diff options
author | McCabe Maxsted | 2009-09-11 00:33:33 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-09-11 00:33:33 -0700 |
commit | efa0d701845542e9ef555260fe6d2ad0beeb0760 (patch) | |
tree | 4527fe04a062d3353e4d1a77c547d1c2b1d475e9 /linden/indra/newview/llfloaterobjectiminfo.cpp | |
parent | Fixed missing 'm' for draw distance slider (diff) | |
download | meta-impy-efa0d701845542e9ef555260fe6d2ad0beeb0760.zip meta-impy-efa0d701845542e9ef555260fe6d2ad0beeb0760.tar.gz meta-impy-efa0d701845542e9ef555260fe6d2ad0beeb0760.tar.bz2 meta-impy-efa0d701845542e9ef555260fe6d2ad0beeb0760.tar.xz |
Backported clickable object names from 1.23
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterobjectiminfo.cpp | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterobjectiminfo.cpp b/linden/indra/newview/llfloaterobjectiminfo.cpp new file mode 100644 index 0000000..6cbc4e2 --- /dev/null +++ b/linden/indra/newview/llfloaterobjectiminfo.cpp | |||
@@ -0,0 +1,204 @@ | |||
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
34 | #include "llfloaterobjectiminfo.h" | ||
35 | |||
36 | #include "llagentdata.h" | ||
37 | #include "llcachename.h" | ||
38 | #include "llcommandhandler.h" | ||
39 | #include "llfloater.h" | ||
40 | #include "llfloateravatarinfo.h" | ||
41 | #include "llfloatergroupinfo.h" | ||
42 | #include "llfloatermute.h" | ||
43 | #include "llmutelist.h" | ||
44 | #include "llsdutil.h" | ||
45 | #include "lluictrlfactory.h" | ||
46 | #include "llurldispatcher.h" | ||
47 | #include "llviewercontrol.h" | ||
48 | |||
49 | //////////////////////////////////////////////////////////////////////////// | ||
50 | // LLFloaterObjectIMInfo | ||
51 | class LLFloaterObjectIMInfo : public LLFloater, public LLFloaterSingleton<LLFloaterObjectIMInfo> | ||
52 | { | ||
53 | public: | ||
54 | LLFloaterObjectIMInfo(const LLSD& sd); | ||
55 | virtual ~LLFloaterObjectIMInfo() { }; | ||
56 | |||
57 | BOOL postBuild(void); | ||
58 | |||
59 | void update(const LLUUID& id, const std::string& name, const std::string& slurl, const LLUUID& owner, bool owner_is_group); | ||
60 | |||
61 | // UI Handlers | ||
62 | static void onClickMap(void* data); | ||
63 | static void onClickOwner(void* data); | ||
64 | static void onClickMute(void* data); | ||
65 | |||
66 | static void nameCallback(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data); | ||
67 | |||
68 | private: | ||
69 | LLUUID mObjectID; | ||
70 | std::string mObjectName; | ||
71 | std::string mSlurl; | ||
72 | LLUUID mOwnerID; | ||
73 | std::string mOwnerName; | ||
74 | bool mOwnerIsGroup; | ||
75 | }; | ||
76 | |||
77 | LLFloaterObjectIMInfo::LLFloaterObjectIMInfo(const LLSD& seed) | ||
78 | : mObjectID(), mObjectName(), mSlurl(), mOwnerID(), mOwnerName(), mOwnerIsGroup(false) | ||
79 | { | ||
80 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_object_im_info.xml"); | ||
81 | |||
82 | if (getRect().mLeft == 0 | ||
83 | && getRect().mBottom == 0) | ||
84 | { | ||
85 | center(); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | BOOL LLFloaterObjectIMInfo::postBuild(void) | ||
90 | { | ||
91 | childSetAction("Mute",onClickMute,this); | ||
92 | childSetActionTextbox("OwnerName",onClickOwner, this); | ||
93 | childSetActionTextbox("Slurl",onClickMap, this); | ||
94 | |||
95 | return true; | ||
96 | } | ||
97 | |||
98 | void LLFloaterObjectIMInfo::update(const LLUUID& object_id, const std::string& name, const std::string& slurl, const LLUUID& owner_id, bool owner_is_group) | ||
99 | { | ||
100 | // When talking to an old region we won't have a slurl. | ||
101 | // The object id isn't really the object id either but we don't use it so who cares. | ||
102 | bool have_slurl = !slurl.empty(); | ||
103 | childSetVisible("Unknown_Slurl",!have_slurl); | ||
104 | childSetVisible("Slurl",have_slurl); | ||
105 | |||
106 | childSetText("ObjectName",name); | ||
107 | childSetText("Slurl",slurl); | ||
108 | childSetText("OwnerName",std::string("")); | ||
109 | |||
110 | bool my_object = (owner_id == gAgentID); | ||
111 | childSetEnabled("Mute",!my_object); | ||
112 | |||
113 | mObjectID = object_id; | ||
114 | mObjectName = name; | ||
115 | mSlurl = slurl; | ||
116 | mOwnerID = owner_id; | ||
117 | mOwnerIsGroup = owner_is_group; | ||
118 | |||
119 | if (gCacheName) gCacheName->get(owner_id,owner_is_group,nameCallback,this); | ||
120 | } | ||
121 | |||
122 | //static | ||
123 | void LLFloaterObjectIMInfo::onClickMap(void* data) | ||
124 | { | ||
125 | LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data; | ||
126 | |||
127 | std::ostringstream link; | ||
128 | link << "secondlife://" << self->mSlurl; | ||
129 | LLURLDispatcher::dispatch(link.str(),false); | ||
130 | } | ||
131 | |||
132 | //static | ||
133 | void LLFloaterObjectIMInfo::onClickOwner(void* data) | ||
134 | { | ||
135 | LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data; | ||
136 | if (self->mOwnerIsGroup) | ||
137 | { | ||
138 | LLFloaterGroupInfo::showFromUUID(self->mOwnerID); | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | LLFloaterAvatarInfo::showFromObject(self->mOwnerID); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | //static | ||
147 | void LLFloaterObjectIMInfo::onClickMute(void* data) | ||
148 | { | ||
149 | LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data; | ||
150 | |||
151 | LLMute::EType mute_type = (self->mOwnerIsGroup) ? LLMute::GROUP : LLMute::AGENT; | ||
152 | LLMute mute(self->mOwnerID, self->mOwnerName, mute_type); | ||
153 | LLMuteList::getInstance()->add(mute); | ||
154 | LLFloaterMute::showInstance(); | ||
155 | self->close(); | ||
156 | } | ||
157 | |||
158 | //static | ||
159 | void LLFloaterObjectIMInfo::nameCallback(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data) | ||
160 | { | ||
161 | LLFloaterObjectIMInfo* self = (LLFloaterObjectIMInfo*)data; | ||
162 | self->mOwnerName = first; | ||
163 | if (!last.empty()) | ||
164 | { | ||
165 | self->mOwnerName += " " + last; | ||
166 | } | ||
167 | |||
168 | self->childSetText("OwnerName",self->mOwnerName); | ||
169 | } | ||
170 | |||
171 | //////////////////////////////////////////////////////////////////////////// | ||
172 | // LLObjectIMInfo | ||
173 | void LLObjectIMInfo::show(const LLUUID &object_id, const std::string &name, const std::string &location, const LLUUID &owner_id, bool owner_is_group) | ||
174 | { | ||
175 | LLFloaterObjectIMInfo* im_info_floater = LLFloaterObjectIMInfo::showInstance(); | ||
176 | im_info_floater->update(object_id,name,location,owner_id,owner_is_group); | ||
177 | } | ||
178 | |||
179 | //////////////////////////////////////////////////////////////////////////// | ||
180 | // LLObjectIMInfoHandler | ||
181 | class LLObjectIMInfoHandler : public LLCommandHandler | ||
182 | { | ||
183 | public: | ||
184 | LLObjectIMInfoHandler() : LLCommandHandler("objectim", false) { } | ||
185 | |||
186 | bool handle(const LLSD& tokens, const LLSD& query_map); | ||
187 | }; | ||
188 | |||
189 | // Creating the object registers with the dispatcher. | ||
190 | LLObjectIMInfoHandler gObjectIMHandler; | ||
191 | |||
192 | // ex. secondlife:///app/objectim/9426adfc-9c17-8765-5f09-fdf19957d003?owner=a112d245-9095-4e9c-ace4-ffa31717f934&groupowned=true&slurl=ahern/123/123/123&name=Object | ||
193 | bool LLObjectIMInfoHandler::handle(const LLSD &tokens, const LLSD &query_map) | ||
194 | { | ||
195 | LLUUID task_id = tokens[0].asUUID(); | ||
196 | std::string name = query_map["name"].asString(); | ||
197 | std::string slurl = query_map["slurl"].asString(); | ||
198 | LLUUID owner = query_map["owner"].asUUID(); | ||
199 | bool group_owned = query_map.has("groupowned"); | ||
200 | |||
201 | LLObjectIMInfo::show(task_id,name,slurl,owner,group_owned); | ||
202 | |||
203 | return true; | ||
204 | } | ||