summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/resumption/resumption_data_db.cc
diff options
context:
space:
mode:
authorHerasym Oleh <oolleehh@gmail.com>2016-03-24 15:27:24 +0200
committerHerasym Oleh <oolleehh@gmail.com>2016-04-13 09:05:33 +0300
commit47e02bf586513eccb2ba00656a17b237efb1442c (patch)
treecf4f5299ae809896e803f1f03f87d8f857b5e73a /src/components/application_manager/src/resumption/resumption_data_db.cc
parent021ed56b19de2f284908d09b74bf2ca39ff76a9e (diff)
downloadsdl_core-47e02bf586513eccb2ba00656a17b237efb1442c.tar.gz
Add implementation SubscribeWayPoints&UnsubsribeWayPoints
Add mobile request/response SubscribeWayPoints Add mobile request/response UnSubscribeWayPoints Add HMI request/response SubscribeWayPoints Add HMI request/response UnsubscribeWayPoints Add SendUnsubscribeWayPoints method in MessageHelper Add save subscribe app status to resumption DB & json Add Sending UnsubscribeWayPoints in case unexpected disconnect Related: APPLINK-21629 Conflicts: src/components/application_manager/src/application_manager_impl.cc
Diffstat (limited to 'src/components/application_manager/src/resumption/resumption_data_db.cc')
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_db.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc
index 21c9eed3b4..4252e86c4c 100644
--- a/src/components/application_manager/src/resumption/resumption_data_db.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_db.cc
@@ -32,6 +32,7 @@
#include <string>
#include <unistd.h>
+#include "application_manager/application_manager_impl.h"
#include "application_manager/resumption/resumption_data_db.h"
#include "application_manager/resumption/resumption_sql_queries.h"
#include "application_manager/smart_object_keys.h"
@@ -152,6 +153,11 @@ void ResumptionDataDB::SaveApplication(
return;
}
+ if (!InsertSubscribedForWayPoints()) {
+ LOG4CXX_ERROR(logger_, "Problem with saving SubscribedForWayPoints");
+ return;
+ }
+
if (application->is_application_data_changed()) {
if (application_exist) {
if (!DeleteSavedApplication(policy_app_id, device_mac)) {
@@ -343,6 +349,11 @@ bool ResumptionDataDB::GetSavedApplication(
return false;
}
+ if (!SelectSubscribedForWayPoints()) {
+ LOG4CXX_ERROR(logger_, "Problem with restoring of SubscribedForWayPoints");
+ return false;
+ }
+
if (!SelectFilesData(policy_app_id, device_id, saved_app)) {
LOG4CXX_ERROR(logger_, "Problem with restoring of files data");
return false;
@@ -2712,6 +2723,73 @@ void ResumptionDataDB::UpdateDataOnAwake() {
}
}
+bool ResumptionDataDB::InsertSubscribedForWayPoints() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace app_mngr;
+
+ if (!DeleteSubscribedForWayPoints()) {
+ LOG4CXX_WARN(logger_, "SubscribedForWayPoints table was not cleaned");
+ }
+
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(kInsertSubscribedForWayPoints)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification query "
+ "for updating some SubscribedForWayPoints data");
+ return false;
+ }
+
+ const std::set<int32_t> apps =
+ application_manager::ApplicationManagerImpl::instance()
+ ->GetSubscribedForWayPoints();
+ for (std::set<int32_t>::iterator i = apps.begin(); i != apps.end(); i++) {
+ query.Reset();
+ query.Bind(0, *i);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Problem with execution query");
+ return false;
+ }
+ }
+ LOG4CXX_INFO(
+ logger_,
+ "Data were updated successfully in SubscribedForWayPoints table");
+ return true;
+}
+
+bool ResumptionDataDB::SelectSubscribedForWayPoints() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::set<int32_t> subscribed_for_way_points;
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(kSelectSubscribedForWayPoints)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Problem with verification kSelectSubscribedForWayPoints query");
+ return false;
+ }
+ while (query.Next()) {
+ subscribed_for_way_points.insert(query.GetInteger(0));
+ }
+ application_manager::ApplicationManagerImpl::instance()
+ ->SetSubscribedForWayPoints(subscribed_for_way_points);
+ return true;
+}
+
+bool ResumptionDataDB::DeleteSubscribedForWayPoints() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(kDeleteSubscribedForWayPoints)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Problem with verification kDeleteSubscribedForWayPoints query");
+ return false;
+ }
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Problem with execution query");
+ return false;
+ }
+ return true;
+}
+
bool ResumptionDataDB::UpdateApplicationData(
app_mngr::ApplicationConstSharedPtr application,
const std::string& policy_app_id,