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>
32 #include <dpl/wrt-dao-ro/config_parser_data.h>
35 namespace WidgetInstall {
37 * @brief string with optional language attribute
43 StringWithLang(DPL::String s) : string(s) { }
44 StringWithLang(DPL::String s, DPL::String l) : string(s), lang(l) { }
45 DPL::String getString()
55 return !this->lang.empty();
57 int operator==(const StringWithLang &other)
59 return (DPL::ToUTF8String(other.string) == DPL::ToUTF8String(string)) &&
60 (DPL::ToUTF8String(other.lang) == DPL::ToUTF8String(lang));
68 typedef StringWithLang LabelType, IconType, DescriptionType;
71 * These types are basicaly strings but they should allow usage of different
72 * range of characters or words (details in XML spec.).
73 * For simplicity DPL::Strings are used, although this can lead to XML
75 * errors (related to usage of not allowed characters in given places).
77 typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
78 typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
79 typedef DPL::OptionalString InstallLocationType, CategoriesType;
80 typedef DPL::String AppCategoryType;
81 typedef DPL::OptionalString KeyType, ValueType;
86 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
87 void writeText(xmlTextWriterPtr writer, DPL::String text);
88 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
89 void writeElementWithOneAttribute(xmlTextWriterPtr writer,
92 const char * nameAttr,
94 bool condition = true);
95 void startElement(xmlTextWriterPtr writer, const char * name);
96 void endElement(xmlTextWriterPtr writer);
97 void writeAttribute(xmlTextWriterPtr writer, const char * name,
98 DPL::String body, bool condition);
99 void writeAttribute(xmlTextWriterPtr writer, const char * name,
100 const char * body, bool condition);
103 * @brief author element
109 Author(AnySimpleType e,
113 email(e), href(h), lang(l), body(b) {}
114 void serialize(xmlTextWriterPtr writer);
123 typedef Author AuthorType;
126 * @brief application-service element
132 void addOperation(const OperationType &x)
134 this->operation.push_back(x);
136 void addUri(const UriType &x)
138 this->uri.push_back(x);
140 void addMime(const MimeType &x)
142 this->mime.push_back(x);
144 void serialize(xmlTextWriterPtr writer);
147 std::list<OperationType> operation; //attr name AnySimpleType
148 std::list<UriType> uri; //attr name AnySimpleType
149 std::list<MimeType> mime; //attr name AnySimpleType
152 typedef AppControl AppControlType;
155 * @brief account element
157 typedef std::list<std::pair<DPL::String, DPL::String>> IconListType;
158 typedef std::list<LabelType> DisplayNameListType;
159 typedef std::list<DPL::String> AccountCapabilityType;
161 struct AccountProvider
164 NcnameType multiAccount;
166 DisplayNameListType name;
167 AccountCapabilityType capability;
170 typedef AccountProvider AccountProviderType;
176 void addAccountProvider(const AccountProvider &x)
180 void serialize(xmlTextWriterPtr writer);
183 AccountProviderType provider;
190 void addPrivilegeName(const DPL::String &x)
192 this->name.push_back(x);
196 return this->name.empty();
199 void serialize(xmlTextWriterPtr writer);
202 std::list<DPL::String> name;
205 typedef Privilege PrivilegeType;
210 Metadata(KeyType k, ValueType v) :
214 void serialize(xmlTextWriterPtr writer);
221 typedef Metadata MetadataType;
225 * @brief ime-application element
231 void setAppid(const NcnameType &x)
235 void setExec(const NcnameType &x)
239 void setMultiple(bool x)
243 void setNodisplay(bool x)
247 void setType(const TypeType &x)
251 void addLabel(const LabelType &x)
253 this->label.push_back(x);
255 void addIcon(const IconType &x)
257 this->icon.push_back(x);
259 void serialize(xmlTextWriterPtr writer);
264 DPL::OptionalBool multiple;
265 DPL::OptionalBool nodisplay;
267 std::list<LabelType> label;
268 std::list<IconType> icon;
271 typedef ImeApplication ImeApplicationType;
274 * @brief service-application element
276 class ServiceApplication
279 ServiceApplication() {}
280 void setAppid(const NcnameType &x)
284 void setAutoRestart(bool x)
286 this->autoRestart = x;
288 void setExec(const AnySimpleType &x)
292 void setOnBoot(bool x)
296 void setType(const TypeType &x)
300 void addLabel(const LabelType &x)
302 this->label.push_back(x);
304 void addIcon(const IconType &x)
306 this->icon.push_back(x);
308 void addAppControl(const AppControlType &x)
310 this->appControl.push_back(x);
312 void serialize(xmlTextWriterPtr writer);
316 DPL::OptionalBool autoRestart;
318 DPL::OptionalBool onBoot;
320 std::list<LabelType> label; //attr name AnySimpleType
321 std::list<IconType> icon; //attr name AnySimpleType
322 std::list<AppControlType> appControl; //attr name AnySimpleType
325 typedef ServiceApplication ServiceApplicationType;
328 * @brief ui-application element
334 void setAppid(const NcnameType &x)
338 void setExtraid(const NcnameType &x)
342 void setExec(const AnySimpleType &x)
346 void setMultiple(bool x)
350 void setNodisplay(bool x)
354 void setTaskmanage(bool x)
356 this->taskmanage = x;
358 void setType(const TypeType &x)
362 void setCategories(const NcnameType &x)
364 this->categories = x;
366 void addLabel(const LabelType &x)
368 this->label.push_back(x);
370 void addIcon(const IconType &x)
372 this->icon.push_back(x);
374 void addAppControl(const AppControlType &x)
376 this->appControl.push_back(x);
378 void addAppCategory(const AppCategoryType &x)
380 this->appCategory.push_back(x);
382 void addMetadata(const MetadataType &m)
384 this->metadata.push_back(m);
386 void serialize(xmlTextWriterPtr writer);
392 DPL::OptionalBool multiple;
393 DPL::OptionalBool nodisplay;
394 DPL::OptionalBool taskmanage;
396 CategoriesType categories;
397 std::list<LabelType> label;
398 std::list<IconType> icon;
399 std::list<AppControlType> appControl;
400 std::list<AppCategoryType> appCategory;
401 std::list<MetadataType> metadata;
404 typedef UiApplication UiApplicationType;
409 * @brief LiveBox element
411 typedef WrtDB::ConfigParserData::LiveboxInfo::BoxSizeList BoxSizeType;
412 typedef WrtDB::ConfigParserData::LiveboxInfo::BoxLabelList BoxLabelType;
417 NcnameType boxMouseEvent;
418 NcnameType boxTouchEffect;
424 typedef BoxInfo BoxInfoType;
430 void setLiveboxId(const NcnameType &x)
434 void setPrimary(const NcnameType &x)
438 void setUpdatePeriod(const NcnameType &x)
440 this->updatePeriod = x;
442 void setLabel(const BoxLabelType &x)
446 void setIcon(const NcnameType &x)
450 void setBox(const BoxInfoType &x)
455 void serialize(xmlTextWriterPtr writer);
458 NcnameType liveboxId;
460 NcnameType autoLaunch;
461 NcnameType updatePeriod;
469 typedef LiveBox LiveBoxInfo;
473 * @brief manifest element
475 * Manifest xml file representation.
481 void serialize(xmlTextWriterPtr writer);
482 void generate(DPL::String filename);
484 void addLabel(const LabelType &x)
486 #ifdef MULTIPROCESS_SERVICE_SUPPORT
487 auto pos = std::find(label.begin(), label.end(), x);
488 if (pos == label.end()) {
489 this->label.push_back(x);
492 this->label.push_back(x);
495 void addIcon(const IconType &x)
497 this->icon.push_back(x);
499 void addAuthor(const AuthorType &x)
501 this->author.push_back(x);
503 void addDescription(const DescriptionType &x)
505 this->description.push_back(x);
507 // void addCompatibility(const CompatibilityType &x)
509 // this->compatibility.push_back(x);
511 // void addDeviceProfile(const DeviceProfileType &x)
513 // this->deviceProfile.push_back(x);
515 void addServiceApplication(const ServiceApplicationType &x)
517 this->serviceApplication.push_back(x);
519 void addUiApplication(const UiApplicationType &x)
521 this->uiApplication.push_back(x);
523 void addImeApplication(const ImeApplicationType &x)
525 this->imeApplication.push_back(x);
527 // void addFont(const FontType &x) { this->font.push_back(x); }
529 void addLivebox(const LiveBoxInfo &x)
531 this->livebox.push_back(x);
534 void addAccount(const Account &x)
536 this->account.push_back(x);
539 void addPrivileges(const PrivilegeType &x)
541 this->privileges = x;
544 void setInstallLocation(const InstallLocationType &x)
546 this->installLocation = x;
548 void setPackage(const NcnameType &x)
552 void setType(const PackageType &x)
556 void setVersion(const NmtokenType &x)
560 void setStoreClientId(const NcnameType &x)
562 this->storeClientId= x;
566 std::list<LabelType> label;
567 std::list<IconType> icon;
568 std::list<AuthorType> author;
569 std::list<DescriptionType> description;
570 // std::list<CompatibilityType> compatibility;
571 // std::list<DeviceProfileType> deviceProfile;
572 std::list<ServiceApplicationType> serviceApplication;
573 std::list<UiApplicationType> uiApplication;
574 std::list<ImeApplicationType> imeApplication;
575 // std::list<FontType> font;
577 std::list<LiveBoxInfo> livebox;
579 InstallLocationType installLocation;
583 std::list<Account> account;
584 PrivilegeType privileges;
585 NcnameType storeClientId;
589 } //namespace WidgetInstall
591 #endif //INSTALLER_JOBS_MANIFEST_H