summaryrefslogtreecommitdiff
path: root/indra/llui/llnotifications.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llnotifications.h')
-rw-r--r--indra/llui/llnotifications.h264
1 files changed, 121 insertions, 143 deletions
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index 1cdd744a68..524cff70e8 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -3,31 +3,25 @@
* @brief Non-UI manager and support for keeping a prioritized list of notifications
* @author Q (with assistance from Richard and Coco)
*
-* $LicenseInfo:firstyear=2008&license=viewergpl$
-*
-* Copyright (c) 2008-2009, Linden Research, Inc.
-*
+* $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
-* The source code in this file ("Source Code") is provided by Linden Lab
-* to you under the terms of the GNU General Public License, version 2.0
-* ("GPL"), unless you have obtained a separate licensing agreement
-* ("Other License"), formally executed by you and Linden Lab. Terms of
-* the GPL can be found in doc/GPL-license.txt in this distribution, or
-* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+* Copyright (C) 2010, Linden Research, Inc.
*
-* There are special exceptions to the terms and conditions of the GPL as
-* it is applied to this Source Code. View the full text of the exception
-* in the file doc/FLOSS-exception.txt in this software distribution, or
-* online at
-* http://secondlifegrid.net/programs/open_source/licensing/flossexception
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
*
-* By copying, modifying or distributing this software, you acknowledge
-* that you have read and understood your obligations described above,
-* and agree to abide by those obligations.
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
*
-* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
-* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
-* COMPLETENESS OR PERFORMANCE.
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -104,9 +98,8 @@
#include "llinitparam.h"
#include "llnotificationslistener.h"
#include "llnotificationptr.h"
-#include "llcachename.h"
-
+class LLAvatarName;
typedef enum e_notification_priority
{
NOTIFICATION_PRIORITY_UNSPECIFIED,
@@ -116,6 +109,11 @@ typedef enum e_notification_priority
NOTIFICATION_PRIORITY_CRITICAL
} ENotificationPriority;
+struct NotificationPriorityValues : public LLInitParam::TypeValuesHelper<ENotificationPriority, NotificationPriorityValues>
+{
+ static void declareValues();
+};
+
class LLNotificationResponderInterface
{
public:
@@ -163,6 +161,68 @@ class LLNotificationForm
LOG_CLASS(LLNotificationForm);
public:
+ struct FormElementBase : public LLInitParam::Block<FormElementBase>
+ {
+ Optional<std::string> 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();
+ };
+
+ struct FormButton : public LLInitParam::Block<FormButton, FormElementBase>
+ {
+ Mandatory<S32> index;
+ Mandatory<std::string> text;
+ Optional<std::string> ignore;
+ Optional<bool> is_default;
+
+ Mandatory<std::string> type;
+
+ FormButton();
+ };
+
+ struct FormInput : public LLInitParam::Block<FormInput, FormElementBase>
+ {
+ Mandatory<std::string> type;
+ Optional<S32> width;
+ Optional<S32> max_length_chars;
+
+ Optional<std::string> value;
+ FormInput();
+ };
+
+ struct FormElement : public LLInitParam::Choice<FormElement>
+ {
+ Alternative<FormButton> button;
+ Alternative<FormInput> input;
+
+ FormElement();
+ };
+
+ struct FormElements : public LLInitParam::Block<FormElements>
+ {
+ Multiple<FormElement> elements;
+ FormElements();
+ };
+
+ struct Params : public LLInitParam::Block<Params>
+ {
+ Optional<std::string> name;
+ Optional<FormIgnore> ignore;
+ Optional<FormElements> form_elements;
+
+ Params();
+ };
+
typedef enum e_ignore_type
{
IGNORE_NO,
@@ -173,8 +233,7 @@ public:
LLNotificationForm();
LLNotificationForm(const LLSD& sd);
- LLNotificationForm(const std::string& name,
- const LLPointer<class LLXMLNode> xml_node);
+ LLNotificationForm(const std::string& name, const Params& p);
LLSD asLLSD() const;
@@ -187,92 +246,25 @@ 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;
-// This is the class of object read from the XML file (notifications.xml,
-// from the appropriate local language directory).
-struct LLNotificationTemplate
-{
- LLNotificationTemplate();
- // the name of the notification -- the key used to identify it
- // Ideally, the key should follow variable naming rules
- // (no spaces or punctuation).
- std::string mName;
- // The type of the notification
- // used to control which queue it's stored in
- std::string mType;
- // The text used to display the notification. Replaceable parameters
- // are enclosed in square brackets like this [].
- std::string mMessage;
- // The label for the notification; used for
- // certain classes of notification (those with a window and a window title).
- // Also used when a notification pops up underneath the current one.
- // Replaceable parameters can be used in the label.
- std::string mLabel;
- // The name of the icon image. This should include an extension.
- std::string mIcon;
- // This is the Highlander bit -- "There Can Be Only One"
- // An outstanding notification with this bit set
- // is updated by an incoming notification with the same name,
- // rather than creating a new entry in the queue.
- // (used for things like progress indications, or repeating warnings
- // like "the grid is going down in N minutes")
- bool mUnique;
- // if we want to be unique only if a certain part of the payload is 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
- // new and the old notification; otherwise, the notification will be
- // duplicated. This is to support suppressing duplicate offers from the same
- // sender but still differentiating different offers. Example: Invitation to
- // conference chat.
- std::vector<std::string> mUniqueContext;
- // If this notification expires automatically, this value will be
- // nonzero, and indicates the number of seconds for which the notification
- // will be valid (a teleport offer, for example, might be valid for
- // 300 seconds).
- U32 mExpireSeconds;
- // if the offer expires, one of the options is chosen automatically
- // based on its "value" parameter. This controls which one.
- // If expireSeconds is specified, expireOption should also be specified.
- U32 mExpireOption;
- // if the notification contains a url, it's stored here (and replaced
- // into the message where [_URL] is found)
- std::string mURL;
- // if there's a URL in the message, this controls which option visits
- // that URL. Obsolete this and eliminate the buttons for affected
- // messages when we allow clickable URLs in the UI
- U32 mURLOption;
-
- U32 mURLOpenExternally;
- //This is a flag that tells if the url needs to open externally dispite
- //what the user setting is.
-
- // does this notification persist across sessions? if so, it will be
- // serialized to disk on first receipt and read on startup
- bool mPersist;
- // This is the name of the default functor, if present, to be
- // used for the notification's callback. It is optional, and used only if
- // the notification is constructed without an identified functor.
- std::string mDefaultFunctor;
- // The form data associated with a given notification (buttons, text boxes, etc)
- LLNotificationFormPtr mForm;
- // default priority for notifications of this type
- ENotificationPriority mPriority;
- // UUID of the audio file to be played when this notification arrives
- // this is loaded as a name, but looked up to get the UUID upon template load.
- // If null, it wasn't specified.
- LLUUID mSoundEffect;
-};
+
+struct LLNotificationTemplate;
// we want to keep a map of these by name, and it's best to manage them
// with smart pointers
@@ -308,7 +300,7 @@ public:
// optional
Optional<LLSD> substitutions;
Optional<LLSD> payload;
- Optional<ENotificationPriority> priority;
+ Optional<ENotificationPriority, NotificationPriorityValues> priority;
Optional<LLSD> form_elements;
Optional<LLDate> time_stamp;
Optional<LLNotificationContext*> context;
@@ -451,6 +443,7 @@ public:
LLSD asLLSD();
void respond(const LLSD& sd);
+ void respondWithDefault();
void* getResponder() { return mResponderObj; }
@@ -468,6 +461,13 @@ public:
return mRespondedTo;
}
+ bool isActive() const
+ {
+ return !isRespondedTo()
+ && !isCancelled()
+ && !isExpired();
+ }
+
const LLSD& getResponse() { return mResponse; }
bool isIgnored() const
@@ -475,15 +475,11 @@ public:
return mIgnored;
}
- const std::string& getName() const
- {
- return mTemplatep->mName;
- }
+ const std::string& getName() const;
- bool isPersistent() const
- {
- return mTemplatep->mPersist;
- }
+ const std::string& getIcon() const;
+
+ bool isPersistent() const;
const LLUUID& id() const
{
@@ -505,28 +501,12 @@ public:
return mTimestamp;
}
- std::string getType() const
- {
- return (mTemplatep ? mTemplatep->mType : "");
- }
-
+ std::string getType() const;
std::string getMessage() const;
std::string getLabel() const;
-
std::string getURL() const;
-// {
-// return (mTemplatep ? mTemplatep->mURL : "");
-// }
-
- S32 getURLOption() const
- {
- return (mTemplatep ? mTemplatep->mURLOption : -1);
- }
-
- S32 getURLOpenExternally() const
- {
- return(mTemplatep? mTemplatep->mURLOpenExternally : -1);
- }
+ S32 getURLOption() const;
+ S32 getURLOpenExternally() const;
const LLNotificationFormPtr getForm();
@@ -596,7 +576,7 @@ public:
std::string summarize() const;
- bool hasUniquenessConstraints() const { return (mTemplatep ? mTemplatep->mUnique : false);}
+ bool hasUniquenessConstraints() const;
virtual ~LLNotification() {}
};
@@ -878,7 +858,6 @@ public:
// load notification descriptions from file;
// OK to call more than once because it will reload
bool loadTemplates();
- LLPointer<class LLXMLNode> checkForXMLTemplate(LLPointer<class LLXMLNode> item);
// Add a simple notification (from XUI)
void addFromCallback(const LLSD& name);
@@ -900,6 +879,7 @@ public:
void add(const LLNotificationPtr pNotif);
void cancel(LLNotificationPtr pNotif);
+ void cancelByName(const std::string& name);
void update(const LLNotificationPtr pNotif);
LLNotificationPtr find(LLUUID uuid);
@@ -923,8 +903,6 @@ public:
// test for existence
bool templateExists(const std::string& name);
- // useful if you're reloading the file
- void clearTemplates(); // erase all templates
void forceResponse(const LLNotification::Params& params, S32 option);
@@ -962,9 +940,6 @@ private:
std::string mFileName;
- typedef std::map<std::string, LLPointer<class LLXMLNode> > XMLTemplateMap;
- XMLTemplateMap mXmlTemplates;
-
LLNotificationMap mUniqueNotifications;
typedef std::map<std::string, std::string> GlobalStringMap;
@@ -1000,17 +975,20 @@ public:
{
// upcast T to the base type to restrict T derivation from LLPostponedNotification
LLPostponedNotification* thiz = new T();
-
thiz->mParams = params;
- gCacheName->get(id, is_group, boost::bind(
- &LLPostponedNotification::onCachedNameReceived, thiz, _1, _2,
- _3, _4));
+ // Avoid header file dependency on llcachename.h
+ lookupName(thiz, id, is_group);
}
private:
- void onCachedNameReceived(const LLUUID& id, const std::string& first,
- const std::string& last, bool is_group);
+ static void lookupName(LLPostponedNotification* thiz, const LLUUID& id, bool is_group);
+ // only used for groups
+ void onGroupNameCache(const LLUUID& id, const std::string& full_name, bool is_group);
+ // only used for avatars
+ void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
+ // used for both group and avatar names
+ void finalizeName(const std::string& name);
void cleanup()
{