summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/app_launch/app_launch_data_db.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/app_launch/app_launch_data_db.cc')
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_db.cc174
1 files changed, 77 insertions, 97 deletions
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
index a931b96fa1..7c015b0707 100644
--- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc
+++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
@@ -39,7 +39,7 @@
#include "application_manager/smart_object_keys.h"
namespace app_launch {
-CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+SDL_CREATE_LOG_VARIABLE("AppLaunch")
AppLaunchDataDB::AppLaunchDataDB(const AppLaunchSettings& settings,
DbStorage db_storage)
@@ -56,8 +56,8 @@ AppLaunchDataDB::AppLaunchDataDB(const AppLaunchSettings& settings,
#endif // __QNX__
DCHECK(db_.get());
} else {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_ERROR(logger_, "Get not existed type of database storage");
+ SDL_LOG_AUTO_TRACE();
+ SDL_LOG_ERROR("Get not existed type of database storage");
}
// Connect to resumption DB
@@ -69,48 +69,44 @@ AppLaunchDataDB::~AppLaunchDataDB() {
}
bool AppLaunchDataDB::Init() {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
if (!db()->Open()) {
- LOG4CXX_ERROR(logger_, "Failed opening database.");
- LOG4CXX_INFO(logger_, "Starting opening retries.");
+ SDL_LOG_ERROR("Failed opening database.");
+ SDL_LOG_INFO("Starting opening retries.");
const uint16_t attempts = settings_.app_launch_max_retry_attempt();
- LOG4CXX_DEBUG(logger_, "Total attempts number is: " << attempts);
+ SDL_LOG_DEBUG("Total attempts number is: " << attempts);
bool is_opened = false;
const uint16_t open_attempt_timeout_ms =
settings_.app_launch_retry_wait_time();
const useconds_t sleep_interval_mcsec = open_attempt_timeout_ms * 1000u;
- LOG4CXX_DEBUG(logger_,
- "Open attempt timeout(ms) is: " << open_attempt_timeout_ms);
+ SDL_LOG_DEBUG("Open attempt timeout(ms) is: " << open_attempt_timeout_ms);
for (size_t i = 0u; i < attempts; ++i) {
usleep(sleep_interval_mcsec);
- LOG4CXX_INFO(logger_, "Attempt: " << i + 1);
+ SDL_LOG_INFO("Attempt: " << i + 1);
if (db()->Open()) {
- LOG4CXX_INFO(logger_, "Database opened.");
+ SDL_LOG_INFO("Database opened.");
is_opened = true;
break;
}
}
if (!is_opened) {
- LOG4CXX_ERROR(logger_,
- "Open retry sequence failed. Tried "
- << attempts << " attempts with "
- << open_attempt_timeout_ms
- << " open timeout(ms) for each.");
+ SDL_LOG_ERROR("Open retry sequence failed. Tried "
+ << attempts << " attempts with " << open_attempt_timeout_ms
+ << " open timeout(ms) for each.");
return false;
}
}
#ifndef __QNX__
if (!db()->IsReadWrite()) {
- LOG4CXX_ERROR(logger_, "There are no read/write permissions for database");
+ SDL_LOG_ERROR("There are no read/write permissions for database");
return false;
}
#endif // __QNX__
utils::dbms::SQLQuery query(db());
if (!query.Exec(kCreateSchema)) {
- LOG4CXX_ERROR(
- logger_,
+ SDL_LOG_ERROR(
"Failed creating schema of database: " << query.LastError().text());
return false;
}
@@ -119,20 +115,20 @@ bool AppLaunchDataDB::Init() {
}
bool AppLaunchDataDB::Persist() {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
bool retVal = false;
if (!init_successeful_) {
- LOG4CXX_ERROR(logger_,
- "AppLaunch data base was not successfully "
- "initialize, AppLaunch won't work!");
+ SDL_LOG_ERROR(
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
return retVal;
}
if ((retVal = WriteDb())) {
- LOG4CXX_DEBUG(logger_, "App_lauch had been successfully saved.");
+ SDL_LOG_DEBUG("App_lauch had been successfully saved.");
} else {
- LOG4CXX_WARN(logger_, "Fail to save app_launch data.");
+ SDL_LOG_WARN("Fail to save app_launch data.");
}
return retVal;
@@ -140,21 +136,20 @@ bool AppLaunchDataDB::Persist() {
bool AppLaunchDataDB::IsAppDataAlreadyExisted(
const ApplicationData& app_data) const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
bool retVal = false;
if (!init_successeful_) {
- LOG4CXX_ERROR(logger_,
- "AppLaunch data base was not successfully "
- "initialize, AppLaunch won't work!");
+ SDL_LOG_ERROR(
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
return retVal;
}
utils::dbms::SQLQuery query(db());
if (!query.Prepare(kFindApplicationData)) {
- LOG4CXX_WARN(logger_,
- "Problem with verification queries 'kFindApplicationData'");
+ SDL_LOG_WARN("Problem with verification queries 'kFindApplicationData'");
return retVal;
}
@@ -165,31 +160,30 @@ bool AppLaunchDataDB::IsAppDataAlreadyExisted(
if (query.Exec()) {
retVal = query.GetBoolean(result_query);
} else {
- LOG4CXX_WARN(logger_,
- "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
- << query.LastError().text());
+ SDL_LOG_WARN("Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
}
return retVal;
}
bool AppLaunchDataDB::RefreshAppSessionTime(const ApplicationData& app_data) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
bool retVal = false;
if (!init_successeful_) {
- LOG4CXX_ERROR(logger_,
- "AppLaunch data base was not successfully "
- "initialize, AppLaunch won't work!");
+ SDL_LOG_ERROR(
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
return retVal;
}
utils::dbms::SQLQuery query(db());
if (!query.Prepare(kRefreshApplicationDataSessionTime)) {
- LOG4CXX_WARN(logger_,
- "Problem with verification queries "
- "'kRefreshApplicationDataSessionTime'");
+ SDL_LOG_WARN(
+ "Problem with verification queries "
+ "'kRefreshApplicationDataSessionTime'");
return retVal;
}
@@ -198,33 +192,31 @@ bool AppLaunchDataDB::RefreshAppSessionTime(const ApplicationData& app_data) {
query.Bind(bundle_id_index, app_data.bundle_id_);
if (query.Exec()) {
- LOG4CXX_DEBUG(logger_, "Dare&time last session were updated successfully");
+ SDL_LOG_DEBUG("Dare&time last session were updated successfully");
retVal = WriteDb();
} else {
- LOG4CXX_WARN(logger_,
- "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
- << query.LastError().text());
+ SDL_LOG_WARN("Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
}
return retVal;
}
bool AppLaunchDataDB::AddNewAppData(const ApplicationData& app_data) {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
bool retVal = false;
if (!init_successeful_) {
- LOG4CXX_ERROR(logger_,
- "AppLaunch data base was not successfully "
- "initialize, AppLaunch won't work!");
+ SDL_LOG_ERROR(
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
return retVal;
}
utils::dbms::SQLQuery query(db());
if (!query.Prepare(kAddApplicationData)) {
- LOG4CXX_WARN(logger_,
- "Problem with verification queries 'kAddApplicationData'");
+ SDL_LOG_WARN("Problem with verification queries 'kAddApplicationData'");
return retVal;
}
@@ -234,12 +226,11 @@ bool AppLaunchDataDB::AddNewAppData(const ApplicationData& app_data) {
retVal = query.Exec();
if (retVal) {
- LOG4CXX_DEBUG(logger_, "New application data was added successfully");
+ SDL_LOG_DEBUG("New application data was added successfully");
retVal = WriteDb();
} else {
- LOG4CXX_WARN(logger_,
- "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
- << query.LastError().text());
+ SDL_LOG_WARN("Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
}
return retVal;
@@ -247,21 +238,20 @@ bool AppLaunchDataDB::AddNewAppData(const ApplicationData& app_data) {
std::vector<ApplicationDataPtr> AppLaunchDataDB::GetAppDataByDevMac(
const std::string& dev_mac) const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
std::vector<ApplicationDataPtr> dev_apps;
if (!init_successeful_) {
- LOG4CXX_ERROR(logger_,
- "AppLaunch data base was not successfully "
- "initialize, AppLaunch won't work!");
+ SDL_LOG_ERROR(
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
return dev_apps;
}
utils::dbms::SQLQuery query(db());
if (!query.Prepare(kGetApplicationDataByDevID)) {
- LOG4CXX_WARN(
- logger_,
+ SDL_LOG_WARN(
"Problem with verification queries 'kGetApplicationDataByDevID'");
return dev_apps;
}
@@ -269,8 +259,7 @@ std::vector<ApplicationDataPtr> AppLaunchDataDB::GetAppDataByDevMac(
query.Bind(device_mac_index, dev_mac);
const bool retVal = query.Exec();
if (retVal) {
- LOG4CXX_INFO(logger_,
- "Values of ignition off counts were updated successfully");
+ SDL_LOG_INFO("Values of ignition off counts were updated successfully");
do {
const std::string device_mac = query.GetString(device_mac_index);
const std::string mobile_app_id = query.GetString(application_id_index);
@@ -278,106 +267,97 @@ std::vector<ApplicationDataPtr> AppLaunchDataDB::GetAppDataByDevMac(
dev_apps.push_back(std::make_shared<ApplicationData>(
mobile_app_id, bundle_id, device_mac));
} while (query.Next());
- LOG4CXX_DEBUG(logger_, "All application data has been successfully loaded");
+ SDL_LOG_DEBUG("All application data has been successfully loaded");
} else {
- LOG4CXX_WARN(logger_,
- "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
- << query.LastError().text());
+ SDL_LOG_WARN("Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
}
return dev_apps;
}
bool AppLaunchDataDB::Clear() {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
bool retVal = false;
utils::dbms::SQLQuery query(db());
retVal = query.Exec(kDropSchema);
if (retVal) {
- LOG4CXX_INFO(logger_, "App_Launch table had been cleared successfully");
+ SDL_LOG_INFO("App_Launch table had been cleared successfully");
retVal = WriteDb();
init_successeful_ = false;
} else {
- LOG4CXX_WARN(logger_,
- "Failed dropping database: " << query.LastError().text());
+ SDL_LOG_WARN("Failed dropping database: " << query.LastError().text());
}
return retVal;
}
uint32_t AppLaunchDataDB::GetCurentNumberOfAppData() const {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
uint32_t number_of_app_data = 0u;
if (!init_successeful_) {
- LOG4CXX_ERROR(logger_,
- "AppLaunch data base was not successfully "
- "initialize, AppLaunch won't work!");
+ SDL_LOG_ERROR(
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
return number_of_app_data;
}
utils::dbms::SQLQuery query(db());
if (!query.Prepare(kGetNumberOfApplicationData)) {
- LOG4CXX_WARN(
- logger_,
+ SDL_LOG_WARN(
"Problem with verification queries 'kGetNumberOfApplicationData'");
return number_of_app_data;
}
if (query.Exec()) {
- LOG4CXX_INFO(logger_,
- "Values of ignition off counts were updated successfully");
+ SDL_LOG_INFO("Values of ignition off counts were updated successfully");
number_of_app_data = query.GetInteger(result_query);
- LOG4CXX_DEBUG(
- logger_,
- "Total cout saved mobile applications is " << number_of_app_data);
+ SDL_LOG_DEBUG("Total cout saved mobile applications is "
+ << number_of_app_data);
} else {
- LOG4CXX_WARN(logger_,
- "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
- << query.LastError().text());
+ SDL_LOG_WARN("Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
}
return number_of_app_data;
}
bool AppLaunchDataDB::DeleteOldestAppData() {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
bool retVal = false;
if (!init_successeful_) {
- LOG4CXX_ERROR(logger_,
- "AppLaunch data base was not successfully "
- "initialize, AppLaunch won't work!");
+ SDL_LOG_ERROR(
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
return retVal;
}
utils::dbms::SQLQuery query(db());
if (!query.Prepare(kDeleteOldestAppData)) {
- LOG4CXX_WARN(logger_,
- "Problem with verification queries 'kDeleteOldestAppData'");
+ SDL_LOG_WARN("Problem with verification queries 'kDeleteOldestAppData'");
return retVal;
}
if ((retVal = query.Exec())) {
- LOG4CXX_INFO(logger_,
- "Values of ignition off counts were updated successfully");
+ SDL_LOG_INFO("Values of ignition off counts were updated successfully");
retVal = WriteDb();
} else {
- LOG4CXX_WARN(logger_,
- "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
- << query.LastError().text());
+ SDL_LOG_WARN("Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
}
return retVal;
}
bool AppLaunchDataDB::WriteDb() {
- LOG4CXX_AUTO_TRACE(logger_);
+ SDL_LOG_AUTO_TRACE();
return db_->Backup();
}