From 2b6d3b851fc6210e7cf6272ac0bc9f8645ca5644 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Thu, 30 Sep 2010 14:48:36 -0700 Subject: Adding tags mechanism to notification visibility rules. Also started adding the tag 'fail' to entries in notifications.xml that are failures the user should always be told about. Reviewed by Richard. --- indra/llui/llnotifications.cpp | 34 +++++++++++++++++++++++++++++++++- indra/llui/llnotifications.h | 2 ++ indra/llui/llnotificationtemplate.h | 12 ++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index dd56f03237..289020fa3f 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -437,6 +437,14 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mUniqueContext.push_back(it->key); } + for(LLInitParam::ParamIterator::const_iterator it = p.tags.begin(), + end_it = p.tags.end(); + it != end_it; + ++it) + { + mTags.push_back(it->value); + } + mForm = LLNotificationFormPtr(new LLNotificationForm(p.name, p.form_ref.form)); } @@ -716,6 +724,25 @@ bool LLNotification::hasUniquenessConstraints() const return (mTemplatep ? mTemplatep->mUnique : false); } +bool LLNotification::matchesTag(const std::string& tag) +{ + bool result = false; + + if(mTemplatep) + { + std::list::iterator it; + for(it = mTemplatep->mTags.begin(); it != mTemplatep->mTags.end(); it++) + { + if((*it) == tag) + { + result = true; + break; + } + } + } + + return result; +} void LLNotification::setIgnored(bool ignore) { @@ -1653,7 +1680,12 @@ bool LLNotifications::isVisibleByRules(LLNotificationPtr n) if(!(*it)->mTag.empty()) { - // TODO: check this notification's tag(s) against it->mTag and continue if no match is found. + // check this notification's tag(s) against it->mTag and continue if no match is found. + if(!n->matchesTag((*it)->mTag)) + { + // This rule's non-empty tag didn't match one of the notification's tags. Skip this rule. + continue; + } } // If we got here, the rule matches. Don't evaluate subsequent rules. diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 75c67151ca..98ff035170 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -580,6 +580,8 @@ public: std::string summarize() const; bool hasUniquenessConstraints() const; + + bool matchesTag(const std::string& tag); virtual ~LLNotification() {} }; diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h index 6bc0d2aaff..dfc2b10eb5 100644 --- a/indra/llui/llnotificationtemplate.h +++ b/indra/llui/llnotificationtemplate.h @@ -156,6 +156,15 @@ struct LLNotificationTemplate {} }; + struct Tag : public LLInitParam::Block + { + Mandatory value; + + Tag() + : value("value") + {} + }; + struct Params : public LLInitParam::Block { Mandatory name; @@ -173,6 +182,7 @@ struct LLNotificationTemplate Optional form_ref; Optional priority; + Multiple tags; Params() @@ -276,6 +286,8 @@ struct LLNotificationTemplate // this is loaded as a name, but looked up to get the UUID upon template load. // If null, it wasn't specified. LLUUID mSoundEffect; + // List of tags that rules can match against. + std::list mTags; }; #endif //LL_LLNOTIFICATION_TEMPLATE_H -- cgit v1.2.3