tizen beta 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 Icon
81     {
82         Icon(const DPL::String& src) : src(src)
83         {
84         }
85         DPL::String src;
86         DPL::OptionalInt width;
87         DPL::OptionalInt height;
88         bool operator==(const Icon&) const;
89         bool operator!=(const Icon&) const;
90         bool operator >(const Icon&) const;
91         bool operator>=(const Icon&) const;
92         bool operator <(const Icon&) const;
93         bool operator<=(const Icon&) const;
94     };
95     typedef std::list<Icon> IconsList;
96
97     struct LocalizedData
98     {
99         DPL::OptionalString name;
100         DPL::OptionalString shortName;
101
102         DPL::OptionalString description;
103
104         DPL::OptionalString license;
105         DPL::OptionalString licenseFile;
106         DPL::OptionalString licenseHref;
107     };
108     typedef std::map<DPL::String, LocalizedData> LocalizedDataSet;
109
110     struct Preference
111     {
112         Preference(const DPL::String& name,
113                 bool readonly = false) :
114             name(name),
115             value(),
116             readonly(readonly)
117         {
118         }
119         DPL::String name;
120         DPL::OptionalString value;
121         bool readonly;
122         bool operator==(const Preference&) const;
123         bool operator!=(const Preference&) const;
124         bool operator >(const Preference&) const;
125         bool operator>=(const Preference&) const;
126         bool operator <(const Preference&) const;
127         bool operator<=(const Preference&) const;
128     };
129     typedef std::set<Preference> PreferencesList;
130     typedef std::set<DPL::String> StringsList;
131
132     struct AccessInfo
133     {
134         AccessInfo(const DPL::String& strIRI,
135                 bool bSubdomainAccess) : m_strIRI(strIRI),
136             m_bSubDomainAccess(bSubdomainAccess)
137         {
138         }
139
140         bool operator==(const AccessInfo&) const;
141         bool operator!=(const AccessInfo&) const;
142         bool operator <(const AccessInfo&) const;
143
144         DPL::String m_strIRI;
145         bool m_bSubDomainAccess;
146     };
147     typedef std::set<AccessInfo> AccessInfoSet;
148
149     struct Setting
150     {
151         Setting(const DPL::String& name,
152                 const DPL::String& value) :
153                 m_name(name),
154                 m_value(value)
155         {
156         }
157         DPL::String m_name;
158         DPL::String m_value;
159
160         bool operator==(const Setting&) const;
161         bool operator!=(const Setting&) const;
162         bool operator >(const Setting&) const;
163         bool operator>=(const Setting&) const;
164         bool operator <(const Setting&) const;
165         bool operator<=(const Setting&) const;
166     };
167
168     typedef std::set<Setting> SettingsList;
169
170     struct ServiceInfo
171     {
172         ServiceInfo(
173             const DPL::String& src,
174             const DPL::String& operation,
175             const DPL::String& scheme,
176             const DPL::String& mime) :
177             m_src(src),
178             m_operation(operation),
179             m_scheme(scheme),
180             m_mime(mime)
181         {
182         }
183         DPL::String m_src;
184         DPL::String m_operation;
185         DPL::String m_scheme;
186         DPL::String m_mime;
187
188         bool operator==(const ServiceInfo&) const;
189         bool operator!=(const ServiceInfo&) const;
190     };
191     typedef std::list<ServiceInfo> ServiceInfoList;
192
193     StringsList nameSpaces;
194
195     LocalizedDataSet localizedDataSet;
196
197     DPL::OptionalString authorName;
198     DPL::OptionalString authorHref;
199     DPL::OptionalString authorEmail;
200
201     FeaturesList featuresList;
202
203     SettingsList settingsList;
204
205     DPL::OptionalInt width;
206     DPL::OptionalInt height;
207
208     DPL::OptionalString widget_id;
209     DPL::OptionalString defaultlocale;
210
211     PreferencesList preferencesList;
212
213     DPL::OptionalString version;
214     StringsList windowModes;
215
216     AccessInfoSet accessInfoSet;
217
218     bool flashNeeded;
219
220     DPL::OptionalFloat minVersionRequired;
221     DPL::OptionalInt minVersionRequiredFound;
222     StringsList powderDescriptionLinks;
223
224     bool backSupported;
225     bool accessNetwork;
226
227     // Unlocalized data, to be processed by WidgetConfigurationManager
228     bool startFileEncountered;
229     DPL::OptionalString startFile;
230     DPL::OptionalString startFileEncoding;
231     DPL::OptionalString startFileContentType;
232     IconsList iconsList;
233
234     // pakcage name determined by operator for TIZEN webapp
235     DPL::OptionalString pkgname;
236     //Application service model list
237     ServiceInfoList appServiceList;
238
239     ConfigParserData() :
240         flashNeeded(false),
241         minVersionRequired(1.0),
242         minVersionRequiredFound(),
243         backSupported(false),
244         accessNetwork(false),
245         startFileEncountered(false)
246     {
247     }
248 };
249
250 } // namespace WrtDB
251
252 #endif  //CONFIG_PARSER_DATA_H_