diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llfloaterfriends.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llfloaterfriends.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterfriends.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/linden/indra/newview/llfloaterfriends.cpp b/linden/indra/newview/llfloaterfriends.cpp index 0de8698..3d2e60a 100644 --- a/linden/indra/newview/llfloaterfriends.cpp +++ b/linden/indra/newview/llfloaterfriends.cpp | |||
@@ -60,6 +60,7 @@ | |||
60 | 60 | ||
61 | //Maximum number of people you can select to do an operation on at once. | 61 | //Maximum number of people you can select to do an operation on at once. |
62 | #define MAX_FRIEND_SELECT 20 | 62 | #define MAX_FRIEND_SELECT 20 |
63 | #define DEFAULT_PERIOD 5.0 | ||
63 | #define RIGHTS_CHANGE_TIMEOUT 5.0 | 64 | #define RIGHTS_CHANGE_TIMEOUT 5.0 |
64 | #define OBSERVER_TIMEOUT 0.5 | 65 | #define OBSERVER_TIMEOUT 0.5 |
65 | 66 | ||
@@ -80,7 +81,6 @@ public: | |||
80 | // events can arrive quickly in bulk - we need not process EVERY one of them - | 81 | // events can arrive quickly in bulk - we need not process EVERY one of them - |
81 | // so we wait a short while to let others pile-in, and process them in aggregate. | 82 | // so we wait a short while to let others pile-in, and process them in aggregate. |
82 | mEventTimer.start(); | 83 | mEventTimer.start(); |
83 | mEventTimer.reset(); | ||
84 | 84 | ||
85 | // save-up all the mask-bits which have come-in | 85 | // save-up all the mask-bits which have come-in |
86 | mMask |= mask; | 86 | mMask |= mask; |
@@ -102,7 +102,7 @@ protected: | |||
102 | 102 | ||
103 | LLPanelFriends::LLPanelFriends() : | 103 | LLPanelFriends::LLPanelFriends() : |
104 | LLPanel(), | 104 | LLPanel(), |
105 | LLEventTimer(1000000), | 105 | LLEventTimer(DEFAULT_PERIOD), |
106 | mObserver(NULL), | 106 | mObserver(NULL), |
107 | mShowMaxSelectWarning(TRUE), | 107 | mShowMaxSelectWarning(TRUE), |
108 | mAllowRightsChange(TRUE), | 108 | mAllowRightsChange(TRUE), |
@@ -122,7 +122,7 @@ LLPanelFriends::~LLPanelFriends() | |||
122 | BOOL LLPanelFriends::tick() | 122 | BOOL LLPanelFriends::tick() |
123 | { | 123 | { |
124 | mEventTimer.stop(); | 124 | mEventTimer.stop(); |
125 | mPeriod = 1000000; | 125 | mPeriod = DEFAULT_PERIOD; |
126 | mAllowRightsChange = TRUE; | 126 | mAllowRightsChange = TRUE; |
127 | updateFriends(LLFriendObserver::ADD); | 127 | updateFriends(LLFriendObserver::ADD); |
128 | return FALSE; | 128 | return FALSE; |
@@ -152,7 +152,6 @@ void LLPanelFriends::updateFriends(U32 changed_mask) | |||
152 | { | 152 | { |
153 | mPeriod = RIGHTS_CHANGE_TIMEOUT; | 153 | mPeriod = RIGHTS_CHANGE_TIMEOUT; |
154 | mEventTimer.start(); | 154 | mEventTimer.start(); |
155 | mEventTimer.reset(); | ||
156 | mAllowRightsChange = FALSE; | 155 | mAllowRightsChange = FALSE; |
157 | } | 156 | } |
158 | else | 157 | else |
@@ -208,17 +207,20 @@ BOOL LLPanelFriends::postBuild() | |||
208 | } | 207 | } |
209 | 208 | ||
210 | 209 | ||
211 | void LLPanelFriends::addFriend(const std::string& name, const LLUUID& agent_id) | 210 | BOOL LLPanelFriends::addFriend(const LLUUID& agent_id) |
212 | { | 211 | { |
213 | LLAvatarTracker& at = LLAvatarTracker::instance(); | 212 | LLAvatarTracker& at = LLAvatarTracker::instance(); |
214 | const LLRelationship* relationInfo = at.getBuddyInfo(agent_id); | 213 | const LLRelationship* relationInfo = at.getBuddyInfo(agent_id); |
215 | if(!relationInfo) return; | 214 | if(!relationInfo) return FALSE; |
216 | BOOL online = relationInfo->isOnline(); | 215 | BOOL online = relationInfo->isOnline(); |
217 | 216 | ||
217 | std::string fullname; | ||
218 | BOOL have_name = gCacheName->getFullName(agent_id, fullname); | ||
219 | |||
218 | LLSD element; | 220 | LLSD element; |
219 | element["id"] = agent_id; | 221 | element["id"] = agent_id; |
220 | element["columns"][LIST_FRIEND_NAME]["column"] = "friend_name"; | 222 | element["columns"][LIST_FRIEND_NAME]["column"] = "friend_name"; |
221 | element["columns"][LIST_FRIEND_NAME]["value"] = name.c_str(); | 223 | element["columns"][LIST_FRIEND_NAME]["value"] = fullname; |
222 | element["columns"][LIST_FRIEND_NAME]["font"] = "SANSSERIF"; | 224 | element["columns"][LIST_FRIEND_NAME]["font"] = "SANSSERIF"; |
223 | element["columns"][LIST_FRIEND_NAME]["font-style"] = "NORMAL"; | 225 | element["columns"][LIST_FRIEND_NAME]["font-style"] = "NORMAL"; |
224 | element["columns"][LIST_ONLINE_STATUS]["column"] = "icon_online_status"; | 226 | element["columns"][LIST_ONLINE_STATUS]["column"] = "icon_online_status"; |
@@ -247,30 +249,39 @@ void LLPanelFriends::addFriend(const std::string& name, const LLUUID& agent_id) | |||
247 | element["columns"][LIST_EDIT_THEIRS]["value"] = relationInfo->isRightGrantedFrom(LLRelationship::GRANT_MODIFY_OBJECTS); | 249 | element["columns"][LIST_EDIT_THEIRS]["value"] = relationInfo->isRightGrantedFrom(LLRelationship::GRANT_MODIFY_OBJECTS); |
248 | 250 | ||
249 | element["columns"][LIST_FRIEND_UPDATE_GEN]["column"] = "friend_last_update_generation"; | 251 | element["columns"][LIST_FRIEND_UPDATE_GEN]["column"] = "friend_last_update_generation"; |
250 | element["columns"][LIST_FRIEND_UPDATE_GEN]["value"] = relationInfo->getChangeSerialNum(); | 252 | element["columns"][LIST_FRIEND_UPDATE_GEN]["value"] = have_name ? relationInfo->getChangeSerialNum() : -1; |
251 | 253 | ||
252 | mFriendsList->addElement(element, ADD_BOTTOM); | 254 | mFriendsList->addElement(element, ADD_BOTTOM); |
255 | return have_name; | ||
253 | } | 256 | } |
254 | 257 | ||
255 | // propagate actual relationship to UI | 258 | // propagate actual relationship to UI |
256 | void LLPanelFriends::updateFriendItem(LLScrollListItem* itemp, const LLRelationship* info) | 259 | BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationship* info) |
257 | { | 260 | { |
258 | if (!itemp) return; | 261 | if (!info) return FALSE; |
259 | if (!info) return; | 262 | LLScrollListItem* itemp = mFriendsList->getItem(agent_id); |
263 | if (!itemp) return FALSE; | ||
264 | |||
265 | std::string fullname; | ||
266 | BOOL have_name = gCacheName->getFullName(agent_id, fullname); | ||
260 | 267 | ||
261 | itemp->getColumn(LIST_ONLINE_STATUS)->setValue(info->isOnline() ? gViewerArt.getString("icon_avatar_online.tga") : LLString()); | 268 | itemp->getColumn(LIST_ONLINE_STATUS)->setValue(info->isOnline() ? gViewerArt.getString("icon_avatar_online.tga") : LLString()); |
269 | itemp->getColumn(LIST_FRIEND_NAME)->setValue(fullname); | ||
262 | // render name of online friends in bold text | 270 | // render name of online friends in bold text |
263 | ((LLScrollListText*)itemp->getColumn(LIST_FRIEND_NAME))->setFontStyle(info->isOnline() ? LLFontGL::BOLD : LLFontGL::NORMAL); | 271 | ((LLScrollListText*)itemp->getColumn(LIST_FRIEND_NAME))->setFontStyle(info->isOnline() ? LLFontGL::BOLD : LLFontGL::NORMAL); |
264 | itemp->getColumn(LIST_VISIBLE_ONLINE)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS)); | 272 | itemp->getColumn(LIST_VISIBLE_ONLINE)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS)); |
265 | itemp->getColumn(LIST_VISIBLE_MAP)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION)); | 273 | itemp->getColumn(LIST_VISIBLE_MAP)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION)); |
266 | itemp->getColumn(LIST_EDIT_MINE)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_MODIFY_OBJECTS)); | 274 | itemp->getColumn(LIST_EDIT_MINE)->setValue(info->isRightGrantedTo(LLRelationship::GRANT_MODIFY_OBJECTS)); |
267 | itemp->getColumn(LIST_FRIEND_UPDATE_GEN)->setValue(info->getChangeSerialNum()); | 275 | S32 change_generation = have_name ? info->getChangeSerialNum() : -1; |
276 | itemp->getColumn(LIST_FRIEND_UPDATE_GEN)->setValue(change_generation); | ||
268 | 277 | ||
269 | // enable this item, in case it was disabled after user input | 278 | // enable this item, in case it was disabled after user input |
270 | itemp->setEnabled(TRUE); | 279 | itemp->setEnabled(TRUE); |
271 | 280 | ||
272 | // changed item in place, need to request sort | 281 | // changed item in place, need to request sort |
273 | mFriendsList->sortItems(); | 282 | mFriendsList->sortItems(); |
283 | |||
284 | return have_name; | ||
274 | } | 285 | } |
275 | 286 | ||
276 | void LLPanelFriends::refreshRightsChangeList() | 287 | void LLPanelFriends::refreshRightsChangeList() |
@@ -354,7 +365,8 @@ void LLPanelFriends::refreshNames() | |||
354 | 365 | ||
355 | std::vector<LLScrollListItem*>::iterator item_it = items.begin(); | 366 | std::vector<LLScrollListItem*>::iterator item_it = items.begin(); |
356 | std::vector<LLScrollListItem*>::iterator item_end = items.end(); | 367 | std::vector<LLScrollListItem*>::iterator item_end = items.end(); |
357 | 368 | ||
369 | BOOL have_names = TRUE; | ||
358 | LLAvatarTracker::buddy_map_t::iterator buddy_it; | 370 | LLAvatarTracker::buddy_map_t::iterator buddy_it; |
359 | for (buddy_it = all_buddies.begin() ; buddy_it != all_buddies.end(); ++buddy_it) | 371 | for (buddy_it = all_buddies.begin() ; buddy_it != all_buddies.end(); ++buddy_it) |
360 | { | 372 | { |
@@ -379,24 +391,24 @@ void LLPanelFriends::refreshNames() | |||
379 | if (last_change_generation < info->getChangeSerialNum()) | 391 | if (last_change_generation < info->getChangeSerialNum()) |
380 | { | 392 | { |
381 | // update existing item in UI | 393 | // update existing item in UI |
382 | updateFriendItem(mFriendsList->getItem(buddy_it->first), info); | 394 | have_names &= updateFriendItem(buddy_it->first, info); |
383 | } | 395 | } |
384 | ++item_it; | 396 | ++item_it; |
385 | } | 397 | } |
386 | // add new friend to list | 398 | // add new friend to list |
387 | else | 399 | else |
388 | { | 400 | { |
389 | const LLUUID& buddy_id = buddy_it->first; | 401 | have_names &= addFriend(buddy_it->first); |
390 | char first_name[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | ||
391 | char last_name[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | ||
392 | |||
393 | gCacheName->getName(buddy_id, first_name, last_name); | ||
394 | std::ostringstream fullname; | ||
395 | fullname << first_name << " " << last_name; | ||
396 | addFriend(fullname.str(), buddy_id); | ||
397 | } | 402 | } |
398 | } | 403 | } |
404 | if (!have_names) | ||
405 | { | ||
406 | mEventTimer.start(); | ||
407 | } | ||
408 | // changed item in place, need to request sort and update columns | ||
409 | mFriendsList->sortItems(); | ||
399 | 410 | ||
411 | // re-select items | ||
400 | mFriendsList->selectMultiple(selected_ids); | 412 | mFriendsList->selectMultiple(selected_ids); |
401 | mFriendsList->setScrollPos(pos); | 413 | mFriendsList->setScrollPos(pos); |
402 | } | 414 | } |
@@ -412,7 +424,7 @@ void LLPanelFriends::refreshUI() | |||
412 | single_selected = TRUE; | 424 | single_selected = TRUE; |
413 | if(num_selected > 1) | 425 | if(num_selected > 1) |
414 | { | 426 | { |
415 | childSetText("friend_name_label", childGetText("Multiple")); | 427 | childSetText("friend_name_label", getString("Multiple")); |
416 | multiple_selected = TRUE; | 428 | multiple_selected = TRUE; |
417 | } | 429 | } |
418 | else | 430 | else |
@@ -501,26 +513,17 @@ void LLPanelFriends::onClickIM(void* user_data) | |||
501 | { | 513 | { |
502 | LLUUID agent_id = ids[0]; | 514 | LLUUID agent_id = ids[0]; |
503 | const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(agent_id); | 515 | const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(agent_id); |
504 | char first[DB_FIRST_NAME_BUF_SIZE]; /* Flawfinder: ignore */ | 516 | std::string fullname; |
505 | char last[DB_LAST_NAME_BUF_SIZE]; /* Flawfinder: ignore */ | 517 | if(info && gCacheName->getFullName(agent_id, fullname)) |
506 | if(info && gCacheName->getName(agent_id, first, last)) | ||
507 | { | 518 | { |
508 | char buffer[MAX_STRING]; /* Flawfinder: ignore */ | ||
509 | snprintf(buffer, MAX_STRING, "%s %s", first, last); /* Flawfinder: ignore */ | ||
510 | gIMMgr->setFloaterOpen(TRUE); | 519 | gIMMgr->setFloaterOpen(TRUE); |
511 | gIMMgr->addSession( | 520 | gIMMgr->addSession(fullname, IM_NOTHING_SPECIAL, agent_id); |
512 | buffer, | ||
513 | IM_NOTHING_SPECIAL, | ||
514 | agent_id); | ||
515 | } | 521 | } |
516 | } | 522 | } |
517 | else | 523 | else |
518 | { | 524 | { |
519 | gIMMgr->setFloaterOpen(TRUE); | 525 | gIMMgr->setFloaterOpen(TRUE); |
520 | gIMMgr->addSession("Friends Conference", | 526 | gIMMgr->addSession("Friends Conference", IM_SESSION_CONFERENCE_START, ids[0], ids); |
521 | IM_SESSION_CONFERENCE_START, | ||
522 | ids[0], | ||
523 | ids); | ||
524 | } | 527 | } |
525 | make_ui_sound("UISndStartIM"); | 528 | make_ui_sound("UISndStartIM"); |
526 | } | 529 | } |
@@ -612,8 +615,7 @@ void LLPanelFriends::onClickRemove(void* user_data) | |||
612 | if(ids.size() == 1) | 615 | if(ids.size() == 1) |
613 | { | 616 | { |
614 | LLUUID agent_id = ids[0]; | 617 | LLUUID agent_id = ids[0]; |
615 | char first[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 618 | std::string first, last; |
616 | char last[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | ||
617 | if(gCacheName->getName(agent_id, first, last)) | 619 | if(gCacheName->getName(agent_id, first, last)) |
618 | { | 620 | { |
619 | args["[FIRST_NAME]"] = first; | 621 | args["[FIRST_NAME]"] = first; |
@@ -671,8 +673,7 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command | |||
671 | if(ids.size() == 1) | 673 | if(ids.size() == 1) |
672 | { | 674 | { |
673 | LLUUID agent_id = ids.begin()->first; | 675 | LLUUID agent_id = ids.begin()->first; |
674 | char first[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 676 | std::string first, last; |
675 | char last[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | ||
676 | if(gCacheName->getName(agent_id, first, last)) | 677 | if(gCacheName->getName(agent_id, first, last)) |
677 | { | 678 | { |
678 | args["[FIRST_NAME]"] = first; | 679 | args["[FIRST_NAME]"] = first; |
@@ -720,9 +721,8 @@ void LLPanelFriends::modifyRightsConfirmation(S32 option, void* user_data) | |||
720 | rights_map_t::iterator rights_it; | 721 | rights_map_t::iterator rights_it; |
721 | for (rights_it = rights->begin(); rights_it != rights->end(); ++rights_it) | 722 | for (rights_it = rights->begin(); rights_it != rights->end(); ++rights_it) |
722 | { | 723 | { |
723 | LLScrollListItem* itemp = panelp->mFriendsList->getItem(rights_it->first); | ||
724 | const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first); | 724 | const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first); |
725 | panelp->updateFriendItem(itemp, info); | 725 | panelp->updateFriendItem(rights_it->first, info); |
726 | } | 726 | } |
727 | } | 727 | } |
728 | panelp->refreshUI(); | 728 | panelp->refreshUI(); |