2a85422604f98cd5e8ad4c25f5e84ddb01fedf2c
[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 <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             WINDOW = 0,
164             INLINE
165         };
166         AppControlInfo(const DPL::String& operation) :
167             m_operation(operation),
168             m_index(0)
169         {}
170         DPL::String m_src;
171         DPL::String m_operation;
172         std::set <DPL::String> m_uriList;
173         std::set <DPL::String> m_mimeList;
174         Disposition m_disposition;
175         unsigned m_index;
176
177         bool operator==(const AppControlInfo&) const;
178         bool operator!=(const AppControlInfo&) const;
179     };
180
181     typedef std::list<AppControlInfo> AppControlInfoList;
182
183     typedef std::list<std::pair<DPL::String, DPL::String> > BoxSizeList;
184
185     struct LiveboxInfo
186     {
187         LiveboxInfo() { }
188
189         struct BoxContent
190         {
191             DPL::String m_boxSrc;
192             DPL::String m_boxMouseEvent;
193             DPL::String m_boxTouchEffect;
194             BoxSizeList m_boxSize;
195             DPL::String m_pdSrc;
196             DPL::String m_pdWidth;
197             DPL::String m_pdHeight;
198             DPL::String m_pdFastOpen;
199         };
200         typedef BoxContent BoxContentInfo;
201
202         DPL::String m_label;
203         DPL::String m_icon;
204         DPL::String m_liveboxId;
205         DPL::String m_primary;
206         DPL::String m_type;
207         DPL::String m_autoLaunch;
208         DPL::String m_updatePeriod;
209         BoxContentInfo m_boxInfo;
210
211         bool operator==(const LiveboxInfo&) const;
212         bool operator!=(const LiveboxInfo&) const;
213         bool operator >(const LiveboxInfo&) const;
214         bool operator>=(const LiveboxInfo&) const;
215         bool operator <(const LiveboxInfo&) const;
216         bool operator<=(const LiveboxInfo&) const;
217     };
218     typedef std::list<DPL::Optional<LiveboxInfo> > LiveboxList;
219
220     enum IconSectionType
221     {
222         DefaultIcon =0,
223         SmallIcon
224     };
225
226     typedef std::set<std::pair<IconSectionType, DPL::String>> IconSet;
227     typedef std::list<DPL::String> CapabilityList;
228     typedef std::set<std::pair<DPL::String, DPL::String>> DisplayNameSet;
229
230     struct AccountProvider
231     {
232         AccountProvider() :
233             m_multiAccountSupport(false)
234         { }
235
236         bool m_multiAccountSupport;
237         IconSet m_iconSet;
238         DisplayNameSet m_displayNameSet;
239         CapabilityList m_capabilityList;
240     };
241
242     typedef std::list<DPL::OptionalString> DependsPkgList;
243     typedef std::set<DPL::String> CategoryList;
244
245     struct AllowNavigationInfo
246     {
247         AllowNavigationInfo(DPL::String scheme,
248                             DPL::String host) :
249             m_scheme(scheme),
250             m_host(host)
251         { }
252         DPL::String m_scheme;
253         DPL::String m_host;
254     };
255     typedef std::list<AllowNavigationInfo> AllowNavigationInfoList;
256
257     enum class SecurityModelVersion {
258         SECURITY_MODEL_V1 = 0, // WARP
259         SECURITY_MODEL_V2      // CSP, allow-navigation
260     };
261
262     LiveboxList m_livebox;
263     StringsList nameSpaces;
264
265     LocalizedDataSet localizedDataSet;
266
267     DPL::OptionalString authorName;
268     DPL::OptionalString authorHref;
269     DPL::OptionalString authorEmail;
270
271     FeaturesList featuresList;
272     PrivilegeList privilegeList;
273
274     SettingsList settingsList;
275
276     DPL::OptionalInt width;
277     DPL::OptionalInt height;
278
279     DPL::OptionalString widget_id;
280     DPL::OptionalString defaultlocale;
281
282     PreferencesList preferencesList;
283
284     DPL::OptionalString version;
285     StringsList windowModes;
286
287     AccessInfoSet accessInfoSet;
288
289     bool flashNeeded;
290
291     DPL::OptionalString minVersionRequired;
292
293     bool backSupported;
294     bool accessNetwork;
295
296     // Unlocalized data, to be processed by WidgetConfigurationManager
297     bool startFileEncountered;
298     DPL::OptionalString startFile;
299     DPL::OptionalString startFileEncoding;
300     DPL::OptionalString startFileContentType;
301     IconsList iconsList;
302
303     // tizen id / required platform min version for TIZEN webapp
304     DPL::OptionalString tizenMinVersionRequired;
305     DPL::OptionalString tizenPkgId;
306     DPL::OptionalString tizenAppId;
307
308     // allow-navigation
309     AllowNavigationInfoList allowNavigationInfoList;
310
311     //csp polic for widget
312     DPL::OptionalString cspPolicy;
313     DPL::OptionalString cspPolicyReportOnly;
314
315     //AppControl model list
316     AppControlInfoList appControlList;
317
318     // For link shared directory
319     DependsPkgList dependsPkgList;
320     // Splash image path
321     DPL::OptionalString splashImgSrc;
322     // Background page filename
323     DPL::OptionalString backgroundPage;
324     // For category
325     CategoryList categoryList;
326     // For Account
327     AccountProvider accountProvider;
328     // security model version
329     SecurityModelVersion securityModelVersion;
330
331     ConfigParserData() :
332         flashNeeded(false),
333         minVersionRequired(),
334         backSupported(false),
335         accessNetwork(false),
336         startFileEncountered(false),
337         securityModelVersion(SecurityModelVersion::SECURITY_MODEL_V1)
338     {}
339 };
340 } // namespace WrtDB
341
342 #endif  //CONFIG_PARSER_DATA_H_