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.cpp78
1 files changed, 74 insertions, 4 deletions
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index 02f948eca9..16218f6d53 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;
@@ -91,6 +92,13 @@ bool LLHandlerUtil::canSpawnIMSession(const LLNotificationPtr& notification)
}
// static
+bool LLHandlerUtil::canAddNotifPanelToIM(const LLNotificationPtr& notification)
+{
+ return OFFER_FRIENDSHIP == notification->getName();
+}
+
+
+// static
bool LLHandlerUtil::canSpawnSessionAndLogToIM(const LLNotificationPtr& notification)
{
return canLogToIM(notification) && canSpawnIMSession(notification);
@@ -137,6 +145,12 @@ void LLHandlerUtil::logToIM(const EInstantMessage& session_type,
// 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(
@@ -148,8 +162,16 @@ 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);
+ 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);
+ }
}
}
@@ -191,7 +213,7 @@ void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChat
}
// 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);
@@ -199,8 +221,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
@@ -210,3 +234,49 @@ 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);
+ session->mMsgs.push_front(offer);
+
+ LLIMFloater::show(session_id);
+}
+
+// static
+void LLHandlerUtil::reloadIMFloaterMessages(
+ const LLNotificationPtr& notification)
+{
+ LLUUID from_id = notification->getPayload()["from_id"];
+ LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, from_id);
+ LLIMFloater* im_floater = LLFloaterReg::findTypedInstance<LLIMFloater>(
+ "impanel", session_id);
+ if (im_floater != NULL)
+ {
+ LLIMModel::LLIMSession * session = LLIMModel::getInstance()->findIMSession(
+ session_id);
+ if(session != NULL)
+ {
+ session->mMsgs.clear();
+ std::list<LLSD> chat_history;
+ LLLogChat::loadAllHistory(session->mHistoryFileName, chat_history);
+ session->addMessagesFromHistory(chat_history);
+ }
+
+ im_floater->reloadMessages();
+ }
+}