summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYevhenii Dementieiev (GitHub) <ydementieiev@luxoft.com>2020-03-18 17:44:45 +0200
committerLitvinenkoIra <ilytvynenko@luxoft.com>2020-03-19 23:06:38 +0200
commitb4861efdf28aa45ba6a9050dcdc1043274ff4322 (patch)
tree7c15a7f547c1744a9951f939eddb05e440071305
parent19d7fa381c885fe7e2cdb1e5e82431c92b5b99b6 (diff)
downloadsdl_core-b4861efdf28aa45ba6a9050dcdc1043274ff4322.tar.gz
Created implementation for save and received MetaInfo
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h2
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc5
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h6
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h6
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h6
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h6
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h6
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h2
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc7
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc5
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h6
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h6
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h3
-rw-r--r--src/components/policy/policy_regular/include/policy/pt_representation.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_queries.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_representation.h4
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc21
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc6
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc38
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc7
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc39
22 files changed, 182 insertions, 10 deletions
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index b8f105380c..414580e2bd 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -382,6 +382,8 @@ class PolicyHandler : public PolicyHandlerInterface,
const std::string& wers_country_code,
const std::string& language) OVERRIDE;
+ std::string GetCCPUVersionFromPT() const OVERRIDE;
+
/**
* @brief Send request to HMI to get update on system parameters
*/
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 1974c99d2c..ee54b05987 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -982,6 +982,11 @@ void PolicyHandler::OnGetSystemInfo(const std::string& ccpu_version,
policy_manager_->SetSystemInfo(ccpu_version, wers_country_code, language);
}
+std::string PolicyHandler::GetCCPUVersionFromPT() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return policy_manager_->GetCCPUVersionFromPT();
+}
+
void PolicyHandler::OnSystemInfoUpdateRequired() {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index 7f31c5834d..a3d0b33850 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -314,6 +314,12 @@ class PolicyHandlerInterface : public VehicleDataItemProvider {
const std::string& language) = 0;
/**
+ * @brief Get information about last ccpu_version from PT
+ * @return ccpu_version from PT
+ */
+ virtual std::string GetCCPUVersionFromPT() const = 0;
+
+ /**
* @brief Send request to HMI to get update on system parameters
*/
virtual void OnSystemInfoUpdateRequired() = 0;
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index 9ba5de4973..6ab755f8d6 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -427,6 +427,12 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const std::string& language) = 0;
/**
+ * @brief Get information about last ccpu_version from PT
+ * @return ccpu_version from PT
+ */
+ virtual std::string GetCCPUVersionFromPT() const = 0;
+
+ /**
* @brief Send OnPermissionsUpdated for choosen application
* @param device_id device identifier
* @param application_id Unique application id
diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index 7ba9a77a6c..cbaa45abdf 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -418,6 +418,12 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const std::string& language) = 0;
/**
+ * @brief Get information about last ccpu_version from PT
+ * @return ccpu_version from PT
+ */
+ virtual std::string GetCCPUVersionFromPT() const = 0;
+
+ /**
* @brief Send OnPermissionsUpdated for choosen application
* @param device_id device identifier
* @param application_id Unique application id
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index b826f4e5ce..3a07b95209 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -605,6 +605,12 @@ class CacheManager : public CacheManagerInterface {
const std::string& language);
/**
+ * @brief Get information about last ccpu_version from PT
+ * @return ccpu_version from PT
+ */
+ std::string GetCCPUVersionFromPT() const;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index 3e3de694d6..7cebaf79cd 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -646,6 +646,12 @@ class CacheManagerInterface {
const std::string& language) = 0;
/**
+ * @brief Get information about last ccpu_version from PT
+ * @return ccpu_version from PT
+ */
+ virtual std::string GetCCPUVersionFromPT() const = 0;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index 2fd58d3a07..2f3dcb66a8 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -435,6 +435,8 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& wers_country_code,
const std::string& language) OVERRIDE;
+ std::string GetCCPUVersionFromPT() const OVERRIDE;
+
/**
* @brief Runs necessary operations, which is depends on external system
* state, e.g. getting system-specific parameters which are need to be
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index d8819b6bad..1c589052c2 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -2293,6 +2293,13 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
return true;
}
+std::string CacheManager::GetCCPUVersionFromPT() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ rpc::Optional<policy_table::ModuleMeta>& module_meta =
+ pt_->policy_table.module_meta;
+ return *(module_meta->ccpu_version);
+}
+
bool CacheManager::IsMetaInfoPresent() const {
CACHE_MANAGER_CHECK(false);
bool result = true;
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index de63762e8e..91172e7107 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -1630,6 +1630,11 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version,
cache_->SetMetaInfo(ccpu_version, wers_country_code, language);
}
+std::string PolicyManagerImpl::GetCCPUVersionFromPT() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->GetCCPUVersionFromPT();
+}
+
void PolicyManagerImpl::OnSystemReady() {
// Update policy table for the first time with system information
if (!cache_->IsMetaInfoPresent()) {
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index 00f0adab06..a3855ee0b6 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -552,6 +552,12 @@ class CacheManager : public CacheManagerInterface {
const std::string& language);
/**
+ * @brief Get information about last ccpu_version from PT
+ * @return ccpu_version from PT
+ */
+ std::string GetCCPUVersionFromPT() const;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index fc1a6337aa..d85586b706 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -587,6 +587,12 @@ class CacheManagerInterface {
const std::string& language) = 0;
/**
+ * @brief Get information about last ccpu_version from PT
+ * @return ccpu_version from PT
+ */
+ virtual std::string GetCCPUVersionFromPT() const = 0;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index d29852b279..188e4f2a13 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -451,6 +451,8 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& wers_country_code,
const std::string& language) OVERRIDE;
+ std::string GetCCPUVersionFromPT() const OVERRIDE;
+
/**
* @brief Runs necessary operations, which is depends on external system
* state, e.g. getting system-specific parameters which are need to be
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h
index 2ffbf2e7ec..9d2994cdff 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h
@@ -424,6 +424,9 @@ struct ConsumerFriendlyMessages : CompositeType {
struct ModuleMeta : CompositeType {
public:
+ Optional<String<0, 250> > ccpu_version;
+ Optional<String<0, 250> > language;
+ Optional<String<0, 250> > wers_country_code;
Optional<Integer<uint32_t, 0, ODO_MAX> > pt_exchanged_at_odometer_x;
Optional<Integer<uint16_t, 0, 65535> > pt_exchanged_x_days_after_epoch;
Optional<Integer<uint16_t, 0, 65535> > ignition_cycles_since_last_exchange;
diff --git a/src/components/policy/policy_regular/include/policy/pt_representation.h b/src/components/policy/policy_regular/include/policy/pt_representation.h
index 467fb4641f..19f383a9d3 100644
--- a/src/components/policy/policy_regular/include/policy/pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/pt_representation.h
@@ -152,6 +152,14 @@ class PTRepresentation {
virtual EndpointUrls GetUpdateUrls(int service_type) = 0;
/**
+ * @brief Records information about head unit system to PT
+ * @return bool Success of operation
+ */
+ virtual bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) = 0;
+
+ /**
* @brief Get allowed number of notifications
* depending on application priority.
* @param priority Priority of application
diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
index 315c30b995..0b0ae11f3f 100644
--- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
+++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h
@@ -142,6 +142,7 @@ extern const std::string kSelectDBVersion;
extern const std::string kUpdateDBVersion;
extern const std::string kSaveModuleMeta;
extern const std::string kSelectModuleMeta;
+extern const std::string kUpdateMetaParams;
extern const std::string kInsertVehicleDataItem;
extern const std::string kSelectVehicleDataItem;
extern const std::string kDeleteVehicleDataItems;
diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
index 5bc49ee973..c19f29f578 100644
--- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h
@@ -89,7 +89,9 @@ class SQLPTRepresentation : public virtual PTRepresentation {
StringArray* nicknames = NULL,
StringArray* app_hmi_types = NULL);
bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups);
-
+ bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language);
#ifdef BUILD_TESTS
uint32_t open_counter() {
return open_counter_;
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 8227090f5f..87393c184d 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -1344,6 +1344,11 @@ void CacheManager::PersistData() {
backup_->SaveApplicationCustomData(
app_id, is_revoked, is_default_policy, is_predata_policy);
is_revoked = false;
+
+ backup_->SetMetaInfo(
+ *(*copy_pt.policy_table.module_meta).ccpu_version,
+ *(*copy_pt.policy_table.module_meta).wers_country_code,
+ *(*copy_pt.policy_table.module_meta).language);
}
// In case of extended policy the meta info should be backuped as well.
@@ -1480,15 +1485,25 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
const std::string& language) {
CACHE_MANAGER_CHECK(false);
sync_primitives::AutoLock auto_lock(cache_lock_);
-
+ rpc::Optional<policy_table::ModuleMeta>& module_meta =
+ pt_->policy_table.module_meta;
+ *(module_meta->ccpu_version) = ccpu_version;
+ *(module_meta->wers_country_code) = wers_country_code;
+ *(module_meta->language) = language;
// We have to set preloaded flag as false in policy table on any response
// of GetSystemInfo (SDLAQ-CRS-2365)
- *pt_->policy_table.module_config.preloaded_pt = false;
-
+ *(pt_->policy_table.module_config.preloaded_pt) = false;
Backup();
return true;
}
+std::string CacheManager::GetCCPUVersionFromPT() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ rpc::Optional<policy_table::ModuleMeta>& module_meta =
+ pt_->policy_table.module_meta;
+ return *(module_meta->ccpu_version);
+}
+
bool CacheManager::IsMetaInfoPresent() const {
CACHE_MANAGER_CHECK(false);
bool result = true;
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index 89f3842df4..9f9b532b6c 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -1207,6 +1207,12 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language) {
LOG4CXX_AUTO_TRACE(logger_);
+ cache_->SetMetaInfo(ccpu_version, wers_country_code, language);
+}
+
+std::string PolicyManagerImpl::GetCCPUVersionFromPT() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->GetCCPUVersionFromPT();
}
void PolicyManagerImpl::OnSystemReady() {
diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc
index 3029ebb067..d1dc52bee0 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -1269,6 +1269,9 @@ ModuleMeta::~ModuleMeta() {}
ModuleMeta::ModuleMeta(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
+ , ccpu_version(impl::ValueMember(value__, "ccpu_version"))
+ , language(impl::ValueMember(value__, "language"))
+ , wers_country_code(impl::ValueMember(value__, "wers_country_code"))
, pt_exchanged_at_odometer_x(
impl::ValueMember(value__, "pt_exchanged_at_odometer_x"))
, pt_exchanged_x_days_after_epoch(
@@ -1278,6 +1281,9 @@ ModuleMeta::ModuleMeta(const Json::Value* value__)
Json::Value ModuleMeta::ToJsonValue() const {
Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("ccpu_version", ccpu_version, &result__);
+ impl::WriteJsonField("language", language, &result__);
+ impl::WriteJsonField("wers_country_code", wers_country_code, &result__);
impl::WriteJsonField(
"pt_exchanged_at_odometer_x", pt_exchanged_at_odometer_x, &result__);
impl::WriteJsonField("pt_exchanged_x_days_after_epoch",
@@ -1293,6 +1299,15 @@ bool ModuleMeta::is_valid() const {
if (struct_empty()) {
return initialization_state__ == kInitialized && Validate();
}
+ if (!ccpu_version.is_valid()) {
+ return false;
+ }
+ if (!language.is_valid()) {
+ return false;
+ }
+ if (!wers_country_code.is_valid()) {
+ return false;
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
return false;
}
@@ -1310,6 +1325,16 @@ bool ModuleMeta::is_initialized() const {
}
bool ModuleMeta::struct_empty() const {
+ if (ccpu_version.is_initialized()) {
+ return false;
+ }
+ if (language.is_initialized()) {
+ return false;
+ }
+
+ if (wers_country_code.is_initialized()) {
+ return false;
+ }
if (pt_exchanged_at_odometer_x.is_initialized()) {
return false;
}
@@ -1327,6 +1352,16 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
+ if (!ccpu_version.is_valid()) {
+ ccpu_version.ReportErrors(&report__->ReportSubobject("ccpu_version"));
+ }
+ if (!language.is_valid()) {
+ language.ReportErrors(&report__->ReportSubobject("language"));
+ }
+ if (!wers_country_code.is_valid()) {
+ wers_country_code.ReportErrors(
+ &report__->ReportSubobject("wers_country_code"));
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
pt_exchanged_at_odometer_x.ReportErrors(
&report__->ReportSubobject("pt_exchanged_at_odometer_x"));
@@ -1343,6 +1378,9 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
void ModuleMeta::SetPolicyTableType(PolicyTableType pt_type) {
CompositeType::SetPolicyTableType(pt_type);
+ ccpu_version.SetPolicyTableType(pt_type);
+ language.SetPolicyTableType(pt_type);
+ wers_country_code.SetPolicyTableType(pt_type);
pt_exchanged_at_odometer_x.SetPolicyTableType(pt_type);
pt_exchanged_x_days_after_epoch.SetPolicyTableType(pt_type);
ignition_cycles_since_last_exchange.SetPolicyTableType(pt_type);
diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc
index 79eee10d43..8e62d474be 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -56,6 +56,9 @@ const std::string kCreateSchema =
" `count_of_sync_reboots` INTEGER "
"); "
"CREATE TABLE IF NOT EXISTS `module_meta`( "
+ " `ccpu_version` VARCHAR(45), "
+ " `language` VARCHAR(45), "
+ " `wers_country_code` VARCHAR(45), "
" `pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0, "
" `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, "
" `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, "
@@ -1047,5 +1050,9 @@ const std::string kSaveModuleMeta =
"`ignition_cycles_since_last_exchange` = ? ";
const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`";
+
+const std::string kUpdateMetaParams =
+ "UPDATE `module_meta` SET "
+ "`ccpu_version` = ?, `language` = ?, `wers_country_code` = ? ";
} // namespace sql_pt
} // namespace policy
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 c6d0b60f89..7bc10e124b 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -476,9 +476,12 @@ void SQLPTRepresentation::GatherModuleMeta(
LOG4CXX_INFO(logger_, "Gather Module Meta Info");
utils::dbms::SQLQuery query(db());
if (query.Prepare(sql_pt::kSelectModuleMeta) && query.Next()) {
- *meta->pt_exchanged_at_odometer_x = query.GetInteger(0);
- *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(1);
- *meta->ignition_cycles_since_last_exchange = query.GetInteger(2);
+ *meta->ccpu_version = query.GetString(0);
+ *meta->language = query.GetString(1);
+ *meta->wers_country_code = query.GetString(2);
+ *meta->pt_exchanged_at_odometer_x = query.GetInteger(3);
+ *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(4);
+ *meta->ignition_cycles_since_last_exchange = query.GetInteger(5);
}
}
@@ -693,6 +696,27 @@ bool SQLPTRepresentation::GatherConsumerFriendlyMessages(
return true;
}
+bool SQLPTRepresentation::SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kUpdateMetaParams)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for insert to module meta.");
+ return false;
+ }
+
+ query.Bind(0, ccpu_version);
+ query.Bind(1, wers_country_code);
+ query.Bind(2, language);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert to module meta.");
+ return false;
+ }
+ return true;
+}
+
bool SQLPTRepresentation::GatherApplicationPoliciesSection(
policy_table::ApplicationPoliciesSection* policies) const {
LOG4CXX_INFO(logger_, "Gather applications policies");
@@ -1396,9 +1420,12 @@ bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) {
}
const int64_t odometer = *(meta.pt_exchanged_at_odometer_x);
- query.Bind(0, odometer);
- query.Bind(1, *(meta.pt_exchanged_x_days_after_epoch));
- query.Bind(2, *(meta.ignition_cycles_since_last_exchange));
+ query.Bind(0, *(meta.ccpu_version));
+ query.Bind(1, *(meta.language));
+ query.Bind(2, *(meta.wers_country_code));
+ query.Bind(3, odometer);
+ query.Bind(4, *(meta.pt_exchanged_x_days_after_epoch));
+ query.Bind(5, *(meta.ignition_cycles_since_last_exchange));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Incorrect update for module_meta.");