From 23f7544cedbe2d5b6fa8a07d823c1c89338b8753 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 16 Nov 2018 13:56:17 -0500 Subject: Address comments --- .../include/application_manager/application.h | 14 ++++--- .../include/application_manager/application_impl.h | 20 +++++---- .../application_manager/src/application_impl.cc | 5 ++- .../src/application_manager_impl.cc | 47 ++++++++++++++-------- 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index b68fc083d7..4ddf1e1388 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -953,22 +953,26 @@ class Application : public virtual InitialApplicationData, const virtual std::string cloud_app_endpoint() = 0; /** - * @brief Get cloud app authtoken to be used in connection handshake after websocket open. + * @brief Get cloud app authtoken to be used in connection handshake after + * websocket open. * @return cloud app authtoken */ const virtual std::string cloud_app_authtoken() = 0; /** - * @brief Get cloud app tranpsport type. Defines the type of websocket connection used. + * @brief Get cloud app tranpsport type. Defines the type of websocket + * connection used. * @return cloud app transport type */ const virtual std::string cloud_app_transport_type() = 0; /** - * @brief Get hybrid app preference. Defines behaviour for when a similar mobile and cloud app are connected simultaneously. + * @brief Get hybrid app preference. Defines behaviour for when a similar + * mobile and cloud app are connected simultaneously. * @return hybrid app preference */ - const virtual std::string hybrid_app_preference() = 0; + const virtual mobile_apis::HybridAppPreference::eType + hybrid_app_preference() = 0; /** * @brief Get cloud app certificate. Used for secured websocket connections. @@ -996,7 +1000,7 @@ class Application : public virtual InitialApplicationData, * @brief Set hybrid app preference */ virtual void set_hybrid_app_preference( - const std::string& hybrid_app_preference) = 0; + const mobile_apis::HybridAppPreference::eType& hybrid_app_preference) = 0; /** * @brief Set cloud app certificate 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 74b2be0934..26d8cd6159 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -416,27 +416,31 @@ class ApplicationImpl : public virtual Application, const std::string cloud_app_endpoint() OVERRIDE; /** - * @brief Get cloud app authtoken to be used in connection handshake after websocket open. + * @brief Get cloud app authtoken to be used in connection handshake after + * websocket open. * @return cloud app authtoken */ const std::string cloud_app_authtoken() OVERRIDE; /** - * @brief Get cloud app tranpsport type. Defines the type of websocket connection used. + * @brief Get cloud app tranpsport type. Defines the type of websocket + * connection used. * @return cloud app transport type */ const std::string cloud_app_transport_type() OVERRIDE; /** - * @brief Get hybrid app preference. Defines behaviour for when a similar mobile and cloud app are connected simultaneously. + * @brief Get hybrid app preference. Defines behaviour for when a similar + * mobile and cloud app are connected simultaneously. * @return hybrid app preference */ - const std::string hybrid_app_preference() OVERRIDE; + const mobile_apis::HybridAppPreference::eType hybrid_app_preference() + OVERRIDE; /** * @brief Get cloud app certificate. Used for secured websocket connections. * @return cloud app certificate. - */ + */ const std::string cloud_app_certificate() OVERRIDE; /** @@ -457,8 +461,8 @@ class ApplicationImpl : public virtual Application, /** * @brief Set hybrid app preference */ - void set_hybrid_app_preference( - const std::string& hybrid_app_preference) OVERRIDE; + void set_hybrid_app_preference(const mobile_apis::HybridAppPreference::eType& + hybrid_app_preference) OVERRIDE; /** * @brief Set cloud app certificate @@ -573,7 +577,7 @@ class ApplicationImpl : public virtual Application, std::string endpoint_; std::string auth_token_; std::string cloud_transport_type_; - std::string hybrid_app_preference_; + mobile_apis::HybridAppPreference::eType hybrid_app_preference_; std::string certificate_; /** diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index c92823bf77..31df4e821b 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1175,7 +1175,8 @@ const std::string ApplicationImpl::cloud_app_transport_type() { return cloud_transport_type_; } -const std::string ApplicationImpl::hybrid_app_preference() { +const mobile_apis::HybridAppPreference::eType +ApplicationImpl::hybrid_app_preference() { return hybrid_app_preference_; } @@ -1197,7 +1198,7 @@ void ApplicationImpl::set_cloud_app_transport_type( } void ApplicationImpl::set_hybrid_app_preference( - const std::string& hybrid_app_preference) { + const mobile_apis::HybridAppPreference::eType& hybrid_app_preference) { hybrid_app_preference_ = hybrid_app_preference; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index c55adf84cb..1cec8b5ca2 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -820,7 +820,7 @@ void ApplicationManagerImpl::CreatePendingApplication( std::string certificate = ""; std::string auth_token = ""; std::string cloud_transport_type = ""; - std::string hybrid_app_preference = ""; + std::string hybrid_app_preference_str = ""; std::string name = device_info.name(); auto it = pending_device_map_.find(name); @@ -833,7 +833,8 @@ void ApplicationManagerImpl::CreatePendingApplication( policy::StringArray nicknames; policy::StringArray app_hmi_types; - GetPolicyHandler().GetInitialAppData(policy_app_id, &nicknames, &app_hmi_types); + GetPolicyHandler().GetInitialAppData( + policy_app_id, &nicknames, &app_hmi_types); if (!nicknames.size()) { LOG4CXX_ERROR(logger_, "Cloud App missing nickname"); @@ -842,15 +843,14 @@ void ApplicationManagerImpl::CreatePendingApplication( const std::string display_name = nicknames[0]; - ApplicationSharedPtr application(new ApplicationImpl( - 0, - policy_app_id, - device_info.mac_address(), - device_id, - custom_str::CustomString( - display_name), - GetPolicyHandler().GetStatisticManager(), - *this)); + ApplicationSharedPtr application( + new ApplicationImpl(0, + policy_app_id, + device_info.mac_address(), + device_id, + custom_str::CustomString(display_name), + GetPolicyHandler().GetStatisticManager(), + *this)); if (!application) { LOG4CXX_INFO(logger_, "Could not streate application"); @@ -858,17 +858,30 @@ void ApplicationManagerImpl::CreatePendingApplication( } GetPolicyHandler().GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference_str); + + mobile_apis::HybridAppPreference::eType hybrid_app_preference_enum; + + bool convert_result = smart_objects::EnumConversionHelper< + mobile_apis::HybridAppPreference::eType>:: + StringToEnum(hybrid_app_preference_str, &hybrid_app_preference_enum); + + if (!convert_result) { + LOG4CXX_ERROR( + logger_, + "Could not convert string to enum: " << hybrid_app_preference_str); + return; + } application->set_hmi_application_id(GenerateNewHMIAppID()); application->set_cloud_app_endpoint(endpoint); application->set_cloud_app_auth_token(auth_token); application->set_cloud_app_transport_type(cloud_transport_type); - application->set_hybrid_app_preference(hybrid_app_preference); + application->set_hybrid_app_preference(hybrid_app_preference_enum); application->set_cloud_app_certificate(certificate); sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); -- cgit v1.2.1