summaryrefslogtreecommitdiff
path: root/indra/newview/llnotificationhandlerutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llnotificationhandlerutil.cpp')
-rw-r--r--indra/newview/llnotificationhandlerutil.cpp85
1 files changed, 79 insertions, 6 deletions
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index fba5773602..9de9998cbd 100644
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -39,6 +39,7 @@
#include "llagent.h"
#include "llfloaterreg.h"
#include "llnearbychat.h"
+#include "llimfloater.h"
using namespace LLNotificationsUI;
@@ -53,6 +54,8 @@ const static std::string GRANTED_MODIFY_RIGHTS("GrantedModifyRights"),
OFFER_FRIENDSHIP("OfferFriendship"),
FRIENDSHIP_ACCEPTED("FriendshipAccepted"),
FRIENDSHIP_OFFERED("FriendshipOffered"),
+ FRIENDSHIP_ACCEPTED_BYME("FriendshipAcceptedByMe"),
+ FRIENDSHIP_DECLINED_BYME("FriendshipDeclinedByMe"),
FRIEND_ONLINE("FriendOnline"), FRIEND_OFFLINE("FriendOffline"),
SERVER_OBJECT_MESSAGE("ServerObjectMessage"),
TELEPORT_OFFERED("TeleportOffered");
@@ -65,6 +68,8 @@ bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification)
|| PAYMENT_RECIVED == notification->getName()
|| OFFER_FRIENDSHIP == notification->getName()
|| FRIENDSHIP_OFFERED == notification->getName()
+ || FRIENDSHIP_ACCEPTED_BYME == notification->getName()
+ || FRIENDSHIP_DECLINED_BYME == notification->getName()
|| SERVER_OBJECT_MESSAGE == notification->getName()
|| INVENTORY_ACCEPTED == notification->getName()
|| INVENTORY_DECLINED == notification->getName();
@@ -91,6 +96,14 @@ bool LLHandlerUtil::canSpawnIMSession(const LLNotificationPtr& notification)
}
// static
+bool LLHandlerUtil::canAddNotifPanelToIM(const LLNotificationPtr& notification)
+{
+ return OFFER_FRIENDSHIP == notification->getName()
+ || USER_GIVE_ITEM == notification->getName();
+}
+
+
+// static
bool LLHandlerUtil::canSpawnSessionAndLogToIM(const LLNotificationPtr& notification)
{
return canLogToIM(notification) && canSpawnIMSession(notification);
@@ -123,16 +136,29 @@ void LLHandlerUtil::logToIM(const EInstantMessage& session_type,
message);
// restore active session id
- LLIMModel::instance().setActiveSessionID(active_session_id);
+ if (active_session_id.isNull())
+ {
+ LLIMModel::instance().resetActiveSessionID();
+ }
+ else
+ {
+ LLIMModel::instance().setActiveSessionID(active_session_id);
+ }
}
}
// static
void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification)
{
+ logToIMP2P(notification, false);
+}
+
+// static
+void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification, bool to_file_only)
+{
const std::string name = LLHandlerUtil::getSubstitutionName(notification);
- const std::string session_name = notification->getPayload().has(
+ std::string session_name = notification->getPayload().has(
"SESSION_NAME") ? notification->getPayload()["SESSION_NAME"].asString() : name;
// don't create IM p2p session with objects, it's necessary condition to log
@@ -141,8 +167,28 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification)
{
LLUUID from_id = notification->getPayload()["from_id"];
- logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(),
- from_id, from_id);
+ //*HACK for ServerObjectMessage the sesson name is really weird, see EXT-4779
+ if (SERVER_OBJECT_MESSAGE == notification->getName())
+ {
+ session_name = "chat";
+ }
+
+ //there still appears a log history file with weird name " .txt"
+ if (" " == session_name || "{waiting}" == session_name || "{nobody}" == session_name)
+ {
+ llwarning("Weird session name (" + session_name + ") for notification " + notification->getName(), 666)
+ }
+
+ if(to_file_only)
+ {
+ logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(),
+ LLUUID(), LLUUID());
+ }
+ else
+ {
+ logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(),
+ from_id, from_id);
+ }
}
}
@@ -158,6 +204,7 @@ void LLHandlerUtil::logGroupNoticeToIMGroup(
llwarns
<< "Group notice for unkown group: "
<< payload["group_id"].asUUID() << llendl;
+ return;
}
const std::string group_name = groupData.mName;
@@ -179,12 +226,13 @@ void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChat
{
LLChat chat_msg(notification->getMessage());
chat_msg.mSourceType = type;
+ chat_msg.mFromName = SYSTEM_FROM;
nearby_chat->addMessage(chat_msg);
}
}
// static
-void LLHandlerUtil::spawnIMSession(const std::string& name, const LLUUID& from_id)
+LLUUID LLHandlerUtil::spawnIMSession(const std::string& name, const LLUUID& from_id)
{
LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, from_id);
@@ -192,8 +240,10 @@ void LLHandlerUtil::spawnIMSession(const std::string& name, const LLUUID& from_i
session_id);
if (session == NULL)
{
- LLIMMgr::instance().addSession(name, IM_NOTHING_SPECIAL, from_id);
+ session_id = LLIMMgr::instance().addSession(name, IM_NOTHING_SPECIAL, from_id);
}
+
+ return session_id;
}
// static
@@ -203,3 +253,26 @@ std::string LLHandlerUtil::getSubstitutionName(const LLNotificationPtr& notifica
? notification->getSubstitutions()["NAME"]
: notification->getSubstitutions()["[NAME]"];
}
+
+// static
+void LLHandlerUtil::addNotifPanelToIM(const LLNotificationPtr& notification)
+{
+ const std::string name = LLHandlerUtil::getSubstitutionName(notification);
+ LLUUID from_id = notification->getPayload()["from_id"];
+
+ LLUUID session_id = spawnIMSession(name, from_id);
+ // add offer to session
+ LLIMModel::LLIMSession * session = LLIMModel::getInstance()->findIMSession(
+ session_id);
+ llassert_always(session != NULL);
+
+ LLSD offer;
+ offer["notification_id"] = notification->getID();
+ offer["from_id"] = notification->getPayload()["from_id"];
+ offer["from"] = name;
+ offer["time"] = LLLogChat::timestamp(true);
+ offer["index"] = (LLSD::Integer)session->mMsgs.size();
+ session->mMsgs.push_front(offer);
+
+ LLIMFloater::show(session_id);
+}