X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fwgt%2Fstep%2Ffilesystem%2Fstep_wgt_patch_icons.cc;h=8bc647f49f0821b0d16e3e2145b936158cb43695;hb=129ec147063d4d90fd495c776edba1b6471816d5;hp=c01c1c87639742bae7d6c8b51d476247d3bbf332;hpb=4d8b0f4845ff867b1b94161d1f6da5b392d97741;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git diff --git a/src/wgt/step/filesystem/step_wgt_patch_icons.cc b/src/wgt/step/filesystem/step_wgt_patch_icons.cc index c01c1c8..8bc647f 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,13 @@ 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_->manifest_data.get()->mainapp_id; + 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,39 +67,24 @@ 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."; // create default icon if there is no icon at all bf::path icon_path = common_icon_location / app->appid; icon_path += ".png"; - bf::copy_file(kDefaultIconPath, icon_path, bf::copy_option::overwrite_if_exists, error); + bf::copy_file(kDefaultIconPath, icon_path, + bf::copy_option::overwrite_if_exists, error); if (error) { LOG(ERROR) << "Failed to create default icon for web application"; return Status::ICON_ERROR; } icon_x* icon = reinterpret_cast(calloc(1, sizeof(icon_x))); + if (!icon) + return Status::ICON_ERROR; icon->text = strdup(icon_path.c_str()); icon->lang = strdup(DEFAULT_LOCALE); app->icon = g_list_append(app->icon, icon);