From 068064e3410b19831e47bba6ff7a27fbd2b67f31 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 8 Dec 2016 15:29:31 +0900 Subject: [PATCH] Fix package icon path It should be under at shared/res for access by other applications. Change-Id: I1cdb835db681a98ea05987a52b9e55b23d5c8f17 Signed-off-by: Sangyoon Jang --- src/wgt/step/filesystem/step_wgt_patch_icons.cc | 53 ++++++++++++++++--------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/src/wgt/step/filesystem/step_wgt_patch_icons.cc b/src/wgt/step/filesystem/step_wgt_patch_icons.cc index ade10df..1a5b3cb 100644 --- a/src/wgt/step/filesystem/step_wgt_patch_icons.cc +++ b/src/wgt/step/filesystem/step_wgt_patch_icons.cc @@ -17,6 +17,33 @@ namespace { const char kDefaultIconPath[] = "/usr/share/wgt-backend/default.png"; +bool PatchIcon(icon_x* icon, const bf::path& dst_path) { + bs::error_code error; + bf::path icon_text(icon->text); + bf::path icon_path = dst_path; + if (strcmp(icon->lang, DEFAULT_LOCALE)) { + icon_path += "."; + icon_path += icon->lang; + } + if (icon_text.has_extension()) + icon_path += icon_text.extension(); + else + icon_path += ".png"; + + bf::copy_file(icon->text, icon_path, + bf::copy_option::overwrite_if_exists, error); + if (error) { + LOG(ERROR) << "Failed to move icon from " << icon->text << " to " + << icon_path; + return false; + } + if (icon->text) + free(const_cast(icon->text)); + icon->text = strdup(icon_path.c_str()); + + return true; +} + } // namespace namespace wgt { @@ -26,6 +53,12 @@ common_installer::Step::Status StepWgtPatchIcons::process() { bf::path common_icon_location = context_->pkg_path.get() / "shared" / "res"; bs::error_code error; bf::create_directories(common_icon_location, error); + for (icon_x* icon : + GListRange(context_->manifest_data.get()->icon)) { + bf::path icon_path = common_icon_location / context_->pkgid.get(); + if (!PatchIcon(icon, icon_path)) + return Status::ICON_ERROR; + } for (application_x* app : GListRange(context_->manifest_data.get()->application)) { if (strcmp(app->type, "webapp") != 0) @@ -33,27 +66,9 @@ common_installer::Step::Status StepWgtPatchIcons::process() { if (app->icon) { // edit icon->text and copy icons to common location for (auto& icon : GListRange(app->icon)) { - bf::path icon_text(icon->text); bf::path icon_path = common_icon_location / app->appid; - if (strcmp(icon->lang, DEFAULT_LOCALE)) { - icon_path += "."; - icon_path += icon->lang; - } - if (icon_text.has_extension()) - icon_path += icon_text.extension(); - else - icon_path += ".png"; - - bf::copy_file(icon->text, icon_path, - bf::copy_option::overwrite_if_exists, error); - if (error) { - LOG(ERROR) << "Failed to move icon from " << icon->text << " to " - << icon_path; + if (!PatchIcon(icon, icon_path)) return Status::ICON_ERROR; - } - if (icon->text) - free(const_cast(icon->text)); - icon->text = strdup(icon_path.c_str()); } } else { LOG(INFO) << "Application provides no icon. Using Tizen default icon."; -- 2.7.4