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.
This commit is contained in:
Lirusaito
2012-12-05 01:48:09 -05:00
parent 2c48161595
commit e2b011590d
3 changed files with 54 additions and 32 deletions

View File

@@ -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. // 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) bool LLAvatarNameCache::getPNSName(const LLUUID& agent_id, std::string& name)
{ {
static LLCachedControl<S32> phoenix_name_system("PhoenixNameSystem", 0);
LLAvatarName avatar_name; 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<S32> 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 0 : name = avatar_name.getLegacyName(); break; case 2 : name = avatar_name.mDisplayName; break;
case 1 : name = avatar_name.getCompleteName(); break; default : name = avatar_name.getLegacyName(); break;
case 2 : name = avatar_name.mDisplayName; break;
default : name = avatar_name.getLegacyName(); break;
}
return true;
} }
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, void LLAvatarNameCache::fireSignal(const LLUUID& agent_id,

View File

@@ -65,9 +65,12 @@ namespace LLAvatarNameCache
// If name is in cache, returns true and fills in provided LLAvatarName // If name is in cache, returns true and fills in provided LLAvatarName
// otherwise returns false // otherwise returns false
bool get(const LLUUID& agent_id, LLAvatarName *av_name); bool get(const LLUUID& agent_id, LLAvatarName *av_name);
// If get() succeeds, returns true and fills in name string according to Phoenix Name System // If get() succeeds, returns true and fills in name string
// otherwise returns false // via void function below, otherwise returns false
bool getPNSName(const LLUUID& agent_id, std::string& name); 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 // Callback types for get() below
typedef boost::signals2::signal< typedef boost::signals2::signal<

View File

@@ -99,6 +99,11 @@ const F32 OFFLINE_SECONDS = FIND_FREQUENCY + 8.0f;
// static // static
LLAvatarTracker LLAvatarTracker::sInstance; LLAvatarTracker LLAvatarTracker::sInstance;
static void on_avatar_name_cache_notify(const LLUUID& agent_id,
const LLAvatarName& av_name,
bool online,
LLSD payload);
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
/// Class LLAvatarTracker /// Class LLAvatarTracker
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
@@ -706,23 +711,9 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online)
if(chat_notify) if(chat_notify)
{ {
// Look up the name of this agent for the notification // Look up the name of this agent for the notification
std::string name; LLAvatarNameCache::get(agent_id,
LLSD args; boost::bind(&on_avatar_name_cache_notify,
if (LLAvatarNameCache::getPNSName(agent_id, name)) _1, _2, online, payload));
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"));
}
} }
mModifyMask |= LLFriendObserver::ONLINE; 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) void LLAvatarTracker::formFriendship(const LLUUID& id)
{ {
if(id.notNull()) if(id.notNull())