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;
183 void addPrivilegeName(const DPL::String &x)
185 this->name.push_back(x);
189 return this->name.empty();
192 void serialize(xmlTextWriterPtr writer);
195 std::list<DPL::String> name;
198 typedef Privilege PrivilegeType;
201 * @brief ime-application element
207 void setAppid(const NcnameType &x)
211 void setExec(const NcnameType &x)
215 void setMultiple(bool x)
219 void setNodisplay(bool x)
223 void setType(const TypeType &x)
227 void addLabel(const LabelType &x)
229 this->label.push_back(x);
231 void addIcon(const IconType &x)
233 this->icon.push_back(x);
235 void serialize(xmlTextWriterPtr writer);
240 DPL::OptionalBool multiple;
241 DPL::OptionalBool nodisplay;
243 std::list<LabelType> label;
244 std::list<IconType> icon;
247 typedef ImeApplication ImeApplicationType;
250 * @brief service-application element
252 class ServiceApplication
255 ServiceApplication() {}
256 void setAppid(const NcnameType &x)
260 void setAutoRestart(bool x)
262 this->autoRestart = x;
264 void setExec(const AnySimpleType &x)
268 void setOnBoot(bool x)
272 void setType(const TypeType &x)
276 void addLabel(const LabelType &x)
278 this->label.push_back(x);
280 void addIcon(const IconType &x)
282 this->icon.push_back(x);
284 void addAppControl(const AppControlType &x)
286 this->appControl.push_back(x);
288 void serialize(xmlTextWriterPtr writer);
292 DPL::OptionalBool autoRestart;
294 DPL::OptionalBool onBoot;
296 std::list<LabelType> label; //attr name AnySimpleType
297 std::list<IconType> icon; //attr name AnySimpleType
298 std::list<AppControlType> appControl; //attr name AnySimpleType
301 typedef ServiceApplication ServiceApplicationType;
304 * @brief ui-application element
310 void setAppid(const NcnameType &x)
314 void setExtraid(const NcnameType &x)
318 void setExec(const AnySimpleType &x)
322 void setMultiple(bool x)
326 void setNodisplay(bool x)
330 void setTaskmanage(bool x)
332 this->taskmanage = x;
334 void setType(const TypeType &x)
338 void setCategories(const NcnameType &x)
340 this->categories = x;
342 void addLabel(const LabelType &x)
344 this->label.push_back(x);
346 void addIcon(const IconType &x)
348 this->icon.push_back(x);
350 void addAppControl(const AppControlType &x)
352 this->appControl.push_back(x);
354 void addAppCategory(const AppCategoryType &x)
356 this->appCategory.push_back(x);
358 void serialize(xmlTextWriterPtr writer);
364 DPL::OptionalBool multiple;
365 DPL::OptionalBool nodisplay;
366 DPL::OptionalBool taskmanage;
368 CategoriesType categories;
369 std::list<LabelType> label;
370 std::list<IconType> icon;
371 std::list<AppControlType> appControl;
372 std::list<AppCategoryType> appCategory;
375 typedef UiApplication UiApplicationType;
378 * @brief LiveBox element
380 typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
385 NcnameType boxMouseEvent;
386 NcnameType boxTouchEffect;
392 typedef BoxInfo BoxInfoType;
398 void setLiveboxId(const NcnameType &x)
402 void setPrimary(const NcnameType &x)
406 void setUpdatePeriod(const NcnameType &x)
408 this->updatePeriod = x;
410 void setLabel(const NcnameType &x)
414 void setIcon(const NcnameType &x)
418 void setBox(const BoxInfoType &x)
423 void serialize(xmlTextWriterPtr writer);
426 NcnameType liveboxId;
428 NcnameType autoLaunch;
429 NcnameType updatePeriod;
436 typedef LiveBox LiveBoxInfo;
439 * @brief manifest element
441 * Manifest xml file representation.
447 void serialize(xmlTextWriterPtr writer);
448 void generate(DPL::String filename);
450 void addLabel(const LabelType &x)
452 this->label.push_back(x);
454 void addIcon(const IconType &x)
456 this->icon.push_back(x);
458 void addAuthor(const AuthorType &x)
460 this->author.push_back(x);
462 void addDescription(const DescriptionType &x)
464 this->description.push_back(x);
466 // void addCompatibility(const CompatibilityType &x)
468 // this->compatibility.push_back(x);
470 // void addDeviceProfile(const DeviceProfileType &x)
472 // this->deviceProfile.push_back(x);
474 void addServiceApplication(const ServiceApplicationType &x)
476 this->serviceApplication.push_back(x);
478 void addUiApplication(const UiApplicationType &x)
480 this->uiApplication.push_back(x);
482 void addImeApplication(const ImeApplicationType &x)
484 this->imeApplication.push_back(x);
486 // void addFont(const FontType &x) { this->font.push_back(x); }
488 void addLivebox(const LiveBoxInfo &x)
490 this->livebox.push_back(x);
493 void addAccount(const Account &x)
495 this->account.push_back(x);
498 void addPrivileges(const PrivilegeType &x)
500 this->privileges = x;
503 void setInstallLocation(const InstallLocationType &x)
505 this->installLocation = x;
507 void setPackage(const NcnameType &x)
511 void setType(const PackageType &x)
515 void setVersion(const NmtokenType &x)
521 std::list<LabelType> label;
522 std::list<IconType> icon;
523 std::list<AuthorType> author;
524 std::list<DescriptionType> description;
525 // std::list<CompatibilityType> compatibility;
526 // std::list<DeviceProfileType> deviceProfile;
527 std::list<ServiceApplicationType> serviceApplication;
528 std::list<UiApplicationType> uiApplication;
529 std::list<ImeApplicationType> imeApplication;
530 // std::list<FontType> font;
531 std::list<LiveBoxInfo> livebox;
532 InstallLocationType installLocation;
536 std::list<Account> account;
537 PrivilegeType privileges;
541 } //namespace WidgetInstall
543 #endif //INSTALLER_JOBS_MANIFEST_H