Make service app as a rpm package
authorSangyoon Jang <jeremy.jang@samsung.com>
Mon, 10 Feb 2025 00:04:21 +0000 (09:04 +0900)
committer장상윤/Tizen Platform Lab(SR)/삼성전자 <jeremy.jang@samsung.com>
Tue, 11 Feb 2025 05:44:32 +0000 (14:44 +0900)
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
13 files changed:
CMakeLists.txt
packaging/tizen-action-framework.spec
src/CMakeLists.txt
src/common/CMakeLists.txt
src/common/action_loader.hh [new file with mode: 0644]
src/common/sqlite_db.cc [new file with mode: 0644]
src/common/sqlite_db.hh [new file with mode: 0644]
src/service/CMakeLists.txt [new file with mode: 0644]
src/service/build.sh
src/service/src/CMakeLists.txt [new file with mode: 0644]
src/service/src/action_request_handler.cc
src/service/src/utils/logging.cc
src/service/tizen-manifest.xml

index d6a6c2debc9f993df25cecc624cdd0c7d602cd11..899a4f53ad5af021235b8a68c7c9a72d059d517d 100644 (file)
@@ -18,6 +18,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Mo
 ## Targets
 SET(TARGET_TIZEN_ACTION_COMMON "tizen-action-common")
 SET(TARGET_TIZEN_ACTION_PLUGIN "tizen-action-plugin")
+SET(TARGET_TIZEN_ACTION_SERVICE "tizen-action-service")
 
 #ENABLE_TESTING()
 #SET(TARGET_TIZEN_ACTION_UNIT_TEST "tizen-action-unit-test")
@@ -30,6 +31,9 @@ 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_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)
 PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog)
 PKG_CHECK_MODULES(GLIB_DEPS REQUIRED glib-2.0)
 PKG_CHECK_MODULES(GMOCK_DEPS REQUIRED gmock)
index 92e6cfa17653498bd2871350db25d5c222beb6d6..5396987aa72e7cce47b5127519844bb96b209d34 100644 (file)
@@ -7,9 +7,13 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
 BuildRequires:  cmake
+BuildRequires:  hash-signer
 BuildRequires:  tidl
 BuildRequires:  pkgconfig(bundle)
 BuildRequires:  pkgconfig(capi-appfw-app-common)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(capi-appfw-package-manager)
+BuildRequires:  pkgconfig(capi-appfw-service-application)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(gmock)
@@ -35,6 +39,14 @@ Requires: %{name} = %{version}-%{release}
 %description tool
 Tizen Action Framework Tools.
 
+%define service_pkgid org.tizen.action-framework.service
+%package -n %{service_pkgid}
+Summary:  Tizen Action Framework Service Package
+Requires: %{name} = %{version}
+
+%description -n %{service_pkgid}
+Tizen Action Framework Service Package.
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -45,7 +57,8 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake . -DCMAKE_VERBOSE_MAKEFILE:BOOL=%{?verbose_make:ON}%{!?verbose_make:OFF} \
          -DUNITDIR=%{_unitdir} \
          -DFULLVER=%{version} \
-         -DMAJORVER=${MAJORVER}
+         -DMAJORVER=${MAJORVER} \
+         -DSERVICE_PKGID=%{service_pkgid}
 
 %__make %{?_smp_mflags}
 
@@ -73,3 +86,16 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %defattr(-,root,root,-)
 %manifest %{name}.manifest
 %{_bindir}/action_fw_tool
+
+#Signing
+%define tizen_sign_base %{_prefix}/apps/%{service_pkgid};%{_prefix}/apps/%{service_pkgid}
+%define tizen_sign 1
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+%define tizen_sign_level platform
+
+%files -n %{service_pkgid}
+%defattr(-,root,root,-)
+%manifest %{name}.manifest
+%{_prefix}/apps/%{service_pkgid}/*
+%{_datadir}/packages/%{service_pkgid}.xml
index 6ef3abc54ec8d963f54e6a440989c95a89bafc4c..43862433ac92e6c28eeaaf3565176b251ccf0aa2 100644 (file)
@@ -1,2 +1,3 @@
 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(pkgmgr_plugin_parser)
+ADD_SUBDIRECTORY(service)
index 44ef0cad4f4d4b95b455a5fc7637036ef0edb0c7..11dd9329e1cb45d0c26d5e978f77a6bcb7989537 100644 (file)
@@ -1,8 +1,8 @@
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} ACTION_COMMON_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} ACTION_COMMON_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils ACTION_COMMON_UTILS_SRCS)
 
 ADD_LIBRARY(${TARGET_TIZEN_ACTION_COMMON} SHARED
-#  ${ACTION_COMMON_SRCS}
+  ${ACTION_COMMON_SRCS}
   ${ACTION_COMMON_UTILS_SRCS}
 )
 
@@ -10,6 +10,7 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_TIZEN_ACTION_COMMON} PUBLIC "${CMAKE_CURRENT
 
 APPLY_PKG_CONFIG(${TARGET_TIZEN_ACTION_COMMON} PUBLIC
   DLOG_DEPS
+  TIZEN_DATABASE_DEPS
 )
 
 INSTALL(TARGETS ${TARGET_TIZEN_ACTION_COMMON} DESTINATION ${LIB_INSTALL_DIR})
diff --git a/src/common/action_loader.hh b/src/common/action_loader.hh
new file mode 100644 (file)
index 0000000..6dd4d66
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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_LOADER_HH_
+#define COMMON_ACTION_LOADER_HH_
+
+namespace common {
+
+class IActionLoader {
+ public:
+  virtual ~IActionLoader() = default;
+  virtual void ListActions() = 0;
+  virtual void GetAction(const std::string& name) = 0;
+};
+
+}  // namespace common
+
+#endif  // COMMON_ACTION_LOADER_HH_
diff --git a/src/common/sqlite_db.cc b/src/common/sqlite_db.cc
new file mode 100644 (file)
index 0000000..5ba070e
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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 "common/sqlite_db.hh"
+
+#include <database.hpp>
+
+#include "common/utils/logging.hh"
+
+namespace {
+
+constexpr char kDbPath[] = "/opt/dbspace/.tizen_action.db";
+constexpr char kGetActionQuery[] =
+    "SELECT pkgid, action_name, json_str FROM action WHERE name = ?";
+constexpr char kListActionQuery[] =
+    "SELECT json_str FROM action;";
+
+}  // namespace
+
+namespace common {
+
+// TODO: check smack label of db file
+SqliteDb::SqliteDb() : conn_(kDbPath, SQLITE_OPEN_READONLY) {
+}
+
+void SqliteDb::ListActions() {
+  // TODO
+  Select();
+}
+
+void SqliteDb::GetAction(const std::string& name) {
+  // TODO
+  Select(name);
+}
+
+void SqliteDb::Select(const std::string& name) {
+  auto q = std::move(tizen_base::Database::Sql(kGetActionQuery)
+      .Bind(name));
+  auto r = conn_.Exec(q);
+  if (!static_cast<bool>(r)) {
+    LOG(ERROR) << "Failed to execute select query: "
+        << static_cast<const char*>(r);
+    return;
+  }
+
+  auto rec = r.GetFirstRecord();
+  if (!rec) {
+    LOG(ERROR) << "No record found";
+    return;
+  }
+
+  auto [pkgid, action_name, json_str] =
+      (*rec).Get<tizen_base::_, tizen_base::_, tizen_base::_>();
+  LOG(DEBUG) << "pkgid: " << static_cast<std::string>(pkgid)
+      << ", name: " << static_cast<std::string>(action_name)
+      << ", json_str: " << static_cast<std::string>(json_str);
+}
+
+void SqliteDb::Select() {
+  auto q = tizen_base::Database::Sql(kListActionQuery);
+  auto r = conn_.Exec(q);
+  if (!static_cast<bool>(r)) {
+    LOG(ERROR) << "Failed to execute select query: "
+        << static_cast<const char*>(r);
+    return;
+  }
+
+  for (const auto& i : r) {
+    auto [pkgid, action_name, json_str] =
+        i.Get<tizen_base::_, tizen_base::_, tizen_base::_>();
+    LOG(DEBUG) << "pkgid: " << static_cast<std::string>(pkgid)
+        << ", name: " << static_cast<std::string>(action_name)
+        << ", json_str: " << static_cast<std::string>(json_str);
+  }
+}
+
+}  // namespace common
diff --git a/src/common/sqlite_db.hh b/src/common/sqlite_db.hh
new file mode 100644 (file)
index 0000000..fa371b0
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_SQLITE_DB_HH_
+#define COMMON_SQLITE_DB_HH_
+
+#include <database.hpp>
+
+#include <string>
+
+#include "common/action_loader.hh"
+
+namespace common {
+
+class SqliteDb : public IActionLoader {
+ public:
+  SqliteDb();
+  ~SqliteDb() = default;
+
+  void ListActions() override;
+  void GetAction(const std::string& name) override;
+
+  void Select();
+  void Select(const std::string& name);
+
+ private:
+  tizen_base::Database conn_;
+};
+
+}  // namespace common
+
+#endif  // COMMON_SQLITE_DB_HH_
\ No newline at end of file
diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4b7537b
--- /dev/null
@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(src)
index 6d8f0442c24a300a970fcda2b0de96b9905b5797..f909c5b57f282f71531cbc8a2b3ca352188660d0 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/bash
 
-tizen build-native -C Debug -a arm -c gcc && tizen package -t tpk -- ./Debug
+tizen build-native -C Debug -a x86_64 -c gcc && tizen package -t tpk -- ./Debug
diff --git a/src/service/src/CMakeLists.txt b/src/service/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..22029ed
--- /dev/null
@@ -0,0 +1,26 @@
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SERVICE_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils SERVICE_UTILS_SRCS)
+ADD_EXECUTABLE(${TARGET_TIZEN_ACTION_SERVICE} ${SERVICE_SRCS} ${SERVICE_UTILS_SRCS})
+
+TARGET_INCLUDE_DIRECTORIES(${TARGET_TIZEN_ACTION_SERVICE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../)
+
+APPLY_PKG_CONFIG(${TARGET_TIZEN_ACTION_SERVICE} PUBLIC
+  CAPI_APPFW_APP_COMMON_DEPS
+  CAPI_APPFW_APP_MANAGER_DEPS
+  CAPI_APPFW_PACKAGE_MANAGER_DEPS
+  CAPI_APPFW_SERVICE_APPLICATION_DEPS
+  DLOG_DEPS
+  GLIB_DEPS
+  TIZEN_DATABASE_DEPS
+  RPC_PORT_DEPS
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_TIZEN_ACTION_SERVICE} PRIVATE ${TARGET_TIZEN_ACTION_COMMON})
+
+SET(MANIFESTDIR "${PREFIX}/share/packages")
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../tizen-manifest.xml DESTINATION ${MANIFESTDIR} RENAME ${SERVICE_PKGID}.xml)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../tizen-manifest.xml DESTINATION ${PREFIX}/apps/${SERVICE_PKGID})
+INSTALL(TARGETS ${TARGET_TIZEN_ACTION_SERVICE} DESTINATION ${PREFIX}/apps/${SERVICE_PKGID}/bin/)
+#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${PREFIX}/apps/${SERVICE_PKGID})
+#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/shared/res DESTINATION ${PREFIX}/apps/${SERVICE_PKGID}/shared)
index 77dee86687efdd874dd3863e8233e72351adb73e..5b14d54ebc6f5aca78f86ed9dcdca43a4128aea2 100644 (file)
@@ -19,6 +19,8 @@
 #include "action_request_handler.h"
 #include "service.h"
 
+#include "common/sqlite_db.hh"
+
 namespace service {
 
 ActionRequestHandler::ActionRequestHandler() {
@@ -32,9 +34,14 @@ void ActionRequestHandler::Init() {
 }
 
 void ActionRequestHandler::OnListActions() {
+  // TODO: db as member variable?
+  auto db = std::make_unique<common::SqliteDb>();
+  db->ListActions();
 }
 
 void ActionRequestHandler::OnGetAction(std::string id) {
+  auto db = std::make_unique<common::SqliteDb>();
+  db->GetAction(id);
 }
 
 void ActionRequestHandler::OnGetActionId(std::string user_description, int top_k,
index 6701ddae53dfd488be718ccef3cdea0082c09081..11f70d658987812f570cfd96bc832ab2a5be3a5c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a apache 2.0 license that can be
 // found in the LICENSE file.
 
-#include "utils/logging.h"
+#include "service/src/utils/logging.h"
 
 namespace utils {
 
index db2247de248d9c2f262e400d993ae9dd30c057a5..868e82ff8724eb48e9cb52b99573d356c4288deb 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns="http://tizen.org/ns/packages" api-version="9.0" package="org.tizen.action-framework.service" version="1.0.0">
     <profile name="tizen" />
-    <service-application appid="org.tizen.action-framework.service" exec="tizenactionframeworkservice" type="capp" multiple="false" taskmanage="false" nodisplay="true">
+    <service-application appid="org.tizen.action-framework.service" exec="tizen-action-service" type="capp" multiple="false" taskmanage="false" nodisplay="true">
         <icon>TizenActionFrameworkService.png</icon>
         <label>TizenActionFrameworkService</label>
        </service-application>