aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterfriends.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llfloaterfriends.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llfloaterfriends.cpp')
-rw-r--r--linden/indra/newview/llfloaterfriends.cpp141
1 files changed, 88 insertions, 53 deletions
diff --git a/linden/indra/newview/llfloaterfriends.cpp b/linden/indra/newview/llfloaterfriends.cpp
index 97b7131..7f6bf01 100644
--- a/linden/indra/newview/llfloaterfriends.cpp
+++ b/linden/indra/newview/llfloaterfriends.cpp
@@ -44,7 +44,6 @@
44#include "llfloateravatarpicker.h" 44#include "llfloateravatarpicker.h"
45#include "llviewerwindow.h" 45#include "llviewerwindow.h"
46#include "llbutton.h" 46#include "llbutton.h"
47#include "llcallingcard.h"
48#include "llfloateravatarinfo.h" 47#include "llfloateravatarinfo.h"
49#include "llinventorymodel.h" 48#include "llinventorymodel.h"
50#include "llnamelistctrl.h" 49#include "llnamelistctrl.h"
@@ -143,7 +142,7 @@ void LLPanelFriends::updateFriends(U32 changed_mask)
143 LLDynamicArray<LLUUID> selected_friends = getSelectedIDs(); 142 LLDynamicArray<LLUUID> selected_friends = getSelectedIDs();
144 if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE)) 143 if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE))
145 { 144 {
146 refreshNames(); 145 refreshNames(changed_mask);
147 } 146 }
148 else if(changed_mask & LLFriendObserver::POWERS) 147 else if(changed_mask & LLFriendObserver::POWERS)
149 { 148 {
@@ -185,7 +184,8 @@ BOOL LLPanelFriends::postBuild()
185 childSetCommitCallback("friend_list", onSelectName, this); 184 childSetCommitCallback("friend_list", onSelectName, this);
186 childSetDoubleClickCallback("friend_list", onClickIM); 185 childSetDoubleClickCallback("friend_list", onClickIM);
187 186
188 refreshNames(); 187 U32 changed_mask = LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE;
188 refreshNames(changed_mask);
189 189
190 childSetAction("im_btn", onClickIM, this); 190 childSetAction("im_btn", onClickIM, this);
191 childSetAction("profile_btn", onClickProfile, this); 191 childSetAction("profile_btn", onClickProfile, this);
@@ -200,13 +200,12 @@ BOOL LLPanelFriends::postBuild()
200 refreshUI(); 200 refreshUI();
201 201
202 // primary sort = online status, secondary sort = name 202 // primary sort = online status, secondary sort = name
203 mFriendsList->sortByColumn("friend_name", TRUE); 203 mFriendsList->sortByColumn(std::string("friend_name"), TRUE);
204 mFriendsList->sortByColumn("icon_online_status", FALSE); 204 mFriendsList->sortByColumn(std::string("icon_online_status"), FALSE);
205 205
206 return TRUE; 206 return TRUE;
207} 207}
208 208
209
210BOOL LLPanelFriends::addFriend(const LLUUID& agent_id) 209BOOL LLPanelFriends::addFriend(const LLUUID& agent_id)
211{ 210{
212 LLAvatarTracker& at = LLAvatarTracker::instance(); 211 LLAvatarTracker& at = LLAvatarTracker::instance();
@@ -264,7 +263,8 @@ BOOL LLPanelFriends::addFriend(const LLUUID& agent_id)
264 return have_name; 263 return have_name;
265} 264}
266 265
267// propagate actual relationship to UI 266// propagate actual relationship to UI.
267// Does not resort the UI list because it can be called frequently. JC
268BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationship* info) 268BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationship* info)
269{ 269{
270 if (!info) return FALSE; 270 if (!info) return FALSE;
@@ -274,7 +274,7 @@ BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationsh
274 std::string fullname; 274 std::string fullname;
275 BOOL have_name = gCacheName->getFullName(agent_id, fullname); 275 BOOL have_name = gCacheName->getFullName(agent_id, fullname);
276 276
277 itemp->getColumn(LIST_ONLINE_STATUS)->setValue(info->isOnline() ? "icon_avatar_online.tga" : LLString::null); 277 itemp->getColumn(LIST_ONLINE_STATUS)->setValue(info->isOnline() ? std::string("icon_avatar_online.tga") : LLStringUtil::null);
278 itemp->getColumn(LIST_FRIEND_NAME)->setValue(fullname); 278 itemp->getColumn(LIST_FRIEND_NAME)->setValue(fullname);
279 // render name of online friends in bold text 279 // render name of online friends in bold text
280 ((LLScrollListText*)itemp->getColumn(LIST_FRIEND_NAME))->setFontStyle(info->isOnline() ? LLFontGL::BOLD : LLFontGL::NORMAL); 280 ((LLScrollListText*)itemp->getColumn(LIST_FRIEND_NAME))->setFontStyle(info->isOnline() ? LLFontGL::BOLD : LLFontGL::NORMAL);
@@ -287,9 +287,7 @@ BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationsh
287 // enable this item, in case it was disabled after user input 287 // enable this item, in case it was disabled after user input
288 itemp->setEnabled(TRUE); 288 itemp->setEnabled(TRUE);
289 289
290 // changed item in place, need to request sort 290 // Do not resort, this function can be called frequently.
291 mFriendsList->sortItems();
292
293 return have_name; 291 return have_name;
294} 292}
295 293
@@ -359,7 +357,7 @@ struct SortFriendsByID
359 } 357 }
360}; 358};
361 359
362void LLPanelFriends::refreshNames() 360void LLPanelFriends::refreshNames(U32 changed_mask)
363{ 361{
364 LLDynamicArray<LLUUID> selected_ids = getSelectedIDs(); 362 LLDynamicArray<LLUUID> selected_ids = getSelectedIDs();
365 S32 pos = mFriendsList->getScrollPos(); 363 S32 pos = mFriendsList->getScrollPos();
@@ -367,27 +365,67 @@ void LLPanelFriends::refreshNames()
367 // get all buddies we know about 365 // get all buddies we know about
368 LLAvatarTracker::buddy_map_t all_buddies; 366 LLAvatarTracker::buddy_map_t all_buddies;
369 LLAvatarTracker::instance().copyBuddyList(all_buddies); 367 LLAvatarTracker::instance().copyBuddyList(all_buddies);
370 368
371 // get all friends in list and sort by UUID 369 BOOL have_names = TRUE;
370
371 if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE))
372 {
373 have_names &= refreshNamesSync(all_buddies);
374 }
375
376 if(changed_mask & LLFriendObserver::ONLINE)
377 {
378 have_names &= refreshNamesPresence(all_buddies);
379 }
380
381 if (!have_names)
382 {
383 mEventTimer.start();
384 }
385 // Changed item in place, need to request sort and update columns
386 // because we might have changed data in a column on which the user
387 // has already sorted. JC
388 mFriendsList->sortItems();
389
390 // re-select items
391 mFriendsList->selectMultiple(selected_ids);
392 mFriendsList->setScrollPos(pos);
393}
394
395BOOL LLPanelFriends::refreshNamesSync(const LLAvatarTracker::buddy_map_t & all_buddies)
396{
397 mFriendsList->deleteAllItems();
398
399 BOOL have_names = TRUE;
400 LLAvatarTracker::buddy_map_t::const_iterator buddy_it = all_buddies.begin();
401
402 for(; buddy_it != all_buddies.end(); ++buddy_it)
403 {
404 have_names &= addFriend(buddy_it->first);
405 }
406
407 return have_names;
408}
409
410BOOL LLPanelFriends::refreshNamesPresence(const LLAvatarTracker::buddy_map_t & all_buddies)
411{
372 std::vector<LLScrollListItem*> items = mFriendsList->getAllData(); 412 std::vector<LLScrollListItem*> items = mFriendsList->getAllData();
373 std::sort(items.begin(), items.end(), SortFriendsByID()); 413 std::sort(items.begin(), items.end(), SortFriendsByID());
374 414
375 std::vector<LLScrollListItem*>::iterator item_it = items.begin(); 415 LLAvatarTracker::buddy_map_t::const_iterator buddy_it = all_buddies.begin();
376 std::vector<LLScrollListItem*>::iterator item_end = items.end(); 416 std::vector<LLScrollListItem*>::const_iterator item_it = items.begin();
377
378 BOOL have_names = TRUE; 417 BOOL have_names = TRUE;
379 LLAvatarTracker::buddy_map_t::iterator buddy_it; 418
380 for (buddy_it = all_buddies.begin() ; buddy_it != all_buddies.end(); ++buddy_it) 419 while(true)
381 { 420 {
382 // erase any items that reflect residents who are no longer buddies 421 if(item_it == items.end() || buddy_it == all_buddies.end())
383 while(item_it != item_end && buddy_it->first > (*item_it)->getValue().asUUID())
384 { 422 {
385 mFriendsList->deleteItems((*item_it)->getValue()); 423 break;
386 ++item_it;
387 } 424 }
388 425
389 // update existing friends with new info 426 const LLUUID & buddy_uuid = buddy_it->first;
390 if (item_it != item_end && buddy_it->first == (*item_it)->getValue().asUUID()) 427 const LLUUID & item_uuid = (*item_it)->getValue().asUUID();
428 if(item_uuid == buddy_uuid)
391 { 429 {
392 const LLRelationship* info = buddy_it->second; 430 const LLRelationship* info = buddy_it->second;
393 if (!info) 431 if (!info)
@@ -402,27 +440,23 @@ void LLPanelFriends::refreshNames()
402 // update existing item in UI 440 // update existing item in UI
403 have_names &= updateFriendItem(buddy_it->first, info); 441 have_names &= updateFriendItem(buddy_it->first, info);
404 } 442 }
443
444 ++buddy_it;
405 ++item_it; 445 ++item_it;
406 } 446 }
407 // add new friend to list 447 else if(item_uuid < buddy_uuid)
408 else
409 { 448 {
410 have_names &= addFriend(buddy_it->first); 449 ++item_it;
450 }
451 else //if(item_uuid > buddy_uuid)
452 {
453 ++buddy_it;
411 } 454 }
412 } 455 }
413 if (!have_names)
414 {
415 mEventTimer.start();
416 }
417 // changed item in place, need to request sort and update columns
418 mFriendsList->sortItems();
419 456
420 // re-select items 457 return have_names;
421 mFriendsList->selectMultiple(selected_ids);
422 mFriendsList->setScrollPos(pos);
423} 458}
424 459
425
426void LLPanelFriends::refreshUI() 460void LLPanelFriends::refreshUI()
427{ 461{
428 BOOL single_selected = FALSE; 462 BOOL single_selected = FALSE;
@@ -443,7 +477,7 @@ void LLPanelFriends::refreshUI()
443 } 477 }
444 else 478 else
445 { 479 {
446 childSetText("friend_name_label", LLString::null); 480 childSetText("friend_name_label", LLStringUtil::null);
447 } 481 }
448 482
449 483
@@ -488,7 +522,7 @@ void LLPanelFriends::onSelectName(LLUICtrl* ctrl, void* user_data)
488//static 522//static
489void LLPanelFriends::onMaximumSelect(void* user_data) 523void LLPanelFriends::onMaximumSelect(void* user_data)
490{ 524{
491 LLString::format_map_t args; 525 LLStringUtil::format_map_t args;
492 args["[MAX_SELECT]"] = llformat("%d", MAX_FRIEND_SELECT); 526 args["[MAX_SELECT]"] = llformat("%d", MAX_FRIEND_SELECT);
493 LLNotifyBox::showXml("MaxListSelectMessage", args); 527 LLNotifyBox::showXml("MaxListSelectMessage", args);
494}; 528};
@@ -539,16 +573,15 @@ void LLPanelFriends::onClickIM(void* user_data)
539} 573}
540 574
541// static 575// static
542void LLPanelFriends::requestFriendship(const LLUUID& target_id, const LLString& target_name) 576void LLPanelFriends::requestFriendship(const LLUUID& target_id, const std::string& target_name, const std::string& message)
543{ 577{
544 // HACK: folder id stored as "message"
545 LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD); 578 LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD);
546 std::string message = calling_card_folder_id.asString();
547 send_improved_im(target_id, 579 send_improved_im(target_id,
548 target_name.c_str(), 580 target_name,
549 message.c_str(), 581 message,
550 IM_ONLINE, 582 IM_ONLINE,
551 IM_FRIENDSHIP_OFFERED); 583 IM_FRIENDSHIP_OFFERED,
584 calling_card_folder_id);
552} 585}
553 586
554struct LLAddFriendData 587struct LLAddFriendData
@@ -558,12 +591,12 @@ struct LLAddFriendData
558}; 591};
559 592
560// static 593// static
561void LLPanelFriends::callbackAddFriend(S32 option, void* data) 594void LLPanelFriends::callbackAddFriend(S32 option, const std::string& text, void* data)
562{ 595{
563 LLAddFriendData* add = (LLAddFriendData*)data; 596 LLAddFriendData* add = (LLAddFriendData*)data;
564 if (option == 0) 597 if (option == 0)
565 { 598 {
566 requestFriendship(add->mID, add->mName); 599 requestFriendship(add->mID, add->mName, text);
567 } 600 }
568 delete add; 601 delete add;
569} 602}
@@ -593,9 +626,9 @@ void LLPanelFriends::requestFriendshipDialog(const LLUUID& id,
593 data->mName = name; 626 data->mName = name;
594 627
595 // TODO: accept a line of text with this dialog 628 // TODO: accept a line of text with this dialog
596 LLString::format_map_t args; 629 LLStringUtil::format_map_t args;
597 args["[NAME]"] = name; 630 args["[NAME]"] = name;
598 gViewerWindow->alertXml("AddFriend", args, callbackAddFriend, data); 631 gViewerWindow->alertXmlEditText("AddFriend", args, NULL, NULL, callbackAddFriend, data);
599} 632}
600 633
601// static 634// static
@@ -617,10 +650,10 @@ void LLPanelFriends::onClickRemove(void* user_data)
617 650
618 //llinfos << "LLPanelFriends::onClickRemove()" << llendl; 651 //llinfos << "LLPanelFriends::onClickRemove()" << llendl;
619 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs(); 652 LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
620 LLStringBase<char>::format_map_t args; 653 LLStringUtil::format_map_t args;
621 if(ids.size() > 0) 654 if(ids.size() > 0)
622 { 655 {
623 LLString msgType = "RemoveFromFriends"; 656 std::string msgType = "RemoveFromFriends";
624 if(ids.size() == 1) 657 if(ids.size() == 1)
625 { 658 {
626 LLUUID agent_id = ids[0]; 659 LLUUID agent_id = ids[0];
@@ -670,7 +703,7 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command
670{ 703{
671 if (ids.empty()) return; 704 if (ids.empty()) return;
672 705
673 LLStringBase<char>::format_map_t args; 706 LLStringUtil::format_map_t args;
674 if(ids.size() > 0) 707 if(ids.size() > 0)
675 { 708 {
676 // copy map of ids onto heap 709 // copy map of ids onto heap
@@ -732,6 +765,8 @@ void LLPanelFriends::modifyRightsConfirmation(S32 option, void* user_data)
732 { 765 {
733 const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first); 766 const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first);
734 panelp->updateFriendItem(rights_it->first, info); 767 panelp->updateFriendItem(rights_it->first, info);
768 // Might have changed the column the user is sorted on.
769 panelp->mFriendsList->sortItems();
735 } 770 }
736 } 771 }
737 panelp->refreshUI(); 772 panelp->refreshUI();