1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
/**
* @file llnotificationtemplate.h
* @brief Description of notification contents
* @author Q (with assistance from Richard and Coco)
*
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* 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.
*
* 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.
*
* 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$
*/
#ifndef LL_LLNOTIFICATION_TEMPLATE_H
#define LL_LLNOTIFICATION_TEMPLATE_H
//#include <string>
//#include <list>
//#include <vector>
//#include <map>
//#include <set>
//#include <iomanip>
//#include <sstream>
//
//#include <boost/utility.hpp>
//#include <boost/shared_ptr.hpp>
//#include <boost/enable_shared_from_this.hpp>
//#include <boost/type_traits.hpp>
//
//// we want to minimize external dependencies, but this one is important
//#include "llsd.h"
//
//// and we need this to manage the notification callbacks
//#include "llevents.h"
//#include "llfunctorregistry.h"
//#include "llpointer.h"
#include "llinitparam.h"
//#include "llnotificationslistener.h"
//#include "llnotificationptr.h"
//#include "llcachename.h"
#include "llnotifications.h"
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
{
struct GlobalString : public LLInitParam::Block<GlobalString>
{
Mandatory<std::string> name,
value;
GlobalString()
: name("name"),
value("value")
{}
};
struct UniquenessContext : public LLInitParam::Block<UniquenessContext>
{
Mandatory<std::string> key;
UniquenessContext()
: key("key")
{}
};
struct UniquenessConstraint : public LLInitParam::Block<UniquenessConstraint>
{
Multiple<UniquenessContext> contexts;
UniquenessConstraint()
: contexts("context")
{}
};
// Templates are used to define common form types, such as OK/Cancel dialogs, etc.
struct Template : public LLInitParam::Block<Template>
{
Mandatory<std::string> name;
Mandatory<LLNotificationForm::Params> form;
Template()
: name("name"),
form("form")
{}
};
// Reference a template to use its form elements
struct TemplateRef : public LLInitParam::Block<TemplateRef>
{
Mandatory<std::string> name;
Optional<std::string> yes_text,
no_text,
cancel_text,
ignore_text;
TemplateRef()
: name("name"),
yes_text("yestext"),
no_text("notext"),
cancel_text("canceltext"),
ignore_text("ignoretext")
{}
};
struct URL : public LLInitParam::Block<URL>
{
Mandatory<S32> option;
Mandatory<std::string> value;
Optional<std::string> target;
Ignored name;
URL()
: option("option", -1),
value("value"),
target("target", "_blank"),
name("name")
{}
};
struct FormRef : public LLInitParam::Choice<FormRef>
{
Alternative<LLNotificationForm::Params> form;
Alternative<TemplateRef> form_template;
FormRef()
: form("form"),
form_template("usetemplate")
{}
};
struct Params : public LLInitParam::Block<Params>
{
Mandatory<std::string> name;
Optional<bool> persist;
Optional<std::string> functor,
icon,
label,
sound,
type,
value;
Optional<U32> duration;
Optional<S32> expire_option;
Optional<URL> url;
Optional<UniquenessConstraint> unique;
Optional<FormRef> form_ref;
Optional<ENotificationPriority,
NotificationPriorityValues> priority;
Params()
: name("name"),
persist("persist", false),
functor("functor"),
icon("icon"),
label("label"),
priority("priority"),
sound("sound"),
type("type"),
value("value"),
duration("duration"),
expire_option("expireOption", -1),
url("url"),
unique("unique"),
form_ref("")
{}
};
struct Notifications : public LLInitParam::Block<Notifications>
{
Multiple<GlobalString> strings;
Multiple<Template> templates;
Multiple<Params> notifications;
Notifications()
: strings("global"),
notifications("notification"),
templates("template")
{}
};
LLNotificationTemplate(const Params& p);
// 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;
std::string mURLTarget;
//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;
};
#endif //LL_LLNOTIFICATION_TEMPLATE_H
|