Introduce WgtInstaller class 78/45778/2
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 6 Aug 2015 08:40:17 +0000 (10:40 +0200)
committerPawel Sikorski <p.sikorski@samsung.com>
Tue, 11 Aug 2015 09:52:34 +0000 (11:52 +0200)
Change-Id: Ic54c461319df0ca063a1e02de830c988329608a1

src/common/CMakeLists.txt
src/common/step/step_fail.cc [new file with mode: 0644]
src/common/step/step_fail.h [new file with mode: 0644]
src/wgt/CMakeLists.txt
src/wgt/wgt_backend.cc
src/wgt/wgt_installer.cc [new file with mode: 0644]
src/wgt/wgt_installer.h [new file with mode: 0644]

index 8ea7bed..2ae693a 100644 (file)
@@ -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 (file)
index 0000000..4cdd796
--- /dev/null
@@ -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 (file)
index 0000000..067b2af
--- /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.
+
+#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_
index d1fd95c..d3c95a9 100644 (file)
@@ -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)
index 2b0de1e..651d20f 100644 (file)
@@ -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 <cerrno>
-
-#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<ci::configuration::StepConfigure>();
-      installer.AddStep<ci::filesystem::StepUnzip>();
-      installer.AddStep<wgt::parse::StepParse>();
-      installer.AddStep<ci::security::StepCheckSignature>();
-      installer.AddStep<wgt::security::StepCheckSettingsLevel>();
-      installer.AddStep<wgt::encrypt::StepEncryptResources>();
-      installer.AddStep<wgt::filesystem::StepWgtResourceDirectory>();
-      installer.AddStep<ci::filesystem::StepCopy>();
-      installer.AddStep<wgt::filesystem::StepWgtCreateStorageDirectories>();
-      installer.AddStep<ci::filesystem::StepCreateStorageDirectories>();
-      installer.AddStep<wgt::filesystem::StepCreateSymbolicLink>();
-      installer.AddStep<wgt::filesystem::StepWgtCreateIcons>();
-      installer.AddStep<ci::pkgmgr::StepGenerateXml>();
-      installer.AddStep<ci::pkgmgr::StepRegisterApplication>();
-      installer.AddStep<ci::security::StepRegisterSecurity>();
-      break;
-    }
-    case ci::RequestType::Update: {
-      installer.AddStep<ci::configuration::StepConfigure>();
-      installer.AddStep<ci::filesystem::StepUnzip>();
-      installer.AddStep<wgt::parse::StepParse>();
-      installer.AddStep<ci::security::StepCheckSignature>();
-      installer.AddStep<wgt::security::StepCheckSettingsLevel>();
-      installer.AddStep<ci::security::StepCheckOldCertificate>();
-      installer.AddStep<wgt::encrypt::StepEncryptResources>();
-      installer.AddStep<wgt::filesystem::StepWgtResourceDirectory>();
-      installer.AddStep<ci::backup::StepOldManifest>();
-      installer.AddStep<ci::backup::StepBackupManifest>();
-      installer.AddStep<ci::backup::StepBackupIcons>();
-      installer.AddStep<ci::backup::StepCopyBackup>();
-      installer.AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
-      installer.AddStep<wgt::filesystem::StepCreateSymbolicLink>();
-      installer.AddStep<wgt::filesystem::StepWgtCreateIcons>();
-      installer.AddStep<ci::security::StepUpdateSecurity>();
-      installer.AddStep<ci::pkgmgr::StepGenerateXml>();
-      installer.AddStep<ci::pkgmgr::StepUpdateApplication>();
-      break;
-    }
-    case ci::RequestType::Uninstall: {
-      installer.AddStep<ci::configuration::StepConfigure>();
-      installer.AddStep<ci::parse::StepParse>();
-      installer.AddStep<ci::backup::StepBackupManifest>();
-      installer.AddStep<ci::pkgmgr::StepUnregisterApplication>();
-      installer.AddStep<ci::filesystem::StepRemoveFiles>();
-      installer.AddStep<ci::filesystem::StepRemoveIcons>();
-      installer.AddStep<ci::security::StepRevokeSecurity>();
-      installer.AddStep<wgt::encrypt::StepRemoveEncryptionData>();
-      break;
-    }
-    case ci::RequestType::Reinstall: {
-      installer.AddStep<ci::configuration::StepConfigure>();
-      installer.AddStep<wgt::parse::StepParse>();
-      installer.AddStep<ci::backup::StepOldManifest>();
-      installer.AddStep<wgt::rds::StepRDSParse>();
-      installer.AddStep<wgt::rds::StepRDSModify>();
-      installer.AddStep<ci::security::StepUpdateSecurity>();
-      break;
-    }
-    case ci::RequestType::Recovery: {
-      installer.AddStep<ci::configuration::StepConfigure>();
-      installer.AddStep<ci::recovery::StepOpenRecoveryFile>();
-      installer.AddStep<wgt::parse::StepParseRecovery>();
-      installer.AddStep<ci::pkgmgr::StepRecoverApplication>();
-      installer.AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
-      installer.AddStep<ci::filesystem::StepRecoverIcons>();
-      installer.AddStep<ci::filesystem::StepRecoverManifest>();
-      installer.AddStep<ci::filesystem::StepRecoverStorageDirectories>();
-      installer.AddStep<ci::filesystem::StepRecoverFiles>();
-      installer.AddStep<ci::security::StepRecoverSecurity>();
-      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 (file)
index 0000000..60d11c2
--- /dev/null
@@ -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<ci::configuration::StepConfigure>();
+      AddStep<ci::filesystem::StepUnzip>();
+      AddStep<wgt::parse::StepParse>();
+      AddStep<ci::security::StepCheckSignature>();
+      AddStep<wgt::security::StepCheckSettingsLevel>();
+      AddStep<wgt::filesystem::StepWgtResourceDirectory>();
+      AddStep<ci::filesystem::StepCopy>();
+      AddStep<wgt::filesystem::StepWgtCreateStorageDirectories>();
+      AddStep<ci::filesystem::StepCreateStorageDirectories>();
+      AddStep<wgt::filesystem::StepCreateSymbolicLink>();
+      AddStep<wgt::filesystem::StepWgtCreateIcons>();
+      AddStep<ci::pkgmgr::StepGenerateXml>();
+      AddStep<ci::pkgmgr::StepRegisterApplication>();
+      AddStep<ci::security::StepRegisterSecurity>();
+      break;
+    }
+    case ci::RequestType::Update: {
+      AddStep<ci::configuration::StepConfigure>();
+      AddStep<ci::filesystem::StepUnzip>();
+      AddStep<wgt::parse::StepParse>();
+      AddStep<ci::security::StepCheckSignature>();
+      AddStep<wgt::security::StepCheckSettingsLevel>();
+      AddStep<ci::security::StepCheckOldCertificate>();
+      AddStep<wgt::filesystem::StepWgtResourceDirectory>();
+      AddStep<ci::backup::StepOldManifest>();
+      AddStep<ci::backup::StepBackupManifest>();
+      AddStep<ci::backup::StepBackupIcons>();
+      AddStep<ci::backup::StepCopyBackup>();
+      AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
+      AddStep<wgt::filesystem::StepCreateSymbolicLink>();
+      AddStep<wgt::filesystem::StepWgtCreateIcons>();
+      AddStep<ci::security::StepUpdateSecurity>();
+      AddStep<ci::pkgmgr::StepGenerateXml>();
+      AddStep<ci::pkgmgr::StepUpdateApplication>();
+      break;
+    }
+    case ci::RequestType::Uninstall: {
+      AddStep<ci::configuration::StepConfigure>();
+      AddStep<ci::parse::StepParse>();
+      AddStep<ci::backup::StepBackupManifest>();
+      AddStep<ci::pkgmgr::StepUnregisterApplication>();
+      AddStep<ci::filesystem::StepRemoveFiles>();
+      AddStep<ci::filesystem::StepRemoveIcons>();
+      AddStep<ci::security::StepRevokeSecurity>();
+      AddStep<wgt::encrypt::StepRemoveEncryptionData>();
+      break;
+    }
+    case ci::RequestType::Reinstall: {
+      AddStep<ci::configuration::StepConfigure>();
+      AddStep<wgt::parse::StepParse>();
+      AddStep<ci::backup::StepOldManifest>();
+      AddStep<wgt::rds::StepRDSParse>();
+      AddStep<wgt::rds::StepRDSModify>();
+      AddStep<ci::security::StepUpdateSecurity>();
+      break;
+    }
+    case ci::RequestType::Recovery: {
+      AddStep<ci::configuration::StepConfigure>();
+      AddStep<ci::recovery::StepOpenRecoveryFile>();
+      AddStep<wgt::parse::StepParseRecovery>();
+      AddStep<ci::pkgmgr::StepRecoverApplication>();
+      AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
+      AddStep<ci::filesystem::StepRecoverIcons>();
+      AddStep<ci::filesystem::StepRecoverManifest>();
+      AddStep<ci::filesystem::StepRecoverStorageDirectories>();
+      AddStep<ci::filesystem::StepRecoverFiles>();
+      AddStep<ci::security::StepRecoverSecurity>();
+      break;
+    }
+    default: {
+      AddStep<ci::configuration::StepFail>();
+    }
+  }
+}
+
+}  // namespace wgt
diff --git a/src/wgt/wgt_installer.h b/src/wgt/wgt_installer.h
new file mode 100644 (file)
index 0000000..4d88edd
--- /dev/null
@@ -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_