1 /* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
2 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a apache 2.0 license that can be
4 // found in the LICENSE file.
6 #include "wgt/step/pkgmgr/step_generate_xml.h"
8 #include <boost/filesystem/path.hpp>
9 #include <boost/system/error_code.hpp>
11 #include <common/utils/file_util.h>
12 #include <common/utils/glist_range.h>
13 #include <common/privileges.h>
15 #include <libxml/parser.h>
16 #include <libxml/xmlreader.h>
17 #include <pkgmgr-info.h>
18 #include <pkgmgr_parser.h>
19 #include <tzplatform_config.h>
26 #include "wgt/wgt_backend_data.h"
28 namespace bs = boost::system;
29 namespace bf = boost::filesystem;
33 const char kResWgt[] = "res/wgt";
34 const char kSharedRes[] = "shared/res";
36 void WriteUIApplicationAttributes(
37 xmlTextWriterPtr writer, application_x *app) {
39 xmlTextWriterWriteAttribute(writer, BAD_CAST "taskmanage",
40 BAD_CAST app->taskmanage);
42 xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay",
43 BAD_CAST app->nodisplay);
45 xmlTextWriterWriteAttribute(writer, BAD_CAST "multiple",
46 BAD_CAST app->multiple);
47 if (app->launch_mode && strlen(app->launch_mode))
48 xmlTextWriterWriteAttribute(writer, BAD_CAST "launch_mode",
49 BAD_CAST app->launch_mode);
50 if (app->ui_gadget && strlen(app->ui_gadget))
51 xmlTextWriterWriteAttribute(writer, BAD_CAST "ui-gadget",
52 BAD_CAST app->ui_gadget);
53 if (app->submode && strlen(app->submode))
54 xmlTextWriterWriteAttribute(writer, BAD_CAST "submode",
55 BAD_CAST app->submode);
56 if (app->submode_mainid && strlen(app->submode_mainid))
57 xmlTextWriterWriteAttribute(writer, BAD_CAST "submode-mainid",
58 BAD_CAST app->submode_mainid);
59 if (app->indicatordisplay && strlen(app->indicatordisplay))
60 xmlTextWriterWriteAttribute(writer, BAD_CAST "indicatordisplay",
61 BAD_CAST app->indicatordisplay);
62 if (app->portraitimg && strlen(app->portraitimg))
63 xmlTextWriterWriteAttribute(writer, BAD_CAST "portrait-effectimage",
64 BAD_CAST app->portraitimg);
65 if (app->landscapeimg && strlen(app->landscapeimg))
66 xmlTextWriterWriteAttribute(writer, BAD_CAST "landscape-effectimage",
67 BAD_CAST app->landscapeimg);
68 if (app->effectimage_type && strlen(app->effectimage_type))
69 xmlTextWriterWriteAttribute(writer, BAD_CAST "effectimage-type",
70 BAD_CAST app->effectimage_type);
71 if (app->hwacceleration && strlen(app->hwacceleration))
72 xmlTextWriterWriteAttribute(writer, BAD_CAST "hwacceleration",
73 BAD_CAST app->hwacceleration);
76 void WriteServiceApplicationAttributes(
77 xmlTextWriterPtr writer, application_x *app) {
78 xmlTextWriterWriteAttribute(writer, BAD_CAST "auto-restart",
79 BAD_CAST(app->autorestart ? app->autorestart : "false"));
80 xmlTextWriterWriteAttribute(writer, BAD_CAST "on-boot",
81 BAD_CAST(app->onboot ? app->onboot : "false"));
83 xmlTextWriterWriteAttribute(writer, BAD_CAST "taskmanage",
84 BAD_CAST app->taskmanage);
87 bool WriteWidgetApplicationAttributesAndElements(
88 xmlTextWriterPtr writer, application_x *app,
89 const wgt::parse::AppWidgetInfo& widget_info,
90 const bf::path& shared_path) {
92 xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay",
93 BAD_CAST app->nodisplay);
95 xmlTextWriterWriteAttribute(writer, BAD_CAST "multiple",
96 BAD_CAST app->multiple);
98 auto& appwidgets = widget_info.app_widgets();
99 const auto& appwidget = std::find_if(appwidgets.begin(), appwidgets.end(),
100 [app](const wgt::parse::AppWidget& widget) {
101 return widget.id == app->appid;
103 if (appwidget == appwidgets.end()) {
107 // Add extra elements for wgt widget-application
108 xmlTextWriterWriteAttribute(writer, BAD_CAST "main",
109 BAD_CAST (appwidget->primary ? "true" : "false")); // NOLINT
110 if (!appwidget->update_period.empty()) {
111 xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST
112 std::to_string(static_cast<int>(
113 appwidget->update_period.front())).c_str());
116 xmlTextWriterWriteAttribute(writer, BAD_CAST "max-instance",
117 BAD_CAST std::to_string(appwidget->max_instance).c_str());
119 for (auto& size : appwidget->content_size) {
120 xmlTextWriterStartElement(writer, BAD_CAST "support-size");
122 std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type);
123 if (!size.preview.empty()) {
124 std::string icon_name = shared_path.string() + "/"
125 + appwidget->id + "." + type + "." + "preview" +
126 bf::path(size.preview).extension().string();
127 xmlTextWriterWriteAttribute(writer, BAD_CAST "preview",
128 BAD_CAST icon_name.c_str()); // NOLINT
131 xmlTextWriterWriteAttribute(writer, BAD_CAST "frame",
133 xmlTextWriterWriteString(writer,
134 BAD_CAST type.c_str());
135 xmlTextWriterEndElement(writer);
138 for (auto& pair : appwidget->metadata) {
139 xmlTextWriterStartElement(writer, BAD_CAST "metadata");
140 xmlTextWriterWriteAttribute(writer, BAD_CAST "key",
141 BAD_CAST pair.first.c_str());
142 if (!pair.second.empty())
143 xmlTextWriterWriteAttribute(writer, BAD_CAST "value",
144 BAD_CAST pair.second.c_str());
145 xmlTextWriterEndElement(writer);
150 void WriteWatchApplicationAttributes(
151 xmlTextWriterPtr writer, application_x* app) {
152 if (app->ambient_support)
153 xmlTextWriterWriteAttribute(writer, BAD_CAST "ambient-support",
154 BAD_CAST app->ambient_support);
162 common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml(
163 application_x* app, xmlTextWriterPtr writer, AppCompType type) {
164 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", BAD_CAST app->appid);
166 // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
167 bf::path exec_path = context_->pkg_path.get()
168 / bf::path("bin") / bf::path(app->appid);
169 xmlTextWriterWriteAttribute(writer, BAD_CAST "exec",
170 BAD_CAST exec_path.string().c_str());
172 xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST app->type);
174 xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST "capp");
176 if (app->process_pool && strlen(app->process_pool))
177 xmlTextWriterWriteAttribute(writer, BAD_CAST "process-pool",
178 BAD_CAST app->process_pool);
179 // app-specific attributes
181 case AppCompType::UIAPP:
182 WriteUIApplicationAttributes(writer, app);
184 case AppCompType::SVCAPP:
185 WriteServiceApplicationAttributes(writer, app);
187 case AppCompType::WIDGETAPP:
188 if (!WriteWidgetApplicationAttributesAndElements(writer, app,
189 static_cast<WgtBackendData*>(
190 context_->backend_data.get())->appwidgets.get(),
191 context_->pkg_path.get() / "shared" / "res"))
192 return Status::MANIFEST_ERROR;
194 case AppCompType::WATCHAPP:
195 WriteWatchApplicationAttributes(writer, app);
199 for (label_x* label : GListRange<label_x*>(app->label)) {
200 if (label->name && strcmp(label->name, "") != 0) {
201 xmlTextWriterStartElement(writer, BAD_CAST "label");
202 if (label->lang && strcmp(DEFAULT_LOCALE, label->lang) != 0) {
203 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
204 BAD_CAST label->lang);
206 xmlTextWriterWriteString(writer, BAD_CAST label->name);
207 xmlTextWriterEndElement(writer);
211 for (auto& icon : GListRange<icon_x*>(app->icon)) {
212 xmlTextWriterStartElement(writer, BAD_CAST "icon");
213 if (icon->lang && strcmp(DEFAULT_LOCALE, icon->lang) != 0) {
214 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
215 BAD_CAST icon->lang);
217 xmlTextWriterWriteString(writer, BAD_CAST icon->text);
218 xmlTextWriterEndElement(writer);
221 for (image_x* image : GListRange<image_x*>(app->image)) {
222 xmlTextWriterStartElement(writer, BAD_CAST "image");
223 if (image->lang && strcmp(DEFAULT_LOCALE, image->lang) != 0) {
224 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
226 BAD_CAST image->lang);
229 xmlTextWriterWriteAttribute(writer, BAD_CAST "section",
230 BAD_CAST image->section);
231 xmlTextWriterEndElement(writer);
234 for (appcontrol_x* appc : GListRange<appcontrol_x*>(app->appcontrol)) {
235 xmlTextWriterStartElement(writer, BAD_CAST "app-control");
237 if (appc->operation) {
238 xmlTextWriterStartElement(writer, BAD_CAST "operation");
239 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
240 BAD_CAST appc->operation);
241 xmlTextWriterEndElement(writer);
245 xmlTextWriterStartElement(writer, BAD_CAST "uri");
246 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
248 xmlTextWriterEndElement(writer);
252 xmlTextWriterStartElement(writer, BAD_CAST "mime");
253 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
254 BAD_CAST appc->mime);
255 xmlTextWriterEndElement(writer);
258 xmlTextWriterEndElement(writer);
261 for (datacontrol_x* datacontrol :
262 GListRange<datacontrol_x*>(app->datacontrol)) {
263 xmlTextWriterStartElement(writer, BAD_CAST "datacontrol");
264 if (datacontrol->access) {
265 xmlTextWriterWriteAttribute(writer, BAD_CAST "access",
266 BAD_CAST datacontrol->access);
268 if (datacontrol->providerid) {
269 xmlTextWriterWriteAttribute(writer, BAD_CAST "providerid",
270 BAD_CAST datacontrol->providerid);
272 if (datacontrol->type) {
273 xmlTextWriterWriteAttribute(writer, BAD_CAST "type",
274 BAD_CAST datacontrol->type);
276 xmlTextWriterEndElement(writer);
279 for (metadata_x* meta : GListRange<metadata_x*>(app->metadata)) {
280 xmlTextWriterStartElement(writer, BAD_CAST "metadata");
281 xmlTextWriterWriteAttribute(writer, BAD_CAST "key",
284 xmlTextWriterWriteAttribute(writer, BAD_CAST "value",
285 BAD_CAST meta->value);
286 xmlTextWriterEndElement(writer);
289 for (const char* category : GListRange<char*>(app->category)) {
290 xmlTextWriterStartElement(writer, BAD_CAST "category");
291 xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST category);
292 xmlTextWriterEndElement(writer);
295 for (const char* background_category : GListRange<char*>(
296 app->background_category)) {
297 xmlTextWriterStartElement(writer, BAD_CAST "background-category");
298 xmlTextWriterWriteAttribute(writer, BAD_CAST "value",
299 BAD_CAST background_category);
300 xmlTextWriterEndElement(writer);
303 return Step::Status::OK;
306 common_installer::Step::Status StepGenerateXml::undo() {
307 bs::error_code error;
308 if (bf::exists(context_->xml_path.get()))
309 bf::remove_all(context_->xml_path.get(), error);
313 common_installer::Step::Status StepGenerateXml::precheck() {
314 if (!context_->manifest_data.get()) {
315 LOG(ERROR) << "manifest_data attribute is empty";
316 return Step::Status::INVALID_VALUE;
318 if (context_->pkgid.get().empty()) {
319 LOG(ERROR) << "pkgid attribute is empty";
320 return Step::Status::PACKAGE_NOT_FOUND;
323 if (!context_->manifest_data.get()->application) {
324 LOG(ERROR) << "No application in package";
325 return Step::Status::INVALID_VALUE;
328 return Step::Status::OK;
331 common_installer::Step::Status StepGenerateXml::process() {
333 bf::path(getUserManifestPath(context_->uid.get(), false))
334 / bf::path(context_->pkgid.get());
336 context_->xml_path.set(xml_path.string());
338 bs::error_code error;
339 if (!bf::exists(xml_path.parent_path(), error)) {
340 if (!common_installer::CreateDir(xml_path.parent_path())) {
342 "Directory for manifest xml is missing and cannot be created";
343 return Status::MANIFEST_ERROR;
347 xmlTextWriterPtr writer;
348 writer = xmlNewTextWriterFilename(context_->xml_path.get().c_str(), 0);
350 LOG(ERROR) << "Failed to create new file";
351 return Step::Status::MANIFEST_ERROR;
354 xmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr);
355 xmlTextWriterSetIndent(writer, 1);
357 Status status = GenerateManifestElement(writer);
358 if (status != Status::OK) {
362 xmlTextWriterEndDocument(writer);
363 xmlFreeTextWriter(writer);
365 if (pkgmgr_parser_check_manifest_validation(
366 context_->xml_path.get().c_str()) != 0) {
367 LOG(ERROR) << "Manifest is not valid";
368 return Step::Status::MANIFEST_ERROR;
371 LOG(DEBUG) << "Successfully create manifest xml "
372 << context_->xml_path.get();
376 common_installer::Step::Status StepGenerateXml::GenerateManifestElement(
377 xmlTextWriterPtr writer) {
378 xmlTextWriterStartElement(writer, BAD_CAST "manifest");
380 GenerateManifestElementAttributes(writer);
381 GenerateLangLabels(writer);
382 GenerateAuthor(writer);
383 GenerateDescription(writer);
384 Status status = GenerateApplications(writer);
385 if (status != Status::OK) {
388 GeneratePrivilege(writer);
389 GenerateAccount(writer);
391 GenerateProfiles(writer);
392 GenerateShortcuts(writer);
394 xmlTextWriterEndElement(writer);
398 void StepGenerateXml::GenerateManifestElementAttributes(
399 xmlTextWriterPtr writer) {
400 xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns",
401 BAD_CAST "http://tizen.org/ns/packages");
402 xmlTextWriterWriteAttribute(writer, BAD_CAST "package",
403 BAD_CAST context_->manifest_data.get()->package);
404 xmlTextWriterWriteAttribute(writer, BAD_CAST "type",
405 BAD_CAST context_->manifest_data.get()->type);
406 xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
407 BAD_CAST context_->manifest_data.get()->version);
408 xmlTextWriterWriteAttribute(writer, BAD_CAST "api-version",
409 BAD_CAST context_->manifest_data.get()->api_version);
410 xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay-setting",
411 BAD_CAST context_->manifest_data.get()->nodisplay_setting);
414 void StepGenerateXml::GenerateLangLabels(xmlTextWriterPtr writer) {
415 for (label_x* label :
416 GListRange<label_x*>(context_->manifest_data.get()->label)) {
417 if (label->name && strcmp(label->name, "") != 0) {
418 xmlTextWriterStartElement(writer, BAD_CAST "label");
419 if (label->lang && strcmp(DEFAULT_LOCALE, label->lang) != 0) {
420 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
421 BAD_CAST label->lang);
423 xmlTextWriterWriteString(writer, BAD_CAST label->name);
424 xmlTextWriterEndElement(writer);
429 void StepGenerateXml::GenerateAuthor(xmlTextWriterPtr writer) {
430 for (author_x* author :
431 GListRange<author_x*>(context_->manifest_data.get()->author)) {
432 xmlTextWriterStartElement(writer, BAD_CAST "author");
433 if (author->email && strlen(author->email)) {
434 xmlTextWriterWriteAttribute(writer, BAD_CAST "email",
435 BAD_CAST author->email);
437 if (author->href && strlen(author->href)) {
438 xmlTextWriterWriteAttribute(writer, BAD_CAST "href",
439 BAD_CAST author->href);
441 xmlTextWriterWriteString(writer, BAD_CAST author->text);
442 xmlTextWriterEndElement(writer);
446 void StepGenerateXml::GenerateDescription(xmlTextWriterPtr writer) {
447 for (description_x* description :
448 GListRange<description_x*>(context_->manifest_data.get()->description)) {
449 xmlTextWriterStartElement(writer, BAD_CAST "description");
450 if (description->lang && strcmp(DEFAULT_LOCALE, description->lang) != 0) {
451 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
452 BAD_CAST description->lang);
454 xmlTextWriterWriteString(writer, BAD_CAST description->text);
455 xmlTextWriterEndElement(writer);
459 common_installer::Step::Status StepGenerateXml::GenerateApplications(
460 xmlTextWriterPtr writer) {
461 for (application_x* app :
462 GListRange<application_x*>(context_->manifest_data.get()->application)) {
464 if (strcmp(app->component_type, "uiapp") == 0) {
465 type = AppCompType::UIAPP;
466 xmlTextWriterStartElement(writer, BAD_CAST "ui-application");
467 } else if (strcmp(app->component_type, "svcapp") == 0) {
468 type = AppCompType::SVCAPP;
469 xmlTextWriterStartElement(writer, BAD_CAST "service-application");
470 } else if (strcmp(app->component_type, "widgetapp") == 0) {
471 type = AppCompType::WIDGETAPP;
472 xmlTextWriterStartElement(writer, BAD_CAST "widget-application");
473 } else if (strcmp(app->component_type, "watchapp") == 0) {
474 type = AppCompType::WATCHAPP;
475 xmlTextWriterStartElement(writer, BAD_CAST "watch-application");
477 LOG(ERROR) << "Unknown application component_type";
478 xmlFreeTextWriter(writer);
479 return Status::ERROR;
481 Status status = GenerateApplicationCommonXml(app, writer, type);
482 if (status != Status::OK) {
483 xmlFreeTextWriter(writer);
486 xmlTextWriterEndElement(writer);
491 void StepGenerateXml::GeneratePrivilege(xmlTextWriterPtr writer) {
492 if (context_->manifest_data.get()->privileges) {
493 xmlTextWriterStartElement(writer, BAD_CAST "privileges");
494 for (const char* priv :
495 GListRange<char*>(context_->manifest_data.get()->privileges)) {
496 xmlTextWriterWriteFormatElement(writer, BAD_CAST "privilege",
497 "%s", BAD_CAST priv);
500 xmlTextWriterEndElement(writer);
504 void StepGenerateXml::GenerateAccount(xmlTextWriterPtr writer) {
505 const auto& accounts =
506 context_->manifest_plugins_data.get().account_info.get().accounts();
507 if (!accounts.empty()) {
508 xmlTextWriterStartElement(writer, BAD_CAST "account");
510 for (auto& account : accounts) {
511 xmlTextWriterStartElement(writer, BAD_CAST "account-provider");
513 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
514 BAD_CAST account.appid.c_str());
516 if (!account.providerid.empty())
517 xmlTextWriterWriteAttribute(writer, BAD_CAST "providerid",
518 BAD_CAST account.providerid.c_str());
520 if (account.multiple_account_support)
521 xmlTextWriterWriteAttribute(writer,
522 BAD_CAST "multiple-accounts-support",
525 xmlTextWriterWriteAttribute(writer,
526 BAD_CAST "multiple-accounts-support",
528 for (auto& icon_pair : account.icon_paths) {
529 xmlTextWriterStartElement(writer, BAD_CAST "icon");
530 if (icon_pair.first == "AccountSmall")
531 xmlTextWriterWriteAttribute(writer, BAD_CAST "section",
532 BAD_CAST "account-small");
534 xmlTextWriterWriteAttribute(writer, BAD_CAST "section",
536 xmlTextWriterWriteString(writer, BAD_CAST icon_pair.second.c_str());
537 xmlTextWriterEndElement(writer);
540 for (auto& name_pair : account.names) {
541 xmlTextWriterStartElement(writer, BAD_CAST "label");
542 if (!name_pair.second.empty())
543 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
544 BAD_CAST name_pair.second.c_str());
545 xmlTextWriterWriteString(writer, BAD_CAST name_pair.first.c_str());
546 xmlTextWriterEndElement(writer);
549 for (auto& capability : account.capabilities) {
550 xmlTextWriterWriteFormatElement(writer, BAD_CAST "capability",
551 "%s", BAD_CAST capability.c_str());
554 xmlTextWriterEndElement(writer);
556 xmlTextWriterEndElement(writer);
560 void StepGenerateXml::GenerateIme(xmlTextWriterPtr writer) {
561 const auto &ime = context_->manifest_plugins_data.get().ime_info.get();
562 const auto ime_uuid = ime.uuid();
563 if (!ime_uuid.empty()) {
564 xmlTextWriterStartElement(writer, BAD_CAST "ime");
566 GListRange<application_x*> app_range(
567 context_->manifest_data.get()->application);
568 if (!app_range.Empty()) {
569 // wgt app have ui-application as first application element.
570 // there may be service-applications but not as first element.
571 application_x* app = *app_range.begin();
572 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
573 BAD_CAST app->appid);
576 xmlTextWriterStartElement(writer, BAD_CAST "uuid");
577 xmlTextWriterWriteString(writer, BAD_CAST ime_uuid.c_str());
578 xmlTextWriterEndElement(writer);
580 xmlTextWriterStartElement(writer, BAD_CAST "languages");
582 for (auto it = ime.LanguagesBegin(); it != ime.LanguagesEnd(); ++it) {
583 xmlTextWriterStartElement(writer, BAD_CAST "language");
584 xmlTextWriterWriteString(writer, BAD_CAST it->c_str());
585 xmlTextWriterEndElement(writer);
588 xmlTextWriterEndElement(writer);
590 xmlTextWriterEndElement(writer);
594 void StepGenerateXml::GenerateProfiles(xmlTextWriterPtr writer) {
595 for (const char* profile :
596 GListRange<char*>(context_->manifest_data.get()->deviceprofile)) {
597 xmlTextWriterStartElement(writer, BAD_CAST "profile");
598 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
600 xmlTextWriterEndElement(writer);
604 void StepGenerateXml::GenerateShortcuts(xmlTextWriterPtr writer) {
605 const auto& shortcuts =
606 context_->manifest_plugins_data.get().shortcut_info.get();
607 if (!shortcuts.empty()) {
608 xmlTextWriterStartElement(writer, BAD_CAST "shortcut-list");
609 for (auto& shortcut : shortcuts) {
610 xmlTextWriterStartElement(writer, BAD_CAST "shortcut");
611 if (!shortcut.app_id.empty())
612 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
613 BAD_CAST shortcut.app_id.c_str());
614 if (!shortcut.app_id.empty())
615 xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_data",
616 BAD_CAST shortcut.extra_data.c_str());
617 if (!shortcut.app_id.empty())
618 xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_key",
619 BAD_CAST shortcut.extra_key.c_str());
620 if (!shortcut.icon.empty()) {
621 xmlTextWriterStartElement(writer, BAD_CAST "icon");
622 xmlTextWriterWriteString(writer, BAD_CAST shortcut.icon.c_str());
623 xmlTextWriterEndElement(writer);
625 for (auto& label : shortcut.labels) {
626 xmlTextWriterStartElement(writer, BAD_CAST "label");
627 if (!label.first.empty())
628 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
629 BAD_CAST label.first.c_str());
630 xmlTextWriterWriteString(writer, BAD_CAST label.second.c_str());
631 xmlTextWriterEndElement(writer);
633 xmlTextWriterEndElement(writer);
635 xmlTextWriterEndElement(writer);
639 } // namespace pkgmgr