#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;
}
}
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
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
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;
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) {
// 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_;
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>();