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 // Generate attributes and elements not covered in manifest.xsd
99 auto& appwidgets = widget_info.app_widgets();
100 const auto& appwidget = std::find_if(appwidgets.begin(), appwidgets.end(),
101 [app](const wgt::parse::AppWidget& widget) {
102 return widget.id == app->appid;
104 if (appwidget == appwidgets.end()) {
105 LOG(ERROR) << "Failed to generate appwidget extra elements";
109 xmlTextWriterWriteAttribute(writer, BAD_CAST "main",
110 BAD_CAST (appwidget->primary ? "true" : "false")); // NOLINT
111 if (!appwidget->update_period.empty()) {
112 xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST
113 std::to_string(static_cast<int>(
114 appwidget->update_period.front())).c_str());
117 xmlTextWriterWriteAttribute(writer, BAD_CAST "max-instance",
118 BAD_CAST std::to_string(appwidget->max_instance).c_str());
120 for (auto& size : appwidget->content_size) {
121 xmlTextWriterStartElement(writer, BAD_CAST "support-size");
123 std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type);
124 if (!size.preview.empty()) {
125 std::string icon_name = shared_path.string() + "/"
126 + appwidget->id + "." + type + "." + "preview" +
127 bf::path(size.preview).extension().string();
128 xmlTextWriterWriteAttribute(writer, BAD_CAST "preview",
129 BAD_CAST icon_name.c_str()); // NOLINT
132 xmlTextWriterWriteAttribute(writer, BAD_CAST "frame",
134 xmlTextWriterWriteString(writer,
135 BAD_CAST type.c_str());
136 xmlTextWriterEndElement(writer);
139 for (auto& pair : appwidget->metadata) {
140 xmlTextWriterStartElement(writer, BAD_CAST "metadata");
141 xmlTextWriterWriteAttribute(writer, BAD_CAST "key",
142 BAD_CAST pair.first.c_str());
143 if (!pair.second.empty())
144 xmlTextWriterWriteAttribute(writer, BAD_CAST "value",
145 BAD_CAST pair.second.c_str());
146 xmlTextWriterEndElement(writer);
151 void WriteWatchApplicationAttributes(
152 xmlTextWriterPtr writer, application_x* app) {
153 if (app->ambient_support)
154 xmlTextWriterWriteAttribute(writer, BAD_CAST "ambient-support",
155 BAD_CAST app->ambient_support);
163 common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml(
164 application_x* app, xmlTextWriterPtr writer, AppCompType type) {
165 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", BAD_CAST app->appid);
167 // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
168 bf::path exec_path = context_->pkg_path.get()
169 / bf::path("bin") / bf::path(app->appid);
170 xmlTextWriterWriteAttribute(writer, BAD_CAST "exec",
171 BAD_CAST exec_path.string().c_str());
173 xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST app->type);
175 xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST "capp");
177 if (app->process_pool && strlen(app->process_pool))
178 xmlTextWriterWriteAttribute(writer, BAD_CAST "process-pool",
179 BAD_CAST app->process_pool);
180 // app-specific attributes
182 case AppCompType::UIAPP:
183 WriteUIApplicationAttributes(writer, app);
185 case AppCompType::SVCAPP:
186 WriteServiceApplicationAttributes(writer, app);
188 case AppCompType::WIDGETAPP:
189 if (!WriteWidgetApplicationAttributesAndElements(writer, app,
190 static_cast<WgtBackendData*>(
191 context_->backend_data.get())->appwidgets.get(),
192 context_->pkg_path.get() / "shared" / "res"))
193 return Status::MANIFEST_ERROR;
195 case AppCompType::WATCHAPP:
196 WriteWatchApplicationAttributes(writer, app);
200 for (label_x* label : GListRange<label_x*>(app->label)) {
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 icon_x* iconx = reinterpret_cast<icon_x*>(app->icon->data);
212 xmlTextWriterWriteFormatElement(
213 writer, BAD_CAST "icon", "%s", BAD_CAST iconx->text);
215 // Default icon setting is role of the platform
216 LOG(DEBUG) << "Icon was not found in application";
219 for (image_x* image : GListRange<image_x*>(app->image)) {
220 xmlTextWriterStartElement(writer, BAD_CAST "image");
221 if (image->lang && strcmp(DEFAULT_LOCALE, image->lang) != 0) {
222 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
224 BAD_CAST image->lang);
227 xmlTextWriterWriteAttribute(writer, BAD_CAST "section",
228 BAD_CAST image->section);
229 xmlTextWriterEndElement(writer);
232 for (appcontrol_x* appc : GListRange<appcontrol_x*>(app->appcontrol)) {
233 xmlTextWriterStartElement(writer, BAD_CAST "app-control");
235 if (appc->operation) {
236 xmlTextWriterStartElement(writer, BAD_CAST "operation");
237 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
238 BAD_CAST appc->operation);
239 xmlTextWriterEndElement(writer);
243 xmlTextWriterStartElement(writer, BAD_CAST "uri");
244 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
246 xmlTextWriterEndElement(writer);
250 xmlTextWriterStartElement(writer, BAD_CAST "mime");
251 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
252 BAD_CAST appc->mime);
253 xmlTextWriterEndElement(writer);
256 xmlTextWriterEndElement(writer);
259 for (datacontrol_x* datacontrol :
260 GListRange<datacontrol_x*>(app->datacontrol)) {
261 xmlTextWriterStartElement(writer, BAD_CAST "datacontrol");
262 if (datacontrol->access) {
263 xmlTextWriterWriteAttribute(writer, BAD_CAST "access",
264 BAD_CAST datacontrol->access);
266 if (datacontrol->providerid) {
267 xmlTextWriterWriteAttribute(writer, BAD_CAST "providerid",
268 BAD_CAST datacontrol->providerid);
270 if (datacontrol->type) {
271 xmlTextWriterWriteAttribute(writer, BAD_CAST "type",
272 BAD_CAST datacontrol->type);
274 xmlTextWriterEndElement(writer);
277 for (metadata_x* meta : GListRange<metadata_x*>(app->metadata)) {
278 xmlTextWriterStartElement(writer, BAD_CAST "metadata");
279 xmlTextWriterWriteAttribute(writer, BAD_CAST "key",
282 xmlTextWriterWriteAttribute(writer, BAD_CAST "value",
283 BAD_CAST meta->value);
284 xmlTextWriterEndElement(writer);
287 for (const char* category : GListRange<char*>(app->category)) {
288 xmlTextWriterStartElement(writer, BAD_CAST "category");
289 xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST category);
290 xmlTextWriterEndElement(writer);
293 for (const char* background_category : GListRange<char*>(
294 app->background_category)) {
295 xmlTextWriterStartElement(writer, BAD_CAST "background-category");
296 xmlTextWriterWriteAttribute(writer, BAD_CAST "value",
297 BAD_CAST background_category);
298 xmlTextWriterEndElement(writer);
301 return Step::Status::OK;
304 common_installer::Step::Status StepGenerateXml::undo() {
305 bs::error_code error;
306 if (bf::exists(context_->xml_path.get()))
307 bf::remove_all(context_->xml_path.get(), error);
311 common_installer::Step::Status StepGenerateXml::precheck() {
312 if (!context_->manifest_data.get()) {
313 LOG(ERROR) << "manifest_data attribute is empty";
314 return Step::Status::INVALID_VALUE;
316 if (context_->pkgid.get().empty()) {
317 LOG(ERROR) << "pkgid attribute is empty";
318 return Step::Status::PACKAGE_NOT_FOUND;
321 if (!context_->manifest_data.get()->application) {
322 LOG(ERROR) << "No application in package";
323 return Step::Status::INVALID_VALUE;
325 // TODO(p.sikorski) check context_->uid.get()
327 return Step::Status::OK;
330 common_installer::Step::Status StepGenerateXml::process() {
332 bf::path(getUserManifestPath(context_->uid.get(), false))
333 / bf::path(context_->pkgid.get());
335 context_->xml_path.set(xml_path.string());
337 bs::error_code error;
338 if (!bf::exists(xml_path.parent_path(), error)) {
339 if (!common_installer::CreateDir(xml_path.parent_path())) {
341 "Directory for manifest xml is missing and cannot be created";
342 return Status::MANIFEST_ERROR;
346 xmlTextWriterPtr writer;
347 writer = xmlNewTextWriterFilename(context_->xml_path.get().c_str(), 0);
349 LOG(ERROR) << "Failed to create new file";
350 return Step::Status::MANIFEST_ERROR;
353 xmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr);
354 xmlTextWriterSetIndent(writer, 1);
356 Status status = GenerateManifestElement(writer);
357 if (status != Status::OK) {
361 xmlTextWriterEndDocument(writer);
362 xmlFreeTextWriter(writer);
364 if (pkgmgr_parser_check_manifest_validation(
365 context_->xml_path.get().c_str()) != 0) {
366 LOG(ERROR) << "Manifest is not valid";
367 return Step::Status::MANIFEST_ERROR;
370 LOG(DEBUG) << "Successfully create manifest xml "
371 << context_->xml_path.get();
375 common_installer::Step::Status StepGenerateXml::GenerateManifestElement(
376 xmlTextWriterPtr writer) {
377 xmlTextWriterStartElement(writer, BAD_CAST "manifest");
379 GenerateManifestElementAttributes(writer);
380 GenerateLangLabels(writer);
381 GenerateAuthor(writer);
382 GenerateDescription(writer);
383 Status status = GenerateApplications(writer);
384 if (status != Status::OK) {
387 GeneratePrivilege(writer);
388 GenerateAccount(writer);
390 GenerateProfiles(writer);
391 GenerateShortcuts(writer);
393 xmlTextWriterEndElement(writer);
397 void StepGenerateXml::GenerateManifestElementAttributes(
398 xmlTextWriterPtr writer) {
399 xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns",
400 BAD_CAST "http://tizen.org/ns/packages");
401 xmlTextWriterWriteAttribute(writer, BAD_CAST "package",
402 BAD_CAST context_->manifest_data.get()->package);
403 xmlTextWriterWriteAttribute(writer, BAD_CAST "type",
404 BAD_CAST context_->manifest_data.get()->type);
405 xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
406 BAD_CAST context_->manifest_data.get()->version);
407 xmlTextWriterWriteAttribute(writer, BAD_CAST "api-version",
408 BAD_CAST context_->manifest_data.get()->api_version);
409 xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay-setting",
410 BAD_CAST context_->manifest_data.get()->nodisplay_setting);
413 void StepGenerateXml::GenerateLangLabels(xmlTextWriterPtr writer) {
414 for (label_x* label :
415 GListRange<label_x*>(context_->manifest_data.get()->label)) {
416 xmlTextWriterStartElement(writer, BAD_CAST "label");
417 if (label->lang && strcmp(DEFAULT_LOCALE, label->lang) != 0) {
418 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
419 BAD_CAST label->lang);
421 xmlTextWriterWriteString(writer, BAD_CAST label->name);
422 xmlTextWriterEndElement(writer);
426 void StepGenerateXml::GenerateAuthor(xmlTextWriterPtr writer) {
427 for (author_x* author :
428 GListRange<author_x*>(context_->manifest_data.get()->author)) {
429 xmlTextWriterStartElement(writer, BAD_CAST "author");
430 if (author->email && strlen(author->email)) {
431 xmlTextWriterWriteAttribute(writer, BAD_CAST "email",
432 BAD_CAST author->email);
434 if (author->href && strlen(author->href)) {
435 xmlTextWriterWriteAttribute(writer, BAD_CAST "href",
436 BAD_CAST author->href);
438 xmlTextWriterWriteString(writer, BAD_CAST author->text);
439 xmlTextWriterEndElement(writer);
443 void StepGenerateXml::GenerateDescription(xmlTextWriterPtr writer) {
444 for (description_x* description :
445 GListRange<description_x*>(context_->manifest_data.get()->description)) {
446 xmlTextWriterStartElement(writer, BAD_CAST "description");
447 if (description->lang && strcmp(DEFAULT_LOCALE, description->lang) != 0) {
448 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
449 BAD_CAST description->lang);
451 xmlTextWriterWriteString(writer, BAD_CAST description->text);
452 xmlTextWriterEndElement(writer);
456 common_installer::Step::Status StepGenerateXml::GenerateApplications(
457 xmlTextWriterPtr writer) {
458 for (application_x* app :
459 GListRange<application_x*>(context_->manifest_data.get()->application)) {
461 if (strcmp(app->component_type, "uiapp") == 0) {
462 type = AppCompType::UIAPP;
463 xmlTextWriterStartElement(writer, BAD_CAST "ui-application");
464 } else if (strcmp(app->component_type, "svcapp") == 0) {
465 type = AppCompType::SVCAPP;
466 xmlTextWriterStartElement(writer, BAD_CAST "service-application");
467 } else if (strcmp(app->component_type, "widgetapp") == 0) {
468 type = AppCompType::WIDGETAPP;
469 xmlTextWriterStartElement(writer, BAD_CAST "widget-application");
470 } else if (strcmp(app->component_type, "watchapp") == 0) {
471 type = AppCompType::WATCHAPP;
472 xmlTextWriterStartElement(writer, BAD_CAST "watch-application");
474 LOG(ERROR) << "Unknown application component_type";
475 xmlFreeTextWriter(writer);
476 return Status::ERROR;
478 Status status = GenerateApplicationCommonXml(app, writer, type);
479 if (status != Status::OK) {
480 xmlFreeTextWriter(writer);
483 xmlTextWriterEndElement(writer);
488 void StepGenerateXml::GeneratePrivilege(xmlTextWriterPtr writer) {
489 if (context_->manifest_data.get()->privileges) {
490 xmlTextWriterStartElement(writer, BAD_CAST "privileges");
491 for (const char* priv :
492 GListRange<char*>(context_->manifest_data.get()->privileges)) {
493 xmlTextWriterWriteFormatElement(writer, BAD_CAST "privilege",
494 "%s", BAD_CAST priv);
497 xmlTextWriterEndElement(writer);
501 void StepGenerateXml::GenerateAccount(xmlTextWriterPtr writer) {
502 const auto& accounts =
503 context_->manifest_plugins_data.get().account_info.get().accounts();
504 if (!accounts.empty()) {
505 xmlTextWriterStartElement(writer, BAD_CAST "account");
507 for (auto& account : accounts) {
508 xmlTextWriterStartElement(writer, BAD_CAST "account-provider");
510 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
511 BAD_CAST account.appid.c_str());
513 if (!account.providerid.empty())
514 xmlTextWriterWriteAttribute(writer, BAD_CAST "providerid",
515 BAD_CAST account.providerid.c_str());
517 if (account.multiple_account_support)
518 xmlTextWriterWriteAttribute(writer,
519 BAD_CAST "multiple-accounts-support",
522 xmlTextWriterWriteAttribute(writer,
523 BAD_CAST "multiple-accounts-support",
525 for (auto& icon_pair : account.icon_paths) {
526 xmlTextWriterStartElement(writer, BAD_CAST "icon");
527 if (icon_pair.first == "AccountSmall")
528 xmlTextWriterWriteAttribute(writer, BAD_CAST "section",
529 BAD_CAST "account-small");
531 xmlTextWriterWriteAttribute(writer, BAD_CAST "section",
533 xmlTextWriterWriteString(writer, BAD_CAST icon_pair.second.c_str());
534 xmlTextWriterEndElement(writer);
537 for (auto& name_pair : account.names) {
538 xmlTextWriterStartElement(writer, BAD_CAST "label");
539 if (!name_pair.second.empty())
540 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
541 BAD_CAST name_pair.second.c_str());
542 xmlTextWriterWriteString(writer, BAD_CAST name_pair.first.c_str());
543 xmlTextWriterEndElement(writer);
546 for (auto& capability : account.capabilities) {
547 xmlTextWriterWriteFormatElement(writer, BAD_CAST "capability",
548 "%s", BAD_CAST capability.c_str());
551 xmlTextWriterEndElement(writer);
553 xmlTextWriterEndElement(writer);
557 void StepGenerateXml::GenerateIme(xmlTextWriterPtr writer) {
558 const auto &ime = context_->manifest_plugins_data.get().ime_info.get();
559 const auto ime_uuid = ime.uuid();
560 if (!ime_uuid.empty()) {
561 xmlTextWriterStartElement(writer, BAD_CAST "ime");
563 GListRange<application_x*> app_range(
564 context_->manifest_data.get()->application);
565 if (!app_range.Empty()) {
566 // wgt app have ui-application as first application element.
567 // there may be service-applications but not as first element.
568 application_x* app = *app_range.begin();
569 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
570 BAD_CAST app->appid);
573 xmlTextWriterStartElement(writer, BAD_CAST "uuid");
574 xmlTextWriterWriteString(writer, BAD_CAST ime_uuid.c_str());
575 xmlTextWriterEndElement(writer);
577 xmlTextWriterStartElement(writer, BAD_CAST "languages");
579 for (auto it = ime.LanguagesBegin(); it != ime.LanguagesEnd(); ++it) {
580 xmlTextWriterStartElement(writer, BAD_CAST "language");
581 xmlTextWriterWriteString(writer, BAD_CAST it->c_str());
582 xmlTextWriterEndElement(writer);
585 xmlTextWriterEndElement(writer);
587 xmlTextWriterEndElement(writer);
591 void StepGenerateXml::GenerateProfiles(xmlTextWriterPtr writer) {
592 for (const char* profile :
593 GListRange<char*>(context_->manifest_data.get()->deviceprofile)) {
594 xmlTextWriterStartElement(writer, BAD_CAST "profile");
595 xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
597 xmlTextWriterEndElement(writer);
601 void StepGenerateXml::GenerateShortcuts(xmlTextWriterPtr writer) {
602 const auto& shortcuts =
603 context_->manifest_plugins_data.get().shortcut_info.get();
604 if (!shortcuts.empty()) {
605 xmlTextWriterStartElement(writer, BAD_CAST "shortcut-list");
606 for (auto& shortcut : shortcuts) {
607 xmlTextWriterStartElement(writer, BAD_CAST "shortcut");
608 if (!shortcut.app_id.empty())
609 xmlTextWriterWriteAttribute(writer, BAD_CAST "appid",
610 BAD_CAST shortcut.app_id.c_str());
611 if (!shortcut.app_id.empty())
612 xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_data",
613 BAD_CAST shortcut.extra_data.c_str());
614 if (!shortcut.app_id.empty())
615 xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_key",
616 BAD_CAST shortcut.extra_key.c_str());
617 if (!shortcut.icon.empty()) {
618 xmlTextWriterStartElement(writer, BAD_CAST "icon");
619 xmlTextWriterWriteString(writer, BAD_CAST shortcut.icon.c_str());
620 xmlTextWriterEndElement(writer);
622 for (auto& label : shortcut.labels) {
623 xmlTextWriterStartElement(writer, BAD_CAST "label");
624 if (!label.first.empty())
625 xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
626 BAD_CAST label.first.c_str());
627 xmlTextWriterWriteString(writer, BAD_CAST label.second.c_str());
628 xmlTextWriterEndElement(writer);
630 xmlTextWriterEndElement(writer);
632 xmlTextWriterEndElement(writer);
636 } // namespace pkgmgr