+++ /dev/null
-/*
- * Copyright (c) 2024 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.
- */
\ No newline at end of file
/bin/bash tidl/prebuild.sh
# build service app
-cd service
+cd src/service
/bin/bash build.sh
+++ /dev/null
-{
- global: main; _IO_*;
- local: *;
-};
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>TizenActionFrameworkService</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
- <arguments>
- <dictionary>
- <key>?name?</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.append_environment</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildArguments</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildCommand</key>
- <value>sbi-make</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildLocation</key>
- <value>${workspace_loc:/TizenActionFrameworkService/Debug}</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
- <value>clean</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.contents</key>
- <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableFullBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.stopOnError</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
- <value>true</value>
- </dictionary>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
- <triggers>full,incremental,</triggers>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.cdt.core.cnature</nature>
- <nature>org.eclipse.cdt.core.ccnature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
- </natures>
- <filteredResources>
- <filter>
- <id>1360216703005</id>
- <name></name>
- <type>26</type>
- <matcher>
- <id>org.eclipse.ui.ide.multiFilter</id>
- <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments>
- </matcher>
- </filter>
- </filteredResources>
-</projectDescription>
-
+++ /dev/null
-#!/bin/bash
-
-tizen build-native -C Debug -a arm -c gcc && tizen package -t tpk -- ./Debug
\ No newline at end of file
+++ /dev/null
-APPNAME = TizenActionFrameworkService
-type = app
-profile = tizen-9.0
-
-USER_SRCS = src/*.cc \
- src/utils/*.cc
-
-USER_INC_DIRS = src
-
-USER_DEFS =
-USER_CPP_DEPS =
-
-USER_UNDEFS =
-USER_CPP_UNDEFS =
-
-USER_OBJS =
-
-USER_CPP_OPTS = -std=c++17
+++ /dev/null
-/*
- * Copyright (c) 2024 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 <string>
-
-#include "action_request_handler.h"
-#include "service.h"
-
-namespace service {
-
-ActionRequestHandler::ActionRequestHandler() {
-}
-
-ActionRequestHandler::~ActionRequestHandler() {
-}
-
-void ActionRequestHandler::Init() {
- service_.Listen(std::make_shared<service::Service::Factory>(*this));
-}
-
-void ActionRequestHandler::OnListActions() {
-}
-
-void ActionRequestHandler::OnGetAction(std::string id) {
-}
-
-void ActionRequestHandler::OnGetActionId(std::string user_description, int top_k,
- float search_threshold) {
-}
-
-} // namespace service
+++ /dev/null
-/*
- * Copyright (c) 2024 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 SRC_ACTION_MANAGER_H_
-#define SRC_ACTION_MANAGER_H_
-
-#include <vector>
-
-#include "irequest_handler.h"
-#include "tizen_action_service_stub.h"
-
-using Action = rpc_port::tizen_action_service_stub::Action;
-
-namespace service {
-
-class ActionRequestHandler : public IRequestHandler {
- public:
- ActionRequestHandler();
- ~ActionRequestHandler();
- void Init();
-
- void OnListActions() override;
- void OnGetAction(std::string id) override;
- void OnGetActionId(std::string user_description, int top_k,
- float search_threshold) override;
-
- private:
- rpc_port::tizen_action_service_stub::stub::ActionService service_;
-};
-
-} // namespace service
-
-#endif // SRC_ACTION_MANAGER_H_
+++ /dev/null
-/*
- * Copyright (c) 2024 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 SRC_IREQUEST_HANDLER_H_
-#define SRC_IREQUEST_HANDLER_H_
-
-#include <string>
-
-namespace service {
-
-class IRequestHandler {
- public:
- virtual ~IRequestHandler() = default;
- virtual void OnListActions() = 0;
- virtual void OnGetAction(std::string id) = 0;
- virtual void OnGetActionId(std::string user_description, int top_k,
- float search_threshold) = 0;
-};
-
-} // namespace service
-
-#endif // SRC_IREQUEST_HANDLER_H_
+++ /dev/null
-/*
- * Copyright (c) 2024 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 <tizen.h>
-#include <service_app.h>
-
-#include <memory>
-
-#include "action_request_handler.h"
-#include "utils/logging.h"
-
-namespace {
-
-bool ServiceAppCreate(void* data) {
- return true;
-}
-
-void ServiceAppTerminate(void* data) {
- return;
-}
-
-void ServiceAppControl(app_control_h app_control, void* data) {
- return;
-}
-
-void ServiceAppLangChanged(app_event_info_h event_info, void* user_data) {
- /*APP_EVENT_LANGUAGE_CHANGED*/
- return;
-}
-
-void ServiceAppRegionChanged(app_event_info_h event_info, void* user_data) {
- /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-void ServiceAppLowBattery(app_event_info_h event_info, void* user_data) {
- /*APP_EVENT_LOW_BATTERY*/
-}
-
-void ServiceAppLowMemory(app_event_info_h event_info, void* user_data) {
- /*APP_EVENT_LOW_MEMORY*/
-}
-
-} // namespace
-
-int main(int argc, char* argv[]) {
- service_app_lifecycle_callback_s event_callback;
- app_event_handler_h handlers[5] = { nullptr, };
-
- event_callback.create = ServiceAppCreate;
- event_callback.terminate = ServiceAppTerminate;
- event_callback.app_control = ServiceAppControl;
-
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY],
- APP_EVENT_LOW_BATTERY, ServiceAppLowBattery, nullptr);
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY],
- APP_EVENT_LOW_MEMORY, ServiceAppLowMemory, nullptr);
- service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
- APP_EVENT_LANGUAGE_CHANGED, ServiceAppLangChanged, nullptr);
- service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
- APP_EVENT_REGION_FORMAT_CHANGED, ServiceAppRegionChanged, nullptr);
-
- service::ActionRequestHandler manager;
- manager.Init();
-
- LOG(DEBUG) << "service_app_main start...";
-
- return service_app_main(argc, argv, &event_callback, nullptr);
-}
+++ /dev/null
-/*
- * Copyright (c) 2024 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 "irequest_handler.h"
-#include "service.h"
-
-namespace service {
-
-Service::Service(std::string sender, std::string instance,
- IRequestHandler& handler)
- : rs::stub::ActionService::ServiceBase(std::move(sender),
- std::move(instance)), handler_(handler) {
-}
-
-Service::~Service() {
-}
-
-std::vector<rs::Action> Service::ListActions() {
- // return list of actions from db
- // handler_->ListActions();
- return {};
-}
-
-rs::Action Service::GetAction(std::string action_id) {
- // return action by id
- // handler_->GetAction(action_id);
- return {};
-}
-
-std::vector<rs::VectorDbResult> Service::GetActionId(
- std::string user_description, int top_k, float search_threshold) {
- // return result from db
- // handler_->GetActionId(user_description, top_k, search_threshold);
- return {};
-}
-
-} // namespace service
+++ /dev/null
-/*
- * Copyright (c) 2024 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 SRC_SERVICE_H_
-#define SRC_SERVICE_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "irequest_handler.h"
-#include "tizen_action_service_stub.h"
-
-namespace service {
-
-namespace rs = rpc_port::tizen_action_service_stub;
-
-class Service : public rs::stub::ActionService::ServiceBase {
- public:
- class Factory : public rs::stub::ActionService::ServiceBase::Factory {
- public:
- Factory(IRequestHandler& handler) : handler_(handler) {}
- virtual ~Factory() = default;
- std::unique_ptr<rs::stub::ActionService::ServiceBase> CreateService(
- std::string sender, std::string instance) override {
- return std::make_unique<Service>(sender, instance, handler_);
- }
-
- private:
- IRequestHandler& handler_;
- };
-
- Service(std::string sender, std::string instance, IRequestHandler& handler);
- ~Service();
-
- void OnCreate() override {}
- void OnTerminate() override {}
- std::vector<rs::Action> ListActions() override;
- rs::Action GetAction(std::string action_id) override;
- std::vector<rs::VectorDbResult> GetActionId(std::string user_description,
- int top_k, float search_threshold) override;
-
- private:
- IRequestHandler& handler_;
-};
-
-} // namespace service
-
-#endif // SRC_SERVICE_H_
+++ /dev/null
-// Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
-// 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"
-
-namespace utils {
-
-log_priority LogLevelToPriority(LogLevel level) {
- switch (level) {
- case LogLevel::LOG_ERROR:
- return log_priority::DLOG_ERROR;
- case LogLevel::LOG_WARNING:
- return log_priority::DLOG_WARN;
- case LogLevel::LOG_INFO:
- return log_priority::DLOG_INFO;
- case LogLevel::LOG_DEBUG:
- return log_priority::DLOG_DEBUG;
- default:
- return log_priority::DLOG_UNKNOWN;
- }
-}
-
-} // namespace utils
+++ /dev/null
-// Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef LOGGING_HH_
-#define LOGGING_HH_
-
-#include <dlog.h>
-
-#ifndef PROJECT_TAG
-#define PROJECT_TAG "TAF"
-#endif
-
-#ifdef LOG
-#undef LOG
-#endif
-
-#include <cassert>
-#include <cstring>
-#include <iomanip>
-#include <iostream>
-#include <sstream>
-#include <string>
-
-#ifndef __FILENAME__
-#define __FILENAME__ \
- (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
-#endif
-
-namespace utils {
-
-enum class LogLevel {
- LOG_ERROR,
- LOG_WARNING,
- LOG_INFO,
- LOG_DEBUG,
-};
-
-log_priority LogLevelToPriority(LogLevel level);
-
-template <class charT, class traits = std::char_traits<charT>>
-class StringStream : private std::basic_ostringstream<charT, traits> {
- public:
- using std::basic_ostringstream<charT, traits>::str;
-
- template <class T>
- StringStream& operator<<(const T& value) {
- static_cast<std::basic_ostringstream<charT, traits> &>(*this) << value;
- return *this;
- }
-};
-
-class LogCatcher {
- public:
- LogCatcher(LogLevel level, const char* tag)
- : level_(level), tag_(tag) { }
-
- void operator&(const StringStream<char>& str) const {
- dlog_print(LogLevelToPriority(level_), tag_.c_str(), "%s",
- Escape(str.str()).c_str());
- }
-
- private:
- // Since LogCatcher passes input to dlog_print(), the input which contains
- // format string(such as %d, %n) can cause unexpected result.
- // This is simple function to escape '%'.
- // NOTE: Is there any gorgeous way instead of this?
- std::string Escape(const std::string& str) const {
- std::string escaped = std::string(str);
- size_t start_pos = 0;
- std::string from = "%";
- std::string to = "%%";
- while ((start_pos = escaped.find(from, start_pos)) != std::string::npos) {
- escaped.replace(start_pos, from.length(), to);
- start_pos += to.length();
- }
- return escaped;
- }
- LogLevel level_;
- std::string tag_;
-};
-
-} // namespace utils
-
-inline static const constexpr char* __tag_for_project() {
- return PROJECT_TAG;
-}
-
-// Simple logging macro of following usage:
-// LOG(LEVEL) << object_1 << object_2 << object_n;
-// where:
-// LEVEL = ERROR | WARNING | INFO | DEBUG
-#define LOG(LEVEL) \
- ::utils::LogCatcher( \
- ::utils::LogLevel::LOG_ ## LEVEL, __tag_for_project()) \
- & ::utils::StringStream<char>() \
- << std::setw(50) << std::right \
- << (std::string(__FILENAME__) + ": " + std::string(__FUNCTION__) + "(" + \
- std::to_string(__LINE__) + ")").c_str() \
- << std::setw(0) << " : " \
-
-#endif // LOGGING_HH_
+++ /dev/null
-<?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">
- <icon>TizenActionFrameworkService.png</icon>
- <label>TizenActionFrameworkService</label>
- </service-application>
-</manifest>
--- /dev/null
+/*
+ * Copyright (c) 2024 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.
+ */
\ No newline at end of file
--- /dev/null
+{
+ global: main; _IO_*;
+ local: *;
+};
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TizenActionFrameworkService</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>sbi-make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildLocation</key>
+ <value>${workspace_loc:/TizenActionFrameworkService/Debug}</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1360216703005</id>
+ <name></name>
+ <type>26</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
+
--- /dev/null
+#!/bin/bash
+
+tizen build-native -C Debug -a arm -c gcc && tizen package -t tpk -- ./Debug
\ No newline at end of file
--- /dev/null
+APPNAME = TizenActionFrameworkService
+type = app
+profile = tizen-9.0
+
+USER_SRCS = src/*.cc \
+ src/utils/*.cc
+
+USER_INC_DIRS = src
+
+USER_DEFS =
+USER_CPP_DEPS =
+
+USER_UNDEFS =
+USER_CPP_UNDEFS =
+
+USER_OBJS =
+
+USER_CPP_OPTS = -std=c++17
--- /dev/null
+/*
+ * Copyright (c) 2024 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 <string>
+
+#include "action_request_handler.h"
+#include "service.h"
+
+namespace service {
+
+ActionRequestHandler::ActionRequestHandler() {
+}
+
+ActionRequestHandler::~ActionRequestHandler() {
+}
+
+void ActionRequestHandler::Init() {
+ service_.Listen(std::make_shared<service::Service::Factory>(*this));
+}
+
+void ActionRequestHandler::OnListActions() {
+}
+
+void ActionRequestHandler::OnGetAction(std::string id) {
+}
+
+void ActionRequestHandler::OnGetActionId(std::string user_description, int top_k,
+ float search_threshold) {
+}
+
+} // namespace service
--- /dev/null
+/*
+ * Copyright (c) 2024 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 SRC_ACTION_MANAGER_H_
+#define SRC_ACTION_MANAGER_H_
+
+#include <vector>
+
+#include "irequest_handler.h"
+#include "tizen_action_service_stub.h"
+
+using Action = rpc_port::tizen_action_service_stub::Action;
+
+namespace service {
+
+class ActionRequestHandler : public IRequestHandler {
+ public:
+ ActionRequestHandler();
+ ~ActionRequestHandler();
+ void Init();
+
+ void OnListActions() override;
+ void OnGetAction(std::string id) override;
+ void OnGetActionId(std::string user_description, int top_k,
+ float search_threshold) override;
+
+ private:
+ rpc_port::tizen_action_service_stub::stub::ActionService service_;
+};
+
+} // namespace service
+
+#endif // SRC_ACTION_MANAGER_H_
--- /dev/null
+/*
+ * Copyright (c) 2024 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 SRC_IREQUEST_HANDLER_H_
+#define SRC_IREQUEST_HANDLER_H_
+
+#include <string>
+
+namespace service {
+
+class IRequestHandler {
+ public:
+ virtual ~IRequestHandler() = default;
+ virtual void OnListActions() = 0;
+ virtual void OnGetAction(std::string id) = 0;
+ virtual void OnGetActionId(std::string user_description, int top_k,
+ float search_threshold) = 0;
+};
+
+} // namespace service
+
+#endif // SRC_IREQUEST_HANDLER_H_
--- /dev/null
+/*
+ * Copyright (c) 2024 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 <tizen.h>
+#include <service_app.h>
+
+#include <memory>
+
+#include "action_request_handler.h"
+#include "utils/logging.h"
+
+namespace {
+
+bool ServiceAppCreate(void* data) {
+ return true;
+}
+
+void ServiceAppTerminate(void* data) {
+ return;
+}
+
+void ServiceAppControl(app_control_h app_control, void* data) {
+ return;
+}
+
+void ServiceAppLangChanged(app_event_info_h event_info, void* user_data) {
+ /*APP_EVENT_LANGUAGE_CHANGED*/
+ return;
+}
+
+void ServiceAppRegionChanged(app_event_info_h event_info, void* user_data) {
+ /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+void ServiceAppLowBattery(app_event_info_h event_info, void* user_data) {
+ /*APP_EVENT_LOW_BATTERY*/
+}
+
+void ServiceAppLowMemory(app_event_info_h event_info, void* user_data) {
+ /*APP_EVENT_LOW_MEMORY*/
+}
+
+} // namespace
+
+int main(int argc, char* argv[]) {
+ service_app_lifecycle_callback_s event_callback;
+ app_event_handler_h handlers[5] = { nullptr, };
+
+ event_callback.create = ServiceAppCreate;
+ event_callback.terminate = ServiceAppTerminate;
+ event_callback.app_control = ServiceAppControl;
+
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY],
+ APP_EVENT_LOW_BATTERY, ServiceAppLowBattery, nullptr);
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY],
+ APP_EVENT_LOW_MEMORY, ServiceAppLowMemory, nullptr);
+ service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
+ APP_EVENT_LANGUAGE_CHANGED, ServiceAppLangChanged, nullptr);
+ service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
+ APP_EVENT_REGION_FORMAT_CHANGED, ServiceAppRegionChanged, nullptr);
+
+ service::ActionRequestHandler manager;
+ manager.Init();
+
+ LOG(DEBUG) << "service_app_main start...";
+
+ return service_app_main(argc, argv, &event_callback, nullptr);
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 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 "irequest_handler.h"
+#include "service.h"
+
+namespace service {
+
+Service::Service(std::string sender, std::string instance,
+ IRequestHandler& handler)
+ : rs::stub::ActionService::ServiceBase(std::move(sender),
+ std::move(instance)), handler_(handler) {
+}
+
+Service::~Service() {
+}
+
+std::vector<rs::Action> Service::ListActions() {
+ // return list of actions from db
+ // handler_->ListActions();
+ return {};
+}
+
+rs::Action Service::GetAction(std::string action_id) {
+ // return action by id
+ // handler_->GetAction(action_id);
+ return {};
+}
+
+std::vector<rs::VectorDbResult> Service::GetActionId(
+ std::string user_description, int top_k, float search_threshold) {
+ // return result from db
+ // handler_->GetActionId(user_description, top_k, search_threshold);
+ return {};
+}
+
+} // namespace service
--- /dev/null
+/*
+ * Copyright (c) 2024 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 SRC_SERVICE_H_
+#define SRC_SERVICE_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "irequest_handler.h"
+#include "tizen_action_service_stub.h"
+
+namespace service {
+
+namespace rs = rpc_port::tizen_action_service_stub;
+
+class Service : public rs::stub::ActionService::ServiceBase {
+ public:
+ class Factory : public rs::stub::ActionService::ServiceBase::Factory {
+ public:
+ Factory(IRequestHandler& handler) : handler_(handler) {}
+ virtual ~Factory() = default;
+ std::unique_ptr<rs::stub::ActionService::ServiceBase> CreateService(
+ std::string sender, std::string instance) override {
+ return std::make_unique<Service>(sender, instance, handler_);
+ }
+
+ private:
+ IRequestHandler& handler_;
+ };
+
+ Service(std::string sender, std::string instance, IRequestHandler& handler);
+ ~Service();
+
+ void OnCreate() override {}
+ void OnTerminate() override {}
+ std::vector<rs::Action> ListActions() override;
+ rs::Action GetAction(std::string action_id) override;
+ std::vector<rs::VectorDbResult> GetActionId(std::string user_description,
+ int top_k, float search_threshold) override;
+
+ private:
+ IRequestHandler& handler_;
+};
+
+} // namespace service
+
+#endif // SRC_SERVICE_H_
--- /dev/null
+// Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+// 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"
+
+namespace utils {
+
+log_priority LogLevelToPriority(LogLevel level) {
+ switch (level) {
+ case LogLevel::LOG_ERROR:
+ return log_priority::DLOG_ERROR;
+ case LogLevel::LOG_WARNING:
+ return log_priority::DLOG_WARN;
+ case LogLevel::LOG_INFO:
+ return log_priority::DLOG_INFO;
+ case LogLevel::LOG_DEBUG:
+ return log_priority::DLOG_DEBUG;
+ default:
+ return log_priority::DLOG_UNKNOWN;
+ }
+}
+
+} // namespace utils
--- /dev/null
+// Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef LOGGING_HH_
+#define LOGGING_HH_
+
+#include <dlog.h>
+
+#ifndef PROJECT_TAG
+#define PROJECT_TAG "TAF"
+#endif
+
+#ifdef LOG
+#undef LOG
+#endif
+
+#include <cassert>
+#include <cstring>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#ifndef __FILENAME__
+#define __FILENAME__ \
+ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+#endif
+
+namespace utils {
+
+enum class LogLevel {
+ LOG_ERROR,
+ LOG_WARNING,
+ LOG_INFO,
+ LOG_DEBUG,
+};
+
+log_priority LogLevelToPriority(LogLevel level);
+
+template <class charT, class traits = std::char_traits<charT>>
+class StringStream : private std::basic_ostringstream<charT, traits> {
+ public:
+ using std::basic_ostringstream<charT, traits>::str;
+
+ template <class T>
+ StringStream& operator<<(const T& value) {
+ static_cast<std::basic_ostringstream<charT, traits> &>(*this) << value;
+ return *this;
+ }
+};
+
+class LogCatcher {
+ public:
+ LogCatcher(LogLevel level, const char* tag)
+ : level_(level), tag_(tag) { }
+
+ void operator&(const StringStream<char>& str) const {
+ dlog_print(LogLevelToPriority(level_), tag_.c_str(), "%s",
+ Escape(str.str()).c_str());
+ }
+
+ private:
+ // Since LogCatcher passes input to dlog_print(), the input which contains
+ // format string(such as %d, %n) can cause unexpected result.
+ // This is simple function to escape '%'.
+ // NOTE: Is there any gorgeous way instead of this?
+ std::string Escape(const std::string& str) const {
+ std::string escaped = std::string(str);
+ size_t start_pos = 0;
+ std::string from = "%";
+ std::string to = "%%";
+ while ((start_pos = escaped.find(from, start_pos)) != std::string::npos) {
+ escaped.replace(start_pos, from.length(), to);
+ start_pos += to.length();
+ }
+ return escaped;
+ }
+ LogLevel level_;
+ std::string tag_;
+};
+
+} // namespace utils
+
+inline static const constexpr char* __tag_for_project() {
+ return PROJECT_TAG;
+}
+
+// Simple logging macro of following usage:
+// LOG(LEVEL) << object_1 << object_2 << object_n;
+// where:
+// LEVEL = ERROR | WARNING | INFO | DEBUG
+#define LOG(LEVEL) \
+ ::utils::LogCatcher( \
+ ::utils::LogLevel::LOG_ ## LEVEL, __tag_for_project()) \
+ & ::utils::StringStream<char>() \
+ << std::setw(50) << std::right \
+ << (std::string(__FILENAME__) + ": " + std::string(__FUNCTION__) + "(" + \
+ std::to_string(__LINE__) + ")").c_str() \
+ << std::setw(0) << " : " \
+
+#endif // LOGGING_HH_
--- /dev/null
+<?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">
+ <icon>TizenActionFrameworkService.png</icon>
+ <label>TizenActionFrameworkService</label>
+ </service-application>
+</manifest>
exit 1
fi
-mv tizen_action_service_proxy.* $SCRIPT_DIR/../api/src/
-mv tizen_action_service_stub.* $SCRIPT_DIR/../service/src/
+mv tizen_action_service_proxy.* $SCRIPT_DIR/../src/api/
+mv tizen_action_service_stub.* $SCRIPT_DIR/../src/service/src/