2241a7aada54f6fd37ecb0ae99ffcb9fd310bcb0
[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
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
40 class WidgetConfigurationManager;
41
42 class ConfigParserData
43 {
44   public:
45     struct Param
46     {
47         Param(const DPL::String& _name) : name(_name)
48         {
49         }
50         DPL::String name;
51         DPL::String value;
52         bool operator==(const Param&) const;
53         bool operator!=(const Param&) const;
54         bool operator >(const Param&) const;
55         bool operator>=(const Param&) const;
56         bool operator <(const Param&) const;
57         bool operator<=(const Param&) const;
58     };
59     typedef std::set<Param> ParamsList;
60
61     struct Feature
62     {
63         Feature(const DPL::String& _name,
64                 bool _required = true) : name(_name),
65             required(_required)
66         {
67         }
68         DPL::String name;
69         bool required;
70         ParamsList paramsList;
71
72         bool operator==(const Feature&) const;
73         bool operator!=(const Feature&) const;
74         bool operator >(const Feature&) const;
75         bool operator>=(const Feature&) const;
76         bool operator <(const Feature&) const;
77         bool operator<=(const Feature&) const;
78     };
79     typedef std::set<Feature> FeaturesList;
80
81     struct Privilege
82     {
83         Privilege(const DPL::String& _name) : name(_name)
84         {
85         }
86         DPL::String name;
87
88         bool operator==(const Privilege&) const;
89         bool operator!=(const Privilege&) const;
90         bool operator >(const Privilege&) const;
91         bool operator>=(const Privilege&) const;
92         bool operator <(const Privilege&) const;
93         bool operator<=(const Privilege&) const;
94     };
95     typedef std::set<Privilege> PrivilegeList;
96
97     struct Icon
98     {
99         Icon(const DPL::String& _src) : src(_src)
100         {
101         }
102         DPL::String src;
103         DPL::OptionalInt width;
104         DPL::OptionalInt height;
105         bool operator==(const Icon&) const;
106         bool operator!=(const Icon&) const;
107         bool operator >(const Icon&) const;
108         bool operator>=(const Icon&) const;
109         bool operator <(const Icon&) const;
110         bool operator<=(const Icon&) const;
111     };
112     typedef std::list<Icon> IconsList;
113
114     struct LocalizedData
115     {
116         DPL::OptionalString name;
117         DPL::OptionalString shortName;
118
119         DPL::OptionalString description;
120
121         DPL::OptionalString license;
122         DPL::OptionalString licenseFile;
123         DPL::OptionalString licenseHref;
124     };
125     typedef std::map<DPL::String, LocalizedData> LocalizedDataSet;
126
127     struct Preference
128     {
129         Preference(const DPL::String& _name,
130                 bool _readonly = false) :
131             name(_name),
132             value(),
133             readonly(_readonly)
134         {
135         }
136         DPL::String name;
137         DPL::OptionalString value;
138         bool readonly;
139         bool operator==(const Preference&) const;
140         bool operator!=(const Preference&) const;
141         bool operator >(const Preference&) const;
142         bool operator>=(const Preference&) const;
143         bool operator <(const Preference&) const;
144         bool operator<=(const Preference&) const;
145     };
146     typedef std::set<Preference> PreferencesList;
147     typedef std::set<DPL::String> StringsList;
148
149     struct AccessInfo
150     {
151         AccessInfo(const DPL::String& strIRI,
152                 bool bSubdomainAccess) : m_strIRI(strIRI),
153             m_bSubDomainAccess(bSubdomainAccess)
154         {
155         }
156
157         bool operator==(const AccessInfo&) const;
158         bool operator!=(const AccessInfo&) const;
159         bool operator <(const AccessInfo&) const;
160
161         DPL::String m_strIRI;
162         bool m_bSubDomainAccess;
163     };
164     typedef std::set<AccessInfo> AccessInfoSet;
165
166     struct Setting
167     {
168         Setting(const DPL::String& name,
169                 const DPL::String& value) :
170                 m_name(name),
171                 m_value(value)
172         {
173         }
174         DPL::String m_name;
175         DPL::String m_value;
176
177         bool operator==(const Setting&) const;
178         bool operator!=(const Setting&) const;
179         bool operator >(const Setting&) const;
180         bool operator>=(const Setting&) const;
181         bool operator <(const Setting&) const;
182         bool operator<=(const Setting&) const;
183     };
184
185     typedef std::set<Setting> SettingsList;
186
187     /* ServiceInfo will be removed.
188      * ServiceInfo will be changed AppControl
189      */
190     struct ServiceInfo
191     {
192         ServiceInfo(
193             const DPL::String& src,
194             const DPL::String& operation,
195             const DPL::String& scheme,
196             const DPL::String& mime) :
197             m_src(src),
198             m_operation(operation),
199             m_scheme(scheme),
200             m_mime(mime)
201         {
202         }
203         DPL::String m_src;
204         DPL::String m_operation;
205         DPL::String m_scheme;
206         DPL::String m_mime;
207
208         bool operator==(const ServiceInfo&) const;
209         bool operator!=(const ServiceInfo&) const;
210     };
211
212     struct AppControlInfo
213     {
214         AppControlInfo(
215             const DPL::String& operation) :
216             m_operation(operation)
217         {
218         }
219         DPL::String m_src;
220         DPL::String m_operation;
221         std::set <DPL::String> m_uriList;
222         std::set <DPL::String> m_mimeList;
223
224         bool operator==(const AppControlInfo&) const;
225         bool operator!=(const AppControlInfo&) const;
226     };
227
228     typedef std::list<ServiceInfo> ServiceInfoList; // It will be removed.
229     typedef std::list<AppControlInfo> AppControlInfoList;
230
231     typedef std::list<std::pair<DPL::String, DPL::String>> BoxSizeList;
232
233     struct LiveboxInfo
234     {
235         LiveboxInfo() { }
236
237         struct BoxContent
238         {
239             DPL::String m_boxSrc;
240             DPL::String m_boxMouseEvent;
241             BoxSizeList m_boxSize;
242             DPL::String m_pdSrc;
243             DPL::String m_pdWidth;
244             DPL::String m_pdHeight;
245         }; typedef BoxContent BoxContentInfo;
246
247         DPL::String m_label;
248         DPL::String m_icon;
249         DPL::String m_liveboxId;
250         DPL::String m_primary;
251         DPL::String m_type;
252         DPL::String m_autoLaunch;
253         DPL::String m_updatePeriod;
254         BoxContentInfo m_boxInfo;
255
256         bool operator==(const LiveboxInfo&) const;
257         bool operator!=(const LiveboxInfo&) const;
258         bool operator >(const LiveboxInfo&) const;
259         bool operator>=(const LiveboxInfo&) const;
260         bool operator <(const LiveboxInfo&) const;
261         bool operator<=(const LiveboxInfo&) const;
262     };
263     typedef std::list<DPL::Optional<LiveboxInfo>> LiveboxList;
264     LiveboxList m_livebox;
265
266     typedef std::list<DPL::OptionalString> DependsPkgList;
267
268     typedef std::set<DPL::String> CategoryList;
269
270     StringsList nameSpaces;
271
272     LocalizedDataSet localizedDataSet;
273
274     DPL::OptionalString authorName;
275     DPL::OptionalString authorHref;
276     DPL::OptionalString authorEmail;
277
278     FeaturesList featuresList;
279     PrivilegeList privilegeList;
280
281     SettingsList settingsList;
282
283     DPL::OptionalInt width;
284     DPL::OptionalInt height;
285
286     DPL::OptionalString widget_id;
287     DPL::OptionalString defaultlocale;
288
289     PreferencesList preferencesList;
290
291     DPL::OptionalString version;
292     StringsList windowModes;
293
294     AccessInfoSet accessInfoSet;
295
296     bool flashNeeded;
297
298     DPL::OptionalString minVersionRequired;
299
300     bool backSupported;
301     bool accessNetwork;
302
303     // Unlocalized data, to be processed by WidgetConfigurationManager
304     bool startFileEncountered;
305     DPL::OptionalString startFile;
306     DPL::OptionalString startFileEncoding;
307     DPL::OptionalString startFileContentType;
308     IconsList iconsList;
309
310     // tizen id / required platform min version for TIZEN webapp
311     DPL::OptionalString tizenId;
312     DPL::OptionalString tizenMinVersionRequired;
313     DPL::OptionalString tizenPkgId;
314     DPL::OptionalString tizenAppId;
315
316     //csp polic for widget
317     DPL::OptionalString cspPolicy;
318
319     //Application service model list
320     ServiceInfoList appServiceList; //It will be removed.
321     AppControlInfoList appControlList;
322
323     // For link shared directory
324     DependsPkgList dependsPkgList;
325     // Splash image path
326     DPL::OptionalString splashImgSrc;
327     // Background page filename
328     DPL::OptionalString backgroundPage;
329     // For category
330     CategoryList categoryList;
331
332     ConfigParserData() :
333         flashNeeded(false),
334         minVersionRequired(),
335         backSupported(false),
336         accessNetwork(false),
337         startFileEncountered(false)
338     {
339     }
340 };
341
342 } // namespace WrtDB
343
344 #endif  //CONFIG_PARSER_DATA_H_