aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterfriends.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/newview/llfloaterfriends.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloaterfriends.cpp395
1 files changed, 201 insertions, 194 deletions
diff --git a/linden/indra/newview/llfloaterfriends.cpp b/linden/indra/newview/llfloaterfriends.cpp
index d01a24b..78447e9 100644
--- a/linden/indra/newview/llfloaterfriends.cpp
+++ b/linden/indra/newview/llfloaterfriends.cpp
@@ -63,20 +63,18 @@
63class LLLocalFriendsObserver : public LLFriendObserver 63class LLLocalFriendsObserver : public LLFriendObserver
64{ 64{
65public: 65public:
66 LLLocalFriendsObserver(LLFloaterFriends* floater) : mFloater(floater) {} 66 LLLocalFriendsObserver(LLPanelFriends* floater) : mFloater(floater) {}
67 virtual ~LLLocalFriendsObserver() { mFloater = NULL; } 67 virtual ~LLLocalFriendsObserver() { mFloater = NULL; }
68 virtual void changed(U32 mask) 68 virtual void changed(U32 mask)
69 { 69 {
70 mFloater->updateFriends(mask); 70 mFloater->updateFriends(mask);
71 } 71 }
72protected: 72protected:
73 LLFloaterFriends* mFloater; 73 LLPanelFriends* mFloater;
74}; 74};
75 75
76LLFloaterFriends* LLFloaterFriends::sInstance = NULL; 76LLPanelFriends::LLPanelFriends() :
77 77 LLPanel(),
78LLFloaterFriends::LLFloaterFriends() :
79 LLFloater("Friends"),
80 LLEventTimer(1000000), 78 LLEventTimer(1000000),
81 mObserver(NULL), 79 mObserver(NULL),
82 mMenuState(0), 80 mMenuState(0),
@@ -84,80 +82,38 @@ LLFloaterFriends::LLFloaterFriends() :
84 mAllowRightsChange(TRUE), 82 mAllowRightsChange(TRUE),
85 mNumRightsChanged(0) 83 mNumRightsChanged(0)
86{ 84{
87 mTimer.stop(); 85 mEventTimer.stop();
88 sInstance = this;
89 mObserver = new LLLocalFriendsObserver(this); 86 mObserver = new LLLocalFriendsObserver(this);
90 LLAvatarTracker::instance().addObserver(mObserver); 87 LLAvatarTracker::instance().addObserver(mObserver);
91 gSavedSettings.setBOOL("ShowFriends", TRUE);
92 // Builds and adds to gFloaterView
93 gUICtrlFactory->buildFloater(this, "floater_friends.xml");
94} 88}
95 89
96LLFloaterFriends::~LLFloaterFriends() 90LLPanelFriends::~LLPanelFriends()
97{ 91{
98 LLAvatarTracker::instance().removeObserver(mObserver); 92 LLAvatarTracker::instance().removeObserver(mObserver);
99 delete mObserver; 93 delete mObserver;
100 sInstance = NULL;
101 gSavedSettings.setBOOL("ShowFriends", FALSE);
102} 94}
103 95
104void LLFloaterFriends::tick() 96void LLPanelFriends::tick()
105{ 97{
106 mTimer.stop(); 98 mEventTimer.stop();
107 mPeriod = 1000000; 99 mPeriod = 1000000;
108 mAllowRightsChange = TRUE; 100 mAllowRightsChange = TRUE;
109 updateFriends(LLFriendObserver::ADD); 101 updateFriends(LLFriendObserver::ADD);
110} 102}
111 103
112// static 104void LLPanelFriends::updateFriends(U32 changed_mask)
113void LLFloaterFriends::show(void*)
114{
115 if(sInstance)
116 {
117 sInstance->open(); /*Flawfinder: ignore*/
118 }
119 else
120 {
121 LLFloaterFriends* self = new LLFloaterFriends;
122 self->open(); /*Flawfinder: ignore*/
123 }
124}
125
126
127// static
128BOOL LLFloaterFriends::visible(void*)
129{
130 return sInstance && sInstance->getVisible();
131}
132
133
134// static
135void LLFloaterFriends::toggle(void*)
136{
137 if (sInstance)
138 {
139 sInstance->close();
140 }
141 else
142 {
143 show();
144 }
145}
146
147
148void LLFloaterFriends::updateFriends(U32 changed_mask)
149{ 105{
150 LLUUID selected_id; 106 LLUUID selected_id;
151 LLCtrlListInterface *friends_list = sInstance->childGetListInterface("friend_list"); 107 LLCtrlListInterface *friends_list = childGetListInterface("friend_list");
152 if (!friends_list) return; 108 if (!friends_list) return;
153 LLCtrlScrollInterface *friends_scroll = sInstance->childGetScrollInterface("friend_list"); 109 LLCtrlScrollInterface *friends_scroll = childGetScrollInterface("friend_list");
154 if (!friends_scroll) return; 110 if (!friends_scroll) return;
155 111
156 // We kill the selection warning, otherwise we'll spam with warning popups 112 // We kill the selection warning, otherwise we'll spam with warning popups
157 // if the maximum amount of friends are selected 113 // if the maximum amount of friends are selected
158 mShowMaxSelectWarning = false; 114 mShowMaxSelectWarning = false;
159 115
160 LLDynamicArray<LLUUID> selected_friends = sInstance->getSelectedIDs(); 116 LLDynamicArray<LLUUID> selected_friends = getSelectedIDs();
161 if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE)) 117 if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE))
162 { 118 {
163 refreshNames(); 119 refreshNames();
@@ -168,8 +124,8 @@ void LLFloaterFriends::updateFriends(U32 changed_mask)
168 if(mNumRightsChanged > 0) 124 if(mNumRightsChanged > 0)
169 { 125 {
170 mPeriod = RIGHTS_CHANGE_TIMEOUT; 126 mPeriod = RIGHTS_CHANGE_TIMEOUT;
171 mTimer.start(); 127 mEventTimer.start();
172 mTimer.reset(); 128 mEventTimer.reset();
173 mAllowRightsChange = FALSE; 129 mAllowRightsChange = FALSE;
174 } 130 }
175 else 131 else
@@ -194,12 +150,12 @@ void LLFloaterFriends::updateFriends(U32 changed_mask)
194} 150}
195 151
196// virtual 152// virtual
197BOOL LLFloaterFriends::postBuild() 153BOOL LLPanelFriends::postBuild()
198{ 154{
199
200 mFriendsList = LLUICtrlFactory::getScrollListByName(this, "friend_list"); 155 mFriendsList = LLUICtrlFactory::getScrollListByName(this, "friend_list");
201 mFriendsList->setMaxSelectable(MAX_FRIEND_SELECT); 156 mFriendsList->setMaxSelectable(MAX_FRIEND_SELECT);
202 mFriendsList->setMaxiumumSelectCallback(onMaximumSelect); 157 mFriendsList->setMaxiumumSelectCallback(onMaximumSelect);
158 mFriendsList->setCommitOnSelectionChange(TRUE);
203 childSetCommitCallback("friend_list", onSelectName, this); 159 childSetCommitCallback("friend_list", onSelectName, this);
204 childSetDoubleClickCallback("friend_list", onClickIM); 160 childSetDoubleClickCallback("friend_list", onClickIM);
205 161
@@ -214,14 +170,17 @@ BOOL LLFloaterFriends::postBuild()
214 childSetAction("pay_btn", onClickPay, this); 170 childSetAction("pay_btn", onClickPay, this);
215 childSetAction("add_btn", onClickAddFriend, this); 171 childSetAction("add_btn", onClickAddFriend, this);
216 childSetAction("remove_btn", onClickRemove, this); 172 childSetAction("remove_btn", onClickRemove, this);
217 childSetAction("close_btn", onClickClose, this);
218 173
174 setDefaultBtn("im_btn");
175
176 updateFriends(LLFriendObserver::ADD);
219 refreshUI(); 177 refreshUI();
178
220 return TRUE; 179 return TRUE;
221} 180}
222 181
223 182
224void LLFloaterFriends::addFriend(const std::string& name, const LLUUID& agent_id) 183void LLPanelFriends::addFriend(const std::string& name, const LLUUID& agent_id)
225{ 184{
226 LLAvatarTracker& at = LLAvatarTracker::instance(); 185 LLAvatarTracker& at = LLAvatarTracker::instance();
227 const LLRelationship* relationInfo = at.getBuddyInfo(agent_id); 186 const LLRelationship* relationInfo = at.getBuddyInfo(agent_id);
@@ -275,17 +234,26 @@ void LLFloaterFriends::addFriend(const std::string& name, const LLUUID& agent_id
275 mFriendsList->addElement(element, ADD_BOTTOM); 234 mFriendsList->addElement(element, ADD_BOTTOM);
276} 235}
277 236
278void LLFloaterFriends::refreshRightsChangeList(U8 state) 237void LLPanelFriends::refreshRightsChangeList()
279{ 238{
280 LLDynamicArray<LLUUID> friends = getSelectedIDs(); 239 LLDynamicArray<LLUUID> friends = getSelectedIDs();
281 const LLRelationship* friend_status = NULL; 240 S32 num_selected = friends.size();
282 if(friends.size() > 0) friend_status = LLAvatarTracker::instance().getBuddyInfo(friends[0]);
283 241
284 LLSD row; 242 LLSD row;
285 bool can_change_visibility = false; 243 bool can_offer_teleport = num_selected >= 1;
286 bool can_change_modify = false; 244
287 bool can_change_online_multiple = true; 245 // aggregate permissions over all selected friends
288 bool can_change_map_multiple = true; 246 bool friends_see_online = true;
247 bool friends_see_on_map = true;
248 bool friends_modify_objects = true;
249
250 // do at least some of the friends selected have these rights?
251 bool some_friends_see_online = false;
252 bool some_friends_see_on_map = false;
253 bool some_friends_modify_objects = false;
254
255 bool selected_friends_online = true;
256
289 LLTextBox* processing_label = LLUICtrlFactory::getTextBoxByName(this, "process_rights_label"); 257 LLTextBox* processing_label = LLUICtrlFactory::getTextBoxByName(this, "process_rights_label");
290 258
291 if(!mAllowRightsChange) 259 if(!mAllowRightsChange)
@@ -293,7 +261,9 @@ void LLFloaterFriends::refreshRightsChangeList(U8 state)
293 if(processing_label) 261 if(processing_label)
294 { 262 {
295 processing_label->setVisible(true); 263 processing_label->setVisible(true);
296 state = 0; 264 // ignore selection for now
265 friends.clear();
266 num_selected = 0;
297 } 267 }
298 } 268 }
299 else 269 else
@@ -304,82 +274,111 @@ void LLFloaterFriends::refreshRightsChangeList(U8 state)
304 } 274 }
305 } 275 }
306 276
307 if(state == 1) 277 const LLRelationship* friend_status = NULL;
308 { 278 for(LLDynamicArray<LLUUID>::iterator itr = friends.begin(); itr != friends.end(); ++itr)
309 if(friend_status && !friend_status->isOnline())
310 {
311 childSetEnabled("offer_teleport_btn", false);
312 }
313 can_change_visibility = true;
314 can_change_modify = true;
315 }
316 else if (state == 2)
317 { 279 {
318 can_change_visibility = true; 280 friend_status = LLAvatarTracker::instance().getBuddyInfo(*itr);
319 can_change_modify = false; 281 if (friend_status)
320 for(LLDynamicArray<LLUUID>::iterator itr = friends.begin(); itr != friends.end(); ++itr)
321 { 282 {
322 friend_status = LLAvatarTracker::instance().getBuddyInfo(*itr); 283 bool can_see_online = friend_status->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS);
284 bool can_see_on_map = friend_status->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION);
285 bool can_modify_objects = friend_status->isRightGrantedTo(LLRelationship::GRANT_MODIFY_OBJECTS);
286
287 // aggregate rights of this friend into total selection
288 friends_see_online &= can_see_online;
289 friends_see_on_map &= can_see_on_map;
290 friends_modify_objects &= can_modify_objects;
291
292 // can at least one of your selected friends do any of these?
293 some_friends_see_online |= can_see_online;
294 some_friends_see_on_map |= can_see_on_map;
295 some_friends_modify_objects |= can_modify_objects;
296
323 if(!friend_status->isOnline()) 297 if(!friend_status->isOnline())
324 { 298 {
325 childSetEnabled("offer_teleport_btn", false); 299 can_offer_teleport = false;
326 } 300 selected_friends_online = false;
327 if(!friend_status->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS))
328 {
329 can_change_online_multiple = false;
330 can_change_map_multiple = false;
331 }
332 else if(!friend_status->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION))
333 {
334 can_change_map_multiple = false;
335 } 301 }
336 } 302 }
337 303 else // missing buddy info, don't allow any operations
304 {
305 can_offer_teleport = false;
306
307 friends_see_online = false;
308 friends_see_on_map = false;
309 friends_modify_objects = false;
310
311 some_friends_see_online = false;
312 some_friends_see_on_map = false;
313 some_friends_modify_objects = false;
314 }
338 } 315 }
339 316
340 317
341 LLCheckboxCtrl* check; 318 // seeing a friend on the map requires seeing online status as a prerequisite
319 friends_see_on_map &= friends_see_online;
320
342 mMenuState = 0; 321 mMenuState = 0;
343 322
344 check = LLUICtrlFactory::getCheckBoxByName(this, "online_status_cb"); 323 // make checkboxes visible after we have finished processing rights
345 check->setEnabled(can_change_visibility); 324 childSetVisible("online_status_cb", mAllowRightsChange);
346 check->set(FALSE); 325 childSetVisible("map_status_cb", mAllowRightsChange);
347 if(!mAllowRightsChange) check->setVisible(FALSE); 326 childSetVisible("modify_status_cb", mAllowRightsChange);
348 else check->setVisible(TRUE); 327
349 if(friend_status) 328 if (num_selected == 0) // nothing selected
350 { 329 {
351 check->set(friend_status->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS) && can_change_online_multiple); 330 childSetEnabled("im_btn", FALSE);
352 if(friend_status->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS)) mMenuState |= LLRelationship::GRANT_ONLINE_STATUS; 331 childSetEnabled("offer_teleport_btn", FALSE);
332
333 childSetEnabled("online_status_cb", FALSE);
334 childSetValue("online_status_cb", FALSE);
335 childSetTentative("online_status_cb", FALSE);
336
337 childSetEnabled("map_status_cb", FALSE);
338 childSetValue("map_status_cb", FALSE);
339 childSetTentative("map_status_cb", FALSE);
340
341 childSetEnabled("modify_status_cb", FALSE);
342 childSetValue("modify_status_cb", FALSE);
343 childSetTentative("modify_status_cb", FALSE);
353 } 344 }
354 345 else // we have at least one friend selected...
355 check = LLUICtrlFactory::getCheckBoxByName(this, "map_status_cb");
356 check->setEnabled(false);
357 check->set(FALSE);
358 if(!mAllowRightsChange) check->setVisible(FALSE);
359 else check->setVisible(TRUE);
360 if(friend_status)
361 { 346 {
362 check->setEnabled(friend_status->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS) && can_change_visibility && can_change_online_multiple); 347 // only allow IMs to groups when everyone in the group is online
363 check->set(friend_status->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION) && can_change_map_multiple); 348 // to be consistent with context menus in inventory and because otherwise
364 if(friend_status->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION)) mMenuState |= LLRelationship::GRANT_MAP_LOCATION; 349 // offline friends would be silently dropped from the session
365 } 350 childSetEnabled("im_btn", selected_friends_online || num_selected == 1);
366 351
367 check = LLUICtrlFactory::getCheckBoxByName(this, "modify_status_cb"); 352 childSetEnabled("offer_teleport_btn", can_offer_teleport);
368 check->setEnabled(can_change_modify); 353
369 check->set(FALSE); 354 childSetEnabled("online_status_cb", TRUE);
370 if(!mAllowRightsChange) check->setVisible(FALSE); 355 childSetValue("online_status_cb", some_friends_see_online);
371 else check->setVisible(TRUE); 356 childSetTentative("online_status_cb", some_friends_see_online != friends_see_online);
372 if(can_change_modify) 357 if (friends_see_online)
373 { 358 {
374 if(friend_status) 359 mMenuState |= LLRelationship::GRANT_ONLINE_STATUS;
360 }
361
362 childSetEnabled("map_status_cb", TRUE);
363 childSetValue("map_status_cb", some_friends_see_on_map);
364 childSetTentative("map_status_cb", some_friends_see_on_map != friends_see_on_map);
365 if(friends_see_on_map)
375 { 366 {
376 check->set(friend_status->isRightGrantedTo(LLRelationship::GRANT_MODIFY_OBJECTS)); 367 mMenuState |= LLRelationship::GRANT_MAP_LOCATION;
377 if(friend_status->isRightGrantedTo(LLRelationship::GRANT_MODIFY_OBJECTS)) mMenuState |= LLRelationship::GRANT_MODIFY_OBJECTS; 368 }
369
370 // for now, don't allow modify rights change for multiple select
371 childSetEnabled("modify_status_cb", num_selected == 1);
372 childSetValue("modify_status_cb", some_friends_modify_objects);
373 childSetTentative("modify_status_cb", some_friends_modify_objects != friends_modify_objects);
374 if(friends_modify_objects)
375 {
376 mMenuState |= LLRelationship::GRANT_MODIFY_OBJECTS;
378 } 377 }
379 } 378 }
380} 379}
381 380
382void LLFloaterFriends::refreshNames() 381void LLPanelFriends::refreshNames()
383{ 382{
384 LLDynamicArray<LLUUID> selected_ids = getSelectedIDs(); 383 LLDynamicArray<LLUUID> selected_ids = getSelectedIDs();
385 S32 pos = mFriendsList->getScrollPos(); 384 S32 pos = mFriendsList->getScrollPos();
@@ -409,7 +408,7 @@ void LLFloaterFriends::refreshNames()
409} 408}
410 409
411 410
412void LLFloaterFriends::refreshUI() 411void LLPanelFriends::refreshUI()
413{ 412{
414 BOOL single_selected = FALSE; 413 BOOL single_selected = FALSE;
415 BOOL multiple_selected = FALSE; 414 BOOL multiple_selected = FALSE;
@@ -443,40 +442,34 @@ void LLFloaterFriends::refreshUI()
443 childSetEnabled("im_btn", single_selected); 442 childSetEnabled("im_btn", single_selected);
444 childSetEnabled("friend_rights", single_selected); 443 childSetEnabled("friend_rights", single_selected);
445 444
446 //Note: We reset this in refreshRightsChangeList since we already have to iterate 445 refreshRightsChangeList();
447 //through all selected friends there
448 childSetEnabled("offer_teleport_btn", single_selected);
449
450 refreshRightsChangeList((single_selected + multiple_selected));
451} 446}
452 447
453// static 448LLDynamicArray<LLUUID> LLPanelFriends::getSelectedIDs()
454LLDynamicArray<LLUUID> LLFloaterFriends::getSelectedIDs()
455{ 449{
456 LLUUID selected_id; 450 LLUUID selected_id;
457 LLDynamicArray<LLUUID> friend_ids; 451 LLDynamicArray<LLUUID> friend_ids;
458 if(sInstance) 452 std::vector<LLScrollListItem*> selected = mFriendsList->getAllSelected();
453 for(std::vector<LLScrollListItem*>::iterator itr = selected.begin(); itr != selected.end(); ++itr)
459 { 454 {
460 std::vector<LLScrollListItem*> selected = sInstance->mFriendsList->getAllSelected(); 455 friend_ids.push_back((*itr)->getUUID());
461 for(std::vector<LLScrollListItem*>::iterator itr = selected.begin(); itr != selected.end(); ++itr)
462 {
463 friend_ids.push_back((*itr)->getUUID());
464 }
465 } 456 }
466 return friend_ids; 457 return friend_ids;
467} 458}
468 459
469// static 460// static
470void LLFloaterFriends::onSelectName(LLUICtrl* ctrl, void* user_data) 461void LLPanelFriends::onSelectName(LLUICtrl* ctrl, void* user_data)
471{ 462{
472 if(sInstance) 463 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
464
465 if(panelp)
473 { 466 {
474 sInstance->refreshUI(); 467 panelp->refreshUI();
475 } 468 }
476} 469}
477 470
478//static 471//static
479void LLFloaterFriends::onMaximumSelect(void* user_data) 472void LLPanelFriends::onMaximumSelect(void* user_data)
480{ 473{
481 LLString::format_map_t args; 474 LLString::format_map_t args;
482 args["[MAX_SELECT]"] = llformat("%d", MAX_FRIEND_SELECT); 475 args["[MAX_SELECT]"] = llformat("%d", MAX_FRIEND_SELECT);
@@ -484,10 +477,12 @@ void LLFloaterFriends::onMaximumSelect(void* user_data)
484}; 477};
485 478
486// static 479// static
487void LLFloaterFriends::onClickProfile(void* user_data) 480void LLPanelFriends::onClickProfile(void* user_data)
488{ 481{
489 //llinfos << "LLFloaterFriends::onClickProfile()" << llendl; 482 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
490 LLDynamicArray<LLUUID> ids = getSelectedIDs(); 483
484 //llinfos << "LLPanelFriends::onClickProfile()" << llendl;
485 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
491 if(ids.size() > 0) 486 if(ids.size() > 0)
492 { 487 {
493 LLUUID agent_id = ids[0]; 488 LLUUID agent_id = ids[0];
@@ -498,10 +493,12 @@ void LLFloaterFriends::onClickProfile(void* user_data)
498} 493}
499 494
500// static 495// static
501void LLFloaterFriends::onClickIM(void* user_data) 496void LLPanelFriends::onClickIM(void* user_data)
502{ 497{
503 //llinfos << "LLFloaterFriends::onClickIM()" << llendl; 498 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
504 LLDynamicArray<LLUUID> ids = getSelectedIDs(); 499
500 //llinfos << "LLPanelFriends::onClickIM()" << llendl;
501 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
505 if(ids.size() > 0) 502 if(ids.size() > 0)
506 { 503 {
507 if(ids.size() == 1) 504 if(ids.size() == 1)
@@ -514,8 +511,8 @@ void LLFloaterFriends::onClickIM(void* user_data)
514 { 511 {
515 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 512 char buffer[MAX_STRING]; /* Flawfinder: ignore */
516 snprintf(buffer, MAX_STRING, "%s %s", first, last); /* Flawfinder: ignore */ 513 snprintf(buffer, MAX_STRING, "%s %s", first, last); /* Flawfinder: ignore */
517 gIMView->setFloaterOpen(TRUE); 514 gIMMgr->setFloaterOpen(TRUE);
518 gIMView->addSession( 515 gIMMgr->addSession(
519 buffer, 516 buffer,
520 IM_NOTHING_SPECIAL, 517 IM_NOTHING_SPECIAL,
521 agent_id); 518 agent_id);
@@ -523,17 +520,18 @@ void LLFloaterFriends::onClickIM(void* user_data)
523 } 520 }
524 else 521 else
525 { 522 {
526 gIMView->setFloaterOpen(TRUE); 523 gIMMgr->setFloaterOpen(TRUE);
527 gIMView->addSession("Friends Conference", 524 gIMMgr->addSession("Friends Conference",
528 IM_SESSION_CONFERENCE_START, 525 IM_SESSION_CONFERENCE_START,
529 ids[0], 526 ids[0],
530 ids); 527 ids);
531 } 528 }
529 make_ui_sound("UISndStartIM");
532 } 530 }
533} 531}
534 532
535// static 533// static
536void LLFloaterFriends::requestFriendship(const LLUUID& target_id, const LLString& target_name) 534void LLPanelFriends::requestFriendship(const LLUUID& target_id, const LLString& target_name)
537{ 535{
538 // HACK: folder id stored as "message" 536 // HACK: folder id stored as "message"
539 LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD); 537 LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD);
@@ -552,7 +550,7 @@ struct LLAddFriendData
552}; 550};
553 551
554// static 552// static
555void LLFloaterFriends::callbackAddFriend(S32 option, void* data) 553void LLPanelFriends::callbackAddFriend(S32 option, void* data)
556{ 554{
557 LLAddFriendData* add = (LLAddFriendData*)data; 555 LLAddFriendData* add = (LLAddFriendData*)data;
558 if (option == 0) 556 if (option == 0)
@@ -563,7 +561,7 @@ void LLFloaterFriends::callbackAddFriend(S32 option, void* data)
563} 561}
564 562
565// static 563// static
566void LLFloaterFriends::onPickAvatar(const std::vector<std::string>& names, 564void LLPanelFriends::onPickAvatar(const std::vector<std::string>& names,
567 const std::vector<LLUUID>& ids, 565 const std::vector<LLUUID>& ids,
568 void* ) 566 void* )
569{ 567{
@@ -573,7 +571,7 @@ void LLFloaterFriends::onPickAvatar(const std::vector<std::string>& names,
573} 571}
574 572
575// static 573// static
576void LLFloaterFriends::requestFriendshipDialog(const LLUUID& id, 574void LLPanelFriends::requestFriendshipDialog(const LLUUID& id,
577 const std::string& name) 575 const std::string& name)
578{ 576{
579 if(id == gAgentID) 577 if(id == gAgentID)
@@ -593,16 +591,24 @@ void LLFloaterFriends::requestFriendshipDialog(const LLUUID& id,
593} 591}
594 592
595// static 593// static
596void LLFloaterFriends::onClickAddFriend(void* user_data) 594void LLPanelFriends::onClickAddFriend(void* user_data)
597{ 595{
598 LLFloaterAvatarPicker::show(onPickAvatar, user_data, FALSE, TRUE); 596 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
597 LLFloater* root_floater = gFloaterView->getParentFloater(panelp);
598 LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(onPickAvatar, user_data, FALSE, TRUE);
599 if (root_floater)
600 {
601 root_floater->addDependentFloater(picker);
602 }
599} 603}
600 604
601// static 605// static
602void LLFloaterFriends::onClickRemove(void* user_data) 606void LLPanelFriends::onClickRemove(void* user_data)
603{ 607{
604 //llinfos << "LLFloaterFriends::onClickRemove()" << llendl; 608 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
605 LLDynamicArray<LLUUID> ids = getSelectedIDs(); 609
610 //llinfos << "LLPanelFriends::onClickRemove()" << llendl;
611 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
606 LLStringBase<char>::format_map_t args; 612 LLStringBase<char>::format_map_t args;
607 if(ids.size() > 0) 613 if(ids.size() > 0)
608 { 614 {
@@ -630,9 +636,11 @@ void LLFloaterFriends::onClickRemove(void* user_data)
630} 636}
631 637
632// static 638// static
633void LLFloaterFriends::onClickOfferTeleport(void*) 639void LLPanelFriends::onClickOfferTeleport(void* user_data)
634{ 640{
635 LLDynamicArray<LLUUID> ids = getSelectedIDs(); 641 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
642
643 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
636 if(ids.size() > 0) 644 if(ids.size() > 0)
637 { 645 {
638 handle_lure(ids); 646 handle_lure(ids);
@@ -640,43 +648,40 @@ void LLFloaterFriends::onClickOfferTeleport(void*)
640} 648}
641 649
642// static 650// static
643void LLFloaterFriends::onClickPay(void*) 651void LLPanelFriends::onClickPay(void* user_data)
644{ 652{
645 LLDynamicArray<LLUUID> ids = getSelectedIDs(); 653 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
654
655 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
646 if(ids.size() == 1) 656 if(ids.size() == 1)
647 { 657 {
648 handle_pay_by_id(ids[0]); 658 handle_pay_by_id(ids[0]);
649 } 659 }
650} 660}
651 661
652// static 662void LLPanelFriends::onClickOnlineStatus(LLUICtrl* ctrl, void* user_data)
653void LLFloaterFriends::onClickClose(void* user_data)
654{ 663{
655 //llinfos << "LLFloaterFriends::onClickClose()" << llendl; 664 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
656 if(sInstance)
657 {
658 sInstance->onClose(false);
659 }
660}
661 665
662void LLFloaterFriends::onClickOnlineStatus(LLUICtrl* ctrl, void* user_data)
663{
664 bool checked = ctrl->getValue(); 666 bool checked = ctrl->getValue();
665 sInstance->updateMenuState(LLRelationship::GRANT_ONLINE_STATUS, checked); 667 panelp->updateMenuState(LLRelationship::GRANT_ONLINE_STATUS, checked);
666 sInstance->applyRightsToFriends(LLRelationship::GRANT_ONLINE_STATUS, checked); 668 panelp->applyRightsToFriends(LLRelationship::GRANT_ONLINE_STATUS, checked);
667} 669}
668 670
669void LLFloaterFriends::onClickMapStatus(LLUICtrl* ctrl, void* user_data) 671void LLPanelFriends::onClickMapStatus(LLUICtrl* ctrl, void* user_data)
670{ 672{
673 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
671 bool checked = ctrl->getValue(); 674 bool checked = ctrl->getValue();
672 sInstance->updateMenuState(LLRelationship::GRANT_MAP_LOCATION, checked); 675 panelp->updateMenuState(LLRelationship::GRANT_MAP_LOCATION, checked);
673 sInstance->applyRightsToFriends(LLRelationship::GRANT_MAP_LOCATION, checked); 676 panelp->applyRightsToFriends(LLRelationship::GRANT_MAP_LOCATION, checked);
674} 677}
675 678
676void LLFloaterFriends::onClickModifyStatus(LLUICtrl* ctrl, void* user_data) 679void LLPanelFriends::onClickModifyStatus(LLUICtrl* ctrl, void* user_data)
677{ 680{
681 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
682
678 bool checked = ctrl->getValue(); 683 bool checked = ctrl->getValue();
679 LLDynamicArray<LLUUID> ids = getSelectedIDs(); 684 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
680 LLStringBase<char>::format_map_t args; 685 LLStringBase<char>::format_map_t args;
681 if(ids.size() > 0) 686 if(ids.size() > 0)
682 { 687 {
@@ -690,33 +695,35 @@ void LLFloaterFriends::onClickModifyStatus(LLUICtrl* ctrl, void* user_data)
690 args["[FIRST_NAME]"] = first; 695 args["[FIRST_NAME]"] = first;
691 args["[LAST_NAME]"] = last; 696 args["[LAST_NAME]"] = last;
692 } 697 }
693 if(checked) gViewerWindow->alertXml("GrantModifyRights", args, handleModifyRights, NULL); 698 if(checked) gViewerWindow->alertXml("GrantModifyRights", args, handleModifyRights, user_data);
694 else gViewerWindow->alertXml("RevokeModifyRights", args, handleModifyRights, NULL); 699 else gViewerWindow->alertXml("RevokeModifyRights", args, handleModifyRights, user_data);
695 } 700 }
696 else return; 701 else return;
697 } 702 }
698} 703}
699 704
700void LLFloaterFriends::handleModifyRights(S32 option, void* user_data) 705void LLPanelFriends::handleModifyRights(S32 option, void* user_data)
701{ 706{
702 if(sInstance) 707 LLPanelFriends* panelp = (LLPanelFriends*)user_data;
708
709 if(panelp)
703 { 710 {
704 if(!option) 711 if(!option)
705 { 712 {
706 sInstance->updateMenuState(LLRelationship::GRANT_MODIFY_OBJECTS, !((sInstance->getMenuState() & LLRelationship::GRANT_MODIFY_OBJECTS) != 0)); 713 panelp->updateMenuState(LLRelationship::GRANT_MODIFY_OBJECTS, !((panelp->getMenuState() & LLRelationship::GRANT_MODIFY_OBJECTS) != 0));
707 sInstance->applyRightsToFriends(LLRelationship::GRANT_MODIFY_OBJECTS, ((sInstance->getMenuState() & LLRelationship::GRANT_MODIFY_OBJECTS) != 0)); 714 panelp->applyRightsToFriends(LLRelationship::GRANT_MODIFY_OBJECTS, ((panelp->getMenuState() & LLRelationship::GRANT_MODIFY_OBJECTS) != 0));
708 } 715 }
709 sInstance->refreshUI(); 716 panelp->refreshUI();
710 } 717 }
711} 718}
712 719
713void LLFloaterFriends::updateMenuState(S32 flag, BOOL value) 720void LLPanelFriends::updateMenuState(S32 flag, BOOL value)
714{ 721{
715 if(value) mMenuState |= flag; 722 if(value) mMenuState |= flag;
716 else mMenuState &= ~flag; 723 else mMenuState &= ~flag;
717} 724}
718 725
719void LLFloaterFriends::applyRightsToFriends(S32 flag, BOOL value) 726void LLPanelFriends::applyRightsToFriends(S32 flag, BOOL value)
720{ 727{
721 LLMessageSystem* msg = gMessageSystem; 728 LLMessageSystem* msg = gMessageSystem;
722 msg->newMessageFast(_PREHASH_GrantUserRights); 729 msg->newMessageFast(_PREHASH_GrantUserRights);
@@ -745,7 +752,7 @@ void LLFloaterFriends::applyRightsToFriends(S32 flag, BOOL value)
745 752
746 753
747// static 754// static
748void LLFloaterFriends::handleRemove(S32 option, void* user_data) 755void LLPanelFriends::handleRemove(S32 option, void* user_data)
749{ 756{
750 LLDynamicArray<LLUUID>* ids = static_cast<LLDynamicArray<LLUUID>*>(user_data); 757 LLDynamicArray<LLUUID>* ids = static_cast<LLDynamicArray<LLUUID>*>(user_data);
751 for(LLDynamicArray<LLUUID>::iterator itr = ids->begin(); itr != ids->end(); ++itr) 758 for(LLDynamicArray<LLUUID>::iterator itr = ids->begin(); itr != ids->end(); ++itr)