step/step_record.cc
step/step_parse.cc
step/step_remove.cc
+ step/step_signal.cc
step/step_unregister.cc
utils.cc
)
namespace common_installer {
-AppInstaller::AppInstaller(int request, const char* file, const char* pkgid) {
+AppInstaller::AppInstaller(pkgmgr_installer *pi) {
ctx_ = new ContextInstaller();
- ctx_->set_request_type(request);
- ctx_->set_pkgid(pkgid);
- ctx_->set_file_path(file);
+ int request_type = pkgmgr_installer_get_request_type(pi);
+ ctx_->set_pi(pi);
+ ctx_->set_request_type(request_type);
+ switch (request_type) {
+ case PKGMGR_REQ_INSTALL:
+ ctx_->set_file_path(pkgmgr_installer_get_request_info(pi));
+ ctx_->set_pkgid("");
+ break;
+ case PKGMGR_REQ_UNINSTALL:
+ ctx_->set_pkgid(pkgmgr_installer_get_request_info(pi));
+ ctx_->set_file_path("");
+ break;
+ }
}
AppInstaller::~AppInstaller() { delete ctx_; }
return 0;
}
+
int AppInstaller::Run() {
std::list<Step *>::iterator it(ListStep.begin());
std::list<Step *>::iterator itStart(ListStep.begin());
#ifndef COMMON_APP_INSTALLER_H_
#define COMMON_APP_INSTALLER_H_
+#include <pkgmgr_installer.h>
#include <list>
#include "common/step/step.h"
+
namespace common_installer {
class AppInstaller {
ContextInstaller* ctx_;
public:
- AppInstaller(int request, const char* file, const char* pkgid);
+ AppInstaller(pkgmgr_installer *pi);
~AppInstaller();
int AddStep(Step* step);
#define COMMON_CONTEXT_INSTALLER_H_
#include <pkgmgr_parser.h>
+#include <pkgmgr_installer.h>
#include <unistd.h>
#include <sys/types.h>
file_path_ = file_path;
}
+ void set_pi(pkgmgr_installer* pi) {
+ pi_ = pi;
+ }
+
uid_t uid() const { return uid_; }
std::string unpack_directory() const { return unpack_directory_; }
ConfigData* config_data() { return config_data_.get(); }
+ pkgmgr_installer* pi() const { return pi_; }
+
const char* GetApplicationPath();
const char* GetRootApplicationPath();
// data from config.xml
ConfigDataPtr config_data_;
+
+ // data used to send signal
+ pkgmgr_installer *pi_;
};
} // namespace common_installer
--- /dev/null
+/* 2014, Copyright © Eurogiciel Coporation, APACHE-2.0, see LICENSE file */
+
+#include "common/step/step_signal.h"
+
+#include <pkgmgr-info.h>
+#include <unistd.h>
+
+#include <iostream>
+#include "common/utils.h"
+
+#define DBG(msg) std::cout << "[Signal] " << msg << std::endl;
+#define ERR(msg) std::cout << "[ERROR: Signal] " << msg << std::endl;
+
+namespace common_installer {
+namespace signal {
+
+bool StepSignal::sendSignal(ContextInstaller* data, const std::string& key,
+ const std::string& value) {
+ if (!data->pi()) {
+ ERR("PkgmgrSingal not yet intialized");
+ return false;
+ }
+
+ if (key.empty() || value.empty()) {
+ DBG("key or value is empty");
+ return false;
+ }
+
+ // send pkgmgr signal
+ if (pkgmgr_installer_send_signal(
+ data->pi(), data->manifest_data()->type, data->pkgid().c_str(),
+ key.c_str(), value.c_str())) {
+ ERR("Fail to send pkgmgr signal");
+ return false;
+ }
+
+ DBG("Success to send pkgmgr signal");
+ return true;
+}
+
+
+int StepSignal::process(ContextInstaller* data) {
+ sendSignal(data, PKGMGR_INSTALLER_START_KEY_STR,
+ PKGMGR_INSTALLER_INSTALL_EVENT_STR);
+ DBG("Send Start");
+ return APPINST_R_OK;
+}
+
+int StepSignal::clean(ContextInstaller* data) {
+ sendSignal(data, PKGMGR_INSTALLER_END_KEY_STR,
+ PKGMGR_INSTALLER_OK_EVENT_STR);
+ DBG("Send Sucess");
+ return APPINST_R_OK;
+}
+
+int StepSignal::undo(ContextInstaller* data) {
+ sendSignal(data, PKGMGR_INSTALLER_END_KEY_STR,
+ PKGMGR_INSTALLER_FAIL_EVENT_STR);
+ DBG("Send Error");
+ return APPINST_R_OK;
+}
+
+
+
+
+
+} // namespace signal
+} // namespace common_installer
--- /dev/null
+/* 2014, Copyright © Eurogiciel Coporation, APACHE-2.0, see LICENSE file */
+
+#ifndef COMMON_STEP_STEP_SIGNAL_H_
+#define COMMON_STEP_STEP_SIGNAL_H_
+
+#include <string>
+
+#include "common/context_installer.h"
+
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace signal {
+
+class StepSignal : public Step {
+ public:
+ int process(ContextInstaller* context) override;
+ int clean(ContextInstaller* context) override;
+ int undo(ContextInstaller* context) override;
+ private:
+ bool sendSignal(ContextInstaller* data, const std::string& key,
+ const std::string& value);
+};
+
+} // namespace signal
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_SIGNAL_H_
#include "wgt/step/step_parse.h"
#include "common/step/step_generate_xml.h"
#include "common/step/step_record.h"
+#include "common/step/step_signal.h"
// uninstall includes:
#include "common/step/step_parse.h"
pkgmgr_installer_free(pi);
return -result;
}
-
+ common_installer::AppInstaller* installer =
+ new common_installer::AppInstaller(pi);
/* treat the request */
switch (pkgmgr_installer_get_request_type(pi)) {
case PKGMGR_REQ_INSTALL: {
- common_installer::AppInstaller* installer =
- new common_installer::AppInstaller(PKGMGR_REQ_INSTALL,
- pkgmgr_installer_get_request_info(pi), "");
-
common_installer::unzip::StepUnzip* step_unpack =
new common_installer::unzip::StepUnzip();
common_installer::signature::StepSignature* step_signature =
wgt::parse::StepParse();
common_installer::copy::StepCopy* step_copy =
new common_installer::copy::StepCopy();
+ common_installer::signal::StepSignal* step_sendsignal =
+ new common_installer::signal::StepSignal();
common_installer::generate_xml::StepGenerateXml* step_xml =
new common_installer::generate_xml::StepGenerateXml();
common_installer::record::StepRecord* step_record =
installer->AddStep(step_unpack);
installer->AddStep(step_signature);
installer->AddStep(step_parse);
+ installer->AddStep(step_sendsignal);
installer->AddStep(step_copy);
installer->AddStep(step_xml);
installer->AddStep(step_record);
delete step_signature;
delete step_parse;
delete step_copy;
- delete installer;
+ delete step_sendsignal;
delete step_xml;
delete step_record;
break;
}
case PKGMGR_REQ_UNINSTALL: {
- common_installer::AppInstaller* installer =
- new common_installer::AppInstaller(PKGMGR_REQ_UNINSTALL,
- "", pkgmgr_installer_get_request_info(pi));
-
common_installer::parse::StepParse* step_parse =
new common_installer::parse::StepParse();
common_installer::remove::StepRemove* step_remove =
new common_installer::remove::StepRemove();
common_installer::unregister::StepUnregister* step_unregister =
new common_installer::unregister::StepUnregister();
-
+ common_installer::signal::StepSignal* step_sendsignal =
+ new common_installer::signal::StepSignal();
installer->AddStep(step_parse);
+ installer->AddStep(step_sendsignal);
installer->AddStep(step_unregister);
installer->AddStep(step_remove);
delete step_remove;
delete step_unregister;
delete step_parse;
+ delete step_sendsignal;
+
break;
}
default: {
break;
}
}
+ delete installer;
pkgmgr_installer_free(pi);
return result;
}