summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorRichard Linden <none@none>2010-09-16 16:56:28 -0700
committerRichard Linden <none@none>2010-09-16 16:56:28 -0700
commitf2a297a9599fe64ec2700fe6845ec0ec6eddf410 (patch)
treea46b196d7b5df872c910bca1b72097a253d251a9 /indra/llui
parentd6f1f79ced7bb7fa0bb70e41c65f7d7de9c7a306 (diff)
parent7b7d8ffc22d3af3186f96d57f1276411f558d6f1 (diff)
merge
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llnotifications.cpp91
-rw-r--r--indra/llui/llnotifications.h55
-rw-r--r--indra/llui/llnotificationslistener.cpp7
-rw-r--r--indra/llui/llnotificationtemplate.h10
4 files changed, 112 insertions, 51 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index bdc094bf47..bd58fe2637 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -55,6 +55,47 @@ void NotificationPriorityValues::declareValues()
declare("critical", NOTIFICATION_PRIORITY_CRITICAL);
}
+LLNotificationForm::FormElementBase::FormElementBase()
+: name("name")
+{}
+
+LLNotificationForm::FormIgnore::FormIgnore()
+: text("text"),
+ control("control"),
+ invert_control("invert_control", false),
+ save_option("save_option", false)
+{}
+
+LLNotificationForm::FormButton::FormButton()
+: index("index"),
+ text("text"),
+ ignore("ignore"),
+ is_default("default"),
+ type("type")
+{
+ // set type here so it gets serialized
+ type = "button";
+}
+
+LLNotificationForm::FormInput::FormInput()
+: type("type"),
+ width("width", 0)
+{}
+
+LLNotificationForm::FormElement::FormElement()
+: button("button"),
+ input("input")
+{}
+
+LLNotificationForm::FormElements::FormElements()
+: elements("")
+{}
+
+LLNotificationForm::Params::Params()
+: name("name"),
+ ignore("ignore"),
+ form_elements("")
+{}
// Local channel for persistent notifications
// Stores only persistent notifications.
@@ -100,12 +141,7 @@ bool filterIgnoredNotifications(LLNotificationPtr notification)
LLNotificationFormPtr form = notification->getForm();
// Check to see if the user wants to ignore this alert
- if (form->getIgnoreType() != LLNotificationForm::IGNORE_NO)
- {
- return LLUI::sSettingGroups["ignores"]->getBOOL(notification->getName());
- }
-
- return true;
+ return !notification->getForm()->getIgnored();
}
bool handleIgnoredNotification(const LLSD& payload)
@@ -153,7 +189,8 @@ LLNotificationForm::LLNotificationForm()
LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotificationForm::Params& p)
-: mIgnore(IGNORE_NO)
+: mIgnore(IGNORE_NO),
+ mInvertSetting(false)
{
if (p.ignore.isProvided())
{
@@ -171,7 +208,16 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLNotifica
}
BOOL show_notification = TRUE;
- LLUI::sSettingGroups["ignores"]->declareBOOL(name, show_notification, "Ignore notification with this name", TRUE);
+ if (p.ignore.control.isProvided())
+ {
+ mIgnoreSetting = LLUI::sSettingGroups["config"]->getControl(p.ignore.control);
+ mInvertSetting = p.ignore.invert_control;
+ }
+ else
+ {
+ LLUI::sSettingGroups["ignores"]->declareBOOL(name, show_notification, "Ignore notification with this name", TRUE);
+ mIgnoreSetting = LLUI::sSettingGroups["ignores"]->getControl(name);
+ }
}
LLParamSDParser parser;
@@ -300,6 +346,27 @@ std::string LLNotificationForm::getDefaultOption()
return "";
}
+LLControlVariablePtr LLNotificationForm::getIgnoreSetting()
+{
+ return mIgnoreSetting;
+}
+
+bool LLNotificationForm::getIgnored()
+{
+ if (mIgnore != LLNotificationForm::IGNORE_NO
+ && mIgnoreSetting)
+ {
+ return mIgnoreSetting->getValue().asBoolean() != mInvertSetting;
+ }
+
+ return false;
+}
+
+void LLNotificationForm::setIgnored(bool ignored)
+{
+ if (mIgnoreSetting) mIgnoreSetting->setValue(ignored != mInvertSetting);
+}
+
LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Params& p)
: mName(p.name),
mType(p.type),
@@ -545,8 +612,8 @@ void LLNotification::respond(const LLSD& response)
if (mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
{
- BOOL show_notification = mIgnored ? FALSE : TRUE;
- LLUI::sSettingGroups["ignores"]->setBOOL(getName(), show_notification);
+ bool show_notification = !mIgnored;
+ mForm->setIgnored(!show_notification);
if (mIgnored && mForm->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
{
LLUI::sSettingGroups["ignores"]->setLLSD("Default" + getName(), response);
@@ -1294,11 +1361,11 @@ bool LLNotifications::loadTemplates()
}
if(it->form_ref.form_template.cancel_text.isProvided())
{
- replaceFormText(it->form_ref.form, "$cancel_text", it->form_ref.form_template.cancel_text);
+ replaceFormText(it->form_ref.form, "$canceltext", it->form_ref.form_template.cancel_text);
}
if(it->form_ref.form_template.ignore_text.isProvided())
{
- replaceFormText(it->form_ref.form, "$ignore_text", it->form_ref.form_template.ignore_text);
+ replaceFormText(it->form_ref.form, "$ignoretext", it->form_ref.form_template.ignore_text);
}
}
addTemplate(it->name, LLNotificationTemplatePtr(new LLNotificationTemplate(*it)));
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index a58e7afe23..ed29e0d83e 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -163,22 +163,19 @@ class LLNotificationForm
public:
struct FormElementBase : public LLInitParam::Block<FormElementBase>
{
- Mandatory<std::string> name;
+ Optional<std::string> name;
- FormElementBase()
- : name("name")
- {}
+ FormElementBase();
};
struct FormIgnore : public LLInitParam::Block<FormIgnore, FormElementBase>
{
Optional<std::string> text;
Optional<bool> save_option;
+ Optional<std::string> control;
+ Optional<bool> invert_control;
- FormIgnore()
- : text("text"),
- save_option("save_option", false)
- {}
+ FormIgnore();
};
struct FormButton : public LLInitParam::Block<FormButton, FormElementBase>
@@ -190,16 +187,7 @@ public:
Mandatory<std::string> type;
- FormButton()
- : index("index"),
- text("text"),
- ignore("ignore"),
- is_default("default"),
- type("type")
- {
- // set type here so it gets serialized
- type = "button";
- }
+ FormButton();
};
struct FormInput : public LLInitParam::Block<FormInput, FormElementBase>
@@ -207,10 +195,7 @@ public:
Mandatory<std::string> type;
Optional<S32> width;
- FormInput()
- : type("type"),
- width("width", 0)
- {}
+ FormInput();
};
struct FormElement : public LLInitParam::Choice<FormElement>
@@ -218,18 +203,13 @@ public:
Alternative<FormButton> button;
Alternative<FormInput> input;
- FormElement()
- : button("button"),
- input("input")
- {}
+ FormElement();
};
struct FormElements : public LLInitParam::Block<FormElements>
{
Multiple<FormElement> elements;
- FormElements()
- : elements("")
- {}
+ FormElements();
};
struct Params : public LLInitParam::Block<Params>
@@ -238,11 +218,7 @@ public:
Optional<FormIgnore> ignore;
Optional<FormElements> form_elements;
- Params()
- : name("name"),
- ignore("ignore"),
- form_elements("")
- {}
+ Params();
};
typedef enum e_ignore_type
@@ -268,14 +244,19 @@ public:
// appends form elements from another form serialized as LLSD
void append(const LLSD& sub_form);
std::string getDefaultOption();
+ LLPointer<class LLControlVariable> getIgnoreSetting();
+ bool getIgnored();
+ void setIgnored(bool ignored);
EIgnoreType getIgnoreType() { return mIgnore; }
std::string getIgnoreMessage() { return mIgnoreMsg; }
private:
- LLSD mFormData;
- EIgnoreType mIgnore;
- std::string mIgnoreMsg;
+ LLSD mFormData;
+ EIgnoreType mIgnore;
+ std::string mIgnoreMsg;
+ LLPointer<class LLControlVariable> mIgnoreSetting;
+ bool mInvertSetting;
};
typedef boost::shared_ptr<LLNotificationForm> LLNotificationFormPtr;
diff --git a/indra/llui/llnotificationslistener.cpp b/indra/llui/llnotificationslistener.cpp
index 44a90398fd..3bbeb3a778 100644
--- a/indra/llui/llnotificationslistener.cpp
+++ b/indra/llui/llnotificationslistener.cpp
@@ -29,6 +29,7 @@
#include "linden_common.h"
#include "llnotificationslistener.h"
#include "llnotifications.h"
+#include "llnotificationtemplate.h"
#include "llsd.h"
#include "llui.h"
@@ -182,7 +183,11 @@ void LLNotificationsListener::ignore(const LLSD& params) const
if (params["name"].isDefined())
{
// ["name"] was passed: ignore just that notification
- LLUI::sSettingGroups["ignores"]->setBOOL(params["name"], ignore);
+ LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"]);
+ if (templatep)
+ {
+ templatep->mForm->setIgnored(ignore);
+ }
}
else
{
diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h
index 4a020bfe70..a4d393f874 100644
--- a/indra/llui/llnotificationtemplate.h
+++ b/indra/llui/llnotificationtemplate.h
@@ -74,10 +74,18 @@ struct LLNotificationTemplate
struct UniquenessContext : public LLInitParam::Block<UniquenessContext>
{
+ private:
+ // this idiom allows
+ // <notification unique="true">
+ // as well as
+ // <notification> <unique> <context key=""/> </unique>...
+ Optional<bool> dummy_val;
+ public:
Mandatory<std::string> key;
UniquenessContext()
- : key("key")
+ : key("key"),
+ dummy_val("")
{}
};