diff --git a/src/appMain/life_cycle.cc b/src/appMain/life_cycle.cc index 3c1a74b7204..10cca523887 100644 --- a/src/appMain/life_cycle.cc +++ b/src/appMain/life_cycle.cc @@ -92,7 +92,7 @@ LifeCycle::LifeCycle() } bool LifeCycle::StartComponents() { - LOG4CXX_AUTO_TRACE(logger_); + LOGGER_AUTO_TRACE(logger_); DCHECK(!last_state_); profile::Profile* profile = profile::Profile::instance(); last_state_ = new resumption::LastState(profile->app_storage_folder(), @@ -124,7 +124,7 @@ bool LifeCycle::StartComponents() { media_manager_ = new media_manager::MediaManagerImpl(*app_manager_, *profile); if (!app_manager_->Init(*last_state_, media_manager_)) { - LOG4CXX_ERROR(logger_, "Application manager init failed."); + LOGGER_ERROR(logger_, "Application manager init failed."); return false; } @@ -144,7 +144,7 @@ bool LifeCycle::StartComponents() { app_manager_->AddPolicyObserver(crypto_manager_); if (!crypto_manager_->Init()) { - LOG4CXX_ERROR(logger_, "CryptoManager initialization fail."); + LOGGER_ERROR(logger_, "CryptoManager initialization fail."); return false; } #endif // ENABLE_SECURITY @@ -189,7 +189,7 @@ bool LifeCycle::InitMessageSystem() { DCHECK(!message_broker_) message_broker_ = NsMessageBroker::CMessageBroker::getInstance(); if (!message_broker_) { - LOG4CXX_FATAL(logger_, " Wrong pMessageBroker pointer!"); + LOGGER_FATAL(logger_, " Wrong pMessageBroker pointer!"); return false; } @@ -198,27 +198,27 @@ bool LifeCycle::InitMessageSystem() { profile::Profile::instance()->server_port(), message_broker_); if (!message_broker_server_) { - LOG4CXX_FATAL(logger_, " Wrong pJSONRPC20Server pointer!"); + LOGGER_FATAL(logger_, " Wrong pJSONRPC20Server pointer!"); return false; } message_broker_->startMessageBroker(message_broker_server_); if (!networking::init()) { - LOG4CXX_FATAL(logger_, " Networking initialization failed!"); + LOGGER_FATAL(logger_, " Networking initialization failed!"); return false; } if (!message_broker_server_->Bind()) { - LOG4CXX_FATAL(logger_, "Message broker server bind failed!"); + LOGGER_FATAL(logger_, "Message broker server bind failed!"); return false; } else { - LOG4CXX_INFO(logger_, "Message broker server bind successful!"); + LOGGER_INFO(logger_, "Message broker server bind successful!"); } if (!message_broker_server_->Listen()) { - LOG4CXX_FATAL(logger_, "Message broker server listen failed!"); + LOGGER_FATAL(logger_, "Message broker server listen failed!"); return false; } else { - LOG4CXX_INFO(logger_, " Message broker server listen successful!"); + LOGGER_INFO(logger_, " Message broker server listen successful!"); } mb_adapter_ = new hmi_message_handler::MessageBrokerAdapter( @@ -228,11 +228,11 @@ bool LifeCycle::InitMessageSystem() { hmi_handler_->AddHMIMessageAdapter(mb_adapter_); if (!mb_adapter_->Connect()) { - LOG4CXX_FATAL(logger_, "Cannot connect to remote peer!"); + LOGGER_FATAL(logger_, "Cannot connect to remote peer!"); return false; } - LOG4CXX_INFO(logger_, "Start CMessageBroker thread!"); + LOGGER_INFO(logger_, "Start CMessageBroker thread!"); mb_thread_ = new System::Thread( new System::ThreadArgImpl( *message_broker_, @@ -243,7 +243,7 @@ bool LifeCycle::InitMessageSystem() { // thread doesn't have valid Id to associate name with NameMessageBrokerThread(*mb_thread_, "MessageBroker"); - LOG4CXX_INFO(logger_, "Start MessageBroker TCP server thread!"); + LOGGER_INFO(logger_, "Start MessageBroker TCP server thread!"); mb_server_thread_ = new System::Thread(new System::ThreadArgImpl( *message_broker_server_, @@ -252,7 +252,7 @@ bool LifeCycle::InitMessageSystem() { mb_server_thread_->Start(false); NameMessageBrokerThread(*mb_server_thread_, "MB TCPServer"); - LOG4CXX_INFO(logger_, "StartAppMgr JSONRPC 2.0 controller receiver thread!"); + LOGGER_INFO(logger_, "StartAppMgr JSONRPC 2.0 controller receiver thread!"); mb_adapter_thread_ = new System::Thread( new System::ThreadArgImpl( *mb_adapter_, @@ -277,13 +277,13 @@ bool LifeCycle::InitMessageSystem() { hmi_message_handler::HMIMessageHandlerImpl::instance()->AddHMIMessageAdapter( dbus_adapter_); if (!dbus_adapter_->Init()) { - LOG4CXX_FATAL(logger_, "Cannot init DBus service!"); + LOGGER_FATAL(logger_, "Cannot init DBus service!"); return false; } dbus_adapter_->SubscribeTo(); - LOG4CXX_INFO(logger_, "Start DBusMessageAdapter thread!"); + LOGGER_INFO(logger_, "Start DBusMessageAdapter thread!"); dbus_adapter_thread_ = new System::Thread( new System::ThreadArgImpl( *dbus_adapter_, @@ -310,35 +310,33 @@ namespace { void sig_handler(int sig) { switch (sig) { case SIGINT: - LOG4CXX_DEBUG(logger_, "SIGINT signal has been caught"); + LOGGER_DEBUG(logger_, "SIGINT signal has been caught"); break; case SIGTERM: - LOG4CXX_DEBUG(logger_, "SIGTERM signal has been caught"); + LOGGER_DEBUG(logger_, "SIGTERM signal has been caught"); break; case SIGSEGV: - LOG4CXX_DEBUG(logger_, "SIGSEGV signal has been caught"); + LOGGER_DEBUG(logger_, "SIGSEGV signal has been caught"); FLUSH_LOGGER(); // exit need to prevent endless sending SIGSEGV // http://stackoverflow.com/questions/2663456/how-to-write-a-signal-handler-to-catch-sigsegv abort(); default: - LOG4CXX_DEBUG(logger_, "Unexpected signal has been caught"); + LOGGER_DEBUG(logger_, "Unexpected signal has been caught"); exit(EXIT_FAILURE); } } } // namespace void LifeCycle::Run() { - LOG4CXX_AUTO_TRACE(logger_); - // Register signal handlers and wait sys signals - // from OS - if (!utils::WaitTerminationSignals(&sig_handler)) { - LOG4CXX_FATAL(logger_, "Fail to catch system signal!"); - } + LOGGER_AUTO_TRACE(logger_); + ::utils::CreateSdlEvent(); + ::utils::SubscribeToTerminationSignals(); + ::utils::WaitForSdlExecute(); } void LifeCycle::StopComponents() { - LOG4CXX_AUTO_TRACE(logger_); + LOGGER_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(hmi_handler_); hmi_handler_->set_message_observer(NULL); @@ -352,7 +350,7 @@ void LifeCycle::StopComponents() { DCHECK_OR_RETURN_VOID(app_manager_); app_manager_->Stop(); - LOG4CXX_INFO(logger_, "Stopping Protocol Handler"); + LOGGER_INFO(logger_, "Stopping Protocol Handler"); DCHECK_OR_RETURN_VOID(protocol_handler_); protocol_handler_->RemoveProtocolObserver(media_manager_); @@ -360,48 +358,48 @@ void LifeCycle::StopComponents() { protocol_handler_->RemoveProtocolObserver(security_manager_); if (security_manager_) { security_manager_->RemoveListener(app_manager_); - LOG4CXX_INFO(logger_, "Destroying Crypto Manager"); + LOGGER_INFO(logger_, "Destroying Crypto Manager"); delete crypto_manager_; - LOG4CXX_INFO(logger_, "Destroying Security Manager"); + LOGGER_INFO(logger_, "Destroying Security Manager"); delete security_manager_; } #endif // ENABLE_SECURITY protocol_handler_->Stop(); - LOG4CXX_INFO(logger_, "Destroying Media Manager"); + LOGGER_INFO(logger_, "Destroying Media Manager"); DCHECK_OR_RETURN_VOID(media_manager_); media_manager_->SetProtocolHandler(NULL); delete media_manager_; media_manager_ = NULL; - LOG4CXX_INFO(logger_, "Destroying Transport Manager."); + LOGGER_INFO(logger_, "Destroying Transport Manager."); DCHECK_OR_RETURN_VOID(transport_manager_); transport_manager_->Visibility(false); transport_manager_->Stop(); transport_manager::TransportManagerDefault::destroy(); - LOG4CXX_INFO(logger_, "Stopping Connection Handler."); + LOGGER_INFO(logger_, "Stopping Connection Handler."); DCHECK_OR_RETURN_VOID(connection_handler_); connection_handler_->Stop(); - LOG4CXX_INFO(logger_, "Destroying Protocol Handler"); + LOGGER_INFO(logger_, "Destroying Protocol Handler"); DCHECK(protocol_handler_); delete protocol_handler_; protocol_handler_ = NULL; - LOG4CXX_INFO(logger_, "Destroying Connection Handler."); + LOGGER_INFO(logger_, "Destroying Connection Handler."); delete connection_handler_; connection_handler_ = NULL; - LOG4CXX_INFO(logger_, "Destroying Last State"); + LOGGER_INFO(logger_, "Destroying Last State"); DCHECK(last_state_); delete last_state_; last_state_ = NULL; - LOG4CXX_INFO(logger_, "Destroying Application Manager."); + LOGGER_INFO(logger_, "Destroying Application Manager."); application_manager::ApplicationManagerImpl::destroy(); - LOG4CXX_INFO(logger_, "Destroying HMI Message Handler and MB adapter."); + LOGGER_INFO(logger_, "Destroying HMI Message Handler and MB adapter."); #ifdef DBUS_HMIADAPTER if (dbus_adapter_) { @@ -438,7 +436,7 @@ void LifeCycle::StopComponents() { delete hmi_handler_; hmi_handler_ = NULL; - LOG4CXX_INFO(logger_, "Destroying Message Broker"); + LOGGER_INFO(logger_, "Destroying Message Broker"); if (mb_server_thread_) { mb_server_thread_->Stop(); mb_server_thread_->Join(); diff --git a/src/appMain/main.cc b/src/appMain/main.cc index 38d28e8760c..02f97080ea0 100644 --- a/src/appMain/main.cc +++ b/src/appMain/main.cc @@ -108,6 +108,24 @@ bool InitHmi() { return utils::System(kStartHmi).Execute(); } #endif // QT_HMI + +bool UnsibscribeFromTermination() { + // Disable some system signals receiving in thread + // by blocking those signals + // (system signals processes only in the main thread) + // Mustn't block all signals! + // See "Advanced Programming in the UNIX Environment, 3rd Edition" + // (http://poincare.matf.bg.ac.rs/~ivana//courses/ps/sistemi_knjige/pomocno/apue.pdf, + // "12.8. Threads and Signals". + sigset_t signal_set; + sigemptyset(&signal_set); + sigaddset(&signal_set, SIGINT); + sigaddset(&signal_set, SIGTERM); + + return !pthread_sigmask(SIG_BLOCK, &signal_set, NULL); +} + + } /** @@ -118,7 +136,7 @@ bool InitHmi() { */ int32_t main(int32_t argc, char** argv) { // Unsibscribe once for all threads - if (!utils::UnsibscribeFromTermination()) { + if (!UnsibscribeFromTermination()) { // Can't use internal logger here exit(EXIT_FAILURE); } @@ -131,8 +149,7 @@ int32_t main(int32_t argc, char** argv) { } // Logger initialization - INIT_LOGGER("log4cxx.properties", - profile::Profile::instance()->logs_enabled()); + INIT_LOGGER(profile::Profile::instance()->logs_enabled()); threads::Thread::SetNameForId(threads::Thread::CurrentId(), "MainThread"); diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 6506adc31a8..8e563c39e04 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -148,7 +148,7 @@ class CommandImpl : public Command { bool allowed_to_terminate_; #ifdef ENABLE_LOG #if defined(OS_POSIX) - static logger::LoggerPtr logger_; + static log4cxx::LoggerPtr logger_; #elif defined(OS_WINDOWS) static std::string logger_; #endif diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities.h b/src/components/application_manager/include/application_manager/hmi_capabilities.h index 45fa869f6fe..2ae99e8b7bd 100644 --- a/src/components/application_manager/include/application_manager/hmi_capabilities.h +++ b/src/components/application_manager/include/application_manager/hmi_capabilities.h @@ -37,6 +37,7 @@ #include "interfaces/MOBILE_API.h" #include "json/json.h" #include "utils/macro.h" +#include "utils/json_utils.h" #include "application_manager/hmi_language_handler.h" @@ -430,7 +431,7 @@ class HMICapabilities { * @param languages - the converted object * */ - void convert_json_languages_to_obj(Json::Value& json_languages, + void convert_json_languages_to_obj(utils::json::JsonValueRef json_languages, smart_objects::SmartObject& languages); private: diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index b8e4f6171a0..66b56045e91 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -83,8 +83,6 @@ DeviceTypes devicesType = { std::make_pair(std::string("WIFI"), hmi_apis::Common_TransportType::WIFI)}; } -CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") - uint32_t ApplicationManagerImpl::corelation_id_ = 0; const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; @@ -2365,7 +2363,7 @@ void ApplicationManagerImpl::HeadUnitReset( GetPolicyHandler().UnloadPolicyLibrary(); resume_controller().StopSavePersistentDataTimer(); - file_system::remove_directory_content( + file_system::RemoveDirectoryContent( profile::Profile::instance()->app_storage_folder()); break; } @@ -2373,7 +2371,7 @@ void ApplicationManagerImpl::HeadUnitReset( GetPolicyHandler().ClearUserConsent(); resume_controller().StopSavePersistentDataTimer(); - file_system::remove_directory_content( + file_system::RemoveDirectoryContent( profile::Profile::instance()->app_storage_folder()); break; } @@ -3127,7 +3125,7 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( uint64_t file_size = file_system::FileSize(full_file_path); std::ofstream* file_stream; if (offset != 0) { - if (file_size != offset) { + if (file_size != static_cast(offset)) { LOGGER_DEBUG(logger_, "ApplicationManagerImpl::SaveBinaryWithOffset offset" << " does'n match existing file size"); diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc index 99332dfdb4c..cde3faf8d87 100644 --- a/src/components/application_manager/src/hmi_language_handler.cc +++ b/src/components/application_manager/src/hmi_language_handler.cc @@ -78,7 +78,8 @@ void HMILanguageHandler::set_language_for( LOGGER_DEBUG(logger_, "Setting language " << language << " for interface " << interface); - last_state_->dictionary[LanguagesKey][key] = language; + last_state_->dictionary()[LanguagesKey][key] = + static_cast(language); return; } @@ -103,10 +104,10 @@ hmi_apis::Common_Language::eType HMILanguageHandler::get_language_for( return Common_Language::INVALID_ENUM; } - if (last_state_->dictionary.isMember(LanguagesKey)) { - if (last_state_->dictionary[LanguagesKey].isMember(key)) { + if (last_state_->dictionary().HasMember(LanguagesKey)) { + if (last_state_->dictionary()[LanguagesKey].HasMember(key)) { Common_Language::eType language = static_cast( - last_state_->dictionary[LanguagesKey][key].asInt()); + last_state_->dictionary()[LanguagesKey][key].AsInt()); return language; } } diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index cd2ebf9d4e2..b1280104162 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -134,7 +134,7 @@ std::pair kVehicleDataInitializer[] = { const VehicleData MessageHelper::vehicle_data_( kVehicleDataInitializer, - kVehicleDataInitializer + ARRAYSIZE(kVehicleDataInitializer)); + kVehicleDataInitializer + GETARRAYSIZE(kVehicleDataInitializer)); #ifdef HMI_DBUS_API namespace { diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 0501ebb5d02..a2d6149bffe 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -300,14 +300,14 @@ bool PolicyHandler::LoadPolicyLibrary() { return NULL; } - policy_library_.Load(kPolicyLibraryName); + policy_library_.Load(kLibrary.c_str()); if (policy_library_.IsLoaded()) { if (CreateManager()) { policy_manager_->set_listener(this); event_observer_ = utils::MakeShared(this); } } else { - LOGGER_ERROR(logger_, error); + LOGGER_ERROR(logger_, "Policy library loading error"); } return policy_manager_.valid(); } diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 32fde813ce7..be62c4bcddf 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -512,7 +512,7 @@ void RequestController::UpdateTimer() { << date_time::DateTime::getmSecs(current_time - end_time) << " Request timeout (sec): " << front->timeout_msec() / - date_time::DateTime::MILLISECONDS_IN_SECOND); + date_time::kMillisecondsInSecond); timer_.Start(0u, true); } } 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 7775ddef048..1797f0de137 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -56,13 +56,15 @@ namespace resumption { CREATE_LOGGERPTR_GLOBAL(logger_, "Resumption") ResumptionDataDB::ResumptionDataDB() - : db_(new utils::dbms::SQLDatabase(kDatabaseName)) { -#ifndef __QNX__ - std::string path = profile::Profile::instance()->app_storage_folder(); - if (!path.empty()) { - db_->set_path(path + "/"); - } -#endif // __QNX__ +#if defined(__QNX__) + : db_(new utils::dbms::SQLDatabase(kDatabaseName) { +#else + : db_(new utils::dbms::SQLDatabase( + file_system::ConcatPath( + profile::Profile::instance()->app_storage_folder(), + kDatabaseName), + "ResumptionDatabase")) { +#endif } ResumptionDataDB::~ResumptionDataDB() { diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index 535a2a40a68..798f14d666a 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -63,7 +63,8 @@ void ResumptionDataJson::SaveApplication( << " policy_app_id : " << policy_app_id); const std::string hash = application->curHash(); const uint32_t grammar_id = application->get_grammar_id(); - const uint32_t time_stamp = (uint32_t)time(NULL); + const utils::json::JsonValue::UInt time_stamp = + static_cast(time(NULL)); const std::string device_mac = application->mac_address(); const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(); @@ -73,13 +74,15 @@ void ResumptionDataJson::SaveApplication( json_app[strings::device_id] = device_mac; json_app[strings::app_id] = policy_app_id; - json_app[strings::grammar_id] = grammar_id; - json_app[strings::connection_key] = application->app_id(); - json_app[strings::hmi_app_id] = application->hmi_app_id(); + json_app[strings::grammar_id] = utils::json::JsonValue::UInt(grammar_id); + json_app[strings::connection_key] = utils::json::JsonValue::UInt( + application->app_id()); + json_app[strings::hmi_app_id] = utils::json::JsonValue::UInt( + application->hmi_app_id()); json_app[strings::is_media_application] = application->IsAudioApplication(); - json_app[strings::hmi_level] = static_cast(hmi_level); - json_app[strings::ign_off_count] = 0; - json_app[strings::suspend_count] = 0; + json_app[strings::hmi_level] = utils::json::JsonValue::Int(hmi_level); + json_app[strings::ign_off_count] = utils::json::JsonValue::UInt(0); + json_app[strings::suspend_count] = utils::json::JsonValue::UInt(0); json_app[strings::hash_id] = hash; Formatters::CFormatterJsonBase::objToJsonValue( GetApplicationCommands(application), tmp); @@ -200,20 +203,22 @@ void ResumptionDataJson::OnSuspend() { ++itr) { if ((*itr).HasMember(strings::suspend_count)) { const uint32_t suspend_count = (*itr)[strings::suspend_count].AsUInt(); - (*itr)[strings::suspend_count] = suspend_count + 1; + (*itr)[strings::suspend_count] = + utils::json::JsonValue::UInt(suspend_count + 1); } else { LOGGER_WARN(logger_, "Unknown key among saved applications"); - (*itr)[strings::suspend_count] = 1; + (*itr)[strings::suspend_count] = utils::json::JsonValue::UInt(1); } if ((*itr).HasMember(strings::ign_off_count)) { const uint32_t ign_off_count = (*itr)[strings::ign_off_count].AsUInt(); const uint32_t application_lifes = 3; // TODO make profile variable if (ign_off_count < application_lifes) { // TODO read from profile - (*itr)[strings::ign_off_count] = ign_off_count + 1; + (*itr)[strings::ign_off_count] = + utils::json::JsonValue::UInt(ign_off_count + 1); } } else { LOGGER_WARN(logger_, "Unknown key among saved applications"); - (*itr)[strings::ign_off_count] = 1; + (*itr)[strings::ign_off_count] = utils::json::JsonValue::UInt(1); } to_save.Append(*itr); } @@ -235,10 +240,12 @@ void ResumptionDataJson::OnAwake() { ++itr) { if ((*itr).HasMember(strings::ign_off_count)) { const uint32_t ign_off_count = (*itr)[strings::ign_off_count].AsUInt(); - (*itr)[strings::ign_off_count] = ign_off_count - 1; + (*itr)[strings::ign_off_count] = + utils::json::JsonValue::UInt(ign_off_count - 1); } else { LOGGER_WARN(logger_, "Unknown key among saved applications"); - (*itr)[strings::ign_off_count] = 0; + (*itr)[strings::ign_off_count] = + utils::json::JsonValue::UInt(0); } } } @@ -275,7 +282,7 @@ bool ResumptionDataJson::GetSavedApplication( LOGGER_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); const int idx = GetObjectIndex(policy_app_id, device_id); - if (-1 == idx) { + if (-1 == idx) { return false; } const JsonValueRef json_saved_app = GetSavedApplications()[idx]; @@ -333,7 +340,8 @@ uint32_t ResumptionDataJson::GetIgnOffTime() const { sync_primitives::AutoLock autolock(resumption_lock_); JsonValueRef resumption = GetResumptionData(); if (!resumption.HasMember(strings::last_ign_off_time)) { - resumption[strings::last_ign_off_time] = 0; + resumption[strings::last_ign_off_time] = + utils::json::JsonValue::UInt(0); LOGGER_WARN(logger_, "last_save_time section is missed"); } return resumption[strings::last_ign_off_time].AsUInt(); @@ -385,9 +393,12 @@ void ResumptionDataJson::GetDataForLoadResumeData( ((*itr).HasMember(strings::app_id)) && ((*itr).HasMember(strings::device_id))) { smart_objects::SmartObject so(smart_objects::SmartType_Map); - so[strings::hmi_level] = (*itr)[strings::hmi_level].AsInt(); - so[strings::ign_off_count] = (*itr)[strings::ign_off_count].AsInt(); - so[strings::time_stamp] = (*itr)[strings::time_stamp].AsUInt(); + so[strings::hmi_level] = + static_cast((*itr)[strings::hmi_level].AsInt()); + so[strings::ign_off_count] = + static_cast((*itr)[strings::ign_off_count].AsInt()); + so[strings::time_stamp] = + static_cast((*itr)[strings::time_stamp].AsUInt()); so[strings::app_id] = (*itr)[strings::app_id].AsString(); so[strings::device_id] = (*itr)[strings::device_id].AsString(); so_array_data[i++] = so; @@ -414,7 +425,8 @@ void ResumptionDataJson::UpdateHmiLevel( << policy_app_id << " device_id = " << device_id); return; } - GetSavedApplications()[idx][strings::hmi_level] = hmi_level; + GetSavedApplications()[idx][strings::hmi_level] = + utils::json::JsonValue::Int(hmi_level); } utils::json::JsonValueRef ResumptionDataJson::GetSavedApplications() const { @@ -440,7 +452,7 @@ utils::json::JsonValueRef ResumptionDataJson::GetResumptionData() const { using namespace utils::json; LOGGER_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); - JsonValue& last_state = last_state().dictionary(); + JsonValue& last_state = last_state_.dictionary(); if (!last_state.HasMember(strings::resumption)) { last_state[strings::resumption] = JsonValue(ValueType::OBJECT_VALUE); LOGGER_WARN(logger_, "resumption section is missed"); @@ -516,7 +528,8 @@ void ResumptionDataJson::SetLastIgnOffTime(time_t ign_off_time) { sync_primitives::AutoLock autolock(resumption_lock_); LOGGER_WARN(logger_, "ign_off_time = " << ign_off_time); utils::json::JsonValueRef resumption = GetResumptionData(); - resumption[strings::last_ign_off_time] = static_cast(ign_off_time); + resumption[strings::last_ign_off_time] = + utils::json::JsonValue::UInt(ign_off_time); } bool ResumptionDataJson::Init() { @@ -530,20 +543,21 @@ bool ResumptionDataJson::DropAppDataResumption(const std::string& device_id, using namespace app_mngr; sync_primitives::AutoLock autolock(resumption_lock_); utils::json::JsonValueRef application = GetFromSavedOrAppend(app_id, device_id); - if (application.isNull()) { + if (application.IsNull()) { LOGGER_DEBUG(logger_, "Application " << app_id << " with device_id " << device_id << " hasn't been found in resumption data."); return false; } - application[strings::application_commands].clear(); - application[strings::application_submenus].clear(); - application[strings::application_choice_sets].clear(); - application[strings::application_global_properties].clear(); - application[strings::application_subscribtions].clear(); - application[strings::application_files].clear(); + application[strings::application_commands].Clear(); + application[strings::application_submenus].Clear(); + application[strings::application_choice_sets].Clear(); + application[strings::application_global_properties].Clear(); + application[strings::application_subscribtions].Clear(); + application[strings::application_files].Clear(); // Seems there is no interface for json wrapper - needs to be created - application.removeMember(strings::grammar_id); + //application.removeMember(strings::grammar_id); + application[strings::grammar_id].Clear(); LOGGER_DEBUG(logger_, "Resumption data for application " << app_id << " with device_id " << device_id diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h index c6ec2f4b1fa..ad16a9445f2 100644 --- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h +++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h @@ -224,7 +224,8 @@ int32_t Formatters::CFormatterJsonSDLRPCv1::fromString( } } else { out[S::S_PARAMS][S::S_CORRELATION_ID] = - root_json[type][S_CORRELATION_ID].AsInt(); + static_cast( + root_json[type][S_CORRELATION_ID].AsInt()); } out[S::S_PARAMS][S::S_PROTOCOL_TYPE] = 0; out[S::S_PARAMS][S::S_PROTOCOL_VERSION] = 1; diff --git a/src/components/formatters/include/formatters/formatter_json_rpc.h b/src/components/formatters/include/formatters/formatter_json_rpc.h index 2062d3ae097..f97586550f0 100644 --- a/src/components/formatters/include/formatters/formatter_json_rpc.h +++ b/src/components/formatters/include/formatters/formatter_json_rpc.h @@ -318,7 +318,8 @@ int32_t FormatterJsonRpc::FromString(const std::string& str, out[strings::S_PARAMS][strings::S_CORRELATION_ID] = id_value.AsString(); } else if (id_value.IsInt()) { - out[strings::S_PARAMS][strings::S_CORRELATION_ID] = id_value.AsInt(); + out[strings::S_PARAMS][strings::S_CORRELATION_ID] = + static_cast(id_value.AsInt()); } else if (id_value.IsDouble()) { out[strings::S_PARAMS][strings::S_CORRELATION_ID] = id_value.AsDouble(); @@ -436,7 +437,8 @@ int32_t FormatterJsonRpc::FromString(const std::string& str, if (!code_value.IsInt()) { result |= kInvalidFormat | kResponseCodeNotAvailable; } else { - out[strings::S_PARAMS][strings::kCode] = code_value.AsInt(); + out[strings::S_PARAMS][strings::kCode] = + static_cast(code_value.AsInt()); } } diff --git a/src/components/policy/src/policy/include/policy/sql_pt_representation.h b/src/components/policy/src/policy/include/policy/sql_pt_representation.h index 2942c206b98..03c54849576 100644 --- a/src/components/policy/src/policy/include/policy/sql_pt_representation.h +++ b/src/components/policy/src/policy/include/policy/sql_pt_representation.h @@ -38,6 +38,7 @@ #include "policy/pt_representation.h" #include "rpc_base/rpc_base.h" #include "types.h" +#include "utils/sql_wrapper.h" namespace policy_table = rpc::policy_table_interface_base; diff --git a/src/components/policy/src/policy/policy_table/table_struct/types.h b/src/components/policy/src/policy/policy_table/table_struct/types.h index 7823e3fa8f8..05649ba4f45 100644 --- a/src/components/policy/src/policy/policy_table/table_struct/types.h +++ b/src/components/policy/src/policy/policy_table/table_struct/types.h @@ -212,7 +212,7 @@ struct ModuleConfig : CompositeType { notifications_per_minute_by_priority); ~ModuleConfig(); explicit ModuleConfig(const utils::json::JsonValueRef& value__); -void SafeCopyFrom(const ModuleConfig& from); + void SafeCopyFrom(const ModuleConfig& from); utils::json::JsonValue ToJsonValue() const; bool is_valid() const; bool is_initialized() const; diff --git a/src/components/policy/src/policy/src/policy_manager_impl.cc b/src/components/policy/src/policy/src/policy_manager_impl.cc index f559abbb0b9..c5fc055fb4d 100644 --- a/src/components/policy/src/policy/src/policy_manager_impl.cc +++ b/src/components/policy/src/policy/src/policy_manager_impl.cc @@ -74,7 +74,7 @@ PolicyManagerImpl::PolicyManagerImpl(const std::string& app_storage_folder, attempts_to_open_policy_db, open_attempt_timeout_ms)) , retry_sequence_timeout_(kDefaultRetryTimeoutInSec) - , retry_sequence_index_(0), + , retry_sequence_index_(0) , timer_retry_sequence_("Retry sequence timer", new timer::TimerTaskImpl( this, &PolicyManagerImpl::RetrySequence)) @@ -97,7 +97,7 @@ utils::SharedPtr PolicyManagerImpl::Parse( return utils::SharedPtr(); } JsonValue& root_json = parse_result.first; - return utils::MakeShared(&value); + return utils::MakeShared(root_json); } #else @@ -764,7 +764,7 @@ uint32_t PolicyManagerImpl::NextRetryTimeout() { next += retry_sequence_timeout_; } // Return miliseconds - return next * date_time::DateTime::MILLISECONDS_IN_SECOND; + return next * date_time::kMillisecondsInSecond; } void PolicyManagerImpl::RefreshRetrySequence() { diff --git a/src/components/policy/src/policy/src/sql_pt_representation.cc b/src/components/policy/src/policy/src/sql_pt_representation.cc index 32c59a8501f..5c6a6d42e51 100644 --- a/src/components/policy/src/policy/src/sql_pt_representation.cc +++ b/src/components/policy/src/policy/src/sql_pt_representation.cc @@ -79,9 +79,8 @@ SQLPTRepresentation::SQLPTRepresentation(const std::string& app_storage_folder, : db_(new utils::dbms::SQLDatabase( file_system::ConcatPath(app_storage_folder, kDatabaseName), "PolicyDatabase")) -#endif { - -} +#endif +{} SQLPTRepresentation::~SQLPTRepresentation() { db_->Close(); diff --git a/src/components/policy/src/policy/usage_statistics/src/counter.cc b/src/components/policy/src/policy/usage_statistics/src/counter.cc index be68d0ef0c9..534ac7b905f 100644 --- a/src/components/policy/src/policy/usage_statistics/src/counter.cc +++ b/src/components/policy/src/policy/usage_statistics/src/counter.cc @@ -103,7 +103,7 @@ AppStopwatchImpl::AppStopwatchImpl( void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) { stopwatch_type_ = stopwatch_type; - timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND, false); + timer_.Start(time_out_ * date_time::kMillisecondsInSecond, false); } void AppStopwatchImpl::Switch(AppStopwatchId stopwatch_type) { diff --git a/src/components/policy/test/CMakeLists.txt b/src/components/policy/test/CMakeLists.txt index 084ba94351f..f1c083c75e3 100644 --- a/src/components/policy/test/CMakeLists.txt +++ b/src/components/policy/test/CMakeLists.txt @@ -73,7 +73,7 @@ file(COPY PTU3.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY PTU4.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY ptu_requestType.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY ptu2_requestType.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -file(COPY logger.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY log4cxx.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY smartDeviceLink.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY smartDeviceLink2.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY smartDeviceLink3.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/components/rpc_base/include/rpc_base/rpc_base.h b/src/components/rpc_base/include/rpc_base/rpc_base.h index 68430ba535e..4c2554907b4 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base.h @@ -488,6 +488,7 @@ class Optional { const T& operator*() const; T* operator->(); const T* operator->() const; + void assign_if_valid(const Optional& value); // For pointer-like 'if (optional_value)' tests // Better than operator bool because bool can be implicitly // casted to integral types diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h index 25dbf9c26a8..412923d3b0c 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h @@ -567,6 +567,13 @@ const T* Optional::operator->() const { return &value_; } +template +void Optional::assign_if_valid(const Optional& value) { + if (value.is_initialized()) { + value_ = value.value_; + } +} + template Optional::operator const void*() const { return is_initialized() ? &value_ : NULL;