diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-01-29 10:24:45 -0800 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-01-29 10:24:45 -0800 |
commit | 9459fd9137a2901f964bb307348b13d222c8287b (patch) | |
tree | 580499326c48072051dd6afcdd475e4676d1837c /indra/newview/llnotificationhandlerutil.cpp | |
parent | a328cdc83015a46a87377ad3c822c730c03026a3 (diff) | |
parent | 092f93b0c1084edf68fc0536aa03a3c7b816505b (diff) |
PE merge.
Diffstat (limited to 'indra/newview/llnotificationhandlerutil.cpp')
-rw-r--r-- | indra/newview/llnotificationhandlerutil.cpp | 78 |
1 files changed, 74 insertions, 4 deletions
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 02f948eca9..f9b3b7187a 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["notifiaction_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(); + } +} |