## 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")
## 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)
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)
%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} .
%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}
%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
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(pkgmgr_plugin_parser)
+ADD_SUBDIRECTORY(service)
-# 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}
)
APPLY_PKG_CONFIG(${TARGET_TIZEN_ACTION_COMMON} PUBLIC
DLOG_DEPS
+ TIZEN_DATABASE_DEPS
)
INSTALL(TARGETS ${TARGET_TIZEN_ACTION_COMMON} DESTINATION ${LIB_INSTALL_DIR})
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+ADD_SUBDIRECTORY(src)
#!/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
--- /dev/null
+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)
#include "action_request_handler.h"
#include "service.h"
+#include "common/sqlite_db.hh"
+
namespace service {
ActionRequestHandler::ActionRequestHandler() {
}
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,
// 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 {
<?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>