aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterobjectiminfo.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llfloaterobjectiminfo.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/newview/llfloaterobjectiminfo.cpp')
-rw-r--r--linden/indra/newview/llfloaterobjectiminfo.cpp207
1 files changed, 207 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterobjectiminfo.cpp b/linden/indra/newview/llfloaterobjectiminfo.cpp
new file mode 100644
index 0000000..7ef3af2
--- /dev/null
+++ b/linden/indra/newview/llfloaterobjectiminfo.cpp
@@ -0,0 +1,207 @@
1/**
2 * @file llfloaterobjectiminfo.cpp
3 * @brief A floater with information about an object that sent an IM.
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#include "llviewerprecompiledheaders.h"
34
35#include "llfloaterobjectiminfo.h"
36
37#include "llagentdata.h"
38#include "llcachename.h"
39#include "llcommandhandler.h"
40#include "llfloater.h"
41#include "llfloateravatarinfo.h"
42#include "llfloatergroupinfo.h"
43#include "llfloatermute.h"
44#include "llmutelist.h"
45#include "llsdutil.h"
46#include "lluictrlfactory.h"
47#include "llurldispatcher.h"
48#include "llviewercontrol.h"
49
50////////////////////////////////////////////////////////////////////////////
51// LLFloaterObjectIMInfo
52class LLFloaterObjectIMInfo : public LLFloater, public LLFloaterSingleton<LLFloaterObjectIMInfo>
53{
54public:
55 LLFloaterObjectIMInfo(const LLSD& sd);
56 virtual ~LLFloaterObjectIMInfo() { };
57
58 BOOL postBuild(void);
59
60 void update(const LLUUID& id, const std::string& name, const std::string& slurl, const LLUUID& owner, bool owner_is_group);
61
62 // UI Handlers
63 static void onClickMap(void* data);
64 static void onClickOwner(void* data);
65 static void onClickMute(void* data);
66
67 static void nameCallback(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data);
68
69private:
70 LLUUID mObjectID;
71 std::string mObjectName;
72 std::string mSlurl;
73 LLUUID mOwnerID;
74 std::string mOwnerName;
75 bool mOwnerIsGroup;
76};
77
78LLFloaterObjectIMInfo::LLFloaterObjectIMInfo(const LLSD& seed)
79: mObjectID(), mObjectName(), mSlurl(), mOwnerID(), mOwnerName(), mOwnerIsGroup(false)
80{
81 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_object_im_info.xml");
82
83 if (getRect().mLeft == 0
84 && getRect().mBottom == 0)
85 {
86 center();
87 }
88}
89
90BOOL LLFloaterObjectIMInfo::postBuild(void)
91{
92 childSetAction("Mute",onClickMute,this);
93 childSetActionTextbox("OwnerName",onClickOwner, this);
94 childSetActionTextbox("Slurl",onClickMap, this);
95
96 return true;
97}
98
99void LLFloaterObjectIMInfo::update(const LLUUID& object_id, const std::string& name, const std::string& slurl, const LLUUID& owner_id, bool owner_is_group)
100{
101 // When talking to an old region we won't have a slurl.
102 // The object id isn't really the object id either but we don't use it so who cares.
103 bool have_slurl = !slurl.empty();
104 childSetVisible("Unknown_Slurl",!have_slurl);
105 childSetVisible("Slurl",have_slurl);
106
107 childSetText("ObjectName",name);
108 childSetText("Slurl",slurl);
109 childSetText("OwnerName",std::string(""));
110
111 bool my_object = (owner_id == gAgentID);
112 childSetEnabled("Mute",!my_object);
113
114 mObjectID = object_id;
115 mObjectName = name;
116 mSlurl = slurl;
117 mOwnerID = owner_id;
118 mOwnerIsGroup = owner_is_group;
119
120 if (gCacheName) gCacheName->get(owner_id,owner_is_group,nameCallback,this);
121}
122
123//static
124void LLFloaterObjectIMInfo::onClickMap(void* data)
125{
126 LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data;
127
128 std::ostringstream link;
129 link << "secondlife://" << self->mSlurl;
130 class LLWebBrowserCtrl* web = NULL;
131 LLURLDispatcher::dispatch(link.str(), web, true);
132}
133
134//static
135void LLFloaterObjectIMInfo::onClickOwner(void* data)
136{
137 LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data;
138 if (self->mOwnerIsGroup)
139 {
140 LLFloaterGroupInfo::showFromUUID(self->mOwnerID);
141 }
142 else
143 {
144 LLFloaterAvatarInfo::showFromObject(self->mOwnerID);
145 }
146}
147
148//static
149void LLFloaterObjectIMInfo::onClickMute(void* data)
150{
151 LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data;
152
153 LLMute::EType mute_type = (self->mOwnerIsGroup) ? LLMute::GROUP : LLMute::AGENT;
154 LLMute mute(self->mOwnerID, self->mOwnerName, mute_type);
155 LLMuteList::getInstance()->add(mute);
156 LLFloaterMute::showInstance();
157 self->close();
158}
159
160//static
161void LLFloaterObjectIMInfo::nameCallback(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data)
162{
163 LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data;
164 self->mOwnerName = first;
165 if (!last.empty())
166 {
167 self->mOwnerName += " " + last;
168 }
169
170 self->childSetText("OwnerName",self->mOwnerName);
171}
172
173////////////////////////////////////////////////////////////////////////////
174// LLObjectIMInfo
175void LLObjectIMInfo::show(const LLUUID &object_id, const std::string &name, const std::string &location, const LLUUID &owner_id, bool owner_is_group)
176{
177 LLFloaterObjectIMInfo* im_info_floater = LLFloaterObjectIMInfo::showInstance();
178 im_info_floater->update(object_id,name,location,owner_id,owner_is_group);
179}
180
181////////////////////////////////////////////////////////////////////////////
182// LLObjectIMInfoHandler
183class LLObjectIMInfoHandler : public LLCommandHandler
184{
185public:
186 LLObjectIMInfoHandler() : LLCommandHandler("objectim", true) { }
187
188 bool handle(const LLSD& tokens, const LLSD& query_map,
189 LLWebBrowserCtrl* web);
190};
191
192// Creating the object registers with the dispatcher.
193LLObjectIMInfoHandler gObjectIMHandler;
194
195// ex. secondlife:///app/objectim/9426adfc-9c17-8765-5f09-fdf19957d003?owner=a112d245-9095-4e9c-ace4-ffa31717f934&groupowned=true&slurl=ahern/123/123/123&name=Object
196bool LLObjectIMInfoHandler::handle(const LLSD &tokens, const LLSD &query_map, LLWebBrowserCtrl* web)
197{
198 LLUUID task_id = tokens[0].asUUID();
199 std::string name = query_map["name"].asString();
200 std::string slurl = query_map["slurl"].asString();
201 LLUUID owner = query_map["owner"].asUUID();
202 bool group_owned = query_map.has("groupowned");
203
204 LLObjectIMInfo::show(task_id,name,slurl,owner,group_owned);
205
206 return true;
207}