aboutsummaryrefslogtreecommitdiffstats
path: root/src/policy_manager
diff options
context:
space:
mode:
Diffstat (limited to 'src/policy_manager')
-rw-r--r--src/policy_manager/policy_manager.cpp50
1 files changed, 34 insertions, 16 deletions
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index b709843..62b73e9 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -721,8 +721,19 @@ int PolicyManager::setInputEventData(json_object* json_in) {
int event_no = 0;
if (nullptr != event) {
// Convert name to number
- event_no = this->eventname2no[event];
- HMI_DEBUG("wm:pm", "event(%s:%d)", event, event_no);
+ auto itr = this->eventname2no.find(event);
+ if (this->eventname2no.end() != itr) {
+ event_no = this->eventname2no[event];
+ HMI_DEBUG("wm:pm", "event(%s:%d)", event, event_no);
+ }
+ else {
+ HMI_ERROR("wm:pm", "Invalid event name!!");
+ return -1;
+ }
+ }
+ else {
+ HMI_ERROR("wm:pm", "Event is not set!!");
+ return -1;
}
// Get role from json_object
@@ -732,26 +743,38 @@ int PolicyManager::setInputEventData(json_object* json_in) {
HMI_DEBUG("wm:pm", "role(%s)", role);
// Convert role to category
- const char* category = this->role2category[role].c_str();
- if (0 == strcmp("", category)) {
- HMI_ERROR("wm:pm", "Error!!");
+ std::string category;
+ auto itr = this->role2category.find(role);
+ if (this->role2category.end() != itr) {
+ category = this->role2category[role];
+ }
+ else {
+ HMI_ERROR("wm:pm", "Invalid role name!!");
return -1;
}
- HMI_DEBUG("wm:pm", "category(%s)", category);
// Convert name to number
category_no = categoryname2no[category];
- HMI_DEBUG("wm:pm", "role(%s), category(%s:%d)", role, category, category_no);
+ HMI_DEBUG("wm:pm", "role(%s), category(%s:%d)", role, category.c_str(), category_no);
+ }
+ else {
+ role = "";
}
// Get areat from json_object
const char* area = this->getStringFromJson(json_in, "area");
int area_no = 0;
if (nullptr != area) {
- area_no = this->areaname2no[area];
- HMI_DEBUG("wm:pm", "area(%s:%d)", area, area_no);
+ auto itr = this->areaname2no.find(area);
+ if (this->areaname2no.end() != itr) {
+ area_no = this->areaname2no[area];
+ HMI_DEBUG("wm:pm", "area(%s:%d)", area, area_no);
+ }
+ else {
+ HMI_ERROR("wm:pm", "Invalid area name!!");
+ }
}
- else if (nullptr != role) {
+ else if (0 != strcmp("", role)) {
area_no = this->areaname2no[this->role2defaultarea[role]];
HMI_DEBUG("wm:pm", "area(%s:%d)", this->role2defaultarea[role].c_str(), area_no);
}
@@ -759,12 +782,7 @@ int PolicyManager::setInputEventData(json_object* json_in) {
// Set event info to the queue
EventInfo event_info;
event_info.event = (event_no | category_no | area_no);
- if (nullptr == role) {
- event_info.role = std::string("");
- }
- else {
- event_info.role = std::string(role);
- }
+ event_info.role = std::string(role);
event_info.delay = 0;
this->event_info_queue.push(event_info);