- Rename and move result handler interface.
- Fix namespace for rpc_port(tidl).
- Fix some parameter types.
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
db->ListActions();
}
-void ActionRequestHandler::OnGetAction(std::string id) {
+void ActionRequestHandler::OnGetAction(const std::string& id) {
auto db = std::make_unique<action::SqliteDb>();
db->GetAction(id);
}
-void ActionRequestHandler::OnGetActionId(std::string user_description,
+void ActionRequestHandler::OnGetActionId(const std::string& user_description,
int top_k, float search_threshold) {
}
-void ActionRequestHandler::OnExecute(std::string instance,
+void ActionRequestHandler::OnExecute(const std::string& requester,
common::ActionModel& model) {
LOG(DEBUG) << "OnExecute action : " << model.GetActionId()
<< ", appid : " << model.GetAppId();
if (model.GetType() == common::ActionType::AppControl) {
LOG(DEBUG) << "execute appcontrol";
- auto executor = std::make_unique<AppControlExecutor>(instance, model);
+ auto executor = std::make_unique<AppControlExecutor>(requester, model);
executor->SetResultHandler(this);
executor->Execute(model);
executors_.emplace_back(std::move(executor));
}
}
-void ActionRequestHandler::OnResult(std::string executor_id,
- std::string result) {
- LOG(DEBUG) << "OnResult : " << result << ", from : " << executor_id;
+void ActionRequestHandler::OnResult(const std::string& requester,
+ const std::string& result) {
+ LOG(DEBUG) << "OnResult : " << result << ", from : " << requester;
}
} // namespace action
#include <memory>
#include <vector>
+#include "action/result_handler.hh"
#include "action/request_handler.hh"
#include "action/tizen_action_service_stub.h"
#include "common/action_executor.hh"
#include "common/action_model.h"
-#include "common/action_result_handler.hh"
namespace action {
-class ActionRequestHandler : public IRequestHandler, public IActionResultHandler {
+class ActionRequestHandler : public IRequestHandler, public IResultHandler {
public:
ActionRequestHandler();
~ActionRequestHandler();
void Init();
void OnListActions() override;
- void OnGetAction(std::string id) override;
- void OnGetActionId(std::string user_description, int top_k,
+ void OnGetAction(const std::string& id) override;
+ void OnGetActionId(const std::string& user_description, int top_k,
float search_threshold) override;
- void OnExecute(std::string instance, common::ActionModel& model) override;
+ void OnExecute(const std::string& instance,
+ common::ActionModel& model) override;
- void OnResult(std::string executor_id, std::string result) override;
+ void OnResult(const std::string& requester,
+ const std::string& result) override;
private:
rpc_port::tizen_action_service_stub::stub::ActionService service_;
return true;
}
-void AppControlExecutor::SetResultHandler(IActionResultHandler* handler) {
+void AppControlExecutor::SetResultHandler(IResultHandler* handler) {
result_handler_ = handler;
}
#include <app_control.h>
+#include "action/result_handler.hh"
#include "common/action_executor.hh"
#include "common/action_model.h"
-#include "common/action_result_handler.hh"
namespace action {
int Execute(const common::ActionModel& model) override;
void OnAppControlReply(const std::string& reply);
- void SetResultHandler(IActionResultHandler* result_handler);
+ void SetResultHandler(IResultHandler* handler);
private:
void AddExtraData(const common::ActionModel& model);
common::ActionModel model_;
app_control_h app_control_;
- IActionResultHandler* result_handler_;
+ IResultHandler* result_handler_;
};
} // namespace action
public:
virtual ~IRequestHandler() = default;
virtual void OnListActions() = 0;
- virtual void OnGetAction(std::string id) = 0;
- virtual void OnGetActionId(std::string user_description, int top_k,
+ virtual void OnGetAction(const std::string& id) = 0;
+ virtual void OnGetActionId(const std::string& user_description, int top_k,
float search_threshold) = 0;
- virtual void OnExecute(std::string instance, common::ActionModel& model) = 0;
+ virtual void OnExecute(const std::string& requester, common::ActionModel& model) = 0;
};
} // namespace action
--- /dev/null
+/*
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTION_RESULT_HANDLER_HH_
+#define ACTION_RESULT_HANDLER_HH_
+
+#include <string>
+
+namespace action {
+
+class IResultHandler {
+ public:
+ virtual ~IResultHandler() = default;
+ virtual void OnResult(const std::string& executor_id,
+ const std::string& result) = 0;
+};
+
+} // namespace action
+
+#endif // ACTION_RESULT_HANDLER_HH_
Service::Service(std::string sender, std::string instance,
IRequestHandler& handler)
- : rs::stub::ActionService::ServiceBase(std::move(sender),
+ : rpc::stub::ActionService::ServiceBase(std::move(sender),
std::move(instance)), handler_(handler) {
}
Service::~Service() {
}
-std::vector<rs::Action> Service::ListActions() {
+std::vector<rpc::Action> Service::ListActions() {
// return list of actions from db
// handler_->ListActions();
return {};
}
-rs::Action Service::GetAction(std::string action_id) {
+rpc::Action Service::GetAction(std::string action_id) {
// return action by id
// ActionModel action = handler_.OnGetAction(action_id);
auto params = ps->GetParameters();
- rs::Action action;
- std::vector<rs::Parameter> actionparams;
+ rpc::Action action;
+ std::vector<rpc::Parameter> actionparams;
action.Setapp_id(ps->GetAppId());
action.Setaction_id(ps->GetName());
for (auto const& iter : params) {
auto param_value = iter.second;
- auto param = rs::Parameter(iter.first, param_value["type"], "", param_value["desc"],
+ auto param = rpc::Parameter(iter.first, param_value["type"], "", param_value["desc"],
param_value["isMandatory"].compare("true") == 0 ? true : false);
actionparams.push_back(param);
return action;
}
-std::vector<rs::VectorDbResult> Service::GetActionId(
+std::vector<rpc::VectorDbResult> Service::GetActionId(
std::string user_description, int top_k, float search_threshold) {
// return result from db
// handler_->GetActionId(user_description, top_k, search_threshold);
return {};
}
-int Service::Execute(rs::Action action) {
+int Service::Execute(rpc::Action action) {
LOG(DEBUG) << "Execute : " << action.Getaction_id() << ", type : " << action.Gettype();
std::string action_id = action.Getaction_id();
namespace action {
-namespace rs = rpc_port::tizen_action_service_stub;
+namespace rpc = rpc_port::tizen_action_service_stub;
-class Service : public rs::stub::ActionService::ServiceBase {
+class Service : public rpc::stub::ActionService::ServiceBase {
public:
- class Factory : public rs::stub::ActionService::ServiceBase::Factory {
+ class Factory : public rpc::stub::ActionService::ServiceBase::Factory {
public:
Factory(IRequestHandler& handler) : handler_(handler) {}
virtual ~Factory() = default;
- std::unique_ptr<rs::stub::ActionService::ServiceBase> CreateService(
+ std::unique_ptr<rpc::stub::ActionService::ServiceBase> CreateService(
std::string sender, std::string instance) override {
return std::make_unique<Service>(sender, instance, handler_);
}
void OnCreate() override {}
void OnTerminate() override {}
- std::vector<rs::Action> ListActions() override;
- rs::Action GetAction(std::string action_id) override;
- std::vector<rs::VectorDbResult> GetActionId(std::string user_description,
+ std::vector<rpc::Action> ListActions() override;
+ rpc::Action GetAction(std::string action_id) override;
+ std::vector<rpc::VectorDbResult> GetActionId(std::string user_description,
int top_k, float search_threshold) override;
- int Execute(rs::Action action) override;
+ int Execute(rpc::Action action) override;
int RegisterActionReplyCb(std::unique_ptr<ActionReplyCb> cb) override;
bool UnregisterActionReplyCb(int id) override;
+++ /dev/null
-/*
- * Copyright (c) 2025 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef COMMON_ACTION_RESULT_HANDLER_HH_
-#define COMMON_ACTION_RESULT_HANDLER_HH_
-
-class IActionResultHandler {
- public:
- virtual ~IActionResultHandler() = default;
- virtual void OnResult(std::string executor_id, std::string result) = 0;
-};
-
-#endif // COMMON_ACTION_RESULT_HANDLER_HH_
constexpr const char kStubAppId[] = "org.tizen.action-framework.service";
-namespace rp = rpc_port::tizen_action_service_proxy::proxy;
-using ActionReplyCb = rp::ActionService::ActionReplyCb;
+namespace rpc = rpc_port::tizen_action_service_proxy;
+using ActionReplyCb = rpc::proxy::ActionService::ActionReplyCb;
class Reply : public ActionReplyCb {
public:
void OnReceived(std::string result) {