Add InstallationMode to InstallerContext 76/57876/4
authorArkadiusz Szulakiewicz <a.szulakiewi@partner.samsung.com>
Mon, 25 Jan 2016 13:15:18 +0000 (14:15 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Tue, 26 Jan 2016 11:51:24 +0000 (03:51 -0800)
Change-Id: I2cc21d4d79cb2187f65bfa04d152990b67b92333

src/common/app_installer.cc
src/common/installer_context.h
src/common/pkgmgr_interface.cc
src/common/pkgmgr_interface.h

index a3dcd52..76eaeca 100644 (file)
@@ -27,6 +27,7 @@ AppInstaller::AppInstaller(const char* package_type, PkgMgrPtr pkgmgr)
   // TODO(p.sikorski) below property is only used in AppInstaller.
   // maybe it should then be kept in AppInstaller
   context_->pkg_type.set(package_type);
+  context_->installation_mode.set(pkgmgr->GetInstallationMode());
 }
 
 AppInstaller::~AppInstaller() {
index df51dd7..5bf43ba 100644 (file)
@@ -19,6 +19,7 @@
 #include <utility>
 #include <vector>
 
+#include "common/pkgmgr_interface.h"
 #include "common/recovery_file.h"
 #include "common/request.h"
 #include "common/utils/property.h"
@@ -261,6 +262,11 @@ class InstallerContext {
    * \brief request type received from pkgmgr_installer
    */
   Property<RequestType> request_type;
+
+  /**
+   * \brief installation mode (ONLINE / OFFLINE)
+   */
+  Property<InstallationMode> installation_mode;
 };
 
 }  // namespace common_installer
index 61630d8..980b5dd 100644 (file)
@@ -46,6 +46,9 @@ int PkgMgrInterface::InitInternal(int argc, char** argv) {
       LOG(ERROR) << "Cannot create pkgmgr_installer object. Aborting.";
       return ENOMEM;
     }
+    install_mode_ = InstallationMode::OFFLINE;
+  } else {
+    install_mode_ = InstallationMode::ONLINE;
   }
 
   int result = pkgmgr_installer_receive_request(pi_, argc, argv);
index 5bbd935..d65c558 100644 (file)
 
 namespace common_installer {
 
+enum class InstallationMode {
+  ONLINE,
+  OFFLINE
+};
+
 class PkgMgrInterface;
 typedef std::shared_ptr<PkgMgrInterface> PkgMgrPtr;
 
@@ -73,18 +78,29 @@ class PkgMgrInterface {
    */
   DEPRECATED pkgmgr_installer *GetRawPi() const { return pi_; }
 
+  /**
+  * Returns installation mode
+  *
+  * \return 'ONLINE' for online installation, 'OFFLINE' otherwise
+  */
+  InstallationMode GetInstallationMode() const { return install_mode_; }
+
+
   /** PkgMgrInstance destructor. */
   ~PkgMgrInterface();
 
  private:
   explicit PkgMgrInterface(AppQueryInterface* interface)
       : pi_(nullptr),
+        install_mode_(InstallationMode::ONLINE),
         is_app_installed_(false),
         query_interface_(interface) {}
   int InitInternal(int argc, char** argv);
 
   pkgmgr_installer* pi_;
+  InstallationMode install_mode_;
   bool is_app_installed_;
+
   AppQueryInterface* query_interface_;
 
   SCOPE_LOG_TAG(PkgMgrInterface)