From: Changgyu Choi Date: Tue, 11 Mar 2025 07:09:35 +0000 (+0900) Subject: Implement missing CreateExecutor() method X-Git-Tag: accepted/tizen/unified/20250514.114137~44^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f630b1484966a7a7261e4546af774b49b9f8ae6;p=platform%2Fcore%2Fappfw%2Ftizen-action.git Implement missing CreateExecutor() method Signed-off-by: Changgyu Choi --- diff --git a/src/action/action_executor_factory.cc b/src/action/action_executor_factory.cc index f641bd7..3344430 100644 --- a/src/action/action_executor_factory.cc +++ b/src/action/action_executor_factory.cc @@ -1,6 +1,31 @@ #include "action_executor_factory.hh" +#include "app_control_executor.hh" +#include "plugin_executor.hh" + +namespace action { + +class DefaultActionExecutor : public common::AbstractActionExecutor { + public: + explicit DefaultActionExecutor() : AbstractActionExecutor("") {} + ~DefaultActionExecutor() = default; + + int Execute(const common::ActionModel& model) override { return -1; } + void SetResultHandler(common::IResultHandler* handler) override {} +}; + std::unique_ptr -action::ActionExecutorFactory::CreateExecutor(common::ActionType type) { - return std::unique_ptr(); +ActionExecutorFactory::CreateExecutor(std::string instance, + const common::ActionModel& model) { + switch (model.GetType()) { + case common::ActionType::AppControl: + return std::make_unique(std::move(instance), + model); + case common::ActionType::Plugin: + return std::make_unique(std::move(instance)); + default: + return std::unique_ptr(); + } } + +} // namespace action diff --git a/src/action/action_executor_factory.hh b/src/action/action_executor_factory.hh index 85b40da..572e311 100644 --- a/src/action/action_executor_factory.hh +++ b/src/action/action_executor_factory.hh @@ -17,7 +17,9 @@ #ifndef ACTION_ACTION_EXECUTOR_FACTORY_HH_ #define ACTION_ACTION_EXECUTOR_FACTORY_HH_ +#include #include + #include "common/action_executor.hh" namespace action { @@ -25,7 +27,8 @@ namespace action { class ActionExecutorFactory { public: static std::unique_ptr CreateExecutor( - common::ActionType type); + std::string instance, + const common::ActionModel& model); }; } // namespace action diff --git a/src/action/action_request_handler.cc b/src/action/action_request_handler.cc index db1b5b9..d042198 100644 --- a/src/action/action_request_handler.cc +++ b/src/action/action_request_handler.cc @@ -49,16 +49,12 @@ void ActionRequestHandler::OnGetActionId(const std::string& user_description, int top_k, float search_threshold) {} -void ActionRequestHandler::OnExecute(const std::string& requester, +void ActionRequestHandler::OnExecute(const std::string& instance, common::ActionModel& model) { LOG(DEBUG) << "OnExecute action : " << model.GetActionId() << ", appid : " << model.GetAppId(); - LOG(DEBUG) << "execute action type: " - << (model.GetType() == common::ActionType::AppControl - ? "AppControl" - : "Plugin"); - auto executor = ActionExecutorFactory::CreateExecutor(model.GetType()); + auto executor = ActionExecutorFactory::CreateExecutor(instance, model); executor->SetResultHandler(this); executor->Execute(model); executors_.emplace_back(std::move(executor)); diff --git a/src/action/plugin_executor.cc b/src/action/plugin_executor.cc index 7dd82f7..08921c7 100644 --- a/src/action/plugin_executor.cc +++ b/src/action/plugin_executor.cc @@ -44,9 +44,8 @@ class ResultHandler : public rpc_port::plugin_manager_proxy::proxy:: PluginExecutor* executor_ = nullptr; }; -PluginExecutor::PluginExecutor(std::string id, const common::ActionModel& model) +PluginExecutor::PluginExecutor(std::string id) : AbstractActionExecutor(std::move(id)), - model_(model), plugin_manager_( this, "d::org.tizen.appfw.service.tizen_action_plugin_manager") {} @@ -57,6 +56,11 @@ PluginExecutor::~PluginExecutor() { } int PluginExecutor::Execute(const common::ActionModel& model) { + if (model.GetType() != common::ActionType::Plugin) { + LOG(ERROR) << "Invalid action type"; + return -1; + } + LOG(ERROR) << "Plugin Execute : " << model.GetUri(); if (!Connect()) diff --git a/src/action/plugin_executor.hh b/src/action/plugin_executor.hh index 089505e..ac9777d 100644 --- a/src/action/plugin_executor.hh +++ b/src/action/plugin_executor.hh @@ -29,7 +29,7 @@ class PluginExecutor : public common::AbstractActionExecutor, public rpc_port::plugin_manager_proxy::proxy:: PluginManager::IEventListener { public: - explicit PluginExecutor(std::string id, const common::ActionModel& model); + explicit PluginExecutor(std::string instance); ~PluginExecutor(); int Execute(const common::ActionModel& model) override; void SetResultHandler(common::IResultHandler* handler) override; @@ -43,7 +43,6 @@ class PluginExecutor : public common::AbstractActionExecutor, void OnRejected() override; private: - common::ActionModel model_; rpc_port::plugin_manager_proxy::proxy::PluginManager plugin_manager_; common::IResultHandler* result_handler_ = nullptr; bool connected_ = false;