Draft tizen-action-plugin-daemon
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 5 Mar 2025 12:33:05 +0000 (21:33 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Mon, 10 Mar 2025 08:00:01 +0000 (17:00 +0900)
This is for plugin action handling.

Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
CMakeLists.txt
packaging/tizen-action-framework.spec
packaging/tizen-action-plugin-daemon.service [new file with mode: 0644]
packaging/tizen-action-plugin-daemon.socket [new file with mode: 0644]
src/CMakeLists.txt
src/plugin-daemon/CMakeLists.txt [new file with mode: 0644]
src/plugin-daemon/main.cc [new file with mode: 0644]
tidl/plugin_manager.tidl [new file with mode: 0644]
tidl/prebuild.sh
tidl/tizen_action_datatype.tidl [new file with mode: 0644]
tidl/tizen_actions.tidl

index b0f9ef47fcd973896e9640472859fcfb652f08c5..227ac757d6e74b4891e848053166897eb06265c1 100644 (file)
@@ -20,6 +20,7 @@ SET(TARGET_TIZEN_ACTION "tizen-action")
 SET(TARGET_TIZEN_ACTION_COMMON "tizen-action-common")
 SET(TARGET_TIZEN_ACTION_PLUGIN "tizen-action-plugin")
 SET(TARGET_TIZEN_ACTION_SERVICE "tizen-action-service")
+SET(TARGET_TIZEN_ACTION_PLUGIN_DAEMON "tizen-action-plugin-daemon")
 
 #ENABLE_TESTING()
 #SET(TARGET_TIZEN_ACTION_UNIT_TEST "tizen-action-unit-test")
index 3b672c8c29a19a865e105ccc6933e797144d65b7..8a2a150d90a4ccd51fb9c5c1d25c4e41332a44cf 100644 (file)
@@ -6,6 +6,8 @@ Group:      Application Framework/Package Management
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
+Source1002:  tizen-action-plugin-daemon.service
+Source1003:  tizen-action-plugin-daemon.socket
 BuildRequires:  cmake
 BuildRequires:  hash-signer
 BuildRequires:  tidl
@@ -40,6 +42,14 @@ Requires: %{name} = %{version}-%{release}
 %description tool
 Tizen Action Framework Tools.
 
+%package plugin-daemon
+Summary:  Tizen Action Framework Plugin Daemon
+Group:    Application Framework/Service
+Requires: %{name} = %{version}-%{release}
+
+%description plugin-daemon
+Tizen Action Framework Plugin Daemon
+
 %define service_pkgid org.tizen.action-framework.service
 %package -n %{service_pkgid}
 Summary:  Tizen Action Framework Service Package
@@ -65,6 +75,12 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 
 %install
 %make_install
+mkdir -p %{buildroot}%{_unitdir}/basic.target.wants
+mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants
+install -m 0644 %SOURCE1002 %{buildroot}%{_unitdir}/tizen-action-plugin-daemon.service
+install -m 0644 %SOURCE1003 %{buildroot}%{_unitdir}/tizen-action-plugin-daemon.socket
+ln -sf ../tizen-action-plugin-daemon.socket %{buildroot}%{_unitdir}/sockets.target.wants/tizen-action-plugin-daemon.socket
+ln -sf ../tizen-action-plugin-daemon.service %{buildroot}%{_unitdir}/basic.target.wants/tizen-action-plugin-daemon.service
 
 %post
 /sbin/ldconfig
@@ -97,6 +113,15 @@ fi
 %manifest %{name}.manifest
 %{_bindir}/action_fw_tool
 
+%files plugin-daemon
+%defattr(-,root,root,-)
+%manifest %{name}.manifest
+%{_unitdir}/tizen-action-plugin-daemon.service
+%{_unitdir}/tizen-action-plugin-daemon.socket
+%{_unitdir}/sockets.target.wants/tizen-action-plugin-daemon.socket
+%{_unitdir}/basic.target.wants/tizen-action-plugin-daemon.service
+%{_bindir}/tizen-action-plugin-daemon
+
 #Signing
 %define tizen_sign_base %{_prefix}/apps/%{service_pkgid};%{_prefix}/apps/%{service_pkgid}
 %define tizen_sign 1
diff --git a/packaging/tizen-action-plugin-daemon.service b/packaging/tizen-action-plugin-daemon.service
new file mode 100644 (file)
index 0000000..0d4209d
--- /dev/null
@@ -0,0 +1,16 @@
+[Unit]
+Description=Start Tizen Action Framework Plugin Daemon
+Requires=buxton2.service
+After=buxton2.service
+
+[Service]
+User=app_fw
+Group=app_fw
+SmackProcessLabel=System
+ExecStart=/usr/bin/tizen-action-plugin-daemon
+Restart=on-failure
+RestartSec=3
+MemoryLimit=100M
+
+[Install]
+Sockets=tizen-action-plugin-daemon.socket
diff --git a/packaging/tizen-action-plugin-daemon.socket b/packaging/tizen-action-plugin-daemon.socket
new file mode 100644 (file)
index 0000000..371aeb8
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Tizen Action Framework Plugin Daemon socket
+DefaultDependencies=no
+Before=sockets.target
+
+[Socket]
+ListenStream=/run/aul/rpcport/.d::org.tizen.appfw.service.tizen_action_plugin_manager
+SocketMode=0666
+SmackLabelIPIn=*
+SmackLabelIPOut=@
+Service=tizen-action-plugin-daemon.service
+
+[Install]
+WantedBy=sockets.target
index 8bf8dd912e1a7e6ee225c41c10b8191fb012c7ab..1e7a78be37d0f13fad71233753591b549c8c577e 100644 (file)
@@ -2,3 +2,4 @@ ADD_SUBDIRECTORY(action)
 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(pkgmgr_plugin_parser)
 ADD_SUBDIRECTORY(service)
+ADD_SUBDIRECTORY(plugin-daemon)
diff --git a/src/plugin-daemon/CMakeLists.txt b/src/plugin-daemon/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2617559
--- /dev/null
@@ -0,0 +1,21 @@
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} ACTION_PLUGIN_DAEMON_SRCS)
+
+ADD_EXECUTABLE(${TARGET_TIZEN_ACTION_PLUGIN_DAEMON}
+  ${ACTION_PLUGIN_DAEMON_SRCS}
+)
+
+APPLY_PKG_CONFIG(${TARGET_TIZEN_ACTION_PLUGIN_DAEMON} PUBLIC
+  CAPI_APPFW_APP_COMMON_DEPS
+  CAPI_APPFW_APP_MANAGER_DEPS
+  CAPI_APPFW_PACKAGE_MANAGER_DEPS
+  CAPI_APPFW_SERVICE_APPLICATION_DEPS
+  DLOG_DEPS
+  GLIB_DEPS
+  TIZEN_DATABASE_DEPS
+  RPC_PORT_DEPS
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_TIZEN_ACTION_PLUGIN_DAEMON} PRIVATE ${TARGET_TIZEN_ACTION} ${TARGET_TIZEN_ACTION_COMMON})
+
+INSTALL(TARGETS ${TARGET_TIZEN_ACTION_PLUGIN_DAEMON} DESTINATION bin)
+
diff --git a/src/plugin-daemon/main.cc b/src/plugin-daemon/main.cc
new file mode 100644 (file)
index 0000000..ca4aab3
--- /dev/null
@@ -0,0 +1,55 @@
+#include <cstdio>
+#include <rpc-port-internal.h>
+#include <utility>
+
+#include "common/utils/logging.hh"
+#include "plugin_manager_stub.h"
+
+class PluginService : public rpc_port::plugin_manager_stub::stub::PluginManager::ServiceBase {
+ public:
+  class Factory : public rpc_port::plugin_manager_stub::stub::PluginManager::ServiceBase::Factory {
+   public:
+    std::unique_ptr<rpc_port::plugin_manager_stub::stub::PluginManager::ServiceBase> CreateService(
+        std::string sender, std::string instance) override {
+      return std::make_unique<PluginService>(std::move(sender), std::move(instance));
+    }
+  };
+
+  PluginService(std::string sender, std::string instance) : ServiceBase(sender, instance) {
+
+  }
+
+  void OnCreate() override {
+    std::string sender = GetSender();
+    std::string instance = GetInstance();
+    LOG(INFO) << "PluginService created. sender: " << sender << ", instance: " << instance;
+  }
+
+  void OnTerminate() override {
+    std::string sender = GetSender();
+    std::string instance = GetInstance();
+    LOG(INFO) << "PluginService terminated. sender: " << sender << ", instance: " << instance;
+  }
+
+  rpc_port::plugin_manager_stub::Bundle Execute(rpc_port::plugin_manager_stub::Action action) {
+    std::string sender = GetSender();
+    std::string instance = GetInstance();
+    LOG(INFO) << "PluginService execute. sender: " << sender << ", instance: " << instance;
+    return rpc_port::plugin_manager_stub::Bundle();
+  }
+};
+
+int main() {
+  int ret =
+      rpc_port_register_proc_info(".d::org.tizen.appfw.service.tizen_action_plugin_manager", nullptr);
+  if (ret != 0) {
+    perror("Failed to register proc info");
+    return -1;
+  }
+
+  rpc_port::plugin_manager_stub::stub::PluginManager stub;
+  stub.Listen(std::make_shared<PluginService::Factory>());
+  auto* mainloop = g_main_loop_new(nullptr, FALSE);
+  g_main_loop_run(mainloop);
+  g_main_loop_unref(mainloop);
+}
diff --git a/tidl/plugin_manager.tidl b/tidl/plugin_manager.tidl
new file mode 100644 (file)
index 0000000..58cb3a6
--- /dev/null
@@ -0,0 +1,6 @@
+protocol 2
+import <tizen_action_datatype.tidl>
+
+interface PluginManager {
+    bundle Execute(Action action);
+}
index 30411e4fe6650b4f2a12c542994258db278df007..b532293e32ce344434bd965d3c7335105fc5f833 100755 (executable)
@@ -2,6 +2,7 @@
 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
 tidlc -p -l C++ -i $SCRIPT_DIR/tizen_actions.tidl -o tizen_action_service_proxy
 tidlc -s -l C++ -i $SCRIPT_DIR/tizen_actions.tidl -o tizen_action_service_stub
+tidlc -s -l C++ -i $SCRIPT_DIR/plugin_manager.tidl -o plugin_manager_stub
 
 if [ $? -ne 0 ]; then
     echo "*** Failed to generate TIDL code ***"
@@ -10,3 +11,4 @@ fi
 
 mv tizen_action_service_proxy.* $SCRIPT_DIR/../src/api/
 mv tizen_action_service_stub.* $SCRIPT_DIR/../src/action/
+mv plugin_manager_stub.* $SCRIPT_DIR/../src/plugin-daemon/
diff --git a/tidl/tizen_action_datatype.tidl b/tidl/tizen_action_datatype.tidl
new file mode 100644 (file)
index 0000000..8f3b1e6
--- /dev/null
@@ -0,0 +1,33 @@
+protocol 2
+
+struct Parameter {
+    string key;
+    string type;
+    string value;
+    string description;
+    bool is_requied;
+}
+
+struct Result {
+    string key;
+    string type;
+}
+
+struct Action {
+    string action_id;
+    string app_id;
+    string label;
+    string description;
+    string type;
+    string uri;
+    string mime;
+    string operation;
+    array<Parameter> parameters;
+    array<Result> results;
+    array<string> privileges;
+}
+
+struct VectorDbResult {
+    string action_id;
+    float score;
+}
index 2154c9efd2e30df66c9ab05f3aaaf7ae47f56a15..a1267c2ef15af05f1a7b54f3d06faf070f0de1ac 100644 (file)
@@ -1,36 +1,5 @@
 protocol 2
-
-struct Parameter {
-    string key;
-    string type;
-    string value;
-    string description;
-    bool is_requied;
-}
-
-struct Result {
-    string key;
-    string type;
-}
-
-struct Action {
-    string action_id;
-    string app_id;
-    string label;
-    string description;
-    string type;
-    string uri;
-    string mime;
-    string operation;
-    array<Parameter> parameters;
-    array<Result> results;
-    array<string> privileges;
-}
-
-struct VectorDbResult {
-    string action_id;
-    float score;
-}
+import <tizen_action_datatype.tidl>
 
 interface ActionService {
     array<Action> ListActions();