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;
64 typedef DPL::String AppCategoryType;
69 void writeElement(xmlTextWriterPtr writer, const char * name, DPL::String body);
70 void writeText(xmlTextWriterPtr writer, DPL::String text);
71 void writeElement(xmlTextWriterPtr writer, const char * name, const char * body);
72 void writeElementWithOneAttribute(xmlTextWriterPtr writer, const char * name,
73 const char * body, const char * nameAttr, DPL::String bodyAttr,
74 bool condition = true);
75 void startElement(xmlTextWriterPtr writer, const char * name);
76 void endElement(xmlTextWriterPtr writer);
77 void writeAttribute(xmlTextWriterPtr writer, const char * name,
78 DPL::String body, bool condition);
79 void writeAttribute(xmlTextWriterPtr writer, const char * name,
80 const char * body, bool condition);
83 * @brief author element
89 Author(AnySimpleType e,
93 : email(e), href(h), lang(l), body(b) {}
94 void serialize(xmlTextWriterPtr writer);
102 typedef Author AuthorType;
105 * @brief application-service element
111 void addOperation(const OperationType &x) { this->operation.push_back(x); }
112 void addUri(const UriType &x) { this->uri.push_back(x); }
113 void addMime(const MimeType &x) { this->mime.push_back(x); }
114 void serialize(xmlTextWriterPtr writer);
116 std::list<OperationType> operation; //attr name AnySimpleType
117 std::list<UriType> uri; //attr name AnySimpleType
118 std::list<MimeType> mime; //attr name AnySimpleType
121 typedef AppControl AppControlType;
124 * @brief ime-application element
130 void setAppid(const NcnameType &x) { this->appid = x; }
131 void setExec(const NcnameType &x) { this->exec = x; }
132 void setMultiple(bool x) { this->multiple = x; }
133 void setNodisplay(bool x) { this->nodisplay = x; }
134 void setType(const TypeType &x) { this->type = x; }
135 void addLabel(const LabelType &x) { this->label.push_back(x); }
136 void addIcon(const IconType &x) { this->icon.push_back(x); }
137 void serialize(xmlTextWriterPtr writer);
141 DPL::OptionalBool multiple;
142 DPL::OptionalBool nodisplay;
144 std::list<LabelType> label;
145 std::list<IconType> icon;
148 typedef ImeApplication ImeApplicationType;
151 * @brief service-application element
153 class ServiceApplication
156 ServiceApplication() {}
157 void setAppid(const NcnameType &x) { this->appid = x; }
158 void setAutoRestart(bool x) { this->autoRestart = x; }
159 void setExec(const AnySimpleType &x) { this->exec = x; }
160 void setOnBoot(bool x) { this->onBoot = x; }
161 void setType(const TypeType &x) { this->type = x; }
162 void addLabel(const LabelType &x) { this->label.push_back(x); }
163 void addIcon(const IconType &x) { this->icon.push_back(x); }
164 void addAppControl(const AppControlType &x)
166 this->appControl.push_back(x);
168 void serialize(xmlTextWriterPtr writer);
171 DPL::OptionalBool autoRestart;
173 DPL::OptionalBool onBoot;
175 std::list<LabelType> label; //attr name AnySimpleType
176 std::list<IconType> icon; //attr name AnySimpleType
177 std::list<AppControlType> appControl; //attr name AnySimpleType
180 typedef ServiceApplication ServiceApplicationType;
183 * @brief ui-application element
189 void setAppid(const NcnameType &x) { this->appid = x; }
190 void setExtraid(const NcnameType &x) { this->extraid = x; }
191 void setExec(const AnySimpleType &x) { this->exec = x; }
192 void setMultiple(bool x) { this->multiple = x; }
193 void setNodisplay(bool x) { this->nodisplay = x; }
194 void setTaskmanage(bool x) { this->taskmanage = x; }
195 void setType(const TypeType &x) { this->type = x; }
196 void setCategories(const NcnameType &x) { this->categories = x; }
197 void addLabel(const LabelType &x) { this->label.push_back(x); }
198 void addIcon(const IconType &x) { this->icon.push_back(x); }
199 void addAppControl(const AppControlType &x)
201 this->appControl.push_back(x);
203 void addAppCategory(const AppCategoryType &x)
205 this->appCategory.push_back(x);
207 void serialize(xmlTextWriterPtr writer);
212 DPL::OptionalBool multiple;
213 DPL::OptionalBool nodisplay;
214 DPL::OptionalBool taskmanage;
216 CategoriesType categories;
217 std::list<LabelType> label;
218 std::list<IconType> icon;
219 std::list<AppControlType> appControl;
220 std::list<AppCategoryType> appCategory;
223 typedef UiApplication UiApplicationType;
226 * @brief LiveBox element
228 typedef std::list<std::pair<DPL::String, DPL::String>> boxSizeType;
239 typedef BoxInfo BoxInfoType;
245 void setLiveboxId(const NcnameType &x) { this->liveboxId = x; }
246 void setPrimary(const NcnameType &x) { this->primary = x; }
247 void setAutoLaunch(const NcnameType &x) { this->autoLaunch = x; }
248 void setUpdatePeriod(const NcnameType &x) { this->updatePeriod = x; }
249 void setLabel(const NcnameType &x) { this->label = x; }
250 void setIcon(const NcnameType &x) { this->icon = x; }
251 void setBox(const BoxInfoType &x) { this->box = x; }
253 void serialize(xmlTextWriterPtr writer);
256 NcnameType liveboxId;
258 NcnameType autoLaunch;
259 NcnameType updatePeriod;
266 typedef LiveBox LiveBoxInfo;
269 * @brief manifest element
271 * Manifest xml file representation.
277 void serialize(xmlTextWriterPtr writer);
278 void generate(DPL::String filename);
280 void addLabel(const LabelType &x) { this->label.push_back(x); }
281 void addIcon(const IconType &x) { this->icon.push_back(x); }
282 void addAuthor(const AuthorType &x) { this->author.push_back(x); };
283 void addDescription(const DescriptionType &x)
285 this->description.push_back(x);
287 // void addCompatibility(const CompatibilityType &x)
289 // this->compatibility.push_back(x);
291 // void addDeviceProfile(const DeviceProfileType &x)
293 // this->deviceProfile.push_back(x);
295 void addServiceApplication(const ServiceApplicationType &x)
297 this->serviceApplication.push_back(x);
299 void addUiApplication(const UiApplicationType &x)
301 this->uiApplication.push_back(x);
303 void addImeApplication(const ImeApplicationType &x)
305 this->imeApplication.push_back(x);
307 // void addFont(const FontType &x) { this->font.push_back(x); }
309 void addLivebox(const LiveBoxInfo &x)
311 this->livebox.push_back(x);
314 void setInstallLocation(const InstallLocationType &x)
316 this->installLocation = x;
318 void setPackage(const NcnameType &x) { this->package = x; }
319 void setType(const PackageType &x) { this->type = x; }
320 void setVersion(const NmtokenType &x) { this->version = x; }
322 std::list<LabelType> label;
323 std::list<IconType> icon;
324 std::list<AuthorType> author;
325 std::list<DescriptionType> description;
326 // std::list<CompatibilityType> compatibility;
327 // std::list<DeviceProfileType> deviceProfile;
328 std::list<ServiceApplicationType> serviceApplication;
329 std::list<UiApplicationType> uiApplication;
330 std::list<ImeApplicationType> imeApplication;
331 // std::list<FontType> font;
332 std::list<LiveBoxInfo> livebox;
333 InstallLocationType installLocation;
340 } //namespace WidgetInstall
342 #endif //INSTALLER_JOBS_MANIFEST_H