Fix issues with icon 78/36378/2
authorJakub Izydorczyk <j.izydorczyk@samsung.com>
Thu, 5 Mar 2015 08:51:24 +0000 (09:51 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Mon, 9 Mar 2015 10:54:04 +0000 (03:54 -0700)
Fix generation of xml manifest when there is no icon defined in
config.xml. Fix checking if icon exists during fill manifest_x
structure.

Change-Id: I1c1700fc7918eb16a6c94fde77bf5b33818208d5

src/common/step/step_generate_xml.cc
src/widget-manifest-parser/widget_manifest_parser.cc

index e5bee00..2d5feb7 100644 (file)
@@ -41,8 +41,13 @@ Step::Status StepGenerateXml::process() {
     return Step::Status::ERROR;
   }
 
-  fs::path default_icon(
-      tzplatform_mkpath(TZ_SYS_RW_ICONS, "app-installers.png"));
+  const char* path = nullptr;
+  if (!(path = tzplatform_mkpath(TZ_SYS_RW_ICONS, "app-installers.png"))) {
+    LOG(ERROR) << "Internal error of tzplatform config."
+                  "Failed to concatenate path.";
+    return Step::Status::ERROR;
+  }
+  fs::path default_icon(path);
 
   xmlTextWriterPtr writer;
 
@@ -106,12 +111,14 @@ Step::Status StepGenerateXml::process() {
     // if the icon isn't exist print the default icon app-installers.png
     icon_path_ = fs::path(getIconPath(context_->uid()));
     utils::CreateDir(icon_path_);
+
     fs::path icon = fs::path(ui->appid) += fs::path(".png");
 
-    fs::path app_icon = fs::path(context_->pkg_path()) / fs::path(ui->appid)
+    if (ui->icon->name) {
+      fs::path app_icon = fs::path(context_->pkg_path()) / fs::path(ui->appid)
         / fs::path(ui->icon->name);
-    if (fs::exists(app_icon)) {
-      fs::rename(app_icon, icon_path_ /= icon);
+      if (fs::exists(app_icon))
+        fs::rename(app_icon, icon_path_ /= icon);
     } else {
       fs::create_symlink(default_icon, icon_path_ /= icon, error);
       LOG(DEBUG) << "Icon is not found in package, the default icon is setting";
@@ -171,10 +178,11 @@ Step::Status StepGenerateXml::process() {
     utils::CreateDir(icon_path_);
     fs::path icon = fs::path(svc->appid) += fs::path(".png");
 
-    fs::path app_icon = fs::path(context_->pkg_path()) / fs::path(svc->appid)
-        / fs::path(svc->icon->name);
-    if (fs::exists(app_icon)) {
-      fs::rename(app_icon, icon_path_ /= icon);
+    if (svc->icon->name) {
+      fs::path app_icon = fs::path(context_->pkg_path()) / fs::path(svc->appid)
+          / fs::path(svc->icon->name);
+      if (fs::exists(app_icon))
+        fs::rename(app_icon, icon_path_ /= icon);
     } else {
       fs::rename(default_icon, icon_path_ /= icon);
       LOG(DEBUG) << "Icon is not found in package, the default icon is setting";
index 432a9d8..24987e5 100644 (file)
@@ -160,7 +160,8 @@ bool WidgetManifestParser::FillManifestX(manifest_x* manifest) {
 
   manifest->uiapplication->icon =
       reinterpret_cast<icon_x*> (calloc(1, sizeof(icon_x)));
-  manifest->uiapplication->icon->name = strdup(manifest->icon->name);
+  if (manifest->icon)
+    manifest->uiapplication->icon->name = strdup(manifest->icon->name);
   manifest->uiapplication->next = nullptr;
   return true;
 }