From d22c8510b19f12e81dc68562de45c2c364036440 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 17 Sep 2012 17:53:17 -0700 Subject: CHUI-340 : WIP : Sorting implemented. Type and name work. Date and distance still need the relevant values to be computed. --- indra/newview/llconversationmodel.cpp | 70 ++++++++++++++++++++++++++++++---- indra/newview/llconversationmodel.h | 17 +++++++++ indra/newview/llimfloatercontainer.cpp | 1 - indra/newview/llparticipantlist.cpp | 21 ++++++++++ 4 files changed, 101 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index c36c3cbc65..612744c3e9 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -37,7 +37,8 @@ LLConversationItem::LLConversationItem(std::string display_name, const LLUUID& u LLFolderViewModelItemCommon(root_view_model), mName(display_name), mUUID(uuid), - mNeedsRefresh(true) + mNeedsRefresh(true), + mConvType(CONV_UNKNOWN) { } @@ -45,7 +46,8 @@ LLConversationItem::LLConversationItem(const LLUUID& uuid, LLFolderViewModelInte LLFolderViewModelItemCommon(root_view_model), mName(""), mUUID(uuid), - mNeedsRefresh(true) + mNeedsRefresh(true), + mConvType(CONV_UNKNOWN) { } @@ -53,7 +55,8 @@ LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_mod LLFolderViewModelItemCommon(root_view_model), mName(""), mUUID(), - mNeedsRefresh(true) + mNeedsRefresh(true), + mConvType(CONV_UNKNOWN) { } @@ -86,11 +89,13 @@ LLConversationItemSession::LLConversationItemSession(std::string display_name, c LLConversationItem(display_name,uuid,root_view_model), mIsLoaded(false) { + mConvType = CONV_SESSION_UNKNOWN; } LLConversationItemSession::LLConversationItemSession(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) : LLConversationItem(uuid,root_view_model) { + mConvType = CONV_SESSION_UNKNOWN; } bool LLConversationItemSession::hasChildren() const @@ -183,11 +188,13 @@ LLConversationItemParticipant::LLConversationItemParticipant(std::string display mIsMuted(false), mIsModerator(false) { + mConvType = CONV_PARTICIPANT; } LLConversationItemParticipant::LLConversationItemParticipant(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) : LLConversationItem(uuid,root_view_model) { + mConvType = CONV_PARTICIPANT; } void LLConversationItemParticipant::onAvatarNameCache(const LLAvatarName& av_name) @@ -212,11 +219,60 @@ void LLConversationItemParticipant::dumpDebugData() bool LLConversationSort::operator()(const LLConversationItem* const& a, const LLConversationItem* const& b) const { - // For the moment, we sort only by name - // *TODO : Implement the sorting by date as well (most recent first) - // *TODO : Check the type of item (session/participants) as order should be different for both (eventually) + LLConversationItem::EConversationType type_a = a->getType(); + LLConversationItem::EConversationType type_b = b->getType(); + + if ((type_a == LLConversationItem::CONV_PARTICIPANT) && (type_b == LLConversationItem::CONV_PARTICIPANT)) + { + // If both are participants + U32 sort_order = getSortOrderParticipants(); + if (sort_order == LLConversationFilter::SO_DATE) + { + F32 time_a = 0.0; + F32 time_b = 0.0; + if (a->getTime(time_a) && b->getTime(time_b)) + { + return (time_a > time_b); + } + } + else if (sort_order == LLConversationFilter::SO_DISTANCE) + { + F32 dist_a = 0.0; + F32 dist_b = 0.0; + if (a->getDistanceToAgent(dist_a) && b->getDistanceToAgent(dist_b)) + { + return (dist_a > dist_b); + } + } + } + else if ((type_a > LLConversationItem::CONV_PARTICIPANT) && (type_b > LLConversationItem::CONV_PARTICIPANT)) + { + // If both are sessions + U32 sort_order = getSortOrderSessions(); + if (sort_order == LLConversationFilter::SO_DATE) + { + F32 time_a = 0.0; + F32 time_b = 0.0; + if (a->getTime(time_a) && b->getTime(time_b)) + { + return (time_a > time_b); + } + } + else if (sort_order == LLConversationFilter::SO_SESSION_TYPE) + { + return (type_a < type_b); + } + } + else + { + // If one is a participant and the other a session, the session is always "less" than the participant + // so we simply compare the type + // Notes: as a consequence, CONV_UNKNOWN (which should never get created...) always come first + return (type_a < type_b); + } + // By default, in all other possible cases (including sort order of type LLConversationFilter::SO_NAME of course), sort by name S32 compare = LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()); - return (compare < 0); + return (compare < 0); } // diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index ef1903ab19..954543f91a 100755 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -46,6 +46,17 @@ typedef std::map conversations_widgets_map; class LLConversationItem : public LLFolderViewModelItemCommon { public: + enum EConversationType + { + CONV_UNKNOWN = 0, + CONV_PARTICIPANT = 1, + CONV_SESSION_NEARBY = 2, // The order counts here as it is used to sort sessions by type + CONV_SESSION_1_ON_1 = 3, + CONV_SESSION_AD_HOC = 4, + CONV_SESSION_GROUP = 5, + CONV_SESSION_UNKNOWN = 6 + }; + 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); @@ -93,6 +104,11 @@ public: virtual void selectItem(void) { } virtual void showProperties(void); + // Methods used in sorting (see LLConversationSort::operator() + EConversationType const getType() const { return mConvType; } + virtual const bool getTime(F32& time) const { return false; } + virtual const bool getDistanceToAgent(F32& distance) const { return false; } + // This method will be called to determine if a drop can be // performed, and will set drop to TRUE if a drop is // requested. @@ -111,6 +127,7 @@ public: protected: 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 }; diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index ab4b64471b..76bd6b14b9 100755 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -740,7 +740,6 @@ void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid) llwarns << "Couldn't create conversation session item : " << display_name << llendl; return; } - // *TODO: Should we flag LLConversationItemSession with a mIsNearbyChat? item->renameItem(display_name); mConversationsItems[uuid] = item; diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index 0d1a37c835..339cee3f95 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -280,6 +280,27 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, } // we need to exclude agent id for non group chat sort(); + + // Identify and store what kind of session we are + LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(data_source->getSessionID()); + if (im_session) + { + // By default, sessions that can't be identified as group or ad-hoc will be considered P2P (i.e. 1 on 1) + mConvType = CONV_SESSION_1_ON_1; + if (im_session->isAdHocSessionType()) + { + mConvType = CONV_SESSION_AD_HOC; + } + else if (im_session->isGroupSessionType()) + { + mConvType = CONV_SESSION_GROUP; + } + } + else + { + // That's the only session that doesn't get listed in the LLIMModel as a session... + mConvType = CONV_SESSION_NEARBY; + } } LLParticipantList::~LLParticipantList() -- cgit v1.2.3 From a3607a8d8c86b2c25bfa0abda1b0fc9b00f2c099 Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Tue, 18 Sep 2012 16:41:37 +0300 Subject: CHUI-339 FIXED (2 entries shown in conversation log for ad hoc conference for user that starts the conference) --- indra/newview/llconversationlog.cpp | 35 ++++++++++++++++++++++------------- indra/newview/llconversationlog.h | 8 ++++---- indra/newview/llimview.cpp | 21 +++++++++++++++++---- indra/newview/llimview.h | 6 ++++-- 4 files changed, 47 insertions(+), 23 deletions(-) (limited to 'indra') diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index 27be2bc5ae..44bee70427 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -75,7 +75,7 @@ LLConversation::LLConversation(const LLIMModel::LLIMSession& session) mConversationType(session.mSessionType), mConversationName(session.mName), mHistoryFileName(session.mHistoryFileName), - mSessionID(session.mSessionID), + mSessionID(session.isOutgoingAdHoc() ? session.generateOutgouigAdHocHash() : session.mSessionID), mParticipantID(session.mOtherParticipantID), mIsVoice(session.mStartedAsIMCall), mHasOfflineIMs(session.mHasOfflineMessage) @@ -231,8 +231,8 @@ void LLConversationLog::enableLogging(bool enable) void LLConversationLog::logConversation(const LLUUID& session_id) { - LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id); - LLConversation* conversation = findConversation(session_id); + const LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id); + LLConversation* conversation = findConversation(session); if (session && conversation) { @@ -240,14 +240,12 @@ void LLConversationLog::logConversation(const LLUUID& session_id) } else if (session && !conversation) { - createConversation(session_id); + createConversation(session); } } -void LLConversationLog::createConversation(const LLUUID& session_id) +void LLConversationLog::createConversation(const LLIMModel::LLIMSession* session) { - LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id); - if (session) { LLConversation conversation(*session); @@ -262,14 +260,18 @@ void LLConversationLog::createConversation(const LLUUID& session_id) } } -void LLConversationLog::updateConversationName(const LLUUID& session_id, const std::string& name) +void LLConversationLog::updateConversationName(const LLIMModel::LLIMSession* session, const std::string& name) { - LLConversation* conversation = findConversation(session_id); + if (!session) + { + return; + } + LLConversation* conversation = findConversation(session); if (conversation) { conversation->setConverstionName(name); - notifyPrticularConversationObservers(session_id, LLConversationLogObserver::CHANGED_NAME); + notifyPrticularConversationObservers(conversation->getSessionID(), LLConversationLogObserver::CHANGED_NAME); } } @@ -282,8 +284,15 @@ void LLConversationLog::updateConversationTimestamp(LLConversation* conversation } } -LLConversation* LLConversationLog::findConversation(const LLUUID& session_id) +LLConversation* LLConversationLog::findConversation(const LLIMModel::LLIMSession* session) { + if (!session) + { + return NULL; + } + + const LLUUID session_id = session->isOutgoingAdHoc() ? session->generateOutgouigAdHocHash() : session->mSessionID; + conversations_vec_t::iterator conv_it = mConversations.begin(); for(; conv_it != mConversations.end(); ++conv_it) { @@ -489,7 +498,7 @@ void LLConversationLog::onNewMessageReceived(const LLSD& data) logConversation(session_id); } -void LLConversationLog::onAvatarNameCache(const LLUUID& participant_id, const LLAvatarName& av_name, LLIMModel::LLIMSession* session) +void LLConversationLog::onAvatarNameCache(const LLUUID& participant_id, const LLAvatarName& av_name, const LLIMModel::LLIMSession* session) { - updateConversationName(session->mSessionID, av_name.getCompleteName()); + updateConversationName(session, av_name.getCompleteName()); } diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h index a458e975bb..6fff7d6772 100644 --- a/indra/newview/llconversationlog.h +++ b/indra/newview/llconversationlog.h @@ -162,13 +162,13 @@ private: bool saveToFile(const std::string& filename); bool loadFromFile(const std::string& filename); - void onAvatarNameCache(const LLUUID& participant_id, const LLAvatarName& av_name, LLIMModel::LLIMSession* session); + void onAvatarNameCache(const LLUUID& participant_id, const LLAvatarName& av_name, const LLIMModel::LLIMSession* session); - void createConversation(const LLUUID& session_id); + void createConversation(const LLIMModel::LLIMSession* session); void updateConversationTimestamp(LLConversation* conversation); - void updateConversationName(const LLUUID& session_id, const std::string& name); + void updateConversationName(const LLIMModel::LLIMSession* session, const std::string& name); - LLConversation* findConversation(const LLUUID& session_id); + LLConversation* findConversation(const LLIMModel::LLIMSession* session); typedef std::vector conversations_vec_t; std::vector mConversations; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index f5392b442a..b45903835a 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -536,7 +536,7 @@ LLIMModel::LLIMSession* LLIMModel::findAdHocIMSession(const uuid_vec_t& ids) return NULL; } -bool LLIMModel::LLIMSession::isOutgoingAdHoc() +bool LLIMModel::LLIMSession::isOutgoingAdHoc() const { return IM_SESSION_CONFERENCE_START == mType; } @@ -556,6 +556,19 @@ bool LLIMModel::LLIMSession::isOtherParticipantAvaline() return !mOtherParticipantIsAvatar; } +LLUUID LLIMModel::LLIMSession::generateOutgouigAdHocHash() const +{ + LLUUID hash = LLUUID::null; + + if (mInitialTargetIDs.size()) + { + std::set sorted_uuids(mInitialTargetIDs.begin(), mInitialTargetIDs.end()); + hash = generateHash(sorted_uuids); + } + + return hash; +} + void LLIMModel::LLIMSession::buildHistoryFileName() { mHistoryFileName = mName; @@ -572,7 +585,7 @@ void LLIMModel::LLIMSession::buildHistoryFileName() if (mInitialTargetIDs.size()) { std::set sorted_uuids(mInitialTargetIDs.begin(), mInitialTargetIDs.end()); - mHistoryFileName = mName + " hash" + generateHash(sorted_uuids); + mHistoryFileName = mName + " hash" + generateHash(sorted_uuids).asString(); } else { @@ -606,7 +619,7 @@ void LLIMModel::LLIMSession::buildHistoryFileName() } //static -std::string LLIMModel::LLIMSession::generateHash(const std::set& sorted_uuids) +LLUUID LLIMModel::LLIMSession::generateHash(const std::set& sorted_uuids) { LLMD5 md5_uuid; @@ -620,7 +633,7 @@ std::string LLIMModel::LLIMSession::generateHash(const std::set& sorted_ LLUUID participants_md5_hash; md5_uuid.raw_digest((unsigned char*) participants_md5_hash.mData); - return participants_md5_hash.asString(); + return participants_md5_hash; } void LLIMModel::processSessionInitializedReply(const LLUUID& old_session_id, const LLUUID& new_session_id) diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index fa9d20ca53..82cfa394a6 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -85,7 +85,7 @@ public: /** @deprecated */ static void chatFromLogFile(LLLogChat::ELogLineType type, const LLSD& msg, void* userdata); - bool isOutgoingAdHoc(); + bool isOutgoingAdHoc() const; bool isAdHoc(); bool isP2P(); bool isOtherParticipantAvaline(); @@ -95,6 +95,8 @@ public: bool isGroupSessionType() const { return mSessionType == GROUP_SESSION;} bool isAvalineSessionType() const { return mSessionType == AVALINE_SESSION;} + LLUUID generateOutgouigAdHocHash() const; + //*TODO make private /** ad-hoc sessions involve sophisticated chat history file naming schemes */ void buildHistoryFileName(); @@ -139,7 +141,7 @@ public: private: void onAdHocNameCache(const LLAvatarName& av_name); - static std::string generateHash(const std::set& sorted_uuids); + static LLUUID generateHash(const std::set& sorted_uuids); }; -- cgit v1.2.3 From 3fb222e939de7ef71630c5754d964fb81e08fce1 Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Tue, 18 Sep 2012 18:07:16 +0300 Subject: CHUI-348 FIXED (Voice call icon still shows in conversation log) - Removed code responsible for showing voice icon --- indra/newview/llconversationlog.cpp | 18 ++++++------------ indra/newview/llconversationlog.h | 5 +---- indra/newview/llconversationloglistitem.cpp | 12 ++---------- 3 files changed, 9 insertions(+), 26 deletions(-) (limited to 'indra') diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index 44bee70427..7a5a476efb 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -36,8 +36,7 @@ struct Conversation_params { Conversation_params(time_t time) : mTime(time), - mTimestamp(LLConversation::createTimestamp(time)), - mIsVoice(false) + mTimestamp(LLConversation::createTimestamp(time)) {} time_t mTime; @@ -47,7 +46,6 @@ struct Conversation_params std::string mHistoryFileName; LLUUID mSessionID; LLUUID mParticipantID; - bool mIsVoice; bool mHasOfflineIMs; }; @@ -63,7 +61,6 @@ LLConversation::LLConversation(const Conversation_params& params) mHistoryFileName(params.mHistoryFileName), mSessionID(params.mSessionID), mParticipantID(params.mParticipantID), - mIsVoice(params.mIsVoice), mHasOfflineIMs(params.mHasOfflineIMs) { setListenIMFloaterOpened(); @@ -77,7 +74,6 @@ LLConversation::LLConversation(const LLIMModel::LLIMSession& session) mHistoryFileName(session.mHistoryFileName), mSessionID(session.isOutgoingAdHoc() ? session.generateOutgouigAdHocHash() : session.mSessionID), mParticipantID(session.mOtherParticipantID), - mIsVoice(session.mStartedAsIMCall), mHasOfflineIMs(session.mHasOfflineMessage) { setListenIMFloaterOpened(); @@ -92,7 +88,6 @@ LLConversation::LLConversation(const LLConversation& conversation) mHistoryFileName = conversation.getHistoryFileName(); mSessionID = conversation.getSessionID(); mParticipantID = conversation.getParticipantID(); - mIsVoice = conversation.isVoice(); mHasOfflineIMs = conversation.hasOfflineMessages(); setListenIMFloaterOpened(); @@ -147,12 +142,11 @@ void LLConversation::setListenIMFloaterOpened() { LLIMFloater* floater = LLIMFloater::findInstance(mSessionID); - bool has_offline_ims = !mIsVoice && mHasOfflineIMs; bool offline_ims_visible = LLIMFloater::isVisible(floater) && floater->hasFocus(); // we don't need to listen for im floater with this conversation is opened // if floater is already opened or this conversation doesn't have unread offline messages - if (has_offline_ims && !offline_ims_visible) + if (mHasOfflineIMs && !offline_ims_visible) { mIMFloaterShowedConnection = LLIMFloater::setIMFloaterShowedCallback(boost::bind(&LLConversation::onIMFloaterShown, this, _1)); } @@ -393,7 +387,7 @@ bool LLConversationLog::saveToFile(const std::string& filename) fprintf(fp, "[%d] %d %d %d %s| %s %s %s|\n", (S32)conv_it->getTime(), (S32)conv_it->getConversationType(), - (S32)conv_it->isVoice(), + (S32)0, (S32)conv_it->hasOfflineMessages(), conv_it->getConversationName().c_str(), participant_id.c_str(), @@ -423,10 +417,11 @@ bool LLConversationLog::loadFromFile(const std::string& filename) char part_id_buffer[MAX_STRING]; char conv_id_buffer[MAX_STRING]; char history_file_name[MAX_STRING]; - int is_voice; int has_offline_ims; int stype; S32 time; + // before CHUI-348 it was a flag of conversation voice state + int prereserved_unused; while (!feof(fp) && fgets(buffer, MAX_STRING, fp)) { @@ -437,7 +432,7 @@ bool LLConversationLog::loadFromFile(const std::string& filename) sscanf(buffer, "[%d] %d %d %d %[^|]| %s %s %[^|]|", &time, &stype, - &is_voice, + &prereserved_unused, &has_offline_ims, conv_name_buffer, part_id_buffer, @@ -446,7 +441,6 @@ bool LLConversationLog::loadFromFile(const std::string& filename) Conversation_params params(time); params.mConversationType = (SessionType)stype; - params.mIsVoice = is_voice; params.mHasOfflineIMs = has_offline_ims; params.mConversationName = std::string(conv_name_buffer); params.mParticipantID = LLUUID(part_id_buffer); diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h index 6fff7d6772..373406aa6f 100644 --- a/indra/newview/llconversationlog.h +++ b/indra/newview/llconversationlog.h @@ -56,11 +56,9 @@ public: const LLUUID& getParticipantID() const { return mParticipantID; } const std::string& getTimestamp() const { return mTimestamp; } const time_t& getTime() const { return mTime; } - bool isVoice() const { return mIsVoice; } bool hasOfflineMessages() const { return mHasOfflineIMs; } - void setIsVoice(bool is_voice); - void setConverstionName(std::string conv_name) { mConversationName = conv_name; } + void setConverstionName(std::string conv_name) { mConversationName = conv_name; } bool isOlderThan(U32 days) const; @@ -95,7 +93,6 @@ private: std::string mHistoryFileName; LLUUID mSessionID; LLUUID mParticipantID; - bool mIsVoice; bool mHasOfflineIMs; std::string mTimestamp; // last interaction time in form of: mm/dd/yyyy hh:mm }; diff --git a/indra/newview/llconversationloglistitem.cpp b/indra/newview/llconversationloglistitem.cpp index fac6130371..b4ae5f19da 100644 --- a/indra/newview/llconversationloglistitem.cpp +++ b/indra/newview/llconversationloglistitem.cpp @@ -49,10 +49,9 @@ LLConversationLogListItem::LLConversationLogListItem(const LLConversation* conve LLIMFloater* floater = LLIMFloater::findInstance(mConversation->getSessionID()); - bool has_offline_ims = !mConversation->isVoice() && mConversation->hasOfflineMessages(); bool ims_are_read = LLIMFloater::isVisible(floater) && floater->hasFocus(); - if (has_offline_ims && !ims_are_read) + if (mConversation->hasOfflineMessages() && !ims_are_read) { mIMFloaterShowedConnection = LLIMFloater::setIMFloaterShowedCallback(boost::bind(&LLConversationLogListItem::onIMFloaterShown, this, _1)); } @@ -104,16 +103,9 @@ void LLConversationLogListItem::initIcons() break; } - if (mConversation->isVoice()) + if (mConversation->hasOfflineMessages()) { - getChild("voice_session_icon")->setVisible(TRUE); - } - else - { - if (mConversation->hasOfflineMessages()) - { getChild("unread_ims_icon")->setVisible(TRUE); - } } } -- cgit v1.2.3