category is for enhancing efficiency of getting actions.
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
rpc::Action action;
action.Setaction_id(model.GetActionId());
action.Setapp_id(model.GetAppId());
+ action.Setcategory(model.GetCategory());
action.Setdescription(model.GetDescription());
action.Settype("app_control"); // TODO
// action.Setparameters();
rpc::Action action;
action.Setaction_id(model.GetActionId());
action.Setapp_id(model.GetAppId());
+ action.Setcategory(model.GetCategory());
action.Setdescription(model.GetDescription());
action.Settype("app_control"); // TODO
// action.Seturi();
constexpr char kDbPath[] = "/opt/dbspace/.tizen_action.db";
constexpr char kGetActionQuery[] =
- "SELECT pkgid, action_name, json_str FROM action WHERE action_name = ?";
+ "SELECT pkgid, action_name, category, json_str "
+ "FROM action WHERE action_name = ?";
constexpr char kListActionQuery[] =
"SELECT json_str FROM action;";
return {};
}
- auto [pkgid, action_name, json_str] =
- (*rec).Get<tizen_base::_, tizen_base::_, tizen_base::_>();
+ auto [pkgid, action_name, category, json_str] =
+ (*rec).Get<tizen_base::_, tizen_base::_, tizen_base::_, tizen_base::_>();
LOG(DEBUG) << "pkgid: " << static_cast<std::string>(pkgid)
<< ", name: " << static_cast<std::string>(action_name)
+ << ", category: " << static_cast<std::string>(category)
<< ", json_str: " << static_cast<std::string>(json_str);
// TODO: tmp fix
plugin_proxy::Action action;
action.Setaction_id(model.GetActionId());
action.Setapp_id(model.GetAppId());
+ action.Setcategory(model.GetCategory());
action.Setdescription(model.GetDescription());
auto parameters = std::vector<plugin_proxy::Parameter>();
for (auto const& param : model.GetParameters()) {
action_id_ = root["name"].asString();
app_id_ = root["appId"].asString();
- type_ = GetActionTypeFromString(root["type"].asString());
+ category_ = root["category"].asString();
description_ = root["desc"].asString();
+ type_ = GetActionTypeFromString(root["type"].asString());
// params
for (auto const& it : root["params"].getMemberNames()) {
}
ActionModel::ActionModel(std::string action_id, std::string app_id,
- std::string description, std::vector<ActionParameter> parameters,
+ std::string category, std::string description,
+ std::vector<ActionParameter> parameters,
std::vector<std::string> privileges)
: action_id_(std::move(action_id)), app_id_(std::move(app_id)),
- description_(std::move(description)), parameters_(std::move(parameters)),
- privileges_(std::move(privileges)) {
+ category_(std::move(category)), description_(std::move(description)),
+ parameters_(std::move(parameters)), privileges_(std::move(privileges)) {
}
const std::string& ActionModel::GetActionId() const {
app_id_ = std::move(app_id);
}
+const std::string& ActionModel::GetCategory() const {
+ return category_;
+}
+
+void ActionModel::SetCategory(std::string category) {
+ category_ = std::move(category);
+}
+
const ActionType ActionModel::GetType() const {
return type_;
}
ActionModel();
explicit ActionModel(const std::string& json_str);
explicit ActionModel(std::string action_id, std::string app_id,
- std::string description, std::vector<ActionParameter> parameters,
+ std::string category, std::string description,
+ std::vector<ActionParameter> parameters,
std::vector<std::string> privileges);
const std::string& GetActionId() const;
const std::string& GetAppId() const;
void SetAppId(std::string app_id);
+ const std::string& GetCategory() const;
+ void SetCategory(std::string category);
+
const ActionType GetType() const;
void SetType(ActionType type);
private:
std::string action_id_;
std::string app_id_;
+ std::string category_;
ActionType type_ = ActionType::InvalidType;
std::string description_;
class ActionSchema {
public:
- explicit ActionSchema(std::string pkgid, std::string name, std::string json_str)
+ explicit ActionSchema(std::string pkgid, std::string name,
+ std::string category, std::string json_str)
: pkgid_(std::move(pkgid)), name_(std::move(name)),
- json_str_(std::move(json_str)) {}
+ category_(std::move(category)), json_str_(std::move(json_str)) {}
ActionSchema() = default;
~ActionSchema() = default;
std::string GetPkgId() const { return pkgid_; }
std::string GetName() const { return name_; }
+ std::string GetCategory() const { return category_; }
std::string GetJsonStr() const { return json_str_; }
private:
std::string pkgid_;
std::string name_;
+ std::string category_;
std::string json_str_;
};
// TODO
std::string name = root["name"].asString();
+ std::string category = root["category"].asString();
std::string json_str = JsonToString(root);
LOG(DEBUG) << "Parased action for pkgid[ " << pkgid << " ] : " << name;
LOG(DEBUG) << json_str;
- return ActionSchema(pkgid, name, json_str);
+ return ActionSchema(pkgid, name, category, json_str);
}
} // namespace parser
"CREATE TABLE IF NOT EXISTS action (\n"
" pkgid TEXT,\n"
" action_name TEXT,\n"
+ " category TEXT,\n"
" json_str TEXT,\n"
" PRIMARY KEY (pkgid, action_name))";
constexpr char kInsertQuery[] =
- "INSERT INTO action (pkgid, action_name, json_str) "
- "VALUES (?, ?, ?)";
+ "INSERT INTO action (pkgid, action_name, category, json_str) "
+ "VALUES (?, ?, ?, ?)";
constexpr char kDeleteQuery[] =
"DELETE FROM action WHERE pkgid = ?";
constexpr char kSelectQuery[] =
sql.Reset()
.Bind(pkgid)
.Bind(schema.GetName())
+ .Bind(schema.GetCategory())
.Bind(schema.GetJsonStr());
auto result = conn_.Exec(sql);
if (!static_cast<bool>(result)) {
sql.Reset()
.Bind(pkgid)
.Bind(schema.GetName())
+ .Bind(schema.GetCategory())
.Bind(schema.GetJsonStr());
result = conn_.Exec(sql);
if (!result) {
struct Action {
string action_id;
string app_id;
+ string category;
string description;
string type;
array<Parameter> parameters;
auto action = proxy_.GetAction(std::move(action_id));
_D("id: %s --------------------", action.Getaction_id().c_str());
_D("appid: %s", action.Getapp_id().c_str());
+ _D("category: %s", action.Getcategory().c_str());
_D("description: %s", action.Getdescription().c_str());
if (!action.Getprivileges().empty()) {
for (auto action : actions) {
_D("id: %s --------------------", action.Getaction_id().c_str());
_D("appid: %s", action.Getapp_id().c_str());
+ _D("category: %s", action.Getcategory().c_str());
_D("description: %s", action.Getdescription().c_str());
if (!action.Getprivileges().empty()) {