Fix protocol mismatch for plugin action 04/325504/2 tizen
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 11 Jun 2025 05:42:18 +0000 (14:42 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 11 Jun 2025 05:57:37 +0000 (14:57 +0900)
Changes:
 - Modify sample so method interface to "TIZEN_ACTION_EXECUTE".
 - Matched return json format.

Change-Id: I15222398c55e0ef0ce082946063ae05c832a4d21
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/plugin-daemon/main.cc
src/plugin-daemon/plugin_sample_so.cc

index 5c3dc3ecfcad21c8e99508e7988951763042e9f5..01f51c95bae8c62f071921feb52f32af2af4e5a5 100644 (file)
@@ -115,15 +115,15 @@ class PluginService
       std::string plugin_path = root_path + "/lib/" + schema.GetPluginPath();
       LOG(INFO) << "Plugin path: " + plugin_path;
       auto plugin = std::make_unique<Plugin>(plugin_path);
-      std::string result_json = plugin->Execute(action.Getjson());
-      common::SafeJson result("{}");
-      result.set("data", result_json);
-      result_cb->Invoke(result.stringify());
+      std::string result = plugin->Execute(action.Getjson());
+      common::SafeJson result_json("{}");
+      result_json.set("result", result);
+      result_cb->Invoke(result_json.stringify());
     } catch (const std::runtime_error& e) {
       LOG(ERROR) << "Exception occurred: " << e.what();
-      common::SafeJson result("{}");
-      result.set("error", e.what());
-      result_cb->Invoke(result.stringify());
+      common::SafeJson result_json("{}");
+      result_json.set("error", e.what());
+      result_cb->Invoke(result_json.stringify());
     }
   }
 
index e7929440e6a8889bfb702bd0e67aa752cc244cec..b242ade944c55219861cf025a187deeb2f9b620a 100644 (file)
@@ -53,7 +53,7 @@
   }
 }
 */
-API const char* PLUGIN_EXECUTE(const char* action_model_json) {
+API const char* TIZEN_ACTION_EXECUTE(const char* action_model_json) {
   if (action_model_json == nullptr) {
     LOG(ERROR) << "Invalid parameter";
     return nullptr;
@@ -65,7 +65,7 @@ API const char* PLUGIN_EXECUTE(const char* 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");
+    return strdup((param1 + " " + param2).c_str());
   } catch (const std::runtime_error& e) {
     common::SafeJson error_result("{}");
     error_result.set("error", e.what());