summaryrefslogtreecommitdiff
path: root/indra/newview/llimview.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2010-11-04 18:09:35 -0700
committerMerov Linden <merov@lindenlab.com>2010-11-04 18:09:35 -0700
commitba3307b8d0f2ceb40454174a6593f3f98ce98b65 (patch)
tree7c016ab72795543361d206de5344b34a6a823fdf /indra/newview/llimview.cpp
parentdac53830f1a67c8657ced9c39eccedbadf149bd9 (diff)
parent40979589afc5c91cab977307a1e400315b1c8a8f (diff)
merge with STORM-105
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r--indra/newview/llimview.cpp182
1 files changed, 136 insertions, 46 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 01e1c3caa0..914e7a3df0 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)
@@ -283,7 +288,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 +423,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];
@@ -515,6 +525,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;
@@ -533,6 +557,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
@@ -716,8 +746,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
@@ -1028,17 +1068,27 @@ void LLIMModel::sendMessage(const std::string& utf8_text,
if( session == 0)//??? shouldn't really happen
{
LLRecentPeople::instance().add(other_participant_id);
+ return;
}
- else
+ // IM_SESSION_INVITE means that this is an Ad-hoc incoming chat
+ // (it can be also Group chat but it is checked above)
+ // In this case mInitialTargetIDs contains Ad-hoc session ID and it should not be added
+ // 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;
+
+ if (IM_SESSION_CONFERENCE_START == dialog) // outgoing ad-hoc session
{
- // IM_SESSION_INVITE means that this is an Ad-hoc incoming chat
- // (it can be also Group chat but it is checked above)
- // In this case mInitialTargetIDs contains Ad-hoc session ID and it should not be added
- // 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)
- addSpeakersToRecent(im_session_id);
+ // Add only online members of conference to recent list (EXT-8658)
+ addSpeakersToRecent(im_session_id);
+ }
+ else // outgoing P2P session
+ {
+ // Add the recepient of the session.
+ if (!session->mInitialTargetIDs.empty())
+ {
+ LLRecentPeople::instance().add(*(session->mInitialTargetIDs.begin()));
+ }
}
}
}
@@ -1764,11 +1814,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);
@@ -1923,16 +1985,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);
@@ -1960,6 +2027,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)
{
@@ -2067,8 +2152,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);
}
}
@@ -2589,7 +2677,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
{
@@ -2599,9 +2688,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();
@@ -2822,13 +2911,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);
}
}