From e2b011590d5cdbbc161c5cf1b94ceffaf69763ec Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Wed, 5 Dec 2012 01:48:09 -0500 Subject: [PATCH] Fix up the Name System just a little bit more. Better viewed without space changes Pretty much add support for sending LLAvatarName and std::string to become a name via the system... Also a bit of a revert for llcallingcard.cpp in this regard, just allow it to use a callback along with the new support, but still handle the actual name switching in LLAvatarNameCache. Fixes a problem I was having with "[NAME] is Online" notifications appearing early on, only. --- indra/llmessage/llavatarnamecache.cpp | 28 ++++++++------- indra/llmessage/llavatarnamecache.h | 7 ++-- indra/newview/llcallingcard.cpp | 51 ++++++++++++++++++--------- 3 files changed, 54 insertions(+), 32 deletions(-) diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 14b02cd00..af6fb01ec 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -666,22 +666,24 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) // Return true when name has been set to Phoenix Name System Name, if not return false. bool LLAvatarNameCache::getPNSName(const LLUUID& agent_id, std::string& name) { - static LLCachedControl phoenix_name_system("PhoenixNameSystem", 0); LLAvatarName avatar_name; - if (LLAvatarNameCache::get(agent_id, &avatar_name)) + if (get(agent_id, &avatar_name)) + getPNSName(avatar_name, name); + else return false; + return true; +} + +// get() with callback compatible version of getPNSName +void LLAvatarNameCache::getPNSName(const LLAvatarName& avatar_name, std::string& name) +{ + static LLCachedControl phoenix_name_system("PhoenixNameSystem", 0); + switch (phoenix_name_system) { - switch (phoenix_name_system) - { - case 0 : name = avatar_name.getLegacyName(); break; - case 1 : name = avatar_name.getCompleteName(); break; - case 2 : name = avatar_name.mDisplayName; break; - default : name = avatar_name.getLegacyName(); break; - } - return true; + case 0 : name = avatar_name.getLegacyName(); break; + case 1 : name = avatar_name.getCompleteName(); break; + case 2 : name = avatar_name.mDisplayName; break; + default : name = avatar_name.getLegacyName(); break; } - if (gCacheName->getFullName(agent_id, name)) //We've failed, try to get the legacy name anyway - return false; //Legacy name is still a failure, it's not a PNSName, afterall. - return false; } void LLAvatarNameCache::fireSignal(const LLUUID& agent_id, diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index ffe692afa..b5745c77b 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -65,9 +65,12 @@ namespace LLAvatarNameCache // If name is in cache, returns true and fills in provided LLAvatarName // otherwise returns false bool get(const LLUUID& agent_id, LLAvatarName *av_name); - // If get() succeeds, returns true and fills in name string according to Phoenix Name System - // otherwise returns false + // If get() succeeds, returns true and fills in name string + // via void function below, otherwise returns false bool getPNSName(const LLUUID& agent_id, std::string& name); + // Perform a filling of name string according to Phoenix Name System, + // when we have an LLAvatarName already. + void getPNSName(const LLAvatarName& avatar_name, std::string& name); // Callback types for get() below typedef boost::signals2::signal< diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 3aa786ff5..34b8785c9 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -99,6 +99,11 @@ const F32 OFFLINE_SECONDS = FIND_FREQUENCY + 8.0f; // static LLAvatarTracker LLAvatarTracker::sInstance; +static void on_avatar_name_cache_notify(const LLUUID& agent_id, + const LLAvatarName& av_name, + bool online, + LLSD payload); + ///---------------------------------------------------------------------------- /// Class LLAvatarTracker ///---------------------------------------------------------------------------- @@ -706,23 +711,9 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) if(chat_notify) { // Look up the name of this agent for the notification - std::string name; - LLSD args; - if (LLAvatarNameCache::getPNSName(agent_id, name)) - args["NAME"] = name; - - // Popup a notify box with online status of this agent - LLNotificationPtr notification = LLNotificationsUtil::add(online ? "FriendOnline" : "FriendOffline", args, payload); - - // If there's an open IM session with this agent, send a notification there too. - LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, agent_id); - LLFloaterIMPanel *floater = gIMMgr->findFloaterBySession(session_id); - if (floater) - { - std::string notifyMsg = notification->getMessage(); - if (!notifyMsg.empty()) - floater->addHistoryLine(notifyMsg,gSavedSettings.getColor4("SystemChatColor")); - } + LLAvatarNameCache::get(agent_id, + boost::bind(&on_avatar_name_cache_notify, + _1, _2, online, payload)); } mModifyMask |= LLFriendObserver::ONLINE; @@ -731,6 +722,32 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) } } +static void on_avatar_name_cache_notify(const LLUUID& agent_id, + const LLAvatarName& av_name, + bool online, + LLSD payload) +{ + // Popup a notify box with online status of this agent + // Use display name only because this user is your friend + std::string name; + LLAvatarNameCache::getPNSName(av_name, name); + LLSD args; + args["NAME"] = name; + + // Popup a notify box with online status of this agent + LLNotificationPtr notification = LLNotificationsUtil::add(online ? "FriendOnline" : "FriendOffline", args, payload); + + // If there's an open IM session with this agent, send a notification there too. + LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, agent_id); + LLFloaterIMPanel *floater = gIMMgr->findFloaterBySession(session_id); + if (floater) + { + std::string notifyMsg = notification->getMessage(); + if (!notifyMsg.empty()) + floater->addHistoryLine(notifyMsg,gSavedSettings.getColor4("SystemChatColor")); + } +} + void LLAvatarTracker::formFriendship(const LLUUID& id) { if(id.notNull())