From a6cda6b51858478647b9bc394c39b5664657d36a Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Thu, 6 Aug 2015 10:40:17 +0200 Subject: [PATCH] Introduce WgtInstaller class Change-Id: Ic54c461319df0ca063a1e02de830c988329608a1 --- src/common/CMakeLists.txt | 1 + src/common/step/step_fail.cc | 16 ++++++ src/common/step/step_fail.h | 31 ++++++++++ src/wgt/CMakeLists.txt | 1 + src/wgt/wgt_backend.cc | 134 +------------------------------------------ src/wgt/wgt_installer.cc | 134 +++++++++++++++++++++++++++++++++++++++++++ src/wgt/wgt_installer.h | 26 +++++++++ 7 files changed, 212 insertions(+), 131 deletions(-) create mode 100644 src/common/step/step_fail.cc create mode 100644 src/common/step/step_fail.h create mode 100644 src/wgt/wgt_installer.cc create mode 100644 src/wgt/wgt_installer.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 8ea7bed..2ae693a 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -18,6 +18,7 @@ SET(SRCS step/step_copy_backup.cc step/step_copy_storage_directories.cc step/step_create_storage_directories.cc + step/step_fail.cc step/step_generate_xml.cc step/step_recover_application.cc step/step_recover_files.cc diff --git a/src/common/step/step_fail.cc b/src/common/step/step_fail.cc new file mode 100644 index 0000000..4cdd796 --- /dev/null +++ b/src/common/step/step_fail.cc @@ -0,0 +1,16 @@ +// 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 "common/step/step_fail.h" + +namespace common_installer { +namespace configuration { + +Step::Status StepFail::process() { + LOG(ERROR) << "Request was expected to fail"; + return Status::ERROR; +} + +} // namespace configuration +} // namespace common_installer diff --git a/src/common/step/step_fail.h b/src/common/step/step_fail.h new file mode 100644 index 0000000..067b2af --- /dev/null +++ b/src/common/step/step_fail.h @@ -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. + +#ifndef COMMON_STEP_STEP_FAIL_H_ +#define COMMON_STEP_STEP_FAIL_H_ + +#include "common/context_installer.h" + +#include "common/step/step.h" +#include "common/utils/logging.h" + +namespace common_installer { +namespace configuration { + +class StepFail : public Step { + public: + using Step::Step; + + Status process() override; + Status clean() override { return Status::OK; } + Status undo() override { return Status::OK; } + Status precheck() override { return Status::OK; } + + SCOPE_LOG_TAG(Fail) +}; + +} // namespace configuration +} // namespace common_installer + +#endif // COMMON_STEP_STEP_FAIL_H_ diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index d1fd95c..d3c95a9 100644 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -15,6 +15,7 @@ SET(SRCS step/step_wgt_resource_directory.cc wgt_app_query_interface.cc wgt_backend.cc + wgt_installer.cc ) IF(WRT_LAUNCHER) diff --git a/src/wgt/wgt_backend.cc b/src/wgt/wgt_backend.cc index 2b0de1e..651d20f 100644 --- a/src/wgt/wgt_backend.cc +++ b/src/wgt/wgt_backend.cc @@ -3,52 +3,9 @@ // Use of this source code is governed by a apache 2.0 license that can be // found in the LICENSE file. -#include - -#include "common/app_installer.h" #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" -#include "common/step/step_generate_xml.h" -#include "common/step/step_open_recovery_file.h" -#include "common/step/step_parse.h" -#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 "common/step/step_remove_icons.h" -#include "common/step/step_remove_files.h" -#include "common/step/step_remove_temporary_directory.h" -#include "common/step/step_revoke_security.h" -#include "common/step/step_register_security.h" -#include "common/step/step_old_manifest.h" -#include "common/step/step_check_signature.h" -#include "common/step/step_unregister_app.h" -#include "common/step/step_unzip.h" -#include "common/step/step_update_app.h" -#include "common/step/step_update_security.h" -#include "common/step/step_check_old_certificate.h" - -#include "wgt/step/step_create_symbolic_link.h" -#include "wgt/step/step_check_settings_level.h" -#include "wgt/step/step_encrypt_resources.h" -#include "wgt/step/step_parse.h" -#include "wgt/step/step_remove_encryption_data.h" -#include "wgt/step/step_parse_recovery.h" -#include "wgt/step/step_rds_parse.h" -#include "wgt/step/step_rds_modify.h" -#include "wgt/step/step_wgt_create_icons.h" -#include "wgt/step/step_wgt_create_storage_directories.h" -#include "wgt/step/step_wgt_copy_storage_directories.h" -#include "wgt/step/step_wgt_resource_directory.h" #include "wgt/wgt_app_query_interface.h" +#include "wgt/wgt_installer.h" namespace ci = common_installer; @@ -59,91 +16,6 @@ int main(int argc, char** argv) { LOG(ERROR) << "Options cannot be parsed by PkgMgrInstaller"; return -result; } - ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Instance(); - - ci::AppInstaller installer("wgt"); - /* treat the request */ - switch (pkgmgr->GetRequestType()) { - case ci::RequestType::Install : { - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - break; - } - case ci::RequestType::Update: { - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - break; - } - case ci::RequestType::Uninstall: { - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - break; - } - case ci::RequestType::Reinstall: { - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - break; - } - case ci::RequestType::Recovery: { - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - installer.AddStep(); - break; - } - default: { - // unsupported operation - return EINVAL; - } - } - - // run request - result = installer.Run(); - - return result; + wgt::WgtInstaller installer; + return installer.Run(); } diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc new file mode 100644 index 0000000..60d11c2 --- /dev/null +++ b/src/wgt/wgt_installer.cc @@ -0,0 +1,134 @@ +// 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/wgt_installer.h" + +#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" +#include "common/step/step_fail.h" +#include "common/step/step_generate_xml.h" +#include "common/step/step_open_recovery_file.h" +#include "common/step/step_parse.h" +#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 "common/step/step_remove_icons.h" +#include "common/step/step_remove_files.h" +#include "common/step/step_remove_temporary_directory.h" +#include "common/step/step_revoke_security.h" +#include "common/step/step_register_security.h" +#include "common/step/step_old_manifest.h" +#include "common/step/step_check_signature.h" +#include "common/step/step_unregister_app.h" +#include "common/step/step_unzip.h" +#include "common/step/step_update_app.h" +#include "common/step/step_update_security.h" +#include "common/step/step_check_old_certificate.h" + +#include "wgt/step/step_create_symbolic_link.h" +#include "wgt/step/step_check_settings_level.h" +#include "wgt/step/step_parse.h" +#include "wgt/step/step_parse_recovery.h" +#include "wgt/step/step_remove_encryption_data.h" +#include "wgt/step/step_rds_parse.h" +#include "wgt/step/step_rds_modify.h" +#include "wgt/step/step_wgt_create_icons.h" +#include "wgt/step/step_wgt_create_storage_directories.h" +#include "wgt/step/step_wgt_copy_storage_directories.h" +#include "wgt/step/step_wgt_resource_directory.h" + +namespace ci = common_installer; + +namespace wgt { + +WgtInstaller::WgtInstaller() : AppInstaller("wgt") { + ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Instance(); + /* treat the request */ + switch (pkgmgr->GetRequestType()) { + case ci::RequestType::Install : { + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + break; + } + case ci::RequestType::Update: { + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + break; + } + case ci::RequestType::Uninstall: { + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + break; + } + case ci::RequestType::Reinstall: { + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + break; + } + case ci::RequestType::Recovery: { + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + break; + } + default: { + AddStep(); + } + } +} + +} // namespace wgt diff --git a/src/wgt/wgt_installer.h b/src/wgt/wgt_installer.h new file mode 100644 index 0000000..4d88edd --- /dev/null +++ b/src/wgt/wgt_installer.h @@ -0,0 +1,26 @@ +// 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_WGT_INSTALLER_H_ +#define WGT_WGT_INSTALLER_H_ + +#include "common/app_installer.h" + +namespace wgt { + +/** + * @brief The WgtInstaller class + * Subclass of AppInstaller class dedicated for handling wgt request + * + * Performs all types of requests of wgt packages and sets required sequence of + * steps. + */ +class WgtInstaller : public common_installer::AppInstaller { + public: + WgtInstaller(); +}; + +} // namespace wgt + +#endif // WGT_WGT_INSTALLER_H_ -- 2.7.4