summaryrefslogtreecommitdiff
path: root/src/components/policy
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-08-29 10:40:02 -0400
committerGitHub <noreply@github.com>2018-08-29 10:40:02 -0400
commit7c4acd58748330d62b3899187ea9816a852b1421 (patch)
tree36e27b775401ce98cd27d4803c7bf90b5bc3e2c6 /src/components/policy
parent721fcfec20f26ff86dcbd652d12e7cc26e355b7f (diff)
parentbe2301cdaca2e4dcf72684d5b4198f10b61d08ff (diff)
downloadsdl_core-7c4acd58748330d62b3899187ea9816a852b1421.tar.gz
Merge pull request #2549 from JackLivio/fix/allow_empty_module_type_array_in_pt
Allow empty moduleType array in PT
Diffstat (limited to 'src/components/policy')
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h3
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc7
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc18
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc30
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/enums.h3
-rw-r--r--src/components/policy/policy_regular/src/policy_table/enums.cc7
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc30
7 files changed, 82 insertions, 16 deletions
diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h
index 5fc43603d8..a31e955d99 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h
@@ -173,7 +173,8 @@ enum ModuleType {
MT_SEAT,
MT_AUDIO,
MT_LIGHT,
- MT_HMI_SETTINGS
+ MT_HMI_SETTINGS,
+ MT_EMPTY
};
bool IsValidEnum(ModuleType val);
const char* EnumToJsonString(ModuleType val);
diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc
index c2b304df67..31a6fc86e6 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -779,6 +779,8 @@ bool IsValidEnum(ModuleType val) {
return true;
case MT_SEAT:
return true;
+ case MT_EMPTY:
+ return true;
default:
return false;
}
@@ -797,6 +799,8 @@ const char* EnumToJsonString(ModuleType val) {
return "HMI_SETTINGS";
case MT_SEAT:
return "SEAT";
+ case MT_EMPTY:
+ return "EMPTY";
default:
return "";
}
@@ -821,6 +825,9 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
} else if ("HMI_SETTINGS" == literal) {
*result = MT_HMI_SETTINGS;
return true;
+ } else if ("EMPTY" == literal) {
+ *result = MT_EMPTY;
+ return true;
} else {
return false;
}
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
index 5bb602244e..f26264ddf9 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
@@ -761,6 +761,13 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
if (!SaveAppGroup(app.first, app.second.groups)) {
return false;
}
+
+ bool denied = !app.second.moduleType->is_initialized();
+ if (!SaveRemoteControlDenied(app.first, denied) ||
+ !SaveModuleType(app.first, *app.second.moduleType)) {
+ return false;
+ }
+
if (!SaveNickname(app.first, *app.second.nicknames)) {
return false;
}
@@ -870,6 +877,17 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
if (!GatherAppGroup(app_id, &params.groups)) {
return false;
}
+
+ bool denied = false;
+ if (!GatherRemoteControlDenied(app_id, &denied)) {
+ return false;
+ }
+ if (!denied) {
+ if (!GatherModuleType(app_id, &*params.moduleType)) {
+ return false;
+ }
+ }
+
if (!GatherNickName(app_id, &*params.nicknames)) {
return false;
}
diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc
index 6b07cc647f..34c5b90903 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -1740,6 +1740,10 @@ bool SQLPTRepresentation::GatherModuleType(
if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) {
return false;
}
+ if (policy_table::ModuleType::MT_EMPTY == type) {
+ app_types->mark_initialized();
+ continue;
+ }
app_types->push_back(type);
}
return true;
@@ -1772,18 +1776,30 @@ bool SQLPTRepresentation::SaveModuleType(
}
policy_table::ModuleTypes::const_iterator it;
- for (it = types.begin(); it != types.end(); ++it) {
+ if (!types.empty()) {
+ for (it = types.begin(); it != types.end(); ++it) {
+ query.Bind(0, app_id);
+ std::string module(policy_table::EnumToJsonString(*it));
+ query.Bind(1, module);
+ LOG4CXX_DEBUG(logger_,
+ "Module(app: " << app_id << ", type: " << module << ")");
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ return false;
+ }
+ }
+ } else if (types.is_initialized()) {
query.Bind(0, app_id);
- std::string module(policy_table::EnumToJsonString(*it));
- query.Bind(1, module);
- LOG4CXX_DEBUG(logger_,
- "Module(app: " << app_id << ", type: " << module << ")");
+ query.Bind(1,
+ std::string(policy_table::EnumToJsonString(
+ policy_table::ModuleType::MT_EMPTY)));
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into module types.");
return false;
}
+ } else {
+ LOG4CXX_WARN(logger_, "Module Type omitted.");
}
-
return true;
}
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
index 4107fad398..b2acf77ec1 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
@@ -159,7 +159,8 @@ enum ModuleType {
MT_SEAT,
MT_AUDIO,
MT_LIGHT,
- MT_HMI_SETTINGS
+ MT_HMI_SETTINGS,
+ MT_EMPTY
};
bool IsValidEnum(ModuleType val);
const char* EnumToJsonString(ModuleType val);
diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc
index 83ace2feb2..138d866174 100644
--- a/src/components/policy/policy_regular/src/policy_table/enums.cc
+++ b/src/components/policy/policy_regular/src/policy_table/enums.cc
@@ -649,6 +649,8 @@ bool IsValidEnum(ModuleType val) {
return true;
case MT_HMI_SETTINGS:
return true;
+ case MT_EMPTY:
+ return true;
default:
return false;
}
@@ -667,6 +669,8 @@ const char* EnumToJsonString(ModuleType val) {
return "LIGHT";
case MT_HMI_SETTINGS:
return "HMI_SETTINGS";
+ case MT_EMPTY:
+ return "EMPTY";
default:
return "";
}
@@ -691,6 +695,9 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
} else if ("HMI_SETTINGS" == literal) {
*result = MT_HMI_SETTINGS;
return true;
+ } else if ("EMPTY" == literal) {
+ *result = MT_EMPTY;
+ return true;
}
return false;
}
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index 8efe2fb59e..d32ee7133d 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -1696,6 +1696,10 @@ bool SQLPTRepresentation::GatherModuleType(
if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) {
return false;
}
+ if (policy_table::ModuleType::MT_EMPTY == type) {
+ app_types->mark_initialized();
+ continue;
+ }
app_types->push_back(type);
}
return true;
@@ -1728,18 +1732,30 @@ bool SQLPTRepresentation::SaveModuleType(
}
policy_table::ModuleTypes::const_iterator it;
- for (it = types.begin(); it != types.end(); ++it) {
+ if (!types.empty()) {
+ for (it = types.begin(); it != types.end(); ++it) {
+ query.Bind(0, app_id);
+ std::string module(policy_table::EnumToJsonString(*it));
+ query.Bind(1, module);
+ LOG4CXX_DEBUG(logger_,
+ "Module(app: " << app_id << ", type: " << module << ")");
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ return false;
+ }
+ }
+ } else if (types.is_initialized()) {
query.Bind(0, app_id);
- std::string module(policy_table::EnumToJsonString(*it));
- query.Bind(1, module);
- LOG4CXX_DEBUG(logger_,
- "Module(app: " << app_id << ", type: " << module << ")");
+ query.Bind(1,
+ std::string(policy_table::EnumToJsonString(
+ policy_table::ModuleType::MT_EMPTY)));
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger_, "Incorrect insert into module type.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into module types.");
return false;
}
+ } else {
+ LOG4CXX_WARN(logger_, "Module Type omitted.");
}
-
return true;
}