PageRenderTime 46ms CodeModel.GetById 13ms app.highlight 26ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llnotificationtemplate.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 297 lines | 157 code | 33 blank | 107 comment | 0 complexity | d9e85a000aa3650f3f6432bdc5080190 MD5 | raw file
  1/**
  2* @file llnotificationtemplate.h
  3* @brief Description of notification contents
  4* @author Q (with assistance from Richard and Coco)
  5*
  6* $LicenseInfo:firstyear=2008&license=viewerlgpl$
  7* Second Life Viewer Source Code
  8* Copyright (C) 2010, Linden Research, Inc.
  9* 
 10* This library is free software; you can redistribute it and/or
 11* modify it under the terms of the GNU Lesser General Public
 12* License as published by the Free Software Foundation;
 13* version 2.1 of the License only.
 14* 
 15* This library is distributed in the hope that it will be useful,
 16* but WITHOUT ANY WARRANTY; without even the implied warranty of
 17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18* Lesser General Public License for more details.
 19* 
 20* You should have received a copy of the GNU Lesser General Public
 21* License along with this library; if not, write to the Free Software
 22* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23* 
 24* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25* $/LicenseInfo$
 26*/
 27
 28#ifndef LL_LLNOTIFICATION_TEMPLATE_H
 29#define LL_LLNOTIFICATION_TEMPLATE_H
 30
 31//#include <string>
 32//#include <list>
 33//#include <vector>
 34//#include <map>
 35//#include <set>
 36//#include <iomanip>
 37//#include <sstream>
 38//
 39//#include <boost/utility.hpp>
 40//#include <boost/shared_ptr.hpp>
 41//#include <boost/enable_shared_from_this.hpp>
 42//#include <boost/type_traits.hpp>
 43//
 44//// we want to minimize external dependencies, but this one is important
 45//#include "llsd.h"
 46//
 47//// and we need this to manage the notification callbacks
 48//#include "llevents.h"
 49//#include "llfunctorregistry.h"
 50//#include "llpointer.h"
 51#include "llinitparam.h"
 52//#include "llnotificationslistener.h"
 53//#include "llnotificationptr.h"
 54//#include "llcachename.h"
 55#include "llnotifications.h"
 56
 57
 58typedef boost::shared_ptr<LLNotificationForm> LLNotificationFormPtr;
 59
 60// This is the class of object read from the XML file (notifications.xml, 
 61// from the appropriate local language directory).
 62struct LLNotificationTemplate
 63{
 64	struct GlobalString : public LLInitParam::Block<GlobalString>
 65	{
 66		Mandatory<std::string>	name,
 67								value;
 68
 69		GlobalString()
 70		:	name("name"),
 71			value("value")
 72		{}
 73	};
 74
 75	struct UniquenessContext : public LLInitParam::Block<UniquenessContext>
 76	{
 77		Mandatory<std::string>	value;
 78
 79		UniquenessContext()
 80		:	value("value")
 81		{
 82			addSynonym(value, "key");
 83		}
 84		
 85	};
 86
 87	struct UniquenessConstraint : public LLInitParam::Block<UniquenessConstraint>
 88	{
 89	private:
 90		// this idiom allows 
 91		// <notification> <unique/> </notification>
 92		// as well as
 93		// <notification> <unique> <context></context> </unique>...
 94		Optional<LLInitParam::Flag>	dummy_val;
 95	public:
 96		Multiple<UniquenessContext>	contexts;
 97
 98		UniquenessConstraint()
 99		:	contexts("context"),
100			dummy_val("")
101		{}
102	};
103
104	// Templates are used to define common form types, such as OK/Cancel dialogs, etc.
105
106	struct Template : public LLInitParam::Block<Template>
107	{
108		Mandatory<std::string>					name;
109		Mandatory<LLNotificationForm::Params>	form;
110
111		Template()
112		:	name("name"),
113			form("form")
114		{}
115	};
116
117	// Reference a template to use its form elements
118	struct TemplateRef : public LLInitParam::Block<TemplateRef>
119	{
120		Mandatory<std::string>	name;
121		Optional<std::string>	yes_text,
122								no_text,
123								cancel_text,
124								ignore_text;
125
126		TemplateRef()
127		:	name("name"),
128			yes_text("yestext"),
129			no_text("notext"),
130			cancel_text("canceltext"),
131			ignore_text("ignoretext")
132		{}
133	};
134
135	struct URL : public LLInitParam::Block<URL>
136	{
137		Mandatory<S32>			option;
138		Mandatory<std::string>	value;
139		Optional<std::string>	target;
140		Ignored					name;
141
142		URL()
143		:	option("option", -1),
144			value("value"),
145			target("target", "_blank"),
146			name("name")
147		{}
148	};
149
150	struct FormRef : public LLInitParam::ChoiceBlock<FormRef>
151	{
152		Alternative<LLNotificationForm::Params>		form;
153		Alternative<TemplateRef>					form_template;
154
155		FormRef()
156		:	form("form"),
157			form_template("usetemplate")
158		{}
159	};
160
161	struct Tag : public LLInitParam::Block<Tag>
162	{
163		Mandatory<std::string>	value;
164
165		Tag()
166		:	value("value")
167		{}
168	};
169
170	struct Params : public LLInitParam::Block<Params>
171	{
172		Mandatory<std::string>			name;
173		Optional<bool>					persist;
174		Optional<std::string>			functor,
175										icon,
176										label,
177										sound,
178										type,
179										value;
180		Optional<U32>					duration;
181		Optional<S32>					expire_option;
182		Optional<URL>					url;
183		Optional<UniquenessConstraint>	unique;
184		Optional<FormRef>				form_ref;
185		Optional<ENotificationPriority, 
186			NotificationPriorityValues> priority;
187		Multiple<Tag>		tags;
188
189
190		Params()
191		:	name("name"),
192			persist("persist", false),
193			functor("functor"),
194			icon("icon"),
195			label("label"),
196			priority("priority"),
197			sound("sound"),
198			type("type"),
199			value("value"),
200			duration("duration"),
201			expire_option("expireOption", -1),
202			url("url"),
203			unique("unique"),
204			form_ref(""),
205			tags("tag")
206		{}
207
208	};
209
210	struct Notifications : public LLInitParam::Block<Notifications>
211	{
212		Multiple<GlobalString>	strings;
213		Multiple<Template>		templates;
214		Multiple<Params>		notifications;
215
216		Notifications()
217		:	strings("global"),
218			notifications("notification"),
219			templates("template")
220		{}
221	};
222
223	LLNotificationTemplate(const Params& p);
224    // the name of the notification -- the key used to identify it
225    // Ideally, the key should follow variable naming rules 
226    // (no spaces or punctuation).
227    std::string mName;
228    // The type of the notification
229    // used to control which queue it's stored in
230    std::string mType;
231    // The text used to display the notification. Replaceable parameters
232    // are enclosed in square brackets like this [].
233    std::string mMessage;
234	// The label for the notification; used for 
235	// certain classes of notification (those with a window and a window title). 
236	// Also used when a notification pops up underneath the current one.
237	// Replaceable parameters can be used in the label.
238	std::string mLabel;
239	// The name of the icon image. This should include an extension.
240	std::string mIcon;
241    // This is the Highlander bit -- "There Can Be Only One"
242    // An outstanding notification with this bit set
243    // is updated by an incoming notification with the same name,
244    // rather than creating a new entry in the queue.
245    // (used for things like progress indications, or repeating warnings
246    // like "the grid is going down in N minutes")
247    bool mUnique;
248    // if we want to be unique only if a certain part of the payload or substitutions args
249	// are constant specify the field names for the payload. The notification will only be
250    // combined if all of the fields named in the context are identical in the
251    // new and the old notification; otherwise, the notification will be
252    // duplicated. This is to support suppressing duplicate offers from the same
253    // sender but still differentiating different offers. Example: Invitation to
254    // conference chat.
255    std::vector<std::string> mUniqueContext;
256    // If this notification expires automatically, this value will be 
257    // nonzero, and indicates the number of seconds for which the notification
258    // will be valid (a teleport offer, for example, might be valid for 
259    // 300 seconds). 
260    U32 mExpireSeconds;
261    // if the offer expires, one of the options is chosen automatically
262    // based on its "value" parameter. This controls which one. 
263    // If expireSeconds is specified, expireOption should also be specified.
264    U32 mExpireOption;
265    // if the notification contains a url, it's stored here (and replaced 
266    // into the message where [_URL] is found)
267    std::string mURL;
268    // if there's a URL in the message, this controls which option visits
269    // that URL. Obsolete this and eliminate the buttons for affected
270    // messages when we allow clickable URLs in the UI
271    U32 mURLOption;
272	
273	std::string mURLTarget;
274	//This is a flag that tells if the url needs to open externally dispite 
275	//what the user setting is.
276	
277	// does this notification persist across sessions? if so, it will be
278	// serialized to disk on first receipt and read on startup
279	bool mPersist;
280	// This is the name of the default functor, if present, to be
281	// used for the notification's callback. It is optional, and used only if 
282	// the notification is constructed without an identified functor.
283	std::string mDefaultFunctor;
284	// The form data associated with a given notification (buttons, text boxes, etc)
285    LLNotificationFormPtr mForm;
286	// default priority for notifications of this type
287	ENotificationPriority mPriority;
288	// UUID of the audio file to be played when this notification arrives
289	// this is loaded as a name, but looked up to get the UUID upon template load.
290	// If null, it wasn't specified.
291	LLUUID mSoundEffect;
292	// List of tags that rules can match against.
293	std::list<std::string> mTags;
294};
295
296#endif //LL_LLNOTIFICATION_TEMPLATE_H
297