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 account element
150 typedef std::list<std::pair<DPL::String, DPL::String>> IconListType;
151 typedef std::list<LabelType> DisplayNameListType;
152 typedef std::list<DPL::String> AccountCapabilityType;
154 struct AccountProvider
157 NcnameType multiAccount;
159 DisplayNameListType name;
160 AccountCapabilityType capability;
163 typedef AccountProvider AccountProviderType;
169 void addAccountProvider(const AccountProvider &x)
173 void serialize(xmlTextWriterPtr writer);
176 AccountProviderType provider;
180 * @brief ime-application element
186 void setAppid(const NcnameType &x)
190 void setExec(const NcnameType &x)
194 void setMultiple(bool x)
198 void setNodisplay(bool x)
202 void setType(const TypeType &x)
206 void addLabel(const LabelType &x)
208 this->label.push_back(x);
210 void addIcon(const IconType &x)
212 this->icon.push_back(x);
214 void serialize(xmlTextWriterPtr writer);
219 DPL::OptionalBool multiple;
220 DPL::OptionalBool nodisplay;
222 std::list<LabelType> label;
223 std::list<IconType> icon;
226 typedef ImeApplication ImeApplicationType;
229 * @brief service-application element
231 class ServiceApplication
234 ServiceApplication() {}
235 void setAppid(const NcnameType &x)
239 void setAutoRestart(bool x)
241 this->autoRestart = x;
243 void setExec(const AnySimpleType &x)
247 void setOnBoot(bool x)
251 void setType(const TypeType &x)
255 void addLabel(const LabelType &x)
257 this->label.push_back(x);
259 void addIcon(const IconType &x)
261 this->icon.push_back(x);
263 void addAppControl(const AppControlType &x)
265 this->appControl.push_back(x);
267 void serialize(xmlTextWriterPtr writer);
271 DPL::OptionalBool autoRestart;
273 DPL::OptionalBool onBoot;
275 std::list<LabelType> label; //attr name AnySimpleType
276 std::list<IconType> icon; //attr name AnySimpleType
277 std::list<AppControlType> appControl; //attr name AnySimpleType
280 typedef ServiceApplication ServiceApplicationType;
283 * @brief ui-application element
289 void setAppid(const NcnameType &x)
293 void setExtraid(const NcnameType &x)
297 void setExec(const AnySimpleType &x)
301 void setMultiple(bool x)
305 void setNodisplay(bool x)
309 void setTaskmanage(bool x)
311 this->taskmanage = x;
313 void setType(const TypeType &x)
317 void setCategories(const NcnameType &x)
319 this->categories = x;
321 void addLabel(const LabelType &x)
323 this->label.push_back(x);
325 void addIcon(const IconType &x)
327 this->icon.push_back(x);
329 void addAppControl(const AppControlType &x)
331 this->appControl.push_back(x);
333 void addAppCategory(const AppCategoryType &x)
335 this->appCategory.push_back(x);
337 void serialize(xmlTextWriterPtr writer);
343 DPL::OptionalBool multiple;
344 DPL::OptionalBool nodisplay;
345 DPL::OptionalBool taskmanage;
347 CategoriesType categories;
348 std::list<LabelType> label;
349 std::list<IconType> icon;
350 std::list<AppControlType> appControl;
351 std::list<AppCategoryType> appCategory;
354 typedef UiApplication UiApplicationType;
357 * @brief LiveBox element
359 typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
364 NcnameType boxMouseEvent;
365 NcnameType boxTouchEffect;
371 typedef BoxInfo BoxInfoType;
377 void setLiveboxId(const NcnameType &x)
381 void setPrimary(const NcnameType &x)
385 void setAutoLaunch(const NcnameType &x)
387 this->autoLaunch = x;
389 void setUpdatePeriod(const NcnameType &x)
391 this->updatePeriod = x;
393 void setLabel(const NcnameType &x)
397 void setIcon(const NcnameType &x)
401 void setBox(const BoxInfoType &x)
406 void serialize(xmlTextWriterPtr writer);
409 NcnameType liveboxId;
411 NcnameType autoLaunch;
412 NcnameType updatePeriod;
419 typedef LiveBox LiveBoxInfo;
422 * @brief manifest element
424 * Manifest xml file representation.
430 void serialize(xmlTextWriterPtr writer);
431 void generate(DPL::String filename);
433 void addLabel(const LabelType &x)
435 this->label.push_back(x);
437 void addIcon(const IconType &x)
439 this->icon.push_back(x);
441 void addAuthor(const AuthorType &x)
443 this->author.push_back(x);
445 void addDescription(const DescriptionType &x)
447 this->description.push_back(x);
449 // void addCompatibility(const CompatibilityType &x)
451 // this->compatibility.push_back(x);
453 // void addDeviceProfile(const DeviceProfileType &x)
455 // this->deviceProfile.push_back(x);
457 void addServiceApplication(const ServiceApplicationType &x)
459 this->serviceApplication.push_back(x);
461 void addUiApplication(const UiApplicationType &x)
463 this->uiApplication.push_back(x);
465 void addImeApplication(const ImeApplicationType &x)
467 this->imeApplication.push_back(x);
469 // void addFont(const FontType &x) { this->font.push_back(x); }
471 void addLivebox(const LiveBoxInfo &x)
473 this->livebox.push_back(x);
476 void addAccount(const Account &x)
478 this->account.push_back(x);
481 void setInstallLocation(const InstallLocationType &x)
483 this->installLocation = x;
485 void setPackage(const NcnameType &x)
489 void setType(const PackageType &x)
493 void setVersion(const NmtokenType &x)
499 std::list<LabelType> label;
500 std::list<IconType> icon;
501 std::list<AuthorType> author;
502 std::list<DescriptionType> description;
503 // std::list<CompatibilityType> compatibility;
504 // std::list<DeviceProfileType> deviceProfile;
505 std::list<ServiceApplicationType> serviceApplication;
506 std::list<UiApplicationType> uiApplication;
507 std::list<ImeApplicationType> imeApplication;
508 // std::list<FontType> font;
509 std::list<LiveBoxInfo> livebox;
510 InstallLocationType installLocation;
514 std::list<Account> account;
517 } //namespace WidgetInstall
519 #endif //INSTALLER_JOBS_MANIFEST_H