tizen 2.4 release
[framework/web/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 <boost/optional.hpp>
30 #include <dpl/optional_typedefs.h>
31 #include <dpl/string.h>
32 #include <dpl/platform.h>
33 #include <ctype.h>
34
35 namespace WrtDB {
36 void NormalizeString(DPL::OptionalString& txt, bool isTrimSpace = false);
37 void NormalizeString(DPL::String& str);
38 DPL::String GetSingleAttributeValue(const DPL::String value);
39 void NormalizeAndTrimSpaceString(DPL::OptionalString& txt);
40 #if ENABLE(ELEMENT_ATTR_MAX_LENGTH)
41 void NormalizeString(DPL::String& str, const unsigned int length, bool showEllipsis = false);
42 void NormalizeString(DPL::OptionalString& str, const unsigned int length, bool showEllipsis = false);
43 void NormalizeAndTrimSpaceString(DPL::OptionalString& str, const unsigned int length);
44 #endif // ELEMENT_ATTR_MAX_LENGTH
45
46 class WidgetConfigurationManager;
47
48 class ConfigParserData
49 {
50   public:
51     struct Feature
52     {
53         Feature(const DPL::String& _name) : name(_name)
54         {}
55         DPL::String name;
56
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         bool operator <(const Feature&) const;
62         bool operator<=(const Feature&) const;
63     };
64     typedef std::set<Feature> FeaturesList;
65
66     struct Privilege
67     {
68         Privilege(const DPL::String& _name) : name(_name)
69         {}
70         DPL::String name;
71
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         bool operator <(const Privilege&) const;
77         bool operator<=(const Privilege&) const;
78     };
79     typedef std::set<Privilege> PrivilegeList;
80
81     struct Icon
82     {
83         Icon(const DPL::String& _src) : src(_src), isSmall(false)
84         {}
85         DPL::String src;
86         DPL::OptionalInt width;
87         DPL::OptionalInt height;
88         bool isSmall;
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         bool operator <(const Icon&) const;
94         bool operator<=(const Icon&) const;
95     };
96     typedef std::list<Icon> IconsList;
97
98     struct LocalizedData
99     {
100         DPL::OptionalString name;
101         DPL::OptionalString shortName;
102
103         DPL::OptionalString description;
104
105         DPL::OptionalString license;
106         DPL::OptionalString licenseFile;
107         DPL::OptionalString licenseHref;
108     };
109     typedef std::map<DPL::String, LocalizedData> LocalizedDataSet;
110
111     struct Preference
112     {
113         Preference(const DPL::String& _name,
114                    bool _readonly = false) :
115             name(_name),
116             value(),
117             readonly(_readonly)
118         {}
119         DPL::String name;
120         DPL::OptionalString value;
121         bool readonly;
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         bool operator <(const Preference&) const;
127         bool operator<=(const Preference&) const;
128     };
129     typedef std::set<Preference> PreferencesList;
130     typedef std::set<DPL::String> StringsList;
131
132     struct AccessInfo
133     {
134         AccessInfo(const DPL::String& strIRI,
135                    bool bSubdomainAccess) : m_strIRI(strIRI),
136             m_bSubDomainAccess(bSubdomainAccess)
137         {}
138
139         bool operator==(const AccessInfo&) const;
140         bool operator!=(const AccessInfo&) const;
141         bool operator <(const AccessInfo&) const;
142
143         DPL::String m_strIRI;
144         bool m_bSubDomainAccess;
145     };
146     typedef std::set<AccessInfo> AccessInfoSet;
147
148     struct Setting
149     {
150         Setting(const DPL::String& name,
151                 const DPL::String& value) :
152             m_name(name),
153             m_value(value)
154         {}
155         DPL::String m_name;
156         DPL::String m_value;
157
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         bool operator <(const Setting&) const;
163         bool operator<=(const Setting&) const;
164     };
165
166     typedef std::set<Setting> SettingsList;
167
168     struct AppControlInfo
169     {
170         AppControlInfo(const DPL::String& operation) :
171             m_operation(operation)
172         {}
173         DPL::String m_src;
174         DPL::String m_operation;
175         std::set <DPL::String> m_uriList;
176         std::set <DPL::String> m_mimeList;
177         DPL::String m_reload;
178
179         bool operator==(const AppControlInfo&) const;
180         bool operator!=(const AppControlInfo&) const;
181     };
182
183     typedef std::list<AppControlInfo> AppControlInfoList;
184
185 #if USE(WEB_PROVIDER)
186     struct LiveboxInfo
187     {
188         LiveboxInfo() { }
189
190         struct BoxSize
191         {
192             DPL::String m_size;
193             DPL::String m_preview;
194             DPL::String m_useDecoration;
195         };
196         typedef BoxSize BoxSizeInfo;
197         typedef std::list<BoxSizeInfo> BoxSizeList;
198
199         struct BoxContent
200         {
201             DPL::String m_boxSrc;
202             DPL::String m_boxMouseEvent;
203             DPL::String m_boxTouchEffect;
204             BoxSizeList m_boxSize;
205             DPL::String m_pdSrc;
206             DPL::String m_pdWidth;
207             DPL::String m_pdHeight;
208             DPL::String m_pdFastOpen;
209         };
210         typedef BoxContent BoxContentInfo;
211
212         typedef std::list<std::pair<DPL::String, DPL::String> > BoxLabelList;
213
214         BoxLabelList m_label;
215         DPL::String m_icon;
216         DPL::String m_liveboxId;
217         DPL::String m_primary;
218         DPL::String m_type;
219         DPL::String m_autoLaunch;
220         DPL::String m_updatePeriod;
221         BoxContentInfo m_boxInfo;
222
223         bool operator==(const LiveboxInfo&) const;
224         bool operator!=(const LiveboxInfo&) const;
225         bool operator >(const LiveboxInfo&) const;
226         bool operator>=(const LiveboxInfo&) const;
227         bool operator <(const LiveboxInfo&) const;
228         bool operator<=(const LiveboxInfo&) const;
229     };
230     typedef boost::optional<LiveboxInfo> OptionalLiveboxInfo;
231     typedef std::list<OptionalLiveboxInfo> LiveboxList;
232 #endif
233
234     enum IconSectionType
235     {
236         DefaultIcon =0,
237         SmallIcon
238     };
239
240     typedef std::set<std::pair<IconSectionType, DPL::String>> IconSet;
241     typedef std::list<DPL::String> CapabilityList;
242     typedef std::set<std::pair<DPL::String, DPL::String>> DisplayNameSet;
243
244     struct AccountProvider
245     {
246         AccountProvider() :
247             m_multiAccountSupport(false)
248         { }
249
250         bool m_multiAccountSupport;
251         IconSet m_iconSet;
252         DisplayNameSet m_displayNameSet;
253         CapabilityList m_capabilityList;
254     };
255
256     typedef std::list<DPL::OptionalString> DependsPkgList;
257     typedef std::set<DPL::String> CategoryList;
258     typedef std::set<DPL::String> BackgroundCategoryList;
259
260     struct AllowNavigationInfo
261     {
262         AllowNavigationInfo(DPL::String scheme,
263                             DPL::String host) :
264             m_scheme(scheme),
265             m_host(host)
266         { }
267         DPL::String m_scheme;
268         DPL::String m_host;
269     };
270     typedef std::list<AllowNavigationInfo> AllowNavigationInfoList;
271
272     struct Metadata
273     {
274         Metadata(const DPL::OptionalString& _key,
275                  const DPL::OptionalString& _value) :
276             key(_key),
277             value(_value)
278         {}
279         DPL::OptionalString key;
280         DPL::OptionalString value;
281
282         bool operator==(const Metadata&) const;
283         bool operator!=(const Metadata&) const;
284     };
285     typedef std::list<Metadata> MetadataList;
286
287     struct ImeAppInfo
288     {
289         DPL::String uuid;
290         typedef std::set<DPL::String> LanguageList;
291         LanguageList languageList;
292     };
293     typedef std::list<ImeAppInfo> ImeAppInfoList;
294
295     struct ServiceAppInfo
296     {
297         ServiceAppInfo() : onBoot(false), autoRestart(false) { }
298
299         DPL::String serviceId;
300         bool onBoot;
301         bool autoRestart;
302         LocalizedDataSet m_localizedDataSet;
303         DPL::String serviceContent;
304         IconsList m_iconsList;
305         MetadataList m_metadataList;
306         CategoryList m_categoryList;
307     };
308     typedef std::list<ServiceAppInfo> ServiceAppInfoList;
309
310     enum class SecurityModelVersion {
311         SECURITY_MODEL_V1 = 0, // WARP
312         SECURITY_MODEL_V2      // CSP, allow-navigation
313     };
314 #if USE(WEB_PROVIDER)
315     LiveboxList m_livebox;
316 #endif
317     StringsList nameSpaces;
318
319     LocalizedDataSet localizedDataSet;
320
321     DPL::OptionalString authorName;
322     DPL::OptionalString authorHref;
323     DPL::OptionalString authorEmail;
324
325     FeaturesList featuresList;
326     PrivilegeList privilegeList;
327
328     SettingsList settingsList;
329
330     DPL::OptionalInt width;
331     DPL::OptionalInt height;
332
333     DPL::OptionalString widget_id;
334     DPL::OptionalString defaultlocale;
335
336     PreferencesList preferencesList;
337
338     DPL::OptionalString version;
339     StringsList windowModes;
340
341     AccessInfoSet accessInfoSet;
342
343     bool flashNeeded;
344
345     DPL::OptionalString minVersionRequired;
346
347     bool backSupported;
348     bool accessNetwork;
349
350     // Unlocalized data, to be processed by WidgetConfigurationManager
351     bool startFileEncountered;
352     DPL::OptionalString startFile;
353     DPL::OptionalString startFileEncoding;
354     DPL::OptionalString startFileContentType;
355     DPL::OptionalString startFileNamespace;
356     IconsList iconsList;
357
358     // tizen id / required platform min version for TIZEN webapp
359     DPL::OptionalString tizenMinVersionRequired;
360     DPL::OptionalString tizenPkgId;
361     DPL::OptionalString tizenAppId;
362     bool didFoundTizenApplicationElement;
363
364     // LaunchMode(caller, single)
365     DPL::OptionalString launchMode;
366
367     // Ambient Support(true, false)
368     DPL::OptionalString ambient;
369
370     // allow-navigation
371     bool allowNavigationEncountered;
372     AllowNavigationInfoList allowNavigationInfoList;
373
374     //csp polic for widget
375     bool cspPolicyEncountered;
376     DPL::OptionalString cspPolicy;
377     bool cspPolicyReportOnlyEncountered;
378     DPL::OptionalString cspPolicyReportOnly;
379
380     //AppControl model list
381     AppControlInfoList appControlList;
382
383     // For link shared directory
384     DependsPkgList dependsPkgList;
385     // Splash image path
386     DPL::OptionalString splashImgSrc;
387     // Background page filename
388     DPL::OptionalString backgroundPage;
389     // For category
390     CategoryList categoryList;
391     // For background category
392     BackgroundCategoryList backgroundCategoryList;
393     // For Account
394     AccountProvider accountProvider;
395     // security model version
396     SecurityModelVersion securityModelVersion;
397     // security model version
398     MetadataList metadataList;
399     //ime app
400     ImeAppInfoList imeAppInfoList;
401     //service app
402     ServiceAppInfoList serviceAppInfoList;
403
404     ConfigParserData() :
405         flashNeeded(false),
406         minVersionRequired(),
407         backSupported(false),
408         accessNetwork(false),
409         startFileEncountered(false),
410         didFoundTizenApplicationElement(false),
411         allowNavigationEncountered(false),
412         cspPolicyEncountered(false),
413         cspPolicyReportOnlyEncountered(false),
414         securityModelVersion(SecurityModelVersion::SECURITY_MODEL_V1)
415     {}
416 };
417 } // namespace WrtDB
418
419 #endif  //CONFIG_PARSER_DATA_H_