BOOL LLPanelFriends::refreshNamesPresence(const LLAvatarTracker::buddy_map_t & all_buddies) { std::vector<LLScrollListItem*> items = mFriendsList->getAllData(); std::sort(items.begin(), items.end(), SortFriendsByID()); LLAvatarTracker::buddy_map_t::const_iterator buddy_it = all_buddies.begin(); std::vector<LLScrollListItem*>::const_iterator item_it = items.begin(); BOOL have_names = TRUE; while(true) { if(item_it == items.end() || buddy_it == all_buddies.end()) { break; } const LLUUID & buddy_uuid = buddy_it->first; const LLUUID & item_uuid = (*item_it)->getValue().asUUID(); if(item_uuid == buddy_uuid) { const LLRelationship* info = buddy_it->second; if (!info) { ++item_it; continue; } S32 last_change_generation = (*item_it)->getColumn(LIST_FRIEND_UPDATE_GEN)->getValue().asInteger(); if (last_change_generation < info->getChangeSerialNum()) { // update existing item in UI have_names &= updateFriendItem(buddy_it->first, info); } ++buddy_it; ++item_it; } else if(item_uuid < buddy_uuid) { ++item_it; } else //if(item_uuid > buddy_uuid) { ++buddy_it; } } return have_names; }
bool LLPanelFriends::modifyRightsConfirmation(const LLSD& notification, const LLSD& response, rights_map_t* rights) { S32 option = LLNotification::getSelectedOption(notification, response); if(0 == option) { sendRightsGrant(*rights); } else { // need to resync view with model, since user cancelled operation rights_map_t::iterator rights_it; for (rights_it = rights->begin(); rights_it != rights->end(); ++rights_it) { const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first); updateFriendItem(rights_it->first, info); } } refreshUI(); delete rights; return false; }
void LLFloaterFriends::refreshNames() { if (!sInstance) return; LLDynamicArray<LLUUID> selected_ids = getSelectedIDs(); S32 pos = mFriendsList->getScrollPos(); // get all buddies we know about LLAvatarTracker::buddy_map_t all_buddies; LLAvatarTracker::instance().copyBuddyList(all_buddies); // get all friends in list and sort by UUID std::vector<LLScrollListItem*> items = mFriendsList->getAllData(); std::sort(items.begin(), items.end(), SortFriendsByID()); std::vector<LLScrollListItem*>::iterator item_it = items.begin(); std::vector<LLScrollListItem*>::iterator item_end = items.end(); LLAvatarTracker::buddy_map_t::iterator buddy_it; for (buddy_it = all_buddies.begin() ; buddy_it != all_buddies.end(); ++buddy_it) { // erase any items that reflect residents who are no longer buddies while(item_it != item_end && buddy_it->first > (*item_it)->getValue().asUUID()) { mFriendsList->deleteItems((*item_it)->getValue()); ++item_it; } // update existing friends with new info if (item_it != item_end && buddy_it->first == (*item_it)->getValue().asUUID()) { const LLRelationship* info = buddy_it->second; if (!info) { ++item_it; continue; } S32 last_change_generation = (*item_it)->getColumn(LIST_FRIEND_UPDATE_GEN)->getValue().asInteger(); if (last_change_generation < info->getChangeSerialNum()) { // update existing item in UI updateFriendItem(mFriendsList->getItem(buddy_it->first), info); } ++item_it; } // add new friend to list else { const LLUUID& buddy_id = buddy_it->first; char first_name[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ char last_name[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ gCacheName->getName(buddy_id, first_name, last_name); std::ostringstream fullname; fullname << first_name << " " << last_name; addFriend(fullname.str(), buddy_id); } } mFriendsList->selectMultiple(selected_ids); mFriendsList->setScrollPos(pos); }