From: Youmin Ha Date: Tue, 3 Feb 2015 04:55:58 +0000 (+0900) Subject: Give the package type as a AppInstaller object X-Git-Tag: submit/tizen_mobile/20150224.012613~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F34805%2F6;p=platform%2Fcore%2Fappfw%2Fapp-installers.git Give the package type as a AppInstaller object 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 --- diff --git a/src/common/app_installer.cc b/src/common/app_installer.cc index c5825a2..61e8e22 100644 --- a/src/common/app_installer.cc +++ b/src/common/app_installer.cc @@ -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(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; } } diff --git a/src/common/app_installer.h b/src/common/app_installer.h index 993c67e..80ec558 100644 --- a/src/common/app_installer.h +++ b/src/common/app_installer.h @@ -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 diff --git a/src/common/context_installer.cc b/src/common/context_installer.cc index a14095a..febb754 100644 --- a/src/common/context_installer.cc +++ b/src/common/context_installer.cc @@ -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 diff --git a/src/common/context_installer.h b/src/common/context_installer.h index bef7764..d9dedf2 100644 --- a/src/common/context_installer.h +++ b/src/common/context_installer.h @@ -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_; diff --git a/src/wgt/wgt_backend.cc b/src/wgt/wgt_backend.cc index 915459e..1f45ab7 100644 --- a/src/wgt/wgt_backend.cc +++ b/src/wgt/wgt_backend.cc @@ -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();