Add mouse-event of <tizen:box-content> and type of <tizen:livebox>
[framework/web/wrt-installer.git] / src / jobs / widget_install / manifest.h
1 /*
2  * Copyright (c) 2012 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    manifest.h
18  * @author  Mariusz Domanski (m.domanski@samsung.com)
19  */
20
21 #ifndef INSTALLER_JOBS_MANIFEST_H
22 #define INSTALLER_JOBS_MANIFEST_H
23
24 #include <list>
25
26 #include <libxml/encoding.h>
27 #include <libxml/xmlwriter.h>
28
29 #include <dpl/string.h>
30 #include <dpl/optional_typedefs.h>
31 #include <dpl/foreach.h>
32
33 namespace Jobs {
34 namespace WidgetInstall {
35
36 /**
37  * @brief string with optional language attribute
38  */
39 class StringWithLang
40 {
41 public:
42     StringWithLang() { }
43     StringWithLang(DPL::String s): string(s) { }
44     StringWithLang(DPL::String s, DPL::String l): string(s), lang(l) { }
45     DPL::String getString() { return this->string; }
46     DPL::String getLang() { return this->lang; }
47     bool hasLang() { return !this->lang.empty(); }
48 private:
49     DPL::String string;
50     DPL::String lang;
51 };
52
53 typedef StringWithLang LabelType, IconType, DescriptionType;
54
55 /**
56  * These types are basicaly strings but they should allow usage of different
57  * range of characters or words (details in XML spec.).
58  * For simplicity DPL::Strings are used, although this can lead to XML validation
59  * errors (related to usage of not allowed characters in given places).
60  */
61 typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
62 typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
63 typedef DPL::OptionalString InstallLocationType, CategoriesType;
64 typedef DPL::String AppCategoryType;
65
66 /**
67  * xmllib2 wrappers
68  */
69 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
70 void writeText(xmlTextWriterPtr writer, DPL::String text);
71 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
72 void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
73         const char * body, const char * nameAttr, DPL::String bodyAttr,
74         bool condition = true);
75 void startElement(xmlTextWriterPtr writer, const char * name);
76 void endElement(xmlTextWriterPtr writer);
77 void writeAttribute(xmlTextWriterPtr writer, const char * name,
78         DPL::String body, bool condition);
79 void writeAttribute(xmlTextWriterPtr writer, const char * name,
80         const char * body, bool condition);
81
82 /**
83  * @brief author element
84  */
85 class Author
86 {
87 public:
88     Author() {}
89     Author(AnySimpleType e,
90             NcnameType h,
91             LangType l,
92             DPL::String b)
93         : email(e), href(h), lang(l), body(b) {}
94     void serialize(xmlTextWriterPtr writer);
95 private:
96     AnySimpleType email;
97     NcnameType href;
98     LangType lang;
99     DPL::String body;
100 };
101
102 typedef Author AuthorType;
103
104 /**
105  * @brief application-service element
106  */
107 class AppControl
108 {
109 public:
110     AppControl() {}
111     void addOperation(const OperationType &x) { this->operation.push_back(x); }
112     void addUri(const UriType &x) { this->uri.push_back(x); }
113     void addMime(const MimeType &x) { this->mime.push_back(x); }
114     void serialize(xmlTextWriterPtr writer);
115 private:
116     std::list<OperationType> operation; //attr name AnySimpleType
117     std::list<UriType> uri; //attr name AnySimpleType
118     std::list<MimeType> mime; //attr name AnySimpleType
119 };
120
121 typedef AppControl AppControlType;
122
123 /**
124  * @brief ime-application element
125  */
126 class ImeApplication
127 {
128 public:
129     ImeApplication() {}
130     void setAppid(const NcnameType &x) { this->appid = x; }
131     void setExec(const NcnameType &x) { this->exec = x; }
132     void setMultiple(bool x) { this->multiple = x; }
133     void setNodisplay(bool x) { this->nodisplay = x; }
134     void setType(const TypeType &x) { this->type = x; }
135     void addLabel(const LabelType &x) { this->label.push_back(x); }
136     void addIcon(const IconType &x) { this->icon.push_back(x); }
137     void serialize(xmlTextWriterPtr writer);
138 private:
139     NcnameType appid;
140     NcnameType exec;
141     DPL::OptionalBool multiple;
142     DPL::OptionalBool nodisplay;
143     TypeType type;
144     std::list<LabelType> label;
145     std::list<IconType> icon;
146 };
147
148 typedef ImeApplication ImeApplicationType;
149
150 /**
151  * @brief service-application element
152  */
153 class ServiceApplication
154 {
155 public:
156     ServiceApplication() {}
157     void setAppid(const NcnameType &x) { this->appid = x; }
158     void setAutoRestart(bool x) { this->autoRestart = x; }
159     void setExec(const AnySimpleType &x) { this->exec = x; }
160     void setOnBoot(bool x) { this->onBoot = x; }
161     void setType(const TypeType &x) { this->type = x; }
162     void addLabel(const LabelType &x) { this->label.push_back(x); }
163     void addIcon(const IconType &x) { this->icon.push_back(x); }
164     void addAppControl(const AppControlType &x)
165     {
166         this->appControl.push_back(x);
167     }
168     void serialize(xmlTextWriterPtr writer);
169 private:
170     NcnameType appid;
171     DPL::OptionalBool autoRestart;
172     AnySimpleType exec;
173     DPL::OptionalBool onBoot;
174     TypeType type;
175     std::list<LabelType> label; //attr name AnySimpleType
176     std::list<IconType> icon; //attr name AnySimpleType
177     std::list<AppControlType> appControl; //attr name AnySimpleType
178 };
179
180 typedef ServiceApplication ServiceApplicationType;
181
182 /**
183  * @brief ui-application element
184  */
185 class UiApplication
186 {
187 public:
188     UiApplication() {}
189     void setAppid(const NcnameType &x) { this->appid = x; }
190     void setExtraid(const NcnameType &x) { this->extraid = x; }
191     void setExec(const AnySimpleType &x) { this->exec = x; }
192     void setMultiple(bool x) { this->multiple = x; }
193     void setNodisplay(bool x) { this->nodisplay = x; }
194     void setTaskmanage(bool x) { this->taskmanage = x; }
195     void setType(const TypeType &x) { this->type = x; }
196     void setCategories(const NcnameType &x) { this->categories = x; }
197     void addLabel(const LabelType &x) { this->label.push_back(x); }
198     void addIcon(const IconType &x) { this->icon.push_back(x); }
199     void addAppControl(const AppControlType &x)
200     {
201         this->appControl.push_back(x);
202     }
203     void addAppCategory(const AppCategoryType &x)
204     {
205         this->appCategory.push_back(x);
206     }
207     void serialize(xmlTextWriterPtr writer);
208 private:
209     NcnameType appid;
210     NcnameType extraid;
211     AnySimpleType exec;
212     DPL::OptionalBool multiple;
213     DPL::OptionalBool nodisplay;
214     DPL::OptionalBool taskmanage;
215     TypeType type;
216     CategoriesType categories;
217     std::list<LabelType> label;
218     std::list<IconType> icon;
219     std::list<AppControlType> appControl;
220     std::list<AppCategoryType> appCategory;
221 };
222
223 typedef UiApplication UiApplicationType;
224
225 /**
226  * @brief LiveBox element
227  */
228 typedef std::list<std::pair<DPL::String, DPL::String>> boxSizeType;
229
230
231 struct BoxInfo
232 {
233     NcnameType boxSrc;
234     NcnameType boxMouseEvent;
235     boxSizeType boxSize;
236     NcnameType pdSrc;
237     NcnameType pdWidth;
238     NcnameType pdHeight;
239 };
240 typedef BoxInfo BoxInfoType;
241
242 class LiveBox
243 {
244 public:
245     LiveBox() { }
246     void setLiveboxId(const NcnameType &x) { this->liveboxId = x; }
247     void setPrimary(const NcnameType &x) { this->primary = x; }
248     void setAutoLaunch(const NcnameType &x) { this->autoLaunch = x; }
249     void setUpdatePeriod(const NcnameType &x) { this->updatePeriod = x; }
250     void setLabel(const NcnameType &x) { this->label = x; }
251     void setIcon(const NcnameType &x) { this->icon = x; }
252     void setBox(const BoxInfoType &x) { this->box = x; }
253
254     void serialize(xmlTextWriterPtr writer);
255
256 private:
257     NcnameType liveboxId;
258     NcnameType primary;
259     NcnameType autoLaunch;
260     NcnameType updatePeriod;
261     NcnameType timeout;
262     NcnameType label;
263     NcnameType icon;
264     BoxInfoType box;
265 };
266
267 typedef LiveBox LiveBoxInfo;
268
269 /**
270  * @brief manifest element
271  *
272  * Manifest xml file representation.
273  */
274 class Manifest
275 {
276 public:
277     Manifest() {}
278     void serialize(xmlTextWriterPtr writer);
279     void generate(DPL::String filename);
280
281     void addLabel(const LabelType &x) { this->label.push_back(x); }
282     void addIcon(const IconType &x) { this->icon.push_back(x); }
283     void addAuthor(const AuthorType &x) { this->author.push_back(x); };
284     void addDescription(const DescriptionType &x)
285     {
286         this->description.push_back(x);
287     }
288 //    void addCompatibility(const CompatibilityType &x)
289 //    {
290 //        this->compatibility.push_back(x);
291 //    }
292 //    void addDeviceProfile(const DeviceProfileType &x)
293 //    {
294 //        this->deviceProfile.push_back(x);
295 //    }
296     void addServiceApplication(const ServiceApplicationType &x)
297     {
298         this->serviceApplication.push_back(x);
299     }
300     void addUiApplication(const UiApplicationType &x)
301     {
302         this->uiApplication.push_back(x);
303     }
304     void addImeApplication(const ImeApplicationType &x)
305     {
306         this->imeApplication.push_back(x);
307     }
308 //    void addFont(const FontType &x) { this->font.push_back(x); }
309
310     void addLivebox(const LiveBoxInfo &x)
311     {
312         this->livebox.push_back(x);
313     }
314
315     void setInstallLocation(const InstallLocationType &x)
316     {
317         this->installLocation = x;
318     }
319     void setPackage(const NcnameType &x) { this->package = x; }
320     void setType(const PackageType &x) { this->type = x; }
321     void setVersion(const NmtokenType &x) { this->version = x; }
322 private:
323     std::list<LabelType> label;
324     std::list<IconType> icon;
325     std::list<AuthorType> author;
326     std::list<DescriptionType> description;
327 //    std::list<CompatibilityType> compatibility;
328 //    std::list<DeviceProfileType> deviceProfile;
329     std::list<ServiceApplicationType> serviceApplication;
330     std::list<UiApplicationType> uiApplication;
331     std::list<ImeApplicationType> imeApplication;
332 //    std::list<FontType> font;
333     std::list<LiveBoxInfo> livebox;
334     InstallLocationType installLocation;
335     NcnameType package;
336     PackageType type;
337     NmtokenType version;
338 };
339
340 } //namespace Jobs
341 } //namespace WidgetInstall
342
343 #endif //INSTALLER_JOBS_MANIFEST_H