aa0c6b9bb24769ad81c7fdf25630d9a8a6a5a3a7
[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 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         };
199         typedef BoxContent BoxContentInfo;
200
201         DPL::String m_label;
202         DPL::String m_icon;
203         DPL::String m_liveboxId;
204         DPL::String m_primary;
205         DPL::String m_type;
206         DPL::String m_autoLaunch;
207         DPL::String m_updatePeriod;
208         BoxContentInfo m_boxInfo;
209
210         bool operator==(const LiveboxInfo&) const;
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     };
217     typedef std::list<DPL::Optional<LiveboxInfo> > LiveboxList;
218
219     enum IconSectionType
220     {
221         DefaultIcon =0,
222         SmallIcon
223     };
224
225     typedef std::set<std::pair<IconSectionType, DPL::String>> IconSet;
226     typedef std::list<DPL::String> CapabilityList;
227     typedef std::set<std::pair<DPL::String, DPL::String>> DisplayNameSet;
228
229     struct AccountProvider
230     {
231         AccountProvider() :
232             m_multiAccountSupport(false)
233         { }
234
235         bool m_multiAccountSupport;
236         IconSet m_iconSet;
237         DisplayNameSet m_displayNameSet;
238         CapabilityList m_capabilityList;
239     };
240
241     LiveboxList m_livebox;
242
243     typedef std::list<DPL::OptionalString> DependsPkgList;
244
245     typedef std::set<DPL::String> CategoryList;
246
247     StringsList nameSpaces;
248
249     LocalizedDataSet localizedDataSet;
250
251     DPL::OptionalString authorName;
252     DPL::OptionalString authorHref;
253     DPL::OptionalString authorEmail;
254
255     FeaturesList featuresList;
256     PrivilegeList privilegeList;
257
258     SettingsList settingsList;
259
260     DPL::OptionalInt width;
261     DPL::OptionalInt height;
262
263     DPL::OptionalString widget_id;
264     DPL::OptionalString defaultlocale;
265
266     PreferencesList preferencesList;
267
268     DPL::OptionalString version;
269     StringsList windowModes;
270
271     AccessInfoSet accessInfoSet;
272
273     bool flashNeeded;
274
275     DPL::OptionalString minVersionRequired;
276
277     bool backSupported;
278     bool accessNetwork;
279
280     // Unlocalized data, to be processed by WidgetConfigurationManager
281     bool startFileEncountered;
282     DPL::OptionalString startFile;
283     DPL::OptionalString startFileEncoding;
284     DPL::OptionalString startFileContentType;
285     IconsList iconsList;
286
287     // tizen id / required platform min version for TIZEN webapp
288     DPL::OptionalString tizenMinVersionRequired;
289     DPL::OptionalString tizenPkgId;
290     DPL::OptionalString tizenAppId;
291
292     //csp polic for widget
293     DPL::OptionalString cspPolicy;
294     DPL::OptionalString cspPolicyReportOnly;
295
296     //AppControl model list
297     AppControlInfoList appControlList;
298
299     // For link shared directory
300     DependsPkgList dependsPkgList;
301     // Splash image path
302     DPL::OptionalString splashImgSrc;
303     // Background page filename
304     DPL::OptionalString backgroundPage;
305     // For category
306     CategoryList categoryList;
307     // For Account
308     AccountProvider accountProvider;
309
310     ConfigParserData() :
311         flashNeeded(false),
312         minVersionRequired(),
313         backSupported(false),
314         accessNetwork(false),
315         startFileEncountered(false)
316     {}
317 };
318 } // namespace WrtDB
319
320 #endif  //CONFIG_PARSER_DATA_H_