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.cpp77
1 files changed, 76 insertions, 1 deletions
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index 9de9998cbd..88bb769109 100644
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -43,6 +43,75 @@
using namespace LLNotificationsUI;
+// static
+std::list< std::set<std::string> > LLSysHandler::sExclusiveNotificationGroups;
+
+// static
+void LLSysHandler::init()
+{
+ std::set<std::string> online_offline_group;
+ online_offline_group.insert("FriendOnline");
+ online_offline_group.insert("FriendOffline");
+
+ sExclusiveNotificationGroups.push_back(online_offline_group);
+}
+
+LLSysHandler::LLSysHandler()
+{
+ if(sExclusiveNotificationGroups.empty())
+ {
+ init();
+ }
+}
+
+void LLSysHandler::removeExclusiveNotifications(const LLNotificationPtr& notif)
+{
+ LLScreenChannel* channel = dynamic_cast<LLScreenChannel *>(mChannel);
+ if (channel == NULL)
+ {
+ return;
+ }
+
+ class ExclusiveMatcher: public LLScreenChannel::Matcher
+ {
+ public:
+ ExclusiveMatcher(const std::set<std::string>& excl_group,
+ const std::string& from_name) :
+ mExclGroup(excl_group), mFromName(from_name)
+ {
+ }
+ bool matches(const LLNotificationPtr notification) const
+ {
+ for (std::set<std::string>::const_iterator it = mExclGroup.begin(); it
+ != mExclGroup.end(); it++)
+ {
+ std::string from_name = LLHandlerUtil::getSubstitutionName(notification);
+ if (notification->getName() == *it && from_name == mFromName)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ private:
+ const std::set<std::string>& mExclGroup;
+ const std::string& mFromName;
+ };
+
+
+ for (exclusive_notif_sets::iterator it = sExclusiveNotificationGroups.begin(); it
+ != sExclusiveNotificationGroups.end(); it++)
+ {
+ std::set<std::string> group = *it;
+ std::set<std::string>::iterator g_it = group.find(notif->getName());
+ if (g_it != group.end())
+ {
+ channel->killMatchedToasts(ExclusiveMatcher(group,
+ LLHandlerUtil::getSubstitutionName(notif)));
+ }
+ }
+}
+
const static std::string GRANTED_MODIFY_RIGHTS("GrantedModifyRights"),
REVOKED_MODIFY_RIGHTS("RevokedModifyRights"), OBJECT_GIVE_ITEM(
"ObjectGiveItem"), OBJECT_GIVE_ITEM_UNKNOWN_USER(
@@ -249,9 +318,15 @@ LLUUID LLHandlerUtil::spawnIMSession(const std::string& name, const LLUUID& from
// static
std::string LLHandlerUtil::getSubstitutionName(const LLNotificationPtr& notification)
{
- return notification->getSubstitutions().has("NAME")
+ std::string res = notification->getSubstitutions().has("NAME")
? notification->getSubstitutions()["NAME"]
: notification->getSubstitutions()["[NAME]"];
+ if (res.empty())
+ {
+ LLUUID from_id = notification->getPayload()["FROM_ID"];
+ gCacheName->getFullName(from_id, res);
+ }
+ return res;
}
// static