void LLCommonUtils::computeDifference( const uuid_vec_t& vnew, const uuid_vec_t& vcur, uuid_vec_t& vadded, uuid_vec_t& vremoved) { uuid_vec_t vnew_copy(vnew); uuid_vec_t vcur_copy(vcur); std::sort(vnew_copy.begin(), vnew_copy.end()); std::sort(vcur_copy.begin(), vcur_copy.end()); size_t maxsize = llmax(vnew_copy.size(), vcur_copy.size()); vadded.resize(maxsize); vremoved.resize(maxsize); uuid_vec_t::iterator it; // what was removed it = set_difference(vcur_copy.begin(), vcur_copy.end(), vnew_copy.begin(), vnew_copy.end(), vremoved.begin()); vremoved.erase(it, vremoved.end()); // what was added it = set_difference(vnew_copy.begin(), vnew_copy.end(), vcur_copy.begin(), vcur_copy.end(), vadded.begin()); vadded.erase(it, vadded.end()); }
void LLPanelGroupBulk::addUsers(uuid_vec_t& agent_ids) { std::vector<std::string> names; for (S32 i = 0; i < (S32)agent_ids.size(); i++) { std::string fullname; LLUUID agent_id = agent_ids[i]; LLViewerObject* dest = gObjectList.findObject(agent_id); if(dest && dest->isAvatar()) { LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) { fullname = LLCacheName::buildFullName( nvfirst->getString(), nvlast->getString()); } if (!fullname.empty()) { names.push_back(fullname); } else { llwarns << "llPanelGroupBulk: Selected avatar has no name: " << dest->getID() << llendl; names.push_back("(Unknown)"); } } else { //looks like user try to invite offline friend //for offline avatar_id gObjectList.findObject() will return null //so we need to do this additional search in avatar tracker, see EXT-4732 //if (LLAvatarTracker::instance().isBuddy(agent_id)) // Singu Note: We may be using this from another avatar list like group profile, disregard friendship status. { LLAvatarName av_name; if (!LLAvatarNameCache::get(agent_id, &av_name)) { // actually it should happen, just in case LLAvatarNameCache::get(LLUUID(agent_id), boost::bind(&LLPanelGroupBulk::addUserCallback, this, _1, _2)); // for this special case! //when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence // removed id will be added in callback agent_ids.erase(agent_ids.begin() + i); } else { std::string name; LLAvatarNameCache::getPNSName(av_name, name); names.push_back(name); } } } } mImplementation->mListFullNotificationSent = false; mImplementation->addUsers(names, agent_ids); }
void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids) { std::vector<std::string> names; for (S32 i = 0; i < (S32)agent_ids.size(); i++) { LLUUID agent_id = agent_ids[i]; LLViewerObject* dest = gObjectList.findObject(agent_id); std::string fullname; if(dest && dest->isAvatar()) { LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) { fullname = std::string(nvfirst->getString()) + " " + std::string(nvlast->getString()); } if (!fullname.empty()) { names.push_back(fullname); } else { llwarns << "llPanelGroupInvite: Selected avatar has no name: " << dest->getID() << llendl; names.push_back("(Unknown)"); } } else { //looks like user try to invite offline friend //for offline avatar_id gObjectList.findObject() will return null //so we need to do this additional search in avatar tracker, see EXT-4732 if (LLAvatarTracker::instance().isBuddy(agent_id)) { if (!gCacheName->getFullName(agent_id, fullname)) { // actually it should happen, just in case gCacheName->get(LLUUID(agent_id), false, boost::bind( &LLPanelGroupInvite::addUserCallback, this, _1, _2, _3)); // for this special case! //when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence // removed id will be added in callback agent_ids.erase(agent_ids.begin() + i); } else { names.push_back(fullname); } } } } mImplementation->addUsers(names, agent_ids); }