2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @author Mariusz Domanski (m.domanski@samsung.com)
21 #ifndef INSTALLER_JOBS_MANIFEST_H
22 #define INSTALLER_JOBS_MANIFEST_H
26 #include <libxml/encoding.h>
27 #include <libxml/xmlwriter.h>
29 #include <dpl/string.h>
30 #include <dpl/optional_typedefs.h>
31 #include <dpl/foreach.h>
34 namespace WidgetInstall {
36 * @brief string with optional language attribute
42 StringWithLang(DPL::String s) : string(s) { }
43 StringWithLang(DPL::String s, DPL::String l) : string(s), lang(l) { }
44 DPL::String getString()
54 return !this->lang.empty();
62 typedef StringWithLang LabelType, IconType, DescriptionType;
65 * These types are basicaly strings but they should allow usage of different
66 * range of characters or words (details in XML spec.).
67 * For simplicity DPL::Strings are used, although this can lead to XML
69 * errors (related to usage of not allowed characters in given places).
71 typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
72 typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
73 typedef DPL::OptionalString InstallLocationType, CategoriesType;
74 typedef DPL::String AppCategoryType;
79 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
80 void writeText(xmlTextWriterPtr writer, DPL::String text);
81 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
82 void writeElementWithOneAttribute(xmlTextWriterPtr writer,
85 const char * nameAttr,
87 bool condition = true);
88 void startElement(xmlTextWriterPtr writer, const char * name);
89 void endElement(xmlTextWriterPtr writer);
90 void writeAttribute(xmlTextWriterPtr writer, const char * name,
91 DPL::String body, bool condition);
92 void writeAttribute(xmlTextWriterPtr writer, const char * name,
93 const char * body, bool condition);
96 * @brief author element
102 Author(AnySimpleType e,
106 email(e), href(h), lang(l), body(b) {}
107 void serialize(xmlTextWriterPtr writer);
116 typedef Author AuthorType;
119 * @brief application-service element
125 void addOperation(const OperationType &x)
127 this->operation.push_back(x);
129 void addUri(const UriType &x)
131 this->uri.push_back(x);
133 void addMime(const MimeType &x)
135 this->mime.push_back(x);
137 void serialize(xmlTextWriterPtr writer);
140 std::list<OperationType> operation; //attr name AnySimpleType
141 std::list<UriType> uri; //attr name AnySimpleType
142 std::list<MimeType> mime; //attr name AnySimpleType
145 typedef AppControl AppControlType;
148 * @brief ime-application element
154 void setAppid(const NcnameType &x)
158 void setExec(const NcnameType &x)
162 void setMultiple(bool x)
166 void setNodisplay(bool x)
170 void setType(const TypeType &x)
174 void addLabel(const LabelType &x)
176 this->label.push_back(x);
178 void addIcon(const IconType &x)
180 this->icon.push_back(x);
182 void serialize(xmlTextWriterPtr writer);
187 DPL::OptionalBool multiple;
188 DPL::OptionalBool nodisplay;
190 std::list<LabelType> label;
191 std::list<IconType> icon;
194 typedef ImeApplication ImeApplicationType;
197 * @brief service-application element
199 class ServiceApplication
202 ServiceApplication() {}
203 void setAppid(const NcnameType &x)
207 void setAutoRestart(bool x)
209 this->autoRestart = x;
211 void setExec(const AnySimpleType &x)
215 void setOnBoot(bool x)
219 void setType(const TypeType &x)
223 void addLabel(const LabelType &x)
225 this->label.push_back(x);
227 void addIcon(const IconType &x)
229 this->icon.push_back(x);
231 void addAppControl(const AppControlType &x)
233 this->appControl.push_back(x);
235 void serialize(xmlTextWriterPtr writer);
239 DPL::OptionalBool autoRestart;
241 DPL::OptionalBool onBoot;
243 std::list<LabelType> label; //attr name AnySimpleType
244 std::list<IconType> icon; //attr name AnySimpleType
245 std::list<AppControlType> appControl; //attr name AnySimpleType
248 typedef ServiceApplication ServiceApplicationType;
251 * @brief ui-application element
257 void setAppid(const NcnameType &x)
261 void setExtraid(const NcnameType &x)
265 void setExec(const AnySimpleType &x)
269 void setMultiple(bool x)
273 void setNodisplay(bool x)
277 void setTaskmanage(bool x)
279 this->taskmanage = x;
281 void setType(const TypeType &x)
285 void setCategories(const NcnameType &x)
287 this->categories = x;
289 void addLabel(const LabelType &x)
291 this->label.push_back(x);
293 void addIcon(const IconType &x)
295 this->icon.push_back(x);
297 void addAppControl(const AppControlType &x)
299 this->appControl.push_back(x);
301 void addAppCategory(const AppCategoryType &x)
303 this->appCategory.push_back(x);
305 void serialize(xmlTextWriterPtr writer);
311 DPL::OptionalBool multiple;
312 DPL::OptionalBool nodisplay;
313 DPL::OptionalBool taskmanage;
315 CategoriesType categories;
316 std::list<LabelType> label;
317 std::list<IconType> icon;
318 std::list<AppControlType> appControl;
319 std::list<AppCategoryType> appCategory;
322 typedef UiApplication UiApplicationType;
325 * @brief LiveBox element
327 typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
332 NcnameType boxMouseEvent;
333 NcnameType boxTouchEffect;
339 typedef BoxInfo BoxInfoType;
345 void setLiveboxId(const NcnameType &x)
349 void setPrimary(const NcnameType &x)
353 void setAutoLaunch(const NcnameType &x)
355 this->autoLaunch = x;
357 void setUpdatePeriod(const NcnameType &x)
359 this->updatePeriod = x;
361 void setLabel(const NcnameType &x)
365 void setIcon(const NcnameType &x)
369 void setBox(const BoxInfoType &x)
374 void serialize(xmlTextWriterPtr writer);
377 NcnameType liveboxId;
379 NcnameType autoLaunch;
380 NcnameType updatePeriod;
387 typedef LiveBox LiveBoxInfo;
390 * @brief manifest element
392 * Manifest xml file representation.
398 void serialize(xmlTextWriterPtr writer);
399 void generate(DPL::String filename);
401 void addLabel(const LabelType &x)
403 this->label.push_back(x);
405 void addIcon(const IconType &x)
407 this->icon.push_back(x);
409 void addAuthor(const AuthorType &x)
411 this->author.push_back(x);
413 void addDescription(const DescriptionType &x)
415 this->description.push_back(x);
417 // void addCompatibility(const CompatibilityType &x)
419 // this->compatibility.push_back(x);
421 // void addDeviceProfile(const DeviceProfileType &x)
423 // this->deviceProfile.push_back(x);
425 void addServiceApplication(const ServiceApplicationType &x)
427 this->serviceApplication.push_back(x);
429 void addUiApplication(const UiApplicationType &x)
431 this->uiApplication.push_back(x);
433 void addImeApplication(const ImeApplicationType &x)
435 this->imeApplication.push_back(x);
437 // void addFont(const FontType &x) { this->font.push_back(x); }
439 void addLivebox(const LiveBoxInfo &x)
441 this->livebox.push_back(x);
444 void setInstallLocation(const InstallLocationType &x)
446 this->installLocation = x;
448 void setPackage(const NcnameType &x)
452 void setType(const PackageType &x)
456 void setVersion(const NmtokenType &x)
462 std::list<LabelType> label;
463 std::list<IconType> icon;
464 std::list<AuthorType> author;
465 std::list<DescriptionType> description;
466 // std::list<CompatibilityType> compatibility;
467 // std::list<DeviceProfileType> deviceProfile;
468 std::list<ServiceApplicationType> serviceApplication;
469 std::list<UiApplicationType> uiApplication;
470 std::list<ImeApplicationType> imeApplication;
471 // std::list<FontType> font;
472 std::list<LiveBoxInfo> livebox;
473 InstallLocationType installLocation;
479 } //namespace WidgetInstall
481 #endif //INSTALLER_JOBS_MANIFEST_H