[action_fw_tool] Add execute command
authorChanggyu Choi <changyu.choi@samsung.com>
Tue, 21 Jan 2025 08:16:42 +0000 (17:16 +0900)
committer최창규/Tizen Platform Lab(SR)/삼성전자 <changyu.choi@samsung.com>
Tue, 21 Jan 2025 08:33:47 +0000 (17:33 +0900)
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/service/build.sh
src/service/src/action_request_handler.cc
src/service/src/action_request_handler.h
src/service/src/irequest_handler.h
src/service/src/service.cc
src/service/src/service.h
tidl/tizen_actions.tidl
tool/action_fw_tool/CMakeLists.txt
tool/action_fw_tool/tools/execute.cc [new file with mode: 0644]

index 981676b53cad372a364da79a2fb45bf8d88c457c..6d8f0442c24a300a970fcda2b0de96b9905b5797 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/bash
 
-tizen build-native -C Debug -a arm -c gcc && tizen package -t tpk -- ./Debug
\ No newline at end of file
+tizen build-native -C Debug -a arm -c gcc && tizen package -t tpk -- ./Debug
index 3a12c4bd2b909ffc0df6a0d9437a61f7ed144420..77dee86687efdd874dd3863e8233e72351adb73e 100644 (file)
@@ -41,4 +41,8 @@ void ActionRequestHandler::OnGetActionId(std::string user_description, int top_k
     float search_threshold) {
 }
 
+void ActionRequestHandler::OnExecute(std::string launch_req) {
+
+}
+
 }  // namespace service
index e64feea615776d313ba646a659a08283579a42c5..dfbdd2543ded171adef792e7ca3cc1ced77297be 100644 (file)
@@ -36,6 +36,7 @@ class ActionRequestHandler : public IRequestHandler {
   void OnGetAction(std::string id) override;
   void OnGetActionId(std::string user_description, int top_k,
       float search_threshold) override;
+  void OnExecute(std::string request) override;
 
  private:
   rpc_port::tizen_action_service_stub::stub::ActionService service_;
index fa22135eefd76f654d11799273a5b6b28545a444..57ca85dc29185e985a84b7e1b72123094a609df1 100644 (file)
@@ -28,6 +28,7 @@ class IRequestHandler {
   virtual void OnGetAction(std::string id) = 0;
   virtual void OnGetActionId(std::string user_description, int top_k,
       float search_threshold) = 0;
+  virtual void OnExecute(std::string launch_req) = 0;
 };
 
 }  // namespace service
index fb0301b0d8427c8bd2a129d250a3a779b101fd0e..7a13c0de138d32b567fe2c93dd41f7ea4485438e 100644 (file)
@@ -47,4 +47,10 @@ std::vector<rs::VectorDbResult> Service::GetActionId(
   return {};
 }
 
+int Service::Execute(std::string launch_req) {
+  // return action exetution result
+  // handler_->Execute(std::move(launch_req));
+  return 0;
+}
+
 }  // namespace service
index f01e586677d4e17e2fe7a2307fe6d9e9d261c0af..a6aec8cf9b10f50b658ae70b4284b4782590acb6 100644 (file)
@@ -52,6 +52,7 @@ class Service : public rs::stub::ActionService::ServiceBase {
   rs::Action GetAction(std::string action_id) override;
   std::vector<rs::VectorDbResult> GetActionId(std::string user_description,
       int top_k, float search_threshold) override;
+  int Execute(std::string launch_req) override;
 
  private:
   IRequestHandler& handler_;
index ee4c509def5603bcfc94800703148d646d3c6d49..58e01719a54811e38e1b3c5110b2c19dbfa144ae 100644 (file)
@@ -34,4 +34,5 @@ interface ActionService {
     array<Action> ListActions();
     Action GetAction(string action_id);
     array<VectorDbResult> GetActionId(string user_description, int top_k, float search_threshold);
+    int Execute(string launch_req);
 }
index 192d7acd3ebbb63eff8e75dda885378ab8e55655..873305c93a193ada704b46696d60287919300cf8 100644 (file)
@@ -2,7 +2,7 @@ SET(TARGET_ACTION_FW_TOOL "action_fw_tool")
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} ACTION_FW_TOOL_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/tools TOOLS_SRCS)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../.. ACTION_FW_SERVICE_PROXY_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src/api/ ACTION_FW_SERVICE_PROXY_SRCS)
 
 ADD_EXECUTABLE(${TARGET_ACTION_FW_TOOL}
   ${ACTION_FW_TOOL_SRCS}
@@ -30,7 +30,7 @@ APPLY_PKG_CONFIG(${TARGET_ACTION_FW_TOOL} PUBLIC
 
 TARGET_INCLUDE_DIRECTORIES(${TARGET_ACTION_FW_TOOL} PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}/
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../src/api/
 )
 
 INSTALL(TARGETS ${TARGET_ACTION_FW_TOOL} DESTINATION bin)
diff --git a/tool/action_fw_tool/tools/execute.cc b/tool/action_fw_tool/tools/execute.cc
new file mode 100644 (file)
index 0000000..5c1683b
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+#include "action_fw_tool.hh"
+#include "log_private.hh"
+
+#include <utility>
+
+#include "tizen_action_service_proxy.h"
+
+namespace action_fw_tool {
+
+constexpr const char kStubAppId[] = "org.tizen.action-framework.service";
+
+class Execute : public ActionFwTool,
+                  rpc_port::tizen_action_service_proxy::proxy::ActionService::
+                      IEventListener {
+ public:
+  Execute()
+      : ActionFwTool("execute", "Execute", "execute <launch_request(string)>"),
+        proxy_(this, kStubAppId) {}
+
+  virtual ~Execute() {}
+
+  void SetUp() override {
+    try {
+      proxy_.Connect(true);
+      connected = true;
+    } catch (
+        const rpc_port::tizen_action_service_proxy::proxy::InvalidIDException&
+            e) {
+      _E("InvalidIDException");
+    } catch (
+        const rpc_port::tizen_action_service_proxy::proxy::InvalidIOException&
+            e) {
+      _E("InvalidIOException");
+    } catch (const rpc_port::tizen_action_service_proxy::proxy::
+                 PermissionDeniedException& e) {
+      _E("PermissionDeniedException");
+    } catch (...) {
+      _E("Unknown exception");
+    }
+  }
+
+  void TearDown() override {
+    if (connected)
+      proxy_.Disconnect();
+  }
+
+  int Run(int argc, char** argv) override {
+    if (argc < 3) {
+      Usage();
+      return -1;
+    }
+
+    std::string launch_req = std::string(argv[2]);
+    try {
+      int ret = proxy_.Execute(std::move(launch_req));
+      return ret;
+    } catch (...) {
+      _E("Execute Failed");
+      return -1;
+    }
+  }
+
+  void OnConnected() override {
+    connected = true;
+    _W("connected");
+  }
+
+  void OnDisconnected() override {
+    connected = false;
+    _W("disconnected");
+  }
+
+  void OnRejected() override {
+    connected = false;
+    _W("Rejected");
+  }
+
+ private:
+  rpc_port::tizen_action_service_proxy::proxy::ActionService proxy_;
+  bool connected = false;
+};
+
+ACTION_FW_TOOL_REGISTER(Execute, execute);
+
+}  // namespace action_fw_tool