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 manifest element
228 * Manifest xml file representation.
234 void serialize(xmlTextWriterPtr writer);
235 void generate(DPL::String filename);
237 void addLabel(const LabelType &x) { this->label.push_back(x); }
238 void addIcon(const IconType &x) { this->icon.push_back(x); }
239 void addAuthor(const AuthorType &x) { this->author.push_back(x); };
240 void addDescription(const DescriptionType &x)
242 this->description.push_back(x);
244 // void addCompatibility(const CompatibilityType &x)
246 // this->compatibility.push_back(x);
248 // void addDeviceProfile(const DeviceProfileType &x)
250 // this->deviceProfile.push_back(x);
252 void addServiceApplication(const ServiceApplicationType &x)
254 this->serviceApplication.push_back(x);
256 void addUiApplication(const UiApplicationType &x)
258 this->uiApplication.push_back(x);
260 void addImeApplication(const ImeApplicationType &x)
262 this->imeApplication.push_back(x);
264 // void addFont(const FontType &x) { this->font.push_back(x); }
266 void setInstallLocation(const InstallLocationType &x)
268 this->installLocation = x;
270 void setPackage(const NcnameType &x) { this->package = x; }
271 void setType(const PackageType &x) { this->type = x; }
272 void setVersion(const NmtokenType &x) { this->version = x; }
274 std::list<LabelType> label;
275 std::list<IconType> icon;
276 std::list<AuthorType> author;
277 std::list<DescriptionType> description;
278 // std::list<CompatibilityType> compatibility;
279 // std::list<DeviceProfileType> deviceProfile;
280 std::list<ServiceApplicationType> serviceApplication;
281 std::list<UiApplicationType> uiApplication;
282 std::list<ImeApplicationType> imeApplication;
283 // std::list<FontType> font;
284 InstallLocationType installLocation;
291 } //namespace WidgetInstall
293 #endif //INSTALLER_JOBS_MANIFEST_H