Add base code for app_control executor
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 13 Feb 2025 06:45:14 +0000 (15:45 +0900)
committer장상윤/Tizen Platform Lab(SR)/삼성전자 <jeremy.jang@samsung.com>
Thu, 13 Feb 2025 08:46:42 +0000 (17:46 +0900)
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
CMakeLists.txt
packaging/tizen-action-framework.spec
src/action/CMakeLists.txt
src/action/app_control_executor.cc [new file with mode: 0644]
src/action/app_control_executor.hh [new file with mode: 0644]
src/action/app_control_sender.cc [new file with mode: 0644]
src/action/app_control_sender.hh [new file with mode: 0644]
src/common/action_executor.hh [new file with mode: 0644]

index 9f48f288c8461c1e0f8a057bfcf310c1adeb78e4..b0f9ef47fcd973896e9640472859fcfb652f08c5 100644 (file)
@@ -32,6 +32,7 @@ ADD_DEFINITIONS("-DPROJECT_TAG=\"TIZEN_ACTION_FRAMEWORK\"")
 ## Find all needed packages once
 PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle)
 PKG_CHECK_MODULES(CAPI_APPFW_APP_COMMON_DEPS REQUIRED capi-appfw-app-common)
+PKG_CHECK_MODULES(CAPI_APPFW_APP_CONTROL_DEPS REQUIRED capi-appfw-app-control)
 PKG_CHECK_MODULES(CAPI_APPFW_APP_MANAGER_DEPS REQUIRED capi-appfw-app-manager)
 PKG_CHECK_MODULES(CAPI_APPFW_PACKAGE_MANAGER_DEPS REQUIRED capi-appfw-package-manager)
 PKG_CHECK_MODULES(CAPI_APPFW_SERVICE_APPLICATION_DEPS REQUIRED capi-appfw-service-application)
index 78a84c10b1b03c66f6e1b68a14d914e75d2de9e7..1d5808a3ca98ce06fb32e922ca69c5fe93084d2a 100644 (file)
@@ -11,6 +11,7 @@ BuildRequires:  hash-signer
 BuildRequires:  tidl
 BuildRequires:  pkgconfig(bundle)
 BuildRequires:  pkgconfig(capi-appfw-app-common)
+BuildRequires:  pkgconfig(capi-appfw-app-control)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  pkgconfig(capi-appfw-package-manager)
 BuildRequires:  pkgconfig(capi-appfw-service-application)
index f0f31d9cc10aae732d9fde5f5c45defa3e292894..5f9bfd1acea4595bbcffb0615dfac9eb89a8b0ec 100644 (file)
@@ -1,11 +1,13 @@
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} ACTION_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/executor ACTION_EXECUTOR_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils ACTION_UTILS_SRCS)
-ADD_LIBRARY(${TARGET_TIZEN_ACTION} ${ACTION_SRCS} ${ACTION_UTILS_SRCS})
+ADD_LIBRARY(${TARGET_TIZEN_ACTION} ${ACTION_SRCS} ${ACTION_EXECUTOR_SRCS} ${ACTION_UTILS_SRCS})
 
 TARGET_INCLUDE_DIRECTORIES(${TARGET_TIZEN_ACTION} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
 APPLY_PKG_CONFIG(${TARGET_TIZEN_ACTION} PUBLIC
   CAPI_APPFW_APP_COMMON_DEPS
+  CAPI_APPFW_APP_CONTROL_DEPS
   CAPI_APPFW_APP_MANAGER_DEPS
   CAPI_APPFW_PACKAGE_MANAGER_DEPS
   CAPI_APPFW_SERVICE_APPLICATION_DEPS
diff --git a/src/action/app_control_executor.cc b/src/action/app_control_executor.cc
new file mode 100644 (file)
index 0000000..4fc97ad
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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 "action/app_control_executor.hh"
+
+#include <app_control.h>
+
+#include <memory>
+
+#include "action/app_control_sender.hh"
+#include "common/action_model.h"
+#include "common/utils/logging.hh"
+
+namespace {
+
+app_control_h ConvertToAppControl(const common::ActionModel& action_model) {
+  app_control_h handle = nullptr;
+
+  int ret = app_control_create(&handle);
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOG(ERROR) << "Failed to create app_control handle: " << ret;
+    return nullptr;
+  }
+
+  // TODO: Convert to app_control handle from action model
+
+  return handle;
+}
+
+}  // namespace
+
+namespace action {
+
+int AppControlExecutor::Execute(const common::ActionModel& model) {
+  app_control_h app_control = ConvertToAppControl(model);
+
+  std::unique_ptr<AppControlSender> sender =
+      std::make_unique<AppControlSender>(app_control);
+
+  // TODO: handle result?
+  sender->Send();
+
+  senders_.emplace_back(std::move(sender));
+
+  return 0;
+}
+
+}  // namespace action
diff --git a/src/action/app_control_executor.hh b/src/action/app_control_executor.hh
new file mode 100644 (file)
index 0000000..47cdf51
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#ifndef ACTION_APP_CONTROL_EXECUTOR_HH_
+#define ACTION_APP_CONTROL_EXECUTOR_HH_
+
+#include <memory>
+
+#include "action/app_control_sender.hh"
+#include "common/action_executor.hh"
+#include "common/action_model.h"
+
+namespace action {
+
+class AppControlExecutor : public common::IActionExecutor {
+ public:
+  AppControlExecutor();
+  ~AppControlExecutor();
+  int Execute(const common::ActionModel& model) override;
+
+ private:
+  std::vector<std::unique_ptr<AppControlSender>> senders_;
+};
+
+}  // namespace action
+
+#endif  // ACTION_APP_CONTROL_EXECUTOR_HH_
diff --git a/src/action/app_control_sender.cc b/src/action/app_control_sender.cc
new file mode 100644 (file)
index 0000000..44af907
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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 "action/app_control_sender.hh"
+
+#include <app_control.h>
+
+#include "common/utils/logging.hh"
+
+namespace {
+
+void ResultCb(app_control_h request, app_control_error_e result,
+    void* user_data) {
+  LOG(DEBUG) << "ResultCb: " << result;
+}
+
+void ReplyCb(app_control_h request, app_control_h reply,
+    app_control_result_e result, void* user_data) {
+  // TODO: return reply to caller
+}
+
+}  // namespace
+
+namespace action {
+
+AppControlSender::AppControlSender(app_control_h app_control)
+    : app_control_(app_control) {
+}
+
+AppControlSender::~AppControlSender() {
+  int ret = app_control_destroy(app_control_);
+  if (ret != APP_CONTROL_ERROR_NONE)
+    LOG(ERROR) << "Failed to destroy app_control: " << ret;
+}
+
+bool AppControlSender::Send() {
+  int ret = app_control_send_launch_request_async(app_control_, ResultCb,
+      ReplyCb, nullptr);
+  if (ret != APP_CONTROL_ERROR_NONE) {
+    LOG(ERROR) << "Failed to send launch request: " << ret;
+    return false;
+  }
+
+  return true;
+}
+
+}  // namespace action
diff --git a/src/action/app_control_sender.hh b/src/action/app_control_sender.hh
new file mode 100644 (file)
index 0000000..3b48d04
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#ifndef ACTION_EXECUTOR_APP_CONTROL_SENDER_HH_
+#define ACTION_EXECUTOR_APP_CONTROL_SENDER_HH_
+
+#include <app_control.h>
+
+namespace action {
+
+class AppControlSender {
+ public:
+  AppControlSender(app_control_h app_control);
+  ~AppControlSender();
+  bool Send();
+
+ private:
+  app_control_h app_control_;
+};
+
+}  // action
+
+#endif  // ACTION_EXECUTOR_APP_CONTROL_SENDER_HH_
diff --git a/src/common/action_executor.hh b/src/common/action_executor.hh
new file mode 100644 (file)
index 0000000..28674b9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+#ifndef COMMON_ACTION_EXECUTOR_HH_
+#define COMMON_ACTION_EXECUTOR_HH_
+
+#include "common/action_model.h"
+
+namespace common {
+
+class IActionExecutor {
+ public:
+  virtual ~IActionExecutor() = default;
+  virtual int Execute(const ActionModel& model) = 0;
+};
+
+}  // namespace common
+
+#endif  // COMMON_ACTION_EXECUTOR_HH_