--- /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 "action_model.h"
+
+namespace action {
+
+class ActionModel {
+
+}
+
+}
--- /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 MODEL_ACTION_MODEL_H_
+#define MODEL_ACTION_MODEL_H_
+
+#include <vector>
+#include "action_parameter.h"
+
+namespace action {
+
+enum class ActionType {
+ AppControl = 0,
+ Plugin = 1
+}
+
+class ActionModel {
+ public:
+ ActionModel() = default;
+ ~ActionModel() = default;
+
+ private:
+ std::vector<ActionParameter> params_;
+}
+
+} // namespace action
+
+#endif // MODEL_ACTION_MODEL_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 "action_parameter.h"
+
+namespace action {
+
+class ActionParameter {
+
+}
+
+}
--- /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 MODEL_ACTION_MODEL_H_
+#define MODEL_ACTION_MODEL_H_
+
+#include "action_parameter.h"
+
+namespace action {
+
+enum class ParameterType {
+ IntType = 1,
+ StringType = 0
+}
+
+class ActionParameter {
+ public:
+ ActionParameter() = default;
+ ~ActionParameter();
+
+ private:
+ ParameterType type_;
+ std::string name_;
+ std::string description_;
+ bool is_required_;
+}
+
+
+
+} // namespace action
+
+#endif // MODEL_ACTION_MODEL_H_
#include "irequest_handler.h"
#include "service.h"
+#include "utils/logging.h"
+
+#include "utils/sqlite_db.h"
+#include "utils/json_parser.h"
namespace service {
rs::Action Service::GetAction(std::string action_id) {
// return action by id
// handler_->GetAction(action_id);
- return {};
+ LOG(DEBUG) << "GetAction : " << action_id;
+
+ std::string result;
+ utils::SqliteDb sqlite_db;
+
+ sqlite_db.Select(action_id, result);
+
+ LOG(DEBUG) << "GetAction result : " << result;
+
+ auto ps = new utils::JsonParser(result);
+
+ auto params = ps->GetParameters();
+
+ rs::Action action;
+ std::vector<rs::Parameter> actionparams;
+
+ action.Setapp_id(ps->GetAppId());
+ action.Setaction_id(ps->GetName());
+ action.Setlabel(ps->GetName());
+ action.Setdescription(ps->GetDescription());
+
+ for (auto const& iter : params) {
+ auto param_value = iter.second;
+
+ auto param = rs::Parameter(iter.first, param_value["type"], param_value["desc"],
+ param_value["isMandatory"].compare("true") == 0 ? true : false);
+
+ actionparams.push_back(param);
+ }
+
+ action.Setparameters(actionparams);
+
+ LOG(DEBUG) << "appid : " << action.Getapp_id();
+ LOG(DEBUG) << "actionid : " << action.Getaction_id();
+
+ // return {};
+ return action;
}
std::vector<rs::VectorDbResult> Service::GetActionId(
--- /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 <stdexcept>
+
+#include "json_parser.h"
+
+#include "logging.h"
+
+namespace utils {
+
+JsonParser::JsonParser(std::string json_str)
+ : json_str_(json_str) {
+ LOG(DEBUG) << "ParseStr const";
+
+ std::size_t pos = 0;
+ std::size_t lpos = 0;
+ std::string params;
+
+ // remove {}
+ pos = json_str_.find("{");
+ lpos = json_str_.rfind("}");
+ json_str_ = json_str_.substr(pos + 1, lpos - pos - 1);
+
+ // seperate params
+ pos = json_str_.find("{");
+ lpos = json_str_.rfind("}");
+ params = json_str_.substr(pos + 1, lpos - pos - 1);
+ json_str_.replace(pos + 1, lpos - pos - 1, " ");
+
+ // make nodes
+ while(true) {
+ pos = json_str_.find(",");
+
+ if (pos == std::string::npos)
+ break;
+
+ std::string sub_ = json_str_.substr(0, pos);
+ std::size_t spos = sub_.find(":");
+ std::string key = sub_.substr(1, spos - 2);
+ sub_ = sub_.substr(spos + 1);
+ std::string value = sub_.substr(1, sub_.length() - 2);
+
+ nodes_[key] = value;
+
+ // LOG(DEBUG) << key << " : " << value;
+
+ json_str_ = json_str_.substr(pos + 1);
+ }
+
+// LOG(DEBUG) << params;
+
+ std::size_t compos = 0;
+
+ // make params
+ while(true) {
+ pos = params.find("{");
+ lpos = params.find("}");
+
+ std::string key = params.substr(1, pos - 3);
+ std::string value = params.substr(pos + 1, lpos - pos - 1);
+
+ // LOG(DEBUG) << key << " : " << value;
+
+
+ std::size_t subpos = 0;
+ std::size_t nextpos = 0;
+ std::size_t compos_ = 0;
+ std::map<std::string, std::string> mvalue;
+
+ // make param value
+ while(true) {
+ // LOG(DEBUG) << value;
+
+ subpos = value.find("\"");
+ nextpos = value.find("\"", subpos + 1);
+
+ std::string subkey = value.substr(1, nextpos - 1);
+
+ subpos = value.find("\"", nextpos + 1);
+ nextpos = value.find("\"", subpos + 1);
+
+ std::string subval = value.substr(subpos + 1, nextpos - subpos - 1);
+
+ mvalue[subkey] = subval;
+
+ compos_ = value.find(",", nextpos);
+ if (compos_ == std::string::npos)
+ break;
+
+ value = value.substr(compos_ + 1);
+ }
+ params_[key] = mvalue;
+
+ compos = params.find(",", lpos);
+ if (compos == std::string::npos)
+ break;
+
+ params = params.substr(lpos + 2);
+ }
+
+ LOG(DEBUG) << "ParseStr const end";
+}
+
+std::string JsonParser::GetAppId() {
+ return nodes_["appId"];
+}
+
+std::string JsonParser::GetName() {
+ return nodes_["name"];
+}
+
+std::string JsonParser::GetDescription() {
+ return nodes_["desc"];
+}
+
+std::string JsonParser::GetType() {
+ return nodes_["type"];
+}
+
+std::string JsonParser::GetVersion() {
+ return nodes_["version"];
+}
+
+std::string JsonParser::GetRequiredPrivilege() {
+ return nodes_["required-privileges"];
+}
+
+std::string JsonParser::GetReturns() {
+ return nodes_["required-privileges"];
+}
+
+std::map<std::string, std::map<std::string, std::string>> JsonParser::GetParameters() {
+ return params_;
+}
+
+} // namespace utils
--- /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 JSON_PARSER_H_
+#define JSON_PARSER_H_
+
+// #include <json/json.h>
+
+#include <string>
+#include <map>
+
+namespace utils {
+
+/* temporary parser */
+/* need to be changed to use json */
+
+class JsonParser {
+ public:
+ JsonParser(std::string json_str);
+ ~JsonParser() = default;
+
+ std::string GetAppId();
+ std::string GetName();
+ std::string GetDescription();
+ std::string GetType();
+ std::string GetVersion();
+ std::string GetRequiredPrivilege();
+ std::string GetReturns();
+ std::map<std::string, std::map<std::string, std::string>> GetParameters();
+
+ private:
+ std::string json_str_;
+ std::map<std::string, std::string> nodes_;
+ std::map<std::string, std::map<std::string, std::string>> params_;
+};
+
+} // namespace utils
+
+#endif //
--- /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 "sqlite_db.h"
+
+#include "logging.h"
+
+namespace {
+
+constexpr char kDbPath[] = "/opt/dbspace/.tizen_action.db";
+constexpr char kSelectQuery[] =
+ "SELECT json_str FROM action WHERE action_name = ?";
+
+} // namespace
+
+namespace utils {
+
+bool SqliteDb::Select(std::string action_id, std::string& result) {
+ LOG(DEBUG) << "select : " << action_id;
+
+ int ret;
+ char *val;
+ sqlite3 *db;
+ sqlite3_stmt *stmt = nullptr;
+
+ ret = sqlite3_open_v2(kDbPath, &db, SQLITE_OPEN_READONLY, nullptr);
+ if (ret != SQLITE_OK) {
+ LOG(ERROR) << "failed to open db : " << kDbPath << " , : " << ret;
+ return false;
+ }
+
+ ret = sqlite3_prepare_v2(db, kSelectQuery, strlen(kSelectQuery), &stmt, nullptr);
+ if (ret != SQLITE_OK) {
+ LOG(ERROR) << "failed to prepare : " << ret;
+ return false;
+ }
+
+ sqlite3_bind_text(stmt, 1, action_id.c_str(), -1, SQLITE_STATIC);
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_ROW) {
+ LOG(ERROR) << "failed to step : " << sqlite3_errmsg(db);
+ return false;
+ }
+
+ val = (char *)sqlite3_column_text(stmt, 0);
+ LOG(DEBUG) << "result : " << val;
+
+ result = val;
+
+ sqlite3_finalize(stmt);
+ sqlite3_close_v2(db);
+
+ return true;
+}
+
+} // namespace utils
--- /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 SQLITE_DB_H_
+#define SQLITE_DB_H_
+
+// #include <database.hpp>
+#include <sqlite3.h>
+
+#include <string>
+
+/* need to be changed to use cpp tizen-database */
+/* neec to be changed smack label for .tizen_action.db */
+
+namespace utils {
+
+class SqliteDb {
+ public:
+ SqliteDb() = default;
+ ~SqliteDb() = default;
+
+ bool Select(std::string action_id, std::string& result);
+
+};
+
+} // namespace utils
+
+#endif // SQLITE_DB_H_
\ No newline at end of file