From: Changgyu Choi Date: Wed, 11 Jun 2025 05:42:18 +0000 (+0900) Subject: Fix protocol mismatch for plugin action X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=HEAD;p=platform%2Fcore%2Fappfw%2Ftizen-action.git Fix protocol mismatch for plugin action Changes: - Modify sample so method interface to "TIZEN_ACTION_EXECUTE". - Matched return json format. Change-Id: I15222398c55e0ef0ce082946063ae05c832a4d21 Signed-off-by: Changgyu Choi --- diff --git a/src/plugin-daemon/main.cc b/src/plugin-daemon/main.cc index 5c3dc3e..01f51c9 100644 --- a/src/plugin-daemon/main.cc +++ b/src/plugin-daemon/main.cc @@ -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_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()); } } diff --git a/src/plugin-daemon/plugin_sample_so.cc b/src/plugin-daemon/plugin_sample_so.cc index e792944..b242ade 100644 --- a/src/plugin-daemon/plugin_sample_so.cc +++ b/src/plugin-daemon/plugin_sample_so.cc @@ -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("params.param1"); std::string param2 = json.get("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());