1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef COMMON_RECOVERY_FILE_H_
6 #define COMMON_RECOVERY_FILE_H_
8 #include <boost/filesystem/path.hpp>
14 #include "common/utils/request.h"
16 namespace common_installer {
21 * Responsible for managing recovery file.
23 * It dumps information to recover file regarding current status of handled
29 * Creates new RecoveryFile object for given file
31 * \param path path to the package/id
33 * \return new RecoveryFile object
35 static std::unique_ptr<RecoveryFile> CreateRecoveryFile(
36 const boost::filesystem::path& path, RequestType type);
39 * Opens RecoveryFile object for given request
41 * \param path path to the package/id
43 * \return new RecoveryFile object
45 static std::unique_ptr<RecoveryFile> OpenRecoveryFile(
46 const boost::filesystem::path& path);
51 /** Detaching object from given recovery file */
55 * Checks if object is detached from file
57 * \return true if detached
60 bool is_detached() const;
63 * setter for unpacked dir
65 * \param unpacked_dir new unpacked_dir value
67 void set_unpacked_dir(boost::filesystem::path unpacked_dir);
72 * \param pkgid new pkgid value
74 void set_pkgid(std::string pkgid);
77 * setter for backup done
79 * \param backup_done boolean value of backup_done
81 void set_backup_done(bool backup_done);
84 * setter for cleanup flag
86 * \param cleanup boolean value of cleanup
88 void set_cleanup(bool cleanup);
91 * setter for security operation done
93 * \param security_operation_done boolean value of security_operation_done
95 void set_security_operation_done(bool security_operation_done);
98 * getter for unpacked dir
100 * \return current unpacked_dir
102 const boost::filesystem::path& unpacked_dir() const;
107 * * \return current pkgid
109 const std::string& pkgid() const;
112 * getter for request type
114 * \return current request type
116 RequestType type() const;
119 * getter for backup exist flag
121 * \return true if backup does exist
123 bool backup_done() const;
126 * getter for cleanup flag
128 * \return true if cleanup flag has set
130 bool cleanup() const;
133 * getter for security operation done flag
135 * \return true if security operation done flag has set
137 bool security_operation_done() const;
140 * Transaction of current RecoveryFile content into recovery file
142 * \return true if success
144 bool WriteAndCommitFileContent();
147 RecoveryFile(const boost::filesystem::path& path, RequestType type,
150 bool ReadFileContent();
153 boost::filesystem::path unpacked_dir_;
156 boost::filesystem::path path_;
157 boost::filesystem::path backup_path_;
160 bool security_operation_done_;
163 } // namespace recovery
164 } // namespace common_installer
166 #endif // COMMON_RECOVERY_FILE_H_