PageRenderTime 33ms CodeModel.GetById 20ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLNOTIFICATION_TEMPLATE_H
  28. #define LL_LLNOTIFICATION_TEMPLATE_H
  29. //#include <string>
  30. //#include <list>
  31. //#include <vector>
  32. //#include <map>
  33. //#include <set>
  34. //#include <iomanip>
  35. //#include <sstream>
  36. //
  37. //#include <boost/utility.hpp>
  38. //#include <boost/shared_ptr.hpp>
  39. //#include <boost/enable_shared_from_this.hpp>
  40. //#include <boost/type_traits.hpp>
  41. //
  42. //// we want to minimize external dependencies, but this one is important
  43. //#include "llsd.h"
  44. //
  45. //// and we need this to manage the notification callbacks
  46. //#include "llevents.h"
  47. //#include "llfunctorregistry.h"
  48. //#include "llpointer.h"
  49. #include "llinitparam.h"
  50. //#include "llnotificationslistener.h"
  51. //#include "llnotificationptr.h"
  52. //#include "llcachename.h"
  53. #include "llnotifications.h"
  54. typedef boost::shared_ptr<LLNotificationForm> LLNotificationFormPtr;
  55. // This is the class of object read from the XML file (notifications.xml,
  56. // from the appropriate local language directory).
  57. struct LLNotificationTemplate
  58. {
  59. struct GlobalString : public LLInitParam::Block<GlobalString>
  60. {
  61. Mandatory<std::string> name,
  62. value;
  63. GlobalString()
  64. : name("name"),
  65. value("value")
  66. {}
  67. };
  68. struct UniquenessContext : public LLInitParam::Block<UniquenessContext>
  69. {
  70. Mandatory<std::string> value;
  71. UniquenessContext()
  72. : value("value")
  73. {
  74. addSynonym(value, "key");
  75. }
  76. };
  77. struct UniquenessConstraint : public LLInitParam::Block<UniquenessConstraint>
  78. {
  79. private:
  80. // this idiom allows
  81. // <notification> <unique/> </notification>
  82. // as well as
  83. // <notification> <unique> <context></context> </unique>...
  84. Optional<LLInitParam::Flag> dummy_val;
  85. public:
  86. Multiple<UniquenessContext> contexts;
  87. UniquenessConstraint()
  88. : contexts("context"),
  89. dummy_val("")
  90. {}
  91. };
  92. // Templates are used to define common form types, such as OK/Cancel dialogs, etc.
  93. struct Template : public LLInitParam::Block<Template>
  94. {
  95. Mandatory<std::string> name;
  96. Mandatory<LLNotificationForm::Params> form;
  97. Template()
  98. : name("name"),
  99. form("form")
  100. {}
  101. };
  102. // Reference a template to use its form elements
  103. struct TemplateRef : public LLInitParam::Block<TemplateRef>
  104. {
  105. Mandatory<std::string> name;
  106. Optional<std::string> yes_text,
  107. no_text,
  108. cancel_text,
  109. ignore_text;
  110. TemplateRef()
  111. : name("name"),
  112. yes_text("yestext"),
  113. no_text("notext"),
  114. cancel_text("canceltext"),
  115. ignore_text("ignoretext")
  116. {}
  117. };
  118. struct URL : public LLInitParam::Block<URL>
  119. {
  120. Mandatory<S32> option;
  121. Mandatory<std::string> value;
  122. Optional<std::string> target;
  123. Ignored name;
  124. URL()
  125. : option("option", -1),
  126. value("value"),
  127. target("target", "_blank"),
  128. name("name")
  129. {}
  130. };
  131. struct FormRef : public LLInitParam::ChoiceBlock<FormRef>
  132. {
  133. Alternative<LLNotificationForm::Params> form;
  134. Alternative<TemplateRef> form_template;
  135. FormRef()
  136. : form("form"),
  137. form_template("usetemplate")
  138. {}
  139. };
  140. struct Tag : public LLInitParam::Block<Tag>
  141. {
  142. Mandatory<std::string> value;
  143. Tag()
  144. : value("value")
  145. {}
  146. };
  147. struct Params : public LLInitParam::Block<Params>
  148. {
  149. Mandatory<std::string> name;
  150. Optional<bool> persist;
  151. Optional<std::string> functor,
  152. icon,
  153. label,
  154. sound,
  155. type,
  156. value;
  157. Optional<U32> duration;
  158. Optional<S32> expire_option;
  159. Optional<URL> url;
  160. Optional<UniquenessConstraint> unique;
  161. Optional<FormRef> form_ref;
  162. Optional<ENotificationPriority,
  163. NotificationPriorityValues> priority;
  164. Multiple<Tag> tags;
  165. Params()
  166. : name("name"),
  167. persist("persist", false),
  168. functor("functor"),
  169. icon("icon"),
  170. label("label"),
  171. priority("priority"),
  172. sound("sound"),
  173. type("type"),
  174. value("value"),
  175. duration("duration"),
  176. expire_option("expireOption", -1),
  177. url("url"),
  178. unique("unique"),
  179. form_ref(""),
  180. tags("tag")
  181. {}
  182. };
  183. struct Notifications : public LLInitParam::Block<Notifications>
  184. {
  185. Multiple<GlobalString> strings;
  186. Multiple<Template> templates;
  187. Multiple<Params> notifications;
  188. Notifications()
  189. : strings("global"),
  190. notifications("notification"),
  191. templates("template")
  192. {}
  193. };
  194. LLNotificationTemplate(const Params& p);
  195. // the name of the notification -- the key used to identify it
  196. // Ideally, the key should follow variable naming rules
  197. // (no spaces or punctuation).
  198. std::string mName;
  199. // The type of the notification
  200. // used to control which queue it's stored in
  201. std::string mType;
  202. // The text used to display the notification. Replaceable parameters
  203. // are enclosed in square brackets like this [].
  204. std::string mMessage;
  205. // The label for the notification; used for
  206. // certain classes of notification (those with a window and a window title).
  207. // Also used when a notification pops up underneath the current one.
  208. // Replaceable parameters can be used in the label.
  209. std::string mLabel;
  210. // The name of the icon image. This should include an extension.
  211. std::string mIcon;
  212. // This is the Highlander bit -- "There Can Be Only One"
  213. // An outstanding notification with this bit set
  214. // is updated by an incoming notification with the same name,
  215. // rather than creating a new entry in the queue.
  216. // (used for things like progress indications, or repeating warnings
  217. // like "the grid is going down in N minutes")
  218. bool mUnique;
  219. // if we want to be unique only if a certain part of the payload or substitutions args
  220. // are constant specify the field names for the payload. The notification will only be
  221. // combined if all of the fields named in the context are identical in the
  222. // new and the old notification; otherwise, the notification will be
  223. // duplicated. This is to support suppressing duplicate offers from the same
  224. // sender but still differentiating different offers. Example: Invitation to
  225. // conference chat.
  226. std::vector<std::string> mUniqueContext;
  227. // If this notification expires automatically, this value will be
  228. // nonzero, and indicates the number of seconds for which the notification
  229. // will be valid (a teleport offer, for example, might be valid for
  230. // 300 seconds).
  231. U32 mExpireSeconds;
  232. // if the offer expires, one of the options is chosen automatically
  233. // based on its "value" parameter. This controls which one.
  234. // If expireSeconds is specified, expireOption should also be specified.
  235. U32 mExpireOption;
  236. // if the notification contains a url, it's stored here (and replaced
  237. // into the message where [_URL] is found)
  238. std::string mURL;
  239. // if there's a URL in the message, this controls which option visits
  240. // that URL. Obsolete this and eliminate the buttons for affected
  241. // messages when we allow clickable URLs in the UI
  242. U32 mURLOption;
  243. std::string mURLTarget;
  244. //This is a flag that tells if the url needs to open externally dispite
  245. //what the user setting is.
  246. // does this notification persist across sessions? if so, it will be
  247. // serialized to disk on first receipt and read on startup
  248. bool mPersist;
  249. // This is the name of the default functor, if present, to be
  250. // used for the notification's callback. It is optional, and used only if
  251. // the notification is constructed without an identified functor.
  252. std::string mDefaultFunctor;
  253. // The form data associated with a given notification (buttons, text boxes, etc)
  254. LLNotificationFormPtr mForm;
  255. // default priority for notifications of this type
  256. ENotificationPriority mPriority;
  257. // UUID of the audio file to be played when this notification arrives
  258. // this is loaded as a name, but looked up to get the UUID upon template load.
  259. // If null, it wasn't specified.
  260. LLUUID mSoundEffect;
  261. // List of tags that rules can match against.
  262. std::list<std::string> mTags;
  263. };
  264. #endif //LL_LLNOTIFICATION_TEMPLATE_H