diff options
author | maksymsproductengine <maksymsproductengine@lindenlab.com> | 2013-01-08 23:37:29 +0200 |
---|---|---|
committer | maksymsproductengine <maksymsproductengine@lindenlab.com> | 2013-01-08 23:37:29 +0200 |
commit | def252341a8c1675405404a6588749d06fa40791 (patch) | |
tree | 4b35c872d38d91f5ebcbd2a382ee1ad2f34607ca /indra | |
parent | 856969285e027def5acba6c252dc65a242349d4f (diff) |
CHUI-612 FIXED Blank conversation names showing in conversation list
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llconversationmodel.cpp | 129 | ||||
-rwxr-xr-x | indra/newview/llconversationmodel.h | 20 | ||||
-rw-r--r-- | indra/newview/llfloaterimcontainer.cpp | 9 |
3 files changed, 102 insertions, 56 deletions
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index 0243fb1c97..a8da4908ce 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -47,7 +47,8 @@ LLConversationItem::LLConversationItem(std::string display_name, const LLUUID& u mNeedsRefresh(true), mConvType(CONV_UNKNOWN), mLastActiveTime(0.0), - mDisplayModeratorOptions(false) + mDisplayModeratorOptions(false), + mAvatarNameCacheConnection() { } @@ -58,7 +59,8 @@ LLConversationItem::LLConversationItem(const LLUUID& uuid, LLFolderViewModelInte mNeedsRefresh(true), mConvType(CONV_UNKNOWN), mLastActiveTime(0.0), - mDisplayModeratorOptions(false) + mDisplayModeratorOptions(false), + mAvatarNameCacheConnection() { } @@ -69,10 +71,21 @@ LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_mod mNeedsRefresh(true), mConvType(CONV_UNKNOWN), mLastActiveTime(0.0), - mDisplayModeratorOptions(false) + mDisplayModeratorOptions(false), + mAvatarNameCacheConnection() { } +LLConversationItem::~LLConversationItem() +{ + // Disconnect any previous avatar name cache connection to ensure + // that the callback method is not called after destruction + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } +} + void LLConversationItem::postEvent(const std::string& event_type, LLConversationItemSession* session, LLConversationItemParticipant* participant) { LLUUID session_id = (session ? session->getUUID() : LLUUID()); @@ -142,6 +155,37 @@ void LLConversationItem::buildParticipantMenuOptions(menuentry_vec_t& items, U32 } } +// method does subscription to changes in avatar name cache for current session/participant conversation item. +void LLConversationItem::fetchAvatarName(bool isParticipant /*= true*/) +{ + LLUUID item_id = getUUID(); + + // item should not be null for participants + if (isParticipant) + { + llassert(item_id.notNull()); + } + + // disconnect any previous avatar name cache connection + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + + // exclude nearby chat item + if (item_id.notNull()) + { + // for P2P session item, override it as item of called agent + if (CONV_SESSION_1_ON_1 == getType()) + { + item_id = LLIMModel::getInstance()->getOtherParticipantID(item_id); + } + + // subscribe on avatar name cache changes for participant and session items + mAvatarNameCacheConnection = LLAvatarNameCache::get(item_id, boost::bind(&LLConversationItem::onAvatarNameCache, this, _2)); + } +} + // // LLConversationItemSession // @@ -169,11 +213,11 @@ void LLConversationItemSession::addParticipant(LLConversationItemParticipant* pa addChild(participant); mIsLoaded = true; mNeedsRefresh = true; - updateParticipantName(participant); + updateName(participant); postEvent("add_participant", this, participant); } -void LLConversationItemSession::updateParticipantName(LLConversationItemParticipant* participant) +void LLConversationItemSession::updateName(LLConversationItemParticipant* participant) { EConversationType conversation_type = getType(); // We modify the session name only in the case of an ad-hoc session or P2P session, exit otherwise (nothing to do) @@ -181,11 +225,13 @@ void LLConversationItemSession::updateParticipantName(LLConversationItemParticip { return; } + // Avoid changing the default name if no participant present yet if (mChildren.size() == 0) { return; } + uuid_vec_t temp_uuids; // uuids vector for building the added participants' names string if (conversation_type == CONV_SESSION_AD_HOC) { @@ -210,12 +256,14 @@ void LLConversationItemSession::updateParticipantName(LLConversationItemParticip } else if (conversation_type == CONV_SESSION_1_ON_1) { - // In the case of a P2P conversersation, we need to grab the name of the other participant in the session instance itself + // In the case of a P2P conversation, we need to grab the name of the other participant in the session instance itself // as we do not create participants for such a session. - LLFloaterIMSession *conversationFloater = LLFloaterIMSession::findInstance(mUUID); - LLUUID participantID = conversationFloater->getOtherParticipantUUID(); - temp_uuids.push_back(participantID); + if (gAgentID != participant->getUUID()) + { + temp_uuids.push_back(participant->getUUID()); + } } + if (temp_uuids.size() != 0) { std::string new_session_name; @@ -229,7 +277,7 @@ void LLConversationItemSession::removeParticipant(LLConversationItemParticipant* { removeChild(participant); mNeedsRefresh = true; - updateParticipantName(participant); + updateName(participant); postEvent("remove_participant", this, participant); } @@ -393,6 +441,18 @@ void LLConversationItemSession::dumpDebugData(bool dump_children) } } +// should be invoked only for P2P sessions +void LLConversationItemSession::onAvatarNameCache(const LLAvatarName& av_name) +{ + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + + renameItem(av_name.getDisplayName()); + postEvent("update_session", this, NULL); +} + // // LLConversationItemParticipant // @@ -401,8 +461,7 @@ LLConversationItemParticipant::LLConversationItemParticipant(std::string display LLConversationItem(display_name,uuid,root_view_model), mIsMuted(false), mIsModerator(false), - mDistToAgent(-1.0), - mAvatarNameCacheConnection() + mDistToAgent(-1.0) { mDisplayName = display_name; mConvType = CONV_PARTICIPANT; @@ -412,38 +471,12 @@ LLConversationItemParticipant::LLConversationItemParticipant(const LLUUID& uuid, LLConversationItem(uuid,root_view_model), mIsMuted(false), mIsModerator(false), - mDistToAgent(-1.0), - mAvatarNameCacheConnection() + mDistToAgent(-1.0) { mConvType = CONV_PARTICIPANT; } -LLConversationItemParticipant::~LLConversationItemParticipant() -{ - // Disconnect any previous avatar name cache connection to ensure - // that the callback method is not called after destruction - if (mAvatarNameCacheConnection.connected()) - { - mAvatarNameCacheConnection.disconnect(); - } -} - -void LLConversationItemParticipant::fetchAvatarName() -{ - // Request the avatar name from the cache - llassert(getUUID().notNull()); - if (getUUID().notNull()) - { - // Disconnect any previous avatar name cache connection - if (mAvatarNameCacheConnection.connected()) - { - mAvatarNameCacheConnection.disconnect(); - } - mAvatarNameCacheConnection = LLAvatarNameCache::get(getUUID(), boost::bind(&LLConversationItemParticipant::onAvatarNameCache, this, _2)); - } -} - -void LLConversationItemParticipant::updateAvatarName() +void LLConversationItemParticipant::updateName() { llassert(getUUID().notNull()); if (getUUID().notNull()) @@ -451,29 +484,33 @@ void LLConversationItemParticipant::updateAvatarName() LLAvatarName av_name; if (LLAvatarNameCache::get(getUUID(),&av_name)) { - updateAvatarName(av_name); + updateName(av_name); } } } void LLConversationItemParticipant::onAvatarNameCache(const LLAvatarName& av_name) { - mAvatarNameCacheConnection.disconnect(); - updateAvatarName(av_name); + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + + updateName(av_name); } -void LLConversationItemParticipant::updateAvatarName(const LLAvatarName& av_name) +void LLConversationItemParticipant::updateName(const LLAvatarName& av_name) { mName = av_name.getUserName(); mDisplayName = av_name.getDisplayName(); - mNeedsRefresh = true; + renameItem(mDisplayName); if (mParent != NULL) { LLConversationItemSession* parent_session = dynamic_cast<LLConversationItemSession*>(mParent); if (parent_session != NULL) { parent_session->requestSort(); - parent_session->updateParticipantName(this); + parent_session->updateName(this); postEvent("update_participant", parent_session, this); } } diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index 01b3850f5e..6aaea041e4 100755 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -64,7 +64,7 @@ public: LLConversationItem(std::string display_name, const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); LLConversationItem(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); LLConversationItem(LLFolderViewModelInterface& root_view_model); - virtual ~LLConversationItem() {} + virtual ~LLConversationItem(); // Stub those things we won't really be using in this conversation context virtual const std::string& getName() const { return mName; } @@ -132,27 +132,31 @@ public: void buildParticipantMenuOptions(menuentry_vec_t& items, U32 flags); + void fetchAvatarName(bool isParticipant = true); // fetch and update the avatar name + protected: + virtual void onAvatarNameCache(const LLAvatarName& av_name) {} + std::string mName; // Name of the session or the participant LLUUID mUUID; // UUID of the session or the participant EConversationType mConvType; // Type of conversation item bool mNeedsRefresh; // Flag signaling to the view that something changed for this item F64 mLastActiveTime; bool mDisplayModeratorOptions; -}; + boost::signals2::connection mAvatarNameCacheConnection; +}; class LLConversationItemSession : public LLConversationItem { public: LLConversationItemSession(std::string display_name, const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); LLConversationItemSession(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); - virtual ~LLConversationItemSession() {} /*virtual*/ bool hasChildren() const; LLPointer<LLUIImage> getIcon() const { return NULL; } void setSessionID(const LLUUID& session_id) { mUUID = session_id; mNeedsRefresh = true; } void addParticipant(LLConversationItemParticipant* participant); - void updateParticipantName(LLConversationItemParticipant* participant); + void updateName(LLConversationItemParticipant* participant); void removeParticipant(LLConversationItemParticipant* participant); void removeParticipant(const LLUUID& participant_id); void clearParticipants(); @@ -172,6 +176,8 @@ public: void dumpDebugData(bool dump_children = false); private: + /*virtual*/ void onAvatarNameCache(const LLAvatarName& av_name); + bool mIsLoaded; // true if at least one participant has been added to the session, false otherwise }; @@ -180,7 +186,6 @@ class LLConversationItemParticipant : public LLConversationItem public: LLConversationItemParticipant(std::string display_name, const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); LLConversationItemParticipant(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model); - virtual ~LLConversationItemParticipant(); virtual const std::string& getDisplayName() const { return mDisplayName; } @@ -195,8 +200,7 @@ public: virtual const bool getDistanceToAgent(F64& dist) const { dist = mDistToAgent; return (dist >= 0.0); } - void fetchAvatarName(); // fetch and update the avatar name - void updateAvatarName(); // get from the cache (do *not* fetch) and update the avatar name + void updateName(); // get from the cache (do *not* fetch) and update the avatar name LLConversationItemSession* getParentSession(); void dumpDebugData(); @@ -204,7 +208,7 @@ public: private: void onAvatarNameCache(const LLAvatarName& av_name); // callback used by fetchAvatarName - void updateAvatarName(const LLAvatarName& av_name); + void updateName(const LLAvatarName& av_name); bool mIsMuted; // default is false bool mIsModerator; // default is false diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index 38528f18f0..a599fb51e1 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -380,7 +380,7 @@ void LLFloaterIMContainer::processParticipantsStyleUpdate() { LLConversationItemParticipant* participant_model = dynamic_cast<LLConversationItemParticipant*>(*current_participant_model); // Get the avatar name for this participant id from the cache and update the model - participant_model->updateAvatarName(); + participant_model->updateName(); // Next participant current_participant_model++; } @@ -1390,7 +1390,7 @@ LLConversationItem* LLFloaterIMContainer::addConversationListItem(const LLUUID& return NULL; } item->renameItem(display_name); - item->updateParticipantName(NULL); + item->updateName(NULL); mConversationsItems[uuid] = item; @@ -1419,6 +1419,11 @@ LLConversationItem* LLFloaterIMContainer::addConversationListItem(const LLUUID& } } + if (uuid.notNull() && im_sessionp->isP2PSessionType()) + { + item->fetchAvatarName(false); + } + // Do that too for the conversation dialog LLFloaterIMSessionTab *conversation_floater = (uuid.isNull() ? (LLFloaterIMSessionTab*)(LLFloaterReg::findTypedInstance<LLFloaterIMNearbyChat>("nearby_chat")) : (LLFloaterIMSessionTab*)(LLFloaterIMSession::findInstance(uuid))); if (conversation_floater) |