Web app icon path change 89/56489/5
authorLukasz Wysocki <l.wysocki@samsung.com>
Fri, 8 Jan 2016 12:00:06 +0000 (13:00 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Thu, 14 Jan 2016 13:02:52 +0000 (05:02 -0800)
This change will copy Web app icons into {HOME}/.applications/icons
, and {APP_ROOT}/shared/res directories

When some projects will be changed and stop using {HOME} directory,
this change can be reworked.

This commit require following changes:
- https://review.tizen.org/gerrit/#/c/56488/

Change-Id: I9343adf5af1228a0b8ee660f50012eb7ac9b3bee

src/wgt/CMakeLists.txt
src/wgt/step/step_wgt_backup_icons.cc [new file with mode: 0644]
src/wgt/step/step_wgt_backup_icons.h [new file with mode: 0644]
src/wgt/step/step_wgt_create_icons.cc
src/wgt/step/step_wgt_create_icons.h
src/wgt/step/step_wgt_recover_icons.cc [new file with mode: 0644]
src/wgt/step/step_wgt_recover_icons.h [new file with mode: 0644]
src/wgt/wgt_installer.cc

index 6bd0300acf585d00782d9d3441f71e5f9eb64042..d1201bb7378582465c619557c573107ef3d3a960 100644 (file)
@@ -11,9 +11,11 @@ SET(SRCS
   step/step_parse_recovery.cc
   step/step_rds_parse.cc
   step/step_rds_modify.cc
+  step/step_wgt_backup_icons.cc
   step/step_wgt_create_icons.cc
   step/step_wgt_create_storage_directories.cc
   step/step_wgt_copy_storage_directories.cc
+  step/step_wgt_recover_icons.cc
   step/step_wgt_resource_directory.cc
   step/step_add_default_privileges.cc
   wgt_app_query_interface.cc
diff --git a/src/wgt/step/step_wgt_backup_icons.cc b/src/wgt/step/step_wgt_backup_icons.cc
new file mode 100644 (file)
index 0000000..c1d63e0
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/step/step_wgt_backup_icons.h"
+
+#include <pkgmgr-info.h>
+
+namespace {
+const char kSharedRes[] = "shared/res";
+
+namespace bf = boost::filesystem;
+}  // namespace
+
+namespace wgt {
+namespace backup {
+
+common_installer::Step::Status StepWgtBackupIcons::process() {
+  // TODO (l.wysocki): As a temporary solution this will move icons into two
+  // destinations respectively {HOME}/.applications/icons,
+  // and {APP_ROOT}/shared/res, when some project will stop using old
+  // location ({HOME}/.applications/icons) then it can be removed from here.
+  std::vector<bf::path> paths { getIconPath(context_->uid.get()),
+                                context_->root_application_path.get()
+                                / context_->pkgid.get() / kSharedRes };
+  return MoveIcons(paths);
+}
+
+}  // namespace backup
+}  // namespace wgt
diff --git a/src/wgt/step/step_wgt_backup_icons.h b/src/wgt/step/step_wgt_backup_icons.h
new file mode 100644 (file)
index 0000000..dc62760
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_STEP_STEP_WGT_BACKUP_ICONS_H_
+#define WGT_STEP_STEP_WGT_BACKUP_ICONS_H_
+
+#include <common/step/step_backup_icons.h>
+#include <manifest_parser/utils/logging.h>
+
+namespace wgt {
+namespace backup {
+
+/**
+ *\brief Step responsible for creating backup for icons during update and
+ *       uninstallation.
+ *       Used by WGT backend
+ */
+class StepWgtBackupIcons : public common_installer::backup::StepBackupIcons {
+ public:
+  using StepBackupIcons::StepBackupIcons;
+
+  /**
+   * \brief main logic of backuping icons
+   *
+   * \return Status::OK, if successful backup, Status::ERROR otherwise
+   */
+  Status process() override;
+
+  SCOPE_LOG_TAG(WgtBackupIcons)
+};
+
+}  // namespace backup
+}  // namespace wgt
+
+#endif  // WGT_STEP_STEP_WGT_BACKUP_ICONS_H_
index 936e3a80e7a5b038317efa5b509a88ac42f2fcae..1bd73eb153b64569dc16aaaf5564c961b99bd3f5 100644 (file)
@@ -4,15 +4,44 @@
 
 #include "wgt/step/step_wgt_create_icons.h"
 
-namespace {
+#include <pkgmgr-info.h>
 
-const char kResWgt[] = "res/wgt";
+#include "common/utils/glist_range.h"
 
-}
+namespace bf = boost::filesystem;
+namespace ci = common_installer;
+
+namespace {
+const char kResWgt[] = "res/wgt";
+}  // namespace
 
 namespace wgt {
 namespace filesystem {
 
+common_installer::Step::Status StepWgtCreateIcons::process() {
+  // TODO (l.wysocki): As a temporary solution this will copy icons into two
+  // destinations respectively {HOME}/.applications/icons,
+  // and {APP_ROOT}/shared/res, when some project will stop using old
+  // location ({HOME}/.applications/icons) then it can be removed from here.
+  std::vector<bf::path> paths { getIconPath(context_->uid.get()),
+                                StepCreateIcons::GetIconRoot() };
+
+  // explicit step for wgt apps to add absolute path to icon in order to
+  // store it in db
+  ci::Step::Status result = CopyIcons(paths);
+  for (application_x* app :
+      GListRange<application_x*>(context_->manifest_data.get()->application)) {
+    if (app->icon) {
+      icon_x* icon = reinterpret_cast<icon_x*>(app->icon->data);
+      bf::path icon_path = StepCreateIcons::GetIconRoot() / icon->text;
+      if (icon->text)
+        free((void *)icon->text);
+      icon->text = strdup(icon_path.c_str());
+    }
+  }
+  return result;
+}
+
 boost::filesystem::path StepWgtCreateIcons::GetIconRoot() const {
   return context_->pkg_path.get() / kResWgt;
 }
index ee71942ae83a8401b3c5dbbd2c33dd956f5d4b9d..a9501a32090e68e176cc0f97c2f18bc569e3238f 100644 (file)
@@ -22,6 +22,8 @@ class StepWgtCreateIcons
  public:
   using StepCreateIcons::StepCreateIcons;
 
+  Status process() override;
+
   /**
    * \brief Return path to widget icon
    *
diff --git a/src/wgt/step/step_wgt_recover_icons.cc b/src/wgt/step/step_wgt_recover_icons.cc
new file mode 100644 (file)
index 0000000..0149b78
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/step/step_wgt_recover_icons.h"
+
+#include <pkgmgr-info.h>
+
+namespace {
+const char kSharedRes[] = "shared/res";
+
+namespace bf = boost::filesystem;
+}  // namespace
+
+namespace wgt {
+namespace filesystem {
+
+std::vector<boost::filesystem::path> StepWgtRecoverIcons::GetIconsPaths() {
+  // TODO (l.wysocki): As a temporary solution this will move icons into two
+  // destinations respectively {HOME}/.applications/icons,
+  // and {APP_ROOT}/shared/res, when some project will stop using old
+  // location ({HOME}/.applications/icons) then it can be removed from here.
+  std::vector<bf::path> paths { bf::path(getIconPath(context_->uid.get())),
+                                context_->root_application_path.get()
+                                / context_->pkgid.get() / kSharedRes };
+  return paths;
+}
+
+}  // namespace filesystem
+}  // namespace wgt
+
diff --git a/src/wgt/step/step_wgt_recover_icons.h b/src/wgt/step/step_wgt_recover_icons.h
new file mode 100644 (file)
index 0000000..cf63981
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_STEP_STEP_WGT_RECOVER_ICONS_H_
+#define WGT_STEP_STEP_WGT_RECOVER_ICONS_H_
+
+#include <common/step/step_recover_icons.h>
+
+namespace wgt {
+namespace filesystem {
+
+/**
+ * @brief The StepRecoverIcons class
+ *        Fixes state of platform icon files in recovery mode.
+ *
+ * For recovery of new installation, all icons files are removed.
+ * For recovery of update installation, all icons of applications of package are
+ * restored to its previous locations.
+ */
+class StepWgtRecoverIcons :
+    public common_installer::filesystem::StepRecoverIcons {
+ public:
+  using StepRecoverIcons::StepRecoverIcons;
+
+ protected:
+  virtual std::vector<boost::filesystem::path> GetIconsPaths();
+
+  SCOPE_LOG_TAG(WgtRecoverIcons)
+};
+
+}  // namespace filesystem
+}  // namespace wgt
+
+#endif  // WGT_STEP_STEP_WGT_RECOVER_ICONS_H_
index 9d494b9e286cca1823d9f174d7a554cb7248caad..f2be1cd6fc7513b380592574550429f754eb1193 100644 (file)
@@ -9,7 +9,6 @@
 #include <common/pkgmgr_interface.h>
 #include <common/step/step_configure.h>
 #include <common/step/step_backup_manifest.h>
-#include <common/step/step_backup_icons.h>
 #include <common/step/step_copy.h>
 #include <common/step/step_copy_backup.h>
 #include <common/step/step_copy_storage_directories.h>
@@ -22,7 +21,6 @@
 #include <common/step/step_register_app.h>
 #include <common/step/step_recover_application.h>
 #include <common/step/step_recover_files.h>
-#include <common/step/step_recover_icons.h>
 #include <common/step/step_recover_manifest.h>
 #include <common/step/step_recover_security.h>
 #include <common/step/step_recover_storage_directories.h>
 #include "wgt/step/step_rds_modify.h"
 #include "wgt/step/step_rds_parse.h"
 #include "wgt/step/step_remove_encryption_data.h"
+#include "wgt/step/step_wgt_backup_icons.h"
 #include "wgt/step/step_wgt_copy_storage_directories.h"
 #include "wgt/step/step_wgt_create_icons.h"
 #include "wgt/step/step_wgt_create_storage_directories.h"
+#include "wgt/step/step_wgt_recover_icons.h"
 #include "wgt/step/step_wgt_resource_directory.h"
 
 namespace ci = common_installer;
@@ -98,7 +98,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::backup::StepOldManifest>();
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::backup::StepBackupManifest>();
-      AddStep<ci::backup::StepBackupIcons>();
+      AddStep<wgt::backup::StepWgtBackupIcons>();
       AddStep<ci::backup::StepCopyBackup>();
       AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
@@ -147,7 +147,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::backup::StepOldManifest>();
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::backup::StepBackupManifest>();
-      AddStep<ci::backup::StepBackupIcons>();
+      AddStep<wgt::backup::StepWgtBackupIcons>();
       AddStep<ci::backup::StepCopyBackup>();
       AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
@@ -163,7 +163,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<wgt::parse::StepParseRecovery>();
       AddStep<ci::pkgmgr::StepRecoverApplication>();
       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
-      AddStep<ci::filesystem::StepRecoverIcons>();
+      AddStep<wgt::filesystem::StepWgtRecoverIcons>();
       AddStep<ci::filesystem::StepRecoverManifest>();
       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
       AddStep<ci::filesystem::StepRecoverFiles>();