diff options
-rw-r--r-- | indra/llui/llnotifications.cpp | 91 | ||||
-rw-r--r-- | indra/llui/llnotifications.h | 55 | ||||
-rw-r--r-- | indra/llui/llnotificationslistener.cpp | 7 |
3 files changed, 103 insertions, 50 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 { |