diff options
author | Andrew A. de Laix <alain@lindenlab.com> | 2010-11-02 15:59:24 -0700 |
---|---|---|
committer | Andrew A. de Laix <alain@lindenlab.com> | 2010-11-02 15:59:24 -0700 |
commit | 0f6c3a167850a34bad9982ed29eb25c141845320 (patch) | |
tree | 800d474cce6f33a1eb05a6838802235aff58a83e /indra/newview/llnearbychat.cpp | |
parent | be151807222ffa5972256aa9a392e8a319eae5ee (diff) | |
parent | 9cc290ef8fccdc585027d84ac9cfb864ed933061 (diff) |
Merge
Diffstat (limited to 'indra/newview/llnearbychat.cpp')
-rw-r--r-- | indra/newview/llnearbychat.cpp | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index f16cc4cef4..180695e40b 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -46,6 +46,8 @@ #include "llchathistory.h" #include "llstylemap.h" +#include "llavatarnamecache.h" + #include "lldraghandle.h" #include "llbottomtray.h" @@ -179,7 +181,21 @@ void LLNearbyChat::addMessage(const LLChat& chat,bool archive,const LLSD &args) if (gSavedPerAccountSettings.getBOOL("LogNearbyChat")) { - LLLogChat::saveHistory("chat", chat); + std::string from_name = chat.mFromName; + + if (chat.mSourceType == CHAT_SOURCE_AGENT) + { + // if the chat is coming from an agent, log the complete name + LLAvatarName av_name; + LLAvatarNameCache::get(chat.mFromID, &av_name); + + if (!av_name.mIsDisplayNameDefault) + { + from_name = av_name.getCompleteName(); + } + } + + LLLogChat::saveHistory("chat", from_name, chat.mFromID, chat.mText); } } @@ -248,11 +264,23 @@ void LLNearbyChat::processChatHistoryStyleUpdate(const LLSD& newvalue) nearby_chat->updateChatHistoryStyle(); } -bool isTwoWordsName(const std::string& name) +bool isWordsName(const std::string& name) { - //checking for a single space - S32 pos = name.find(' ', 0); - return std::string::npos != pos && name.rfind(' ', name.length()) == pos && 0 != pos && name.length()-1 != pos; + // checking to see if it's display name plus username in parentheses + S32 open_paren = name.find(" (", 0); + S32 close_paren = name.find(')', 0); + + if (open_paren != std::string::npos && + close_paren == name.length()-1) + { + return true; + } + else + { + //checking for a single space + S32 pos = name.find(' ', 0); + return std::string::npos != pos && name.rfind(' ', name.length()) == pos && 0 != pos && name.length()-1 != pos; + } } void LLNearbyChat::loadHistory() @@ -275,9 +303,10 @@ void LLNearbyChat::loadHistory() from_id = msg[IM_FROM_ID].asUUID(); } else - { - gCacheName->getUUID(from, from_id); - } + { + std::string legacy_name = gCacheName->buildLegacyName(from); + gCacheName->getUUID(legacy_name, from_id); + } LLChat chat; chat.mFromName = from; @@ -286,18 +315,15 @@ void LLNearbyChat::loadHistory() chat.mTimeStr = msg[IM_TIME].asString(); chat.mChatStyle = CHAT_STYLE_HISTORY; - if (msg.has(IM_SOURCE_TYPE)) - { - S32 source_type = msg[IM_SOURCE_TYPE].asInteger(); - chat.mSourceType = (EChatSourceType)source_type; - } - else if (from_id.isNull() && SYSTEM_FROM == from) + chat.mSourceType = CHAT_SOURCE_AGENT; + if (from_id.isNull() && SYSTEM_FROM == from) { chat.mSourceType = CHAT_SOURCE_SYSTEM; + } else if (from_id.isNull()) { - chat.mSourceType = isTwoWordsName(from) ? CHAT_SOURCE_UNKNOWN : CHAT_SOURCE_OBJECT; + chat.mSourceType = isWordsName(from) ? CHAT_SOURCE_UNKNOWN : CHAT_SOURCE_OBJECT; } addMessage(chat, true, do_not_log); |