From: Lukasz Wysocki Date: Fri, 8 Jan 2016 12:00:06 +0000 (+0100) Subject: Web app icon path change X-Git-Tag: accepted/tizen/mobile/20160115.010738~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F56489%2F5;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git Web app icon path change 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 --- diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index 6bd0300..d1201bb 100644 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -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 index 0000000..c1d63e0 --- /dev/null +++ b/src/wgt/step/step_wgt_backup_icons.cc @@ -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 + +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 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 index 0000000..dc62760 --- /dev/null +++ b/src/wgt/step/step_wgt_backup_icons.h @@ -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 +#include + +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_ diff --git a/src/wgt/step/step_wgt_create_icons.cc b/src/wgt/step/step_wgt_create_icons.cc index 936e3a8..1bd73eb 100644 --- a/src/wgt/step/step_wgt_create_icons.cc +++ b/src/wgt/step/step_wgt_create_icons.cc @@ -4,15 +4,44 @@ #include "wgt/step/step_wgt_create_icons.h" -namespace { +#include -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 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(context_->manifest_data.get()->application)) { + if (app->icon) { + icon_x* icon = reinterpret_cast(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; } diff --git a/src/wgt/step/step_wgt_create_icons.h b/src/wgt/step/step_wgt_create_icons.h index ee71942..a9501a3 100644 --- a/src/wgt/step/step_wgt_create_icons.h +++ b/src/wgt/step/step_wgt_create_icons.h @@ -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 index 0000000..0149b78 --- /dev/null +++ b/src/wgt/step/step_wgt_recover_icons.cc @@ -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 + +namespace { +const char kSharedRes[] = "shared/res"; + +namespace bf = boost::filesystem; +} // namespace + +namespace wgt { +namespace filesystem { + +std::vector 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 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 index 0000000..cf63981 --- /dev/null +++ b/src/wgt/step/step_wgt_recover_icons.h @@ -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 + +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 GetIconsPaths(); + + SCOPE_LOG_TAG(WgtRecoverIcons) +}; + +} // namespace filesystem +} // namespace wgt + +#endif // WGT_STEP_STEP_WGT_RECOVER_ICONS_H_ diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 9d494b9..f2be1cd 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -22,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -52,9 +50,11 @@ #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(); AddStep(); AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -147,7 +147,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -163,7 +163,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep();