diff options
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r-- | indra/newview/llimview.cpp | 213 |
1 files changed, 149 insertions, 64 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 493398c68a..02a693b9a0 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -28,6 +28,7 @@ #include "llimview.h" +#include "llavatarnamecache.h" // IDEVO #include "llfloaterreg.h" #include "llfontgl.h" #include "llgl.h" @@ -64,11 +65,6 @@ #include "llviewerparcelmgr.h" -const static std::string IM_TIME("time"); -const static std::string IM_TEXT("message"); -const static std::string IM_FROM("from"); -const static std::string IM_FROM_ID("from_id"); - const static std::string ADHOC_NAME_SUFFIX(" Conference"); const static std::string NEARBY_P2P_BY_OTHER("nearby_P2P_by_other"); @@ -101,6 +97,20 @@ BOOL LLSessionTimeoutTimer::tick() return TRUE; } +static void on_avatar_name_cache_toast(const LLUUID& agent_id, + const LLAvatarName& av_name, + LLSD msg) +{ + LLSD args; + args["MESSAGE"] = msg["message"]; + args["TIME"] = msg["time"]; + // *TODO: Can this ever be an object name or group name? + args["FROM"] = av_name.getCompleteName(); + args["FROM_ID"] = msg["from_id"]; + args["SESSION_ID"] = msg["session_id"]; + LLNotificationsUtil::add("IMToast", args, LLSD(), boost::bind(&LLIMFloater::show, msg["session_id"].asUUID())); +} + void toast_callback(const LLSD& msg){ // do not show toast in busy mode or it goes from agent if (gAgent.getBusy() || gAgent.getID() == msg["from_id"]) @@ -128,14 +138,9 @@ void toast_callback(const LLSD& msg){ return; } - LLSD args; - args["MESSAGE"] = msg["message"]; - args["TIME"] = msg["time"]; - args["FROM"] = msg["from"]; - args["FROM_ID"] = msg["from_id"]; - args["SESSION_ID"] = msg["session_id"]; - - LLNotificationsUtil::add("IMToast", args, LLSD(), boost::bind(&LLIMFloater::show, msg["session_id"].asUUID())); + LLAvatarNameCache::get(msg["from_id"].asUUID(), + boost::bind(&on_avatar_name_cache_toast, + _1, _2, msg)); } void LLIMModel::setActiveSessionID(const LLUUID& session_id) @@ -252,21 +257,17 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& // history files have consistent (English) names in different locales. if (isAdHocSessionType() && IM_SESSION_INVITE == type) { - // Name here has a form of "<Avatar's name> Conference" - // Lets update it to localize the "Conference" word. See EXT-8429. - S32 separator_index = mName.rfind(" "); - std::string name = mName.substr(0, separator_index); - ++separator_index; - std::string conference_word = mName.substr(separator_index, mName.length()); + LLAvatarNameCache::get(mOtherParticipantID, + boost::bind(&LLIMModel::LLIMSession::onAdHocNameCache, + this, _2)); + } +} - // additional check that session name is what we expected - if ("Conference" == conference_word) - { +void LLIMModel::LLIMSession::onAdHocNameCache(const LLAvatarName& av_name) +{ LLStringUtil::format_map_t args; - args["[AGENT_NAME]"] = name; + args["[AGENT_NAME]"] = av_name.getCompleteName(); LLTrans::findString(mName, "conference-title-incoming", args); - } - } } void LLIMModel::LLIMSession::onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state, const LLVoiceChannel::EDirection& direction) @@ -283,7 +284,7 @@ void LLIMModel::LLIMSession::onVoiceChannelStateChanged(const LLVoiceChannel::ES // no text notifications break; case P2P_SESSION: - gCacheName->getFullName(mOtherParticipantID, other_avatar_name); + gCacheName->getFullName(mOtherParticipantID, other_avatar_name); // voice if(direction == LLVoiceChannel::INCOMING_CALL) { @@ -418,12 +419,17 @@ void LLIMModel::LLIMSession::addMessagesFromHistory(const std::list<LLSD>& histo const LLSD& msg = *it; std::string from = msg[IM_FROM]; - LLUUID from_id = LLUUID::null; - if (msg[IM_FROM_ID].isUndefined()) + LLUUID from_id; + if (msg[IM_FROM_ID].isDefined()) { - gCacheName->getUUID(from, from_id); + from_id = msg[IM_FROM_ID].asUUID(); + } + else + { + // convert it to a legacy name if we have a complete name + std::string legacy_name = gCacheName->buildLegacyName(from); + gCacheName->getUUID(legacy_name, from_id); } - std::string timestamp = msg[IM_TIME]; std::string text = msg[IM_TEXT]; @@ -495,6 +501,11 @@ LLIMModel::LLIMSession* LLIMModel::findAdHocIMSession(const uuid_vec_t& ids) return NULL; } +bool LLIMModel::LLIMSession::isOutgoingAdHoc() +{ + return IM_SESSION_CONFERENCE_START == mType; +} + bool LLIMModel::LLIMSession::isAdHoc() { return IM_SESSION_CONFERENCE_START == mType || (IM_SESSION_INVITE == mType && !gAgent.isInGroup(mSessionID)); @@ -510,6 +521,20 @@ bool LLIMModel::LLIMSession::isOtherParticipantAvaline() return !mOtherParticipantIsAvatar; } +void LLIMModel::LLIMSession::onAvatarNameCache(const LLUUID& avatar_id, const LLAvatarName& av_name) +{ + if (av_name.mLegacyFirstName.empty()) + { + // if mLegacyFirstName is empty it means display names is off and the + // data came from the gCacheName, mDisplayName will be the legacy name + mHistoryFileName = LLCacheName::cleanFullName(av_name.mDisplayName); + } + else + { + mHistoryFileName = LLCacheName::cleanFullName(av_name.getLegacyName()); + } +} + void LLIMModel::LLIMSession::buildHistoryFileName() { mHistoryFileName = mName; @@ -528,6 +553,12 @@ void LLIMModel::LLIMSession::buildHistoryFileName() //in case of incoming ad-hoc sessions mHistoryFileName = mName + " " + LLLogChat::timestamp(true) + " " + mSessionID.asString().substr(0, 4); } + + // look up username to use as the log name + if (isP2P()) + { + LLAvatarNameCache::get(mOtherParticipantID, boost::bind(&LLIMModel::LLIMSession::onAvatarNameCache, this, _1, _2)); + } } //static @@ -622,7 +653,10 @@ bool LLIMModel::newSession(const LLUUID& session_id, const std::string& name, co LLIMSession* session = new LLIMSession(session_id, name, type, other_participant_id, ids, voice); mId2SessionMap[session_id] = session; - LLIMMgr::getInstance()->notifyObserverSessionAdded(session_id, name, other_participant_id); + // When notifying observer, name of session is used instead of "name", because they may not be the + // same if it is an adhoc session (in this case name is localized in LLIMSession constructor). + std::string session_name = LLIMModel::getInstance()->getName(session_id); + LLIMMgr::getInstance()->notifyObserverSessionAdded(session_id, session_name, other_participant_id); return true; @@ -708,8 +742,18 @@ bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from, bool LLIMModel::logToFile(const std::string& file_name, const std::string& from, const LLUUID& from_id, const std::string& utf8_text) { if (gSavedPerAccountSettings.getBOOL("LogInstantMessages")) - { - LLLogChat::saveHistory(file_name, from, from_id, utf8_text); + { + std::string from_name = from; + + LLAvatarName av_name; + if (!from_id.isNull() && + LLAvatarNameCache::get(from_id, &av_name) && + !av_name.mIsDisplayNameDefault) + { + from_name = av_name.getCompleteName(); + } + + LLLogChat::saveHistory(file_name, from_name, from_id, utf8_text); return true; } else @@ -1029,24 +1073,25 @@ void LLIMModel::sendMessage(const std::string& utf8_text, // to Recent People to prevent showing of an item with (???)(???). See EXT-8246. // Concrete participants will be added into this list once they sent message in chat. if (IM_SESSION_INVITE == dialog) return; - // Add only online members to recent (EXT-8658) - LLIMSpeakerMgr* speaker_mgr = LLIMModel::getInstance()->getSpeakerManager(im_session_id); - LLSpeakerMgr::speaker_list_t speaker_list; - if(speaker_mgr != NULL) - { - speaker_mgr->getSpeakerList(&speaker_list, true); - } - for(LLSpeakerMgr::speaker_list_t::iterator it = speaker_list.begin(); it != speaker_list.end(); it++) - { - const LLPointer<LLSpeaker>& speakerp = *it; - - LLRecentPeople::instance().add(speakerp->mID); - } + addSpeakersToRecent(im_session_id); } } +} - +void LLIMModel::addSpeakersToRecent(const LLUUID& im_session_id) +{ + LLIMSpeakerMgr* speaker_mgr = LLIMModel::getInstance()->getSpeakerManager(im_session_id); + LLSpeakerMgr::speaker_list_t speaker_list; + if(speaker_mgr != NULL) + { + speaker_mgr->getSpeakerList(&speaker_list, true); + } + for(LLSpeakerMgr::speaker_list_t::iterator it = speaker_list.begin(); it != speaker_list.end(); it++) + { + const LLPointer<LLSpeaker>& speakerp = *it; + LLRecentPeople::instance().add(speakerp->mID); + } } void session_starter_helper( @@ -1755,11 +1800,23 @@ void LLOutgoingCallDialog::show(const LLSD& key) callee_name = LLTextUtil::formatPhoneNumber(callee_name); } - setTitle(callee_name); - LLSD callee_id = mPayload["other_user_id"]; - getChild<LLUICtrl>("calling")->setTextArg("[CALLEE_NAME]", callee_name); - getChild<LLUICtrl>("connecting")->setTextArg("[CALLEE_NAME]", callee_name); + // Beautification: Since you know who you called, just show display name + std::string title = callee_name; + std::string final_callee_name = callee_name; + if (mPayload["session_type"].asInteger() == LLIMModel::LLIMSession::P2P_SESSION) + { + LLAvatarName av_name; + if (LLAvatarNameCache::get(callee_id, &av_name)) + { + final_callee_name = av_name.mDisplayName; + title = av_name.getCompleteName(); + } + } + getChild<LLUICtrl>("calling")->setTextArg("[CALLEE_NAME]", final_callee_name); + getChild<LLUICtrl>("connecting")->setTextArg("[CALLEE_NAME]", final_callee_name); + + setTitle(title); // for outgoing group calls callee_id == group id == session id setIcon(callee_id, callee_id); @@ -1914,16 +1971,21 @@ BOOL LLIncomingCallDialog::postBuild() if (caller_name == "anonymous") { caller_name = getString("anonymous"); + setCallerName(caller_name, caller_name, call_type); } else if (!is_avatar) { caller_name = LLTextUtil::formatPhoneNumber(caller_name); + setCallerName(caller_name, caller_name, call_type); + } + else + { + // Get the full name information + LLAvatarNameCache::get(caller_id, + boost::bind(&LLIncomingCallDialog::onAvatarNameCache, + this, _1, _2, call_type)); } - setTitle(caller_name + " " + call_type); - - LLUICtrl* caller_name_widget = getChild<LLUICtrl>("caller name"); - caller_name_widget->setValue(caller_name + " " + call_type); setIcon(session_id, caller_id); childSetAction("Accept", onAccept, this); @@ -1951,6 +2013,24 @@ BOOL LLIncomingCallDialog::postBuild() return TRUE; } +void LLIncomingCallDialog::setCallerName(const std::string& ui_title, + const std::string& ui_label, + const std::string& call_type) +{ + setTitle(ui_title); + + // call_type may be a string like " is calling." + LLUICtrl* caller_name_widget = getChild<LLUICtrl>("caller name"); + caller_name_widget->setValue(ui_label + " " + call_type); +} + +void LLIncomingCallDialog::onAvatarNameCache(const LLUUID& agent_id, + const LLAvatarName& av_name, + const std::string& call_type) +{ + std::string title = av_name.getCompleteName(); + setCallerName(title, av_name.mDisplayName, call_type); +} void LLIncomingCallDialog::onOpen(const LLSD& key) { @@ -2058,8 +2138,11 @@ void LLIncomingCallDialog::processCallResponse(S32 response) } else { - if (gCacheName->getFullName(caller_id, correct_session_name)) + // *NOTE: really should be using callbacks here + LLAvatarName av_name; + if (LLAvatarNameCache::get(caller_id, &av_name)) { + correct_session_name = av_name.mDisplayName + " (" + av_name.mUsername + ")"; correct_session_name.append(ADHOC_NAME_SUFFIX); } } @@ -2580,7 +2663,8 @@ void LLIMMgr::inviteToSession( { if (caller_name.empty()) { - gCacheName->get(caller_id, FALSE, boost::bind(&LLIMMgr::onInviteNameLookup, payload, _1, _2, _3, _4)); + gCacheName->get(caller_id, false, // voice + boost::bind(&LLIMMgr::onInviteNameLookup, payload, _1, _2, _3)); } else { @@ -2590,9 +2674,9 @@ void LLIMMgr::inviteToSession( } } -void LLIMMgr::onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group) +void LLIMMgr::onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& name, bool is_group) { - payload["caller_name"] = first + " " + last; + payload["caller_name"] = name; payload["session_name"] = payload["caller_name"].asString(); std::string notify_box_type = payload["notify_box_type"].asString(); @@ -2813,13 +2897,14 @@ void LLIMMgr::noteOfflineUsers( for(S32 i = 0; i < count; ++i) { info = at.getBuddyInfo(ids.get(i)); - std::string first, last; - if(info && !info->isOnline() - && gCacheName->getName(ids.get(i), first, last)) + LLAvatarName av_name; + if (info + && !info->isOnline() + && LLAvatarNameCache::get(ids.get(i), &av_name)) { LLUIString offline = LLTrans::getString("offline_message"); - offline.setArg("[FIRST]", first); - offline.setArg("[LAST]", last); + // Use display name only because this user is your friend + offline.setArg("[NAME]", av_name.mDisplayName); im_model.proccessOnlineOfflineNotification(session_id, offline); } } |