tizen 2.3.1 release
[framework/web/wearable/wrt-commons.git] / modules / widget_dao / include / dpl / wrt-dao-ro / config_parser_data.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file        config_parser_data.h
18  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
19  * @version     0.1
20  * @brief
21  */
22 #ifndef CONFIG_PARSER_DATA_H_
23 #define CONFIG_PARSER_DATA_H_
24
25 #include <string>
26 #include <set>
27 #include <list>
28 #include <map>
29 #include <dpl/optional_typedefs.h>
30 #include <dpl/string.h>
31 #include <dpl/platform.h>
32 #include <ctype.h>
33
34 namespace WrtDB {
35 void NormalizeString(DPL::OptionalString& txt, bool isTrimSpace = false);
36 void NormalizeString(DPL::String& str);
37 DPL::String GetSingleAttributeValue(const DPL::String value);
38 void NormalizeAndTrimSpaceString(DPL::OptionalString& txt);
39 #if ENABLE(ELEMENT_ATTR_MAX_LENGTH)
40 void NormalizeString(DPL::String& str, const unsigned int length, bool showEllipsis = false);
41 void NormalizeString(DPL::OptionalString& str, const unsigned int length, bool showEllipsis = false);
42 void NormalizeAndTrimSpaceString(DPL::OptionalString& str, const unsigned int length);
43 #endif // ELEMENT_ATTR_MAX_LENGTH
44 class WidgetConfigurationManager;
45
46 class ConfigParserData
47 {
48   public:
49     struct Feature
50     {
51         Feature(const DPL::String& _name) : name(_name)
52         {}
53         DPL::String name;
54
55         bool operator==(const Feature&) const;
56         bool operator!=(const Feature&) const;
57         bool operator >(const Feature&) const;
58         bool operator>=(const Feature&) const;
59         bool operator <(const Feature&) const;
60         bool operator<=(const Feature&) const;
61     };
62     typedef std::set<Feature> FeaturesList;
63
64     struct Privilege
65     {
66         Privilege(const DPL::String& _name) : name(_name)
67         {}
68         DPL::String name;
69
70         bool operator==(const Privilege&) const;
71         bool operator!=(const Privilege&) const;
72         bool operator >(const Privilege&) const;
73         bool operator>=(const Privilege&) const;
74         bool operator <(const Privilege&) const;
75         bool operator<=(const Privilege&) const;
76     };
77     typedef std::set<Privilege> PrivilegeList;
78
79     struct Icon
80     {
81         Icon(const DPL::String& _src) : src(_src), isSmall(false)
82         {}
83         DPL::String src;
84         DPL::OptionalInt width;
85         DPL::OptionalInt height;
86         bool isSmall;
87         bool operator==(const Icon&) const;
88         bool operator!=(const Icon&) const;
89         bool operator >(const Icon&) const;
90         bool operator>=(const Icon&) const;
91         bool operator <(const Icon&) const;
92         bool operator<=(const Icon&) const;
93     };
94     typedef std::list<Icon> IconsList;
95
96     struct LocalizedData
97     {
98         DPL::OptionalString name;
99         DPL::OptionalString shortName;
100
101         DPL::OptionalString description;
102
103         DPL::OptionalString license;
104         DPL::OptionalString licenseFile;
105         DPL::OptionalString licenseHref;
106     };
107     typedef std::map<DPL::String, LocalizedData> LocalizedDataSet;
108
109     struct Preference
110     {
111         Preference(const DPL::String& _name,
112                    bool _readonly = false) :
113             name(_name),
114             value(),
115             readonly(_readonly)
116         {}
117         DPL::String name;
118         DPL::OptionalString value;
119         bool readonly;
120         bool operator==(const Preference&) const;
121         bool operator!=(const Preference&) const;
122         bool operator >(const Preference&) const;
123         bool operator>=(const Preference&) const;
124         bool operator <(const Preference&) const;
125         bool operator<=(const Preference&) const;
126     };
127     typedef std::set<Preference> PreferencesList;
128     typedef std::set<DPL::String> StringsList;
129
130     struct AccessInfo
131     {
132         AccessInfo(const DPL::String& strIRI,
133                    bool bSubdomainAccess) : m_strIRI(strIRI),
134             m_bSubDomainAccess(bSubdomainAccess)
135         {}
136
137         bool operator==(const AccessInfo&) const;
138         bool operator!=(const AccessInfo&) const;
139         bool operator <(const AccessInfo&) const;
140
141         DPL::String m_strIRI;
142         bool m_bSubDomainAccess;
143     };
144     typedef std::set<AccessInfo> AccessInfoSet;
145
146     struct Setting
147     {
148         Setting(const DPL::String& name,
149                 const DPL::String& value) :
150             m_name(name),
151             m_value(value)
152         {}
153         DPL::String m_name;
154         DPL::String m_value;
155
156         bool operator==(const Setting&) const;
157         bool operator!=(const Setting&) const;
158         bool operator >(const Setting&) const;
159         bool operator>=(const Setting&) const;
160         bool operator <(const Setting&) const;
161         bool operator<=(const Setting&) const;
162     };
163
164     typedef std::set<Setting> SettingsList;
165
166     struct AppControlInfo
167     {
168         enum class Disposition {
169             UNDEFINE = 0,
170             WINDOW   = 1,
171             INLINE   = 2
172         };
173         AppControlInfo(const DPL::String& operation) :
174             m_operation(operation),
175             m_disposition(Disposition::UNDEFINE),
176             m_index(0)
177         {}
178         DPL::String m_src;
179         DPL::String m_operation;
180         std::set <DPL::String> m_uriList;
181         std::set <DPL::String> m_mimeList;
182         Disposition m_disposition;
183         unsigned m_index;
184
185         bool operator==(const AppControlInfo&) const;
186         bool operator!=(const AppControlInfo&) const;
187     };
188
189     typedef std::list<AppControlInfo> AppControlInfoList;
190
191     struct LiveboxInfo
192     {
193         LiveboxInfo() { }
194
195         struct BoxSize
196         {
197             DPL::String m_size;
198             DPL::String m_preview;
199             DPL::String m_useDecoration;
200         };
201         typedef BoxSize BoxSizeInfo;
202         typedef std::list<BoxSizeInfo> BoxSizeList;
203
204         struct BoxContent
205         {
206             DPL::String m_boxSrc;
207             DPL::String m_boxMouseEvent;
208             DPL::String m_boxTouchEffect;
209             BoxSizeList m_boxSize;
210             DPL::String m_pdSrc;
211             DPL::String m_pdWidth;
212             DPL::String m_pdHeight;
213             DPL::String m_pdFastOpen;
214         };
215         typedef BoxContent BoxContentInfo;
216
217         typedef std::list<std::pair<DPL::String, DPL::String> > BoxLabelList;
218
219         BoxLabelList m_label;
220         DPL::String m_icon;
221         DPL::String m_liveboxId;
222         DPL::String m_primary;
223         DPL::String m_type;
224         DPL::String m_autoLaunch;
225         DPL::String m_updatePeriod;
226         BoxContentInfo m_boxInfo;
227
228         bool operator==(const LiveboxInfo&) const;
229         bool operator!=(const LiveboxInfo&) const;
230         bool operator >(const LiveboxInfo&) const;
231         bool operator>=(const LiveboxInfo&) const;
232         bool operator <(const LiveboxInfo&) const;
233         bool operator<=(const LiveboxInfo&) const;
234     };
235     typedef DPL::Optional<LiveboxInfo> OptionalLiveboxInfo;
236     typedef std::list<OptionalLiveboxInfo> LiveboxList;
237
238     enum IconSectionType
239     {
240         DefaultIcon =0,
241         SmallIcon
242     };
243
244     typedef std::set<std::pair<IconSectionType, DPL::String>> IconSet;
245     typedef std::list<DPL::String> CapabilityList;
246     typedef std::set<std::pair<DPL::String, DPL::String>> DisplayNameSet;
247
248     struct AccountProvider
249     {
250         AccountProvider() :
251             m_multiAccountSupport(false)
252         { }
253
254         bool m_multiAccountSupport;
255         IconSet m_iconSet;
256         DisplayNameSet m_displayNameSet;
257         CapabilityList m_capabilityList;
258     };
259
260     typedef std::list<DPL::OptionalString> DependsPkgList;
261     typedef std::set<DPL::String> CategoryList;
262
263     struct AllowNavigationInfo
264     {
265         AllowNavigationInfo(DPL::String scheme,
266                             DPL::String host) :
267             m_scheme(scheme),
268             m_host(host)
269         { }
270         DPL::String m_scheme;
271         DPL::String m_host;
272     };
273     typedef std::list<AllowNavigationInfo> AllowNavigationInfoList;
274
275     struct Metadata
276     {
277         Metadata(const DPL::OptionalString& _key,
278                  const DPL::OptionalString& _value) :
279             key(_key),
280             value(_value)
281         {}
282         DPL::OptionalString key;
283         DPL::OptionalString value;
284
285         bool operator==(const Metadata&) const;
286         bool operator!=(const Metadata&) const;
287     };
288     typedef std::list<Metadata> MetadataList;
289
290     struct ImeAppInfo
291     {
292         DPL::String uuid;
293         typedef std::set<DPL::String> LanguageList;
294         LanguageList languageList;
295     };
296     typedef std::list<ImeAppInfo> ImeAppInfoList;
297
298     struct ServiceAppInfo
299     {
300         ServiceAppInfo() : onBoot(false), autoRestart(false) { }
301
302         DPL::String serviceId;
303         bool onBoot;
304         bool autoRestart;
305         LocalizedDataSet m_localizedDataSet;
306         DPL::String serviceContent;
307         IconsList m_iconsList;
308         MetadataList m_metadataList;
309         CategoryList m_categoryList;
310     };
311     typedef std::list<ServiceAppInfo> ServiceAppInfoList;
312
313     enum class SecurityModelVersion {
314         SECURITY_MODEL_V1 = 0, // WARP
315         SECURITY_MODEL_V2      // CSP, allow-navigation
316     };
317
318     LiveboxList m_livebox;
319     StringsList nameSpaces;
320
321     LocalizedDataSet localizedDataSet;
322
323     DPL::OptionalString authorName;
324     DPL::OptionalString authorHref;
325     DPL::OptionalString authorEmail;
326
327     FeaturesList featuresList;
328     PrivilegeList privilegeList;
329
330     SettingsList settingsList;
331
332     DPL::OptionalInt width;
333     DPL::OptionalInt height;
334
335     DPL::OptionalString widget_id;
336     DPL::OptionalString defaultlocale;
337
338     PreferencesList preferencesList;
339
340     DPL::OptionalString version;
341     StringsList windowModes;
342
343     AccessInfoSet accessInfoSet;
344
345     bool flashNeeded;
346
347     DPL::OptionalString minVersionRequired;
348
349     bool backSupported;
350     bool accessNetwork;
351
352     // Unlocalized data, to be processed by WidgetConfigurationManager
353     bool startFileEncountered;
354     DPL::OptionalString startFile;
355     DPL::OptionalString startFileEncoding;
356     DPL::OptionalString startFileContentType;
357     DPL::OptionalString startFileNamespace;
358     IconsList iconsList;
359
360     // tizen id / required platform min version for TIZEN webapp
361     DPL::OptionalString tizenMinVersionRequired;
362     DPL::OptionalString tizenPkgId;
363     DPL::OptionalString tizenAppId;
364     bool didFoundTizenApplicationElement;
365
366     // Ambient Support(true, false)
367     DPL::OptionalString ambient;
368
369     // allow-navigation
370     bool allowNavigationEncountered;
371     AllowNavigationInfoList allowNavigationInfoList;
372
373     //csp polic for widget
374     bool cspPolicyEncountered;
375     DPL::OptionalString cspPolicy;
376     bool cspPolicyReportOnlyEncountered;
377     DPL::OptionalString cspPolicyReportOnly;
378
379     //AppControl model list
380     AppControlInfoList appControlList;
381
382     // For link shared directory
383     DependsPkgList dependsPkgList;
384     // Splash image path
385     DPL::OptionalString splashImgSrc;
386     // Background page filename
387     DPL::OptionalString backgroundPage;
388     // For category
389     CategoryList categoryList;
390     // For Account
391     AccountProvider accountProvider;
392     // security model version
393     SecurityModelVersion securityModelVersion;
394     // security model version
395     MetadataList metadataList;
396     //ime app
397     ImeAppInfoList imeAppInfoList;
398     //service app
399     ServiceAppInfoList serviceAppInfoList;
400
401     ConfigParserData() :
402         flashNeeded(false),
403         minVersionRequired(),
404         backSupported(false),
405         accessNetwork(false),
406         startFileEncountered(false),
407         didFoundTizenApplicationElement(false),
408         allowNavigationEncountered(false),
409         cspPolicyEncountered(false),
410         cspPolicyReportOnlyEncountered(false),
411         securityModelVersion(SecurityModelVersion::SECURITY_MODEL_V1)
412     {}
413 };
414 } // namespace WrtDB
415
416 #endif  //CONFIG_PARSER_DATA_H_