summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAGaliuzov <AGaliuzov@luxoft.com>2016-01-21 13:18:34 +0200
committerAGaliuzov <AGaliuzov@luxoft.com>2016-01-21 13:18:34 +0200
commit033e93244839fa373f2d2bd2e2b6dc27b92b6f3a (patch)
tree9aac79b6a1ed5529c55539ffb82a302b0e35e72d /src
parent6193d355f95be1ffcc0d660d92e3539ec79969d8 (diff)
parent9dbc649a259928feb00350c5df0f28c1875c1d43 (diff)
downloadsdl_core-033e93244839fa373f2d2bd2e2b6dc27b92b6f3a.tar.gz
Merge pull request #340 from LuxoftSDL/feature/CustomStringImpl
Feature/custom string
Diffstat (limited to 'src')
-rw-r--r--src/components/application_manager/include/application_manager/application.h7
-rw-r--r--src/components/application_manager/include/application_manager/application_impl.h10
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h1
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h30
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/change_registration_request.h97
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h25
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h118
-rw-r--r--src/components/application_manager/src/application_impl.cc6
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc13
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc3
-rw-r--r--src/components/application_manager/src/commands/hmi/on_allow_sdl_functionality_notification.cc7
-rw-r--r--src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc42
-rw-r--r--src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc8
-rw-r--r--src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc95
-rw-r--r--src/components/application_manager/src/commands/hmi/on_received_policy_update.cc11
-rw-r--r--src/components/application_manager/src/commands/mobile/add_command_request.cc246
-rw-r--r--src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc39
-rw-r--r--src/components/application_manager/src/commands/mobile/change_registration_request.cc23
-rw-r--r--src/components/application_manager/src/commands/mobile/dial_number_request.cc60
-rw-r--r--src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc166
-rw-r--r--src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_interaction_request.cc235
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc26
-rw-r--r--src/components/application_manager/src/commands/mobile/set_app_icon_request.cc102
-rw-r--r--src/components/application_manager/src/commands/mobile/system_request.cc59
-rw-r--r--src/components/application_manager/src/commands/mobile/update_turn_list_request.cc77
-rw-r--r--src/components/application_manager/src/hmi_capabilities.cc567
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc6
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl.cc2
-rw-r--r--src/components/application_manager/test/resumption/include/application_mock.h7
-rw-r--r--src/components/application_manager/test/resumption/resumption_data_test.cc57
-rw-r--r--src/components/application_manager/test/state_controller/include/application_mock.h6
-rw-r--r--src/components/formatters/src/formatter_json_rpc.cc84
-rw-r--r--src/components/include/security_manager/ssl_context.h44
-rw-r--r--src/components/policy/src/policy/include/policy/policy_listener.h27
-rw-r--r--src/components/policy/src/policy/src/policy_helper.cc323
-rw-r--r--src/components/policy/test/include/mock_policy_listener.h32
-rw-r--r--src/components/policy/test/policy_manager_impl_test.cc391
-rw-r--r--src/components/security_manager/src/ssl_context_impl.cc252
-rw-r--r--src/components/security_manager/test/ssl_certificate_handshake_test.cc211
-rw-r--r--src/components/security_manager/test/ssl_context_test.cc69
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_object.h97
-rw-r--r--src/components/smart_objects/src/smart_object.cc164
-rw-r--r--src/components/smart_objects/src/string_schema_item.cc12
-rw-r--r--[-rwxr-xr-x]src/components/test_main.cc14
-rw-r--r--src/components/utils/CMakeLists.txt1
-rw-r--r--src/components/utils/include/utils/gen_hash.h14
-rw-r--r--src/components/utils/src/custom_string.cc36
-rw-r--r--src/components/utils/src/file_system.cc94
-rw-r--r--src/components/utils/src/gen_hash.cc46
-rw-r--r--src/components/utils/test/CMakeLists.txt1
-rw-r--r--src/components/utils/test/custom_string_test.cc100
52 files changed, 2223 insertions, 1942 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 c5b86aeab6..0653025434 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
@@ -2151,7 +2152,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;
@@ -2434,7 +2435,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 8b58cf8f08..26f984a990 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);
@@ -1184,7 +1184,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);
@@ -1193,7 +1193,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());
diff --git a/src/components/formatters/src/formatter_json_rpc.cc b/src/components/formatters/src/formatter_json_rpc.cc
index 6c6e47069f..e349ced4d6 100644
--- a/src/components/formatters/src/formatter_json_rpc.cc
+++ b/src/components/formatters/src/formatter_json_rpc.cc
@@ -41,23 +41,23 @@ namespace Formatters {
namespace strings = NsJSONHandler::strings;
-const char *FormatterJsonRpc::kRequest = "request";
-const char *FormatterJsonRpc::kResponse = "response";
-const char *FormatterJsonRpc::kNotification = "notification";
-const char *FormatterJsonRpc::kErrorResponse = "error_response";
-const char *FormatterJsonRpc::kJsonRpc = "jsonrpc";
-const char *FormatterJsonRpc::kJsonRpcExpectedValue = "2.0";
-const char *FormatterJsonRpc::kId = "id";
-const char *FormatterJsonRpc::kMethod = "method";
-const char *FormatterJsonRpc::kParams = "params";
-const char *FormatterJsonRpc::kResult = "result";
-const char *FormatterJsonRpc::kError = "error";
-const char *FormatterJsonRpc::kCode = "code";
-const char *FormatterJsonRpc::kData = "data";
-const char *FormatterJsonRpc::kMessage = "message";
-
-bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
- std::string &out_str) {
+const char* FormatterJsonRpc::kRequest = "request";
+const char* FormatterJsonRpc::kResponse = "response";
+const char* FormatterJsonRpc::kNotification = "notification";
+const char* FormatterJsonRpc::kErrorResponse = "error_response";
+const char* FormatterJsonRpc::kJsonRpc = "jsonrpc";
+const char* FormatterJsonRpc::kJsonRpcExpectedValue = "2.0";
+const char* FormatterJsonRpc::kId = "id";
+const char* FormatterJsonRpc::kMethod = "method";
+const char* FormatterJsonRpc::kParams = "params";
+const char* FormatterJsonRpc::kResult = "result";
+const char* FormatterJsonRpc::kError = "error";
+const char* FormatterJsonRpc::kCode = "code";
+const char* FormatterJsonRpc::kData = "data";
+const char* FormatterJsonRpc::kMessage = "message";
+
+bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject& obj,
+ std::string& out_str) {
bool result = true;
try {
Json::Value root(Json::objectValue);
@@ -71,8 +71,8 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
bool is_message_params = formatted_object.keyExists(strings::S_MSG_PARAMS);
bool empty_message_params = true;
if (true == is_message_params) {
- const NsSmartObjects::SmartObject &msg_params = formatted_object
- .getElement(strings::S_MSG_PARAMS);
+ const NsSmartObjects::SmartObject& msg_params =
+ formatted_object.getElement(strings::S_MSG_PARAMS);
result = (NsSmartObjects::SmartType_Map == msg_params.getType());
if (true == result) {
@@ -86,13 +86,13 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
if (false == formatted_object.keyExists(strings::S_PARAMS)) {
result = false;
} else {
- const NsSmartObjects::SmartObject &params = formatted_object.getElement(
- strings::S_PARAMS);
+ const NsSmartObjects::SmartObject& params =
+ formatted_object.getElement(strings::S_PARAMS);
if (NsSmartObjects::SmartType_Map != params.getType()) {
result = false;
} else {
- const NsSmartObjects::SmartObject &message_type_object = params
- .getElement(strings::S_MESSAGE_TYPE);
+ const NsSmartObjects::SmartObject& message_type_object =
+ params.getElement(strings::S_MESSAGE_TYPE);
if (NsSmartObjects::SmartType_String != message_type_object.getType()) {
result = false;
@@ -113,13 +113,14 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
if (false == params.keyExists(strings::kCode)) {
result = false;
} else {
- const NsSmartObjects::SmartObject &code = params.getElement(
- strings::kCode);
+ const NsSmartObjects::SmartObject& code =
+ params.getElement(strings::kCode);
if (NsSmartObjects::SmartType_Integer != code.getType()) {
result = false;
} else {
- root[kResult][kCode] = utils::ConvertInt64ToLongLongInt(code.asInt());
+ root[kResult][kCode] =
+ utils::ConvertInt64ToLongLongInt(code.asInt());
}
}
} else if (kNotification == message_type) {
@@ -130,12 +131,13 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
result = result && SetMethod(params, root[kError][kData]);
result = result && SetMessage(params, root[kError]);
- const NsSmartObjects::SmartObject &code = params.getElement(
- strings::kCode);
+ const NsSmartObjects::SmartObject& code =
+ params.getElement(strings::kCode);
if (NsSmartObjects::SmartType_Integer != code.getType()) {
result = false;
} else {
- root[kError][kCode] = utils::ConvertInt64ToLongLongInt(code.asInt());
+ root[kError][kCode] =
+ utils::ConvertInt64ToLongLongInt(code.asInt());
}
}
}
@@ -149,12 +151,12 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
return result;
}
-bool FormatterJsonRpc::SetMethod(const NsSmartObjects::SmartObject &params,
- Json::Value &method_container) {
+bool FormatterJsonRpc::SetMethod(const NsSmartObjects::SmartObject& params,
+ Json::Value& method_container) {
bool result = false;
if (true == params.keyExists(strings::S_FUNCTION_ID)) {
- const NsSmartObjects::SmartObject &function_id =
+ const NsSmartObjects::SmartObject& function_id =
params.getElement(strings::S_FUNCTION_ID);
if (NsSmartObjects::SmartType_String == function_id.getType()) {
@@ -166,13 +168,13 @@ bool FormatterJsonRpc::SetMethod(const NsSmartObjects::SmartObject &params,
return result;
}
-bool FormatterJsonRpc::SetId(const NsSmartObjects::SmartObject &params,
- Json::Value &id_container) {
+bool FormatterJsonRpc::SetId(const NsSmartObjects::SmartObject& params,
+ Json::Value& id_container) {
bool result = false;
if (true == params.keyExists(strings::S_CORRELATION_ID)) {
- const NsSmartObjects::SmartObject &id = params.getElement(
- strings::S_CORRELATION_ID);
+ const NsSmartObjects::SmartObject& id =
+ params.getElement(strings::S_CORRELATION_ID);
if (NsSmartObjects::SmartType_Integer == id.getType()) {
id_container[kId] = utils::ConvertUInt64ToLongLongUInt(id.asUInt());
@@ -183,16 +185,16 @@ bool FormatterJsonRpc::SetId(const NsSmartObjects::SmartObject &params,
return result;
}
-bool FormatterJsonRpc::SetMessage(const NsSmartObjects::SmartObject &params,
- Json::Value &message_container) {
+bool FormatterJsonRpc::SetMessage(const NsSmartObjects::SmartObject& params,
+ Json::Value& message_container) {
bool result = false;
if (true == params.keyExists(strings::kMessage)) {
- const NsSmartObjects::SmartObject &message = params.getElement(
- strings::kMessage);
+ const NsSmartObjects::SmartObject& message =
+ params.getElement(strings::kMessage);
if (NsSmartObjects::SmartType_String == message.getType()) {
- message_container[kMessage] = message.asString();
+ message_container[kMessage] = message.asString();
result = true;
}
}
diff --git a/src/components/include/security_manager/ssl_context.h b/src/components/include/security_manager/ssl_context.h
index e361e98c3e..1149accaed 100644
--- a/src/components/include/security_manager/ssl_context.h
+++ b/src/components/include/security_manager/ssl_context.h
@@ -37,6 +37,7 @@
#include <string>
#include <ctype.h>
#include <algorithm>
+#include "utils/custom_string.h"
// TODO(EZamakhov): update brief info
/**
@@ -55,11 +56,13 @@
*
* \param in_data [in] data sent by other side
* \param in_data_size [in] size of data in \ref in_data buffer
- * \param out_data [out] response of SSL context if there is one. If not, equals NULL
+ * \param out_data [out] response of SSL context if there is one. If not,
+ * equals NULL
* \param out_data_size [out] length of response. On no response, equals 0
*/
namespace security_manager {
+namespace custom_str = utils::custom_string;
class SSLContext {
public:
enum HandshakeResult {
@@ -74,42 +77,39 @@ class SSLContext {
};
struct HandshakeContext {
- std::string expected_sn;
- std::string expected_cn;
+ custom_str::CustomString expected_sn;
+ custom_str::CustomString expected_cn;
- HandshakeContext& make_context(const std::string& sn,
- const std::string& cn) {
+ HandshakeContext& make_context(const custom_str::CustomString& sn,
+ const custom_str::CustomString& cn) {
expected_sn = sn;
expected_cn = cn;
-
- std::transform(expected_sn.begin(), expected_sn.end(),
- expected_sn.begin(), ::tolower);
-
- std::transform(expected_cn.begin(), expected_cn.end(),
- expected_cn.begin(), ::tolower);
return *this;
}
};
virtual HandshakeResult StartHandshake(const uint8_t** const out_data,
- size_t *out_data_size) = 0;
- virtual HandshakeResult DoHandshakeStep(const uint8_t *const in_data,
+ size_t* out_data_size) = 0;
+ virtual HandshakeResult DoHandshakeStep(const uint8_t* const in_data,
size_t in_data_size,
const uint8_t** const out_data,
- size_t *out_data_size) = 0;
- virtual bool Encrypt(const uint8_t *const in_data, size_t in_data_size,
- const uint8_t ** const out_data, size_t *out_data_size) = 0;
- virtual bool Decrypt(const uint8_t *const in_data, size_t in_data_size,
- const uint8_t ** const out_data, size_t *out_data_size) = 0;
- virtual bool IsInitCompleted() const = 0;
- virtual bool IsHandshakePending() const = 0;
+ size_t* out_data_size) = 0;
+ virtual bool Encrypt(const uint8_t* const in_data,
+ size_t in_data_size,
+ const uint8_t** const out_data,
+ size_t* out_data_size) = 0;
+ virtual bool Decrypt(const uint8_t* const in_data,
+ size_t in_data_size,
+ const uint8_t** const out_data,
+ size_t* out_data_size) = 0;
+ virtual bool IsInitCompleted() const = 0;
+ virtual bool IsHandshakePending() const = 0;
virtual size_t get_max_block_size(size_t mtu) const = 0;
virtual std::string LastError() const = 0;
virtual void ResetConnection() = 0;
virtual void SetHandshakeContext(const HandshakeContext& hsh_ctx) = 0;
- virtual ~SSLContext() { }
-
+ virtual ~SSLContext() {}
};
} // namespace security_manager
#endif // SRC_COMPONENTS_INCLUDE_SECURITY_MANAGER_SSL_CONTEXT_H_
diff --git a/src/components/policy/src/policy/include/policy/policy_listener.h b/src/components/policy/src/policy/include/policy/policy_listener.h
index 357fb20aed..2565bc353a 100644
--- a/src/components/policy/src/policy/include/policy/policy_listener.h
+++ b/src/components/policy/src/policy/include/policy/policy_listener.h
@@ -36,12 +36,15 @@
#include <queue>
#include "policy/policy_types.h"
+#include "utils/custom_string.h"
namespace policy {
+
+namespace custom_str = utils::custom_string;
+
class PolicyListener {
public:
- virtual ~PolicyListener() {
- }
+ virtual ~PolicyListener() {}
virtual void OnPermissionsUpdated(const std::string& policy_app_id,
const Permissions& permissions,
const policy::HMILevel& default_hmi) = 0;
@@ -52,16 +55,18 @@ class PolicyListener {
virtual std::string OnCurrentDeviceIdUpdateRequired(
const std::string& policy_app_id) = 0;
virtual void OnSystemInfoUpdateRequired() = 0;
- virtual std::string GetAppName(const std::string& policy_app_id) = 0;
- virtual void OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types) = 0;
+ virtual custom_str::CustomString GetAppName(
+ const std::string& policy_app_id) = 0;
+ virtual void OnUpdateHMIAppType(
+ std::map<std::string, StringArray> app_hmi_types) = 0;
- /**
- * @brief CanUpdate allows to find active application
- * and check whether related device consented.
- *
- * @return true if there are at least one application has been registered
- * with consented device.
- */
+ /**
+ * @brief CanUpdate allows to find active application
+ * and check whether related device consented.
+ *
+ * @return true if there are at least one application has been registered
+ * with consented device.
+ */
virtual bool CanUpdate() = 0;
/**
diff --git a/src/components/policy/src/policy/src/policy_helper.cc b/src/components/policy/src/policy/src/policy_helper.cc
index a762451c6f..b72a041a83 100644
--- a/src/components/policy/src/policy/src/policy_helper.cc
+++ b/src/components/policy/src/policy/src/policy_helper.cc
@@ -34,11 +34,14 @@
#include <sstream>
#include <string.h>
#include "utils/logger.h"
+#include "utils/custom_string.h"
#include "policy/policy_helper.h"
#include "policy/policy_manager_impl.h"
namespace policy {
+namespace custom_str = utils::custom_string;
+
namespace {
CREATE_LOGGERPTR_GLOBAL(logger_, "Policy")
@@ -50,53 +53,48 @@ bool Compare(const StringsValueType& first, const StringsValueType& second) {
}
struct CheckGroupName {
- CheckGroupName(const policy::StringsValueType& value)
- : value_(value) {
- }
+ CheckGroupName(const policy::StringsValueType& value) : value_(value) {}
bool operator()(const FunctionalGroupNames::value_type& value) {
return value.second.second == std::string(value_);
}
-private:
+ private:
const policy::StringsValueType& value_;
};
-struct CopyAttributes{
+struct CopyAttributes {
CopyAttributes(const FunctionalGroupNames& groups_attributes,
- std::vector<FunctionalGroupPermission>& groups_permissions)
- : groups_attributes_(groups_attributes),
- groups_permissions_(groups_permissions) {
- }
-
-bool operator()(const policy::StringsValueType& value) {
- CheckGroupName checker(value);
- FunctionalGroupNames::const_iterator it =
- std::find_if(groups_attributes_.begin(), groups_attributes_.end(),
- checker);
- if (groups_attributes_.end() == it) {
- return false;
+ std::vector<FunctionalGroupPermission>& groups_permissions)
+ : groups_attributes_(groups_attributes)
+ , groups_permissions_(groups_permissions) {}
+
+ bool operator()(const policy::StringsValueType& value) {
+ CheckGroupName checker(value);
+ FunctionalGroupNames::const_iterator it = std::find_if(
+ groups_attributes_.begin(), groups_attributes_.end(), checker);
+ if (groups_attributes_.end() == it) {
+ return false;
+ }
+ FunctionalGroupPermission group;
+ group.group_name = it->second.second;
+ group.group_alias = it->second.first;
+ group.group_id = it->first;
+ groups_permissions_.push_back(group);
+ return true;
}
- FunctionalGroupPermission group;
- group.group_name = it->second.second;
- group.group_alias = it->second.first;
- group.group_id = it->first;
- groups_permissions_.push_back(group);
- return true;
-}
-private:
+ private:
const FunctionalGroupNames& groups_attributes_;
std::vector<FunctionalGroupPermission>& groups_permissions_;
};
-} // namespace
+} // namespace
CompareGroupName::CompareGroupName(const StringsValueType& group_name)
- : group_name_(group_name) {
-}
+ : group_name_(group_name) {}
bool CompareGroupName::operator()(
- const StringsValueType& group_name_to_compare) const {
+ const StringsValueType& group_name_to_compare) const {
const std::string gn_ = group_name_;
const std::string gn_compare = group_name_to_compare;
return !(strcasecmp(gn_.c_str(), gn_compare.c_str()));
@@ -125,10 +123,7 @@ CheckAppPolicy::CheckAppPolicy(
PolicyManagerImpl* pm,
const utils::SharedPtr<policy_table::Table> update,
const utils::SharedPtr<policy_table::Table> snapshot)
- : pm_(pm),
- update_(update),
- snapshot_(snapshot) {
-}
+ : pm_(pm), update_(update), snapshot_(snapshot) {}
bool policy::CheckAppPolicy::HasRevokedGroups(
const policy::AppPoliciesValueType& app_policy,
@@ -149,13 +144,16 @@ bool policy::CheckAppPolicy::HasRevokedGroups(
StringsConstItr it_groups_curr_end = groups_curr.end();
policy_table::Strings revoked_group_list;
- std::set_difference(it_groups_curr, it_groups_curr_end,
- it_groups_new, it_groups_new_end,
- std::back_inserter(revoked_group_list), Compare);
+ std::set_difference(it_groups_curr,
+ it_groups_curr_end,
+ it_groups_new,
+ it_groups_new_end,
+ std::back_inserter(revoked_group_list),
+ Compare);
// Remove groups which are not required user consent
policy_table::Strings::iterator it_revoked = revoked_group_list.begin();
- for (;revoked_group_list.end() != it_revoked; ) {
+ for (; revoked_group_list.end() != it_revoked;) {
if (!IsConsentRequired(app_policy.first, std::string(*it_revoked))) {
revoked_group_list.erase(it_revoked);
it_revoked = revoked_group_list.begin();
@@ -190,9 +188,12 @@ bool policy::CheckAppPolicy::HasNewGroups(
StringsConstItr it_groups_curr_end = groups_curr.end();
policy_table::Strings new_group_list;
- std::set_difference(it_groups_new, it_groups_new_end,
- it_groups_curr, it_groups_curr_end,
- std::back_inserter(new_group_list), Compare);
+ std::set_difference(it_groups_new,
+ it_groups_new_end,
+ it_groups_curr,
+ it_groups_curr_end,
+ std::back_inserter(new_group_list),
+ Compare);
if (new_groups) {
*new_groups = new_group_list;
@@ -219,8 +220,7 @@ bool policy::CheckAppPolicy::HasConsentNeededGroups(
return false;
}
-std::vector<FunctionalGroupPermission>
-policy::CheckAppPolicy::GetRevokedGroups(
+std::vector<FunctionalGroupPermission> policy::CheckAppPolicy::GetRevokedGroups(
const policy::AppPoliciesValueType& app_policy) const {
policy_table::Strings revoked_groups_names;
if (!HasRevokedGroups(app_policy, &revoked_groups_names)) {
@@ -235,8 +235,8 @@ policy::CheckAppPolicy::GetRevokedGroups(
std::vector<FunctionalGroupPermission> revoked_groups_permissions;
CopyAttributes copier(groups_attributes, revoked_groups_permissions);
- std::for_each(revoked_groups_names.begin(), revoked_groups_names.end(),
- copier);
+ std::for_each(
+ revoked_groups_names.begin(), revoked_groups_names.end(), copier);
return revoked_groups_permissions;
}
@@ -248,7 +248,7 @@ void policy::CheckAppPolicy::RemoveRevokedConsents(
revoked_groups.begin();
std::vector<policy::FunctionalGroupPermission>::const_iterator it_end =
revoked_groups.end();
- for (;it != it_end; ++it) {
+ for (; it != it_end; ++it) {
pm_->RemoveAppConsentForGroup(app_policy.first, it->group_name);
}
}
@@ -267,13 +267,13 @@ void policy::CheckAppPolicy::NotifySystem(
}
void CheckAppPolicy::SendPermissionsToApp(
- const AppPoliciesValueType& app_policy) const {
+ const AppPoliciesValueType& app_policy) const {
const std::string app_id = app_policy.first;
const std::string device_id = pm_->GetCurrentDeviceId(app_id);
if (device_id.empty()) {
- LOG4CXX_WARN(logger_, "Couldn't find device info for application id: "
- << app_id);
+ LOG4CXX_WARN(logger_,
+ "Couldn't find device info for application id: " << app_id);
return;
}
std::vector<FunctionalGroupPermission> group_permissons;
@@ -282,7 +282,8 @@ void CheckAppPolicy::SendPermissionsToApp(
Permissions notification_data;
pm_->PrepareNotificationData(update_->policy_table.functional_groupings,
app_policy.second.groups,
- group_permissons, notification_data);
+ group_permissons,
+ notification_data);
LOG4CXX_INFO(logger_, "Send notification for application_id: " << app_id);
// Default_hmi is Ford-specific and should not be used with basic policy
@@ -291,7 +292,7 @@ void CheckAppPolicy::SendPermissionsToApp(
}
bool CheckAppPolicy::IsAppRevoked(
- const AppPoliciesValueType& app_policy) const {
+ const AppPoliciesValueType& app_policy) const {
LOG4CXX_AUTO_TRACE(logger_);
// Application params are not initialized = application revoked
// i.e. "123":null
@@ -301,15 +302,15 @@ bool CheckAppPolicy::IsAppRevoked(
bool CheckAppPolicy::NicknamesMatch(
const AppPoliciesValueType& app_policy) const {
const std::string& app_id = app_policy.first;
- std::string app_name = pm_->listener()->GetAppName(app_id);
- if (!app_name.empty() &&
- app_policy.second.nicknames &&
+ const custom_str::CustomString app_name = pm_->listener()->GetAppName(app_id);
+ if (!app_name.empty() && app_policy.second.nicknames &&
!app_policy.second.nicknames->empty()) {
for (policy_table::Strings::const_iterator it =
- app_policy.second.nicknames->begin();
- app_policy.second.nicknames->end() != it; ++it) {
+ app_policy.second.nicknames->begin();
+ app_policy.second.nicknames->end() != it;
+ ++it) {
std::string temp = *it;
- if (!strcasecmp(temp.c_str(), app_name.c_str())) {
+ if (app_name.CompareIgnoreCase(temp.c_str())) {
return true;
}
}
@@ -322,8 +323,8 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
const std::string app_id = app_policy.first;
if (!IsKnownAppication(app_id)) {
- LOG4CXX_WARN(logger_, "Application:" << app_id <<
- " is not present in snapshot.");
+ LOG4CXX_WARN(logger_,
+ "Application:" << app_id << " is not present in snapshot.");
return true;
}
@@ -345,13 +346,15 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
NotifySystem(app_policy);
}
if (RESULT_NO_CHANGES == result) {
- LOG4CXX_INFO(logger_, "Permissions for application:" << app_id <<
- " wasn't changed.");
+ LOG4CXX_INFO(logger_,
+ "Permissions for application:" << app_id
+ << " wasn't changed.");
return true;
}
- LOG4CXX_INFO(logger_, "Permissions for application:" << app_id <<
- " have been changed.");
+ LOG4CXX_INFO(logger_,
+ "Permissions for application:" << app_id
+ << " have been changed.");
if (!IsPredefinedApp(app_policy) && RESULT_CONSENT_NOT_REQIURED != result) {
SetPendingPermissions(app_policy, result);
@@ -370,46 +373,47 @@ void policy::CheckAppPolicy::SetPendingPermissions(
PermissionsCheckResult result) const {
const std::string app_id = app_policy.first;
AppPermissions permissions_diff(app_id);
- permissions_diff.priority = policy_table::EnumToJsonString(
- app_policy.second.priority);
+ permissions_diff.priority =
+ policy_table::EnumToJsonString(app_policy.second.priority);
switch (result) {
- case RESULT_APP_REVOKED:
- permissions_diff.appRevoked = true;
- break;
- case RESULT_NICKNAME_MISMATCH:
- permissions_diff.appUnauthorized = true;
- break;
- case RESULT_PERMISSIONS_REVOKED:
- permissions_diff.isAppPermissionsRevoked = true;
- permissions_diff.appRevokedPermissions = GetRevokedGroups(app_policy);
- RemoveRevokedConsents(app_policy, permissions_diff.appRevokedPermissions);
- break;
- case RESULT_CONSENT_NEEDED:
- permissions_diff.appPermissionsConsentNeeded = true;
- break;
- case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
- permissions_diff.isAppPermissionsRevoked = true;
- permissions_diff.appPermissionsConsentNeeded = true;
- permissions_diff.appRevokedPermissions = GetRevokedGroups(app_policy);
- RemoveRevokedConsents(app_policy, permissions_diff.appRevokedPermissions);
- break;
- case RESULT_REQUEST_TYPE_CHANGED:
- permissions_diff.priority.clear();
- permissions_diff.requestTypeChanged = true;
- {
- // Getting RequestTypes from PTU (not from cache)
- policy_table::RequestTypes::const_iterator it_request_type =
- app_policy.second.RequestType->begin();
- for (; app_policy.second.RequestType->end() != it_request_type;
- ++it_request_type) {
- permissions_diff.requestType.push_back(EnumToJsonString(*it_request_type));
- }
- }
+ case RESULT_APP_REVOKED:
+ permissions_diff.appRevoked = true;
+ break;
+ case RESULT_NICKNAME_MISMATCH:
+ permissions_diff.appUnauthorized = true;
+ break;
+ case RESULT_PERMISSIONS_REVOKED:
+ permissions_diff.isAppPermissionsRevoked = true;
+ permissions_diff.appRevokedPermissions = GetRevokedGroups(app_policy);
+ RemoveRevokedConsents(app_policy, permissions_diff.appRevokedPermissions);
+ break;
+ case RESULT_CONSENT_NEEDED:
+ permissions_diff.appPermissionsConsentNeeded = true;
+ break;
+ case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
+ permissions_diff.isAppPermissionsRevoked = true;
+ permissions_diff.appPermissionsConsentNeeded = true;
+ permissions_diff.appRevokedPermissions = GetRevokedGroups(app_policy);
+ RemoveRevokedConsents(app_policy, permissions_diff.appRevokedPermissions);
+ break;
+ case RESULT_REQUEST_TYPE_CHANGED:
+ permissions_diff.priority.clear();
+ permissions_diff.requestTypeChanged = true;
+ {
+ // Getting RequestTypes from PTU (not from cache)
+ policy_table::RequestTypes::const_iterator it_request_type =
+ app_policy.second.RequestType->begin();
+ for (; app_policy.second.RequestType->end() != it_request_type;
+ ++it_request_type) {
+ permissions_diff.requestType.push_back(
+ EnumToJsonString(*it_request_type));
+ }
+ }
- break;
- default:
- return;
+ break;
+ default:
+ return;
}
pm_->app_permissions_diff_lock_.Acquire();
pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff));
@@ -419,7 +423,6 @@ void policy::CheckAppPolicy::SetPendingPermissions(
policy::CheckAppPolicy::PermissionsCheckResult
policy::CheckAppPolicy::CheckPermissionsChanges(
const policy::AppPoliciesValueType& app_policy) const {
-
bool has_revoked_groups = HasRevokedGroups(app_policy);
bool has_consent_needed_groups = HasConsentNeededGroups(app_policy);
@@ -477,8 +480,9 @@ bool CheckAppPolicy::IsRequestTypeChanged(
}
FillNotificationData::FillNotificationData(Permissions& data,
- GroupConsent group_state, GroupConsent undefined_group_consent)
- : data_(data) {
+ GroupConsent group_state,
+ GroupConsent undefined_group_consent)
+ : data_(data) {
switch (group_state) {
case kGroupAllowed:
current_key_ = kAllowedKey;
@@ -488,9 +492,9 @@ FillNotificationData::FillNotificationData(Permissions& data,
current_key_ = kUndefinedKey;
break;
}
- current_key_ = kGroupAllowed == undefined_group_consent?
- kAllowedKey:
- kUserDisallowedKey;
+ current_key_ = kGroupAllowed == undefined_group_consent
+ ? kAllowedKey
+ : kUserDisallowedKey;
break;
default:
current_key_ = kUserDisallowedKey;
@@ -524,7 +528,7 @@ bool FillNotificationData::operator()(const RpcValueType& rpc) {
}
void FillNotificationData::UpdateHMILevels(
- const policy_table::HmiLevels& in_hmi, std::set<HMILevel>& out_hmi) {
+ const policy_table::HmiLevels& in_hmi, std::set<HMILevel>& out_hmi) {
HMILevelsConstItr it_hmi_levels = in_hmi.begin();
HMILevelsConstItr it_hmi_levels_end = in_hmi.end();
@@ -534,8 +538,8 @@ void FillNotificationData::UpdateHMILevels(
}
void FillNotificationData::UpdateParameters(
- const policy_table::Parameters& in_parameters,
- std::set<Parameter>& out_parameter) {
+ const policy_table::Parameters& in_parameters,
+ std::set<Parameter>& out_parameter) {
ParametersConstItr it_parameters = in_parameters.begin();
ParametersConstItr it_parameters_end = in_parameters.end();
@@ -558,7 +562,7 @@ void FillNotificationData::ExcludeSame() {
(*it).second.hmi_permissions.find(kUserDisallowedKey);
ParameterPermissions& rpc_parameter_permissions =
- (*it).second.parameter_permissions;
+ (*it).second.parameter_permissions;
ParameterPermissions::const_iterator it_parameter_allowed =
(*it).second.parameter_permissions.find(kAllowedKey);
ParameterPermissions::const_iterator it_parameter_undefined =
@@ -570,11 +574,11 @@ void FillNotificationData::ExcludeSame() {
if (rpc_hmi_permissions.end() != it_hmi_user_disallowed) {
if (rpc_hmi_permissions.end() != it_hmi_allowed) {
ExcludeSameHMILevels(rpc_hmi_permissions[kAllowedKey],
- rpc_hmi_permissions[kUserDisallowedKey]);
+ rpc_hmi_permissions[kUserDisallowedKey]);
}
if (rpc_hmi_permissions.end() != it_hmi_undefined) {
ExcludeSameHMILevels(rpc_hmi_permissions[kUndefinedKey],
- rpc_hmi_permissions[kUserDisallowedKey]);
+ rpc_hmi_permissions[kUserDisallowedKey]);
}
}
@@ -593,7 +597,7 @@ void FillNotificationData::ExcludeSame() {
if (rpc_hmi_permissions.end() != it_hmi_undefined) {
if (rpc_hmi_permissions.end() != it_hmi_allowed) {
ExcludeSameHMILevels(rpc_hmi_permissions[kAllowedKey],
- rpc_hmi_permissions[kUndefinedKey]);
+ rpc_hmi_permissions[kUndefinedKey]);
}
}
@@ -607,24 +611,26 @@ void FillNotificationData::ExcludeSame() {
}
void FillNotificationData::ExcludeSameHMILevels(
- std::set<HMILevel>& source,
- const std::set<HMILevel>& target) {
+ std::set<HMILevel>& source, const std::set<HMILevel>& target) {
std::set<HMILevel> diff_hmi;
- std::set_difference(source.begin(), source.end(),
- target.begin(), target.end(),
+ std::set_difference(source.begin(),
+ source.end(),
+ target.begin(),
+ target.end(),
std::inserter(diff_hmi, diff_hmi.begin()));
source = diff_hmi;
}
void FillNotificationData::ExcludeSameParameters(
- std::set<Parameter>& source,
- const std::set<Parameter>& target) {
+ std::set<Parameter>& source, const std::set<Parameter>& target) {
std::set<Parameter> diff_parameter;
- std::set_difference(source.begin(), source.end(),
- target.begin(), target.end(),
+ std::set_difference(source.begin(),
+ source.end(),
+ target.begin(),
+ target.end(),
std::inserter(diff_parameter, diff_parameter.begin()));
source = diff_parameter;
@@ -638,15 +644,14 @@ void FillNotificationData::InitRpcKeys(const std::string& rpc_name) {
}
ProcessFunctionalGroup::ProcessFunctionalGroup(
- const policy_table::FunctionalGroupings& fg,
- const std::vector<FunctionalGroupPermission>& group_permissions,
- Permissions& data,
- GroupConsent undefined_group_consent)
- : fg_(fg),
- group_permissions_(group_permissions),
- data_(data),
- undefined_group_consent_(undefined_group_consent) {
-}
+ const policy_table::FunctionalGroupings& fg,
+ const std::vector<FunctionalGroupPermission>& group_permissions,
+ Permissions& data,
+ GroupConsent undefined_group_consent)
+ : fg_(fg)
+ , group_permissions_(group_permissions)
+ , data_(data)
+ , undefined_group_consent_(undefined_group_consent) {}
bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) {
const std::string group_name_str = group_name;
@@ -654,19 +659,19 @@ bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) {
if (fg_.end() != it) {
const policy_table::Rpc& rpcs = (*it).second.rpcs;
- FillNotificationData filler(data_, GetGroupState(group_name_str),
- undefined_group_consent_);
+ FillNotificationData filler(
+ data_, GetGroupState(group_name_str), undefined_group_consent_);
std::for_each(rpcs.begin(), rpcs.end(), filler);
}
return true;
}
GroupConsent ProcessFunctionalGroup::GetGroupState(
- const std::string& group_name) {
+ const std::string& group_name) {
std::vector<FunctionalGroupPermission>::const_iterator it =
- group_permissions_.begin();
+ group_permissions_.begin();
std::vector<FunctionalGroupPermission>::const_iterator it_end =
- group_permissions_.end();
+ group_permissions_.end();
for (; it != it_end; ++it) {
if (group_name == (*it).group_name) {
return (*it).state;
@@ -676,15 +681,13 @@ GroupConsent ProcessFunctionalGroup::GetGroupState(
}
FunctionalGroupInserter::FunctionalGroupInserter(
- const policy_table::Strings& preconsented_groups, PermissionsList& list)
- : list_(list),
- preconsented_(preconsented_groups) {
-}
+ const policy_table::Strings& preconsented_groups, PermissionsList& list)
+ : list_(list), preconsented_(preconsented_groups) {}
void FunctionalGroupInserter::operator()(const StringsValueType& group_name) {
CompareGroupName name(group_name);
- if (std::find_if(preconsented_.begin(), preconsented_.end(), name)
- == preconsented_.end()) {
+ if (std::find_if(preconsented_.begin(), preconsented_.end(), name) ==
+ preconsented_.end()) {
list_.push_back(group_name);
}
}
@@ -694,7 +697,7 @@ void FillFunctionalGroupPermissions(
FunctionalGroupNames& names,
GroupConsent state,
std::vector<FunctionalGroupPermission>& permissions) {
- LOG4CXX_INFO(logger_, "FillFunctionalGroupPermissions" );
+ LOG4CXX_INFO(logger_, "FillFunctionalGroupPermissions");
FunctionalGroupIDs::const_iterator it = ids.begin();
FunctionalGroupIDs::const_iterator it_end = ids.end();
for (; it != it_end; ++it) {
@@ -714,7 +717,7 @@ bool IsPredefinedApp(const AppPoliciesValueType& app) {
FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
const FunctionalGroupIDs& what) {
- LOG4CXX_INFO(logger_, "Exclude same groups" );
+ LOG4CXX_INFO(logger_, "Exclude same groups");
FunctionalGroupIDs from_copy(from);
FunctionalGroupIDs what_copy(what);
@@ -722,8 +725,10 @@ FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
std::sort(what_copy.begin(), what_copy.end());
FunctionalGroupIDs no_same;
- std::set_difference(from_copy.begin(), from_copy.end(),
- what_copy.begin(),what_copy.end(),
+ std::set_difference(from_copy.begin(),
+ from_copy.end(),
+ what_copy.begin(),
+ what_copy.end(),
std::back_inserter(no_same));
no_same.resize(std::distance(no_same.begin(),
@@ -734,7 +739,7 @@ FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
FunctionalGroupIDs Merge(const FunctionalGroupIDs& first,
const FunctionalGroupIDs& second) {
- LOG4CXX_INFO(logger_, "Merge groups" );
+ LOG4CXX_INFO(logger_, "Merge groups");
FunctionalGroupIDs first_copy(first);
FunctionalGroupIDs second_copy(second);
@@ -742,12 +747,14 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first,
std::sort(second_copy.begin(), second_copy.end());
FunctionalGroupIDs merged;
- std::set_union(first_copy.begin(), first_copy.end(),
- second_copy.begin(), second_copy.end(),
+ std::set_union(first_copy.begin(),
+ first_copy.end(),
+ second_copy.begin(),
+ second_copy.end(),
std::back_inserter(merged));
- merged.resize(std::distance(merged.begin(),
- std::unique(merged.begin(), merged.end())));
+ merged.resize(
+ std::distance(merged.begin(), std::unique(merged.begin(), merged.end())));
return merged;
}
@@ -762,20 +769,22 @@ FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first,
std::sort(second_copy.begin(), second_copy.end());
FunctionalGroupIDs same;
- std::set_intersection(first_copy.begin(), first_copy.end(),
- second_copy.begin(), second_copy.end(),
+ std::set_intersection(first_copy.begin(),
+ first_copy.end(),
+ second_copy.begin(),
+ second_copy.end(),
std::back_inserter(same));
- same.resize(std::distance(same.begin(),
- std::unique(same.begin(), same.end())));
+ same.resize(
+ std::distance(same.begin(), std::unique(same.begin(), same.end())));
return same;
}
bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) {
policy_table::ApplicationPolicies::iterator it = app_policies.begin();
- policy_table::ApplicationPolicies::iterator it_default = app_policies.
- find(kDefaultId);
+ policy_table::ApplicationPolicies::iterator it_default =
+ app_policies.find(kDefaultId);
for (; app_policies.end() != it; ++it) {
// Set default policies for app, if there is record like "123":"default"
if (kDefaultId.compare((*it).second.get_string()) == 0) {
@@ -783,7 +792,8 @@ bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) {
(*it).second = (*it_default).second;
it->second.set_to_string(kDefaultId);
} else {
- LOG4CXX_ERROR(logger_, "There is no default application policy was "
+ LOG4CXX_ERROR(logger_,
+ "There is no default application policy was "
"found in PTU.");
return false;
}
@@ -792,5 +802,4 @@ bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) {
return true;
}
-
}
diff --git a/src/components/policy/test/include/mock_policy_listener.h b/src/components/policy/test/include/mock_policy_listener.h
index e59b5b3de1..6a5aa92d54 100644
--- a/src/components/policy/test/include/mock_policy_listener.h
+++ b/src/components/policy/test/include/mock_policy_listener.h
@@ -32,7 +32,6 @@
#ifndef SRC_COMPONENTS_POLICY_TEST_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
#define SRC_COMPONENTS_POLICY_TEST_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
-
#include <string>
#include "gmock/gmock.h"
@@ -40,11 +39,14 @@
#include "policy/policy_listener.h"
#include "rpc_base/rpc_base.h"
#include "table_struct/types.h"
+#include "utils/custom_string.h"
namespace policy_table = ::rpc::policy_table_interface_base;
namespace policy {
+namespace custom_str = utils::custom_string;
+
class MockPolicyListener : public PolicyListener {
public:
MOCK_METHOD3(OnPermissionsUpdated,
@@ -56,31 +58,25 @@ class MockPolicyListener : public PolicyListener {
const Permissions& permissions));
MOCK_METHOD1(OnPendingPermissionChange,
void(const std::string& policy_app_id));
- MOCK_METHOD1(OnUpdateStatusChanged,
- void(const std::string& status));
+ MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string& status));
MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired,
std::string(const std::string& policy_app_id));
- MOCK_METHOD0(OnSystemInfoUpdateRequired,
- void());
+ MOCK_METHOD0(OnSystemInfoUpdateRequired, void());
MOCK_METHOD1(GetAppName,
- std::string(const std::string& policy_app_id));
- MOCK_METHOD0(OnUserRequestedUpdateCheckRequired,
- void());
+ custom_str::CustomString(const std::string& policy_app_id));
+ MOCK_METHOD0(OnUserRequestedUpdateCheckRequired, void());
MOCK_METHOD2(OnDeviceConsentChanged,
- void(const std::string& device_id,
- bool is_allowed));
- MOCK_METHOD1(OnUpdateHMIAppType,
- void(std::map<std::string, StringArray>));
- MOCK_METHOD1(GetAvailableApps,
- void(std::queue<std::string>&));
+ void(const std::string& device_id, bool is_allowed));
+ MOCK_METHOD1(OnUpdateHMIAppType, void(std::map<std::string, StringArray>));
+ MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string>&));
MOCK_METHOD3(OnSnapshotCreated,
void(const BinaryMessage& pt_string,
const std::vector<int>& retry_seconds,
int timeout_exceed));
- MOCK_METHOD0(CanUpdate,
- bool());
- MOCK_METHOD1(OnCertificateUpdated, void (const std::string&));
- MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, void (const AppPermissions&, const std::string&));
+ MOCK_METHOD0(CanUpdate, bool());
+ MOCK_METHOD1(OnCertificateUpdated, void(const std::string&));
+ MOCK_CONST_METHOD2(SendOnAppPermissionsChanged,
+ void(const AppPermissions&, const std::string&));
};
} // namespace policy
diff --git a/src/components/policy/test/policy_manager_impl_test.cc b/src/components/policy/test/policy_manager_impl_test.cc
index d8afc93958..b76509ab44 100644
--- a/src/components/policy/test/policy_manager_impl_test.cc
+++ b/src/components/policy/test/policy_manager_impl_test.cc
@@ -65,18 +65,19 @@ namespace test {
namespace components {
namespace policy {
-typedef std::multimap< std::string, policy_table::Rpcs& >
- UserConsentPromptToRpcsConnections;
-template<typename T>
+namespace custom_str = utils::custom_string;
+
+typedef std::multimap<std::string, policy_table::Rpcs&>
+ UserConsentPromptToRpcsConnections;
+template <typename T>
std::string NumberToString(T Number) {
std::ostringstream ss;
ss << Number;
return ss.str();
}
-template<typename T>
-void SortAndCheckEquality(std::vector<T> first,
- std::vector<T> second) {
+template <typename T>
+void SortAndCheckEquality(std::vector<T> first, std::vector<T> second) {
ASSERT_EQ(first.size(), second.size());
std::sort(first.begin(), first.end());
std::sort(second.begin(), second.end());
@@ -103,182 +104,189 @@ class PolicyManagerImplTest : public ::testing::Test {
};
class PolicyManagerImplTest2 : public ::testing::Test {
- public:
- PolicyManagerImplTest2()
- : app_id1("123456789"),
- app_id2("1766825573"),
- dev_id1("XXX123456789ZZZ"),
- dev_id2("08-00-27-CE-76-FE"),
- PTU_request_types(Json::arrayValue) {}
-
- protected:
- PolicyManagerImpl* manager;
- NiceMock<MockPolicyListener> listener;
- std::vector<std::string> hmi_level;
- std::vector<std::string> PT_request_types;
- uint32_t PTU_request_types_size;
- unsigned int index;
- const std::string app_id1;
- const std::string app_id2;
- const std::string dev_id1;
- const std::string dev_id2;
- Json::Value PTU_request_types;
-
- void SetUp() OVERRIDE {
- file_system::CreateDirectory("storage1");
-
- profile::Profile::instance()->config_file_name("smartDeviceLink2.ini");
- manager = new PolicyManagerImpl();
- manager->set_listener(&listener);
- const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"};
- hmi_level.assign(levels, levels + sizeof(levels) / sizeof(levels[0]));
- srand(time(NULL));
- index = rand() % 3;
- }
+ public:
+ PolicyManagerImplTest2()
+ : app_id1("123456789")
+ , app_id2("1766825573")
+ , dev_id1("XXX123456789ZZZ")
+ , dev_id2("08-00-27-CE-76-FE")
+ , PTU_request_types(Json::arrayValue) {}
- std::vector<std::string> JsonToVectorString(const Json::Value& PTU_request_types) {
- std::vector<std::string> result;
- for (uint32_t i = 0; i < PTU_request_types.size(); ++i) {
- result.push_back(PTU_request_types[i].asString());
- }
- return result;
- }
+ protected:
+ PolicyManagerImpl* manager;
+ NiceMock<MockPolicyListener> listener;
+ std::vector<std::string> hmi_level;
+ std::vector<std::string> PT_request_types;
+ uint32_t PTU_request_types_size;
+ unsigned int index;
+ const std::string app_id1;
+ const std::string app_id2;
+ const std::string dev_id1;
+ const std::string dev_id2;
+ Json::Value PTU_request_types;
- const Json::Value GetPTU(std::string file_name) {
- // Get PTU
- std::ifstream ifile(file_name);
- Json::Reader reader;
- std::string json;
- Json::Value root(Json::objectValue);
- if (ifile.is_open() && reader.parse(ifile, root, true)) {
- json = root.toStyledString();
- }
- ifile.close();
- ::policy::BinaryMessage msg(json.begin(), json.end());
- // Load Json to cache
- EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
- return root;
- }
+ void SetUp() OVERRIDE {
+ file_system::CreateDirectory("storage1");
- void CreateLocalPT(std::string file_name) {
- file_system::remove_directory_content("storage1");
- ASSERT_TRUE(manager->InitPT(file_name));
- }
+ profile::Profile::instance()->config_file_name("smartDeviceLink2.ini");
+ manager = new PolicyManagerImpl();
+ manager->set_listener(&listener);
+ const char* levels[] = {"BACKGROUND", "FULL", "LIMITED", "NONE"};
+ hmi_level.assign(levels, levels + sizeof(levels) / sizeof(levels[0]));
+ srand(time(NULL));
+ index = rand() % 3;
+ }
- void AddRTtoPT(const std::string& update_file_name,
- const std::string& section_name, const uint32_t rt_number,
- const uint32_t invalid_rt_number) {
- // Arrange
- CreateLocalPT("sdl_preloaded_pt.json");
- // Get RequestTypes from section of preloaded_pt app_policies
- PT_request_types = manager->GetAppRequestTypes(section_name);
- EXPECT_EQ(rt_number, PT_request_types.size());
- Json::Value root = GetPTU(update_file_name);
- // Get Request Types from JSON (PTU)
- PTU_request_types =
- root["policy_table"]["app_policies"][section_name]["RequestType"];
- PTU_request_types_size = PTU_request_types.size();
- PT_request_types.clear();
- // Get RequestTypes from section of PT app policies after update
- PT_request_types = manager->GetAppRequestTypes(section_name);
- // Check number of RT in PTU and PT now are equal
- ASSERT_EQ(PTU_request_types_size - invalid_rt_number,
- PT_request_types.size());
+ std::vector<std::string> JsonToVectorString(
+ const Json::Value& PTU_request_types) {
+ std::vector<std::string> result;
+ for (uint32_t i = 0; i < PTU_request_types.size(); ++i) {
+ result.push_back(PTU_request_types[i].asString());
}
+ return result;
+ }
- void AddRTtoAppSectionPT(const std::string& update_file_name,
- const std::string& section_name,
- const uint32_t rt_number,
- const uint32_t invalid_rt_number) {
- // Arrange
- CreateLocalPT("sdl_preloaded_pt.json");
- // Add app
- manager->AddApplication(section_name);
- // Check app gets RequestTypes from pre_DataConsent of app_policies
- // section
- PT_request_types = manager->GetAppRequestTypes(section_name);
- EXPECT_EQ(rt_number, PT_request_types.size());
- EXPECT_CALL(listener, OnPendingPermissionChange(section_name)).Times(1);
- Json::Value root = GetPTU(update_file_name);
-
- // Get App Request Types from PTU
- PTU_request_types =
- root["policy_table"]["app_policies"][section_name]["RequestType"];
- PTU_request_types_size = PTU_request_types.size();
-
- PT_request_types.clear();
- // Get RequestTypes from <app_id> section of app policies after PT update
- PT_request_types = manager->GetAppRequestTypes(section_name);
- // Check sizes of Request types of PT and PTU
- ASSERT_EQ(PTU_request_types_size - invalid_rt_number,
- PT_request_types.size());
-
- ::policy::AppPermissions permissions =
- manager->GetAppPermissionsChanges(section_name);
- EXPECT_TRUE(permissions.requestTypeChanged);
+ const Json::Value GetPTU(std::string file_name) {
+ // Get PTU
+ std::ifstream ifile(file_name);
+ Json::Reader reader;
+ std::string json;
+ Json::Value root(Json::objectValue);
+ if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ json = root.toStyledString();
}
+ ifile.close();
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+ // Load Json to cache
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
+ return root;
+ }
+
+ void CreateLocalPT(std::string file_name) {
+ file_system::remove_directory_content("storage1");
+ ASSERT_TRUE(manager->InitPT(file_name));
+ }
- std::vector<policy_table::RequestType> PushRequestTypesToContainer(
- const std::vector<std::string>& temp_result) {
- policy_table::RequestType filtered_result;
- std::vector<policy_table::RequestType> final_result;
- for (uint32_t i = 0; i < temp_result.size(); ++i) {
- if (policy_table::EnumFromJsonString(temp_result[i],
- &filtered_result)) {
- final_result.push_back(filtered_result);
- }
+ void AddRTtoPT(const std::string& update_file_name,
+ const std::string& section_name,
+ const uint32_t rt_number,
+ const uint32_t invalid_rt_number) {
+ // Arrange
+ CreateLocalPT("sdl_preloaded_pt.json");
+ // Get RequestTypes from section of preloaded_pt app_policies
+ PT_request_types = manager->GetAppRequestTypes(section_name);
+ EXPECT_EQ(rt_number, PT_request_types.size());
+ Json::Value root = GetPTU(update_file_name);
+ // Get Request Types from JSON (PTU)
+ PTU_request_types =
+ root["policy_table"]["app_policies"][section_name]["RequestType"];
+ PTU_request_types_size = PTU_request_types.size();
+ PT_request_types.clear();
+ // Get RequestTypes from section of PT app policies after update
+ PT_request_types = manager->GetAppRequestTypes(section_name);
+ // Check number of RT in PTU and PT now are equal
+ ASSERT_EQ(PTU_request_types_size - invalid_rt_number,
+ PT_request_types.size());
+ }
+
+ void AddRTtoAppSectionPT(const std::string& update_file_name,
+ const std::string& section_name,
+ const uint32_t rt_number,
+ const uint32_t invalid_rt_number) {
+ // Arrange
+ CreateLocalPT("sdl_preloaded_pt.json");
+ // Add app
+ manager->AddApplication(section_name);
+ // Check app gets RequestTypes from pre_DataConsent of app_policies
+ // section
+ PT_request_types = manager->GetAppRequestTypes(section_name);
+ EXPECT_EQ(rt_number, PT_request_types.size());
+ EXPECT_CALL(listener, OnPendingPermissionChange(section_name)).Times(1);
+ Json::Value root = GetPTU(update_file_name);
+
+ // Get App Request Types from PTU
+ PTU_request_types =
+ root["policy_table"]["app_policies"][section_name]["RequestType"];
+ PTU_request_types_size = PTU_request_types.size();
+
+ PT_request_types.clear();
+ // Get RequestTypes from <app_id> section of app policies after PT update
+ PT_request_types = manager->GetAppRequestTypes(section_name);
+ // Check sizes of Request types of PT and PTU
+ ASSERT_EQ(PTU_request_types_size - invalid_rt_number,
+ PT_request_types.size());
+
+ ::policy::AppPermissions permissions =
+ manager->GetAppPermissionsChanges(section_name);
+ EXPECT_TRUE(permissions.requestTypeChanged);
+ }
+
+ std::vector<policy_table::RequestType> PushRequestTypesToContainer(
+ const std::vector<std::string>& temp_result) {
+ policy_table::RequestType filtered_result;
+ std::vector<policy_table::RequestType> final_result;
+ for (uint32_t i = 0; i < temp_result.size(); ++i) {
+ if (policy_table::EnumFromJsonString(temp_result[i], &filtered_result)) {
+ final_result.push_back(filtered_result);
}
- return final_result;
}
+ return final_result;
+ }
- void CheckResultForValidRT() {
- // Convert Json Array to std::vector<std::string>
- const std::vector<std::string>& result = JsonToVectorString(PTU_request_types);
- // Checks
- SortAndCheckEquality(PT_request_types, result);
- }
+ void CheckResultForValidRT() {
+ // Convert Json Array to std::vector<std::string>
+ const std::vector<std::string>& result =
+ JsonToVectorString(PTU_request_types);
+ // Checks
+ SortAndCheckEquality(PT_request_types, result);
+ }
- void CheckResultForInvalidRT() {
- // Convert Json Array to std::vector<std::string>
- const std::vector<std::string>& temp_result = JsonToVectorString(PTU_request_types);
- std::vector<policy_table::RequestType> result1 = PushRequestTypesToContainer(temp_result);
- std::vector<policy_table::RequestType> result2 = PushRequestTypesToContainer(PT_request_types);
- // Checks
- SortAndCheckEquality(result1, result2);
- }
- void FillMultimapFromFunctionalGroupings(
- UserConsentPromptToRpcsConnections& input_multimap,
- policy_table::FunctionalGroupings& fg_table){
- policy_table::FunctionalGroupings::iterator fg_itter = fg_table.begin();
- const policy_table::FunctionalGroupings::iterator fg_itter_end = fg_table.end();
- for(; fg_itter != fg_itter_end; ++fg_itter){
- // RPCS getting
- policy_table::Rpcs& rpcs_ref = fg_itter->second;
- // User_consent_prompt getting
- rpc::Optional<rpc::String<1,255> >& optional_ref =
- rpcs_ref.user_consent_prompt;
- rpc::String<1,255>& ucp_string = *optional_ref;
- const std::string& ucp_std_string =
- static_cast<const std::string&>(ucp_string);
- // Multimap inserting
- input_multimap.insert(std::pair<std::string, policy_table::Rpcs&>(ucp_std_string, rpcs_ref));
- }
+ void CheckResultForInvalidRT() {
+ // Convert Json Array to std::vector<std::string>
+ const std::vector<std::string>& temp_result =
+ JsonToVectorString(PTU_request_types);
+ std::vector<policy_table::RequestType> result1 =
+ PushRequestTypesToContainer(temp_result);
+ std::vector<policy_table::RequestType> result2 =
+ PushRequestTypesToContainer(PT_request_types);
+ // Checks
+ SortAndCheckEquality(result1, result2);
+ }
+ void FillMultimapFromFunctionalGroupings(
+ UserConsentPromptToRpcsConnections& input_multimap,
+ policy_table::FunctionalGroupings& fg_table) {
+ policy_table::FunctionalGroupings::iterator fg_itter = fg_table.begin();
+ const policy_table::FunctionalGroupings::iterator fg_itter_end =
+ fg_table.end();
+ for (; fg_itter != fg_itter_end; ++fg_itter) {
+ // RPCS getting
+ policy_table::Rpcs& rpcs_ref = fg_itter->second;
+ // User_consent_prompt getting
+ rpc::Optional<rpc::String<1, 255> >& optional_ref =
+ rpcs_ref.user_consent_prompt;
+ rpc::String<1, 255>& ucp_string = *optional_ref;
+ const std::string& ucp_std_string =
+ static_cast<const std::string&>(ucp_string);
+ // Multimap inserting
+ input_multimap.insert(std::pair<std::string, policy_table::Rpcs&>(
+ ucp_std_string, rpcs_ref));
}
+ }
- void GetFunctionalGroupingsFromManager(
- policy_table::FunctionalGroupings& input_functional_groupings){
- // Get cache
- ::policy::CacheManagerInterfaceSPtr cache = manager->GetCache();
- // Get table_snapshot
- utils::SharedPtr<policy_table::Table> table = cache->GenerateSnapshot();
- // Set functional groupings from policy table
- input_functional_groupings = table->policy_table.functional_groupings;
- }
+ void GetFunctionalGroupingsFromManager(
+ policy_table::FunctionalGroupings& input_functional_groupings) {
+ // Get cache
+ ::policy::CacheManagerInterfaceSPtr cache = manager->GetCache();
+ // Get table_snapshot
+ utils::SharedPtr<policy_table::Table> table = cache->GenerateSnapshot();
+ // Set functional groupings from policy table
+ input_functional_groupings = table->policy_table.functional_groupings;
+ }
- void TearDown() OVERRIDE {
- profile::Profile::instance()->config_file_name("smartDeviceLink.ini");
- delete manager;
- }
+ void TearDown() OVERRIDE {
+ profile::Profile::instance()->config_file_name("smartDeviceLink.ini");
+ delete manager;
+ }
};
TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) {
@@ -298,14 +306,18 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) {
EXPECT_TRUE(manager->IsApplicationRevoked(app_id1));
}
-TEST_F(PolicyManagerImplTest2, AddApplication_AddNewApplicationFromDeviceWithoutConsent_ExpectUpdateRequired) {
+TEST_F(
+ PolicyManagerImplTest2,
+ AddApplication_AddNewApplicationFromDeviceWithoutConsent_ExpectUpdateRequired) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
manager->AddApplication(app_id1);
EXPECT_EQ("UPDATE_NEEDED", manager->GetPolicyTableStatus());
}
-TEST_F(PolicyManagerImplTest2, AddApplication_AddExistingApplicationFromDeviceWithoutConsent_ExpectNoUpdateRequired) {
+TEST_F(
+ PolicyManagerImplTest2,
+ AddApplication_AddExistingApplicationFromDeviceWithoutConsent_ExpectNoUpdateRequired) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
@@ -317,7 +329,8 @@ TEST_F(PolicyManagerImplTest2, AddApplication_AddExistingApplicationFromDeviceWi
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
}
-TEST_F(PolicyManagerImplTest2, PTUpdatedAt_DaysNotExceedLimit_ExpectNoUpdateRequired) {
+TEST_F(PolicyManagerImplTest2,
+ PTUpdatedAt_DaysNotExceedLimit_ExpectNoUpdateRequired) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
TimevalStruct current_time = date_time::DateTime::getCurrentTime();
@@ -371,11 +384,12 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) {
Json::Reader reader;
Json::Value root(Json::objectValue);
if (ifile.is_open() && reader.parse(ifile, root, true)) {
- Json::Value seconds_between_retries = Json::Value(Json::arrayValue);
- seconds_between_retries = root["policy_table"]["module_config"]["seconds_between_retries"];
+ Json::Value seconds_between_retries = Json::Value(Json::arrayValue);
+ seconds_between_retries =
+ root["policy_table"]["module_config"]["seconds_between_retries"];
uint32_t size = seconds_between_retries.size();
CreateLocalPT("sdl_preloaded_pt.json");
- for(uint32_t i = 0; i < size; ++i) {
+ for (uint32_t i = 0; i < size; ++i) {
EXPECT_EQ(seconds_between_retries[i], manager->NextRetryTimeout());
}
}
@@ -395,26 +409,29 @@ TEST_F(PolicyManagerImplTest2, GetPolicyTableStatus_ExpectUpToDate) {
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
}
-TEST_F(PolicyManagerImplTest2, RetrySequenceDelaysSeconds_Expect_CorrectValues) {
+TEST_F(PolicyManagerImplTest2,
+ RetrySequenceDelaysSeconds_Expect_CorrectValues) {
// Arrange
std::ifstream ifile("sdl_preloaded_pt.json");
Json::Reader reader;
Json::Value root(Json::objectValue);
if (ifile.is_open() && reader.parse(ifile, root, true)) {
- Json::Value seconds_between_retries = Json::Value(Json::arrayValue);
- seconds_between_retries = root["policy_table"]["module_config"]["seconds_between_retries"];
+ Json::Value seconds_between_retries = Json::Value(Json::arrayValue);
+ seconds_between_retries =
+ root["policy_table"]["module_config"]["seconds_between_retries"];
uint32_t size = seconds_between_retries.size();
CreateLocalPT("sdl_preloaded_pt.json");
std::vector<int> delaySecs = manager->RetrySequenceDelaysSeconds();
// Check
ASSERT_EQ(size, delaySecs.size());
- for(uint32_t i = 0; i < size; ++i) {
- EXPECT_EQ(seconds_between_retries[i], delaySecs[i]);
+ for (uint32_t i = 0; i < size; ++i) {
+ EXPECT_EQ(seconds_between_retries[i], delaySecs[i]);
}
}
}
-TEST_F(PolicyManagerImplTest2, OnExceededTimeout_GetPolicyTableStatus_ExpectUpdateNeeded) {
+TEST_F(PolicyManagerImplTest2,
+ OnExceededTimeout_GetPolicyTableStatus_ExpectUpdateNeeded) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
manager->OnExceededTimeout();
@@ -435,11 +452,11 @@ TEST_F(PolicyManagerImplTest2, GetInitialAppData_ExpectReceivedConsentCorrect) {
Json::Value root = GetPTU("valid_sdl_pt_update.json");
- Json::Value appHmiTypes = Json::Value(Json::arrayValue);
+ Json::Value appHmiTypes = Json::Value(Json::arrayValue);
appHmiTypes = root["policy_table"]["app_policies"][app_id2]["AppHMIType"];
uint32_t appHmiType_size = appHmiTypes.size();
- Json::Value appNicknames = Json::Value(Json::arrayValue);
+ Json::Value appNicknames = Json::Value(Json::arrayValue);
appNicknames = root["policy_table"]["app_policies"][app_id2]["nicknames"];
uint32_t appNicknames_size = appNicknames.size();
@@ -453,16 +470,17 @@ TEST_F(PolicyManagerImplTest2, GetInitialAppData_ExpectReceivedConsentCorrect) {
ASSERT_GT(nick_names_size, 0u);
ASSERT_GT(app_hmi_types_size, 0u);
// Check nicknames match
- for(uint32_t i = 0; i < nick_names_size; ++i) {
+ for (uint32_t i = 0; i < nick_names_size; ++i) {
EXPECT_EQ(app_nicknames1[i], appNicknames[i].asString());
}
// Check AppHMITypes match
- for(uint32_t i = 0; i < app_hmi_types_size; ++i) {
+ for (uint32_t i = 0; i < app_hmi_types_size; ++i) {
EXPECT_EQ(app_hmi_types1[i], appHmiTypes[i].asString());
}
}
-TEST_F(PolicyManagerImplTest2, CanAppKeepContext_SetPoliciesForAppUpdated_ExpectAppCanKeepContext) {
+TEST_F(PolicyManagerImplTest2,
+ CanAppKeepContext_SetPoliciesForAppUpdated_ExpectAppCanKeepContext) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
manager->AddApplication(app_id2);
@@ -471,7 +489,8 @@ TEST_F(PolicyManagerImplTest2, CanAppKeepContext_SetPoliciesForAppUpdated_Expect
EXPECT_TRUE(manager->CanAppKeepContext(app_id2));
}
-TEST_F(PolicyManagerImplTest2, CanAppStealFocus_SetPoliciesForAppUpdated_ExpectAppCanStealFocus) {
+TEST_F(PolicyManagerImplTest2,
+ CanAppStealFocus_SetPoliciesForAppUpdated_ExpectAppCanStealFocus) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
manager->AddApplication(app_id2);
@@ -483,7 +502,7 @@ TEST_F(PolicyManagerImplTest2, CanAppStealFocus_SetPoliciesForAppUpdated_ExpectA
TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) {
// Arrange
EXPECT_CALL(listener, OnCurrentDeviceIdUpdateRequired(app_id2)).Times(1);
- EXPECT_EQ("", manager->GetCurrentDeviceId(app_id2));
+ EXPECT_EQ(custom_str::CustomString(""), manager->GetCurrentDeviceId(app_id2));
}
} // namespace policy
diff --git a/src/components/security_manager/src/ssl_context_impl.cc b/src/components/security_manager/src/ssl_context_impl.cc
index 6ef073dbb4..e9c3c026ba 100644
--- a/src/components/security_manager/src/ssl_context_impl.cc
+++ b/src/components/security_manager/src/ssl_context_impl.cc
@@ -45,17 +45,18 @@ namespace security_manager {
CREATE_LOGGERPTR_GLOBAL(logger_, "SecurityManager")
-CryptoManagerImpl::SSLContextImpl::SSLContextImpl(SSL *conn, Mode mode)
- : connection_(conn),
- bioIn_(BIO_new(BIO_s_mem())),
- bioOut_(BIO_new(BIO_s_mem())),
- bioFilter_(NULL),
+CryptoManagerImpl::SSLContextImpl::SSLContextImpl(SSL* conn, Mode mode)
+ : connection_(conn)
+ , bioIn_(BIO_new(BIO_s_mem()))
+ , bioOut_(BIO_new(BIO_s_mem()))
+ , bioFilter_(NULL)
+ ,
// TODO(EZamakhov): get MTU by parameter (from transport)
// default buffer size is TCP MTU
- buffer_size_(1500),
- buffer_(new uint8_t[buffer_size_]),
- is_handshake_pending_(false),
- mode_(mode) {
+ buffer_size_(1500)
+ , buffer_(new uint8_t[buffer_size_])
+ , is_handshake_pending_(false)
+ , mode_(mode) {
SSL_set_bio(connection_, bioIn_, bioOut_);
}
@@ -63,7 +64,7 @@ std::string CryptoManagerImpl::SSLContextImpl::LastError() const {
if (!IsInitCompleted()) {
return std::string("Initialization is not completed");
}
- const char *reason = ERR_reason_error_string(ERR_get_error());
+ const char* reason = ERR_reason_error_string(ERR_get_error());
return std::string(reason ? reason : "");
}
@@ -72,79 +73,81 @@ bool CryptoManagerImpl::SSLContextImpl::IsInitCompleted() const {
return SSL_is_init_finished(connection_);
}
-SSLContext::HandshakeResult CryptoManagerImpl::SSLContextImpl::
-StartHandshake(const uint8_t** const out_data, size_t *out_data_size) {
+SSLContext::HandshakeResult CryptoManagerImpl::SSLContextImpl::StartHandshake(
+ const uint8_t** const out_data, size_t* out_data_size) {
is_handshake_pending_ = true;
return DoHandshakeStep(NULL, 0, out_data, out_data_size);
}
namespace {
- size_t aes128_gcm_sha256_max_block_size(size_t mtu) {
- if (mtu < 29)
- return 0;
- return mtu - 29;
- }
- size_t rc4_md5_max_block_size(size_t mtu) {
- if (mtu < 21)
- return 0;
- return mtu - 21;
- }
- size_t rc4_sha_max_block_size(size_t mtu) {
- if (mtu < 25)
- return 0;
- return mtu - 25;
- }
- size_t seed_sha_max_block_size(size_t mtu) {
- if (mtu < 53)
- return 0;
- return ((mtu - 37) & 0xfffffff0) - 5;
- }
- size_t aes128_sha256_max_block_size(size_t mtu) {
- if (mtu < 69)
- return 0;
- return ((mtu - 53) & 0xfffffff0) - 1;
- }
- size_t des_cbc3_sha_max_block_size(size_t mtu) {
- if (mtu < 37)
- return 0;
- return ((mtu - 29) & 0xfffffff8) - 5;
- }
+size_t aes128_gcm_sha256_max_block_size(size_t mtu) {
+ if (mtu < 29)
+ return 0;
+ return mtu - 29;
+}
+size_t rc4_md5_max_block_size(size_t mtu) {
+ if (mtu < 21)
+ return 0;
+ return mtu - 21;
+}
+size_t rc4_sha_max_block_size(size_t mtu) {
+ if (mtu < 25)
+ return 0;
+ return mtu - 25;
+}
+size_t seed_sha_max_block_size(size_t mtu) {
+ if (mtu < 53)
+ return 0;
+ return ((mtu - 37) & 0xfffffff0) - 5;
+}
+size_t aes128_sha256_max_block_size(size_t mtu) {
+ if (mtu < 69)
+ return 0;
+ return ((mtu - 53) & 0xfffffff0) - 1;
+}
+size_t des_cbc3_sha_max_block_size(size_t mtu) {
+ if (mtu < 37)
+ return 0;
+ return ((mtu - 29) & 0xfffffff8) - 5;
+}
} // namespace
std::map<std::string, CryptoManagerImpl::SSLContextImpl::BlockSizeGetter>
CryptoManagerImpl::SSLContextImpl::create_max_block_sizes() {
std::map<std::string, CryptoManagerImpl::SSLContextImpl::BlockSizeGetter> rc;
- rc.insert(std::make_pair("AES128-GCM-SHA256", aes128_gcm_sha256_max_block_size));
- rc.insert(std::make_pair("AES128-SHA256", aes128_sha256_max_block_size));
- rc.insert(std::make_pair("AES128-SHA", seed_sha_max_block_size));
- rc.insert(std::make_pair("AES256-GCM-SHA384", aes128_gcm_sha256_max_block_size));
- rc.insert(std::make_pair("AES256-SHA256", aes128_sha256_max_block_size));
- rc.insert(std::make_pair("AES256-SHA", seed_sha_max_block_size));
- rc.insert(std::make_pair("CAMELLIA128-SHA", seed_sha_max_block_size));
- rc.insert(std::make_pair("CAMELLIA256-SHA", seed_sha_max_block_size));
- rc.insert(std::make_pair("DES-CBC3-SHA", des_cbc3_sha_max_block_size));
- rc.insert(std::make_pair("DES-CBC-SHA", des_cbc3_sha_max_block_size));
- rc.insert(std::make_pair("RC4-MD5", rc4_md5_max_block_size));
- rc.insert(std::make_pair("RC4-SHA", rc4_sha_max_block_size));
- rc.insert(std::make_pair("SEED-SHA", seed_sha_max_block_size));
+ rc.insert(
+ std::make_pair("AES128-GCM-SHA256", aes128_gcm_sha256_max_block_size));
+ rc.insert(std::make_pair("AES128-SHA256", aes128_sha256_max_block_size));
+ rc.insert(std::make_pair("AES128-SHA", seed_sha_max_block_size));
+ rc.insert(
+ std::make_pair("AES256-GCM-SHA384", aes128_gcm_sha256_max_block_size));
+ rc.insert(std::make_pair("AES256-SHA256", aes128_sha256_max_block_size));
+ rc.insert(std::make_pair("AES256-SHA", seed_sha_max_block_size));
+ rc.insert(std::make_pair("CAMELLIA128-SHA", seed_sha_max_block_size));
+ rc.insert(std::make_pair("CAMELLIA256-SHA", seed_sha_max_block_size));
+ rc.insert(std::make_pair("DES-CBC3-SHA", des_cbc3_sha_max_block_size));
+ rc.insert(std::make_pair("DES-CBC-SHA", des_cbc3_sha_max_block_size));
+ rc.insert(std::make_pair("RC4-MD5", rc4_md5_max_block_size));
+ rc.insert(std::make_pair("RC4-SHA", rc4_sha_max_block_size));
+ rc.insert(std::make_pair("SEED-SHA", seed_sha_max_block_size));
return rc;
}
std::map<std::string, CryptoManagerImpl::SSLContextImpl::BlockSizeGetter>
-CryptoManagerImpl::SSLContextImpl::max_block_sizes =
- CryptoManagerImpl::SSLContextImpl::create_max_block_sizes();
+ CryptoManagerImpl::SSLContextImpl::max_block_sizes =
+ CryptoManagerImpl::SSLContextImpl::create_max_block_sizes();
-void CryptoManagerImpl::SSLContextImpl::PrintCertData(X509* cert,
- const std::string& cert_owner) {
+void CryptoManagerImpl::SSLContextImpl::PrintCertData(
+ X509* cert, const std::string& cert_owner) {
if (cert) {
X509_NAME* subj_name = X509_get_subject_name(cert);
- char *subj = X509_NAME_oneline(subj_name, NULL, 0);
+ char* subj = X509_NAME_oneline(subj_name, NULL, 0);
if (subj) {
std::replace(subj, subj + strlen(subj), '/', ' ');
- LOG4CXX_DEBUG(logger_, cert_owner <<" subject:" << subj);
+ LOG4CXX_DEBUG(logger_, cert_owner << " subject:" << subj);
OPENSSL_free(subj);
}
- char *issuer = X509_NAME_oneline(X509_get_issuer_name(cert), NULL, 0);
+ char* issuer = X509_NAME_oneline(X509_get_issuer_name(cert), NULL, 0);
if (issuer) {
std::replace(issuer, issuer + strlen(issuer), '/', ' ');
LOG4CXX_DEBUG(logger_, cert_owner << " issuer:" << issuer);
@@ -166,37 +169,42 @@ void CryptoManagerImpl::SSLContextImpl::PrintCertData(X509* cert,
void CryptoManagerImpl::SSLContextImpl::PrintCertInfo() {
PrintCertData(SSL_get_certificate(connection_), "HU's");
- STACK_OF(X509 ) *peer_certs = SSL_get_peer_cert_chain(connection_);
+ STACK_OF(X509)* peer_certs = SSL_get_peer_cert_chain(connection_);
while (sk_X509_num(peer_certs) > 0) {
X509* cert = sk_X509_pop(peer_certs);
- PrintCertData(cert, "SERVERS");
+ PrintCertData(cert, "SERVERS");
}
}
-SSLContext::HandshakeResult CryptoManagerImpl::SSLContextImpl::
-CheckCertContext() {
+SSLContext::HandshakeResult
+CryptoManagerImpl::SSLContextImpl::CheckCertContext() {
X509* cert = SSL_get_peer_certificate(connection_);
if (!cert) {
// According to the openssl documentation the peer certificate
// might be ommitted for the SERVER but required for the cient.
- return CLIENT == mode_ ? Handshake_Result_Fail : Handshake_Result_Success;
+ return CLIENT == mode_ ? Handshake_Result_Fail : Handshake_Result_Success;
}
- X509_NAME* subj_name =
- X509_get_subject_name(cert);
+ X509_NAME* subj_name = X509_get_subject_name(cert);
const std::string& cn = GetTextBy(subj_name, NID_commonName);
const std::string& sn = GetTextBy(subj_name, NID_serialNumber);
- if (hsh_context_.expected_cn.compare(cn) != 0) {
- LOG4CXX_ERROR(logger_,"Trying to run handshake with wrong app name: " << cn
- << ". Expected app name: " << hsh_context_.expected_cn);
+ if (!(hsh_context_.expected_cn.CompareIgnoreCase(cn.c_str()))) {
+ LOG4CXX_ERROR(logger_,
+ "Trying to run handshake with wrong app name: "
+ << cn
+ << ". Expected app name: "
+ << hsh_context_.expected_cn.AsMBString());
return Handshake_Result_AppNameMismatch;
}
- if (hsh_context_.expected_sn.compare(sn) != 0) {
- LOG4CXX_ERROR(logger_,"Trying to run handshake with wrong app id: " << sn
- << ". Expected app id: " << hsh_context_.expected_sn);
+ if (!(hsh_context_.expected_sn.CompareIgnoreCase(sn.c_str()))) {
+ LOG4CXX_ERROR(logger_,
+ "Trying to run handshake with wrong app id: "
+ << sn
+ << ". Expected app id: "
+ << hsh_context_.expected_sn.AsMBString());
return Handshake_Result_AppIDMismatch;
}
return Handshake_Result_Success;
@@ -213,9 +221,9 @@ bool CryptoManagerImpl::SSLContextImpl::ReadHandshakeData(
EnsureBufferSizeEnough(pend);
const int read_count = BIO_read(bioOut_, buffer_, pend);
- if (read_count == static_cast<int>(pend)) {
+ if (read_count == static_cast<int>(pend)) {
*out_data_size = read_count;
- *out_data = buffer_;
+ *out_data = buffer_;
} else {
LOG4CXX_WARN(logger_, "BIO read fail");
is_handshake_pending_ = false;
@@ -227,8 +235,8 @@ bool CryptoManagerImpl::SSLContextImpl::ReadHandshakeData(
return true;
}
-bool CryptoManagerImpl::SSLContextImpl::
-WriteHandshakeData(const uint8_t* const in_data, size_t in_data_size) {
+bool CryptoManagerImpl::SSLContextImpl::WriteHandshakeData(
+ const uint8_t* const in_data, size_t in_data_size) {
LOG4CXX_AUTO_TRACE(logger_);
if (in_data && in_data_size) {
const int ret = BIO_write(bioIn_, in_data, in_data_size);
@@ -241,9 +249,8 @@ WriteHandshakeData(const uint8_t* const in_data, size_t in_data_size) {
return true;
}
-
-SSLContext::HandshakeResult CryptoManagerImpl::SSLContextImpl::
-PerformHandshake() {
+SSLContext::HandshakeResult
+CryptoManagerImpl::SSLContextImpl::PerformHandshake() {
const int handshake_result = SSL_do_handshake(connection_);
if (handshake_result == 1) {
const HandshakeResult result = CheckCertContext();
@@ -258,7 +265,7 @@ PerformHandshake() {
bioFilter_ = BIO_new(BIO_f_ssl());
BIO_set_ssl(bioFilter_, connection_, BIO_NOCLOSE);
- const SSL_CIPHER *cipher = SSL_get_current_cipher(connection_);
+ const SSL_CIPHER* cipher = SSL_get_current_cipher(connection_);
max_block_size_ = max_block_sizes[SSL_CIPHER_get_name(cipher)];
is_handshake_pending_ = false;
@@ -271,8 +278,13 @@ PerformHandshake() {
if (error != SSL_ERROR_WANT_READ) {
const long error = SSL_get_verify_result(connection_);
SetHandshakeError(error);
- LOG4CXX_WARN(logger_, "Handshake failed with error " << " -> " << SSL_get_error(connection_, error)
- << " \"" << LastError() << '"');
+ LOG4CXX_WARN(logger_,
+ "Handshake failed with error "
+ << " -> "
+ << SSL_get_error(connection_, error)
+ << " \""
+ << LastError()
+ << '"');
ResetConnection();
is_handshake_pending_ = false;
@@ -287,10 +299,11 @@ PerformHandshake() {
return Handshake_Result_Success;
}
-
-SSLContext::HandshakeResult CryptoManagerImpl::SSLContextImpl::
-DoHandshakeStep(const uint8_t* const in_data, size_t in_data_size,
- const uint8_t** const out_data, size_t* out_data_size) {
+SSLContext::HandshakeResult CryptoManagerImpl::SSLContextImpl::DoHandshakeStep(
+ const uint8_t* const in_data,
+ size_t in_data_size,
+ const uint8_t** const out_data,
+ size_t* out_data_size) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK(out_data);
DCHECK(out_data_size);
@@ -299,16 +312,15 @@ DoHandshakeStep(const uint8_t* const in_data, size_t in_data_size,
// TODO(Ezamakhov): add test - hanshake fail -> restart StartHandshake
{
- sync_primitives::AutoLock locker(bio_locker);
+ sync_primitives::AutoLock locker(bio_locker);
- if (SSL_is_init_finished(connection_)) {
- LOG4CXX_DEBUG(logger_, "SSL initilization is finished");
- is_handshake_pending_ = false;
- return Handshake_Result_Success;
+ if (SSL_is_init_finished(connection_)) {
+ LOG4CXX_DEBUG(logger_, "SSL initilization is finished");
+ is_handshake_pending_ = false;
+ return Handshake_Result_Success;
}
}
-
if (!WriteHandshakeData(in_data, in_data_size)) {
return Handshake_Result_AbnormalFail;
}
@@ -327,14 +339,12 @@ DoHandshakeStep(const uint8_t* const in_data, size_t in_data_size,
return res;
}
-bool CryptoManagerImpl::SSLContextImpl::Encrypt(
- const uint8_t * const in_data, size_t in_data_size,
- const uint8_t ** const out_data, size_t *out_data_size) {
-
+bool CryptoManagerImpl::SSLContextImpl::Encrypt(const uint8_t* const in_data,
+ size_t in_data_size,
+ const uint8_t** const out_data,
+ size_t* out_data_size) {
sync_primitives::AutoLock locker(bio_locker);
- if (!SSL_is_init_finished(connection_) ||
- !in_data ||
- !in_data_size) {
+ if (!SSL_is_init_finished(connection_) || !in_data || !in_data_size) {
return false;
}
@@ -355,10 +365,10 @@ bool CryptoManagerImpl::SSLContextImpl::Encrypt(
return true;
}
-bool CryptoManagerImpl::SSLContextImpl::Decrypt(
- const uint8_t * const in_data, size_t in_data_size,
- const uint8_t ** const out_data, size_t *out_data_size) {
-
+bool CryptoManagerImpl::SSLContextImpl::Decrypt(const uint8_t* const in_data,
+ size_t in_data_size,
+ const uint8_t** const out_data,
+ size_t* out_data_size) {
sync_primitives::AutoLock locker(bio_locker);
if (!SSL_is_init_finished(connection_)) {
return false;
@@ -433,7 +443,7 @@ void CryptoManagerImpl::SSLContextImpl::ResetConnection() {
SSL_shutdown(connection_);
}
LOG4CXX_DEBUG(logger_, "SSL connection recreation");
- SSL_CTX * ssl_context = connection_->ctx;
+ SSL_CTX* ssl_context = connection_->ctx;
SSL_free(connection_);
connection_ = SSL_new(ssl_context);
if (mode_ == SERVER) {
@@ -454,35 +464,38 @@ void CryptoManagerImpl::SSLContextImpl::SetHandshakeContext(
void CryptoManagerImpl::SSLContextImpl::EnsureBufferSizeEnough(size_t size) {
if (buffer_size_ < size) {
delete[] buffer_;
- buffer_ = new(std::nothrow) uint8_t[size];
+ buffer_ = new (std::nothrow) uint8_t[size];
if (buffer_) {
buffer_size_ = size;
}
- }
+ }
}
SSLContext::HandshakeResult
CryptoManagerImpl::SSLContextImpl::openssl_error_convert_to_internal(
const long error) {
- switch(error) {
- case X509_V_ERR_CERT_HAS_EXPIRED: return Handshake_Result_CertExpired;
- case X509_V_ERR_CERT_NOT_YET_VALID: return Handshake_Result_NotYetValid;
+ switch (error) {
+ case X509_V_ERR_CERT_HAS_EXPIRED:
+ return Handshake_Result_CertExpired;
+ case X509_V_ERR_CERT_NOT_YET_VALID:
+ return Handshake_Result_NotYetValid;
case X509_V_ERR_SUBJECT_ISSUER_MISMATCH:
case X509_V_ERR_CERT_SIGNATURE_FAILURE:
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
return Handshake_Result_CertNotSigned;
- default: return Handshake_Result_Fail;
+ default:
+ return Handshake_Result_Fail;
}
}
-std::string CryptoManagerImpl::SSLContextImpl::GetTextBy(
- X509_NAME* name, int object) const {
+std::string CryptoManagerImpl::SSLContextImpl::GetTextBy(X509_NAME* name,
+ int object) const {
const int req_len = X509_NAME_get_text_by_NID(name, object, NULL, 0);
if (-1 == req_len) {
- LOG4CXX_WARN(logger_, "Unable to obtain object: " << object
- << " from certificate");
+ LOG4CXX_WARN(logger_,
+ "Unable to obtain object: " << object << " from certificate");
return std::string();
}
@@ -490,10 +503,9 @@ std::string CryptoManagerImpl::SSLContextImpl::GetTextBy(
data.resize(req_len + 1);
X509_NAME_get_text_by_NID(name, object, &data.front(), data.size());
- std::string str (data.begin(), data.end() - 1);
+ std::string str(data.begin(), data.end() - 1);
- std::transform(str.begin(), str.end(),
- str.begin(), ::tolower);
+ std::transform(str.begin(), str.end(), str.begin(), ::tolower);
return str;
}
diff --git a/src/components/security_manager/test/ssl_certificate_handshake_test.cc b/src/components/security_manager/test/ssl_certificate_handshake_test.cc
index 4e77b4a4f7..2ce7f16abb 100644
--- a/src/components/security_manager/test/ssl_certificate_handshake_test.cc
+++ b/src/components/security_manager/test/ssl_certificate_handshake_test.cc
@@ -93,9 +93,13 @@ class SSLHandshakeTest : public testing::Test {
std::stringstream ss;
ss << cert.rdbuf();
cert.close();
- const bool initialized = server_manager->Init(
- security_manager::SERVER, protocol, ss.str(), ciphers_list, verify_peer,
- cacertificate_path, updates_before_hour);
+ const bool initialized = server_manager->Init(security_manager::SERVER,
+ protocol,
+ ss.str(),
+ ciphers_list,
+ verify_peer,
+ cacertificate_path,
+ updates_before_hour);
if (!initialized) {
return false;
}
@@ -107,7 +111,8 @@ class SSLHandshakeTest : public testing::Test {
}
security_manager::SSLContext::HandshakeContext ctx;
- server_ctx->SetHandshakeContext(ctx.make_context("SPT", "client"));
+ server_ctx->SetHandshakeContext(ctx.make_context(custom_str::CustomString("SPT"),
+ custom_str::CustomString("client")));
return true;
}
@@ -121,9 +126,13 @@ class SSLHandshakeTest : public testing::Test {
std::stringstream ss;
ss << cert.rdbuf();
cert.close();
- const bool initialized = client_manager->Init(
- security_manager::CLIENT, protocol, ss.str(), ciphers_list, verify_peer,
- cacertificate_path, updates_before_hour);
+ const bool initialized = client_manager->Init(security_manager::CLIENT,
+ protocol,
+ ss.str(),
+ ciphers_list,
+ verify_peer,
+ cacertificate_path,
+ updates_before_hour);
if (!initialized) {
return false;
}
@@ -134,7 +143,8 @@ class SSLHandshakeTest : public testing::Test {
}
security_manager::SSLContext::HandshakeContext ctx;
- client_ctx->SetHandshakeContext(ctx.make_context("SPT", "server"));
+ client_ctx->SetHandshakeContext(ctx.make_context(
+ custom_str::CustomString("SPT"), custom_str::CustomString("server")));
return true;
}
@@ -159,15 +169,15 @@ class SSLHandshakeTest : public testing::Test {
while (true) {
ASSERT_EQ(SSLContext::Handshake_Result_Success,
- server_ctx->DoHandshakeStep(client_buf, client_buf_len,
- &server_buf, &server_buf_len))
+ server_ctx->DoHandshakeStep(
+ client_buf, client_buf_len, &server_buf, &server_buf_len))
<< ERR_reason_error_string(ERR_get_error());
ASSERT_FALSE(server_buf == NULL);
ASSERT_GT(server_buf_len, 0u);
ASSERT_EQ(SSLContext::Handshake_Result_Success,
- client_ctx->DoHandshakeStep(server_buf, server_buf_len,
- &client_buf, &client_buf_len))
+ client_ctx->DoHandshakeStep(
+ server_buf, server_buf_len, &client_buf, &client_buf_len))
<< ERR_reason_error_string(ERR_get_error());
if (server_ctx->IsInitCompleted()) {
break;
@@ -198,8 +208,8 @@ class SSLHandshakeTest : public testing::Test {
ASSERT_GT(server_buf_len, 0u);
ASSERT_EQ(SSLContext::Handshake_Result_Success,
- client_ctx->DoHandshakeStep(server_buf, server_buf_len,
- &client_buf, &client_buf_len))
+ client_ctx->DoHandshakeStep(
+ server_buf, server_buf_len, &client_buf, &client_buf_len))
<< ERR_reason_error_string(ERR_get_error());
ASSERT_FALSE(client_ctx->IsInitCompleted())
<< "Expected server side handshake fail";
@@ -218,8 +228,8 @@ class SSLHandshakeTest : public testing::Test {
while (true) {
ASSERT_EQ(SSLContext::Handshake_Result_Success,
- server_ctx->DoHandshakeStep(client_buf, client_buf_len,
- &server_buf, &server_buf_len))
+ server_ctx->DoHandshakeStep(
+ client_buf, client_buf_len, &server_buf, &server_buf_len))
<< ERR_reason_error_string(ERR_get_error());
ASSERT_FALSE(server_buf == NULL);
@@ -255,38 +265,59 @@ class SSLHandshakeTest : public testing::Test {
};
TEST_F(SSLHandshakeTest, NoVerification) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", skip_peer_verification, ""))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", skip_peer_verification, ""))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_Success());
}
TEST_F(SSLHandshakeTest, CAVerification_ServerSide) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", verify_peer, client_ca_cert_filename))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ verify_peer,
+ client_ca_cert_filename))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", skip_peer_verification, ""))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_Success());
}
TEST_F(SSLHandshakeTest, CAVerification_ServerSide_NoCACertificate) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", verify_peer, "unex"))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ verify_peer,
+ "unex"))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", skip_peer_verification, ""))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_ServerSideFail());
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", verify_peer, client_ca_cert_filename))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ verify_peer,
+ client_ca_cert_filename))
<< server_manager->LastError();
GTEST_TRACE(ResetConnections());
@@ -295,29 +326,44 @@ TEST_F(SSLHandshakeTest, CAVerification_ServerSide_NoCACertificate) {
}
TEST_F(SSLHandshakeTest, CAVerification_ClientSide) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", verify_peer, client_ca_cert_filename))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ verify_peer,
+ client_ca_cert_filename))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", verify_peer, server_ca_cert_filename))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ verify_peer,
+ server_ca_cert_filename))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_Success());
}
TEST_F(SSLHandshakeTest, CAVerification_ClientSide_NoCACertificate) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", skip_peer_verification, ""))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", verify_peer, "client_ca_cert_filename"))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ verify_peer,
+ "client_ca_cert_filename"))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_ClientSideFail(
security_manager::SSLContext::Handshake_Result_Fail));
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", verify_peer, server_ca_cert_filename))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ verify_peer,
+ server_ca_cert_filename))
<< client_manager->LastError();
GTEST_TRACE(ResetConnections());
@@ -326,11 +372,17 @@ TEST_F(SSLHandshakeTest, CAVerification_ClientSide_NoCACertificate) {
}
TEST_F(SSLHandshakeTest, CAVerification_BothSides) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", verify_peer, client_ca_cert_filename))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ verify_peer,
+ client_ca_cert_filename))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", verify_peer, server_ca_cert_filename))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ verify_peer,
+ server_ca_cert_filename))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_Success());
@@ -338,11 +390,16 @@ TEST_F(SSLHandshakeTest, CAVerification_BothSides) {
TEST_F(SSLHandshakeTest, UnsignedCert) {
ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
- server_unsigned_cert_file, "ALL",
- skip_peer_verification, ""))
+ server_unsigned_cert_file,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", verify_peer, client_ca_cert_filename))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ verify_peer,
+ client_ca_cert_filename))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_ClientSideFail(
security_manager::SSLContext::Handshake_Result_CertNotSigned));
@@ -350,11 +407,16 @@ TEST_F(SSLHandshakeTest, UnsignedCert) {
TEST_F(SSLHandshakeTest, ExpiredCert) {
ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
- server_expired_cert_file, "ALL", verify_peer,
+ server_expired_cert_file,
+ "ALL",
+ verify_peer,
client_ca_cert_filename))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", verify_peer, server_ca_cert_filename))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ verify_peer,
+ server_ca_cert_filename))
<< client_manager->LastError();
GTEST_TRACE(HandshakeProcedure_ClientSideFail(
@@ -362,32 +424,46 @@ TEST_F(SSLHandshakeTest, ExpiredCert) {
}
TEST_F(SSLHandshakeTest, AppNameAndAppIDInvalid) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", verify_peer, client_ca_cert_filename))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ verify_peer,
+ client_ca_cert_filename))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", verify_peer, server_ca_cert_filename))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ verify_peer,
+ server_ca_cert_filename))
<< client_manager->LastError();
security_manager::SSLContext::HandshakeContext ctx;
- client_ctx->SetHandshakeContext(ctx.make_context("server", "Wrong"));
+ client_ctx->SetHandshakeContext(ctx.make_context(
+ custom_str::CustomString("server"), custom_str::CustomString("Wrong")));
GTEST_TRACE(HandshakeProcedure_ClientSideFail(
security_manager::SSLContext::Handshake_Result_AppNameMismatch));
ResetConnections();
- client_ctx->SetHandshakeContext(ctx.make_context("Wrong", "server"));
+ client_ctx->SetHandshakeContext(ctx.make_context(
+ custom_str::CustomString("Wrong"), custom_str::CustomString("server")));
GTEST_TRACE(HandshakeProcedure_ClientSideFail(
security_manager::SSLContext::Handshake_Result_AppIDMismatch));
}
TEST_F(SSLHandshakeTest, NoVerification_ResetConnection) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", skip_peer_verification, ""))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", skip_peer_verification, ""))
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ skip_peer_verification,
+ ""))
<< client_manager->LastError();
const int times = 100;
@@ -401,11 +477,16 @@ TEST_F(SSLHandshakeTest, NoVerification_ResetConnection) {
}
TEST_F(SSLHandshakeTest, CAVerification_BothSides_ResetConnection) {
- ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2, server_certificate,
- "ALL", verify_peer, client_ca_cert_filename))
+ ASSERT_TRUE(InitServerManagers(security_manager::TLSv1_2,
+ server_certificate,
+ "ALL",
+ verify_peer,
+ client_ca_cert_filename))
<< server_manager->LastError();
- ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2, client_certificate,
- "ALL", skip_peer_verification,
+ ASSERT_TRUE(InitClientManagers(security_manager::TLSv1_2,
+ client_certificate,
+ "ALL",
+ skip_peer_verification,
server_ca_cert_filename))
<< client_manager->LastError();
diff --git a/src/components/security_manager/test/ssl_context_test.cc b/src/components/security_manager/test/ssl_context_test.cc
index d36e9135fe..b1ec9902f3 100644
--- a/src/components/security_manager/test/ssl_context_test.cc
+++ b/src/components/security_manager/test/ssl_context_test.cc
@@ -69,15 +69,25 @@ class SSLTest : public testing::Test {
ss << file.rdbuf();
file.close();
crypto_manager = new security_manager::CryptoManagerImpl();
- const bool crypto_manager_initialization = crypto_manager->Init(
- security_manager::SERVER, security_manager::TLSv1_2, ss.str(),
- FORD_CIPHER, false, "", updates_before_hour);
+ const bool crypto_manager_initialization =
+ crypto_manager->Init(security_manager::SERVER,
+ security_manager::TLSv1_2,
+ ss.str(),
+ FORD_CIPHER,
+ false,
+ "",
+ updates_before_hour);
EXPECT_TRUE(crypto_manager_initialization);
client_manager = new security_manager::CryptoManagerImpl();
- const bool client_manager_initialization = client_manager->Init(
- security_manager::CLIENT, security_manager::TLSv1_2, "", FORD_CIPHER,
- false, "", updates_before_hour);
+ const bool client_manager_initialization =
+ client_manager->Init(security_manager::CLIENT,
+ security_manager::TLSv1_2,
+ "",
+ FORD_CIPHER,
+ false,
+ "",
+ updates_before_hour);
EXPECT_TRUE(client_manager_initialization);
}
@@ -91,7 +101,8 @@ class SSLTest : public testing::Test {
client_ctx = client_manager->CreateSSLContext();
security_manager::SSLContext::HandshakeContext ctx;
- ctx.make_context("SPT", "client");
+ ctx.make_context(custom_str::CustomString("SPT"),
+ custom_str::CustomString("client"));
server_ctx->SetHandshakeContext(ctx);
ctx.expected_cn = "server";
@@ -128,8 +139,8 @@ TEST_F(SSLTest, BrokenHandshake) {
const_cast<uint8_t*>(client_buf)[client_buf_len / 2] ^= 0xFF;
const_cast<uint8_t*>(client_buf)[client_buf_len - 1] ^= 0xFF;
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_AbnormalFail,
- server_ctx->DoHandshakeStep(client_buf, client_buf_len, &server_buf,
- &server_buf_len));
+ server_ctx->DoHandshakeStep(
+ client_buf, client_buf_len, &server_buf, &server_buf_len));
}
TEST_F(SSLTest, Positive) {
@@ -145,14 +156,14 @@ TEST_F(SSLTest, Positive) {
for (;;) {
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
- server_ctx->DoHandshakeStep(client_buf, client_buf_len,
- &server_buf, &server_buf_len));
+ server_ctx->DoHandshakeStep(
+ client_buf, client_buf_len, &server_buf, &server_buf_len));
ASSERT_FALSE(server_buf == NULL);
ASSERT_GT(server_buf_len, 0u);
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
- client_ctx->DoHandshakeStep(server_buf, server_buf_len,
- &client_buf, &client_buf_len));
+ client_ctx->DoHandshakeStep(
+ server_buf, server_buf_len, &client_buf, &client_buf_len));
if (server_ctx->IsInitCompleted()) {
break;
}
@@ -172,15 +183,15 @@ TEST_F(SSLTest, Positive) {
const uint8_t* encrypted_text = 0;
size_t text_len = 4;
size_t encrypted_text_len;
- EXPECT_TRUE(client_ctx->Encrypt(text, text_len, &encrypted_text,
- &encrypted_text_len));
+ EXPECT_TRUE(client_ctx->Encrypt(
+ text, text_len, &encrypted_text, &encrypted_text_len));
ASSERT_NE(encrypted_text, reinterpret_cast<void*>(NULL));
ASSERT_GT(encrypted_text_len, 0u);
// Decrypt text on server side
- EXPECT_TRUE(server_ctx->Decrypt(encrypted_text, encrypted_text_len, &text,
- &text_len));
+ EXPECT_TRUE(server_ctx->Decrypt(
+ encrypted_text, encrypted_text_len, &text, &text_len));
ASSERT_NE(text, reinterpret_cast<void*>(NULL));
ASSERT_GT(text_len, 0u);
@@ -199,14 +210,14 @@ TEST_F(SSLTest, EcncryptionFail) {
ASSERT_FALSE(client_buf == NULL);
ASSERT_GT(client_buf_len, 0u);
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
- server_ctx->DoHandshakeStep(client_buf, client_buf_len,
- &server_buf, &server_buf_len));
+ server_ctx->DoHandshakeStep(
+ client_buf, client_buf_len, &server_buf, &server_buf_len));
ASSERT_FALSE(server_buf == NULL);
ASSERT_GT(server_buf_len, 0u);
ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
- client_ctx->DoHandshakeStep(server_buf, server_buf_len,
- &client_buf, &client_buf_len));
+ client_ctx->DoHandshakeStep(
+ server_buf, server_buf_len, &client_buf, &client_buf_len));
}
// expect empty buffers after init complete
ASSERT_TRUE(client_buf == NULL);
@@ -220,8 +231,8 @@ TEST_F(SSLTest, EcncryptionFail) {
const uint8_t* encrypted_text = 0;
size_t text_len = 4;
size_t encrypted_text_len;
- EXPECT_TRUE(client_ctx->Encrypt(text, text_len, &encrypted_text,
- &encrypted_text_len));
+ EXPECT_TRUE(client_ctx->Encrypt(
+ text, text_len, &encrypted_text, &encrypted_text_len));
ASSERT_NE(encrypted_text, reinterpret_cast<void*>(NULL));
ASSERT_GT(encrypted_text_len, 0u);
@@ -233,15 +244,15 @@ TEST_F(SSLTest, EcncryptionFail) {
const uint8_t* out_text;
size_t out_text_size;
// Decrypt broken text on server side
- EXPECT_FALSE(server_ctx->Decrypt(&broken[0], broken.size(), &out_text,
- &out_text_size));
+ EXPECT_FALSE(server_ctx->Decrypt(
+ &broken[0], broken.size(), &out_text, &out_text_size));
// Check after broken message that server encryption and decryption fail
// Encrypte message on server side
- EXPECT_FALSE(server_ctx->Decrypt(encrypted_text, encrypted_text_len,
- &out_text, &out_text_size));
- EXPECT_FALSE(server_ctx->Encrypt(text, text_len, &encrypted_text,
- &encrypted_text_len));
+ EXPECT_FALSE(server_ctx->Decrypt(
+ encrypted_text, encrypted_text_len, &out_text, &out_text_size));
+ EXPECT_FALSE(server_ctx->Encrypt(
+ text, text_len, &encrypted_text, &encrypted_text_len));
}
} // namespace ssl_context_test
diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h
index b8bafb77de..688550b040 100644
--- a/src/components/smart_objects/include/smart_objects/smart_object.h
+++ b/src/components/smart_objects/include/smart_objects/smart_object.h
@@ -39,9 +39,13 @@
#include <map>
#include "smart_objects/smart_schema.h"
+#include "utils/custom_string.h"
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
+
+namespace custom_str = utils::custom_string;
+
class SmartObject;
/**
@@ -89,7 +93,8 @@ enum SmartType {
SmartType_Array = 7,
/**
- * @brief Binary data value. Gives possibility for object to store binary data.
+ * @brief Binary data value. Gives possibility for object to store binary
+ *data.
**/
SmartType_Binary = 8,
@@ -99,7 +104,8 @@ enum SmartType {
SmartType_UInteger = 9,
/**
- * @brief Invalid value. Represents invalid object that cannot change his type.
+ * @brief Invalid value. Represents invalid object that cannot change his
+ *type.
**/
SmartType_Invalid = -1
};
@@ -129,8 +135,10 @@ typedef std::vector<SmartObjectSPtr> SmartObjectList;
/**
* @brief Main SmartObject class
*
- * This class act as Variant type from other languages and can be used as primitive type
- * like bool, int32_t, char, double, string and as complex type like array and map.
+ * This class act as Variant type from other languages and can be used as
+ *primitive type
+ * like bool, int32_t, char, double, string and as complex type like array and
+ *map.
**/
class SmartObject FINAL {
@@ -155,7 +163,7 @@ class SmartObject FINAL {
*
* @param pointer
**/
- template<typename UnknownType>
+ template <typename UnknownType>
SmartObject(const UnknownType&);
/**
@@ -293,13 +301,13 @@ class SmartObject FINAL {
* @{
**/
- /**
- * @brief Assignment operator for type: uint64_t
- *
- * @param NewValue New object value
- * @return SmartObject&
- **/
- SmartObject& operator=(const uint64_t NewValue);
+ /**
+ * @brief Assignment operator for type: uint64_t
+ *
+ * @param NewValue New object value
+ * @return SmartObject&
+ **/
+ SmartObject& operator=(const uint64_t NewValue);
/** @} */
@@ -420,6 +428,13 @@ class SmartObject FINAL {
explicit SmartObject(const std::string& InitialValue);
/**
+ * @brief Constructor for creating object of type: CustomString
+ *
+ * @param InitialValue Initial object value
+ **/
+ explicit SmartObject(const custom_str::CustomString& InitialValue);
+
+ /**
* @brief Constructor for creating object of type: string
*
* @param InitialValue Initial object value
@@ -427,6 +442,13 @@ class SmartObject FINAL {
explicit SmartObject(const char* InitialValue);
/**
+ * @brief Returns current object converted to CustomString
+ *
+ * @return custom_str::CustomString
+ **/
+ custom_str::CustomString asCustomString() const;
+
+ /**
* @brief Returns current object converted to string
*
* @return std::string
@@ -442,6 +464,14 @@ class SmartObject FINAL {
const char* asCharArray() const;
/**
+ * @brief Assignment operator for type: CustomString
+ *
+ * @param NewValue New object value
+ * @return SmartObject&
+ **/
+ SmartObject& operator=(const custom_str::CustomString& NewValue);
+
+ /**
* @brief Assignment operator for type: string
*
* @param NewValue New object value
@@ -692,7 +722,7 @@ class SmartObject FINAL {
* @param Other value to be compared with
* @return bool Result of nequation
**/
- template<typename Type>
+ template <typename Type>
bool operator!=(const Type& Other) const {
return !(*this == Other);
}
@@ -716,7 +746,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to int32_t type
*
- * @return int32_t Converted value or invalid_int_value if conversion not possible
+ * @return int32_t Converted value or invalid_int_value if conversion not
+ *possible
**/
inline int64_t convert_int() const;
/** @} */
@@ -738,7 +769,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to char type
*
- * @return int32_t Converted value or invalid_char_value if conversion not possible
+ * @return int32_t Converted value or invalid_char_value if conversion not
+ *possible
**/
inline char convert_char() const;
/** @} */
@@ -760,7 +792,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to double type
*
- * @return int32_t Converted value or invalid_double_value if conversion not possible
+ * @return int32_t Converted value or invalid_double_value if conversion not
+ *possible
**/
inline double convert_double() const;
/** @} */
@@ -782,16 +815,13 @@ class SmartObject FINAL {
/**
* @brief Converts object to bool type
*
- * @return int32_t Converted value or invalid_bool_value if conversion not possible
+ * @return int32_t Converted value or invalid_bool_value if conversion not
+ *possible
**/
inline bool convert_bool() const;
/** @} */
/**
- * @name Support of type: string (internal)
- * @{
- */
- /**
* @brief Sets new string value to the object.
*
* This method changes also internal object type
@@ -799,10 +829,10 @@ class SmartObject FINAL {
* @param NewValue New object value
* @return void
**/
- inline void set_value_string(const std::string& NewValue);
+ inline void set_value_string(const custom_str::CustomString& NewValue);
/**
- * @brief Sets new string value to the object.
+ * @brief Sets new CustomString value to the object.
*
* This method changes also internal object type
*
@@ -814,12 +844,21 @@ class SmartObject FINAL {
/**
* @brief Converts object to string type
*
- * @return int32_t Converted value or invalid_string_value if conversion not possible
+ * @return int32_t Converted value or invalid_string_value if conversion not
+ *possible
**/
inline std::string convert_string() const;
/** @} */
/**
+ * @brief Converts object to CustomString type
+ *
+ * @return CustomString Converted value or
+ * invalid_string_value if conversion not possible
+ **/
+ inline custom_str::CustomString convert_custom_string() const;
+
+ /**
* @name Support of type: binary (internal)
* @{
*/
@@ -836,7 +875,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to binary type
*
- * @return int32_t Converted value or invalid_binary_value if conversion not possible
+ * @return int32_t Converted value or invalid_binary_value if conversion not
+ *possible
**/
inline SmartBinary convert_binary() const;
@@ -862,7 +902,7 @@ class SmartObject FINAL {
* @param Value Pointer to string to convert
* @return double
**/
- static double convert_string_to_double(const std::string* Value);
+ static double convert_string_to_double(const custom_str::CustomString* Value);
/**
* @brief Converts string to int64_t
@@ -870,7 +910,8 @@ class SmartObject FINAL {
* @param Value Pointer to string to convert
* @return int64_t int64_t
**/
- static uint64_t convert_string_to_integer(const std::string* Value);
+ static uint64_t convert_string_to_integer(
+ const custom_str::CustomString* Value);
/**
* @brief Converts double value to string
@@ -920,7 +961,7 @@ class SmartObject FINAL {
bool bool_value;
char char_value;
int64_t int_value;
- std::string* str_value;
+ custom_str::CustomString* str_value;
SmartArray* array_value;
SmartMap* map_value;
SmartBinary* binary_value;
diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc
index 5b6df0b5d9..5c90de5671 100644
--- a/src/components/smart_objects/src/smart_object.cc
+++ b/src/components/smart_objects/src/smart_object.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,22 +50,17 @@ namespace NsSmartObjects {
**/
static const char* invalid_cstr_value = "";
-SmartObject::SmartObject()
- : m_type(SmartType_Null),
- m_schema() {
+SmartObject::SmartObject() : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
}
SmartObject::SmartObject(const SmartObject& Other)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
duplicate(Other);
}
-SmartObject::SmartObject(SmartType Type)
- : m_type(SmartType_Null),
- m_schema() {
+SmartObject::SmartObject(SmartType Type) : m_type(SmartType_Null), m_schema() {
switch (Type) {
case SmartType_Null:
break;
@@ -85,7 +80,7 @@ SmartObject::SmartObject(SmartType Type)
set_value_char(' ');
break;
case SmartType_String:
- set_value_string("");
+ set_value_string(custom_str::CustomString());
break;
case SmartType_Map:
m_data.map_value = new SmartMap();
@@ -139,17 +134,19 @@ bool SmartObject::operator==(const SmartObject& Other) const {
return true;
if (m_data.map_value->size() != Other.m_data.map_value->size())
return false;
- return std::equal(m_data.map_value->begin(), m_data.map_value->end(),
+ return std::equal(m_data.map_value->begin(),
+ m_data.map_value->end(),
Other.m_data.map_value->begin());
- }
+ }
case SmartType_Array: {
if (m_data.array_value == Other.m_data.array_value)
return true;
if (m_data.array_value->size() != Other.m_data.array_value->size())
return false;
- return std::equal(m_data.array_value->begin(), m_data.array_value->end(),
+ return std::equal(m_data.array_value->begin(),
+ m_data.array_value->end(),
Other.m_data.array_value->begin());
- }
+ }
case SmartType_Binary: {
if (m_data.binary_value == Other.m_data.binary_value)
return true;
@@ -158,7 +155,7 @@ bool SmartObject::operator==(const SmartObject& Other) const {
return std::equal(m_data.binary_value->begin(),
m_data.binary_value->end(),
Other.m_data.binary_value->begin());
- }
+ }
case SmartType_Null:
return true;
case SmartType_Invalid:
@@ -171,8 +168,7 @@ bool SmartObject::operator==(const SmartObject& Other) const {
}
SmartObject::SmartObject(int32_t InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_integer(InitialValue);
}
@@ -201,8 +197,8 @@ bool SmartObject::operator==(const int32_t Value) const {
}
void SmartObject::set_value_integer(int64_t NewValue) {
- if (NewValue > std::numeric_limits<int32_t>::max()
- && NewValue <= std::numeric_limits<uint32_t>::max()) {
+ if (NewValue > std::numeric_limits<int32_t>::max() &&
+ NewValue <= std::numeric_limits<uint32_t>::max()) {
set_new_type(SmartType_UInteger);
} else {
set_new_type(SmartType_Integer);
@@ -229,8 +225,7 @@ int64_t SmartObject::convert_int() const {
}
SmartObject::SmartObject(uint32_t InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_integer(InitialValue);
}
@@ -259,8 +254,7 @@ bool SmartObject::operator==(const uint32_t Value) const {
}
SmartObject::SmartObject(int64_t InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_integer(InitialValue);
}
@@ -288,8 +282,7 @@ SmartObject& SmartObject::operator=(const uint64_t NewValue) {
}
SmartObject::SmartObject(double InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_double(InitialValue);
}
@@ -335,8 +328,7 @@ double SmartObject::convert_double() const {
}
SmartObject::SmartObject(bool InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_bool(InitialValue);
}
@@ -381,8 +373,7 @@ bool SmartObject::convert_bool() const {
}
SmartObject::SmartObject(char InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_char(InitialValue);
}
@@ -414,9 +405,10 @@ void SmartObject::set_value_char(char NewValue) {
char SmartObject::convert_char() const {
switch (m_type) {
case SmartType_String:
- return
- (m_data.str_value->length() == 1) ?
- m_data.str_value->at(0) : invalid_char_value;
+ return (m_data.str_value->length() == 1 &&
+ m_data.str_value->is_ascii_string())
+ ? m_data.str_value->at(0)
+ : invalid_char_value;
case SmartType_Character:
return m_data.char_value;
default:
@@ -425,17 +417,30 @@ char SmartObject::convert_char() const {
return invalid_char_value;
}
-SmartObject::SmartObject(const std::string& InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+// =============================================================
+// STD::STRING TYPE SUPPORT
+// =============================================================
+
+SmartObject::SmartObject(const custom_str::CustomString& InitialValue)
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_string(InitialValue);
}
+SmartObject::SmartObject(const std::string& InitialValue)
+ : m_type(SmartType_Null), m_schema() {
+ m_data.str_value = NULL;
+ set_value_string(custom_str::CustomString(InitialValue));
+}
+
std::string SmartObject::asString() const {
return convert_string();
}
+custom_str::CustomString SmartObject::asCustomString() const {
+ return convert_custom_string();
+}
+
const char* SmartObject::asCharArray() const {
if (m_data.str_value != NULL) {
return m_data.str_value->c_str();
@@ -445,46 +450,65 @@ const char* SmartObject::asCharArray() const {
SmartObject& SmartObject::operator=(const std::string& NewValue) {
if (m_type != SmartType_Invalid) {
+ set_value_string(custom_str::CustomString(NewValue));
+ }
+ return *this;
+}
+
+SmartObject& SmartObject::operator=(const custom_str::CustomString& NewValue) {
+ if (m_type != SmartType_Invalid) {
set_value_string(NewValue);
}
return *this;
}
bool SmartObject::operator==(const std::string& Value) const {
- const std::string comp = convert_string();
+ const custom_str::CustomString& comp(convert_custom_string());
if (comp == invalid_string_value) {
return false;
}
return comp == Value;
}
-void SmartObject::set_value_string(const std::string& NewValue) {
+void SmartObject::set_value_string(const custom_str::CustomString& NewValue) {
set_new_type(SmartType_String);
- m_data.str_value = new std::string(NewValue);
+ m_data.str_value = new custom_str::CustomString(NewValue);
}
std::string SmartObject::convert_string() const {
switch (m_type) {
- case SmartType_String:
- return *(m_data.str_value);
case SmartType_Integer: {
- std::stringstream stream;
- stream << m_data.int_value;
- return stream.str();
- }
+ std::stringstream stream;
+ stream << m_data.int_value;
+ return stream.str();
+ }
case SmartType_Character:
return std::string(1, m_data.char_value);
case SmartType_Double:
return convert_double_to_string(m_data.double_value);
+ case SmartType_String:
+ return (m_data.str_value)->AsMBString();
default:
break;
}
return NsSmartDeviceLink::NsSmartObjects::invalid_cstr_value;
}
+custom_str::CustomString SmartObject::convert_custom_string() const {
+ switch (m_type) {
+ case SmartType_String:
+ return *(m_data.str_value);
+ default:
+ return custom_str::CustomString(convert_string());
+ }
+}
+
+// =============================================================
+// CHAR* TYPE SUPPORT
+// =============================================================
+
SmartObject::SmartObject(const char* const InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_cstr(InitialValue);
return;
@@ -498,7 +522,7 @@ SmartObject& SmartObject::operator=(const char* NewValue) {
}
bool SmartObject::operator==(const char* Value) const {
- const std::string comp = convert_string();
+ const custom_str::CustomString& comp(convert_custom_string());
if (comp == invalid_string_value) {
return false;
}
@@ -506,12 +530,15 @@ bool SmartObject::operator==(const char* Value) const {
}
void SmartObject::set_value_cstr(const char* NewValue) {
- set_value_string(NewValue ? std::string(NewValue) : std::string());
+ set_value_string(NewValue ? custom_str::CustomString(NewValue)
+ : custom_str::CustomString());
}
+// =============================================================
+// BINARY TYPE SUPPORT
+// =============================================================
SmartObject::SmartObject(const SmartBinary& InitialValue)
- : m_type(SmartType_Null),
- m_schema() {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_binary(InitialValue);
}
@@ -559,6 +586,10 @@ SmartBinary SmartObject::convert_binary() const {
return invalid_binary_value;
}
+// =============================================================
+// ARRAY INTERFACE SUPPORT
+// =============================================================
+
SmartObject& SmartObject::operator[](const int32_t Index) {
return handle_array_access(Index);
}
@@ -590,11 +621,15 @@ inline SmartObject& SmartObject::handle_array_access(const int32_t Index) {
return invalid_object_value;
}
+// =============================================================
+// MAP INTERFACE SUPPORT
+// =============================================================
+
SmartObject& SmartObject::operator[](const std::string& Key) {
return handle_map_access(Key);
}
-const SmartObject& SmartObject::operator[] (const std::string& Key) const {
+const SmartObject& SmartObject::operator[](const std::string& Key) const {
return getElement(Key);
}
@@ -648,11 +683,14 @@ SmartObject& SmartObject::handle_map_access(const std::string& Key) {
return map[Key];
}
+// =============================================================
+// OTHER METHODS
+// =============================================================
void SmartObject::duplicate(const SmartObject& OtherObject) {
SmartData newData;
const SmartType newType = OtherObject.m_type;
switch (newType) {
- case SmartType_Null: // on duplicate empty SmartObject
+ case SmartType_Null: // on duplicate empty SmartObject
return;
case SmartType_Map:
newData.map_value = new SmartMap(*OtherObject.m_data.map_value);
@@ -673,7 +711,8 @@ void SmartObject::duplicate(const SmartObject& OtherObject) {
newData.char_value = OtherObject.m_data.char_value;
break;
case SmartType_String:
- newData.str_value = new std::string(*OtherObject.m_data.str_value);
+ newData.str_value =
+ new custom_str::CustomString(*OtherObject.m_data.str_value);
break;
case SmartType_Binary:
newData.binary_value = new SmartBinary(*OtherObject.m_data.binary_value);
@@ -746,8 +785,9 @@ void SmartObject::set_new_type(SmartType NewType) {
m_type = NewType;
}
-double SmartObject::convert_string_to_double(const std::string* Value) {
- if (!Value || Value->empty()) {
+double SmartObject::convert_string_to_double(
+ const custom_str::CustomString* Value) {
+ if (!Value || Value->empty() || !(Value->is_ascii_string())) {
return invalid_double_value;
}
@@ -780,12 +820,13 @@ std::string SmartObject::convert_double_to_string(const double& Value) {
return s;
}
-uint64_t SmartObject::convert_string_to_integer(const std::string* Value) {
- if (!Value || Value->empty()) {
+uint64_t SmartObject::convert_string_to_integer(
+ const custom_str::CustomString* Value) {
+ if (!Value || Value->empty() || !(Value->is_ascii_string())) {
return invalid_int64_value;
}
int64_t result;
- std::stringstream stream(*Value);
+ std::stringstream stream(Value->AsMBString());
stream >> result;
if (stream.eof()) {
return result;
@@ -797,15 +838,16 @@ SmartType SmartObject::getType() const {
return m_type;
}
-std::string SmartObject::OperatorToTransform(const SmartMap::value_type &pair) {
- return pair.first;
+std::string SmartObject::OperatorToTransform(const SmartMap::value_type& pair) {
+ return pair.first;
}
std::set<std::string> SmartObject::enumerate() const {
std::set<std::string> keys;
if (m_type == SmartType_Map) {
- std::transform(m_data.map_value->begin(), m_data.map_value->end(),
+ std::transform(m_data.map_value->begin(),
+ m_data.map_value->end(),
std::inserter(keys, keys.end()),
&SmartObject::OperatorToTransform);
}
diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc
index c9c00e8896..3fac3a6cde 100644
--- a/src/components/smart_objects/src/string_schema_item.cc
+++ b/src/components/smart_objects/src/string_schema_item.cc
@@ -31,10 +31,13 @@
*/
#include "smart_objects/smart_object.h"
#include "smart_objects/string_schema_item.h"
+#include "utils/custom_string.h"
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
+namespace custom_str = utils::custom_string;
+
utils::SharedPtr<CStringSchemaItem> CStringSchemaItem::create(
const TSchemaItemParameter<size_t>& MinLength,
const TSchemaItemParameter<size_t>& MaxLength,
@@ -47,7 +50,7 @@ Errors::eType CStringSchemaItem::validate(const SmartObject& Object) {
return Errors::INVALID_VALUE;
}
- const std::string value = Object.asString();
+ const custom_str::CustomString value = Object.asCustomString();
size_t length;
if (mMinLength.getValue(length) && (value.size() < length)) {
@@ -71,10 +74,9 @@ CStringSchemaItem::CStringSchemaItem(
const TSchemaItemParameter<size_t>& MinLength,
const TSchemaItemParameter<size_t>& MaxLength,
const TSchemaItemParameter<std::string>& DefaultValue)
- : CDefaultSchemaItem<std::string>(DefaultValue),
- mMinLength(MinLength),
- mMaxLength(MaxLength) {
-}
+ : CDefaultSchemaItem<std::string>(DefaultValue)
+ , mMinLength(MinLength)
+ , mMaxLength(MaxLength) {}
} // namespace NsSmartObjects
} // namespace NsSmartDeviceLink
diff --git a/src/components/test_main.cc b/src/components/test_main.cc
index a0aee7614d..66013d78c4 100755..100644
--- a/src/components/test_main.cc
+++ b/src/components/test_main.cc
@@ -1,10 +1,12 @@
#include "gmock/gmock.h"
#include "utils/logger.h"
-
+#include "utils/custom_string.h"
+namespace custom_str = utils::custom_string;
int main(int argc, char** argv) {
- testing::InitGoogleMock(&argc, argv);
- const int result = RUN_ALL_TESTS();
- DEINIT_LOGGER();
- return result;
+ testing::InitGoogleMock(&argc, argv);
+ ::testing::DefaultValue<custom_str::CustomString>::Set(
+ custom_str::CustomString(""));
+ const int result = RUN_ALL_TESTS();
+ DEINIT_LOGGER();
+ return result;
}
-
diff --git a/src/components/utils/CMakeLists.txt b/src/components/utils/CMakeLists.txt
index cc301c5f4f..708f8abcfd 100644
--- a/src/components/utils/CMakeLists.txt
+++ b/src/components/utils/CMakeLists.txt
@@ -57,6 +57,7 @@ set (SOURCES
${UTILS_SRC_DIR}/appenders_loader.cc
${UTILS_SRC_DIR}/gen_hash.cc
${UTILS_SRC_DIR}/convert_utils.cc
+ ${UTILS_SRC_DIR}/custom_string.cc
)
if(ENABLE_LOG)
diff --git a/src/components/utils/include/utils/gen_hash.h b/src/components/utils/include/utils/gen_hash.h
index 2195f7dad7..acb2e28a1d 100644
--- a/src/components/utils/include/utils/gen_hash.h
+++ b/src/components/utils/include/utils/gen_hash.h
@@ -37,6 +37,10 @@
namespace utils {
+namespace custom_string {
+class CustomString;
+}
+
/**
* @brief generate random alphanumeric string of specified length
* @param size length of random string
@@ -54,12 +58,14 @@ const std::string gen_hash(size_t size);
int32_t Djb2HashFromString(const std::string& str_to_hash);
/**
- * @brief Allows to generate hash from the specified string.
+ * @brief Generates hash.
* The faq6 algorithm uses for hash generation.
- * @param str_to_hash - the string from which hash should be generated.
+ * @param str_to_hash - the CustomSting contains ASCII or UTF8 string from which
+ * hash should be generated.
* @return uint32_t hash for the specified string.
*/
-uint32_t Faq6HashFromString(const std::string& str_to_hash);
+uint32_t CaseInsensitiveFaq6HashFromString(
+ const custom_string::CustomString& str_to_hash);
/**
* @brief Transforms input string to lower case and then generates hash.
@@ -67,7 +73,7 @@ uint32_t Faq6HashFromString(const std::string& str_to_hash);
* @param str_to_hash - the string from which hash should be generated.
* @return uint32_t hash for the specified string.
*/
-uint32_t CaseInsensitiveFaq6HashFromString(const std::string& str_to_hash);
+uint32_t CaseInsensitiveFaq6HashFromString(const char* cstr);
} // namespace utils
diff --git a/src/components/utils/src/custom_string.cc b/src/components/utils/src/custom_string.cc
index 14078568d5..081ca0b45e 100644
--- a/src/components/utils/src/custom_string.cc
+++ b/src/components/utils/src/custom_string.cc
@@ -40,34 +40,34 @@
#include "utils/logger.h"
#include "utils/macro.h"
-
namespace {
namespace custom_str = utils::custom_string;
-//Calculates amount of characters in UTF string
+// Calculates amount of characters in UTF string
size_t CalculateLengthOfString(const char* str) {
size_t length_of_string = 0;
- for(size_t i = 0; str[i] != '\0'; ++i) {
- if ((str[i] & custom_str::kHigestByteOfUTF8Byte2) != custom_str::kByteOfUTF8) {
+ for (size_t i = 0; str[i] != '\0'; ++i) {
+ if ((str[i] & custom_str::kHigestByteOfUTF8Byte2) !=
+ custom_str::kByteOfUTF8) {
++length_of_string;
}
}
return length_of_string;
}
-//Converts string to unicode string.
+// Converts string to unicode string.
std::wstring ConvertUTFToWString(const char* str) {
size_t size = CalculateLengthOfString(str);
- std::vector<wchar_t> wchar_array(size+1, L'\0');
+ std::vector<wchar_t> wchar_array(size + 1, L'\0');
std::string current_locale = setlocale(LC_ALL, NULL);
- setlocale(LC_ALL, "");//system locale
+ setlocale(LC_ALL, ""); // system locale
mbstowcs(&(wchar_array.front()), str, size);
setlocale(LC_ALL, current_locale.c_str());
return std::wstring(&(wchar_array.front()));
}
-//Converts string to lower case unicode string.
+// Converts string to lower case unicode string.
void ConvertWStringToLowerCase(std::wstring& str) {
const std::string current_locale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "");
@@ -79,27 +79,25 @@ void ConvertWStringToLowerCase(std::wstring& str) {
namespace utils {
namespace custom_string {
-CustomString::CustomString():amount_characters_(0), is_ascii_string_(true) {
-
-}
+CustomString::CustomString() : amount_characters_(0), is_ascii_string_(true) {}
-CustomString::CustomString(const std::string& str): mb_string_(str),
-amount_characters_(0), is_ascii_string_(true) {
+CustomString::CustomString(const std::string& str)
+ : mb_string_(str), amount_characters_(0), is_ascii_string_(true) {
InitData();
}
-CustomString::CustomString(const char* str): mb_string_(str), amount_characters_(0),
- is_ascii_string_(true) {
+CustomString::CustomString(const char* str)
+ : mb_string_(str), amount_characters_(0), is_ascii_string_(true) {
InitData();
}
-CustomString::CustomString(size_t n, char c): mb_string_(n, c),
- amount_characters_(0), is_ascii_string_(true) {
+CustomString::CustomString(size_t n, char c)
+ : mb_string_(n, c), amount_characters_(0), is_ascii_string_(true) {
InitData();
}
size_t CustomString::size() const {
- return amount_characters_;
+ return amount_characters_;
}
size_t CustomString::length() const {
@@ -138,7 +136,7 @@ CustomString CustomString::operator+(const CustomString& str) const {
CustomString CustomString::operator+(const std::string& str) const {
if (!str.empty()) {
- CustomString result_str (mb_string_ + str);
+ CustomString result_str(mb_string_ + str);
return result_str;
}
return *this;
diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc
index ca17c0f135..91ff0c3b07 100644
--- a/src/components/utils/src/file_system.cc
+++ b/src/components/utils/src/file_system.cc
@@ -49,7 +49,7 @@
CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
uint64_t file_system::GetAvailableDiskSpace(const std::string& path) {
- struct statvfs fsInfo = { 0 };
+ struct statvfs fsInfo = {0};
if (statvfs(path.c_str(), &fsInfo) == 0) {
return fsInfo.f_bsize * fsInfo.f_bfree;
} else {
@@ -57,9 +57,9 @@ uint64_t file_system::GetAvailableDiskSpace(const std::string& path) {
}
}
-int64_t file_system::FileSize(const std::string &path) {
+int64_t file_system::FileSize(const std::string& path) {
if (file_system::FileExists(path)) {
- struct stat file_info = { 0 };
+ struct stat file_info = {0};
stat(path.c_str(), &file_info);
return file_info.st_size;
}
@@ -75,20 +75,19 @@ size_t file_system::DirectorySize(const std::string& path) {
struct dirent dir_element_;
struct dirent* dir_element = &dir_element_;
#else
- char* direntbuffer =
- new char[offsetof(struct dirent, d_name) +
- pathconf(path.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new(direntbuffer) dirent;
+ char* direntbuffer = new char[offsetof(struct dirent, d_name) +
+ pathconf(path.c_str(), _PC_NAME_MAX) + 1];
+ struct dirent* dir_element = new (direntbuffer) dirent;
#endif
struct dirent* result = NULL;
- struct stat file_info = { 0 };
+ struct stat file_info = {0};
directory = opendir(path.c_str());
if (NULL != directory) {
return_code = readdir_r(directory, dir_element, &result);
for (; NULL != result && 0 == return_code;
return_code = readdir_r(directory, dir_element, &result)) {
- if (0 == strcmp(result->d_name, "..")
- || 0 == strcmp(result->d_name, ".")) {
+ if (0 == strcmp(result->d_name, "..") ||
+ 0 == strcmp(result->d_name, ".")) {
continue;
}
std::string full_element_path = path + "/" + result->d_name;
@@ -132,7 +131,7 @@ bool file_system::CreateDirectoryRecursively(const std::string& path) {
}
bool file_system::IsDirectory(const std::string& name) {
- struct stat status = { 0 };
+ struct stat status = {0};
if (-1 == stat(name.c_str(), &status)) {
return false;
@@ -142,7 +141,7 @@ bool file_system::IsDirectory(const std::string& name) {
}
bool file_system::DirectoryExists(const std::string& name) {
- struct stat status = { 0 };
+ struct stat status = {0};
if (-1 == stat(name.c_str(), &status) || !S_ISDIR(status.st_mode)) {
return false;
@@ -152,7 +151,7 @@ bool file_system::DirectoryExists(const std::string& name) {
}
bool file_system::FileExists(const std::string& name) {
- struct stat status = { 0 };
+ struct stat status = {0};
if (-1 == stat(name.c_str(), &status)) {
return false;
@@ -160,9 +159,9 @@ bool file_system::FileExists(const std::string& name) {
return true;
}
-bool file_system::Write(
- const std::string& file_name, const std::vector<uint8_t>& data,
- std::ios_base::openmode mode) {
+bool file_system::Write(const std::string& file_name,
+ const std::vector<uint8_t>& data,
+ std::ios_base::openmode mode) {
std::ofstream file(file_name.c_str(), std::ios_base::binary | mode);
if (file.is_open()) {
for (uint32_t i = 0; i < data.size(); ++i) {
@@ -176,12 +175,9 @@ bool file_system::Write(
std::ofstream* file_system::Open(const std::string& file_name,
std::ios_base::openmode mode) {
-
-
std::ofstream* file = new std::ofstream();
- file->open( file_name.c_str(),std::ios_base::binary | mode);
+ file->open(file_name.c_str(), std::ios_base::binary | mode);
if (file->is_open()) {
-
return file;
}
@@ -217,7 +213,7 @@ std::string file_system::CurrentWorkingDirectory() {
return std::string(path);
}
-std::string file_system::GetAbsolutePath(const std::string &path) {
+std::string file_system::GetAbsolutePath(const std::string& path) {
char abs_path[PATH_MAX];
if (NULL == realpath(path.c_str(), abs_path)) {
return std::string();
@@ -243,7 +239,7 @@ void file_system::remove_directory_content(const std::string& directory_name) {
char* direntbuffer =
new char[offsetof(struct dirent, d_name) +
pathconf(directory_name.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new(direntbuffer) dirent;
+ struct dirent* dir_element = new (direntbuffer) dirent;
#endif
struct dirent* result = NULL;
@@ -254,8 +250,8 @@ void file_system::remove_directory_content(const std::string& directory_name) {
for (; NULL != result && 0 == return_code;
return_code = readdir_r(directory, dir_element, &result)) {
- if (0 == strcmp(result->d_name, "..")
- || 0 == strcmp(result->d_name, ".")) {
+ if (0 == strcmp(result->d_name, "..") ||
+ 0 == strcmp(result->d_name, ".")) {
continue;
}
@@ -278,8 +274,7 @@ void file_system::remove_directory_content(const std::string& directory_name) {
bool file_system::RemoveDirectory(const std::string& directory_name,
bool is_recursively) {
- if (DirectoryExists(directory_name)
- && IsAccessible(directory_name, W_OK)) {
+ if (DirectoryExists(directory_name) && IsAccessible(directory_name, W_OK)) {
if (is_recursively) {
remove_directory_content(directory_name);
}
@@ -302,7 +297,7 @@ bool file_system::IsReadingAllowed(const std::string& name) {
}
std::vector<std::string> file_system::ListFiles(
- const std::string& directory_name) {
+ const std::string& directory_name) {
std::vector<std::string> listFiles;
if (!DirectoryExists(directory_name)) {
return listFiles;
@@ -317,7 +312,7 @@ std::vector<std::string> file_system::ListFiles(
char* direntbuffer =
new char[offsetof(struct dirent, d_name) +
pathconf(directory_name.c_str(), _PC_NAME_MAX) + 1];
- struct dirent* dir_element = new(direntbuffer) dirent;
+ struct dirent* dir_element = new (direntbuffer) dirent;
#endif
struct dirent* result = NULL;
@@ -327,8 +322,8 @@ std::vector<std::string> file_system::ListFiles(
for (; NULL != result && 0 == return_code;
return_code = readdir_r(directory, dir_element, &result)) {
- if (0 == strcmp(result->d_name, "..")
- || 0 == strcmp(result->d_name, ".")) {
+ if (0 == strcmp(result->d_name, "..") ||
+ 0 == strcmp(result->d_name, ".")) {
continue;
}
@@ -336,7 +331,6 @@ std::vector<std::string> file_system::ListFiles(
}
closedir(directory);
-
}
#ifdef __QNXNTO__
@@ -349,7 +343,7 @@ std::vector<std::string> file_system::ListFiles(
bool file_system::WriteBinaryFile(const std::string& name,
const std::vector<uint8_t>& contents) {
using namespace std;
- ofstream output(name.c_str(), ios_base::binary|ios_base::trunc);
+ ofstream output(name.c_str(), ios_base::binary | ios_base::trunc);
output.write(reinterpret_cast<const char*>(&contents.front()),
contents.size());
return output.good();
@@ -388,29 +382,20 @@ const std::string file_system::ConvertPathForURL(const std::string& path) {
std::string::const_iterator it_path_end = path.end();
const std::string reserved_symbols = "!#$&'()*+,:;=?@[] ";
- std::string::const_iterator it_sym = reserved_symbols.begin();
- std::string::const_iterator it_sym_end = reserved_symbols.end();
-
+ size_t pos = std::string::npos;
std::string converted_path;
- while (it_path != it_path_end) {
- it_sym = reserved_symbols.begin();
- for (; it_sym != it_sym_end; ++it_sym) {
-
- if (*it_path == *it_sym) {
- const size_t size = 100;
- char percent_value[size];
- snprintf(percent_value, size, "%%%x", *it_path);
- converted_path += percent_value;
- ++it_path;
- continue;
- }
+ for (; it_path != it_path_end; ++it_path) {
+ pos = reserved_symbols.find_first_of(*it_path);
+ if (pos != std::string::npos) {
+ const size_t size = 100;
+ char percent_value[size];
+ snprintf(percent_value, size, "%%%x", *it_path);
+ converted_path += percent_value;
+ } else {
+ converted_path += *it_path;
}
-
- converted_path += *it_path;
- ++it_path;
}
-
return converted_path;
}
@@ -424,7 +409,6 @@ bool file_system::CreateFile(const std::string& path) {
}
}
-
uint64_t file_system::GetFileModificationTime(const std::string& path) {
struct stat info;
stat(path.c_str(), &info);
@@ -435,8 +419,7 @@ uint64_t file_system::GetFileModificationTime(const std::string& path) {
#endif
}
-bool file_system::CopyFile(const std::string& src,
- const std::string& dst) {
+bool file_system::CopyFile(const std::string& src, const std::string& dst) {
if (!FileExists(src) || FileExists(dst) || !CreateFile(dst)) {
return false;
}
@@ -448,8 +431,7 @@ bool file_system::CopyFile(const std::string& src,
return true;
}
-bool file_system::MoveFile(const std::string& src,
- const std::string& dst) {
+bool file_system::MoveFile(const std::string& src, const std::string& dst) {
if (std::rename(src.c_str(), dst.c_str()) == 0) {
return true;
} else {
diff --git a/src/components/utils/src/gen_hash.cc b/src/components/utils/src/gen_hash.cc
index 23b92bbd8f..a43b8feb03 100644
--- a/src/components/utils/src/gen_hash.cc
+++ b/src/components/utils/src/gen_hash.cc
@@ -31,17 +31,18 @@
*/
#include "utils/gen_hash.h"
-
#include <cstdlib>
#include <string>
#include <locale>
+#include "utils/custom_string.h"
namespace utils {
const std::string gen_hash(size_t size) {
- static const char symbols[] = "0123456789"
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ static const char symbols[] =
+ "0123456789"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const size_t capacity = sizeof(symbols) - 1;
std::string hash(size, '\0');
@@ -57,7 +58,7 @@ int32_t Djb2HashFromString(const std::string& str_to_hash) {
std::string::const_iterator it = str_to_hash.begin();
std::string::const_iterator it_end = str_to_hash.end();
- for (;it != it_end; ++it) {
+ for (; it != it_end; ++it) {
hash = ((hash << 5) + hash) + (*it);
}
@@ -67,12 +68,12 @@ int32_t Djb2HashFromString(const std::string& str_to_hash) {
return result;
}
-uint32_t Faq6HashFromString(const std::string& str_to_hash) {
+uint32_t CaseInsensitiveFaq6HashFromString(const char* cstr) {
uint32_t hash = 0;
- const char* cstr = str_to_hash.c_str();
-
+ std::locale loc;
for (; *cstr; ++cstr) {
- hash += (uint32_t)(*cstr);
+ char lower_char = std::tolower(*cstr, loc);
+ hash += static_cast<uint32_t>(lower_char);
hash += (hash << 10);
hash ^= (hash >> 6);
}
@@ -84,21 +85,22 @@ uint32_t Faq6HashFromString(const std::string& str_to_hash) {
}
uint32_t CaseInsensitiveFaq6HashFromString(
- const std::string& str_to_hash) {
+ const custom_string::CustomString& str_to_hash) {
uint32_t hash = 0;
- const char* cstr = str_to_hash.c_str();
- std::locale loc;
-
- for (; *cstr; ++cstr) {
- char lower_char = std::tolower(*cstr, loc);
- hash += (uint32_t)(lower_char);
- hash += (hash << 10);
- hash ^= (hash >> 6);
+ if (str_to_hash.is_ascii_string()) {
+ hash = CaseInsensitiveFaq6HashFromString(str_to_hash.c_str());
+ } else {
+ const std::wstring& wstr = str_to_hash.ToWStringLowerCase();
+ size_t size = wstr.size();
+ for (size_t i = 0; i < size; ++i) {
+ hash += static_cast<uint32_t>(wstr[i]);
+ hash += (hash << 10);
+ hash ^= (hash >> 6);
+ }
+ hash += (hash << 3);
+ hash ^= (hash >> 11);
+ hash += (hash << 15);
}
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
-
return hash;
}
diff --git a/src/components/utils/test/CMakeLists.txt b/src/components/utils/test/CMakeLists.txt
index 7587027383..1aee683571 100644
--- a/src/components/utils/test/CMakeLists.txt
+++ b/src/components/utils/test/CMakeLists.txt
@@ -64,6 +64,7 @@ set(testSources
scope_guard_test.cc
atomic_object_test.cc
message_loop_thread_test.cc
+ custom_string_test.cc
)
set(testLibraries
diff --git a/src/components/utils/test/custom_string_test.cc b/src/components/utils/test/custom_string_test.cc
index da37c128de..8c42e9a513 100644
--- a/src/components/utils/test/custom_string_test.cc
+++ b/src/components/utils/test/custom_string_test.cc
@@ -45,22 +45,30 @@ std::string CreateMultibyteString(uint8_t* array, size_t array_size) {
return std::string(array, array + array_size);
}
-class CustomStringTest: public ::testing::TestWithParam<std::string> {
+class CustomStringTest : public ::testing::TestWithParam<std::string> {
protected:
static void SetUpTestCase() {
const size_t kSizeStr = 8;
- uint8_t array[] = {0xD0, 0xA2, 0xD0, 0xB5, 0xD1, 0x81, 0xD1, 0x82}; //Array contains russian word "Тест"
+ uint8_t array[] = {0xD0,
+ 0xA2,
+ 0xD0,
+ 0xB5,
+ 0xD1,
+ 0x81,
+ 0xD1,
+ 0x82}; // Array contains russian word "Тест"
mbstring1_ = CreateMultibyteString(array, kSizeStr);
mbstring2_ = mbstring1_ + "abc";
- amount_symbols_mbstring1_ = 4; //amount of symbols from string mbstring1_
- amount_symbols_mbstring2_ = 7; //amount of symbols from string mbstring2_
+ amount_symbols_mbstring1_ = 4; // amount of symbols from string mbstring1_
+ amount_symbols_mbstring2_ = 7; // amount of symbols from string mbstring2_
amount_bytes_mbstring1_ = mbstring1_.size();
amount_bytes_mbstring2_ = mbstring2_.size();
- }
+ }
public:
- static std::string mbstring1_; //String contains russian word "Тест"
- static std::string mbstring2_; //String contains russian word with ASCII symbols "Тестabc"
+ static std::string mbstring1_; // String contains russian word "Тест"
+ static std::string
+ mbstring2_; // String contains russian word with ASCII symbols "Тестabc"
static size_t amount_symbols_mbstring1_;
static size_t amount_symbols_mbstring2_;
static size_t amount_bytes_mbstring1_;
@@ -74,10 +82,8 @@ size_t CustomStringTest::amount_symbols_mbstring2_ = 0;
size_t CustomStringTest::amount_bytes_mbstring1_ = 0;
size_t CustomStringTest::amount_bytes_mbstring2_ = 0;
-
-
-
-TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectSizeAndIsASCIIStringEQTrue) {
+TEST_F(CustomStringTest,
+ AddASCIIStringToCustomString_ExpectCorrectSizeAndIsASCIIStringEQTrue) {
std::string str("Test string");
custom_str::CustomString obj(str);
@@ -88,7 +94,8 @@ TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectSizeAndIsASCI
EXPECT_FALSE(obj.empty());
}
-TEST_F(CustomStringTest, AddEmptyToCustomString_ExpectCorrectSizeAndIsASCIIStringEQTrue) {
+TEST_F(CustomStringTest,
+ AddEmptyToCustomString_ExpectCorrectSizeAndIsASCIIStringEQTrue) {
std::string str;
custom_str::CustomString obj(str);
@@ -99,19 +106,22 @@ TEST_F(CustomStringTest, AddEmptyToCustomString_ExpectCorrectSizeAndIsASCIIStrin
EXPECT_TRUE(obj.empty());
}
-TEST_F(CustomStringTest, AddEmptyToCustomString_ExpectCorrectWorkOfMethodAsMBString) {
+TEST_F(CustomStringTest,
+ AddEmptyToCustomString_ExpectCorrectWorkOfMethodAsMBString) {
std::string str;
custom_str::CustomString obj(str);
EXPECT_TRUE(str == obj.AsMBString());
}
-TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectWorkOfMethodAsMBString) {
+TEST_F(CustomStringTest,
+ AddASCIIStringToCustomString_ExpectCorrectWorkOfMethodAsMBString) {
std::string str("Test string");
custom_str::CustomString obj(str);
EXPECT_TRUE(str == obj.AsMBString());
}
-TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectWorkOfAppendOperator) {
+TEST_F(CustomStringTest,
+ AddASCIIStringToCustomString_ExpectCorrectWorkOfAppendOperator) {
custom_str::CustomString obj("Test string");
custom_str::CustomString obj1("abc");
custom_str::CustomString obj_empty;
@@ -130,7 +140,8 @@ TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectWorkOfAppendO
EXPECT_TRUE(str_result1 == obj_result.AsMBString());
}
-TEST_F(CustomStringTest, AddEmptyStringToCustomString_ExpectCorrectWorkOfAppendOperator) {
+TEST_F(CustomStringTest,
+ AddEmptyStringToCustomString_ExpectCorrectWorkOfAppendOperator) {
custom_str::CustomString obj_empty;
custom_str::CustomString obj("abc");
custom_str::CustomString obj_empty1;
@@ -147,7 +158,9 @@ TEST_F(CustomStringTest, AddEmptyStringToCustomString_ExpectCorrectWorkOfAppendO
EXPECT_TRUE(str_empty == obj_result.AsMBString());
}
-TEST_F(CustomStringTest, AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkOfCompareOperator) {
+TEST_F(
+ CustomStringTest,
+ AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkOfCompareOperator) {
custom_str::CustomString obj_empty;
custom_str::CustomString obj_empty1;
custom_str::CustomString obj("abc");
@@ -164,7 +177,8 @@ TEST_F(CustomStringTest, AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkO
EXPECT_FALSE(obj == str_empty);
}
-TEST_F(CustomStringTest, AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkOfCompareMethod) {
+TEST_F(CustomStringTest,
+ AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkOfCompareMethod) {
custom_str::CustomString obj_empty;
custom_str::CustomString obj("abc");
std::string str_empty;
@@ -180,7 +194,8 @@ TEST_F(CustomStringTest, AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkO
EXPECT_TRUE(obj.compare("abc") == 0);
}
-TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectWorkOfAtMethod) {
+TEST_F(CustomStringTest,
+ AddASCIIStringToCustomString_ExpectCorrectWorkOfAtMethod) {
std::string str("abc");
custom_str::CustomString obj(str);
for (size_t i = 0; i < obj.size(); ++i) {
@@ -188,7 +203,9 @@ TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectWorkOfAtMetho
}
}
-TEST_F(CustomStringTest, AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkOfCompareIgnoreCaseMethod) {
+TEST_F(
+ CustomStringTest,
+ AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkOfCompareIgnoreCaseMethod) {
custom_str::CustomString obj_empty;
custom_str::CustomString obj_empty1;
custom_str::CustomString obj("abc");
@@ -203,13 +220,15 @@ TEST_F(CustomStringTest, AddASCIIAndEmptyStringToCustomString_ExpectCorrectWorkO
EXPECT_FALSE(obj.CompareIgnoreCase(obj_empty));
}
-TEST_F(CustomStringTest, AddASCIIStringToCustomString_ExpectCorrectWorkOfToWStringMethod) {
+TEST_F(CustomStringTest,
+ AddASCIIStringToCustomString_ExpectCorrectWorkOfToWStringMethod) {
custom_str::CustomString obj("abc");
std::wstring wstr(L"abc");
EXPECT_TRUE(wstr == obj.ToWString());
}
-TEST_F(CustomStringTest, AddUTF8StringToCustomString_ExpectCorrectSizeAndIsASCIIStringEQFalse) {
+TEST_F(CustomStringTest,
+ AddUTF8StringToCustomString_ExpectCorrectSizeAndIsASCIIStringEQFalse) {
custom_str::CustomString obj(CustomStringTest::mbstring1_);
EXPECT_EQ(obj.size(), CustomStringTest::amount_symbols_mbstring1_);
EXPECT_EQ(obj.length(), CustomStringTest::amount_symbols_mbstring1_);
@@ -217,7 +236,9 @@ TEST_F(CustomStringTest, AddUTF8StringToCustomString_ExpectCorrectSizeAndIsASCII
EXPECT_FALSE(obj.is_ascii_string());
}
-TEST_F(CustomStringTest, AddMixingUTF8WithASCIIStringToCustomString_ExpectCorrectSizeAndIsASCIIStringEQFalse) {
+TEST_F(
+ CustomStringTest,
+ AddMixingUTF8WithASCIIStringToCustomString_ExpectCorrectSizeAndIsASCIIStringEQFalse) {
custom_str::CustomString obj(CustomStringTest::mbstring2_);
EXPECT_EQ(obj.size(), CustomStringTest::amount_symbols_mbstring2_);
EXPECT_EQ(obj.length(), CustomStringTest::amount_symbols_mbstring2_);
@@ -225,14 +246,17 @@ TEST_F(CustomStringTest, AddMixingUTF8WithASCIIStringToCustomString_ExpectCorrec
EXPECT_FALSE(obj.is_ascii_string());
}
-TEST_F(CustomStringTest, AddUTF8StringAndMixingUTF8WithASCIIToCustomString_ExpectCorrectWorkOfMethodAsMBString) {
+TEST_F(
+ CustomStringTest,
+ AddUTF8StringAndMixingUTF8WithASCIIToCustomString_ExpectCorrectWorkOfMethodAsMBString) {
custom_str::CustomString obj(CustomStringTest::mbstring1_);
custom_str::CustomString obj1(CustomStringTest::mbstring2_);
EXPECT_TRUE(CustomStringTest::mbstring1_ == obj.AsMBString());
EXPECT_TRUE(CustomStringTest::mbstring2_ == obj1.AsMBString());
}
-TEST_F(CustomStringTest, AddUTF8StringToCustomString_ExpectCorrectConvertingToWString) {
+TEST_F(CustomStringTest,
+ AddUTF8StringToCustomString_ExpectCorrectConvertingToWString) {
custom_str::CustomString obj(CustomStringTest::mbstring1_);
custom_str::CustomString obj1(CustomStringTest::mbstring2_);
std::wstring wstr1(L"Тест");
@@ -241,7 +265,9 @@ TEST_F(CustomStringTest, AddUTF8StringToCustomString_ExpectCorrectConvertingToWS
EXPECT_TRUE(wstr2 == obj1.ToWString());
}
-TEST_F(CustomStringTest, AddSameMultiByteStringsToCustomString_ExpectCorrectCaseSensetiveComparing) {
+TEST_F(
+ CustomStringTest,
+ AddSameMultiByteStringsToCustomString_ExpectCorrectCaseSensetiveComparing) {
custom_str::CustomString obj(CustomStringTest::mbstring1_);
custom_str::CustomString obj_1(CustomStringTest::mbstring1_);
EXPECT_TRUE(obj == obj_1);
@@ -250,7 +276,9 @@ TEST_F(CustomStringTest, AddSameMultiByteStringsToCustomString_ExpectCorrectCase
EXPECT_EQ(0, obj.compare(CustomStringTest::mbstring1_));
}
-TEST_F(CustomStringTest, AddDiferenceMultiByteStringsToCustomString_ExpectCorrectCaseSensetiveComparing) {
+TEST_F(
+ CustomStringTest,
+ AddDiferenceMultiByteStringsToCustomString_ExpectCorrectCaseSensetiveComparing) {
custom_str::CustomString obj(CustomStringTest::mbstring1_);
custom_str::CustomString obj1(CustomStringTest::mbstring2_);
EXPECT_FALSE(obj == obj1);
@@ -258,16 +286,27 @@ TEST_F(CustomStringTest, AddDiferenceMultiByteStringsToCustomString_ExpectCorrec
EXPECT_TRUE(obj.compare(CustomStringTest::mbstring2_) != 0);
}
-TEST_F(CustomStringTest, AddDiferenceMultiByteStringsToCustomString_ExpectCorrectCaseInsensitiveComparing) {
+TEST_F(
+ CustomStringTest,
+ AddDiferenceMultiByteStringsToCustomString_ExpectCorrectCaseInsensitiveComparing) {
custom_str::CustomString obj(CustomStringTest::mbstring1_);
custom_str::CustomString obj1(CustomStringTest::mbstring2_);
EXPECT_FALSE(obj.CompareIgnoreCase(obj1));
EXPECT_FALSE(obj.CompareIgnoreCase(CustomStringTest::mbstring2_.c_str()));
}
-TEST_F(CustomStringTest, AddSameMultiByteStringsToCustomString_ExpectCorrectCaseInsensitiveComparing) {
+TEST_F(
+ CustomStringTest,
+ AddSameMultiByteStringsToCustomString_ExpectCorrectCaseInsensitiveComparing) {
const size_t kSizeStr = 8;
- uint8_t array[] = {0xD1, 0x82, 0xD0, 0xB5, 0xD1, 0x81, 0xD0, 0xA2}; //String contains russian word "тесТ"
+ uint8_t array[] = {0xD1,
+ 0x82,
+ 0xD0,
+ 0xB5,
+ 0xD1,
+ 0x81,
+ 0xD0,
+ 0xA2}; // String contains russian word "тесТ"
std::string mbstring = CreateMultibyteString(array, kSizeStr);
custom_str::CustomString obj(CustomStringTest::mbstring1_);
custom_str::CustomString obj1(mbstring);
@@ -278,4 +317,3 @@ TEST_F(CustomStringTest, AddSameMultiByteStringsToCustomString_ExpectCorrectCase
} // namespace utils
} // namespace components
} // namespace test
-