Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules_mobile / 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 <ctype.h>
32
33 namespace WrtDB {
34 void NormalizeString(DPL::OptionalString& txt, bool isTrimSpace = false);
35 void NormalizeString(DPL::String& str);
36 DPL::String GetSingleAttributeValue(const DPL::String value);
37 void NormalizeAndTrimSpaceString(DPL::OptionalString& txt);
38
39 class WidgetConfigurationManager;
40
41 class ConfigParserData
42 {
43   public:
44     struct Feature
45     {
46         Feature(const DPL::String& _name) : name(_name)
47         {}
48         DPL::String name;
49
50         bool operator==(const Feature&) const;
51         bool operator!=(const Feature&) const;
52         bool operator >(const Feature&) const;
53         bool operator>=(const Feature&) const;
54         bool operator <(const Feature&) const;
55         bool operator<=(const Feature&) const;
56     };
57     typedef std::set<Feature> FeaturesList;
58
59     struct Privilege
60     {
61         Privilege(const DPL::String& _name) : name(_name)
62         {}
63         DPL::String name;
64
65         bool operator==(const Privilege&) const;
66         bool operator!=(const Privilege&) const;
67         bool operator >(const Privilege&) const;
68         bool operator>=(const Privilege&) const;
69         bool operator <(const Privilege&) const;
70         bool operator<=(const Privilege&) const;
71     };
72     typedef std::set<Privilege> PrivilegeList;
73
74     struct Icon
75     {
76         Icon(const DPL::String& _src) : src(_src)
77         {}
78         DPL::String src;
79         DPL::OptionalInt width;
80         DPL::OptionalInt height;
81         bool operator==(const Icon&) const;
82         bool operator!=(const Icon&) const;
83         bool operator >(const Icon&) const;
84         bool operator>=(const Icon&) const;
85         bool operator <(const Icon&) const;
86         bool operator<=(const Icon&) const;
87     };
88     typedef std::list<Icon> IconsList;
89
90     struct LocalizedData
91     {
92         DPL::OptionalString name;
93         DPL::OptionalString shortName;
94
95         DPL::OptionalString description;
96
97         DPL::OptionalString license;
98         DPL::OptionalString licenseFile;
99         DPL::OptionalString licenseHref;
100     };
101     typedef std::map<DPL::String, LocalizedData> LocalizedDataSet;
102
103     struct Preference
104     {
105         Preference(const DPL::String& _name,
106                    bool _readonly = false) :
107             name(_name),
108             value(),
109             readonly(_readonly)
110         {}
111         DPL::String name;
112         DPL::OptionalString value;
113         bool readonly;
114         bool operator==(const Preference&) const;
115         bool operator!=(const Preference&) const;
116         bool operator >(const Preference&) const;
117         bool operator>=(const Preference&) const;
118         bool operator <(const Preference&) const;
119         bool operator<=(const Preference&) const;
120     };
121     typedef std::set<Preference> PreferencesList;
122     typedef std::set<DPL::String> StringsList;
123
124     struct AccessInfo
125     {
126         AccessInfo(const DPL::String& strIRI,
127                    bool bSubdomainAccess) : m_strIRI(strIRI),
128             m_bSubDomainAccess(bSubdomainAccess)
129         {}
130
131         bool operator==(const AccessInfo&) const;
132         bool operator!=(const AccessInfo&) const;
133         bool operator <(const AccessInfo&) const;
134
135         DPL::String m_strIRI;
136         bool m_bSubDomainAccess;
137     };
138     typedef std::set<AccessInfo> AccessInfoSet;
139
140     struct Setting
141     {
142         Setting(const DPL::String& name,
143                 const DPL::String& value) :
144             m_name(name),
145             m_value(value)
146         {}
147         DPL::String m_name;
148         DPL::String m_value;
149
150         bool operator==(const Setting&) const;
151         bool operator!=(const Setting&) const;
152         bool operator >(const Setting&) const;
153         bool operator>=(const Setting&) const;
154         bool operator <(const Setting&) const;
155         bool operator<=(const Setting&) const;
156     };
157
158     typedef std::set<Setting> SettingsList;
159
160     struct AppControlInfo
161     {
162         enum class Disposition {
163             UNDEFINE = 0,
164             WINDOW   = 1,
165             INLINE   = 2
166         };
167         AppControlInfo(const DPL::String& operation) :
168             m_operation(operation),
169             m_disposition(Disposition::UNDEFINE),
170             m_index(0)
171         {}
172         DPL::String m_src;
173         DPL::String m_operation;
174         std::set <DPL::String> m_uriList;
175         std::set <DPL::String> m_mimeList;
176         Disposition m_disposition;
177         unsigned m_index;
178
179         bool operator==(const AppControlInfo&) const;
180         bool operator!=(const AppControlInfo&) const;
181     };
182
183     typedef std::list<AppControlInfo> AppControlInfoList;
184
185     struct LiveboxInfo
186     {
187         LiveboxInfo() { }
188
189         struct BoxSize
190         {
191             DPL::String m_size;
192             DPL::String m_preview;
193             DPL::String m_useDecoration;
194         };
195         typedef BoxSize BoxSizeInfo;
196         typedef std::list<BoxSizeInfo> BoxSizeList;
197
198         struct BoxContent
199         {
200             DPL::String m_boxSrc;
201             DPL::String m_boxMouseEvent;
202             DPL::String m_boxTouchEffect;
203             BoxSizeList m_boxSize;
204             DPL::String m_pdSrc;
205             DPL::String m_pdWidth;
206             DPL::String m_pdHeight;
207             DPL::String m_pdFastOpen;
208         };
209         typedef BoxContent BoxContentInfo;
210
211         typedef std::list<std::pair<DPL::String, DPL::String> > BoxLabelList;
212
213         BoxLabelList m_label;
214         DPL::String m_icon;
215         DPL::String m_liveboxId;
216         DPL::String m_primary;
217         DPL::String m_type;
218         DPL::String m_autoLaunch;
219         DPL::String m_updatePeriod;
220         BoxContentInfo m_boxInfo;
221
222         bool operator==(const LiveboxInfo&) const;
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     };
229     typedef std::list<DPL::Optional<LiveboxInfo> > LiveboxList;
230
231     enum IconSectionType
232     {
233         DefaultIcon =0,
234         SmallIcon
235     };
236
237     typedef std::set<std::pair<IconSectionType, DPL::String>> IconSet;
238     typedef std::list<DPL::String> CapabilityList;
239     typedef std::set<std::pair<DPL::String, DPL::String>> DisplayNameSet;
240
241     struct AccountProvider
242     {
243         AccountProvider() :
244             m_multiAccountSupport(false)
245         { }
246
247         bool m_multiAccountSupport;
248         IconSet m_iconSet;
249         DisplayNameSet m_displayNameSet;
250         CapabilityList m_capabilityList;
251     };
252
253     typedef std::list<DPL::OptionalString> DependsPkgList;
254     typedef std::set<DPL::String> CategoryList;
255
256     struct AllowNavigationInfo
257     {
258         AllowNavigationInfo(DPL::String scheme,
259                             DPL::String host) :
260             m_scheme(scheme),
261             m_host(host)
262         { }
263         DPL::String m_scheme;
264         DPL::String m_host;
265     };
266     typedef std::list<AllowNavigationInfo> AllowNavigationInfoList;
267
268     struct Metadata
269     {
270         Metadata(const DPL::OptionalString& _key,
271                  const DPL::OptionalString& _value) :
272             key(_key),
273             value(_value)
274         {}
275         DPL::OptionalString key;
276         DPL::OptionalString value;
277
278         bool operator==(const Metadata&) const;
279         bool operator!=(const Metadata&) const;
280     };
281     typedef std::list<Metadata> MetadataList;
282
283     enum class SecurityModelVersion {
284         SECURITY_MODEL_V1 = 0, // WARP
285         SECURITY_MODEL_V2      // CSP, allow-navigation
286     };
287
288     LiveboxList m_livebox;
289     StringsList nameSpaces;
290
291     LocalizedDataSet localizedDataSet;
292
293     DPL::OptionalString authorName;
294     DPL::OptionalString authorHref;
295     DPL::OptionalString authorEmail;
296
297     FeaturesList featuresList;
298     PrivilegeList privilegeList;
299
300     SettingsList settingsList;
301
302     DPL::OptionalInt width;
303     DPL::OptionalInt height;
304
305     DPL::OptionalString widget_id;
306     DPL::OptionalString defaultlocale;
307
308     PreferencesList preferencesList;
309
310     DPL::OptionalString version;
311     StringsList windowModes;
312
313     AccessInfoSet accessInfoSet;
314
315     bool flashNeeded;
316
317     DPL::OptionalString minVersionRequired;
318
319     bool backSupported;
320     bool accessNetwork;
321
322     // Unlocalized data, to be processed by WidgetConfigurationManager
323     bool startFileEncountered;
324     DPL::OptionalString startFile;
325     DPL::OptionalString startFileEncoding;
326     DPL::OptionalString startFileContentType;
327     DPL::OptionalString startFileNamespace;
328     IconsList iconsList;
329
330     // tizen id / required platform min version for TIZEN webapp
331     DPL::OptionalString tizenMinVersionRequired;
332     DPL::OptionalString tizenPkgId;
333     DPL::OptionalString tizenAppId;
334
335     // allow-navigation
336     bool allowNavigationEncountered;
337     AllowNavigationInfoList allowNavigationInfoList;
338
339     //csp polic for widget
340     DPL::OptionalString cspPolicy;
341     DPL::OptionalString cspPolicyReportOnly;
342
343     //AppControl model list
344     AppControlInfoList appControlList;
345
346     // For link shared directory
347     DependsPkgList dependsPkgList;
348     // Splash image path
349     DPL::OptionalString splashImgSrc;
350     // Background page filename
351     DPL::OptionalString backgroundPage;
352     // For category
353     CategoryList categoryList;
354     // For Account
355     AccountProvider accountProvider;
356     // security model version
357     SecurityModelVersion securityModelVersion;
358     // security model version
359     MetadataList metadataList;
360
361     ConfigParserData() :
362         flashNeeded(false),
363         minVersionRequired(),
364         backSupported(false),
365         accessNetwork(false),
366         startFileEncountered(false),
367         allowNavigationEncountered(false),
368         securityModelVersion(SecurityModelVersion::SECURITY_MODEL_V1)
369     {}
370 };
371 } // namespace WrtDB
372
373 #endif  //CONFIG_PARSER_DATA_H_