summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-03-30 18:36:43 -0700
committerRichard Linden <none@none>2012-03-30 18:36:43 -0700
commitc2afd200a0d55c5137de6f89200a8d4b09ba8b6e (patch)
tree88d83457bd871c829288d374fbcceb55f8b09308 /indra/llui
parent56f9c54c8348786db395ccd464eec17d5b17eeb1 (diff)
CHUI-51 WIP notifications routing code cleanup
object inventory offers don't increment system menu count added customizable merging behavior for duplicate "unique" notifications fixed overeager notification channels
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llnotifications.cpp43
-rw-r--r--indra/llui/llnotifications.h8
-rw-r--r--indra/llui/llnotificationtemplate.h14
3 files changed, 46 insertions, 19 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index c45899a4bd..79135d2c60 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -246,7 +246,7 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotifica
LLParamSDParser parser;
parser.writeSD(mFormData, p.form_elements);
- if (!mFormData.isArray())
+ if (!mFormData.isArray() && !mFormData.isUndefined())
{
// change existing contents to a one element array
LLSD new_llsd_array = LLSD::emptyArray();
@@ -407,6 +407,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
mURLOption(p.url.option),
mURLTarget(p.url.target),
mUnique(p.unique.isProvided()),
+ mCombineBehavior(p.unique.combine),
mPriority(p.priority),
mPersist(p.persist),
mDefaultFunctor(p.functor.isProvided() ? p.functor() : p.name()),
@@ -903,6 +904,10 @@ bool LLNotification::hasFormElements() const
return mTemplatep->mForm->getNumElements() != 0;
}
+LLNotification::ECombineBehavior LLNotification::getCombineBehavior() const
+{
+ return mTemplatep->mCombineBehavior;
+}
@@ -1242,22 +1247,25 @@ bool LLNotifications::failedUniquenessTest(const LLSD& payload)
return false;
}
- // Update the existing unique notification with the data from this particular instance...
- // This guarantees that duplicate notifications will be collapsed to the one
- // most recently triggered
- for (LLNotificationMap::iterator existing_it = mUniqueNotifications.find(pNotif->getName());
- existing_it != mUniqueNotifications.end();
- ++existing_it)
+ if (pNotif->getCombineBehavior() == LLNotification::USE_NEWEST)
{
- LLNotificationPtr existing_notification = existing_it->second;
- if (pNotif != existing_notification
- && pNotif->isEquivalentTo(existing_notification))
+ // Update the existing unique notification with the data from this particular instance...
+ // This guarantees that duplicate notifications will be collapsed to the one
+ // most recently triggered
+ for (LLNotificationMap::iterator existing_it = mUniqueNotifications.find(pNotif->getName());
+ existing_it != mUniqueNotifications.end();
+ ++existing_it)
{
- // copy notification instance data over to oldest instance
- // of this unique notification and update it
- existing_notification->updateFrom(pNotif);
- // then delete the new one
- cancel(pNotif);
+ LLNotificationPtr existing_notification = existing_it->second;
+ if (pNotif != existing_notification
+ && pNotif->isEquivalentTo(existing_notification))
+ {
+ // copy notification instance data over to oldest instance
+ // of this unique notification and update it
+ existing_notification->updateFrom(pNotif);
+ // then delete the new one
+ cancel(pNotif);
+ }
}
}
@@ -1296,10 +1304,7 @@ void LLNotifications::createDefaultChannels()
boost::bind(&LLNotifications::isVisibleByRules, this, _1)));
mDefaultChannels.push_back(new LLNotificationChannel("Visible", "VisibilityRules",
&LLNotificationFilters::includeEverything));
-
- // create special persistent notification channel
- // this isn't a leak, don't worry about the empty "new"
- new LLPersistentNotificationChannel();
+ mDefaultChannels.push_back(new LLPersistentNotificationChannel());
// connect action methods to these channels
LLNotifications::instance().getChannel("Enabled")->
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index 344108ecbf..4e2b997156 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -297,6 +297,7 @@ LOG_CLASS(LLNotification);
friend class LLNotifications;
public:
+
// parameter object used to instantiate a new notification
struct Params : public LLInitParam::Block<Params>
{
@@ -518,6 +519,13 @@ public:
bool canLogToIM() const;
bool hasFormElements() const;
+ typedef enum e_combine_behavior
+ {
+ USE_NEWEST,
+ USE_OLDEST
+ } ECombineBehavior;
+
+ ECombineBehavior getCombineBehavior() const;
const LLNotificationFormPtr getForm();
const LLDate getExpiration() const
diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h
index 1df7205b23..8080acbf87 100644
--- a/indra/llui/llnotificationtemplate.h
+++ b/indra/llui/llnotificationtemplate.h
@@ -61,6 +61,17 @@ typedef boost::shared_ptr<LLNotificationForm> LLNotificationFormPtr;
// from the appropriate local language directory).
struct LLNotificationTemplate
{
+ struct CombineBehaviorNames
+ : public LLInitParam::TypeValuesHelper<LLNotification::ECombineBehavior, CombineBehaviorNames>
+ {
+ static void declareValues()
+ {
+ declare("newest", LLNotification::USE_NEWEST);
+ declare("oldest", LLNotification::USE_OLDEST);
+ }
+ };
+
+
struct GlobalString : public LLInitParam::Block<GlobalString>
{
Mandatory<std::string> name,
@@ -94,9 +105,11 @@ struct LLNotificationTemplate
Optional<LLInitParam::Flag> dummy_val;
public:
Multiple<UniquenessContext> contexts;
+ Optional<LLNotification::ECombineBehavior, CombineBehaviorNames> combine;
UniquenessConstraint()
: contexts("context"),
+ combine("combine", LLNotification::USE_NEWEST),
dummy_val("")
{}
};
@@ -249,6 +262,7 @@ struct LLNotificationTemplate
// (used for things like progress indications, or repeating warnings
// like "the grid is going down in N minutes")
bool mUnique;
+ LLNotification::ECombineBehavior mCombineBehavior;
// if we want to be unique only if a certain part of the payload or substitutions args
// are constant specify the field names for the payload. The notification will only be
// combined if all of the fields named in the context are identical in the