diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-03-04 10:51:49 +0000 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-03-04 10:51:49 +0000 |
commit | 87c986dc5809b71a7ee76438111a37838063cb18 (patch) | |
tree | 80771ab88e80db0d6b61485427fb7bcbf021d7b6 /indra/newview/llnotificationhandlerutil.cpp | |
parent | 3614dc007328111462297e9244f370fb5f4a0910 (diff) | |
parent | 6d5442fbbd3adc9a708b894d402c9719f2dfa324 (diff) |
PE merge.
Diffstat (limited to 'indra/newview/llnotificationhandlerutil.cpp')
-rw-r--r-- | indra/newview/llnotificationhandlerutil.cpp | 77 |
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 |