diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llfloaternewim.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaternewim.cpp | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaternewim.cpp b/linden/indra/newview/llfloaternewim.cpp new file mode 100644 index 0000000..3199eef --- /dev/null +++ b/linden/indra/newview/llfloaternewim.cpp | |||
@@ -0,0 +1,244 @@ | |||
1 | /** | ||
2 | * @file llfloaternewim.cpp | ||
3 | * @brief Panel allowing the user to create a new IM session. | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llfloaternewim.h" | ||
31 | |||
32 | #include "llvieweruictrlfactory.h" | ||
33 | #include "llinstantmessage.h" | ||
34 | #include "sound_ids.h" | ||
35 | #include "audioengine.h" | ||
36 | #include "llfontgl.h" | ||
37 | #include "llnamevalue.h" | ||
38 | |||
39 | #include "llagent.h" | ||
40 | #include "llbutton.h" | ||
41 | #include "llfloater.h" | ||
42 | #include "llfontgl.h" | ||
43 | #include "llimpanel.h" | ||
44 | #include "llkeyboard.h" | ||
45 | #include "llnamelistctrl.h" | ||
46 | #include "llresmgr.h" | ||
47 | #include "lltabcontainer.h" | ||
48 | #include "llimview.h" | ||
49 | #include "lltextbox.h" | ||
50 | |||
51 | extern LLAudioEngine* gAudiop; | ||
52 | extern BOOL gInitializationComplete; | ||
53 | S32 COL_1_WIDTH = 200; | ||
54 | |||
55 | static LLString sOnlineDescriptor = "*"; | ||
56 | static LLString sNameFormat = "[FIRST] [LAST]"; | ||
57 | |||
58 | LLFloaterNewIM::LLFloaterNewIM() | ||
59 | { | ||
60 | gUICtrlFactory->buildFloater(this, "floater_new_im.xml"); | ||
61 | } | ||
62 | |||
63 | BOOL LLFloaterNewIM::postBuild() | ||
64 | { | ||
65 | requires("start_btn", WIDGET_TYPE_BUTTON); | ||
66 | requires("close_btn", WIDGET_TYPE_BUTTON); | ||
67 | requires("user_list", WIDGET_TYPE_NAME_LIST); | ||
68 | requires("online_descriptor", WIDGET_TYPE_TEXT_BOX); | ||
69 | requires("name_format", WIDGET_TYPE_TEXT_BOX); | ||
70 | |||
71 | if (checkRequirements()) | ||
72 | { | ||
73 | childSetAction("start_btn", &LLFloaterNewIM::onStart, this); | ||
74 | childSetAction("close_btn", &LLFloaterNewIM::onClickClose, this); | ||
75 | mSelectionList = LLViewerUICtrlFactory::getNameListByName(this, "user_list"); | ||
76 | mSelectionList->setDoubleClickCallback(&LLFloaterNewIM::onStart); | ||
77 | mSelectionList->setCallbackUserData(this); | ||
78 | sOnlineDescriptor = childGetValue("online_descriptor").asString(); | ||
79 | sNameFormat = childGetValue("name_format").asString(); | ||
80 | setDefaultBtn("start_btn"); | ||
81 | return TRUE; | ||
82 | } | ||
83 | |||
84 | return FALSE; | ||
85 | } | ||
86 | |||
87 | |||
88 | LLFloaterNewIM::~LLFloaterNewIM() | ||
89 | { | ||
90 | clearAllTargets(); | ||
91 | } | ||
92 | |||
93 | |||
94 | void LLFloaterNewIM::clearAllTargets() | ||
95 | { | ||
96 | mSelectionList->deleteAllItems(); | ||
97 | } | ||
98 | |||
99 | void LLFloaterNewIM::addTarget(const LLUUID& uuid, const std::string& name, | ||
100 | void* data, BOOL bold, BOOL online) | ||
101 | { | ||
102 | LLScrollListItem* item = new LLScrollListItem(TRUE, data, uuid); | ||
103 | |||
104 | item->addColumn(name, bold ? LLFontGL::sSansSerifBold : LLFontGL::sSansSerif, COL_1_WIDTH); | ||
105 | if( online ) | ||
106 | { | ||
107 | item->addColumn(sOnlineDescriptor, LLFontGL::sSansSerifBold); | ||
108 | } | ||
109 | |||
110 | mSelectionList->addItem(item); | ||
111 | if (mSelectionList->getFirstSelectedIndex() == -1) | ||
112 | { | ||
113 | mSelectionList->selectFirstItem(); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | void LLFloaterNewIM::addAgent(const LLUUID& uuid, void* data, BOOL online) | ||
118 | { | ||
119 | LLScrollListItem* item = new LLScrollListItem(TRUE, data, uuid); | ||
120 | char first[DB_FIRST_NAME_BUF_SIZE]; | ||
121 | first[0] = '\0'; | ||
122 | char last[DB_LAST_NAME_BUF_SIZE]; | ||
123 | last[0] = '\0'; | ||
124 | gCacheName->getName(uuid, first, last); | ||
125 | LLUIString fullname = sNameFormat; | ||
126 | fullname.setArg("[FIRST]", first); | ||
127 | fullname.setArg("[LAST]", last); | ||
128 | item->addColumn( | ||
129 | fullname, | ||
130 | online ? LLFontGL::sSansSerifBold : LLFontGL::sSansSerif, | ||
131 | COL_1_WIDTH, | ||
132 | FALSE); | ||
133 | if(online) | ||
134 | { | ||
135 | item->addColumn(sOnlineDescriptor, LLFontGL::sSansSerifBold); | ||
136 | } | ||
137 | mSelectionList->addItem(item, ADD_BOTTOM); | ||
138 | if (mSelectionList->getFirstSelectedIndex() == -1) | ||
139 | { | ||
140 | mSelectionList->selectFirstItem(); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | BOOL LLFloaterNewIM::isUUIDAvailable(const LLUUID& uuid) | ||
145 | { | ||
146 | std::vector<LLScrollListItem*> data_list = mSelectionList->getAllData(); | ||
147 | std::vector<LLScrollListItem*>::iterator data_itor; | ||
148 | for (data_itor = data_list.begin(); data_itor != data_list.end(); ++data_itor) | ||
149 | { | ||
150 | LLScrollListItem* item = *data_itor; | ||
151 | if(item->getUUID() == uuid) | ||
152 | { | ||
153 | return TRUE; | ||
154 | } | ||
155 | } | ||
156 | return FALSE; | ||
157 | } | ||
158 | |||
159 | void LLFloaterNewIM::onStart(void* userdata) | ||
160 | { | ||
161 | LLFloaterNewIM* self = (LLFloaterNewIM*) userdata; | ||
162 | |||
163 | LLScrollListItem* item = self->mSelectionList->getFirstSelected(); | ||
164 | if(item) | ||
165 | { | ||
166 | const LLScrollListCell* cell = item->getColumn(0); | ||
167 | LLString name(cell->getText()); | ||
168 | |||
169 | // *NOTE: Do a live detrmination of what type of session it | ||
170 | // should be. If we restrict the new im panel to online users, | ||
171 | // then we can remove some of this code. | ||
172 | EInstantMessage type; | ||
173 | EInstantMessage* t = (EInstantMessage*)item->getUserdata(); | ||
174 | if(t) type = (*t); | ||
175 | else type = LLIMView::defaultIMTypeForAgent(item->getUUID()); | ||
176 | gIMView->addSession(name, type, item->getUUID()); | ||
177 | |||
178 | make_ui_sound("UISndStartIM"); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | make_ui_sound("UISndInvalidOp"); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | |||
187 | // static | ||
188 | void LLFloaterNewIM::onClickClose(void *userdata) | ||
189 | { | ||
190 | gIMView->setFloaterOpen(FALSE); | ||
191 | } | ||
192 | |||
193 | |||
194 | BOOL LLFloaterNewIM::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | ||
195 | { | ||
196 | BOOL handled = LLFloater::handleKeyHere(key, mask, called_from_parent); | ||
197 | if (getVisible() && mEnabled && !called_from_parent) | ||
198 | { | ||
199 | if ( KEY_ESCAPE == key ) | ||
200 | { | ||
201 | handled = TRUE; | ||
202 | // Close talk panel on escape | ||
203 | gIMView->toggle(NULL); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | // Might need to call base class here if not handled | ||
208 | return handled; | ||
209 | } | ||
210 | |||
211 | BOOL LLFloaterNewIM::canClose() | ||
212 | { | ||
213 | if (getHost()) | ||
214 | { | ||
215 | LLMultiFloater* hostp = (LLMultiFloater*)getHost(); | ||
216 | // if we are the only tab in the im view, go ahead and close | ||
217 | return hostp->getFloaterCount() == 1; | ||
218 | } | ||
219 | return TRUE; | ||
220 | } | ||
221 | |||
222 | void LLFloaterNewIM::close(bool app_quitting) | ||
223 | { | ||
224 | if (getHost()) | ||
225 | { | ||
226 | LLMultiFloater* hostp = (LLMultiFloater*)getHost(); | ||
227 | hostp->close(); | ||
228 | } | ||
229 | else | ||
230 | { | ||
231 | // this shouldn't be called, because we are always hosted | ||
232 | LLFloater::close(app_quitting); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | S32 LLFloaterNewIM::getScrollPos() | ||
237 | { | ||
238 | return mSelectionList->getScrollPos(); | ||
239 | } | ||
240 | |||
241 | void LLFloaterNewIM::setScrollPos( S32 pos ) | ||
242 | { | ||
243 | mSelectionList->setScrollPos( pos ); | ||
244 | } | ||