Give the package type as a AppInstaller object 05/34805/6
authorYoumin Ha <youmin.ha@samsung.com>
Tue, 3 Feb 2015 04:55:58 +0000 (13:55 +0900)
committerYoumin Ha <youmin.ha@samsung.com>
Mon, 23 Feb 2015 06:41:00 +0000 (15:41 +0900)
To send a start/end/progress DBUS signal, client needs to know the
package type as a string. This patch adds an argument package_type on
the AppInstaller constructor, and stores it into the ContextInstaller.

Change-Id: I18a7770dbb706a6ab72cce6010d348fda4d47137

src/common/app_installer.cc
src/common/app_installer.h
src/common/context_installer.cc
src/common/context_installer.h
src/wgt/wgt_backend.cc

index c5825a2..61e8e22 100644 (file)
@@ -7,21 +7,24 @@
 #include "common/pkgmgr_signal.h"
 #include "utils/logging.h"
 
+#define STR_EMPTY ""
+
 namespace common_installer {
 
-AppInstaller::AppInstaller(pkgmgr_installer *pi)
-    : context_(new ContextInstaller()) {
+AppInstaller::AppInstaller(pkgmgr_installer *pi, const char* package_type)
+  : context_(new ContextInstaller()) {
   int request_type = pkgmgr_installer_get_request_type(pi);
   context_->set_pi(std::unique_ptr<PkgmgrSignal>(new PkgmgrSignal(pi)));
   context_->set_request_type(request_type);
+  context_->set_pkg_type(package_type);
   switch (request_type) {
     case PKGMGR_REQ_INSTALL:
      context_->set_file_path(pkgmgr_installer_get_request_info(pi));
-     context_->set_pkgid("");
+     context_->set_pkgid(STR_EMPTY);
     break;
     case PKGMGR_REQ_UNINSTALL:
      context_->set_pkgid(pkgmgr_installer_get_request_info(pi));
-     context_->set_file_path("");
+     context_->set_file_path(STR_EMPTY);
     break;
   }
 }
index 993c67e..80ec558 100644 (file)
@@ -15,7 +15,7 @@ namespace common_installer {
 
 class AppInstaller {
  public:
-  explicit AppInstaller(pkgmgr_installer *pi);
+  explicit AppInstaller(pkgmgr_installer *pi, const char* package_type);
   virtual ~AppInstaller();
 
   // Adds new step to installer by specified type
index a14095a..febb754 100644 (file)
@@ -35,4 +35,21 @@ const char* ContextInstaller::GetApplicationPath() const {
   return (fs::path(GetRootApplicationPath()) / fs::path(pkgid())).c_str();
 }
 
+
+void ContextInstaller::set_new_temporary_pkgid() {
+  static const char lookup[] =
+    "abcdefghijklmnopqrstuvwxyz"
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "0123456789";
+    static const int len = 12;
+    const size_t max_lookup = (sizeof(lookup)-1);
+
+    std::string pkgid(len, 0);
+
+    for (int i = 0; i < len-1; i++) {
+      pkgid.append(1, lookup[ rand() % max_lookup ]);
+    }
+    set_pkgid(pkgid);
+}
+
 }  // namespace common_installer
index bef7764..d9dedf2 100644 (file)
@@ -52,6 +52,11 @@ class ContextInstaller {
     req_ = req;
   }
 
+  std::string pkg_type() const { return pkg_type_; }
+  void set_pkg_type(const std::string& pkg_type) {
+    pkg_type_ = pkg_type;
+  }
+
   manifest_x* manifest_data() const { return manifest_; }
   void set_manifest(manifest_x* manifest) {
     manifest_ = manifest;
@@ -66,6 +71,7 @@ class ContextInstaller {
   void set_pkgid(const std::string& pkgid) {
     pkgid_ = pkgid;
   }
+  void set_new_temporary_pkgid(void);
 
   std::string pkg_path() const { return pkg_path_; }
   void set_pkg_path(const std::string& package_path) {
@@ -108,6 +114,9 @@ class ContextInstaller {
   // pkgid used for update or uninstallation processing
   std::string pkgid_;
 
+  // package_type
+  std::string pkg_type_;
+
   // uid of the user that request the operation
   uid_t uid_;
 
index 915459e..1f45ab7 100644 (file)
@@ -41,10 +41,8 @@ int main(int argc, char** argv) {
     pkgmgr_installer_free(pi);
     return -result;
   }
-
-  ci::AppInstaller installer(pi);
-
-  // set steps
+  common_installer::AppInstaller installer(pi, "wgt");
+  /* treat the request */
   switch (pkgmgr_installer_get_request_type(pi)) {
     case PKGMGR_REQ_INSTALL: {
       installer.AddStep<ci::unzip::StepUnzip>();