+
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} ACTION_PLUGIN_DAEMON_SRCS)
ADD_EXECUTABLE(${TARGET_TIZEN_ACTION_PLUGIN_DAEMON}
${ACTION_PLUGIN_DAEMON_SRCS}
)
+SET(TARGET_ACTION_PLUGIN_SAMPLE "action-plugin-sample")
+ADD_LIBRARY(${TARGET_ACTION_PLUGIN_SAMPLE} plugin_sample_so.cc)
+
APPLY_PKG_CONFIG(${TARGET_TIZEN_ACTION_PLUGIN_DAEMON} PUBLIC
CAPI_APPFW_APP_COMMON_DEPS
CAPI_APPFW_APP_MANAGER_DEPS
RPC_PORT_DEPS
)
+APPLY_PKG_CONFIG(${TARGET_ACTION_PLUGIN_SAMPLE} PUBLIC
+ CAPI_APPFW_APP_COMMON_DEPS
+ DLOG_DEPS
+ GLIB_DEPS
+)
+
TARGET_LINK_LIBRARIES(${TARGET_TIZEN_ACTION_PLUGIN_DAEMON} PRIVATE ${TARGET_TIZEN_ACTION} ${TARGET_TIZEN_ACTION_COMMON})
TARGET_INCLUDE_DIRECTORIES(${TARGET_TIZEN_ACTION_PLUGIN_DAEMON} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
+TARGET_LINK_LIBRARIES(${TARGET_ACTION_PLUGIN_SAMPLE} PUBLIC ${TARGET_TIZEN_ACTION_COMMON})
+TARGET_INCLUDE_DIRECTORIES(${TARGET_ACTION_PLUGIN_SAMPLE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
INSTALL(TARGETS ${TARGET_TIZEN_ACTION_PLUGIN_DAEMON} DESTINATION bin)
-
+INSTALL(TARGETS ${TARGET_ACTION_PLUGIN_SAMPLE} DESTINATION ${LIB_INSTALL_DIR})
--- /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.
+ */
+
+#include <stdexcept>
+
+#include "common/utils/safe_json.hpp"
+#include "common/utils/logging.hh"
+
+
+#undef API
+#define API extern "C" __attribute__((visibility("default")))
+/*
+{
+ "version": "v2",
+ "name": "plugin-action-test",
+ "category": "test",
+ "desc": "Plugin test action",
+ "type": "plugin",
+ "params": {
+ "param1": {
+ "type": "string",
+ "desc": "String parameter.",
+ "isRequired": true
+ },
+ "param2": {
+ "type": "string",
+ "desc": "String parameter.",
+ "isRequired": true
+ }
+ },
+ "requiredPrivileges": [],
+ "returns": {
+ "result": {
+ "type": "string",
+ "desc": "The result string."
+ }
+ },
+ "details": {
+ "pluginPath": "/usr/lib64/libaction-plugin-sample.so"
+ }
+}
+*/
+API const char* PLUGIN_EXECUTE(const char* action_model_json) {
+ if (action_model_json == nullptr) {
+ LOG(ERROR) << "Invalid parameter";
+ return nullptr;
+ }
+
+ common::SafeJson result("{}");
+ try {
+ common::SafeJson json(action_model_json);
+ std::string param1 = json.get<std::string>("params.param1");
+ std::string param2 = json.get<std::string>("params.param2");
+ LOG(INFO) << "param1: " << param1 << ", param2: " << param2;
+ result.set("result", "success");
+ } catch (const std::runtime_error& e) {
+ common::SafeJson result("{}");
+ result.set("error", e.what());
+ return strdup(result.stringify().c_str());
+ }
+
+ return strdup(result.stringify().c_str());
+}