1 /* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
2 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a apache 2.0 license that can be
4 // found in the LICENSE file.
7 A step is made of 4 functions (that must be defined)
11 - precheck checks the input data used during process method
12 - process handles the job to be done
13 - undo undo the step's work after failure
14 - clean remove temporary data of the step after success
16 All these functions have the same signature: they do not accept any arguments
17 and they return a value which states the execution result.
19 The returned code of Step::Status::OK indicates a successful execution.
20 Otherwise, the returned code should be set to value different than
23 Errornous result of processing is casted to integer value and sent to
24 client which initialized request.
26 #ifndef COMMON_STEP_STEP_H_
27 #define COMMON_STEP_STEP_H_
29 #include <pkgmgr_installer_error.h>
33 #include "common/installer_context.h"
35 // This macro should be defined at the end of class definition
36 #define STEP_NAME(NAME) \
38 const char* name() const override { return #NAME; } \
40 namespace common_installer {
43 * \brief Abstract base class for all Steps* used for requests handling.
45 * It is an abstract base class that demands the definition of
46 * 4 methods: process, precheck, undo and clean.
50 /** Possible code returned by process, undo, clean, precheck methods. */
52 GLOBALSYMLINK_ERROR = PKGMGR_INSTALLER_ERRCODE_GLOBALSYMLINK_ERROR,
53 GRANT_PERMISSION_ERROR = PKGMGR_INSTALLER_ERRCODE_GRANT_PERMISSION_ERROR,
54 IMAGE_ERROR = PKGMGR_INSTALLER_ERRCODE_IMAGE_ERROR,
55 UNZIP_ERROR = PKGMGR_INSTALLER_ERRCODE_UNZIP_ERROR,
56 SECURITY_ERROR = PKGMGR_INSTALLER_ERRCODE_SECURITY_ERROR,
57 REGISTER_ERROR = PKGMGR_INSTALLER_ERRCODE_REGISTER_ERROR,
58 PRIVILEGE_ERROR = PKGMGR_INSTALLER_ERRCODE_PRIVILEGE_ERROR,
59 PARSE_ERROR = PKGMGR_INSTALLER_ERRCODE_PARSE_ERROR,
60 RECOVERY_ERROR = PKGMGR_INSTALLER_ERRCODE_RECOVERY_ERROR,
61 DELTA_ERROR = PKGMGR_INSTALLER_ERRCODE_DELTA_ERROR,
62 APP_DIR_ERROR = PKGMGR_INSTALLER_ERRCODE_APP_DIR_ERROR,
63 CONFIG_ERROR = PKGMGR_INSTALLER_ERRCODE_CONFIG_ERROR,
64 SIGNATURE_ERROR = PKGMGR_INSTALLER_ERRCODE_SIGNATURE_ERROR,
65 SIGNATURE_INVALID = PKGMGR_INSTALLER_ERRCODE_SIGNATURE_INVALID,
66 CERT_ERROR = PKGMGR_INSTALLER_ERRCODE_CERT_ERROR,
67 AUTHOR_CERT_NOT_MATCH = PKGMGR_INSTALLER_ERRCODE_AUTHOR_CERT_NOT_MATCH,
68 AUTHOR_CERT_NOT_FOUND = PKGMGR_INSTALLER_ERRCODE_AUTHOR_CERT_NOT_FOUND,
69 ICON_ERROR = PKGMGR_INSTALLER_ERRCODE_ICON_ERROR,
70 ICON_NOT_FOUND = PKGMGR_INSTALLER_ERRCODE_ICON_NOT_FOUND,
71 MANIFEST_ERROR = PKGMGR_INSTALLER_ERRCODE_MANIFEST_ERROR,
72 MANIFEST_NOT_FOUND = PKGMGR_INSTALLER_ERRCODE_MANIFEST_NOT_FOUND,
73 PACKAGE_NOT_FOUND = PKGMGR_INSTALLER_ERRCODE_PACKAGE_NOT_FOUND,
74 OPERATION_NOT_ALLOWED = PKGMGR_INSTALLER_ERRCODE_OPERATION_NOT_ALLOWED,
75 OUT_OF_SPACE = PKGMGR_INSTALLER_ERRCODE_OUT_OF_SPACE,
76 INVALID_VALUE = PKGMGR_INSTALLER_ERRCODE_INVALID_VALUE,
77 ERROR = PKGMGR_INSTALLER_ERRCODE_ERROR,
78 OK = PKGMGR_INSTALLER_ERRCODE_OK,
79 RECOVERY_DONE = PKGMGR_INSTALLER_ERRCODE_OK + 1
82 class IStepErrorSignal {
84 virtual ~IStepErrorSignal() {}
85 virtual void on_error(Step::Status result, const std::string& error) = 0;
88 /** Standard constructor */
89 explicit Step(InstallerContext* context) : context_(context) { }
91 /** Virtual "empty" destructor */
94 /** Handles the job to be done */
95 virtual Status process() = 0;
97 /** Undos the step's work after failure */
98 virtual Status undo() = 0;
100 /** Removes temporary data of the step after success */
101 virtual Status clean() = 0;
103 /** Checks the input data used during process method */
104 virtual Status precheck() = 0;
106 /** Returns step name */
107 virtual const char* name() const = 0;
109 void connect(IStepErrorSignal* signal) {
114 InstallerContext* context_;
115 IStepErrorSignal* on_error_;
118 } // namespace common_installer
120 #endif // COMMON_STEP_STEP_H_