diff options
Diffstat (limited to 'src/components/application_manager')
32 files changed, 1092 insertions, 1061 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 0be02d0101..66b6f38791 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -58,6 +58,9 @@ namespace application_manager { namespace mobile_api = mobile_apis; namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; + +namespace custom_str = utils::custom_string; + typedef int32_t ErrorCode; class UsageStatistics; @@ -452,7 +455,7 @@ class Application : public virtual InitialApplicationData, virtual void set_hmi_application_id(uint32_t hmi_app_id) = 0; virtual uint32_t hmi_app_id() const = 0; virtual uint32_t app_id() const = 0; - virtual const std::string& name() const = 0; + virtual const custom_str::CustomString& name() const = 0; /** * @brief Sets application folder name, which is used for storing of related * files, e.g. icons @@ -500,7 +503,7 @@ class Application : public virtual InitialApplicationData, */ virtual bool tts_properties_in_full() = 0; virtual void set_version(const Version& version) = 0; - virtual void set_name(const std::string& name) = 0; + virtual void set_name(const custom_str::CustomString& name) = 0; virtual void set_is_media_application(bool is_media) = 0; virtual void increment_put_file_in_none_count() = 0; virtual void increment_delete_file_in_none_count() = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index fdb4bdad1e..d63b429c09 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -49,6 +49,7 @@ #include "utils/timer_thread.h" #include "utils/lock.h" #include "utils/atomic_object.h" +#include "utils/custom_string.h" namespace usage_statistics { @@ -60,6 +61,7 @@ using namespace utils; using namespace timer; namespace mobile_api = mobile_apis; +namespace custom_str = custom_string; class ApplicationImpl : public virtual InitialApplicationDataImpl, public virtual DynamicApplicationDataImpl { @@ -67,7 +69,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, ApplicationImpl( uint32_t application_id, const std::string& mobile_app_id, - const std::string& app_name, + const custom_str::CustomString& app_name, utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager); ~ApplicationImpl(); @@ -118,7 +120,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void set_hmi_application_id(uint32_t hmi_app_id); inline uint32_t hmi_app_id() const; inline uint32_t app_id() const; - const std::string& name() const; + const custom_str::CustomString& name() const; void set_folder_name(const std::string& folder_name) OVERRIDE; const std::string folder_name() const; bool is_media_application() const; @@ -138,7 +140,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void set_tts_properties_in_full(bool active); bool tts_properties_in_full(); void set_version(const Version& ver); - void set_name(const std::string& name); + void set_name(const custom_str::CustomString& name); void set_is_media_application(bool is_media); void increment_put_file_in_none_count(); void increment_delete_file_in_none_count(); @@ -303,7 +305,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, uint32_t grammar_id_; Version version_; - std::string app_name_; + custom_str::CustomString app_name_; uint32_t hmi_app_id_; uint32_t app_id_; smart_objects::SmartObject* active_message_; diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index b79c022a20..a2acb4a3d3 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -102,6 +102,7 @@ namespace application_manager { namespace mobile_api = mobile_apis; using namespace utils; using namespace timer; +namespace custom_str = custom_string; class ApplicationManagerImpl; diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index 0401a3bf46..164871e1af 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -50,19 +50,14 @@ namespace commands { namespace NsSmart = NsSmartDeviceLink::NsSmartObjects; class CommandRequestImpl : public CommandImpl, - public event_engine::EventObserver { + public event_engine::EventObserver { public: - - enum RequestState { - kAwaitingHMIResponse = 0, - kTimedOut, - kCompleted - }; + enum RequestState { kAwaitingHMIResponse = 0, kTimedOut, kCompleted }; explicit CommandRequestImpl(const MessageSharedPtr& message); virtual ~CommandRequestImpl(); virtual bool CheckPermissions(); - virtual bool Init(); + virtual bool Init(); virtual bool CleanUp(); virtual void Run(); @@ -99,7 +94,7 @@ class CommandRequestImpl : public CommandImpl, * @param allow_empty_string if true methods allow empty sting * @return true if success otherwise return false */ - bool CheckSyntax(std::string str, bool allow_empty_line = false); + bool CheckSyntax(const std::string& str, bool allow_empty_line = false); /* * @brief Sends HMI request @@ -110,8 +105,8 @@ class CommandRequestImpl : public CommandImpl, * @return hmi correlation id */ uint32_t SendHMIRequest(const hmi_apis::FunctionID::eType& function_id, - const smart_objects::SmartObject* msg_params = NULL, - bool use_events = false); + const smart_objects::SmartObject* msg_params = NULL, + bool use_events = false); /* * @brief Creates HMI request @@ -131,8 +126,7 @@ class CommandRequestImpl : public CommandImpl, mobile_apis::Result::eType GetMobileResultCode( const hmi_apis::Common_Result::eType& hmi_code) const; -protected: - + protected: /** * @brief Checks message permissions and parameters according to policy table * permissions @@ -161,14 +155,13 @@ protected: bool HasDisallowedParams() const; protected: - RequestState current_state_; - sync_primitives::Lock state_lock_; - CommandParametersPermissions parameters_permissions_; + RequestState current_state_; + sync_primitives::Lock state_lock_; + CommandParametersPermissions parameters_permissions_; private: DISALLOW_COPY_AND_ASSIGN(CommandRequestImpl); - /** * @brief Adds param to disallowed parameters enumeration * @param info string with disallowed params enumeration @@ -181,7 +174,8 @@ protected: * @brief Adds disallowed parameters to response info * @param response Response message, which info should be extended */ - void AddDisallowedParametersToInfo(smart_objects::SmartObject& response) const; + void AddDisallowedParametersToInfo( + smart_objects::SmartObject& response) const; }; } // namespace commands diff --git a/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h b/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h index b8ac0e7831..5e12b1f08d 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h @@ -39,15 +39,18 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/pending.h" #include "utils/macro.h" +#include "utils/custom_string.h" namespace application_manager { namespace commands { +namespace custom_str = utils::custom_string; + /** * @brief ChangeRegistrationRequest command class **/ -class ChangeRegistrationRequest : public CommandRequestImpl { +class ChangeRegistrationRequest : public CommandRequestImpl { public: /** * @brief ChangeRegistrationRequest class constructor @@ -107,9 +110,9 @@ class ChangeRegistrationRequest : public CommandRequestImpl { * * @return true if all of result codes is success */ - bool AllHmiResponsesSuccess(const hmi_apis::Common_Result::eType ui, - const hmi_apis::Common_Result::eType vr, - const hmi_apis::Common_Result::eType tts); + bool AllHmiResponsesSuccess(const hmi_apis::Common_Result::eType ui, + const hmi_apis::Common_Result::eType vr, + const hmi_apis::Common_Result::eType tts); /** * @brief Checks change_registration params(ttsName, appname, @@ -118,49 +121,49 @@ class ChangeRegistrationRequest : public CommandRequestImpl { * @return true if command contains \t\n \\t \\n of whitespace otherwise * returns false. */ - bool IsWhiteSpaceExist(); - - /** - * @brief Check parameters (name, vr) for - * coincidence with already known parameters of registered applications - * - * @return SUCCESS if there is no coincidence of app.name/VR synonyms, - * otherwise appropriate error code returns - */ - mobile_apis::Result::eType CheckCoincidence(); - - /** - * @brief Checks if requested name is allowed by policy - * @param app_name Application name - * @return true, if allowed, otherwise - false - */ - bool IsNicknameAllowed(const std::string& app_name) const; - - /** - * @brief Predicate for using with CheckCoincidence method to compare with VR synonym SO - * - * @return TRUE if there is coincidence of VR, otherwise FALSE - */ - struct CoincidencePredicateVR { - explicit CoincidencePredicateVR(const std::string &newItem) - :newItem_(newItem) - {}; - - bool operator()(smart_objects::SmartObject obj) { - const std::string vr_synonym = obj.asString(); - return !(strcasecmp(vr_synonym.c_str(), newItem_.c_str())); - }; - - const std::string &newItem_; - }; - - Pending pending_requests_; - - hmi_apis::Common_Result::eType ui_result_; - hmi_apis::Common_Result::eType vr_result_; - hmi_apis::Common_Result::eType tts_result_; - - DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationRequest); + bool IsWhiteSpaceExist(); + + /** + * @brief Check parameters (name, vr) for + * coincidence with already known parameters of registered applications + * + * @return SUCCESS if there is no coincidence of app.name/VR synonyms, + * otherwise appropriate error code returns + */ + mobile_apis::Result::eType CheckCoincidence(); + + /** + * @brief Checks if requested name is allowed by policy + * @param app_name Application name + * @return true, if allowed, otherwise - false + */ + bool IsNicknameAllowed(const custom_str::CustomString& app_name) const; + + /** + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO + * + * @return TRUE if there is coincidence of VR, otherwise FALSE + */ + struct CoincidencePredicateVR { + explicit CoincidencePredicateVR(const custom_str::CustomString& newItem) + : newItem_(newItem){}; + + bool operator()(const smart_objects::SmartObject& obj) const { + const custom_str::CustomString& vr_synonym = obj.asCustomString(); + return newItem_.CompareIgnoreCase(vr_synonym); + }; + + const custom_str::CustomString& newItem_; + }; + + Pending pending_requests_; + + hmi_apis::Common_Result::eType ui_result_; + hmi_apis::Common_Result::eType vr_result_; + hmi_apis::Common_Result::eType tts_result_; + + DISALLOW_COPY_AND_ASSIGN(ChangeRegistrationRequest); }; } // namespace commands diff --git a/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h b/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h index df1b5a70d9..5d1ee428cc 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h @@ -37,6 +37,7 @@ #include <string.h> #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "utils/custom_string.h" namespace policy { struct DeviceInfo; @@ -48,6 +49,8 @@ class Application; namespace commands { +namespace custom_str = utils::custom_string; + /** * @brief Register app interface request command class **/ @@ -99,22 +102,21 @@ class RegisterAppInterfaceRequest : public CommandRequestImpl { mobile_apis::Result::eType CheckCoincidence(); /* - * @brief Predicate for using with CheckCoincidence method to compare with VR synonym SO + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO * * return TRUE if there is coincidence of VR, otherwise FALSE */ struct CoincidencePredicateVR { - explicit CoincidencePredicateVR(const std::string &newItem) - :newItem_(newItem) - {}; - - bool operator()(smart_objects::SmartObject obj) { - const std::string vr_synonym = obj.asString(); - return !(strcasecmp(vr_synonym.c_str(), newItem_.c_str())); - }; + explicit CoincidencePredicateVR(const custom_str::CustomString& newItem) + : newItem_(newItem){}; - const std::string &newItem_; + bool operator()(const smart_objects::SmartObject& obj) { + const custom_str::CustomString& vr_synonym = obj.asCustomString(); + return newItem_.CompareIgnoreCase(vr_synonym); }; + const custom_str::CustomString& newItem_; + }; /** * @brief Check request parameters against policy table data @@ -152,11 +154,10 @@ class RegisterAppInterfaceRequest : public CommandRequestImpl { */ void SendSubscribeCustomButtonNotification(); -private: + private: std::string response_info_; mobile_apis::Result::eType result_checking_app_hmi_type_; - DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceRequest); }; 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 a7f3349638..deda63c0ae 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 @@ -46,6 +46,7 @@ #include "utils/threads/thread_delegate.h" #include "utils/conditional_variable.h" #include "utils/rwlock.h" +#include "utils/custom_string.h" #include "usage_statistics/statistics_manager.h" #include "application_manager/policies/policy_handler_observer.h" #include "utils/threads/async_runner.h" @@ -58,11 +59,13 @@ class Value; namespace policy { typedef std::vector<uint32_t> AppIds; typedef std::vector<uint32_t> DeviceHandles; +namespace custom_str = utils::custom_string; -class PolicyHandler : - public utils::Singleton<PolicyHandler, utils::deleters::Deleter<PolicyHandler> >, - public PolicyListener, - public threads::AsyncRunner { +class PolicyHandler + : public utils::Singleton<PolicyHandler, + utils::deleters::Deleter<PolicyHandler> >, + public PolicyListener, + public threads::AsyncRunner { public: virtual ~PolicyHandler(); bool LoadPolicyLibrary(); @@ -87,18 +90,18 @@ class PolicyHandler : bool GetPriority(const std::string& policy_app_id, std::string* priority); void CheckPermissions(const PTString& app_id, - const PTString& hmi_level, - const PTString& rpc, - const RPCParams& rpc_params, - CheckPermissionResult& result); + const PTString& hmi_level, + const PTString& rpc, + const RPCParams& rpc_params, + CheckPermissionResult& result); uint32_t GetNotificationsNumber(const std::string& priority); DeviceConsent GetUserConsentForDevice(const std::string& device_id); bool GetDefaultHmi(const std::string& policy_app_id, - std::string* default_hmi); + std::string* default_hmi); bool GetInitialAppData(const std::string& application_id, - StringArray* nicknames = NULL, - StringArray* app_hmi_types = NULL); + StringArray* nicknames = NULL, + StringArray* app_hmi_types = NULL); void GetServiceUrls(const std::string& service_type, EndpointUrls& end_points); @@ -163,7 +166,8 @@ class PolicyHandler : * @param device_id Device mac address * @param connection_type Device connection type */ - void AddDevice(const std::string& device_id, const std::string& connection_type); + void AddDevice(const std::string& device_id, + const std::string& connection_type); /** * @brief Save device info for specific device to policy table @@ -179,7 +183,7 @@ class PolicyHandler : * @param permissions User-changed group permissions consent */ void OnAppPermissionConsent(const uint32_t connection_key, - const PermissionConsent &permissions); + const PermissionConsent& permissions); /** * @brief Get appropriate message parameters and send them with response @@ -219,7 +223,7 @@ class PolicyHandler : * application * @param policy_app_id Application id */ - std::string OnCurrentDeviceIdUpdateRequired(const std::string& policy_app_id); + std::string OnCurrentDeviceIdUpdateRequired(const std::string& policy_app_id); /** * @brief Set parameters from OnSystemInfoChanged to policy table @@ -277,9 +281,10 @@ class PolicyHandler : */ uint32_t GetAppIdForSending(); - std::string GetAppName(const std::string& policy_app_id); + custom_str::CustomString GetAppName(const std::string& policy_app_id); - virtual void OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types); + virtual void OnUpdateHMIAppType( + std::map<std::string, StringArray> app_hmi_types); virtual void OnCertificateUpdated(const std::string& certificate_data); @@ -366,7 +371,7 @@ class PolicyHandler : */ void OnAppRegisteredOnMobile(const std::string& application_id); -//TODO(AKutsan) REMOVE THIS UGLY HOTFIX + // TODO(AKutsan) REMOVE THIS UGLY HOTFIX virtual void Increment(usage_statistics::GlobalCounterId type); virtual void Increment(const std::string& app_id, usage_statistics::AppCounterId type); @@ -381,25 +386,24 @@ class PolicyHandler : void SetPolicyManager(utils::SharedPtr<PolicyManager> pm) { policy_manager_ = pm; } -#endif // BUILD_TESTS +#endif // BUILD_TESTS #ifdef ENABLE_SECURITY std::string RetrieveCertificate() const; -#endif // ENABLE_SECURITY - -protected: +#endif // ENABLE_SECURITY + protected: /** * Starts next retry exchange policy table */ void StartNextRetry(); private: - /** * Checks system action of application for permission of keep context * @param system_action system action (see mobile api) * @param policy_app_id unique application id - * @return false if system_action is KEEP_CONTEXT and it isn't allowed by policy + * @return false if system_action is KEEP_CONTEXT and it isn't allowed by + * policy * otherwise true */ bool CheckKeepContext(const std::string& policy_app_id); @@ -408,7 +412,8 @@ protected: * Checks system action of application for permission of steal focus * @param system_action system action (see mobile api) * @param policy_app_id unique application id - * @return false if system_action is STEAL_FOCUS and it isn't allowed by policy + * @return false if system_action is STEAL_FOCUS and it isn't allowed by + * policy * otherwise true */ bool CheckStealFocus(const std::string& policy_app_id); @@ -428,40 +433,33 @@ protected: */ void SetDaysAfterEpoch(); -private: - class StatisticManagerImpl: public usage_statistics::StatisticsManager { - //TODO(AKutsan) REMOVE THIS UGLY HOTFIX - virtual void Increment(usage_statistics::GlobalCounterId type) { - - PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(type)); - } - - virtual void Increment(const std::string& app_id, - usage_statistics::AppCounterId type) { - - PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(app_id, - type)); - } - - virtual void Set(const std::string& app_id, - usage_statistics::AppInfoId type, - const std::string& value) { - - PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(app_id, - type, - value)); - } - - virtual void Add(const std::string& app_id, - usage_statistics::AppStopwatchId type, - int32_t timespan_seconds) { - - PolicyHandler::instance()->AsyncRun(new StatisticsDelegate( - app_id, type, timespan_seconds)); - } + private: + class StatisticManagerImpl : public usage_statistics::StatisticsManager { + // TODO(AKutsan) REMOVE THIS UGLY HOTFIX + virtual void Increment(usage_statistics::GlobalCounterId type) { + PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(type)); + } + + virtual void Increment(const std::string& app_id, + usage_statistics::AppCounterId type) { + PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(app_id, type)); + } + + virtual void Set(const std::string& app_id, + usage_statistics::AppInfoId type, + const std::string& value) { + PolicyHandler::instance()->AsyncRun( + new StatisticsDelegate(app_id, type, value)); + } + + virtual void Add(const std::string& app_id, + usage_statistics::AppStopwatchId type, + int32_t timespan_seconds) { + PolicyHandler::instance()->AsyncRun( + new StatisticsDelegate(app_id, type, timespan_seconds)); + } }; - //TODO(AKutsan) REMOVE THIS UGLY HOTFIX - + // TODO(AKutsan) REMOVE THIS UGLY HOTFIX PolicyHandler(); bool SaveSnapshot(const BinaryMessage& pt_string, std::string& snap_path); @@ -481,7 +479,7 @@ private: inline bool CreateManager(); - typedef std::list <PolicyHandlerObserver*> HandlersCollection; + typedef std::list<PolicyHandlerObserver*> HandlersCollection; HandlersCollection listeners_; sync_primitives::Lock listeners_lock_; @@ -499,8 +497,8 @@ private: friend class AppPermissionDelegate; DISALLOW_COPY_AND_ASSIGN(PolicyHandler); - FRIEND_BASE_SINGLETON_CLASS_WITH_DELETER(PolicyHandler, - utils::deleters::Deleter<PolicyHandler>); + FRIEND_BASE_SINGLETON_CLASS_WITH_DELETER( + PolicyHandler, utils::deleters::Deleter<PolicyHandler>); FRIEND_DELETER_DESTRUCTOR(PolicyHandler); }; diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index d908f485a1..c2ad548be1 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -75,7 +75,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") ApplicationImpl::ApplicationImpl( uint32_t application_id, const std::string& mobile_app_id, - const std::string& app_name, + const custom_str::CustomString& app_name, utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager) : grammar_id_(0) , hmi_app_id_(0) @@ -264,7 +264,7 @@ void ApplicationImpl::set_hmi_application_id(uint32_t hmi_app_id) { hmi_app_id_ = hmi_app_id; } -const std::string& ApplicationImpl::name() const { +const custom_str::CustomString& ApplicationImpl::name() const { return app_name_; } @@ -326,7 +326,7 @@ void ApplicationImpl::set_version(const Version& ver) { version_ = ver; } -void ApplicationImpl::set_name(const std::string& name) { +void ApplicationImpl::set_name(const custom_str::CustomString& name) { app_name_ = name; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index f3d99a072f..2e8a743ff5 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Ford Motor Company + * Copyright (c) 2016, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -437,8 +437,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( smart_objects::SmartObject& params = message[strings::msg_params]; const std::string& policy_app_id = params[strings::app_id].asString(); - const std::string& app_name = - message[strings::msg_params][strings::app_name].asString(); + const custom_str::CustomString& app_name = + message[strings::msg_params][strings::app_name].asCustomString(); LOG4CXX_DEBUG(logger_, "App with connection key: " << connection_key @@ -1265,7 +1265,8 @@ ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const { ApplicationConstSharedPtr app = application(key); security_manager::SSLContext::HandshakeContext res; DCHECK_OR_RETURN(app.valid(), res); - return res.make_context(app->mobile_app_id(), app->name()); + return res.make_context(custom_str::CustomString(app->mobile_app_id()), + app->name()); } #endif // ENABLE_SECURITY @@ -2133,7 +2134,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, SmartObject vrSynonym; SmartObject ttsName; - const std::string appName(app_data[json::name].asString()); + const custom_str::CustomString appName(app_data[json::name].asCustomString()); if (app_data.keyExists(json::ios)) { os_type = json::ios; @@ -2415,7 +2416,7 @@ void ApplicationManagerImpl::RemoveAppsWaitingForRegistration( while (apps_to_register_.end() != it_app) { LOG4CXX_DEBUG(logger_, - "Waiting app: " << (*it_app)->name() << " is removed."); + "Waiting app: " << (*it_app)->name().c_str() << " is removed."); apps_to_register_.erase(it_app); it_app = std::find_if( apps_to_register_.begin(), apps_to_register_.end(), device_finder); diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index e9fb7ecd7d..b83b646385 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -172,7 +172,8 @@ void CommandRequestImpl::SendResponse( ApplicationManagerImpl::instance()->ManageMobileCommand(result); } -bool CommandRequestImpl::CheckSyntax(std::string str, bool allow_empty_line) { +bool CommandRequestImpl::CheckSyntax(const std::string& str, + bool allow_empty_line) { if (std::string::npos != str.find_first_of("\t\n")) { LOG4CXX_ERROR(logger_, "CheckSyntax failed! :" << str); return false; diff --git a/src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc b/src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc index c1224eff09..6bb010ed78 100644 --- a/src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc @@ -39,11 +39,9 @@ namespace commands { OnAllowSDLFunctionalityNotification::OnAllowSDLFunctionalityNotification( const MessageSharedPtr& message) - : NotificationFromHMI(message) { -} + : NotificationFromHMI(message) {} -OnAllowSDLFunctionalityNotification::~OnAllowSDLFunctionalityNotification() { -} +OnAllowSDLFunctionalityNotification::~OnAllowSDLFunctionalityNotification() {} void OnAllowSDLFunctionalityNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -59,4 +57,3 @@ void OnAllowSDLFunctionalityNotification::Run() { } // namespace commands } // namespace application_manager - diff --git a/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc index 69a18200fa..3e39e2c44e 100644 --- a/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc @@ -40,12 +40,11 @@ namespace application_manager { namespace commands { -OnAppPermissionConsentNotification::OnAppPermissionConsentNotification(const MessageSharedPtr& message) - : NotificationFromHMI(message) { -} +OnAppPermissionConsentNotification::OnAppPermissionConsentNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) {} -OnAppPermissionConsentNotification::~OnAppPermissionConsentNotification() { -} +OnAppPermissionConsentNotification::~OnAppPermissionConsentNotification() {} void OnAppPermissionConsentNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -62,28 +61,29 @@ void OnAppPermissionConsentNotification::Run() { if (msg_params.keyExists("consentedFunctions")) { smart_objects::SmartArray* user_consent = - msg_params["consentedFunctions"].asArray(); - - smart_objects::SmartArray::const_iterator it = user_consent->begin(); - smart_objects::SmartArray::const_iterator it_end = user_consent->end(); - for (; it != it_end; ++it) { - policy::FunctionalGroupPermission permissions; - permissions.group_id = (*it)["id"].asInt(); - permissions.group_alias = (*it)["name"].asString(); - if ((*it).keyExists("allowed")) { - permissions.state = (*it)["allowed"].asBool() ? policy::kGroupAllowed : - policy::kGroupDisallowed; - } else { - permissions.state = policy::kGroupUndefined; - } + msg_params["consentedFunctions"].asArray(); + + smart_objects::SmartArray::const_iterator it = user_consent->begin(); + smart_objects::SmartArray::const_iterator it_end = user_consent->end(); + for (; it != it_end; ++it) { + policy::FunctionalGroupPermission permissions; + permissions.group_id = (*it)["id"].asInt(); + permissions.group_alias = (*it)["name"].asString(); + if ((*it).keyExists("allowed")) { + permissions.state = (*it)["allowed"].asBool() + ? policy::kGroupAllowed + : policy::kGroupDisallowed; + } else { + permissions.state = policy::kGroupUndefined; + } permission_consent.group_permissions.push_back(permissions); } permission_consent.consent_source = msg_params["source"].asString(); - policy::PolicyHandler::instance()->OnAppPermissionConsent(connection_key, - permission_consent); + policy::PolicyHandler::instance()->OnAppPermissionConsent( + connection_key, permission_consent); } } diff --git a/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc index 441538bee2..fbd866927b 100644 --- a/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc @@ -38,11 +38,10 @@ namespace application_manager { namespace commands { OnDeviceChosenNotification::OnDeviceChosenNotification( - const MessageSharedPtr& message) : NotificationFromHMI(message) { -} + const MessageSharedPtr& message) + : NotificationFromHMI(message) {} -OnDeviceChosenNotification::~OnDeviceChosenNotification() { -} +OnDeviceChosenNotification::~OnDeviceChosenNotification() {} void OnDeviceChosenNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -57,4 +56,3 @@ void OnDeviceChosenNotification::Run() { } // namespace commands } // namespace application_manager - diff --git a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc index b41eb6b861..a1d8d753e7 100644 --- a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc @@ -38,38 +38,40 @@ #include "encryption/hashing.h" namespace { - // TODO(AOleynik) : replace this !!! - void check_zero(const char& a, const char& b, std::string& bt_mac) { - if ('0' != a && '0' == b) { - bt_mac.push_back(a); - bt_mac.push_back(b); - } else if ('0' == a) { - bt_mac.push_back(b); - } else { - bt_mac.push_back(a); - bt_mac.push_back(b); - } - } - - std::string convert_to_bt_mac(std::string& deviceInternalId) { - std::transform(deviceInternalId.begin(), deviceInternalId.end(),deviceInternalId.begin(), ::tolower); +// TODO(AOleynik) : replace this !!! +void check_zero(const char& a, const char& b, std::string& bt_mac) { + if ('0' != a && '0' == b) { + bt_mac.push_back(a); + bt_mac.push_back(b); + } else if ('0' == a) { + bt_mac.push_back(b); + } else { + bt_mac.push_back(a); + bt_mac.push_back(b); + } +} - std::string bt_mac; - check_zero(deviceInternalId[10], deviceInternalId[11], bt_mac); - bt_mac.push_back(':'); - check_zero(deviceInternalId[8], deviceInternalId[9], bt_mac); - bt_mac.push_back(':'); - check_zero(deviceInternalId[6], deviceInternalId[7], bt_mac); - bt_mac.push_back(':'); - check_zero(deviceInternalId[4], deviceInternalId[5], bt_mac); - bt_mac.push_back(':'); - check_zero(deviceInternalId[2], deviceInternalId[3], bt_mac); - bt_mac.push_back(':'); - check_zero(deviceInternalId[0], deviceInternalId[1], bt_mac); +std::string convert_to_bt_mac(std::string& deviceInternalId) { + std::transform(deviceInternalId.begin(), + deviceInternalId.end(), + deviceInternalId.begin(), + ::tolower); - return bt_mac; - } + std::string bt_mac; + check_zero(deviceInternalId[10], deviceInternalId[11], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[8], deviceInternalId[9], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[6], deviceInternalId[7], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[4], deviceInternalId[5], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[2], deviceInternalId[3], bt_mac); + bt_mac.push_back(':'); + check_zero(deviceInternalId[0], deviceInternalId[1], bt_mac); + return bt_mac; +} } namespace application_manager { @@ -77,33 +79,32 @@ namespace application_manager { namespace commands { OnDeviceStateChangedNotification::OnDeviceStateChangedNotification( - const MessageSharedPtr& message) - : NotificationFromHMI(message) { -} + const MessageSharedPtr& message) + : NotificationFromHMI(message) {} -OnDeviceStateChangedNotification::~OnDeviceStateChangedNotification() { -} +OnDeviceStateChangedNotification::~OnDeviceStateChangedNotification() {} void OnDeviceStateChangedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - if ((*message_)[strings::msg_params]["deviceState"] - == hmi_apis::Common_DeviceState::UNPAIRED) { - // It is expected, that "deviceInternalId" is the device MAC address in - // form XXXXXXXXXX - std::string device_id = (*message_)[strings::msg_params]["deviceInternalId"] - .asString(); + if ((*message_)[strings::msg_params]["deviceState"] == + hmi_apis::Common_DeviceState::UNPAIRED) { + // It is expected, that "deviceInternalId" is the device MAC address in + // form XXXXXXXXXX + std::string device_id = + (*message_)[strings::msg_params]["deviceInternalId"].asString(); if (device_id.empty()) { if ((*message_)[strings::msg_params].keyExists("deviceId")) { - device_id = (*message_)[strings::msg_params]["deviceId"]["id"].asString(); + device_id = + (*message_)[strings::msg_params]["deviceId"]["id"].asString(); } } else { - // Policy uses hashed MAC address as device_id - LOG4CXX_DEBUG(logger_,"Device_id from HMI: " << device_id); - std::string bt_mac = convert_to_bt_mac(device_id); - LOG4CXX_DEBUG(logger_,"Device_id as BT MAC: " << bt_mac); - device_id = encryption::MakeHash(bt_mac); - LOG4CXX_DEBUG(logger_,"Device_id hashed as BT MAC : " << device_id); + // Policy uses hashed MAC address as device_id + LOG4CXX_DEBUG(logger_, "Device_id from HMI: " << device_id); + std::string bt_mac = convert_to_bt_mac(device_id); + LOG4CXX_DEBUG(logger_, "Device_id as BT MAC: " << bt_mac); + device_id = encryption::MakeHash(bt_mac); + LOG4CXX_DEBUG(logger_, "Device_id hashed as BT MAC : " << device_id); } policy::PolicyHandler::instance()->RemoveDevice(device_id); } diff --git a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc index a5ea29c6d2..df620effb0 100644 --- a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc +++ b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc @@ -40,22 +40,21 @@ namespace application_manager { namespace commands { OnReceivedPolicyUpdate::OnReceivedPolicyUpdate(const MessageSharedPtr& message) - : NotificationFromHMI(message) { -} + : NotificationFromHMI(message) {} -OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() { -} +OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() {} void OnReceivedPolicyUpdate::Run() { LOG4CXX_AUTO_TRACE(logger_); const std::string& file_path = - (*message_)[strings::msg_params][hmi_notification::policyfile].asString(); + (*message_)[strings::msg_params][hmi_notification::policyfile].asString(); policy::BinaryMessage file_content; if (!file_system::ReadBinaryFile(file_path, file_content)) { LOG4CXX_ERROR(logger_, "Failed to read Update file."); return; } - policy::PolicyHandler::instance()->ReceiveMessageFromSDK(file_path, file_content); + policy::PolicyHandler::instance()->ReceiveMessageFromSDK(file_path, + file_content); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc index 666304bfe5..9079f34488 100644 --- a/src/components/application_manager/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc @@ -38,23 +38,24 @@ #include "application_manager/message_helper.h" #include "utils/file_system.h" #include "utils/helpers.h" +#include "utils/custom_string.h" namespace application_manager { namespace commands { +namespace custom_str = utils::custom_string; + AddCommandRequest::AddCommandRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message), - send_ui_(false), - send_vr_(false), - is_ui_received_(false), - is_vr_received_(false), - ui_result_(hmi_apis::Common_Result::INVALID_ENUM), - vr_result_(hmi_apis::Common_Result::INVALID_ENUM) { -} + : CommandRequestImpl(message) + , send_ui_(false) + , send_vr_(false) + , is_ui_received_(false) + , is_vr_received_(false) + , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) + , vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {} -AddCommandRequest::~AddCommandRequest() { -} +AddCommandRequest::~AddCommandRequest() {} void AddCommandRequest::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); @@ -75,14 +76,12 @@ void AddCommandRequest::Run() { } if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImage((*message_)[strings::msg_params] - [strings::cmd_icon], app); + mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::cmd_icon], app); if (mobile_apis::Result::SUCCESS != verification_result) { LOG4CXX_ERROR( - logger_, - "MessageHelper::VerifyImage return " << verification_result); + logger_, "MessageHelper::VerifyImage return " << verification_result); SendResponse(false, verification_result); return; } @@ -95,13 +94,13 @@ void AddCommandRequest::Run() { } if (app->FindCommand( - (*message_)[strings::msg_params][strings::cmd_id].asUInt())) { + (*message_)[strings::msg_params][strings::cmd_id].asUInt())) { LOG4CXX_ERROR(logger_, "INVALID_ID"); SendResponse(false, mobile_apis::Result::INVALID_ID); return; } - bool data_exist = false; + bool data_exist = false; if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { if (!CheckCommandName(app)) { @@ -109,21 +108,22 @@ void AddCommandRequest::Run() { return; } if (((*message_)[strings::msg_params][strings::menu_params].keyExists( - hmi_request::parent_id)) && (0 != (*message_)[strings::msg_params] - [strings::menu_params][hmi_request::parent_id].asUInt())) { + hmi_request::parent_id)) && + (0 != + (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id] + .asUInt())) { if (!CheckCommandParentId(app)) { - SendResponse(false, mobile_apis::Result::INVALID_ID, - "Parent ID doesn't exist"); + SendResponse( + false, mobile_apis::Result::INVALID_ID, "Parent ID doesn't exist"); return; } } data_exist = true; } - if (((*message_)[strings::msg_params].keyExists(strings::vr_commands)) - && ((*message_)[strings::msg_params] - [strings::vr_commands].length() > 0)) { - + if (((*message_)[strings::msg_params].keyExists(strings::vr_commands)) && + ((*message_)[strings::msg_params][strings::vr_commands].length() > 0)) { if (!CheckCommandVRSynonym(app)) { SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); return; @@ -139,18 +139,16 @@ void AddCommandRequest::Run() { } if (IsWhiteSpaceExist()) { - LOG4CXX_ERROR(logger_, - "Incoming add command has contains \t\n \\t \\n"); + LOG4CXX_ERROR(logger_, "Incoming add command has contains \t\n \\t \\n"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } - app->AddCommand((*message_)[strings::msg_params] - [strings::cmd_id].asUInt(), - (*message_)[strings::msg_params]); + app->AddCommand((*message_)[strings::msg_params][strings::cmd_id].asUInt(), + (*message_)[strings::msg_params]); - smart_objects::SmartObject ui_msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject ui_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { ui_msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; @@ -159,10 +157,11 @@ void AddCommandRequest::Run() { ui_msg_params[strings::app_id] = app->app_id(); - if ( ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) - && ((*message_)[strings::msg_params][strings::cmd_icon].keyExists(strings::value)) - && (0 < (*message_)[strings::msg_params][strings::cmd_icon] - [strings::value].length())) { + if (((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) && + ((*message_)[strings::msg_params][strings::cmd_icon].keyExists( + strings::value)) && + (0 < (*message_)[strings::msg_params][strings::cmd_icon][strings::value] + .length())) { ui_msg_params[strings::cmd_icon] = (*message_)[strings::msg_params][strings::cmd_icon]; } @@ -170,8 +169,8 @@ void AddCommandRequest::Run() { send_ui_ = true; } - smart_objects::SmartObject vr_msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject vr_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); if ((*message_)[strings::msg_params].keyExists(strings::vr_commands)) { vr_msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; @@ -204,27 +203,30 @@ bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { CommandsMap::const_iterator i = commands.begin(); uint32_t saved_parent_id = 0; uint32_t parent_id = 0; - if ((*message_)[strings::msg_params] - [strings::menu_params].keyExists(hmi_request::parent_id)) { - parent_id = (*message_)[strings::msg_params] - [strings::menu_params][hmi_request::parent_id].asUInt(); + if ((*message_)[strings::msg_params][strings::menu_params].keyExists( + hmi_request::parent_id)) { + parent_id = (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id] + .asUInt(); } for (; commands.end() != i; ++i) { - if (!(*i->second).keyExists(strings::menu_params)) { continue; } saved_parent_id = 0; if ((*i->second)[strings::menu_params].keyExists(hmi_request::parent_id)) { - saved_parent_id = (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt(); + saved_parent_id = + (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt(); } - if (((*i->second)[strings::menu_params][strings::menu_name].asString() - == (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name].asString()) && + if (((*i->second)[strings::menu_params][strings::menu_name].asString() == + (*message_)[strings::msg_params][strings::menu_params] + [strings::menu_name] + .asString()) && (saved_parent_id == parent_id)) { - LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandName received" + LOG4CXX_INFO(logger_, + "AddCommandRequest::CheckCommandName received" " command name already exist in same level menu"); return false; } @@ -242,23 +244,23 @@ bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) { CommandsMap::const_iterator it = commands.begin(); for (; commands.end() != it; ++it) { - - if(!(*it->second).keyExists(strings::vr_commands)) { + if (!(*it->second).keyExists(strings::vr_commands)) { continue; } for (size_t i = 0; i < (*it->second)[strings::vr_commands].length(); ++i) { for (size_t j = 0; - j < (*message_)[strings::msg_params][strings::vr_commands].length(); - ++j) { - std::string vr_cmd_i = - (*it->second)[strings::vr_commands][i].asString(); - std::string vr_cmd_j = - (*message_)[strings::msg_params] - [strings::vr_commands][j].asString(); - - if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) { - LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandVRSynonym" + j < (*message_)[strings::msg_params][strings::vr_commands].length(); + ++j) { + const custom_str::CustomString& vr_cmd_i = + (*it->second)[strings::vr_commands][i].asCustomString(); + const custom_str::CustomString& vr_cmd_j = + (*message_)[strings::msg_params][strings::vr_commands][j] + .asCustomString(); + + if (vr_cmd_i.CompareIgnoreCase(vr_cmd_j)) { + LOG4CXX_INFO(logger_, + "AddCommandRequest::CheckCommandVRSynonym" " received command vr synonym already exist"); return false; } @@ -275,11 +277,13 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) { const int32_t parent_id = (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id].asInt(); + [hmi_request::parent_id] + .asInt(); smart_objects::SmartObject* parent = app->FindSubMenu(parent_id); if (!parent) { - LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandParentId received" + LOG4CXX_INFO(logger_, + "AddCommandRequest::CheckCommandParentId received" " submenu doesn't exist"); return false; } @@ -301,7 +305,8 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { } smart_objects::SmartObject msg_param(smart_objects::SmartType_Map); - msg_param[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; + msg_param[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; msg_param[strings::app_id] = application->app_id(); switch (event.id()) { @@ -328,7 +333,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { break; } default: { - LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); return; } } @@ -342,93 +347,83 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { } smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); - msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; msg_params[strings::app_id] = application->app_id(); mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; const bool is_vr_invalid_unsupported = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - vr_result_, - hmi_apis::Common_Result::INVALID_ENUM, - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + vr_result_, + hmi_apis::Common_Result::INVALID_ENUM, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); const bool is_ui_ivalid_unsupported = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - ui_result_, - hmi_apis::Common_Result::INVALID_ENUM, - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + ui_result_, + hmi_apis::Common_Result::INVALID_ENUM, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); - const bool is_no_ui_error = - Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - ui_result_, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS); + const bool is_no_ui_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS); - const bool is_no_vr_error = - Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - vr_result_, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS); + const bool is_no_vr_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + vr_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS); - bool result = - (is_no_ui_error && is_no_vr_error) || - (is_no_ui_error && is_vr_invalid_unsupported) || - (is_no_vr_error && is_ui_ivalid_unsupported); + bool result = (is_no_ui_error && is_no_vr_error) || + (is_no_ui_error && is_vr_invalid_unsupported) || + (is_no_vr_error && is_ui_ivalid_unsupported); const bool is_vr_or_ui_warning = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - hmi_apis::Common_Result::WARNINGS, - ui_result_, - vr_result_); + hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_); - if (!result && - hmi_apis::Common_Result::REJECTED == ui_result_) { + if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) { result_code = MessageHelper::HMIToMobileResult(ui_result_); } else if (is_vr_or_ui_warning) { result_code = mobile_apis::Result::WARNINGS; } else { - result_code = MessageHelper::HMIToMobileResult( - std::max(ui_result_, vr_result_)); + result_code = + MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_)); } if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) { - const bool is_ui_not_ok = - Compare<hmi_apis::Common_Result::eType, NEQ, ALL>( - ui_result_, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); + const bool is_ui_not_ok = Compare<hmi_apis::Common_Result::eType, NEQ, ALL>( + ui_result_, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); if (is_ui_not_ok) { - result_code = - ui_result_ == hmi_apis::Common_Result::REJECTED - ? mobile_apis::Result::REJECTED - : mobile_apis::Result::GENERIC_ERROR; + result_code = ui_result_ == hmi_apis::Common_Result::REJECTED + ? mobile_apis::Result::REJECTED + : mobile_apis::Result::GENERIC_ERROR; msg_params[strings::grammar_id] = application->get_grammar_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); - application->RemoveCommand((*message_)[strings::msg_params] - [strings::cmd_id].asUInt()); + application->RemoveCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt()); result = false; } } - if(BothSend() && - hmi_apis::Common_Result::SUCCESS == ui_result_ && - !is_no_vr_error) { - - result_code = - vr_result_ == hmi_apis::Common_Result::REJECTED - ? mobile_apis::Result::REJECTED : - mobile_apis::Result::GENERIC_ERROR; + if (BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ && + !is_no_vr_error) { + result_code = vr_result_ == hmi_apis::Common_Result::REJECTED + ? mobile_apis::Result::REJECTED + : mobile_apis::Result::GENERIC_ERROR; SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); - application->RemoveCommand((*message_)[strings::msg_params] - [strings::cmd_id].asUInt()); + application->RemoveCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt()); result = false; } @@ -449,7 +444,8 @@ bool AddCommandRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { str = (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name].asCharArray(); + [strings::menu_name] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid menu name syntax check failed."); return true; @@ -461,8 +457,8 @@ bool AddCommandRequest::IsWhiteSpaceExist() { (*message_)[strings::msg_params][strings::vr_commands].length(); for (size_t i = 0; i < len; ++i) { - str = (*message_)[strings::msg_params] - [strings::vr_commands][i].asCharArray(); + str = (*message_)[strings::msg_params][strings::vr_commands][i] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid vr_commands syntax check failed"); return true; @@ -471,8 +467,8 @@ bool AddCommandRequest::IsWhiteSpaceExist() { } if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { - str = (*message_)[strings::msg_params] - [strings::cmd_icon][strings::value].asCharArray(); + str = (*message_)[strings::msg_params][strings::cmd_icon][strings::value] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid cmd_icon value syntax check failed"); return true; @@ -487,19 +483,20 @@ bool AddCommandRequest::BothSend() const { void AddCommandRequest::RemoveCommand() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( - connection_key()); + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); if (!app.valid()) { LOG4CXX_ERROR(logger_, "No application associated with session key"); return; } smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); - msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::cmd_id] = + (*message_)[strings::msg_params][strings::cmd_id]; msg_params[strings::app_id] = app->app_id(); - app->RemoveCommand((*message_)[strings::msg_params] - [strings::cmd_id].asUInt()); + app->RemoveCommand( + (*message_)[strings::msg_params][strings::cmd_id].asUInt()); if (BothSend() && !(is_vr_received_ || is_ui_received_)) { // in case we have send bth UI and VR and no one respond @@ -516,7 +513,6 @@ void AddCommandRequest::RemoveCommand() { msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); } - } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc index 6217c27890..6f2529bfee 100644 --- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc @@ -41,17 +41,15 @@ namespace application_manager { namespace commands { AddSubMenuRequest::AddSubMenuRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message) { -} + : CommandRequestImpl(message) {} -AddSubMenuRequest::~AddSubMenuRequest() { -} +AddSubMenuRequest::~AddSubMenuRequest() {} void AddSubMenuRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( - connection_key()); + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(connection_key()); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer"); @@ -67,7 +65,7 @@ void AddSubMenuRequest::Run() { return; } - const std::string menu_name = + const std::string& menu_name = (*message_)[strings::msg_params][strings::menu_name].asString(); if (app->IsSubMenuNameAlreadyExist(menu_name)) { @@ -82,14 +80,14 @@ void AddSubMenuRequest::Run() { return; } - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::menu_id] = (*message_)[strings::msg_params][strings::menu_id]; if ((*message_)[strings::msg_params].keyExists(strings::position)) { - msg_params[strings::menu_params][strings::position] = - (*message_)[strings::msg_params][strings::position]; + msg_params[strings::menu_params][strings::position] = + (*message_)[strings::msg_params][strings::position]; } msg_params[strings::menu_params][strings::menu_name] = (*message_)[strings::msg_params][strings::menu_name]; @@ -109,14 +107,13 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) { static_cast<mobile_apis::Result::eType>( message[strings::params][hmi_response::code].asInt()); - const bool result = - Compare<mobile_api::Result::eType, EQ, ONE>( - result_code, - mobile_api::Result::SUCCESS, - mobile_api::Result::WARNINGS); + const bool result = Compare<mobile_api::Result::eType, EQ, ONE>( + result_code, + mobile_api::Result::SUCCESS, + mobile_api::Result::WARNINGS); ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application(connection_key()); + ApplicationManagerImpl::instance()->application(connection_key()); if (!application) { LOG4CXX_ERROR(logger_, "NULL pointer"); @@ -124,10 +121,10 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) { } if (result) { - application->AddSubMenu((*message_)[strings::msg_params] - [strings::menu_id].asInt(), - (*message_)[strings::msg_params]); - } + application->AddSubMenu( + (*message_)[strings::msg_params][strings::menu_id].asInt(), + (*message_)[strings::msg_params]); + } SendResponse(result, result_code, NULL, &(message[strings::msg_params])); if (result) { application->UpdateHash(); diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc index c68f545360..0109d3235b 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -41,14 +41,15 @@ #include "interfaces/HMI_API.h" namespace { +namespace custom_str = utils::custom_string; struct IsSameNickname { - IsSameNickname(const std::string& app_id) : app_id_(app_id) {} + IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {} bool operator()(const policy::StringArray::value_type& nickname) const { - return !strcasecmp(app_id_.c_str(), nickname.c_str()); + return app_id_.CompareIgnoreCase(nickname.c_str()); } private: - const std::string& app_id_; + const custom_str::CustomString& app_id_; }; } @@ -119,7 +120,7 @@ void ChangeRegistrationRequest::Run() { } if (msg_params.keyExists(strings::app_name) && - !IsNicknameAllowed(msg_params[strings::app_name].asString())) { + !IsNicknameAllowed(msg_params[strings::app_name].asCustomString())) { LOG4CXX_ERROR(logger_, "Nickname is not allowed."); SendResponse(false, mobile_apis::Result::DISALLOWED); return; @@ -136,7 +137,7 @@ void ChangeRegistrationRequest::Run() { ui_params[strings::app_id] = app->app_id(); if (msg_params.keyExists(strings::app_name)) { ui_params[strings::app_name] = msg_params[strings::app_name]; - app->set_name(msg_params[strings::app_name].asString()); + app->set_name(msg_params[strings::app_name].asCustomString()); } if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { ui_params[strings::ngn_media_screen_app_name] = @@ -387,10 +388,10 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { (*message_)[strings::msg_params]; ApplicationManagerImpl::ApplicationListAccessor accessor; - std::string app_name; + custom_str::CustomString app_name; uint32_t app_id = connection_key(); if (msg_params.keyExists(strings::app_name)) { - app_name = msg_params[strings::app_name].asString(); + app_name = msg_params[strings::app_name].asCustomString(); } ApplicationSetConstIt it = accessor.begin(); @@ -399,9 +400,9 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { continue; } - const std::string& cur_name = (*it)->name(); + const custom_str::CustomString& cur_name = (*it)->name(); if (msg_params.keyExists(strings::app_name)) { - if (!strcasecmp(app_name.c_str(), cur_name.c_str())) { + if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); return mobile_apis::Result::DUPLICATE_NAME; } @@ -435,7 +436,7 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { } bool ChangeRegistrationRequest::IsNicknameAllowed( - const std::string& app_name) const { + const custom_str::CustomString& app_name) const { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()->application( diff --git a/src/components/application_manager/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/src/commands/mobile/dial_number_request.cc index 87cf42d361..5c1cf18cf8 100644 --- a/src/components/application_manager/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -42,18 +42,16 @@ namespace application_manager { namespace commands { DialNumberRequest::DialNumberRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message) { -} + : CommandRequestImpl(message) {} -DialNumberRequest::~DialNumberRequest() { -} +DialNumberRequest::~DialNumberRequest() {} -bool DialNumberRequest::Init(){ - LOG4CXX_AUTO_TRACE(logger_); +bool DialNumberRequest::Init() { + LOG4CXX_AUTO_TRACE(logger_); - default_timeout_ = 0; + default_timeout_ = 0; - return true; + return true; } void DialNumberRequest::Run() { @@ -67,30 +65,31 @@ void DialNumberRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - std::string number = (*message_)[strings::msg_params][strings::number].asString(); + std::string number = + (*message_)[strings::msg_params][strings::number].asString(); if (!CheckSyntax(number)) { - LOG4CXX_ERROR(logger_, "Invalid incoming data"); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; + LOG4CXX_ERROR(logger_, "Invalid incoming data"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; } StripNumberParam(number); if (number.empty()) { - LOG4CXX_WARN(logger_, "After strip number param is empty. Invalid incoming data"); + LOG4CXX_WARN(logger_, + "After strip number param is empty. Invalid incoming data"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::number] = - (*message_)[strings::msg_params][strings::number].asString(); + (*message_)[strings::msg_params][strings::number].asString(); msg_params[strings::app_id] = application->hmi_app_id(); - SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_DialNumber, - &msg_params, true); + SendHMIRequest( + hmi_apis::FunctionID::BasicCommunication_DialNumber, &msg_params, true); } void DialNumberRequest::on_event(const event_engine::Event& event) { - ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); @@ -104,13 +103,13 @@ void DialNumberRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::BasicCommunication_DialNumber: { LOG4CXX_INFO(logger_, "Received DialNumber event"); - result_code = CommandRequestImpl::GetMobileResultCode( - static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asInt())); + result_code = CommandRequestImpl::GetMobileResultCode( + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt())); break; } default: { - LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); return; } } @@ -129,12 +128,13 @@ void DialNumberRequest::on_event(const event_engine::Event& event) { SendResponse(is_success, result_code); } -void DialNumberRequest::StripNumberParam(std::string &number) { - std::size_t found = 0; - while (std::string::npos != (found = number.find_first_not_of("+0123456789"))) { - number.erase(number.begin() + found); - } - (*message_)[strings::msg_params][strings::number] = number; +void DialNumberRequest::StripNumberParam(std::string& number) { + std::size_t found = 0; + while (std::string::npos != + (found = number.find_first_not_of("+0123456789"))) { + number.erase(number.begin() + found); + } + (*message_)[strings::msg_params][strings::number] = number; } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc index ed75e62c0c..6413e9d7d4 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc @@ -47,17 +47,17 @@ namespace str = strings; #ifdef HMI_DBUS_API GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message) { -} + : CommandRequestImpl(message) {} -GetVehicleDataRequest::~GetVehicleDataRequest() { -} +GetVehicleDataRequest::~GetVehicleDataRequest() {} void GetVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + int32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(app_id); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer"); @@ -69,8 +69,8 @@ void GetVehicleDataRequest::Run() { VehicleData::const_iterator it = vehicle_data.begin(); for (; vehicle_data.end() != it; ++it) { - if (true == (*message_)[str::msg_params].keyExists(it->first) - && true == (*message_)[str::msg_params][it->first].asBool()) { + if (true == (*message_)[str::msg_params].keyExists(it->first) && + true == (*message_)[str::msg_params][it->first].asBool()) { SendRequestsToHmi(app->app_id()); return; } @@ -80,37 +80,44 @@ void GetVehicleDataRequest::Run() { } namespace { - struct Subrequest { - hmi_apis::FunctionID::eType func_id; - const char* str; - }; - Subrequest subrequests[] = { - { hmi_apis::FunctionID::VehicleInfo_GetGpsData, str::gps}, - { hmi_apis::FunctionID::VehicleInfo_GetSpeed, str::speed}, - { hmi_apis::FunctionID::VehicleInfo_GetRpm, str::rpm}, - { hmi_apis::FunctionID::VehicleInfo_GetFuelLevel, str::fuel_level}, - { hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState, str::fuel_level_state}, - { hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption, str::instant_fuel_consumption}, - { hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature, str::external_temp}, - { hmi_apis::FunctionID::VehicleInfo_GetVin, str::vin}, - { hmi_apis::FunctionID::VehicleInfo_GetPrndl, str::prndl}, - { hmi_apis::FunctionID::VehicleInfo_GetTirePressure, str::tire_pressure}, - { hmi_apis::FunctionID::VehicleInfo_GetOdometer, str::odometer}, - { hmi_apis::FunctionID::VehicleInfo_GetBeltStatus, str::belt_status}, - { hmi_apis::FunctionID::VehicleInfo_GetBodyInformation, str::body_information}, - { hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus, str::device_status}, - { hmi_apis::FunctionID::VehicleInfo_GetDriverBraking, str::driver_braking}, - { hmi_apis::FunctionID::VehicleInfo_GetWiperStatus, str::wiper_status}, - { hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus, str::head_lamp_status}, - { hmi_apis::FunctionID::VehicleInfo_GetEngineTorque, str::engine_torque}, - { hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition, str::acc_pedal_pos}, - { hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle, str::steering_wheel_angle}, - { hmi_apis::FunctionID::VehicleInfo_GetECallInfo, str::e_call_info}, - { hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus, str::airbag_status}, - { hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent, str::emergency_event}, - { hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus, str::cluster_mode_status}, - { hmi_apis::FunctionID::VehicleInfo_GetMyKey, str::my_key}, - }; +struct Subrequest { + hmi_apis::FunctionID::eType func_id; + const char* str; +}; +Subrequest subrequests[] = { + {hmi_apis::FunctionID::VehicleInfo_GetGpsData, str::gps}, + {hmi_apis::FunctionID::VehicleInfo_GetSpeed, str::speed}, + {hmi_apis::FunctionID::VehicleInfo_GetRpm, str::rpm}, + {hmi_apis::FunctionID::VehicleInfo_GetFuelLevel, str::fuel_level}, + {hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState, + str::fuel_level_state}, + {hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption, + str::instant_fuel_consumption}, + {hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature, + str::external_temp}, + {hmi_apis::FunctionID::VehicleInfo_GetVin, str::vin}, + {hmi_apis::FunctionID::VehicleInfo_GetPrndl, str::prndl}, + {hmi_apis::FunctionID::VehicleInfo_GetTirePressure, str::tire_pressure}, + {hmi_apis::FunctionID::VehicleInfo_GetOdometer, str::odometer}, + {hmi_apis::FunctionID::VehicleInfo_GetBeltStatus, str::belt_status}, + {hmi_apis::FunctionID::VehicleInfo_GetBodyInformation, + str::body_information}, + {hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus, str::device_status}, + {hmi_apis::FunctionID::VehicleInfo_GetDriverBraking, str::driver_braking}, + {hmi_apis::FunctionID::VehicleInfo_GetWiperStatus, str::wiper_status}, + {hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus, + str::head_lamp_status}, + {hmi_apis::FunctionID::VehicleInfo_GetEngineTorque, str::engine_torque}, + {hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition, str::acc_pedal_pos}, + {hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle, + str::steering_wheel_angle}, + {hmi_apis::FunctionID::VehicleInfo_GetECallInfo, str::e_call_info}, + {hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus, str::airbag_status}, + {hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent, str::emergency_event}, + {hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus, + str::cluster_mode_status}, + {hmi_apis::FunctionID::VehicleInfo_GetMyKey, str::my_key}, +}; } void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) { @@ -119,8 +126,8 @@ void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) { for (size_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) { const Subrequest& sr = subrequests[i]; - if (true == (*message_)[str::msg_params].keyExists(sr.str) - && true == (*message_)[str::msg_params][sr.str].asBool()) { + if (true == (*message_)[str::msg_params].keyExists(sr.str) && + true == (*message_)[str::msg_params][sr.str].asBool()) { HmiRequest hmi_request; hmi_request.str = sr.str; hmi_request.func_id = sr.func_id; @@ -133,7 +140,8 @@ void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) { hmi_requests_.size() << " requests are going to be sent to HMI"); for (HmiRequests::const_iterator it = hmi_requests_.begin(); - it != hmi_requests_.end(); ++it) { + it != hmi_requests_.end(); + ++it) { SendHMIRequest(it->func_id, &msg_params, true); } } @@ -144,12 +152,12 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); for (HmiRequests::iterator it = hmi_requests_.begin(); - it != hmi_requests_.end(); ++it) { - HmiRequest & hmi_request = *it; + it != hmi_requests_.end(); + ++it) { + HmiRequest& hmi_request = *it; if (hmi_request.func_id == event.id()) { - hmi_request.status = - static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code] - .asInt()); + hmi_request.status = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); if (hmi_apis::Common_Result::SUCCESS == hmi_request.status) hmi_request.value = message[str::msg_params][hmi_request.str]; hmi_request.complete = true; @@ -161,7 +169,8 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { bool any_arg_success = false; mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS; for (HmiRequests::const_iterator it = hmi_requests_.begin(); - it != hmi_requests_.end(); ++it) { + it != hmi_requests_.end(); + ++it) { if (!it->complete) { all_complete = false; break; @@ -169,13 +178,16 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { if (hmi_apis::Common_Result::SUCCESS != it->status) { if (mobile_api::Result::SUCCESS == status) { status = static_cast<mobile_apis::Result::eType>(it->status); - } else if (status - != static_cast<mobile_apis::Result::eType>(it->status)) { + } else if (status != + static_cast<mobile_apis::Result::eType>(it->status)) { status = mobile_api::Result::eType::GENERIC_ERROR; } - LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status << ", so response status become " << status); + LOG4CXX_TRACE(logger_, + "Status from HMI: " << it->status + << ", so response status become " + << status); } else { - any_arg_success = true; + any_arg_success = true; } } @@ -183,34 +195,34 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { smart_objects::SmartObject response_params(smart_objects::SmartType_Map); if (any_arg_success) { for (HmiRequests::const_iterator it = hmi_requests_.begin(); - it != hmi_requests_.end(); ++it) { + it != hmi_requests_.end(); + ++it) { response_params[it->str] = it->value; } } - LOG4CXX_INFO( - logger_, "All HMI requests are complete"); - const char *info = NULL; + LOG4CXX_INFO(logger_, "All HMI requests are complete"); + const char* info = NULL; std::string error_message; if (true == message[strings::params].keyExists(strings::error_msg)) { error_message = message[strings::params][strings::error_msg].asString(); info = error_message.c_str(); } - SendResponse( any_arg_success, status, info, &response_params); + SendResponse(any_arg_success, status, info, &response_params); } } #else GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message) { -} + : CommandRequestImpl(message) {} -GetVehicleDataRequest::~GetVehicleDataRequest() { -} +GetVehicleDataRequest::~GetVehicleDataRequest() {} void GetVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); + int32_t app_id = + (*message_)[strings::params][strings::connection_key].asUInt(); + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->application(app_id); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer"); @@ -219,27 +231,27 @@ void GetVehicleDataRequest::Run() { } if (app->IsCommandLimitsExceeded( - static_cast<mobile_apis::FunctionID::eType>(function_id()), - application_manager::TLimitSource::CONFIG_FILE)) { + static_cast<mobile_apis::FunctionID::eType>(function_id()), + application_manager::TLimitSource::CONFIG_FILE)) { LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high."); SendResponse(false, mobile_apis::Result::REJECTED); return; } const VehicleData& vehicle_data = MessageHelper::vehicle_data(); VehicleData::const_iterator it = vehicle_data.begin(); - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::app_id] = app->app_id(); const uint32_t min_length_msg_params = 1; for (; vehicle_data.end() != it; ++it) { - if (true == (*message_)[str::msg_params].keyExists(it->first) - && true == (*message_)[str::msg_params][it->first].asBool()) { + if (true == (*message_)[str::msg_params].keyExists(it->first) && + true == (*message_)[str::msg_params][it->first].asBool()) { msg_params[it->first] = (*message_)[strings::msg_params][it->first]; } } if (msg_params.length() > min_length_msg_params) { - SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetVehicleData, - &msg_params, true); + SendHMIRequest( + hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true); return; } else if (HasDisallowedParams()) { SendResponse(false, mobile_apis::Result::DISALLOWED); @@ -260,11 +272,11 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { bool result = false; if (mobile_apis::Result::SUCCESS == result_code || (hmi_apis::Common_Result::DATA_NOT_AVAILABLE == - static_cast<hmi_apis::Common_Result::eType>(result_code) - && message[strings::msg_params].length() > 1)) { + static_cast<hmi_apis::Common_Result::eType>(result_code) && + message[strings::msg_params].length() > 1)) { result = true; } - const char *info = NULL; + const char* info = NULL; std::string error_message; if (true == message[strings::msg_params].keyExists(hmi_response::method)) { @@ -284,8 +296,8 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { } } -#endif // #ifdef HMI_DBUS_API +#endif // #ifdef HMI_DBUS_API -} // namespace commands +} // namespace commands -} // namespace application_manager +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc index dc3f8ad39f..9c60b90be5 100644 --- a/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc @@ -98,7 +98,7 @@ void OnVehicleDataNotification::Run() { for (size_t idx = 0; idx < appNotification.size(); idx++) { LOG4CXX_INFO( logger_, - "Send OnVehicleData PRNDL notification to " << appNotification[idx]->name() + "Send OnVehicleData PRNDL notification to " << appNotification[idx]->name().c_str() << " application id " << appNotification[idx]->app_id()); (*message_)[strings::params][strings::connection_key] = appNotification[idx]->app_id(); diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc index f6b9801fff..98ddfafb0d 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -42,31 +42,31 @@ #include "interfaces/HMI_API.h" #include "utils/file_system.h" #include "utils/helpers.h" +#include "utils/custom_string.h" namespace application_manager { namespace commands { +namespace custom_str = utils::custom_string; + uint32_t PerformInteractionRequest::pi_requests_count_ = 0; PerformInteractionRequest::PerformInteractionRequest( - const MessageSharedPtr& message) -: CommandRequestImpl(message), - interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM), - ui_response_recived_(false), - vr_response_recived_(false), - app_pi_was_active_before_(false) { - + const MessageSharedPtr& message) + : CommandRequestImpl(message) + , interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM) + , ui_response_recived_(false) + , vr_response_recived_(false) + , app_pi_was_active_before_(false) { subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand); subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress); } -PerformInteractionRequest::~PerformInteractionRequest() { -} +PerformInteractionRequest::~PerformInteractionRequest() {} bool PerformInteractionRequest::Init() { - /* Timeout in milliseconds. If omitted a standard value of 10000 milliseconds is used.*/ if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { @@ -112,8 +112,9 @@ void PerformInteractionRequest::Run() { if ((mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) && (mobile_apis::LayoutMode::KEYBOARD == interaction_layout)) { - LOG4CXX_ERROR(logger_, "PerformInteraction contains InteractionMode" - "=VR_ONLY and interactionLayout=KEYBOARD"); + LOG4CXX_ERROR(logger_, + "PerformInteraction contains InteractionMode" + "=VR_ONLY and interactionLayout=KEYBOARD"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } @@ -124,25 +125,28 @@ void PerformInteractionRequest::Run() { if (0 == choice_set_id_list_length) { if (mobile_apis::LayoutMode::KEYBOARD == interaction_layout) { if (mobile_apis::InteractionMode::BOTH == interaction_mode_) { - LOG4CXX_ERROR(logger_,"interactionChoiceSetIDList is empty," - " InteractionMode=BOTH and" - " interactionLayout=KEYBOARD"); + LOG4CXX_ERROR(logger_, + "interactionChoiceSetIDList is empty," + " InteractionMode=BOTH and" + " interactionLayout=KEYBOARD"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } } else { - LOG4CXX_ERROR(logger_,"interactionChoiceSetIDList is empty" - " and interactionLayout!=KEYBOARD"); + LOG4CXX_ERROR(logger_, + "interactionChoiceSetIDList is empty" + " and interactionLayout!=KEYBOARD"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } } if (msg_params.keyExists(strings::vr_help)) { - if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( - msg_params[strings::vr_help], app)) { - LOG4CXX_ERROR(logger_, "Verification of " << strings::vr_help - << " failed."); + if (mobile_apis::Result::SUCCESS != + MessageHelper::VerifyImageVrHelpItems(msg_params[strings::vr_help], + app)) { + LOG4CXX_ERROR(logger_, + "Verification of " << strings::vr_help << " failed."); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } @@ -169,8 +173,7 @@ void PerformInteractionRequest::Run() { switch (interaction_mode_) { case mobile_apis::InteractionMode::BOTH: { LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); - if (!CheckChoiceSetVRSynonyms(app) || - !CheckChoiceSetMenuNames(app) || + if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || !CheckVrHelpItemPositions(app)) { return; } @@ -178,8 +181,7 @@ void PerformInteractionRequest::Run() { } case mobile_apis::InteractionMode::MANUAL_ONLY: { LOG4CXX_DEBUG(logger_, "Interaction Mode: MANUAL_ONLY"); - if (!CheckChoiceSetVRSynonyms(app) || - !CheckChoiceSetMenuNames(app) || + if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || !CheckVrHelpItemPositions(app)) { return; } @@ -187,8 +189,7 @@ void PerformInteractionRequest::Run() { } case mobile_apis::InteractionMode::VR_ONLY: { LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY"); - if (!CheckChoiceSetVRSynonyms(app) || - !CheckVrHelpItemPositions(app)) { + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) { return; } break; @@ -214,7 +215,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::UI_OnResetTimeout: { LOG4CXX_DEBUG(logger_, "Received UI_OnResetTimeout event"); ApplicationManagerImpl::instance()->updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout()); break; } case hmi_apis::FunctionID::UI_PerformInteraction: { @@ -247,13 +248,13 @@ void PerformInteractionRequest::onTimeOut() { CommandRequestImpl::onTimeOut(); } else { ApplicationManagerImpl::instance()->updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout()); } break; } case mobile_apis::InteractionMode::VR_ONLY: { ApplicationManagerImpl::instance()->updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout()); break; } case mobile_apis::InteractionMode::MANUAL_ONLY: { @@ -269,7 +270,6 @@ void PerformInteractionRequest::onTimeOut() { }; } - void PerformInteractionRequest::ProcessVRResponse( const smart_objects::SmartObject& message) { LOG4CXX_AUTO_TRACE(logger_); @@ -289,8 +289,7 @@ void PerformInteractionRequest::ProcessVRResponse( const mobile_apis::Result::eType vr_perform_interaction_code = static_cast<eType>(message[strings::params][hmi_response::code].asInt()); - const bool is_generic_error = - GENERIC_ERROR == vr_perform_interaction_code; + const bool is_generic_error = GENERIC_ERROR == vr_perform_interaction_code; if (is_generic_error) { LOG4CXX_DEBUG(logger_, "VR response GENERIC_ERROR"); TerminatePerformInteraction(); @@ -298,10 +297,8 @@ void PerformInteractionRequest::ProcessVRResponse( return; } - const bool is_vr_aborted_timeout = - Compare<Result::eType, EQ, ONE>(vr_perform_interaction_code, - ABORTED, - TIMED_OUT); + const bool is_vr_aborted_timeout = Compare<Result::eType, EQ, ONE>( + vr_perform_interaction_code, ABORTED, TIMED_OUT); if (is_vr_aborted_timeout) { LOG4CXX_DEBUG(logger_, "VR response aborted"); @@ -312,10 +309,8 @@ void PerformInteractionRequest::ProcessVRResponse( return; } LOG4CXX_DEBUG(logger_, "Update timeout for UI"); - ApplicationManagerImpl::instance()-> - updateRequestTimeout(connection_key(), - correlation_id(), - default_timeout()); + ApplicationManagerImpl::instance()->updateRequestTimeout( + connection_key(), correlation_id(), default_timeout()); return; } @@ -328,8 +323,9 @@ void PerformInteractionRequest::ProcessVRResponse( if (SUCCESS == vr_perform_interaction_code && InteractionMode::MANUAL_ONLY == interaction_mode_) { - LOG4CXX_DEBUG(logger_, "VR response SUCCESS in MANUAL_ONLY mode " << - "Wait for UI response"); + LOG4CXX_DEBUG(logger_, + "VR response SUCCESS in MANUAL_ONLY mode " + << "Wait for UI response"); // in case MANUAL_ONLY mode VR.PI SUCCESS just return return; } @@ -342,16 +338,15 @@ void PerformInteractionRequest::ProcessVRResponse( if (!CheckChoiceIDFromResponse(app, choise_id)) { LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI"); TerminatePerformInteraction(); - SendResponse(false, GENERIC_ERROR,"Wrong choiceID was received from HMI"); + SendResponse( + false, GENERIC_ERROR, "Wrong choiceID was received from HMI"); return; } msg_params[strings::choice_id] = choise_id; } - const bool is_vr_result_warning = - Compare<Result::eType, EQ, ONE>(vr_perform_interaction_code, - UNSUPPORTED_REQUEST, - WARNINGS); + const bool is_vr_result_warning = Compare<Result::eType, EQ, ONE>( + vr_perform_interaction_code, UNSUPPORTED_REQUEST, WARNINGS); if (is_vr_result_warning) { LOG4CXX_DEBUG(logger_, "VR response WARNINGS"); @@ -362,7 +357,8 @@ void PerformInteractionRequest::ProcessVRResponse( LOG4CXX_DEBUG(logger_, "VR response consider to be SUCCESS"); TerminatePerformInteraction(); - msg_params[strings::trigger_source] = static_cast<int32_t>(TriggerSource::TS_VR); + msg_params[strings::trigger_source] = + static_cast<int32_t>(TriggerSource::TS_VR); SendResponse(true, SUCCESS, NULL, &msg_params); } @@ -379,25 +375,23 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse( return; } - SmartObject msg_params = - SmartObject(SmartType_Map); - + SmartObject msg_params = SmartObject(SmartType_Map); + mobile_apis::Result::eType result_code = GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt())); - const bool result = - Compare<mobile_api::Result::eType, EQ, ONE>( - result_code, - mobile_apis::Result::SUCCESS, - mobile_apis::Result::WARNINGS, - mobile_apis::Result::UNSUPPORTED_RESOURCE); + const bool result = Compare<mobile_api::Result::eType, EQ, ONE>( + result_code, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS, + mobile_apis::Result::UNSUPPORTED_RESOURCE); const bool is_pi_unsupported_warning = Compare<mobile_api::Result::eType, EQ, ONE>( - result_code, - mobile_apis::Result::UNSUPPORTED_RESOURCE, - mobile_apis::Result::WARNINGS); + result_code, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + mobile_apis::Result::WARNINGS); std::string info; @@ -405,8 +399,8 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse( if (is_pi_unsupported_warning) { result_code = mobile_apis::Result::WARNINGS; info = "Unsupported phoneme type was sent in an item"; - if (message.keyExists(strings::params) - && message[strings::params].keyExists(strings::data)) { + if (message.keyExists(strings::params) && + message[strings::params].keyExists(strings::data)) { msg_params = message[strings::params][strings::data]; } } else if (message.keyExists(strings::msg_params)) { @@ -431,10 +425,7 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse( DisablePerformInteraction(); const char* return_info = (info.empty()) ? NULL : info.c_str(); - const SmartObject* response_params = - msg_params.empty() - ? NULL - : &msg_params; + const SmartObject* response_params = msg_params.empty() ? NULL : &msg_params; SendResponse(result, result_code, return_info, response_params); } @@ -444,12 +435,12 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( smart_objects::SmartObject& choice_set_id_list = (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); - mobile_apis::InteractionMode::eType mode = + mobile_apis::InteractionMode::eType mode = static_cast<mobile_apis::InteractionMode::eType>( - (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); if (mobile_apis::InteractionMode::VR_ONLY != mode) { msg_params[hmi_request::initial_text][hmi_request::field_name] = @@ -471,24 +462,23 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( if (mobile_apis::InteractionMode::BOTH == mode || mobile_apis::InteractionMode::MANUAL_ONLY == mode) { - msg_params[strings::timeout] = default_timeout_/2; + msg_params[strings::timeout] = default_timeout_ / 2; } else { msg_params[strings::timeout] = default_timeout_; } msg_params[strings::app_id] = app->app_id(); if (mobile_apis::InteractionMode::VR_ONLY != mode) { - msg_params[strings::choice_set] = smart_objects::SmartObject( - smart_objects::SmartType_Array); + msg_params[strings::choice_set] = + smart_objects::SmartObject(smart_objects::SmartType_Array); } int32_t index_array_of_vr_help = 0; for (size_t i = 0; i < choice_set_id_list.length(); ++i) { - smart_objects::SmartObject* choice_set = app->FindChoiceSet( - choice_set_id_list[i].asInt()); + smart_objects::SmartObject* choice_set = + app->FindChoiceSet(choice_set_id_list[i].asInt()); if (choice_set) { // save perform interaction choice set - app->AddPerformInteractionChoiceSet(correlation_id(), - choice_set_id_list[i].asInt(), - *choice_set); + app->AddPerformInteractionChoiceSet( + correlation_id(), choice_set_id_list[i].asInt(), *choice_set); for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) { if (mobile_apis::InteractionMode::VR_ONLY != mode) { size_t index = msg_params[strings::choice_set].length(); @@ -497,8 +487,8 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( // vrCommands should be added via VR.AddCommand only msg_params[strings::choice_set][index].erase(strings::vr_commands); } - if (mobile_apis::InteractionMode::MANUAL_ONLY != - mode && !is_vr_help_item) { + if (mobile_apis::InteractionMode::MANUAL_ONLY != mode && + !is_vr_help_item) { smart_objects::SmartObject& vr_commands = (*choice_set)[strings::choice_set][j][strings::vr_commands]; if (0 < vr_commands.length()) { @@ -512,15 +502,15 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( } } } - if ((*message_)[strings::msg_params] - .keyExists(hmi_request::interaction_layout) - && mobile_apis::InteractionMode::VR_ONLY != mode) { + if ((*message_)[strings::msg_params].keyExists( + hmi_request::interaction_layout) && + mobile_apis::InteractionMode::VR_ONLY != mode) { msg_params[hmi_request::interaction_layout] = - (*message_)[strings::msg_params][hmi_request::interaction_layout]. - asInt(); + (*message_)[strings::msg_params][hmi_request::interaction_layout] + .asInt(); } - SendHMIRequest(hmi_apis::FunctionID::UI_PerformInteraction, - &msg_params, true); + SendHMIRequest( + hmi_apis::FunctionID::UI_PerformInteraction, &msg_params, true); } void PerformInteractionRequest::SendVRPerformInteractionRequest( @@ -531,7 +521,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( smart_objects::SmartObject(smart_objects::SmartType_Map); smart_objects::SmartObject& choice_list = - (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; if (mobile_apis::InteractionMode::MANUAL_ONLY != interaction_mode_) { msg_params[strings::grammar_id] = @@ -545,7 +535,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( LOG4CXX_WARN(logger_, "Couldn't found choiset"); continue; } - msg_params[strings::grammar_id][grammar_id_index++]= + msg_params[strings::grammar_id][grammar_id_index++] = (*choice_set)[strings::grammar_id].asUInt(); } } @@ -564,9 +554,8 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( app->FindChoiceSet(choice_list[i].asInt()); if (choice_set) { - for (uint32_t j = 0; - j < (*choice_set)[strings::choice_set].length(); - ++j) { + for (uint32_t j = 0; j < (*choice_set)[strings::choice_set].length(); + ++j) { smart_objects::SmartObject& vr_commands = (*choice_set)[strings::choice_set][j][strings::vr_commands]; if (0 < vr_commands.length()) { @@ -588,7 +577,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) { msg_params[strings::timeout_prompt] = - (*message_)[strings::msg_params][strings::timeout_prompt]; + (*message_)[strings::msg_params][strings::timeout_prompt]; } else { if (msg_params.keyExists(strings::help_prompt)) { msg_params[strings::timeout_prompt] = msg_params[strings::help_prompt]; @@ -596,23 +585,23 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { - msg_params[strings::initial_prompt] = - (*message_)[strings::msg_params][strings::initial_prompt]; + msg_params[strings::initial_prompt] = + (*message_)[strings::msg_params][strings::initial_prompt]; } mobile_apis::InteractionMode::eType mode = static_cast<mobile_apis::InteractionMode::eType>( - (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + (*message_)[strings::msg_params][strings::interaction_mode].asInt()); if (mobile_apis::InteractionMode::BOTH == mode || mobile_apis::InteractionMode::MANUAL_ONLY == mode) { - msg_params[strings::timeout] = default_timeout_/2; + msg_params[strings::timeout] = default_timeout_ / 2; } else { msg_params[strings::timeout] = default_timeout_; } msg_params[strings::app_id] = app->app_id(); - SendHMIRequest(hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, - true); + SendHMIRequest( + hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true); } bool PerformInteractionRequest::CheckChoiceSetMenuNames( @@ -624,12 +613,12 @@ bool PerformInteractionRequest::CheckChoiceSetMenuNames( for (size_t i = 0; i < choice_list.length(); ++i) { // choice_set contains SmartObject msg_params - smart_objects::SmartObject* i_choice_set = app->FindChoiceSet( - choice_list[i].asInt()); + smart_objects::SmartObject* i_choice_set = + app->FindChoiceSet(choice_list[i].asInt()); for (size_t j = 0; j < choice_list.length(); ++j) { - smart_objects::SmartObject* j_choice_set = app->FindChoiceSet( - choice_list[j].asInt()); + smart_objects::SmartObject* j_choice_set = + app->FindChoiceSet(choice_list[j].asInt()); if (i == j) { // skip check the same element @@ -646,16 +635,17 @@ bool PerformInteractionRequest::CheckChoiceSetMenuNames( size_t jj = 0; for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { - std::string ii_menu_name = + const std::string& ii_menu_name = (*i_choice_set)[strings::choice_set][ii][strings::menu_name] .asString(); - std::string jj_menu_name = + const std::string& jj_menu_name = (*j_choice_set)[strings::choice_set][jj][strings::menu_name] .asString(); if (ii_menu_name == jj_menu_name) { LOG4CXX_ERROR(logger_, "Choice set has duplicated menu name"); - SendResponse(false, mobile_apis::Result::DUPLICATE_NAME, + SendResponse(false, + mobile_apis::Result::DUPLICATE_NAME, "Choice set has duplicated menu name"); return false; } @@ -676,12 +666,12 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( for (size_t i = 0; i < choice_list.length(); ++i) { // choice_set contains SmartObject msg_params - smart_objects::SmartObject* i_choice_set = app->FindChoiceSet( - choice_list[i].asInt()); + smart_objects::SmartObject* i_choice_set = + app->FindChoiceSet(choice_list[i].asInt()); for (size_t j = 0; j < choice_list.length(); ++j) { - smart_objects::SmartObject* j_choice_set = app->FindChoiceSet( - choice_list[j].asInt()); + smart_objects::SmartObject* j_choice_set = + app->FindChoiceSet(choice_list[j].asInt()); if (i == j) { // skip check the same element @@ -707,11 +697,14 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( for (size_t iii = 0; iii < ii_vr_commands.length(); ++iii) { for (size_t jjj = 0; jjj < jj_vr_commands.length(); ++jjj) { - std::string vr_cmd_i = ii_vr_commands[iii].asString(); - std::string vr_cmd_j = jj_vr_commands[jjj].asString(); - if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) { + const custom_str::CustomString& vr_cmd_i = + ii_vr_commands[iii].asCustomString(); + const custom_str::CustomString& vr_cmd_j = + jj_vr_commands[jjj].asCustomString(); + if (vr_cmd_i.CompareIgnoreCase(vr_cmd_j)) { LOG4CXX_ERROR(logger_, "Choice set has duplicated VR synonym"); - SendResponse(false, mobile_apis::Result::DUPLICATE_NAME, + SendResponse(false, + mobile_apis::Result::DUPLICATE_NAME, "Choice set has duplicated VR synonym"); return false; } @@ -741,7 +734,8 @@ bool PerformInteractionRequest::CheckVrHelpItemPositions( for (size_t i = 0; i < vr_help.length(); ++i) { if (position != vr_help[i][strings::position].asInt()) { LOG4CXX_ERROR(logger_, "Non-sequential vrHelp item position"); - SendResponse(false, mobile_apis::Result::REJECTED, + SendResponse(false, + mobile_apis::Result::REJECTED, "Non-sequential vrHelp item position"); return false; } @@ -781,7 +775,6 @@ bool PerformInteractionRequest::IsWhiteSpaceExist() { return true; } - if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { const smart_objects::SmartArray* ip_array = (*message_)[strings::msg_params][strings::initial_prompt].asArray(); @@ -860,8 +853,8 @@ bool PerformInteractionRequest::IsWhiteSpaceExist() { void PerformInteractionRequest::TerminatePerformInteraction() { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[hmi_request::method_name] = "UI.PerformInteraction"; SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &msg_params); DisablePerformInteraction(); @@ -880,8 +873,8 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( const PerformChoice& choice = choice_set_map_it->second; PerformChoice::const_iterator it = choice.begin(); for (; choice.end() != it; ++it) { - const smart_objects::SmartObject& choice_set = (*it->second).getElement( - strings::choice_set); + const smart_objects::SmartObject& choice_set = + (*it->second).getElement(strings::choice_set); for (size_t j = 0; j < choice_set.length(); ++j) { if (choice_id == choice_set.getElement(j).getElement(strings::choice_id).asInt()) { diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 37dedd5744..554729a3d0 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -46,6 +46,8 @@ namespace { +namespace custom_str = utils::custom_string; + mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) { if ("DEFAULT" == str) { return mobile_apis::AppHMIType::DEFAULT; @@ -93,7 +95,7 @@ struct CheckMissedTypes { : policy_app_types_(policy_app_types), log_(log) {} bool operator()(const smart_objects::SmartArray::value_type& value) { - std::string app_type_str = value.asString(); + const std::string app_type_str = value.asString(); policy::StringArray::const_iterator it = policy_app_types_.begin(); policy::StringArray::const_iterator it_end = policy_app_types_.end(); for (; it != it_end; ++it) { @@ -114,13 +116,13 @@ struct CheckMissedTypes { }; struct IsSameNickname { - IsSameNickname(const std::string& app_id) : app_id_(app_id) {} - bool operator()(const policy::StringArray::value_type nickname) const { - return !strcasecmp(app_id_.c_str(), nickname.c_str()); + IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {} + bool operator()(const policy::StringArray::value_type& nickname) const { + return app_id_.CompareIgnoreCase(nickname.c_str()); } private: - const std::string& app_id_; + const custom_str::CustomString& app_id_; }; } @@ -352,7 +354,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { hmi_capabilities.active_ui_language()) { LOG4CXX_WARN(logger_, "Wrong language on registering application " - << application->name()); + << application->name().c_str()); LOG4CXX_ERROR( logger_, @@ -564,11 +566,11 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { ApplicationManagerImpl::ApplicationListAccessor accessor; ApplicationSetConstIt it = accessor.begin(); - const std::string app_name = msg_params[strings::app_name].asString(); + const custom_str::CustomString app_name = msg_params[strings::app_name].asCustomString(); for (; accessor.end() != it; ++it) { // name check - const std::string& cur_name = (*it)->name(); + const custom_str::CustomString& cur_name = (*it)->name(); if (!strcasecmp(app_name.c_str(), cur_name.c_str())) { LOG4CXX_ERROR(logger_, "Application name is known already."); return mobile_apis::Result::DUPLICATE_NAME; @@ -628,7 +630,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { if (!app_nicknames.empty()) { IsSameNickname compare( - message[strings::msg_params][strings::app_name].asString()); + message[strings::msg_params][strings::app_name].asCustomString()); policy::StringArray::const_iterator it = std::find_if(app_nicknames.begin(), app_nicknames.end(), compare); if (app_nicknames.end() == it) { @@ -723,8 +725,8 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { "RegisterAppInterfaceRequest::" "IsApplicationWithSameAppIdRegistered"); - const std::string mobile_app_id = - (*message_)[strings::msg_params][strings::app_id].asString(); + const custom_string::CustomString mobile_app_id = + (*message_)[strings::msg_params][strings::app_id].asCustomString(); ApplicationManagerImpl::ApplicationListAccessor accessor; const ApplicationSet applications = accessor.applications(); @@ -733,7 +735,7 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { ApplicationSetConstIt it_end = applications.end(); for (; it != it_end; ++it) { - if (!strcasecmp(mobile_app_id.c_str(), (*it)->mobile_app_id().c_str())) { + if (mobile_app_id.CompareIgnoreCase((*it)->mobile_app_id().c_str())) { return true; } } diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc index 71ccc4d273..5c9a4f80e7 100644 --- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc @@ -50,14 +50,12 @@ SetAppIconRequest::SetAppIconRequest(const MessageSharedPtr& message) : CommandRequestImpl(message) { if (-1 == is_icons_saving_enabled_) { const std::string path = profile::Profile::instance()->app_icons_folder(); - is_icons_saving_enabled_ = - file_system::IsWritingAllowed(path) && - file_system::IsReadingAllowed(path); + is_icons_saving_enabled_ = file_system::IsWritingAllowed(path) && + file_system::IsReadingAllowed(path); } } -SetAppIconRequest::~SetAppIconRequest() { -} +SetAppIconRequest::~SetAppIconRequest() {} void SetAppIconRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -90,22 +88,22 @@ void SetAppIconRequest::Run() { CopyToIconStorage(full_file_path); } - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::app_id] = app->app_id(); - msg_params[strings::sync_file_name] = smart_objects::SmartObject( - smart_objects::SmartType_Map); + msg_params[strings::sync_file_name] = + smart_objects::SmartObject(smart_objects::SmartType_Map); -// Panasonic requres unchanged path value without encoded special characters - const std::string full_file_path_for_hmi = file_system::ConvertPathForURL( - full_file_path); + // Panasonic requres unchanged path value without encoded special characters + const std::string full_file_path_for_hmi = + file_system::ConvertPathForURL(full_file_path); msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi; // TODO(VS): research why is image_type hardcoded msg_params[strings::sync_file_name][strings::image_type] = - static_cast<int32_t> (SetAppIconRequest::ImageType::DYNAMIC); + static_cast<int32_t>(SetAppIconRequest::ImageType::DYNAMIC); // for further use in on_event function (*message_)[strings::msg_params][strings::sync_file_name] = @@ -115,7 +113,7 @@ void SetAppIconRequest::Run() { } void SetAppIconRequest::CopyToIconStorage( - const std::string& path_to_file) const { + const std::string& path_to_file) const { if (!profile::Profile::instance()->enable_protocol_4()) { LOG4CXX_WARN(logger_, "Icon copying skipped, since protocol ver. 4 is not enabled."); @@ -123,27 +121,29 @@ void SetAppIconRequest::CopyToIconStorage( } std::vector<uint8_t> file_content; - if(!file_system::ReadBinaryFile(path_to_file, file_content)) { + if (!file_system::ReadBinaryFile(path_to_file, file_content)) { LOG4CXX_ERROR(logger_, "Can't read icon file: " << path_to_file); return; } const std::string icon_storage = - profile::Profile::instance()->app_icons_folder(); - const uint64_t storage_max_size = - static_cast<uint64_t>( - profile::Profile::instance()->app_icons_folder_max_size()); + profile::Profile::instance()->app_icons_folder(); + const uint64_t storage_max_size = static_cast<uint64_t>( + profile::Profile::instance()->app_icons_folder_max_size()); const uint64_t file_size = file_system::FileSize(path_to_file); if (storage_max_size < file_size) { - LOG4CXX_ERROR(logger_, "Icon size (" << file_size << ") is bigger, than " - " icons storage maximum size (" << storage_max_size << ")." - "Copying skipped."); + LOG4CXX_ERROR(logger_, + "Icon size (" << file_size << ") is bigger, than " + " icons storage maximum size (" + << storage_max_size + << ")." + "Copying skipped."); return; } - const uint64_t storage_size = static_cast<uint64_t>( - file_system::DirectorySize(icon_storage)); + const uint64_t storage_size = + static_cast<uint64_t>(file_system::DirectorySize(icon_storage)); if (storage_max_size < (file_size + storage_size)) { const uint32_t icons_amount = profile::Profile::instance()->app_icons_amount_to_remove(); @@ -160,17 +160,17 @@ void SetAppIconRequest::CopyToIconStorage( } } ApplicationConstSharedPtr app = - application_manager::ApplicationManagerImpl::instance()-> - application(connection_key()); + application_manager::ApplicationManagerImpl::instance()->application( + connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, "Can't get application for connection key: " - << connection_key()); + LOG4CXX_ERROR( + logger_, + "Can't get application for connection key: " << connection_key()); return; } - const std::string icon_path = - icon_storage + "/" + app->mobile_app_id(); + const std::string icon_path = icon_storage + "/" + app->mobile_app_id(); if (!file_system::CreateFile(icon_path)) { LOG4CXX_ERROR(logger_, "Can't create icon: " << icon_path); return; @@ -181,8 +181,9 @@ void SetAppIconRequest::CopyToIconStorage( return; } - LOG4CXX_DEBUG(logger_, "Icon was successfully copied from :" << path_to_file - << " to " << icon_path); + LOG4CXX_DEBUG(logger_, + "Icon was successfully copied from :" << path_to_file << " to " + << icon_path); return; } @@ -192,7 +193,7 @@ void SetAppIconRequest::RemoveOldestIcons(const std::string& storage, const std::vector<std::string> icons_list = file_system::ListFiles(storage); std::map<uint64_t, std::string> icon_modification_time; std::vector<std::string>::const_iterator it = icons_list.begin(); - for (;it != icons_list.end(); ++it) { + for (; it != icons_list.end(); ++it) { const std::string file_name = *it; const std::string file_path = storage + "/" + file_name; if (!file_system::FileExists(file_path)) { @@ -213,19 +214,18 @@ void SetAppIconRequest::RemoveOldestIcons(const std::string& storage, LOG4CXX_DEBUG(logger_, "Error while deleting icon " << file_path); } icon_modification_time.erase(icon_modification_time.begin()); - LOG4CXX_DEBUG(logger_, "Old icon " << file_path - << " was deleted successfully."); + LOG4CXX_DEBUG(logger_, + "Old icon " << file_path << " was deleted successfully."); } } bool SetAppIconRequest::IsEnoughSpaceForIcon(const uint64_t icon_size) const { const std::string icon_storage = - profile::Profile::instance()->app_icons_folder(); - const uint64_t storage_max_size = - static_cast<uint64_t>( - profile::Profile::instance()->app_icons_folder_max_size()); - const uint64_t storage_size = static_cast<uint64_t>( - file_system::DirectorySize(icon_storage)); + profile::Profile::instance()->app_icons_folder(); + const uint64_t storage_max_size = static_cast<uint64_t>( + profile::Profile::instance()->app_icons_folder_max_size()); + const uint64_t storage_size = + static_cast<uint64_t>(file_system::DirectorySize(icon_storage)); return storage_max_size >= (icon_size + storage_size); } @@ -240,24 +240,24 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { static_cast<mobile_apis::Result::eType>( message[strings::params][hmi_response::code].asInt()); - const bool result = - Compare<mobile_api::Result::eType, EQ, ONE>( - result_code, - mobile_api::Result::SUCCESS, - mobile_api::Result::WARNINGS); + const bool result = Compare<mobile_api::Result::eType, EQ, ONE>( + result_code, + mobile_api::Result::SUCCESS, + mobile_api::Result::WARNINGS); if (result) { ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(connection_key()); if (!message_.valid() || !app.valid()) { - LOG4CXX_ERROR(logger_, "NULL pointer."); - return; + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; } - const std::string path = (*message_)[strings::msg_params] - [strings::sync_file_name] - [strings::value].asString(); + const std::string& path = + (*message_)[strings::msg_params][strings::sync_file_name] + [strings::value] + .asString(); app->set_app_icon_path(path); LOG4CXX_INFO(logger_, diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index 634b223b2f..c4c81a837e 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -55,11 +55,9 @@ const std::string kSYNC = "SYNC"; const std::string kIVSU = "IVSU"; SystemRequest::SystemRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message) { -} + : CommandRequestImpl(message) {} -SystemRequest::~SystemRequest() { -} +SystemRequest::~SystemRequest() {} void SystemRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -78,7 +76,7 @@ void SystemRequest::Run() { (*message_)[strings::msg_params][strings::request_type].asInt()); if (!policy::PolicyHandler::instance()->IsRequestTypeAllowed( - application->mobile_app_id(), request_type)) { + application->mobile_app_id(), request_type)) { SendResponse(false, mobile_apis::Result::DISALLOWED); return; } @@ -90,15 +88,14 @@ void SystemRequest::Run() { file_name = kSYNC; } - bool is_system_file = - std::string::npos != file_name.find(kSYNC) || - std::string::npos != file_name.find(kIVSU); + bool is_system_file = std::string::npos != file_name.find(kSYNC) || + std::string::npos != file_name.find(kIVSU); // to avoid override existing file if (is_system_file) { const uint8_t max_size = 255; char buf[max_size] = {'\0'}; - snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%d%s", index++, file_name.c_str()); + snprintf(buf, max_size - 1, "%d%s", index++, file_name.c_str()); file_name = buf; } @@ -119,9 +116,10 @@ void SystemRequest::Run() { file_dst_path += file_name; if ((*message_)[strings::params].keyExists(strings::binary_data)) { - LOG4CXX_DEBUG(logger_, "Binary data is present. Trying to save it to: " - << binary_data_folder); - if (mobile_apis::Result::SUCCESS != + LOG4CXX_DEBUG( + logger_, + "Binary data is present. Trying to save it to: " << binary_data_folder); + if (mobile_apis::Result::SUCCESS != (ApplicationManagerImpl::instance()->SaveBinary( binary_data, binary_data_folder, file_name, 0))) { LOG4CXX_DEBUG(logger_, "Binary data can't be saved."); @@ -132,9 +130,11 @@ void SystemRequest::Run() { std::string app_full_file_path = binary_data_folder; app_full_file_path += file_name; - LOG4CXX_DEBUG(logger_, "Binary data is not present. Trying to find file " - << file_name << " within previously saved app file in " - << binary_data_folder); + LOG4CXX_DEBUG(logger_, + "Binary data is not present. Trying to find file " + << file_name + << " within previously saved app file in " + << binary_data_folder); const AppFile* file = application->GetFile(app_full_file_path); if (!file || !file->is_download_complete || @@ -147,7 +147,7 @@ void SystemRequest::Run() { (*message_)[strings::msg_params][strings::file_name].asString(); } if (!(mobile_apis::RequestType::HTTP == request_type && - 0 == origin_file_name.compare(kIVSU))) { + 0 == origin_file_name.compare(kIVSU))) { LOG4CXX_DEBUG(logger_, "Binary data required. Reject"); SendResponse(false, mobile_apis::Result::REJECTED); return; @@ -184,10 +184,10 @@ void SystemRequest::Run() { return; } - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); if (std::string::npos != file_name.find(kIVSU)) { - msg_params[strings::file_name] = file_name.c_str(); + msg_params[strings::file_name] = file_name; } else { msg_params[strings::file_name] = file_dst_path; } @@ -198,8 +198,8 @@ void SystemRequest::Run() { msg_params[strings::request_type] = (*message_)[strings::msg_params][strings::request_type]; SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest, - &msg_params, true); - + &msg_params, + true); } void SystemRequest::on_event(const event_engine::Event& event) { @@ -214,14 +214,13 @@ void SystemRequest::on_event(const event_engine::Event& event) { GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt())); - const bool result = - Compare<mobile_api::Result::eType, EQ, ONE>( - result_code, - mobile_api::Result::SUCCESS, - mobile_api::Result::WARNINGS); + const bool result = Compare<mobile_api::Result::eType, EQ, ONE>( + result_code, + mobile_api::Result::SUCCESS, + mobile_api::Result::WARNINGS); ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application(connection_key()); + ApplicationManagerImpl::instance()->application(connection_key()); if (!(application.valid())) { LOG4CXX_ERROR(logger_, "NULL pointer"); @@ -243,15 +242,15 @@ void SystemRequest::on_event(const event_engine::Event& event) { } bool SystemRequest::ValidateQueryAppData( - const smart_objects::SmartObject& data) const { + const smart_objects::SmartObject& data) const { if (!data.isValid()) { LOG4CXX_ERROR(logger_, "QueryApps response is not valid."); return false; } if (!data.keyExists(json::response)) { LOG4CXX_ERROR(logger_, - "QueryApps response does not contain '" - << json::response << "' parameter."); + "QueryApps response does not contain '" << json::response + << "' parameter."); return false; } smart_objects::SmartArray* obj_array = data[json::response].asArray(); diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc index 42262eb856..482e9d7b42 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc @@ -38,17 +38,18 @@ #include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "utils/custom_string.h" namespace application_manager { namespace commands { +namespace custom_str = utils::custom_string; + UpdateTurnListRequest::UpdateTurnListRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message) { -} + : CommandRequestImpl(message) {} -UpdateTurnListRequest::~UpdateTurnListRequest() { -} +UpdateTurnListRequest::~UpdateTurnListRequest() {} void UpdateTurnListRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -69,7 +70,7 @@ void UpdateTurnListRequest::Run() { return; } - //ProcessSoftButtons checks strings on the contents incorrect character + // ProcessSoftButtons checks strings on the contents incorrect character mobile_apis::Result::eType processing_result = MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); @@ -84,20 +85,20 @@ void UpdateTurnListRequest::Run() { smart_objects::SmartObject& turn_list_array = ((*message_)[strings::msg_params][strings::turn_list]); for (uint32_t i = 0; i < turn_list_array.length(); ++i) { - if((turn_list_array[i].keyExists(strings::turn_icon)) && - (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImage( - turn_list_array[i][strings::turn_icon], app))) { - LOG4CXX_ERROR( - logger_, - "MessageHelper::VerifyImage return INVALID_DATA"); + if ((turn_list_array[i].keyExists(strings::turn_icon)) && + (mobile_apis::Result::SUCCESS != + MessageHelper::VerifyImage(turn_list_array[i][strings::turn_icon], + app))) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyImage return INVALID_DATA"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } } } - smart_objects::SmartObject msg_params = smart_objects::SmartObject( - smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params = (*message_)[strings::msg_params]; if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { @@ -109,15 +110,15 @@ void UpdateTurnListRequest::Run() { for (uint32_t i = 0; i < msg_params[strings::turn_list].length(); ++i) { if (msg_params[strings::turn_list][i].keyExists(hmi_request::navi_text)) { - std::string navigation_text = - msg_params[strings::turn_list][i][hmi_request::navi_text].asString(); + const custom_str::CustomString& navigation_text = + msg_params[strings::turn_list][i][hmi_request::navi_text] + .asCustomString(); msg_params[strings::turn_list][i].erase(hmi_request::navi_text); - msg_params[strings::turn_list] - [i][hmi_request::navi_text][hmi_request::field_name] = - static_cast<int>(hmi_apis::Common_TextFieldName::turnText); - msg_params[strings::turn_list] - [i][hmi_request::navi_text][hmi_request::field_text] = - navigation_text; + msg_params[strings::turn_list][i][hmi_request::navi_text] + [hmi_request::field_name] = static_cast<int>( + hmi_apis::Common_TextFieldName::turnText); + msg_params[strings::turn_list][i][hmi_request::navi_text] + [hmi_request::field_text] = navigation_text; } } } @@ -125,14 +126,14 @@ void UpdateTurnListRequest::Run() { msg_params[strings::app_id] = app->app_id(); if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { - MessageHelper::SubscribeApplicationToSoftButton((*message_)[strings::msg_params], - app, function_id()); + MessageHelper::SubscribeApplicationToSoftButton( + (*message_)[strings::msg_params], app, function_id()); } if ((*message_)[strings::msg_params].keyExists(strings::turn_list) || (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { - SendHMIRequest(hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, - true); + SendHMIRequest( + hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, true); } else { // conditional mandatory LOG4CXX_ERROR(logger_, "INVALID_DATA!"); @@ -150,20 +151,20 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) { mobile_apis::Result::eType result_code = static_cast<mobile_apis::Result::eType>( - message[strings::params][hmi_response::code].asInt()); + message[strings::params][hmi_response::code].asInt()); HMICapabilities& hmi_capabilities = ApplicationManagerImpl::instance()->hmi_capabilities(); - bool result = (mobile_apis::Result::SUCCESS == result_code) || + bool result = + (mobile_apis::Result::SUCCESS == result_code) || ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && - (hmi_capabilities.is_ui_cooperating())); - + (hmi_capabilities.is_ui_cooperating())); SendResponse(result, result_code, NULL, &(message[strings::msg_params])); break; } default: { - LOG4CXX_ERROR(logger_,"Received unknown event" << event.id()); + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); break; } } @@ -177,10 +178,10 @@ bool UpdateTurnListRequest::CheckTurnListArray() { } for (int32_t i = 0; i < length; ++i) { - if (!((*message_)[strings::msg_params][strings::turn_list][i]. - keyExists(hmi_request::navi_text)) && - !((*message_)[strings::msg_params][strings::turn_list][i]. - keyExists(strings::turn_icon))) { + if (!((*message_)[strings::msg_params][strings::turn_list][i].keyExists( + hmi_request::navi_text)) && + !((*message_)[strings::msg_params][strings::turn_list][i].keyExists( + strings::turn_icon))) { return false; } } @@ -202,7 +203,8 @@ bool UpdateTurnListRequest::IsWhiteSpaceExist() { if ((*it_tl).keyExists(strings::navigation_text)) { str = (*it_tl)[strings::navigation_text].asCharArray(); if (!CheckSyntax(str)) { - LOG4CXX_ERROR(logger_, + LOG4CXX_ERROR( + logger_, "Invalid turn_list navigation_text text syntax check failed"); return true; } @@ -211,12 +213,11 @@ bool UpdateTurnListRequest::IsWhiteSpaceExist() { if ((*it_tl).keyExists(strings::turn_icon)) { str = (*it_tl)[strings::turn_icon][strings::value].asCharArray(); if (!CheckSyntax(str)) { - LOG4CXX_ERROR(logger_, - "Invalid turn_list turn_icon value syntax check failed"); + LOG4CXX_ERROR( + logger_, "Invalid turn_list turn_icon value syntax check failed"); return true; } } - } } return false; diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities.cc index ad43e42ac7..a5a35daa36 100644 --- a/src/components/application_manager/src/hmi_capabilities.cc +++ b/src/components/application_manager/src/hmi_capabilities.cc @@ -51,133 +51,126 @@ namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters; CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") -std::map<std::string, hmi_apis::Common_VrCapabilities::eType> vr_enum_capabilities = -{ - {"TEXT", hmi_apis::Common_VrCapabilities::VR_TEXT} -}; - -std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name = -{ - {"OK" , hmi_apis::Common_ButtonName::OK}, - {"SEEKLEFT" , hmi_apis::Common_ButtonName::SEEKLEFT}, - {"SEEKRIGHT" , hmi_apis::Common_ButtonName::SEEKRIGHT}, - {"TUNEUP" , hmi_apis::Common_ButtonName::TUNEUP}, - {"TUNEDOWN" , hmi_apis::Common_ButtonName::TUNEDOWN}, - {"PRESET_0" , hmi_apis::Common_ButtonName::PRESET_0}, - {"PRESET_1" , hmi_apis::Common_ButtonName::PRESET_1}, - {"PRESET_2" , hmi_apis::Common_ButtonName::PRESET_2}, - {"PRESET_3" , hmi_apis::Common_ButtonName::PRESET_3}, - {"PRESET_4" , hmi_apis::Common_ButtonName::PRESET_4}, - {"PRESET_5" , hmi_apis::Common_ButtonName::PRESET_5}, - {"PRESET_6" , hmi_apis::Common_ButtonName::PRESET_6}, - {"PRESET_7" , hmi_apis::Common_ButtonName::PRESET_7}, - {"PRESET_8" , hmi_apis::Common_ButtonName::PRESET_8}, - {"PRESET_9" , hmi_apis::Common_ButtonName::PRESET_9}, - {"CUSTOM_BUTTON" , hmi_apis::Common_ButtonName::CUSTOM_BUTTON}, - {"SEARCH" , hmi_apis::Common_ButtonName::SEARCH}, +std::map<std::string, hmi_apis::Common_VrCapabilities::eType> + vr_enum_capabilities = {{"TEXT", hmi_apis::Common_VrCapabilities::VR_TEXT}}; + +std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name = { + {"OK", hmi_apis::Common_ButtonName::OK}, + {"SEEKLEFT", hmi_apis::Common_ButtonName::SEEKLEFT}, + {"SEEKRIGHT", hmi_apis::Common_ButtonName::SEEKRIGHT}, + {"TUNEUP", hmi_apis::Common_ButtonName::TUNEUP}, + {"TUNEDOWN", hmi_apis::Common_ButtonName::TUNEDOWN}, + {"PRESET_0", hmi_apis::Common_ButtonName::PRESET_0}, + {"PRESET_1", hmi_apis::Common_ButtonName::PRESET_1}, + {"PRESET_2", hmi_apis::Common_ButtonName::PRESET_2}, + {"PRESET_3", hmi_apis::Common_ButtonName::PRESET_3}, + {"PRESET_4", hmi_apis::Common_ButtonName::PRESET_4}, + {"PRESET_5", hmi_apis::Common_ButtonName::PRESET_5}, + {"PRESET_6", hmi_apis::Common_ButtonName::PRESET_6}, + {"PRESET_7", hmi_apis::Common_ButtonName::PRESET_7}, + {"PRESET_8", hmi_apis::Common_ButtonName::PRESET_8}, + {"PRESET_9", hmi_apis::Common_ButtonName::PRESET_9}, + {"CUSTOM_BUTTON", hmi_apis::Common_ButtonName::CUSTOM_BUTTON}, + {"SEARCH", hmi_apis::Common_ButtonName::SEARCH}, }; -std::map<std::string, hmi_apis::Common_TextFieldName::eType> text_fields_enum_name = -{ +std::map<std::string, + hmi_apis::Common_TextFieldName::eType> text_fields_enum_name = { {"mainField1", hmi_apis::Common_TextFieldName::mainField1}, {"mainField2", hmi_apis::Common_TextFieldName::mainField2}, {"mainField3", hmi_apis::Common_TextFieldName::mainField3}, {"mainField4", hmi_apis::Common_TextFieldName::mainField4}, - {"statusBar" , hmi_apis::Common_TextFieldName::statusBar}, + {"statusBar", hmi_apis::Common_TextFieldName::statusBar}, {"mediaClock", hmi_apis::Common_TextFieldName::mediaClock}, {"mediaTrack", hmi_apis::Common_TextFieldName::mediaTrack}, {"alertText1", hmi_apis::Common_TextFieldName::alertText1}, {"alertText2", hmi_apis::Common_TextFieldName::alertText2}, {"alertText3", hmi_apis::Common_TextFieldName::alertText3}, - {"scrollableMessageBody" , hmi_apis::Common_TextFieldName::scrollableMessageBody}, - {"initialInteractionText", hmi_apis::Common_TextFieldName::initialInteractionText}, - {"navigationText1" , hmi_apis::Common_TextFieldName::navigationText1}, - {"navigationText2" , hmi_apis::Common_TextFieldName::navigationText2}, - {"ETA" , hmi_apis::Common_TextFieldName::ETA}, - {"totalDistance" , hmi_apis::Common_TextFieldName::totalDistance}, - {"audioPassThruDisplayText1", hmi_apis::Common_TextFieldName::audioPassThruDisplayText1}, - {"audioPassThruDisplayText2", hmi_apis::Common_TextFieldName::audioPassThruDisplayText2}, - {"sliderHeader" , hmi_apis::Common_TextFieldName::sliderHeader}, - {"sliderFooter" , hmi_apis::Common_TextFieldName::sliderFooter}, - {"notificationText" , hmi_apis::Common_TextFieldName::notificationText}, - {"menuName" , hmi_apis::Common_TextFieldName::menuName}, - {"secondaryText" , hmi_apis::Common_TextFieldName::secondaryText}, - {"tertiaryText" , hmi_apis::Common_TextFieldName::tertiaryText}, + {"scrollableMessageBody", + hmi_apis::Common_TextFieldName::scrollableMessageBody}, + {"initialInteractionText", + hmi_apis::Common_TextFieldName::initialInteractionText}, + {"navigationText1", hmi_apis::Common_TextFieldName::navigationText1}, + {"navigationText2", hmi_apis::Common_TextFieldName::navigationText2}, + {"ETA", hmi_apis::Common_TextFieldName::ETA}, + {"totalDistance", hmi_apis::Common_TextFieldName::totalDistance}, + {"audioPassThruDisplayText1", + hmi_apis::Common_TextFieldName::audioPassThruDisplayText1}, + {"audioPassThruDisplayText2", + hmi_apis::Common_TextFieldName::audioPassThruDisplayText2}, + {"sliderHeader", hmi_apis::Common_TextFieldName::sliderHeader}, + {"sliderFooter", hmi_apis::Common_TextFieldName::sliderFooter}, + {"notificationText", hmi_apis::Common_TextFieldName::notificationText}, + {"menuName", hmi_apis::Common_TextFieldName::menuName}, + {"secondaryText", hmi_apis::Common_TextFieldName::secondaryText}, + {"tertiaryText", hmi_apis::Common_TextFieldName::tertiaryText}, {"timeToDestination", hmi_apis::Common_TextFieldName::timeToDestination}, - {"locationName" , hmi_apis::Common_TextFieldName::locationName}, - {"locationDescription", hmi_apis::Common_TextFieldName::locationDescription}, - {"addressLines" , hmi_apis::Common_TextFieldName::turnText}, - {"turnText" , hmi_apis::Common_TextFieldName::addressLines}, - {"phoneNumber" , hmi_apis::Common_TextFieldName::phoneNumber}, - {"turnText" , hmi_apis::Common_TextFieldName::turnText}, - {"menuTitle" , hmi_apis::Common_TextFieldName::menuTitle}, - {"navigationText" , hmi_apis::Common_TextFieldName::navigationText}, + {"locationName", hmi_apis::Common_TextFieldName::locationName}, + {"locationDescription", + hmi_apis::Common_TextFieldName::locationDescription}, + {"addressLines", hmi_apis::Common_TextFieldName::turnText}, + {"turnText", hmi_apis::Common_TextFieldName::addressLines}, + {"phoneNumber", hmi_apis::Common_TextFieldName::phoneNumber}, + {"turnText", hmi_apis::Common_TextFieldName::turnText}, + {"menuTitle", hmi_apis::Common_TextFieldName::menuTitle}, + {"navigationText", hmi_apis::Common_TextFieldName::navigationText}, }; -std::map<std::string, hmi_apis::Common_MediaClockFormat::eType> media_clock_enum_name = -{ - {"CLOCK1" , hmi_apis::Common_MediaClockFormat::CLOCK1}, - {"CLOCK2" , hmi_apis::Common_MediaClockFormat::CLOCK2}, - {"CLOCK3" , hmi_apis::Common_MediaClockFormat::CLOCK3}, - {"CLOCKTEXT1", hmi_apis::Common_MediaClockFormat::CLOCKTEXT1}, - {"CLOCKTEXT2", hmi_apis::Common_MediaClockFormat::CLOCKTEXT2}, - {"CLOCKTEXT3", hmi_apis::Common_MediaClockFormat::CLOCKTEXT3}, - {"CLOCKTEXT4", hmi_apis::Common_MediaClockFormat::CLOCKTEXT4}, +std::map<std::string, hmi_apis::Common_MediaClockFormat::eType> + media_clock_enum_name = { + {"CLOCK1", hmi_apis::Common_MediaClockFormat::CLOCK1}, + {"CLOCK2", hmi_apis::Common_MediaClockFormat::CLOCK2}, + {"CLOCK3", hmi_apis::Common_MediaClockFormat::CLOCK3}, + {"CLOCKTEXT1", hmi_apis::Common_MediaClockFormat::CLOCKTEXT1}, + {"CLOCKTEXT2", hmi_apis::Common_MediaClockFormat::CLOCKTEXT2}, + {"CLOCKTEXT3", hmi_apis::Common_MediaClockFormat::CLOCKTEXT3}, + {"CLOCKTEXT4", hmi_apis::Common_MediaClockFormat::CLOCKTEXT4}, }; -std::map<std::string, hmi_apis::Common_ImageType::eType> image_type_enum = -{ - {"STATIC" , hmi_apis::Common_ImageType::STATIC}, - {"DYNAMIC", hmi_apis::Common_ImageType::DYNAMIC} -}; +std::map<std::string, hmi_apis::Common_ImageType::eType> image_type_enum = { + {"STATIC", hmi_apis::Common_ImageType::STATIC}, + {"DYNAMIC", hmi_apis::Common_ImageType::DYNAMIC}}; std::map<std::string, hmi_apis::Common_SamplingRate::eType> sampling_rate_enum = -{ - {"8KHZ" , hmi_apis::Common_SamplingRate::RATE_8KHZ}, - {"16KHZ", hmi_apis::Common_SamplingRate::RATE_16KHZ}, - {"22KHZ", hmi_apis::Common_SamplingRate::RATE_22KHZ}, - {"44KHZ", hmi_apis::Common_SamplingRate::RATE_44KHZ} -}; - -std::map<std::string, hmi_apis::Common_BitsPerSample::eType> bit_per_sample_enum = -{ - {"RATE_8_BIT", hmi_apis::Common_BitsPerSample::RATE_8_BIT}, - {"RATE_16_BIT", hmi_apis::Common_BitsPerSample::RATE_16_BIT} -}; - -std::map<std::string, hmi_apis::Common_AudioType::eType> audio_type_enum = -{ - {"PCM", hmi_apis::Common_AudioType::PCM} -}; - -std::map<std::string, hmi_apis::Common_HmiZoneCapabilities::eType> hmi_zone_enum = -{ - {"FRONT", hmi_apis::Common_HmiZoneCapabilities::FRONT}, - {"BACK", hmi_apis::Common_HmiZoneCapabilities::BACK}, + {{"8KHZ", hmi_apis::Common_SamplingRate::RATE_8KHZ}, + {"16KHZ", hmi_apis::Common_SamplingRate::RATE_16KHZ}, + {"22KHZ", hmi_apis::Common_SamplingRate::RATE_22KHZ}, + {"44KHZ", hmi_apis::Common_SamplingRate::RATE_44KHZ}}; + +std::map<std::string, hmi_apis::Common_BitsPerSample::eType> + bit_per_sample_enum = { + {"RATE_8_BIT", hmi_apis::Common_BitsPerSample::RATE_8_BIT}, + {"RATE_16_BIT", hmi_apis::Common_BitsPerSample::RATE_16_BIT}}; + +std::map<std::string, hmi_apis::Common_AudioType::eType> audio_type_enum = { + {"PCM", hmi_apis::Common_AudioType::PCM}}; + +std::map<std::string, hmi_apis::Common_HmiZoneCapabilities::eType> + hmi_zone_enum = { + {"FRONT", hmi_apis::Common_HmiZoneCapabilities::FRONT}, + {"BACK", hmi_apis::Common_HmiZoneCapabilities::BACK}, }; const std::map<std::string, hmi_apis::Common_ImageFieldName::eType> -image_field_name_enum = -{ - {"softButtonImage", hmi_apis::Common_ImageFieldName::softButtonImage}, - {"choiceImage", hmi_apis::Common_ImageFieldName::choiceImage}, - {"choiceSecondaryImage", hmi_apis::Common_ImageFieldName::choiceSecondaryImage}, - {"vrHelpItem", hmi_apis::Common_ImageFieldName::vrHelpItem}, - {"turnIcon", hmi_apis::Common_ImageFieldName::turnIcon}, - {"menuIcon", hmi_apis::Common_ImageFieldName::menuIcon}, - {"cmdIcon", hmi_apis::Common_ImageFieldName::cmdIcon}, - {"appIcon", hmi_apis::Common_ImageFieldName::appIcon}, - {"graphic", hmi_apis::Common_ImageFieldName::graphic}, - {"showConstantTBTIcon", hmi_apis::Common_ImageFieldName::showConstantTBTIcon}, - {"showConstantTBTNextTurnIcon", - hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon}, - {"locationImage", - hmi_apis::Common_ImageFieldName::locationImage} -}; - -const std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum = -{ + image_field_name_enum = { + {"softButtonImage", hmi_apis::Common_ImageFieldName::softButtonImage}, + {"choiceImage", hmi_apis::Common_ImageFieldName::choiceImage}, + {"choiceSecondaryImage", + hmi_apis::Common_ImageFieldName::choiceSecondaryImage}, + {"vrHelpItem", hmi_apis::Common_ImageFieldName::vrHelpItem}, + {"turnIcon", hmi_apis::Common_ImageFieldName::turnIcon}, + {"menuIcon", hmi_apis::Common_ImageFieldName::menuIcon}, + {"cmdIcon", hmi_apis::Common_ImageFieldName::cmdIcon}, + {"appIcon", hmi_apis::Common_ImageFieldName::appIcon}, + {"graphic", hmi_apis::Common_ImageFieldName::graphic}, + {"showConstantTBTIcon", + hmi_apis::Common_ImageFieldName::showConstantTBTIcon}, + {"showConstantTBTNextTurnIcon", + hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon}, + {"locationImage", hmi_apis::Common_ImageFieldName::locationImage}}; + +const std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum = { {"GRAPHIC_BMP", hmi_apis::Common_FileType::GRAPHIC_BMP}, {"GRAPHIC_JPEG", hmi_apis::Common_FileType::GRAPHIC_JPEG}, {"GRAPHIC_PNG", hmi_apis::Common_FileType::GRAPHIC_PNG}, @@ -185,63 +178,58 @@ const std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum = {"AUDIO_MP3", hmi_apis::Common_FileType::AUDIO_MP3}, {"AUDIO_AAC", hmi_apis::Common_FileType::AUDIO_AAC}, {"BINARY", hmi_apis::Common_FileType::BINARY}, - {"JSON", hmi_apis::Common_FileType::JSON} -}; - -const std::map<std::string, hmi_apis::Common_DisplayType::eType> display_type_enum = -{ - {"CID", hmi_apis::Common_DisplayType::CID}, - {"TYPE2", hmi_apis::Common_DisplayType::TYPE2}, - {"TYPE5", hmi_apis::Common_DisplayType::TYPE5}, - {"NGN", hmi_apis::Common_DisplayType::NGN}, - {"GEN2_8_DMA", hmi_apis::Common_DisplayType::GEN2_8_DMA}, - {"GEN2_6_DMA", hmi_apis::Common_DisplayType::GEN2_6_DMA}, - {"MFD3", hmi_apis::Common_DisplayType::MFD3}, - {"MFD4", hmi_apis::Common_DisplayType::MFD4}, - {"MFD5", hmi_apis::Common_DisplayType::MFD5}, - {"GEN3_8_INCH", hmi_apis::Common_DisplayType::GEN3_8_INCH} -}; - -const std::map<std::string, hmi_apis::Common_CharacterSet::eType> character_set_enum = -{ - {"TYPE2SET" , hmi_apis::Common_CharacterSet::TYPE2SET}, - {"TYPE5SET" , hmi_apis::Common_CharacterSet::TYPE5SET}, - {"CID1SET" , hmi_apis::Common_CharacterSet::CID1SET}, - {"CID2SET" , hmi_apis::Common_CharacterSet::CID2SET} -}; + {"JSON", hmi_apis::Common_FileType::JSON}}; + +const std::map<std::string, hmi_apis::Common_DisplayType::eType> + display_type_enum = { + {"CID", hmi_apis::Common_DisplayType::CID}, + {"TYPE2", hmi_apis::Common_DisplayType::TYPE2}, + {"TYPE5", hmi_apis::Common_DisplayType::TYPE5}, + {"NGN", hmi_apis::Common_DisplayType::NGN}, + {"GEN2_8_DMA", hmi_apis::Common_DisplayType::GEN2_8_DMA}, + {"GEN2_6_DMA", hmi_apis::Common_DisplayType::GEN2_6_DMA}, + {"MFD3", hmi_apis::Common_DisplayType::MFD3}, + {"MFD4", hmi_apis::Common_DisplayType::MFD4}, + {"MFD5", hmi_apis::Common_DisplayType::MFD5}, + {"GEN3_8_INCH", hmi_apis::Common_DisplayType::GEN3_8_INCH}}; + +const std::map<std::string, hmi_apis::Common_CharacterSet::eType> + character_set_enum = {{"TYPE2SET", hmi_apis::Common_CharacterSet::TYPE2SET}, + {"TYPE5SET", hmi_apis::Common_CharacterSet::TYPE5SET}, + {"CID1SET", hmi_apis::Common_CharacterSet::CID1SET}, + {"CID2SET", hmi_apis::Common_CharacterSet::CID2SET}}; HMICapabilities::HMICapabilities(ApplicationManagerImpl* const app_mngr) - : is_vr_cooperating_(false), - is_tts_cooperating_(false), - is_ui_cooperating_(false), - is_navi_cooperating_(false), - is_ivi_cooperating_(false), - is_vr_ready_response_recieved_(false), - is_tts_ready_response_recieved_(false), - is_ui_ready_response_recieved_(false), - is_navi_ready_response_recieved_(false), - is_ivi_ready_response_recieved_(false), - attenuated_supported_(false), - ui_language_(hmi_apis::Common_Language::INVALID_ENUM), - vr_language_(hmi_apis::Common_Language::INVALID_ENUM), - tts_language_(hmi_apis::Common_Language::INVALID_ENUM), - vehicle_type_(NULL), - ui_supported_languages_(NULL), - tts_supported_languages_(NULL), - vr_supported_languages_(NULL), - display_capabilities_(NULL), - hmi_zone_capabilities_(NULL), - soft_buttons_capabilities_(NULL), - button_capabilities_(NULL), - preset_bank_capabilities_(NULL), - vr_capabilities_(NULL), - speech_capabilities_(NULL), - audio_pass_thru_capabilities_(NULL), - prerecorded_speech_(NULL), - is_navigation_supported_(false), - is_phone_call_supported_(false), - app_mngr_(app_mngr) { - + : is_vr_cooperating_(false) + , is_tts_cooperating_(false) + , is_ui_cooperating_(false) + , is_navi_cooperating_(false) + , is_ivi_cooperating_(false) + , is_vr_ready_response_recieved_(false) + , is_tts_ready_response_recieved_(false) + , is_ui_ready_response_recieved_(false) + , is_navi_ready_response_recieved_(false) + , is_ivi_ready_response_recieved_(false) + , attenuated_supported_(false) + , ui_language_(hmi_apis::Common_Language::INVALID_ENUM) + , vr_language_(hmi_apis::Common_Language::INVALID_ENUM) + , tts_language_(hmi_apis::Common_Language::INVALID_ENUM) + , vehicle_type_(NULL) + , ui_supported_languages_(NULL) + , tts_supported_languages_(NULL) + , vr_supported_languages_(NULL) + , display_capabilities_(NULL) + , hmi_zone_capabilities_(NULL) + , soft_buttons_capabilities_(NULL) + , button_capabilities_(NULL) + , preset_bank_capabilities_(NULL) + , vr_capabilities_(NULL) + , speech_capabilities_(NULL) + , audio_pass_thru_capabilities_(NULL) + , prerecorded_speech_(NULL) + , is_navigation_supported_(false) + , is_phone_call_supported_(false) + , app_mngr_(app_mngr) { if (false == load_capabilities_from_file()) { LOG4CXX_ERROR(logger_, "file hmi_capabilities.json was not loaded"); } else { @@ -282,9 +270,9 @@ HMICapabilities::~HMICapabilities() { bool HMICapabilities::is_hmi_capabilities_initialized() const { bool result = true; - if (is_vr_ready_response_recieved_ && is_tts_ready_response_recieved_ - && is_ui_ready_response_recieved_ && is_navi_ready_response_recieved_ - && is_ivi_ready_response_recieved_) { + if (is_vr_ready_response_recieved_ && is_tts_ready_response_recieved_ && + is_ui_ready_response_recieved_ && is_navi_ready_response_recieved_ && + is_ivi_ready_response_recieved_) { if (is_vr_cooperating_) { if ((!vr_supported_languages_) || (hmi_apis::Common_Language::INVALID_ENUM == vr_language_)) { @@ -300,9 +288,9 @@ bool HMICapabilities::is_hmi_capabilities_initialized() const { } if (is_ui_cooperating_) { - if ((!ui_supported_languages_) || + if ((!ui_supported_languages_) || (hmi_apis::Common_Language::INVALID_ENUM == ui_language_)) { - result = false; + result = false; } } @@ -324,8 +312,8 @@ bool HMICapabilities::VerifyImageType(int32_t image_type) const { } if (display_capabilities_->keyExists(hmi_response::image_capabilities)) { - const smart_objects::SmartObject& image_caps = display_capabilities_ - ->getElement(hmi_response::image_capabilities); + const smart_objects::SmartObject& image_caps = + display_capabilities_->getElement(hmi_response::image_capabilities); for (uint32_t i = 0; i < image_caps.length(); ++i) { if (image_caps.getElement(i).asInt() == image_type) { return true; @@ -341,13 +329,16 @@ void HMICapabilities::set_is_vr_cooperating(bool value) { is_vr_cooperating_ = value; if (is_vr_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_language( - MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::VR_GetLanguage)); app_mngr_->ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( - MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetSupportedLanguages)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::VR_GetSupportedLanguages)); app_mngr_->ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( - MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetCapabilities)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::VR_GetCapabilities)); app_mngr_->ManageHMICommand(get_capabilities); } } @@ -357,16 +348,16 @@ void HMICapabilities::set_is_tts_cooperating(bool value) { is_tts_cooperating_ = value; if (is_tts_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_language( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::TTS_GetLanguage)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::TTS_GetLanguage)); app_mngr_->ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::TTS_GetSupportedLanguages)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::TTS_GetSupportedLanguages)); app_mngr_->ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::TTS_GetCapabilities)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::TTS_GetCapabilities)); app_mngr_->ManageHMICommand(get_capabilities); } } @@ -376,16 +367,16 @@ void HMICapabilities::set_is_ui_cooperating(bool value) { is_ui_cooperating_ = value; if (is_ui_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_language( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::UI_GetLanguage)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::UI_GetLanguage)); app_mngr_->ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::UI_GetSupportedLanguages)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::UI_GetSupportedLanguages)); app_mngr_->ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::UI_GetCapabilities)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::UI_GetCapabilities)); app_mngr_->ManageHMICommand(get_capabilities); } } @@ -400,8 +391,8 @@ void HMICapabilities::set_is_ivi_cooperating(bool value) { is_ivi_cooperating_ = value; if (is_ivi_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_type( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::VehicleInfo_GetVehicleType)); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::VehicleInfo_GetVehicleType)); app_mngr_->ManageHMICommand(get_type); } } @@ -411,17 +402,17 @@ void HMICapabilities::set_attenuated_supported(bool state) { } void HMICapabilities::set_active_ui_language( - const hmi_apis::Common_Language::eType& language) { + const hmi_apis::Common_Language::eType& language) { ui_language_ = language; } void HMICapabilities::set_active_vr_language( - const hmi_apis::Common_Language::eType& language) { + const hmi_apis::Common_Language::eType& language) { vr_language_ = language; } void HMICapabilities::set_active_tts_language( - const hmi_apis::Common_Language::eType& language) { + const hmi_apis::Common_Language::eType& language) { tts_language_ = language; } @@ -438,8 +429,8 @@ void HMICapabilities::set_tts_supported_languages( if (tts_supported_languages_) { delete tts_supported_languages_; } - tts_supported_languages_ = new smart_objects::SmartObject( - supported_languages); + tts_supported_languages_ = + new smart_objects::SmartObject(supported_languages); } void HMICapabilities::set_vr_supported_languages( @@ -463,8 +454,8 @@ void HMICapabilities::set_hmi_zone_capabilities( if (hmi_zone_capabilities_) { delete hmi_zone_capabilities_; } - hmi_zone_capabilities_ = new smart_objects::SmartObject( - hmi_zone_capabilities); + hmi_zone_capabilities_ = + new smart_objects::SmartObject(hmi_zone_capabilities); } void HMICapabilities::set_soft_button_capabilities( @@ -472,8 +463,8 @@ void HMICapabilities::set_soft_button_capabilities( if (soft_buttons_capabilities_) { delete soft_buttons_capabilities_; } - soft_buttons_capabilities_ = new smart_objects::SmartObject( - soft_button_capabilities); + soft_buttons_capabilities_ = + new smart_objects::SmartObject(soft_button_capabilities); } void HMICapabilities::set_button_capabilities( @@ -505,8 +496,8 @@ void HMICapabilities::set_audio_pass_thru_capabilities( if (audio_pass_thru_capabilities_) { delete audio_pass_thru_capabilities_; } - audio_pass_thru_capabilities_ = new smart_objects::SmartObject( - audio_pass_thru_capabilities); + audio_pass_thru_capabilities_ = + new smart_objects::SmartObject(audio_pass_thru_capabilities); } void HMICapabilities::set_preset_bank_capabilities( @@ -514,12 +505,12 @@ void HMICapabilities::set_preset_bank_capabilities( if (preset_bank_capabilities_) { delete preset_bank_capabilities_; } - preset_bank_capabilities_ = new smart_objects::SmartObject( - preset_bank_capabilities); + preset_bank_capabilities_ = + new smart_objects::SmartObject(preset_bank_capabilities); } void HMICapabilities::set_vehicle_type( - const smart_objects::SmartObject& vehicle_type) { + const smart_objects::SmartObject& vehicle_type) { if (vehicle_type_) { delete vehicle_type_; } @@ -527,7 +518,7 @@ void HMICapabilities::set_vehicle_type( } void HMICapabilities::set_prerecorded_speech( - const smart_objects::SmartObject& prerecorded_speech) { + const smart_objects::SmartObject& prerecorded_speech) { if (prerecorded_speech_) { delete prerecorded_speech_; prerecorded_speech_ = NULL; @@ -561,9 +552,8 @@ bool HMICapabilities::load_capabilities_from_file() { } try { - Json::Reader reader_; - Json::Value root_json; + Json::Value root_json; bool result = reader_.parse(json_string, root_json, false); if (!result) { @@ -589,13 +579,15 @@ bool HMICapabilities::load_capabilities_from_file() { if (check_existing_json_member(ui, "displayCapabilities")) { smart_objects::SmartObject display_capabilities_so; Json::Value display_capabilities = ui.get("displayCapabilities", ""); - Formatters::CFormatterJsonBase::jsonValueToObj( - display_capabilities, display_capabilities_so); + Formatters::CFormatterJsonBase::jsonValueToObj(display_capabilities, + display_capabilities_so); if (display_capabilities_so.keyExists(hmi_response::display_type)) { - std::map<std::string, hmi_apis::Common_DisplayType::eType> - ::const_iterator it = display_type_enum.find( - (display_capabilities_so[hmi_response::display_type]).asString()); + std::map<std::string, + hmi_apis::Common_DisplayType::eType>::const_iterator it = + display_type_enum.find( + (display_capabilities_so[hmi_response::display_type]) + .asString()); display_capabilities_so.erase(hmi_response::display_type); if (display_type_enum.end() != it) { display_capabilities_so[hmi_response::display_type] = it->second; @@ -607,31 +599,36 @@ bool HMICapabilities::load_capabilities_from_file() { display_capabilities_so[hmi_response::text_fields].length(); for (uint32_t i = 0; i < len; ++i) { - - if ((display_capabilities_so - [hmi_response::text_fields][i]).keyExists(strings::name)) { - std::map<std::string, hmi_apis::Common_TextFieldName::eType> - ::const_iterator it_text_field_name = text_fields_enum_name.find( - display_capabilities_so[hmi_response::text_fields] - [i][strings::name].asString()); - display_capabilities_so[hmi_response::text_fields][i].erase(strings::name); + if ((display_capabilities_so[hmi_response::text_fields][i]) + .keyExists(strings::name)) { + std::map<std::string, + hmi_apis::Common_TextFieldName::eType>::const_iterator + it_text_field_name = text_fields_enum_name.find( + display_capabilities_so[hmi_response::text_fields][i] + [strings::name] + .asString()); + display_capabilities_so[hmi_response::text_fields][i].erase( + strings::name); if (text_fields_enum_name.end() != it_text_field_name) { - display_capabilities_so[hmi_response::text_fields] - [i][strings::name] = it_text_field_name->second; + display_capabilities_so[hmi_response::text_fields][i] + [strings::name] = + it_text_field_name->second; } } - if ((display_capabilities_so - [hmi_response::text_fields][i]).keyExists(strings::character_set)) { - std::map<std::string, hmi_apis::Common_CharacterSet::eType> - ::const_iterator it_characte_set = character_set_enum.find( - display_capabilities_so[hmi_response::text_fields] - [i][strings::character_set].asString()); - display_capabilities_so - [hmi_response::text_fields][i].erase(strings::character_set); + if ((display_capabilities_so[hmi_response::text_fields][i]) + .keyExists(strings::character_set)) { + std::map<std::string, + hmi_apis::Common_CharacterSet::eType>::const_iterator + it_characte_set = character_set_enum.find( + display_capabilities_so[hmi_response::text_fields][i] + [strings::character_set] + .asString()); + display_capabilities_so[hmi_response::text_fields][i].erase( + strings::character_set); if (character_set_enum.end() != it_characte_set) { - display_capabilities_so - [hmi_response::text_fields][i][strings::character_set] = - it_characte_set->second; + display_capabilities_so[hmi_response::text_fields][i] + [strings::character_set] = + it_characte_set->second; } } } @@ -642,23 +639,28 @@ bool HMICapabilities::load_capabilities_from_file() { display_capabilities_so[hmi_response::image_fields]; for (uint32_t i = 0; i < array_image_fields.length(); ++i) { if (array_image_fields[i].keyExists(strings::name)) { - std::map<std::string, hmi_apis::Common_ImageFieldName::eType> - ::const_iterator it = image_field_name_enum.find( - (array_image_fields[i][strings::name]).asString()); + std::map<std::string, + hmi_apis::Common_ImageFieldName::eType>::const_iterator + it = image_field_name_enum.find( + (array_image_fields[i][strings::name]).asString()); array_image_fields[i].erase(strings::name); if (image_field_name_enum.end() != it) { array_image_fields[i][strings::name] = it->second; } } - if (array_image_fields[i].keyExists(strings::image_type_supported)) { + if (array_image_fields[i].keyExists( + strings::image_type_supported)) { smart_objects::SmartObject& image_type_supported_array = array_image_fields[i][strings::image_type_supported]; smart_objects::SmartObject image_type_supported_enum( smart_objects::SmartType_Array); - for (uint32_t k = 0, j = 0; k < image_type_supported_array.length(); ++k) { - std::map<std::string, hmi_apis::Common_FileType::eType> - ::const_iterator it = file_type_enum.find( - (image_type_supported_array[k]).asString()); + for (uint32_t k = 0, j = 0; + k < image_type_supported_array.length(); + ++k) { + std::map<std::string, + hmi_apis::Common_FileType::eType>::const_iterator it = + file_type_enum.find( + (image_type_supported_array[k]).asString()); if (file_type_enum.end() != it) { image_type_supported_enum[j++] = it->second; } @@ -669,15 +671,18 @@ bool HMICapabilities::load_capabilities_from_file() { } } } - if (display_capabilities_so.keyExists(hmi_response::media_clock_formats)) { + if (display_capabilities_so.keyExists( + hmi_response::media_clock_formats)) { smart_objects::SmartObject& media_clock_formats_array = display_capabilities_so[hmi_response::media_clock_formats]; smart_objects::SmartObject media_clock_formats_enum( smart_objects::SmartType_Array); - for (uint32_t i = 0, j = 0; i < media_clock_formats_array.length(); ++i) { - std::map<std::string, hmi_apis::Common_MediaClockFormat::eType> - ::const_iterator it = media_clock_enum_name.find( - (media_clock_formats_array[i]).asString()); + for (uint32_t i = 0, j = 0; i < media_clock_formats_array.length(); + ++i) { + std::map<std::string, + hmi_apis::Common_MediaClockFormat::eType>::const_iterator + it = media_clock_enum_name.find( + (media_clock_formats_array[i]).asString()); if (media_clock_enum_name.end() != it) { media_clock_formats_enum[j++] = it->second; } @@ -687,15 +692,17 @@ bool HMICapabilities::load_capabilities_from_file() { media_clock_formats_enum; } - if (display_capabilities_so.keyExists(hmi_response::image_capabilities)) { + if (display_capabilities_so.keyExists( + hmi_response::image_capabilities)) { smart_objects::SmartObject& image_capabilities_array = display_capabilities_so[hmi_response::image_capabilities]; smart_objects::SmartObject image_capabilities_enum( smart_objects::SmartType_Array); - for (uint32_t i = 0, j = 0; i < image_capabilities_array.length(); ++i) { - std::map<std::string, hmi_apis::Common_ImageType::eType> - ::const_iterator it = image_type_enum.find( - (image_capabilities_array[i]).asString()); + for (uint32_t i = 0, j = 0; i < image_capabilities_array.length(); + ++i) { + std::map<std::string, + hmi_apis::Common_ImageType::eType>::const_iterator it = + image_type_enum.find((image_capabilities_array[i]).asString()); if (image_type_enum.end() != it) { image_capabilities_enum[j++] = it->second; } @@ -708,25 +715,30 @@ bool HMICapabilities::load_capabilities_from_file() { } if (check_existing_json_member(ui, "audioPassThruCapabilities")) { - Json::Value audio_capabilities = ui.get("audioPassThruCapabilities", ""); + Json::Value audio_capabilities = + ui.get("audioPassThruCapabilities", ""); smart_objects::SmartObject audio_capabilities_so = smart_objects::SmartObject(smart_objects::SmartType_Array); audio_capabilities_so = smart_objects::SmartObject(smart_objects::SmartType_Map); if (check_existing_json_member(audio_capabilities, "samplingRate")) { audio_capabilities_so["samplingRate"] = - sampling_rate_enum.find( - audio_capabilities.get("samplingRate", "").asString())->second; + sampling_rate_enum.find(audio_capabilities.get("samplingRate", "") + .asString()) + ->second; } if (check_existing_json_member(audio_capabilities, "bitsPerSample")) { audio_capabilities_so["bitsPerSample"] = bit_per_sample_enum.find( - audio_capabilities.get("bitsPerSample", "").asString())->second; + audio_capabilities.get("bitsPerSample", "") + .asString()) + ->second; } if (check_existing_json_member(audio_capabilities, "audioType")) { audio_capabilities_so["audioType"] = - audio_type_enum.find( - audio_capabilities.get("audioType", "").asString())->second; + audio_type_enum.find(audio_capabilities.get("audioType", "") + .asString()) + ->second; } set_audio_pass_thru_capabilities(audio_capabilities_so); } @@ -735,19 +747,20 @@ bool HMICapabilities::load_capabilities_from_file() { smart_objects::SmartObject hmi_zone_capabilities_so = smart_objects::SmartObject(smart_objects::SmartType_Array); hmi_zone_capabilities_so = - hmi_zone_enum.find(ui.get("hmiZoneCapabilities", "").asString())->second; + hmi_zone_enum.find(ui.get("hmiZoneCapabilities", "").asString()) + ->second; set_hmi_zone_capabilities(hmi_zone_capabilities_so); } if (check_existing_json_member(ui, "softButtonCapabilities")) { - Json::Value soft_button_capabilities = ui.get( - "softButtonCapabilities", ""); + Json::Value soft_button_capabilities = + ui.get("softButtonCapabilities", ""); smart_objects::SmartObject soft_button_capabilities_so; Formatters::CFormatterJsonBase::jsonValueToObj( soft_button_capabilities, soft_button_capabilities_so); set_soft_button_capabilities(soft_button_capabilities_so); } - } //UI end + } // UI end // VR if (check_existing_json_member(root_json, "VR")) { @@ -775,9 +788,9 @@ bool HMICapabilities::load_capabilities_from_file() { } set_vr_capabilities(vr_capabilities_so); } - }//VR end + } // VR end - //TTS + // TTS if (check_existing_json_member(root_json, "TTS")) { Json::Value tts = root_json.get("TTS", ""); @@ -798,7 +811,7 @@ bool HMICapabilities::load_capabilities_from_file() { set_speech_capabilities( smart_objects::SmartObject(tts.get("capabilities", "").asString())); } - } //TTS end + } // TTS end // Buttons if (check_existing_json_member(root_json, "Buttons")) { @@ -806,14 +819,15 @@ bool HMICapabilities::load_capabilities_from_file() { if (check_existing_json_member(buttons, "capabilities")) { Json::Value bt_capabilities = buttons.get("capabilities", ""); smart_objects::SmartObject buttons_capabilities_so; - Formatters::CFormatterJsonBase::jsonValueToObj( - bt_capabilities, buttons_capabilities_so); + Formatters::CFormatterJsonBase::jsonValueToObj(bt_capabilities, + buttons_capabilities_so); for (uint32_t i = 0; i < buttons_capabilities_so.length(); ++i) { if ((buttons_capabilities_so[i]).keyExists(strings::name)) { - std::map<std::string, hmi_apis::Common_ButtonName::eType> - ::const_iterator it = button_enum_name.find( - (buttons_capabilities_so[i][strings::name]).asString()); + std::map<std::string, + hmi_apis::Common_ButtonName::eType>::const_iterator it = + button_enum_name.find( + (buttons_capabilities_so[i][strings::name]).asString()); buttons_capabilities_so[i].erase(strings::name); if (button_enum_name.end() != it) { buttons_capabilities_so[i][strings::name] = it->second; @@ -825,21 +839,20 @@ bool HMICapabilities::load_capabilities_from_file() { if (check_existing_json_member(buttons, "presetBankCapabilities")) { Json::Value presetBank = buttons.get("presetBankCapabilities", ""); smart_objects::SmartObject preset_bank_so; - Formatters::CFormatterJsonBase::jsonValueToObj( - presetBank, preset_bank_so); + Formatters::CFormatterJsonBase::jsonValueToObj(presetBank, + preset_bank_so); set_preset_bank_capabilities(preset_bank_so); } - } //Buttons end + } // Buttons end - //VehicleType + // VehicleType if (check_existing_json_member(root_json, "VehicleInfo")) { Json::Value vehicle_info = root_json.get("VehicleInfo", ""); smart_objects::SmartObject vehicle_type_so; - Formatters::CFormatterJsonBase::jsonValueToObj( - vehicle_info, vehicle_type_so); + Formatters::CFormatterJsonBase::jsonValueToObj(vehicle_info, + vehicle_type_so); set_vehicle_type(vehicle_type_so); - }// VehicleType end - + } // VehicleType end } catch (...) { return false; @@ -847,16 +860,16 @@ bool HMICapabilities::load_capabilities_from_file() { return true; } -bool HMICapabilities::check_existing_json_member( - const Json::Value& json_member, const char* name_of_member) { +bool HMICapabilities::check_existing_json_member(const Json::Value& json_member, + const char* name_of_member) { return json_member.isMember(name_of_member); } -void HMICapabilities::convert_json_languages_to_obj(Json::Value& json_languages, - smart_objects::SmartObject& languages) { +void HMICapabilities::convert_json_languages_to_obj( + Json::Value& json_languages, smart_objects::SmartObject& languages) { for (uint32_t i = 0, j = 0; i < json_languages.size(); ++i) { - languages[j++] = MessageHelper::CommonLanguageFromString( - json_languages[i].asString()); + languages[j++] = + MessageHelper::CommonLanguageFromString(json_languages[i].asString()); } } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 708f23ca8b..b1600a32f9 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -775,7 +775,7 @@ bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string, "Update url is " << url << " for application " - << ApplicationManagerImpl::instance()->application(app_id)->name()); + << ApplicationManagerImpl::instance()->application(app_id)->name().c_str()); MessageHelper::SendPolicySnapshotNotification(app_id, pt_string, url, 0); @@ -1183,7 +1183,7 @@ void PolicyHandler::OnSystemError(int code) { } } -std::string PolicyHandler::GetAppName(const std::string& policy_app_id) { +custom_str::CustomString PolicyHandler::GetAppName(const std::string& policy_app_id) { ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application_by_policy_id( policy_app_id); @@ -1192,7 +1192,7 @@ std::string PolicyHandler::GetAppName(const std::string& policy_app_id) { LOG4CXX_WARN( logger_, "Connection_key not found for application_id:" << policy_app_id); - return ""; + return custom_str::CustomString(""); } return app->name(); } diff --git a/src/components/application_manager/src/resumption/resume_ctrl.cc b/src/components/application_manager/src/resumption/resume_ctrl.cc index 6618b02962..86a778873e 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl.cc @@ -293,7 +293,7 @@ bool ResumeCtrl::StartResumption(ApplicationSharedPtr application, MessageHelper::GetDeviceMacAddressForHandle(application->device()), saved_app); if (result) { - const std::string saved_hash = saved_app[strings::hash_id].asString(); + const std::string& saved_hash = saved_app[strings::hash_id].asString(); result = saved_hash == hash ? RestoreApplicationData(application) : false; application->UpdateHash(); AddToResumptionTimerQueue(application->app_id()); diff --git a/src/components/application_manager/test/resumption/include/application_mock.h b/src/components/application_manager/test/resumption/include/application_mock.h index 9c9e66dcf6..e510930242 100644 --- a/src/components/application_manager/test/resumption/include/application_mock.h +++ b/src/components/application_manager/test/resumption/include/application_mock.h @@ -34,11 +34,14 @@ #include <string> #include "gmock/gmock.h" #include "application_manager/application.h" +#include "utils/custom_string.h" namespace test { namespace components { namespace resumption_test { +namespace custom_str = utils::custom_string; + class ApplicationMock : public ::application_manager::Application { public: MOCK_CONST_METHOD0(mobile_app_id, std::string()); @@ -82,7 +85,7 @@ class ApplicationMock : public ::application_manager::Application { MOCK_CONST_METHOD0(version, const ::application_manager::Version&()); MOCK_METHOD1(set_hmi_application_id, void(uint32_t hmi_app_id)); MOCK_CONST_METHOD0(hmi_app_id, uint32_t()); - MOCK_CONST_METHOD0(name, const std::string&()); + MOCK_CONST_METHOD0(name, const custom_str::CustomString&()); MOCK_METHOD1(set_folder_name, void(const std::string& folder_name)); MOCK_CONST_METHOD0(folder_name, const std::string()); MOCK_CONST_METHOD0(is_media_application, bool()); @@ -104,7 +107,7 @@ class ApplicationMock : public ::application_manager::Application { MOCK_METHOD0(tts_properties_in_full, bool()); MOCK_METHOD1(set_version, void(const ::application_manager::Version& version)); - MOCK_METHOD1(set_name, void(const std::string& name)); + MOCK_METHOD1(set_name, void(const custom_str::CustomString& name)); MOCK_METHOD1(set_is_media_application, void(bool is_media)); MOCK_METHOD0(increment_put_file_in_none_count, void()); MOCK_METHOD0(increment_delete_file_in_none_count, void()); diff --git a/src/components/application_manager/test/resumption/resumption_data_test.cc b/src/components/application_manager/test/resumption/resumption_data_test.cc index b8054b0d85..7d04659a8b 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -37,7 +37,7 @@ #include "application_manager/usage_statistics.h" #include "include/application_mock.h" #include "include/resumption_data_mock.h" - +#include "utils/custom_string.h" #include "application_manager/application_manager_impl.h" #include "application_manager/application.h" #include "utils/data_accessor.h" @@ -54,7 +54,7 @@ std::string application_manager::MessageHelper::GetDeviceMacAddressForHandle( namespace test { namespace components { namespace resumption_test { - +namespace custom_str = utils::custom_string; using ::testing::Return; using ::testing::ReturnRef; using ::testing::ReturnPointee; @@ -66,8 +66,9 @@ void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { EXPECT_EQ(hmi_app_id_, resume_app_list[am::strings::hmi_app_id].asUInt()); EXPECT_EQ(ign_off_count_, resume_app_list[am::strings::ign_off_count].asUInt()); - EXPECT_EQ(hmi_level_, static_cast<HMILevel::eType>( - resume_app_list[am::strings::hmi_level].asInt())); + EXPECT_EQ(hmi_level_, + static_cast<HMILevel::eType>( + resume_app_list[am::strings::hmi_level].asInt())); EXPECT_EQ(is_audio_, resume_app_list[am::strings::is_media_application].asBool()); EXPECT_EQ("12345", resume_app_list[am::strings::device_id].asString()); @@ -85,9 +86,9 @@ void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { void ResumptionDataTest::CheckCommands(sm::SmartObject& res_list) { for (uint32_t i = 0; i < count_of_commands; ++i) { EXPECT_EQ(i, res_list[i][am::strings::cmd_id].asUInt()); - std::string name = - (*test_commands_map[i])[am::strings::menu_params] - [am::strings::menu_name].asString(); + std::string name = (*test_commands_map[i])[am::strings::menu_params] + [am::strings::menu_name] + .asString(); EXPECT_EQ(name, res_list[i][am::strings::menu_params][am::strings::menu_name] .asString()); @@ -99,7 +100,8 @@ void ResumptionDataTest::CheckCommands(sm::SmartObject& res_list) { res_list[i][am::strings::menu_params][am::strings::position].asInt()); int parent_id = (*test_commands_map[i])[am::strings::menu_params] - [am::hmi_request::parent_id].asInt(); + [am::hmi_request::parent_id] + .asInt(); EXPECT_EQ(parent_id, res_list[i][am::strings::menu_params][am::hmi_request::parent_id] .asInt()); @@ -158,20 +160,24 @@ void ResumptionDataTest::CheckChoiceSet(sm::SmartObject& res_list) { std::snprintf(numb, 12, "%d", i + j); std::string test_choice = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::vr_commands][0].asString(); + [am::strings::vr_commands][0] + .asString(); EXPECT_EQ(test_choice, command[am::strings::vr_commands][0].asString()); std::string menu_name = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::menu_name].asString(); + [am::strings::menu_name] + .asString(); EXPECT_EQ(menu_name, command[am::strings::menu_name].asString()); std::string secondary_text = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::secondary_text].asString(); + [am::strings::secondary_text] + .asString(); EXPECT_EQ(secondary_text, command[am::strings::secondary_text].asString()); std::string tertiary_text = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::tertiary_text].asString(); + [am::strings::tertiary_text] + .asString(); EXPECT_EQ(tertiary_text, command[am::strings::tertiary_text].asString()); std::string image_value = @@ -189,13 +195,15 @@ void ResumptionDataTest::CheckChoiceSet(sm::SmartObject& res_list) { image_value = (*test_choiceset_map[i])[am::strings::choice_set][j] [am::strings::secondary_image] - [am::strings::value].asString(); + [am::strings::value] + .asString(); EXPECT_EQ( image_value, command[am::strings::secondary_image][am::strings::value].asString()); image_type = (*test_choiceset_map[i])[am::strings::choice_set][j] [am::strings::secondary_image] - [am::strings::image_type].asInt(); + [am::strings::image_type] + .asInt(); EXPECT_EQ(image_type, command[am::strings::secondary_image][am::strings::image_type] .asInt()); @@ -261,13 +269,15 @@ void ResumptionDataTest::CheckKeyboardProperties(sm::SmartObject& res_list) { res_list[am::strings::limited_character_list][i].asString()); } - EXPECT_EQ(testlanguage, static_cast<Language::eType>( - res_list[am::strings::language].asInt())); + EXPECT_EQ( + testlanguage, + static_cast<Language::eType>(res_list[am::strings::language].asInt())); EXPECT_EQ(testlayout, static_cast<KeyboardLayout::eType>( res_list[am::hmi_request::keyboard_layout].asInt())); - EXPECT_EQ(testmode, static_cast<KeypressMode::eType>( - res_list[am::strings::key_press_mode].asInt())); + EXPECT_EQ(testmode, + static_cast<KeypressMode::eType>( + res_list[am::strings::key_press_mode].asInt())); EXPECT_EQ(auto_complete_text, res_list[am::strings::auto_complete_text].asString()); } @@ -283,8 +293,9 @@ void ResumptionDataTest::CheckMenuIcon(sm::SmartObject& res_list) { (*menu_icon_)[am::strings::image_type].asInt()); EXPECT_EQ(value, res_list[am::strings::value].asString()); - EXPECT_EQ(type, static_cast<ImageType::eType>( - res_list[am::strings::image_type].asInt())); + EXPECT_EQ( + type, + static_cast<ImageType::eType>(res_list[am::strings::image_type].asInt())); } void ResumptionDataTest::CheckHelpPrompt(sm::SmartObject& res_list) { @@ -302,8 +313,9 @@ void ResumptionDataTest::CheckTimeoutPrompt( SpeechCapabilities::eType speech = static_cast<SpeechCapabilities::eType>( (*timeout_prompt_)[i][am::strings::type].asInt()); EXPECT_EQ(text, res_list[i][am::strings::text].asString()); - EXPECT_EQ(speech, static_cast<SpeechCapabilities::eType>( - res_list[i][am::strings::type].asInt())); + EXPECT_EQ(speech, + static_cast<SpeechCapabilities::eType>( + res_list[i][am::strings::type].asInt())); } } @@ -379,6 +391,7 @@ void ResumptionDataTest::SetGlobalProporties() { } void ResumptionDataTest::SetMenuTitleAndIcon() { + custom_str::CustomString icon_name("test icon"); sm::SmartObject sm_icon; sm_icon[am::strings::value] = "test icon"; sm_icon[am::strings::image_type] = ImageType::STATIC; diff --git a/src/components/application_manager/test/state_controller/include/application_mock.h b/src/components/application_manager/test/state_controller/include/application_mock.h index 6bdcb940bd..7b4e938666 100644 --- a/src/components/application_manager/test/state_controller/include/application_mock.h +++ b/src/components/application_manager/test/state_controller/include/application_mock.h @@ -40,6 +40,8 @@ namespace state_controller_test { namespace am = application_manager; +namespace custom_str = utils::custom_string; + class ApplicationMock : public am::Application { public: MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*()); @@ -80,7 +82,7 @@ class ApplicationMock : public am::Application { MOCK_METHOD1(set_hmi_application_id, void(uint32_t hmi_app_id)); MOCK_CONST_METHOD0(hmi_app_id, uint32_t()); - MOCK_CONST_METHOD0(name, const std::string&()); + MOCK_CONST_METHOD0(name, const custom_str::CustomString&()); MOCK_METHOD1(set_folder_name, void(const std::string& folder_name)); MOCK_CONST_METHOD0(folder_name, const std::string()); MOCK_CONST_METHOD0(is_media_application, bool()); @@ -103,7 +105,7 @@ class ApplicationMock : public am::Application { MOCK_METHOD1(set_tts_properties_in_full, void(bool active)); MOCK_METHOD0(tts_properties_in_full, bool()); MOCK_METHOD1(set_version, void(const am::Version& version)); - MOCK_METHOD1(set_name, void(const std::string& name)); + MOCK_METHOD1(set_name, void(const custom_str::CustomString& name)); MOCK_METHOD1(set_is_media_application, void(bool is_media)); MOCK_METHOD0(increment_put_file_in_none_count, void()); MOCK_METHOD0(increment_delete_file_in_none_count, void()); |