#include <bundle_cpp.h>
+#include <utility>
+
#include "aul/app_manager/app_event.hh"
#include "aul/common/common.hh"
#include "aul/common/exception.hh"
AppEvent::AppEvent(std::string app_id, AppEvent::IEvent* ev)
: app_id_(std::move(app_id)), ev_(ev) {
- std::string endpoint = "app_status_event:" + app_id_;
+ endpoint_ = "app_status_event:" + app_id_;
if (getuid() >= REGULAR_UID_MIN)
- endpoint += ":" + std::to_string(getuid());
-
- int ret = aul_app_com_create_async(endpoint.c_str(), nullptr, OnAppStatusCb,
- this, &handle_);
- if (ret != AUL_R_OK) {
- _E("aul_app_com_create(%s) is failed. error(%d)", endpoint.c_str(), ret);
- THROW(ret);
- }
+ endpoint_ += ":" + std::to_string(getuid());
}
AppEvent::AppEvent(AppEvent::IEvent* ev) : ev_(ev) {
- std::string endpoint = "app_status_event";
+ endpoint_ = "app_status_event";
if (getuid() >= REGULAR_UID_MIN)
- endpoint += ":" + std::to_string(getuid());
-
- int ret = aul_app_com_create_async(endpoint.c_str(), nullptr, OnAppStatusCb,
- this, &handle_);
- if (ret != AUL_R_OK) {
- _E("aul_app_com_create(%s) is failed. error(%d)", endpoint.c_str(), ret);
- THROW(ret);
- }
+ endpoint_ += ":" + std::to_string(getuid());
}
AppEvent::~AppEvent() {
aul_app_com_leave(handle_);
}
+void AppEvent::Listen() {
+ int ret = aul_app_com_create_async(endpoint_.c_str(), nullptr, OnAppStatusCb,
+ this, &handle_);
+ if (ret != AUL_R_OK) {
+ _E("aul_app_com_create(%s) is failed. error(%d)", endpoint_.c_str(), ret);
+ THROW(ret);
+ }
+}
+
int AppEvent::OnAppStatusCb(const char* endpoint, aul_app_com_result_e res,
bundle* envelope, void* user_data) {
tizen_base::Bundle b(envelope);