diff options
Diffstat (limited to 'indra/newview/llnotificationhandlerutil.cpp')
-rw-r--r-- | indra/newview/llnotificationhandlerutil.cpp | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 857b7e9796..5b54092c5c 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -37,20 +37,46 @@ #include "llnotifications.h" #include "llimview.h" #include "llagent.h" +#include "llfloaterreg.h" +#include "llnearbychat.h" using namespace LLNotificationsUI; const static std::string GRANTED_MODIFY_RIGHTS("GrantedModifyRights"), REVOKED_MODIFY_RIGHTS("RevokedModifyRights"), OBJECT_GIVE_ITEM( "ObjectGiveItem"), OBJECT_GIVE_ITEM_UNKNOWN_USER( - "ObjectGiveItemUnknownUser"), PAYMENT_RECIVED("PaymentRecived"); + "ObjectGiveItemUnknownUser"), PAYMENT_RECIVED("PaymentRecived"), + ADD_FRIEND_WITH_MESSAGE("AddFriendWithMessage"), + USER_GIVE_ITEM("UserGiveItem"), OFFER_FRIENDSHIP("OfferFriendship"), + FRIENDSHIP_ACCEPTED("FriendshipAccepted"), + FRIENDSHIP_OFFERED("FriendshipOffered"), + FRIEND_ONLINE("FriendOnline"), FRIEND_OFFLINE("FriendOffline"), + SERVER_OBJECT_MESSAGE("ServerObjectMessage"); // static bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification) { return GRANTED_MODIFY_RIGHTS == notification->getName() || REVOKED_MODIFY_RIGHTS == notification->getName() - || PAYMENT_RECIVED == notification->getName(); + || PAYMENT_RECIVED == notification->getName() + || FRIENDSHIP_OFFERED == notification->getName() + || SERVER_OBJECT_MESSAGE == notification->getName(); +} + +// static +bool LLHandlerUtil::canLogToNearbyChat(const LLNotificationPtr& notification) +{ + return notification->getType() == "notifytip" + && FRIEND_ONLINE != notification->getName() + && FRIEND_OFFLINE != notification->getName(); +} + +// static +bool LLHandlerUtil::canSpawnIMSession(const LLNotificationPtr& notification) +{ + return ADD_FRIEND_WITH_MESSAGE == notification->getName() + || OFFER_FRIENDSHIP == notification->getName() + || FRIENDSHIP_ACCEPTED == notification->getName(); } // static @@ -92,13 +118,16 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification) notification->getSubstitutions().has("NAME") ? notification->getSubstitutions()["NAME"] : notification->getSubstitutions()["[NAME]"]; + const 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 if (notification->getName() != OBJECT_GIVE_ITEM && notification->getName() != OBJECT_GIVE_ITEM_UNKNOWN_USER) { LLUUID from_id = notification->getPayload()["from_id"]; - logToIM(IM_NOTHING_SPECIAL, name, name, notification->getMessage(), + logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(), from_id, from_id); } } @@ -128,3 +157,15 @@ void LLHandlerUtil::logGroupNoticeToIMGroup( payload["group_id"], sender_id); } +// static +void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChatSourceType type) +{ + LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD()); + if(nearby_chat) + { + LLChat chat_msg(notification->getMessage()); + chat_msg.mSourceType = type; + nearby_chat->addMessage(chat_msg); + } +} + |