diff options
author | William Todd Stinson <stinson@lindenlab.com> | 2012-10-16 12:23:15 -0700 |
---|---|---|
committer | William Todd Stinson <stinson@lindenlab.com> | 2012-10-16 12:23:15 -0700 |
commit | a46d4ada3a2fe9ed8e5279e7d7e20d1ca485482c (patch) | |
tree | 3472c567b099034ee8ea13d34ccf89b41a6daccf /indra/newview/llconversationmodel.cpp | |
parent | 0ca59987843cfcaedb12592b9466567ef421c4e8 (diff) | |
parent | 5a22949cf509ebd1a3c7dfbd029b4bc188fee4a3 (diff) |
Pull and merge from ssh://stinson@hg.lindenlab.com/richard/viewer-chui/.
Diffstat (limited to 'indra/newview/llconversationmodel.cpp')
-rw-r--r-- | indra/newview/llconversationmodel.cpp | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index 5fc305da81..e5232d730c 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -27,6 +27,11 @@ #include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llavatarnamecache.h" +#include "llavataractions.h" +#include "llevents.h" +#include "llsdutil.h" #include "llconversationmodel.h" #include "llimview.h" //For LLIMModel @@ -64,6 +69,14 @@ LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_mod { } +void LLConversationItem::postEvent(const std::string& event_type, LLConversationItemSession* session, LLConversationItemParticipant* participant) +{ + LLUUID session_id = (session ? session->getUUID() : LLUUID()); + LLUUID participant_id = (participant ? participant->getUUID() : LLUUID()); + LLSD event(LLSDMap("type", event_type)("session_uuid", session_id)("participant_uuid", participant_id)); + LLEventPumps::instance().obtain("ConversationsEvents").post(event); +} + // Virtual action callbacks void LLConversationItem::performAction(LLInventoryModel* model, std::string action) { @@ -130,12 +143,55 @@ void LLConversationItemSession::addParticipant(LLConversationItemParticipant* pa addChild(participant); mIsLoaded = true; mNeedsRefresh = true; + updateParticipantName(participant); + postEvent("add_participant", this, participant); +} + +void LLConversationItemSession::updateParticipantName(LLConversationItemParticipant* participant) +{ + // We modify the session name only in the case of an ad-hoc session, exit otherwise (nothing to do) + if (getType() != CONV_SESSION_AD_HOC) + { + return; + } + // Avoid changing the default name if no participant present yet + if (mChildren.size() == 0) + { + return; + } + // Build a string containing the participants names and check if ready for display (we don't want "(waiting)" in there) + bool all_names_resolved = true; + uuid_vec_t temp_uuids; // uuids vector for building the added participants' names string + child_list_t::iterator iter = mChildren.begin(); + while (iter != mChildren.end()) + { + LLConversationItemParticipant* current_participant = dynamic_cast<LLConversationItemParticipant*>(*iter); + temp_uuids.push_back(current_participant->getUUID()); + LLAvatarName av_name; + if (!LLAvatarNameCache::get(current_participant->getUUID(), &av_name)) + { + // If the name is not in the cache yet, bail out + // Note: we don't bind ourselves to the LLAvatarNameCache event as we are called by + // onAvatarNameCache() which is itself attached to the same event. + all_names_resolved = false; + break; + } + iter++; + } + if (all_names_resolved) + { + std::string new_session_name; + LLAvatarActions::buildResidentsString(temp_uuids, new_session_name); + renameItem(new_session_name); + postEvent("update_session", this, NULL); + } } void LLConversationItemSession::removeParticipant(LLConversationItemParticipant* participant) { removeChild(participant); mNeedsRefresh = true; + postEvent("remove_participant", this, participant); } void LLConversationItemSession::removeParticipant(const LLUUID& participant_id) @@ -319,7 +375,10 @@ void LLConversationItemParticipant::buildContextMenu(LLMenuGL& menu, U32 flags) menuentry_vec_t items; menuentry_vec_t disabled_items; - buildParticipantMenuOptions(items); + if(gAgent.getID() != mUUID) + { + buildParticipantMenuOptions(items); + } hide_context_entries(menu, items, disabled_items); } @@ -328,10 +387,13 @@ void LLConversationItemParticipant::onAvatarNameCache(const LLAvatarName& av_nam mName = (av_name.mUsername.empty() ? av_name.mDisplayName : av_name.mUsername); mDisplayName = (av_name.mDisplayName.empty() ? av_name.mUsername : av_name.mDisplayName); mNeedsRefresh = true; - if (mParent) + LLConversationItemSession* parent_session = dynamic_cast<LLConversationItemSession*>(mParent); + if (parent_session) { - mParent->requestSort(); + parent_session->requestSort(); + parent_session->updateParticipantName(this); } + postEvent("update_participant", parent_session, this); } void LLConversationItemParticipant::dumpDebugData() |