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