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;
84 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
85 void writeText(xmlTextWriterPtr writer, DPL::String text);
86 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
87 void writeElementWithOneAttribute(xmlTextWriterPtr writer,
90 const char * nameAttr,
92 bool condition = true);
93 void startElement(xmlTextWriterPtr writer, const char * name);
94 void endElement(xmlTextWriterPtr writer);
95 void writeAttribute(xmlTextWriterPtr writer, const char * name,
96 DPL::String body, bool condition);
97 void writeAttribute(xmlTextWriterPtr writer, const char * name,
98 const char * body, bool condition);
101 * @brief author element
107 Author(AnySimpleType e,
111 email(e), href(h), lang(l), body(b) {}
112 void serialize(xmlTextWriterPtr writer);
121 typedef Author AuthorType;
124 * @brief application-service element
130 void addOperation(const OperationType &x)
132 this->operation.push_back(x);
134 void addUri(const UriType &x)
136 this->uri.push_back(x);
138 void addMime(const MimeType &x)
140 this->mime.push_back(x);
142 void serialize(xmlTextWriterPtr writer);
145 std::list<OperationType> operation; //attr name AnySimpleType
146 std::list<UriType> uri; //attr name AnySimpleType
147 std::list<MimeType> mime; //attr name AnySimpleType
150 typedef AppControl AppControlType;
153 * @brief account element
155 typedef std::list<std::pair<DPL::String, DPL::String>> IconListType;
156 typedef std::list<LabelType> DisplayNameListType;
157 typedef std::list<DPL::String> AccountCapabilityType;
159 struct AccountProvider
162 NcnameType multiAccount;
164 DisplayNameListType name;
165 AccountCapabilityType capability;
168 typedef AccountProvider AccountProviderType;
174 void addAccountProvider(const AccountProvider &x)
178 void serialize(xmlTextWriterPtr writer);
181 AccountProviderType provider;
188 void addPrivilegeName(const DPL::String &x)
190 this->name.push_back(x);
194 return this->name.empty();
197 void serialize(xmlTextWriterPtr writer);
200 std::list<DPL::String> name;
203 typedef Privilege PrivilegeType;
206 * @brief ime-application element
212 void setAppid(const NcnameType &x)
216 void setExec(const NcnameType &x)
220 void setMultiple(bool x)
224 void setNodisplay(bool x)
228 void setType(const TypeType &x)
232 void addLabel(const LabelType &x)
234 this->label.push_back(x);
236 void addIcon(const IconType &x)
238 this->icon.push_back(x);
240 void serialize(xmlTextWriterPtr writer);
245 DPL::OptionalBool multiple;
246 DPL::OptionalBool nodisplay;
248 std::list<LabelType> label;
249 std::list<IconType> icon;
252 typedef ImeApplication ImeApplicationType;
255 * @brief service-application element
257 class ServiceApplication
260 ServiceApplication() {}
261 void setAppid(const NcnameType &x)
265 void setAutoRestart(bool x)
267 this->autoRestart = x;
269 void setExec(const AnySimpleType &x)
273 void setOnBoot(bool x)
277 void setType(const TypeType &x)
281 void addLabel(const LabelType &x)
283 this->label.push_back(x);
285 void addIcon(const IconType &x)
287 this->icon.push_back(x);
289 void addAppControl(const AppControlType &x)
291 this->appControl.push_back(x);
293 void serialize(xmlTextWriterPtr writer);
297 DPL::OptionalBool autoRestart;
299 DPL::OptionalBool onBoot;
301 std::list<LabelType> label; //attr name AnySimpleType
302 std::list<IconType> icon; //attr name AnySimpleType
303 std::list<AppControlType> appControl; //attr name AnySimpleType
306 typedef ServiceApplication ServiceApplicationType;
309 * @brief ui-application element
315 void setAppid(const NcnameType &x)
319 void setExtraid(const NcnameType &x)
323 void setExec(const AnySimpleType &x)
327 void setMultiple(bool x)
331 void setNodisplay(bool x)
335 void setTaskmanage(bool x)
337 this->taskmanage = x;
339 void setType(const TypeType &x)
343 void setCategories(const NcnameType &x)
345 this->categories = x;
347 void addLabel(const LabelType &x)
349 this->label.push_back(x);
351 void addIcon(const IconType &x)
353 this->icon.push_back(x);
355 void addAppControl(const AppControlType &x)
357 this->appControl.push_back(x);
359 void addAppCategory(const AppCategoryType &x)
361 this->appCategory.push_back(x);
363 void serialize(xmlTextWriterPtr writer);
369 DPL::OptionalBool multiple;
370 DPL::OptionalBool nodisplay;
371 DPL::OptionalBool taskmanage;
373 CategoriesType categories;
374 std::list<LabelType> label;
375 std::list<IconType> icon;
376 std::list<AppControlType> appControl;
377 std::list<AppCategoryType> appCategory;
380 typedef UiApplication UiApplicationType;
383 * @brief LiveBox element
385 typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
390 NcnameType boxMouseEvent;
391 NcnameType boxTouchEffect;
397 typedef BoxInfo BoxInfoType;
403 void setLiveboxId(const NcnameType &x)
407 void setPrimary(const NcnameType &x)
411 void setUpdatePeriod(const NcnameType &x)
413 this->updatePeriod = x;
415 void setLabel(const NcnameType &x)
419 void setIcon(const NcnameType &x)
423 void setBox(const BoxInfoType &x)
428 void serialize(xmlTextWriterPtr writer);
431 NcnameType liveboxId;
433 NcnameType autoLaunch;
434 NcnameType updatePeriod;
441 typedef LiveBox LiveBoxInfo;
444 * @brief manifest element
446 * Manifest xml file representation.
452 void serialize(xmlTextWriterPtr writer);
453 void generate(DPL::String filename);
455 void addLabel(const LabelType &x)
457 #ifdef MULTIPROCESS_SERVICE_SUPPORT
458 auto pos = std::find(label.begin(), label.end(), x);
459 if (pos == label.end()) {
460 this->label.push_back(x);
463 this->label.push_back(x);
466 void addIcon(const IconType &x)
468 this->icon.push_back(x);
470 void addAuthor(const AuthorType &x)
472 this->author.push_back(x);
474 void addDescription(const DescriptionType &x)
476 this->description.push_back(x);
478 // void addCompatibility(const CompatibilityType &x)
480 // this->compatibility.push_back(x);
482 // void addDeviceProfile(const DeviceProfileType &x)
484 // this->deviceProfile.push_back(x);
486 void addServiceApplication(const ServiceApplicationType &x)
488 this->serviceApplication.push_back(x);
490 void addUiApplication(const UiApplicationType &x)
492 this->uiApplication.push_back(x);
494 void addImeApplication(const ImeApplicationType &x)
496 this->imeApplication.push_back(x);
498 // void addFont(const FontType &x) { this->font.push_back(x); }
500 void addLivebox(const LiveBoxInfo &x)
502 this->livebox.push_back(x);
505 void addAccount(const Account &x)
507 this->account.push_back(x);
510 void addPrivileges(const PrivilegeType &x)
512 this->privileges = x;
515 void setInstallLocation(const InstallLocationType &x)
517 this->installLocation = x;
519 void setPackage(const NcnameType &x)
523 void setType(const PackageType &x)
527 void setVersion(const NmtokenType &x)
533 std::list<LabelType> label;
534 std::list<IconType> icon;
535 std::list<AuthorType> author;
536 std::list<DescriptionType> description;
537 // std::list<CompatibilityType> compatibility;
538 // std::list<DeviceProfileType> deviceProfile;
539 std::list<ServiceApplicationType> serviceApplication;
540 std::list<UiApplicationType> uiApplication;
541 std::list<ImeApplicationType> imeApplication;
542 // std::list<FontType> font;
543 std::list<LiveBoxInfo> livebox;
544 InstallLocationType installLocation;
548 std::list<Account> account;
549 PrivilegeType privileges;
553 } //namespace WidgetInstall
555 #endif //INSTALLER_JOBS_MANIFEST_H