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 {
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() { return this->string; }
46 DPL::String getLang() { return this->lang; }
47 bool hasLang() { return !this->lang.empty(); }
53 typedef StringWithLang LabelType, IconType, DescriptionType;
56 * These types are basicaly strings but they should allow usage of different
57 * range of characters or words (details in XML spec.).
58 * For simplicity DPL::Strings are used, although this can lead to XML validation
59 * errors (related to usage of not allowed characters in given places).
61 typedef DPL::String NcnameType, NmtokenType, AnySimpleType, LangType;
62 typedef DPL::String OperationType, MimeType, UriType, TypeType, PackageType;
63 typedef DPL::OptionalString InstallLocationType, CategoriesType;
68 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
69 void writeText(xmlTextWriterPtr writer, DPL::String text);
70 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
71 void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
72 const char * body, const char * nameAttr, DPL::String bodyAttr,
73 bool condition = true);
74 void startElement(xmlTextWriterPtr writer, const char * name);
75 void endElement(xmlTextWriterPtr writer);
76 void writeAttribute(xmlTextWriterPtr writer, const char * name,
77 DPL::String body, bool condition);
78 void writeAttribute(xmlTextWriterPtr writer, const char * name,
79 const char * body, bool condition);
82 * @brief author element
88 Author(AnySimpleType e,
92 : email(e), href(h), lang(l), body(b) {}
93 void serialize(xmlTextWriterPtr writer);
101 typedef Author AuthorType;
104 * @brief application-service element
106 class ApplicationService
109 ApplicationService() {}
110 void addOperation(const OperationType &x) { this->operation.push_back(x); }
111 void addUri(const UriType &x) { this->uri.push_back(x); }
112 void addMime(const MimeType &x) { this->mime.push_back(x); }
113 void serialize(xmlTextWriterPtr writer);
115 std::list<OperationType> operation; //attr name AnySimpleType
116 std::list<UriType> uri; //attr name AnySimpleType
117 std::list<MimeType> mime; //attr name AnySimpleType
120 typedef ApplicationService ApplicationServiceType;
123 * @brief ime-application element
129 void setAppid(const NcnameType &x) { this->appid = x; }
130 void setExec(const NcnameType &x) { this->exec = x; }
131 void setMultiple(bool x) { this->multiple = x; }
132 void setNodisplay(bool x) { this->nodisplay = x; }
133 void setType(const TypeType &x) { this->type = x; }
134 void addLabel(const LabelType &x) { this->label.push_back(x); }
135 void addIcon(const IconType &x) { this->icon.push_back(x); }
136 void serialize(xmlTextWriterPtr writer);
140 DPL::OptionalBool multiple;
141 DPL::OptionalBool nodisplay;
143 std::list<LabelType> label;
144 std::list<IconType> icon;
147 typedef ImeApplication ImeApplicationType;
150 * @brief service-application element
152 class ServiceApplication
155 ServiceApplication() {}
156 void setAppid(const NcnameType &x) { this->appid = x; }
157 void setAutoRestart(bool x) { this->autoRestart = x; }
158 void setExec(const AnySimpleType &x) { this->exec = x; }
159 void setOnBoot(bool x) { this->onBoot = x; }
160 void setType(const TypeType &x) { this->type = x; }
161 void addLabel(const LabelType &x) { this->label.push_back(x); }
162 void addIcon(const IconType &x) { this->icon.push_back(x); }
163 void addApplicationService(const ApplicationServiceType &x)
165 this->applicationService.push_back(x);
167 void serialize(xmlTextWriterPtr writer);
170 DPL::OptionalBool autoRestart;
172 DPL::OptionalBool onBoot;
174 std::list<LabelType> label; //attr name AnySimpleType
175 std::list<IconType> icon; //attr name AnySimpleType
176 std::list<ApplicationServiceType> applicationService; //attr name AnySimpleType
179 typedef ServiceApplication ServiceApplicationType;
182 * @brief ui-application element
188 void setAppid(const NcnameType &x) { this->appid = x; }
189 void setExtraid(const NcnameType &x) { this->extraid = x; }
190 void setExec(const AnySimpleType &x) { this->exec = x; }
191 void setMultiple(bool x) { this->multiple = x; }
192 void setNodisplay(bool x) { this->nodisplay = x; }
193 void setTaskmanage(bool x) { this->taskmanage = x; }
194 void setType(const TypeType &x) { this->type = x; }
195 void setCategories(const NcnameType &x) { this->categories = x; }
196 void addLabel(const LabelType &x) { this->label.push_back(x); }
197 void addIcon(const IconType &x) { this->icon.push_back(x); }
198 void addApplicationService(const ApplicationServiceType &x)
200 this->applicationService.push_back(x);
202 void serialize(xmlTextWriterPtr writer);
207 DPL::OptionalBool multiple;
208 DPL::OptionalBool nodisplay;
209 DPL::OptionalBool taskmanage;
211 CategoriesType categories;
212 std::list<LabelType> label;
213 std::list<IconType> icon;
214 std::list<ApplicationServiceType> applicationService;
217 typedef UiApplication UiApplicationType;
220 * @brief manifest element
222 * Manifest xml file representation.
228 void serialize(xmlTextWriterPtr writer);
229 void generate(DPL::String filename);
231 void addLabel(const LabelType &x) { this->label.push_back(x); }
232 void addIcon(const IconType &x) { this->icon.push_back(x); }
233 void addAuthor(const AuthorType &x) { this->author.push_back(x); };
234 void addDescription(const DescriptionType &x)
236 this->description.push_back(x);
238 // void addCompatibility(const CompatibilityType &x)
240 // this->compatibility.push_back(x);
242 // void addDeviceProfile(const DeviceProfileType &x)
244 // this->deviceProfile.push_back(x);
246 void addServiceApplication(const ServiceApplicationType &x)
248 this->serviceApplication.push_back(x);
250 void addUiApplication(const UiApplicationType &x)
252 this->uiApplication.push_back(x);
254 void addImeApplication(const ImeApplicationType &x)
256 this->imeApplication.push_back(x);
258 // void addFont(const FontType &x) { this->font.push_back(x); }
260 void setInstallLocation(const InstallLocationType &x)
262 this->installLocation = x;
264 void setPackage(const NcnameType &x) { this->package = x; }
265 void setType(const PackageType &x) { this->type = x; }
266 void setVersion(const NmtokenType &x) { this->version = x; }
268 std::list<LabelType> label;
269 std::list<IconType> icon;
270 std::list<AuthorType> author;
271 std::list<DescriptionType> description;
272 // std::list<CompatibilityType> compatibility;
273 // std::list<DeviceProfileType> deviceProfile;
274 std::list<ServiceApplicationType> serviceApplication;
275 std::list<UiApplicationType> uiApplication;
276 std::list<ImeApplicationType> imeApplication;
277 // std::list<FontType> font;
278 InstallLocationType installLocation;
285 } //namespace WidgetInstall
287 #endif //INSTALLER_JOBS_MANIFEST_H