app_control_h app_control = ConvertToAppControl(model);
std::unique_ptr<AppControlSender> sender =
- std::make_unique<AppControlSender>(app_control);
+ std::make_unique<AppControlSender>(app_control, this);
// TODO: handle result?
sender->Send();
return 0;
}
+void AppControlExecutor::OnReply(const std::string& reply) {
+ // TODO: Handle reply
+ LOG(DEBUG) << reply;
+}
+
} // namespace action
void ReplyCb(app_control_h request, app_control_h reply,
app_control_result_e result, void* user_data) {
// TODO: return reply to caller
+ common::IActionExecutor* on_reply =
+ static_cast<common::IActionExecutor*>(user_data);
+
+ // TODO: return what
+ std::string result_str = "result";
+ on_reply->OnReply(result_str);
}
} // namespace
namespace action {
-AppControlSender::AppControlSender(app_control_h app_control)
- : app_control_(app_control) {
+AppControlSender::AppControlSender(app_control_h app_control,
+ common::IActionExecutor* executor)
+ : app_control_(app_control), executor_(executor) {
}
AppControlSender::~AppControlSender() {
bool AppControlSender::Send() {
int ret = app_control_send_launch_request_async(app_control_, ResultCb,
- ReplyCb, nullptr);
+ ReplyCb, static_cast<void*>(executor_));
if (ret != APP_CONTROL_ERROR_NONE) {
LOG(ERROR) << "Failed to send launch request: " << ret;
return false;
#include <app_control.h>
+#include "common/action_executor.hh"
+
namespace action {
class AppControlSender {
public:
- AppControlSender(app_control_h app_control);
+ AppControlSender(app_control_h app_control,
+ common::IActionExecutor* executor);
~AppControlSender();
bool Send();
private:
app_control_h app_control_;
+ common::IActionExecutor* executor_;
};
} // action
#ifndef COMMON_ACTION_EXECUTOR_HH_
#define COMMON_ACTION_EXECUTOR_HH_
+#include <string>
+
#include "common/action_model.h"
namespace common {
public:
virtual ~IActionExecutor() = default;
virtual int Execute(const ActionModel& model) = 0;
+ virtual void OnReply(const std::string& result) = 0;
};
} // namespace common