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;
407 * @brief LiveBox element
409 typedef WrtDB::ConfigParserData::LiveboxInfo::BoxSizeList BoxSizeType;
410 typedef WrtDB::ConfigParserData::LiveboxInfo::BoxLabelList BoxLabelType;
415 NcnameType boxMouseEvent;
416 NcnameType boxTouchEffect;
422 typedef BoxInfo BoxInfoType;
428 void setLiveboxId(const NcnameType &x)
432 void setPrimary(const NcnameType &x)
436 void setUpdatePeriod(const NcnameType &x)
438 this->updatePeriod = x;
440 void setLabel(const BoxLabelType &x)
444 void setIcon(const NcnameType &x)
448 void setBox(const BoxInfoType &x)
453 void serialize(xmlTextWriterPtr writer);
456 NcnameType liveboxId;
458 NcnameType autoLaunch;
459 NcnameType updatePeriod;
467 typedef LiveBox LiveBoxInfo;
470 * @brief manifest element
472 * Manifest xml file representation.
478 void serialize(xmlTextWriterPtr writer);
479 void generate(DPL::String filename);
481 void addLabel(const LabelType &x)
483 #ifdef MULTIPROCESS_SERVICE_SUPPORT
484 auto pos = std::find(label.begin(), label.end(), x);
485 if (pos == label.end()) {
486 this->label.push_back(x);
489 this->label.push_back(x);
492 void addIcon(const IconType &x)
494 this->icon.push_back(x);
496 void addAuthor(const AuthorType &x)
498 this->author.push_back(x);
500 void addDescription(const DescriptionType &x)
502 this->description.push_back(x);
504 // void addCompatibility(const CompatibilityType &x)
506 // this->compatibility.push_back(x);
508 // void addDeviceProfile(const DeviceProfileType &x)
510 // this->deviceProfile.push_back(x);
512 void addServiceApplication(const ServiceApplicationType &x)
514 this->serviceApplication.push_back(x);
516 void addUiApplication(const UiApplicationType &x)
518 this->uiApplication.push_back(x);
520 void addImeApplication(const ImeApplicationType &x)
522 this->imeApplication.push_back(x);
524 // void addFont(const FontType &x) { this->font.push_back(x); }
526 void addLivebox(const LiveBoxInfo &x)
528 this->livebox.push_back(x);
531 void addAccount(const Account &x)
533 this->account.push_back(x);
536 void addPrivileges(const PrivilegeType &x)
538 this->privileges = x;
541 void setInstallLocation(const InstallLocationType &x)
543 this->installLocation = x;
545 void setPackage(const NcnameType &x)
549 void setType(const PackageType &x)
553 void setVersion(const NmtokenType &x)
557 void setStoreClientId(const NcnameType &x)
559 this->storeClientId= x;
563 std::list<LabelType> label;
564 std::list<IconType> icon;
565 std::list<AuthorType> author;
566 std::list<DescriptionType> description;
567 // std::list<CompatibilityType> compatibility;
568 // std::list<DeviceProfileType> deviceProfile;
569 std::list<ServiceApplicationType> serviceApplication;
570 std::list<UiApplicationType> uiApplication;
571 std::list<ImeApplicationType> imeApplication;
572 // std::list<FontType> font;
573 std::list<LiveBoxInfo> livebox;
574 InstallLocationType installLocation;
578 std::list<Account> account;
579 PrivilegeType privileges;
580 NcnameType storeClientId;
584 } //namespace WidgetInstall
586 #endif //INSTALLER_JOBS_MANIFEST_H