Skip the security registration if it is unnecessary
[platform/core/appfw/app-installers.git] / src / common / recovery_file.h
index 4c775c7..d68fb60 100644 (file)
 #include <boost/filesystem/path.hpp>
 
 #include <cstdio>
+#include <memory>
 #include <string>
 
-#include "common/request_type.h"
+#include "common/utils/request.h"
 
 namespace common_installer {
 
 namespace recovery {
 
+/**
+ * Responsible for managing recovery file.
+ *
+ * It dumps information to recover file regarding current status of handled
+ * request.
+ */
 class RecoveryFile {
  public:
-  static std::unique_ptr<RecoveryFile> CreateRecoveryFileForPath(
-      const boost::filesystem::path& path);
-  static std::unique_ptr<RecoveryFile> OpenRecoveryFileForPath(
+  /**
+   * Creates new RecoveryFile object for given file
+   *
+   * \param path path to the package/id
+   *
+   * \return new RecoveryFile object
+   */
+  static std::unique_ptr<RecoveryFile> CreateRecoveryFile(
+      const boost::filesystem::path& path, RequestType type);
+
+  /**
+   * Opens RecoveryFile object for given request
+   *
+   * \param path path to the package/id
+   *
+   * \return new RecoveryFile object
+   */
+  static std::unique_ptr<RecoveryFile> OpenRecoveryFile(
       const boost::filesystem::path& path);
+
+  /** Desctructor */
   ~RecoveryFile();
+
+  /** Detaching object from given recovery file */
   void Detach();
+
+  /**
+   * Checks if object is detached from file
+   *
+   * \return true if detached
+   *
+   */
   bool is_detached() const;
 
-  void set_unpacked_dir(const boost::filesystem::path& unpacked_dir);
-  void set_pkgid(const std::string& pkgid);
-  void set_type(RequestType type);
+  /**
+   * setter for unpacked dir
+   *
+   * \param unpacked_dir new unpacked_dir value
+   */
+  void set_unpacked_dir(boost::filesystem::path unpacked_dir);
+
+  /**
+   * setter for pkgid
+   *
+   * \param pkgid new pkgid value
+   */
+  void set_pkgid(std::string pkgid);
+
+  /**
+   * setter for backup done
+   *
+   * \param backup_done boolean value of backup_done
+   */
+  void set_backup_done(bool backup_done);
+
+  /**
+   * setter for cleanup flag
+   *
+   * \param cleanup boolean value of cleanup
+   */
+  void set_cleanup(bool cleanup);
+
+  /**
+   * setter for security operation done
+   *
+   * \param security_operation_done boolean value of security_operation_done
+   */
+  void set_security_operation_done(bool security_operation_done);
+
+  /**
+   * getter for unpacked dir
+   *
+   * \return current unpacked_dir
+   */
   const boost::filesystem::path& unpacked_dir() const;
+
+  /**
+   * getter for pkgid
+   *
+   * * \return current pkgid
+   */
   const std::string& pkgid() const;
+
+  /**
+   * getter for request type
+   *
+   * \return current request type
+   */
   RequestType type() const;
 
+  /**
+   * getter for backup exist flag
+   *
+   * \return true if backup does exist
+   */
+  bool backup_done() const;
+
+  /**
+   * getter for cleanup flag
+   *
+   * \return true if cleanup flag has set
+   */
+  bool cleanup() const;
+
+  /**
+   * getter for security operation done flag
+   *
+   * \return true if security operation done flag has set
+   */
+  bool security_operation_done() const;
+
+  /**
+   * Transaction of current RecoveryFile content into recovery file
+   *
+   * \return true if success
+   */
   bool WriteAndCommitFileContent();
 
  private:
-  RecoveryFile(const boost::filesystem::path& path, bool load);
+  RecoveryFile(const boost::filesystem::path& path, RequestType type,
+      bool load);
 
   bool ReadFileContent();
 
@@ -45,6 +154,10 @@ class RecoveryFile {
   std::string pkgid_;
 
   boost::filesystem::path path_;
+  boost::filesystem::path backup_path_;
+  bool backup_done_;
+  bool cleanup_;
+  bool security_operation_done_;
 };
 
 }  // namespace recovery