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();
56 int operator==(const StringWithLang &other)
58 return (DPL::ToUTF8String(other.string) == DPL::ToUTF8String(string)) &&
59 (DPL::ToUTF8String(other.lang) == DPL::ToUTF8String(lang));
67 typedef StringWithLang LabelType, IconType, DescriptionType;
70 * These types are basicaly strings but they should allow usage of different
71 * range of characters or words (details in XML spec.).
72 * For simplicity DPL::Strings are used, although this can lead to XML
74 * errors (related to usage of not allowed characters in given places).
76 typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
77 typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
78 typedef DPL::OptionalString InstallLocationType, CategoriesType;
79 typedef DPL::String AppCategoryType;
80 typedef DPL::String KeyType, ValueType;
85 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
86 void writeText(xmlTextWriterPtr writer, DPL::String text);
87 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
88 void writeElementWithOneAttribute(xmlTextWriterPtr writer,
91 const char * nameAttr,
93 bool condition = true);
94 void startElement(xmlTextWriterPtr writer, const char * name);
95 void endElement(xmlTextWriterPtr writer);
96 void writeAttribute(xmlTextWriterPtr writer, const char * name,
97 DPL::String body, bool condition);
98 void writeAttribute(xmlTextWriterPtr writer, const char * name,
99 const char * body, bool condition);
102 * @brief author element
108 Author(AnySimpleType e,
112 email(e), href(h), lang(l), body(b) {}
113 void serialize(xmlTextWriterPtr writer);
122 typedef Author AuthorType;
125 * @brief application-service element
131 void addOperation(const OperationType &x)
133 this->operation.push_back(x);
135 void addUri(const UriType &x)
137 this->uri.push_back(x);
139 void addMime(const MimeType &x)
141 this->mime.push_back(x);
143 void serialize(xmlTextWriterPtr writer);
146 std::list<OperationType> operation; //attr name AnySimpleType
147 std::list<UriType> uri; //attr name AnySimpleType
148 std::list<MimeType> mime; //attr name AnySimpleType
151 typedef AppControl AppControlType;
154 * @brief account element
156 typedef std::list<std::pair<DPL::String, DPL::String>> IconListType;
157 typedef std::list<LabelType> DisplayNameListType;
158 typedef std::list<DPL::String> AccountCapabilityType;
160 struct AccountProvider
163 NcnameType multiAccount;
165 DisplayNameListType name;
166 AccountCapabilityType capability;
169 typedef AccountProvider AccountProviderType;
175 void addAccountProvider(const AccountProvider &x)
179 void serialize(xmlTextWriterPtr writer);
182 AccountProviderType provider;
189 void addPrivilegeName(const DPL::String &x)
191 this->name.push_back(x);
195 return this->name.empty();
198 void serialize(xmlTextWriterPtr writer);
201 std::list<DPL::String> name;
204 typedef Privilege PrivilegeType;
209 Metadata(KeyType k, ValueType v) :
213 void serialize(xmlTextWriterPtr writer);
220 typedef Metadata MetadataType;
224 * @brief ime-application element
230 void setAppid(const NcnameType &x)
234 void setExec(const NcnameType &x)
238 void setMultiple(bool x)
242 void setNodisplay(bool x)
246 void setType(const TypeType &x)
250 void addLabel(const LabelType &x)
252 this->label.push_back(x);
254 void addIcon(const IconType &x)
256 this->icon.push_back(x);
258 void serialize(xmlTextWriterPtr writer);
263 DPL::OptionalBool multiple;
264 DPL::OptionalBool nodisplay;
266 std::list<LabelType> label;
267 std::list<IconType> icon;
270 typedef ImeApplication ImeApplicationType;
273 * @brief service-application element
275 class ServiceApplication
278 ServiceApplication() {}
279 void setAppid(const NcnameType &x)
283 void setAutoRestart(bool x)
285 this->autoRestart = x;
287 void setExec(const AnySimpleType &x)
291 void setOnBoot(bool x)
295 void setType(const TypeType &x)
299 void addLabel(const LabelType &x)
301 this->label.push_back(x);
303 void addIcon(const IconType &x)
305 this->icon.push_back(x);
307 void addAppControl(const AppControlType &x)
309 this->appControl.push_back(x);
311 void serialize(xmlTextWriterPtr writer);
315 DPL::OptionalBool autoRestart;
317 DPL::OptionalBool onBoot;
319 std::list<LabelType> label; //attr name AnySimpleType
320 std::list<IconType> icon; //attr name AnySimpleType
321 std::list<AppControlType> appControl; //attr name AnySimpleType
324 typedef ServiceApplication ServiceApplicationType;
327 * @brief ui-application element
333 void setAppid(const NcnameType &x)
337 void setExtraid(const NcnameType &x)
341 void setExec(const AnySimpleType &x)
345 void setMultiple(bool x)
349 void setNodisplay(bool x)
353 void setTaskmanage(bool x)
355 this->taskmanage = x;
357 void setType(const TypeType &x)
361 void setCategories(const NcnameType &x)
363 this->categories = x;
365 void addLabel(const LabelType &x)
367 this->label.push_back(x);
369 void addIcon(const IconType &x)
371 this->icon.push_back(x);
373 void addAppControl(const AppControlType &x)
375 this->appControl.push_back(x);
377 void addAppCategory(const AppCategoryType &x)
379 this->appCategory.push_back(x);
381 void addMetadata(const MetadataType &m)
383 this->metadata.push_back(m);
385 void serialize(xmlTextWriterPtr writer);
391 DPL::OptionalBool multiple;
392 DPL::OptionalBool nodisplay;
393 DPL::OptionalBool taskmanage;
395 CategoriesType categories;
396 std::list<LabelType> label;
397 std::list<IconType> icon;
398 std::list<AppControlType> appControl;
399 std::list<AppCategoryType> appCategory;
400 std::list<MetadataType> metadata;
403 typedef UiApplication UiApplicationType;
406 * @brief LiveBox element
408 typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
413 NcnameType boxMouseEvent;
414 NcnameType boxTouchEffect;
420 typedef BoxInfo BoxInfoType;
426 void setLiveboxId(const NcnameType &x)
430 void setPrimary(const NcnameType &x)
434 void setUpdatePeriod(const NcnameType &x)
436 this->updatePeriod = x;
438 void setLabel(const NcnameType &x)
442 void setIcon(const NcnameType &x)
446 void setBox(const BoxInfoType &x)
451 void serialize(xmlTextWriterPtr writer);
454 NcnameType liveboxId;
456 NcnameType autoLaunch;
457 NcnameType updatePeriod;
464 typedef LiveBox LiveBoxInfo;
467 * @brief manifest element
469 * Manifest xml file representation.
475 void serialize(xmlTextWriterPtr writer);
476 void generate(DPL::String filename);
478 void addLabel(const LabelType &x)
480 #ifdef MULTIPROCESS_SERVICE_SUPPORT
481 auto pos = std::find(label.begin(), label.end(), x);
482 if (pos == label.end()) {
483 this->label.push_back(x);
486 this->label.push_back(x);
489 void addIcon(const IconType &x)
491 this->icon.push_back(x);
493 void addAuthor(const AuthorType &x)
495 this->author.push_back(x);
497 void addDescription(const DescriptionType &x)
499 this->description.push_back(x);
501 // void addCompatibility(const CompatibilityType &x)
503 // this->compatibility.push_back(x);
505 // void addDeviceProfile(const DeviceProfileType &x)
507 // this->deviceProfile.push_back(x);
509 void addServiceApplication(const ServiceApplicationType &x)
511 this->serviceApplication.push_back(x);
513 void addUiApplication(const UiApplicationType &x)
515 this->uiApplication.push_back(x);
517 void addImeApplication(const ImeApplicationType &x)
519 this->imeApplication.push_back(x);
521 // void addFont(const FontType &x) { this->font.push_back(x); }
523 void addLivebox(const LiveBoxInfo &x)
525 this->livebox.push_back(x);
528 void addAccount(const Account &x)
530 this->account.push_back(x);
533 void addPrivileges(const PrivilegeType &x)
535 this->privileges = x;
538 void setInstallLocation(const InstallLocationType &x)
540 this->installLocation = x;
542 void setPackage(const NcnameType &x)
546 void setType(const PackageType &x)
550 void setVersion(const NmtokenType &x)
556 std::list<LabelType> label;
557 std::list<IconType> icon;
558 std::list<AuthorType> author;
559 std::list<DescriptionType> description;
560 // std::list<CompatibilityType> compatibility;
561 // std::list<DeviceProfileType> deviceProfile;
562 std::list<ServiceApplicationType> serviceApplication;
563 std::list<UiApplicationType> uiApplication;
564 std::list<ImeApplicationType> imeApplication;
565 // std::list<FontType> font;
566 std::list<LiveBoxInfo> livebox;
567 InstallLocationType installLocation;
571 std::list<Account> account;
572 PrivilegeType privileges;
576 } //namespace WidgetInstall
578 #endif //INSTALLER_JOBS_MANIFEST_H