diff options
Diffstat (limited to 'src/components/policy/policy_external/src/sql_pt_representation.cc')
-rw-r--r-- | src/components/policy/policy_external/src/sql_pt_representation.cc | 46 |
1 files changed, 27 insertions, 19 deletions
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 b05716dc3f..34c5b90903 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -235,10 +235,10 @@ int SQLPTRepresentation::TimeoutResponse() { utils::dbms::SQLQuery query(db()); if (!query.Prepare(sql_pt::kSelectTimeoutResponse) || !query.Exec()) { LOG4CXX_INFO(logger_, "Can not select timeout response for retry sequence"); - const int defaultTimeout = 30 * date_time::DateTime::MILLISECONDS_IN_SECOND; + const int defaultTimeout = 30 * date_time::MILLISECONDS_IN_SECOND; return defaultTimeout; } - return query.GetInteger(0) * date_time::DateTime::MILLISECONDS_IN_SECOND; + return query.GetInteger(0) * date_time::MILLISECONDS_IN_SECOND; } bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) { @@ -513,10 +513,10 @@ bool SQLPTRepresentation::RefreshDB() { return true; } -utils::SharedPtr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot() +std::shared_ptr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot() const { LOG4CXX_AUTO_TRACE(logger_); - utils::SharedPtr<policy_table::Table> table = new policy_table::Table(); + auto table = std::make_shared<policy_table::Table>(); GatherModuleMeta(&*table->policy_table.module_meta); GatherModuleConfig(&table->policy_table.module_config); GatherUsageAndErrorCounts(&*table->policy_table.usage_and_error_counts); @@ -765,7 +765,6 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return false; } -#ifdef SDL_REMOTE_CONTROL bool denied = false; if (!GatherRemoteControlDenied(app_id, &denied)) { return false; @@ -775,7 +774,6 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return false; } } -#endif // SDL_REMOTE_CONTROL if (!GatherNickName(app_id, &*params.nicknames)) { return false; @@ -1051,14 +1049,11 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( return false; } -#ifdef SDL_REMOTE_CONTROL - bool denied = !app.second.moduleType->is_initialized(); if (!SaveRemoteControlDenied(app.first, denied) || !SaveModuleType(app.first, *app.second.moduleType)) { return false; } -#endif // SDL_REMOTE_CONTROL if (!SaveNickname(app.first, *app.second.nicknames)) { return false; @@ -1714,8 +1709,6 @@ bool SQLPTRepresentation::GatherAppGroup( return true; } -#ifdef SDL_REMOTE_CONTROL - bool SQLPTRepresentation::GatherRemoteControlDenied(const std::string& app_id, bool* denied) const { LOG4CXX_AUTO_TRACE(logger_); @@ -1747,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; @@ -1779,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; } @@ -1905,7 +1914,6 @@ bool SQLPTRepresentation::GatherRemoteRpc( } return true; } -#endif // SDL_REMOTE_CONTROL bool SQLPTRepresentation::SaveApplicationCustomData(const std::string& app_id, bool is_revoked, |