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