Fix package icon path 82/103382/1 accepted/tizen/3.0/common/20161209.094819 accepted/tizen/3.0/ivi/20161209.001945 accepted/tizen/3.0/mobile/20161209.001856 accepted/tizen/3.0/tv/20161209.001921 accepted/tizen/3.0/wearable/20161209.001932 submit/tizen_3.0/20161208.065808
authorSangyoon Jang <s89.jang@samsung.com>
Thu, 8 Dec 2016 06:29:31 +0000 (15:29 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Thu, 8 Dec 2016 07:32:48 +0000 (16:32 +0900)
It should be under at shared/res for access by other applications.

Change-Id: I1cdb835db681a98ea05987a52b9e55b23d5c8f17
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/wgt/step/filesystem/step_wgt_patch_icons.cc

index ade10df..1a5b3cb 100644 (file)
@@ -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<char*>(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<icon_x*>(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<application_x*>(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<icon_x*>(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<char*>(icon->text));
-        icon->text = strdup(icon_path.c_str());
       }
     } else {
       LOG(INFO) << "Application provides no icon. Using Tizen default icon.";