diff options
author | James Cook <james@lindenlab.com> | 2010-05-25 11:40:29 -0700 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2010-05-25 11:40:29 -0700 |
commit | d6ea42984553b7adb6f26cf2ed094d32e36814d2 (patch) | |
tree | 25fe04a20b89ce63ad5c6b32856371c46a728c08 /indra | |
parent | fb51f985c35f5dae85057ad932928b8fcd44cc73 (diff) |
DEV-50013 Display names load at startup in local chat/IM history
Had to change the chat log file format to include agent_id.
Code will load viewer 2.0 logs, but viewer 2.0 will just discard
data from 2.1 logs, which seems OK. Reviewed with Leyla.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llimview.cpp | 24 | ||||
-rw-r--r-- | indra/newview/lllogchat.cpp | 27 | ||||
-rw-r--r-- | indra/newview/lllogchat.h | 2 | ||||
-rw-r--r-- | indra/newview/llnearbychat.cpp | 8 |
4 files changed, 47 insertions, 14 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index e915d3ad70..e6db942bad 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -270,7 +270,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) { @@ -405,13 +405,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()) { + from_id = msg[IM_FROM_ID].asUUID(); + } + else + { + // Legacy chat logs only wrote the legacy name, not the agent_id gCacheName->getUUID(from, from_id); } - std::string timestamp = msg[IM_TIME]; std::string text = msg[IM_TEXT]; @@ -2582,7 +2586,7 @@ void LLIMMgr::inviteToSession( { if (caller_name.empty()) { - gCacheName->get(caller_id, false, + gCacheName->get(caller_id, false, // voice boost::bind(&LLIMMgr::onInviteNameLookup, payload, _1, _2, _3)); } else @@ -2816,12 +2820,14 @@ void LLIMMgr::noteOfflineUsers( for(S32 i = 0; i < count; ++i) { info = at.getBuddyInfo(ids.get(i)); - std::string full_name; - if(info && !info->isOnline() - && gCacheName->getFullName(ids.get(i), full_name)) + LLAvatarName av_name; + if (info + && !info->isOnline() + && LLAvatarNameCache::get(ids.get(i), &av_name)) { LLUIString offline = LLTrans::getString("offline_message"); - offline.setArg("[NAME]", full_name); + // Use display name only because this user is your friend + offline.setArg("[NAME]", av_name.mDisplayName); im_model.proccessOnlineOfflineNotification(session_id, offline); } } diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index be8b2363ad..1d348834fe 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -426,6 +426,12 @@ void LLChatLogFormatter::format(const LLSD& im, std::ostream& ostr) const return; } + if (im[IM_FROM_ID].isDefined()) + { + LLUUID from_id = im[IM_FROM_ID].asUUID(); + ostr << '{' << from_id.asString() << '}'; + } + if (im[IM_TIME].isDefined()) { std::string timestamp = im[IM_TIME].asString(); @@ -456,15 +462,32 @@ void LLChatLogFormatter::format(const LLSD& im, std::ostream& ostr) const } } -bool LLChatLogParser::parse(std::string& raw, LLSD& im) +bool LLChatLogParser::parse(const std::string& raw, LLSD& im) { if (!raw.length()) return false; im = LLSD::emptyMap(); + // In Viewer 2.1 we added UUID to chat/IM logging so we can look up + // display names + std::string line = raw; + if (raw[0] == '{') + { + const S32 UUID_LEN = 36; + size_t pos = line.find_first_of('}'); + // If it matches, pos will be 37 + if (pos != line.npos && pos > UUID_LEN) + { + std::string uuid_string = line.substr(1, UUID_LEN); + LLUUID from_id(uuid_string); + im[IM_FROM_ID] = from_id; + line = line.substr(pos + 1); + } + } + //matching a timestamp boost::match_results<std::string::const_iterator> matches; - if (!boost::regex_match(raw, matches, TIMESTAMP_AND_STUFF)) return false; + if (!boost::regex_match(line, matches, TIMESTAMP_AND_STUFF)) return false; bool has_timestamp = matches[IDX_TIMESTAMP].matched; if (has_timestamp) diff --git a/indra/newview/lllogchat.h b/indra/newview/lllogchat.h index 4290e4bbc0..a67b58e55b 100644 --- a/indra/newview/lllogchat.h +++ b/indra/newview/lllogchat.h @@ -106,7 +106,7 @@ public: * * @return false if failed to parse mandatory data - message text */ - static bool parse(std::string& raw, LLSD& im); + static bool parse(const std::string& raw, LLSD& im); protected: LLChatLogParser(); diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index f1c13de8bb..74ede67c97 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -301,8 +301,12 @@ void LLNearbyChat::loadHistory() 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()) + { + from_id = msg[IM_FROM_ID].asUUID(); + } + else { gCacheName->getUUID(from, from_id); } |