Fix miscellaneous
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 6 Mar 2025 02:17:35 +0000 (11:17 +0900)
committer장상윤/Tizen Platform Lab(SR)/삼성전자 <jeremy.jang@samsung.com>
Mon, 10 Mar 2025 05:52:24 +0000 (14:52 +0900)
- 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>
src/action/action_request_handler.cc
src/action/action_request_handler.hh
src/action/app_control_executor.cc
src/action/app_control_executor.hh
src/action/request_handler.hh
src/action/result_handler.hh [new file with mode: 0644]
src/action/service.cc
src/action/service.hh
src/common/action_result_handler.hh [deleted file]
tool/action_fw_tool/tools/execute.cc

index aa8483c87058163211f56c8423c8f432b6b88d5d..bec6995e2d9c6ce639e838da972e68e2a94dbabe 100644 (file)
@@ -41,16 +41,16 @@ void ActionRequestHandler::OnListActions() {
   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();
@@ -58,7 +58,7 @@ void ActionRequestHandler::OnExecute(std::string instance,
   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));
@@ -67,9 +67,9 @@ void ActionRequestHandler::OnExecute(std::string instance,
   }
 }
 
-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
index ea4529095dc5de53bc8684bf3afa024c6d1c52d7..2c926d11391b3f19a9fa4716295326adff501c57 100644 (file)
 #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_;
index e3c106b737597b6dd8283645c1cdf899a2fbaa36..1d17ebaed6151775a0c542367d1cbac2f17246f4 100644 (file)
@@ -119,7 +119,7 @@ bool AppControlExecutor::SendAppControl() {
   return true;
 }
 
-void AppControlExecutor::SetResultHandler(IActionResultHandler* handler) {
+void AppControlExecutor::SetResultHandler(IResultHandler* handler) {
   result_handler_ = handler;
 }
 
index dbb547ecb4f6f13339abed7959a3acc83c55e23a..5e54197ef45156d4326910c581693d278086c66f 100644 (file)
@@ -19,9 +19,9 @@
 
 #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 {
 
@@ -32,7 +32,7 @@ class AppControlExecutor : public common::AbstractActionExecutor {
   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);
@@ -40,7 +40,7 @@ class AppControlExecutor : public common::AbstractActionExecutor {
 
   common::ActionModel model_;
   app_control_h app_control_;
-  IActionResultHandler* result_handler_;
+  IResultHandler* result_handler_;
 };
 
 }  // namespace action
index 153eda7bf713d863ac7a1022c10095e41c2c3ebd..0cd57c93a371d35e5eba63f04463b359b48429b5 100644 (file)
@@ -30,10 +30,10 @@ class IRequestHandler {
  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
diff --git a/src/action/result_handler.hh b/src/action/result_handler.hh
new file mode 100644 (file)
index 0000000..9f9763a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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_
index a7eece2672ba262bfdff0267014ef67d35fc24e9..e8229793399225ab31544ccf08a0c60b2174a0cf 100644 (file)
@@ -56,20 +56,20 @@ namespace action {
 
 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);
 
@@ -85,8 +85,8 @@ rs::Action Service::GetAction(std::string 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());
@@ -96,7 +96,7 @@ rs::Action Service::GetAction(std::string action_id) {
   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);
@@ -111,14 +111,14 @@ rs::Action Service::GetAction(std::string action_id) {
   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();
index fb62f416c3586c83f3bd11578a77d451d7231f64..ba39e1ef7ee586d5d8674e60f3f1550dfe2839ef 100644 (file)
@@ -29,15 +29,15 @@ using ActionReplyCb =
 
 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_);
     }
@@ -51,11 +51,11 @@ class Service : public rs::stub::ActionService::ServiceBase {
 
   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;
 
diff --git a/src/common/action_result_handler.hh b/src/common/action_result_handler.hh
deleted file mode 100644 (file)
index c6cc429..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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_
index 5a642f9f5be0d727580b7b5c74f4982e921b36f6..2af8a30d6530b2f64948c496b066a8b70ef11908 100644 (file)
@@ -26,8 +26,8 @@ namespace action_fw_tool {
 
 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) {