diff options
Diffstat (limited to 'src/components/config_profile')
-rw-r--r-- | src/components/config_profile/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/components/config_profile/include/config_profile/ini_file.h | 37 | ||||
-rw-r--r-- | src/components/config_profile/include/config_profile/profile.h | 1361 | ||||
-rw-r--r-- | src/components/config_profile/src/ini_file.cc | 142 | ||||
-rw-r--r-- | src/components/config_profile/src/profile.cc | 1029 | ||||
-rw-r--r-- | src/components/config_profile/test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/components/config_profile/test/ini_file_test.cc | 279 | ||||
-rw-r--r-- | src/components/config_profile/test/profile_test.cc | 790 |
8 files changed, 1976 insertions, 1668 deletions
diff --git a/src/components/config_profile/CMakeLists.txt b/src/components/config_profile/CMakeLists.txt index fe6f373b3a..107fd58127 100644 --- a/src/components/config_profile/CMakeLists.txt +++ b/src/components/config_profile/CMakeLists.txt @@ -45,4 +45,4 @@ target_link_libraries("ConfigProfile" Utils) if(BUILD_TESTS) add_subdirectory(test) -endif()
\ No newline at end of file +endif() diff --git a/src/components/config_profile/include/config_profile/ini_file.h b/src/components/config_profile/include/config_profile/ini_file.h index 1b6248246c..3f3ddddf48 100644 --- a/src/components/config_profile/include/config_profile/ini_file.h +++ b/src/components/config_profile/include/config_profile/ini_file.h @@ -37,7 +37,7 @@ namespace profile { -#define INI_FILE_VER 1000 +#define INI_FILE_VER 1000 #if !defined TRUE #define TRUE 1 @@ -56,12 +56,12 @@ namespace profile { /* * @brief Global defines */ -#define INI_LINE_LEN 512 -#define INI_FILE_TEMP_NAME "ini.tmp" +#define INI_LINE_LEN 512 +#define INI_FILE_TEMP_NAME "ini.tmp" -#define INI_FLAG_UPDATE 0x00 -#define INI_FLAG_ITEM_UP_CREA 0x01 -#define INI_FLAG_FILE_UP_CREA 0x10 +#define INI_FLAG_UPDATE 0x00 +#define INI_FLAG_ITEM_UP_CREA 0x01 +#define INI_FLAG_FILE_UP_CREA 0x10 /* * @brief Global typedefs @@ -90,28 +90,27 @@ extern "C" { * * @return NULL if file or desired entry not found, otherwise pointer to fname */ -extern char* ini_write_inst(const char *fname, - uint8_t flag); +extern char* ini_write_inst(const char* fname, uint8_t flag); /* * @brief Read a certain item of the specified chapter of a ini-file * * @return NULL if file or desired entry not found, otherwise pointer to value */ -extern char* ini_read_value(const char *fname, - const char *chapter, - const char *item, - char *value); +extern char* ini_read_value(const char* fname, + const char* chapter, + const char* item, + char* value); /* * @brief Write a certain item of the specified chapter of a ini-file * * @return NULL if file not found, otherwise pointer to value */ -extern char ini_write_value(const char *fname, - const char *chapter, - const char *item, - const char *value, +extern char ini_write_value(const char* fname, + const char* chapter, + const char* item, + const char* value, uint8_t flag); /* @@ -120,9 +119,9 @@ extern char ini_write_value(const char *fname, * * @return NULL if desired entry not found, otherwise pointer to value */ -extern Ini_search_id ini_parse_line(const char *line, - const char *tag, - char *value); +extern Ini_search_id ini_parse_line(const char* line, + const char* tag, + char* value); #ifdef __cplusplus } diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 6a43cafdd3..5abf8a9f78 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -38,693 +38,780 @@ #include <vector> #include <list> #include "utils/macro.h" -#include "utils/singleton.h" +#include "protocol_handler/protocol_handler_settings.h" +#include "connection_handler/connection_handler_settings.h" +#include "hmi_message_handler/hmi_message_handler_settings.h" +#include "media_manager/media_manager_settings.h" +#include "transport_manager/transport_manager_settings.h" +#include "application_manager/application_manager_settings.h" +#include "policy/policy_settings.h" namespace profile { /** * The Profile class */ -class Profile : public utils::Singleton<Profile> { - public: - // Methods section - - /** - * Destructor - * - * Unimplemented to avoid misusing - * - */ - virtual ~Profile(); - - /** - * @brief Returns sdl version represented - * by git commit or value specified by user - */ - const std::string& sdl_version() const; - - /** - * @brief Returns true if HMI should be started, otherwise false - */ - bool launch_hmi() const; +class Profile : public protocol_handler::ProtocolHandlerSettings, + public connection_handler::ConnectionHandlerSettings, + public hmi_message_handler::HMIMessageHandlerSettings, + public media_manager::MediaManagerSettings, + public policy::PolicySettings, + public transport_manager::TransportManagerSettings, + public application_manager::ApplicationManagerSettings { + public: + // Methods section + + /** + * Default constructor + * + * Unimplemented to avoid misusing + * + */ + Profile(); + + /** + * Destructor + * + * Unimplemented to avoid misusing + * + */ + virtual ~Profile(); + + /** + * @brief Returns sdl version represented + * by git commit or value specified by user + */ + const std::string& sdl_version() const OVERRIDE; + + /** + * @brief Returns true if HMI should be started, otherwise false + */ + bool launch_hmi() const OVERRIDE; #ifdef WEB_HMI - /** - * @brief Returns link to web hmi - */ - std::string link_to_web_hmi() const; -#endif // WEB_HMI - /** - * @brief Returns application configuration path - */ - const std::string& app_config_folder() const; - - /** - * @brief Returns application storage path - */ - const std::string& app_storage_folder() const; - - /** - * @brief Return application resourse folder - */ - const std::string& app_resourse_folder() const; - - /** - * @brief Returns true, if SDL 4.0 is enabled - */ - bool enable_protocol_4() const; - - /** - * @brief Returns application icons folder path - */ - const std::string& app_icons_folder() const; - - /** - * @brief Returns application icons folder maximum size - */ - const uint32_t& app_icons_folder_max_size() const; - - /** - * @brief Returns application icons amount to remove from icon folder, - * if maximum size exceeded - */ - const uint32_t& app_icons_amount_to_remove() const; - - /** - * @brief Returns the path to the config file - */ - const std::string& config_file_name() const; - - /** - * @brief Sets the path to the config file - */ - void config_file_name(const std::string& fileName); - - /** - * @brief Returns server address - */ - const std::string& server_address() const; - - /** - * @brief Returns server port - */ - const uint16_t& server_port() const; - - /** - * @brief Returns port for video streaming - */ - const uint16_t& video_streaming_port() const; - - /** - * @brief Returns port for audio streaming - */ - const uint16_t& audio_streaming_port() const; - - /** - * @brief Returns streaming timeout - */ - uint32_t stop_streaming_timeout() const; - - /** - * @brief Returns port for time reports - */ - const uint16_t& time_testing_port() const; - - /** - * @brief Returns hmi capabilities file name - */ - const std::string& hmi_capabilities_file_name() const; - - /** - * @brief Returns help promt vector - */ - const std::vector<std::string>& help_prompt() const; - - /** - * @brief Returns help promt vector - */ - const std::vector<std::string>& time_out_promt() const; - - /** - * @brief Returns vr commands default for all apps - * such as Help. - */ - const std::vector<std::string>& vr_commands() const; - - /** - * @brief Maximum command id available for mobile app - */ - const uint32_t& max_cmd_id() const; - - /** - * @brief Default timeout for waiting for response to mobile app - */ - const uint32_t& default_timeout() const; - - /** - * @brief Default timeout for waiting for resuming - */ - const uint32_t& app_resuming_timeout() const; - const uint32_t& app_resumption_save_persistent_data_timeout() const; - - /** - * @brief Returns desirable thread stack size - */ - const uint64_t& thread_min_stack_size() const; - - /** - * @brief Returns true if audio mixing is supported - */ - bool is_mixing_audio_supported() const; - - /** - * @brief Returns true if video re-decoding enabled - */ - bool is_redecoding_enabled() const; - - /** - * @brief Returns title for Vr Help - */ - const std::string& vr_help_title() const; - - /** - * @brief Returns application directory quota size - */ - const uint32_t& app_dir_quota() const; - - /** - * @brief Returns the video server type - */ - const std::string& video_server_type() const; - - /** - * @brief Returns the audio server type - */ - const std::string& audio_server_type() const; - - /** - * @brief Returns the video pipe path - */ - const std::string& named_video_pipe_path() const; - - /** - * @brief Returns the audio pipe path - */ - const std::string& named_audio_pipe_path() const; - - /** - * @brief Returns time scale for max amount of requests for application - * in hmi level none. - */ - const uint32_t& app_hmi_level_none_time_scale() const; - - /** - * @brief Returns path to testing file to which redirects video stream - */ - const std::string& video_stream_file() const; - - /** - * @brief Returns path to testing file to which redirects audio stream - */ - const std::string& audio_stream_file() const; - - /** - * @brief Returns timeout for SDL to wait for the next package of raw data - * over audio service - */ - const std::uint32_t audio_data_stopped_timeout() const; - - /** - * @brief Returns timeout for SDL to wait for the next package of raw data - * over video service - */ - const std::uint32_t video_data_stopped_timeout() const; - - /** - * @brief Returns allowable max amount of requests per time scale for - * application in hmi level none - * - */ - const uint32_t& app_hmi_level_none_time_scale_max_requests() const; - - /** - * @brief Returns application time scale for max amount of requests per it. - */ - const uint32_t& app_time_scale() const; - - /** - * @brief Returns allowable max amount of requests per application - * time scale - */ - const uint32_t& app_time_scale_max_requests() const; - - /** - * @brief Returns allowable amount of the system pending requests - */ - const uint32_t& pending_requests_amount() const; - - /** - * @brief Returns Max allowed number of PutFile requests for one - * application in NONE - */ - const uint32_t& put_file_in_none() const; - - /** - * @brief Returns Max allowed number of DeleteFile requests for one - * application in NONE - */ - const uint32_t& delete_file_in_none() const; - - /** - * @brief Returns Max allowed number of ListFiles requests for one - * application in NONE - */ - const uint32_t& list_files_in_none() const; - - /* - * @brief Returns file name for storing applications data - */ - const std::string& app_info_storage() const; - - /* - * @brief Heartbeat timeout before closing connection - */ - int32_t heart_beat_timeout() const; - - /* - * @brief Path to preloaded policy file - */ - const std::string& preloaded_pt_file() const; - - /** - * @brief Path to policies snapshot file - * @return file path - */ - const std::string& policies_snapshot_file_name() const; - - /** - * @brief Should Policy be turned off? (Library not loaded) - * @return Flag - */ - bool enable_policy() const; - - /* - * @brief Timeout in transport manager before disconnect + /** + * @brief Returns link to web hmi */ - uint32_t transport_manager_disconnect_timeout() const; - - /* - * @brief Returns true if last state singleton is used - */ - bool use_last_state() const; - - /** - * @brief Returns supported diagnostic modes - */ - const std::vector<uint32_t>& supported_diag_modes() const; - - /** - * @brief Returns system files folder path - */ - const std::string& system_files_path() const; - - /** - * @brief Returns port for TCP transport adapter - */ - uint16_t transport_manager_tcp_adapter_port() const; - - /** - * @brief Returns value of timeout after which sent - * tts global properties for VCA - */ - uint16_t tts_global_properties_timeout() const; - - /** - * @brief Reads a string value from the profile - * - * @param value Result value - * @param default_value Value to use key wasn't found - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * - * @return FALSE if could not read the value out of the profile - * (then the value is equal \c default_value) - */ - bool ReadStringValue(std::string* value, - const char* default_value, - const char* const pSection, - const char* const pKey) const; - - /** - * @brief Reads an int32_t value from the profile - * - * @param value Result value - * @param default_value Value to use key wasn't found - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * - * @return FALSE if could not read the value out of the profile - * (then the value is equal \c default_value) - */ - bool ReadIntValue(int32_t* value, - int32_t default_value, - const char* const pSection, - const char* const pKey) const; - /** - * @brief Reads an bool value from the profile - * - * @param value Result value - * @param default_value Value to use key wasn't found - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * - * @return FALSE if could not read the value out of the profile - * (then the value is equal \c default_value) - */ - bool ReadBoolValue(bool *value, - const bool default_value, - const char * const pSection, - const char * const pKey) const; - /** - * @brief Reads an container of string values from the profile, - * which handle as "Value1, Value2, Value3" - * - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * @param out_result Pointer to bool value for result reading Section - * (could be NULL) - * - * @return container of values or empty continer - * if could not read the value out of the profile - */ - std::list<std::string> ReadStringContainer( - const char * const pSection, - const char * const pKey, - bool* out_result) const; - /** - * @brief Reads an container of hex int values from the profile, - * which handle as "0x01, 0xA0, 0XFF" - * - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * @param out_result Pointer to bool value for result reading Section - * (could be NULL) - * - * @return container of values or empty continer - * if could not read the value out of the profile - */ - std::list<int> ReadIntContainer(const char * const pSection, - const char * const pKey, - bool* out_result) const; + std::string link_to_web_hmi() const; +#endif // WEB_HMI + /** + * @brief Returns application configuration path + */ + const std::string& app_config_folder() const; + + /** + * @brief Returns application storage path + */ + const std::string& app_storage_folder() const; + + /** + * @brief Return application resourse folder + */ + const std::string& app_resource_folder() const; + + /** + * @brief Returns true, if SDL 4.0 is enabled + */ + bool enable_protocol_4() const OVERRIDE; + + /** + * @brief Returns application icons folder path + */ + const std::string& app_icons_folder() const OVERRIDE; + + /** + * @brief Returns application icons folder maximum size + */ + const uint32_t& app_icons_folder_max_size() const OVERRIDE; + + /** + * @brief Returns application icons amount to remove from icon folder, + * if maximum size exceeded + */ + const uint32_t& app_icons_amount_to_remove() const OVERRIDE; + + /** + * @brief Returns the path to the config file + */ + const std::string& config_file_name() const; + + /** + * @brief Sets the path to the config file + */ + void config_file_name(const std::string& fileName); + + /** + * @brief Returns server address + */ + const std::string& server_address() const; + + /** + * @brief Returns server port + */ + const uint16_t& server_port() const; + + /** + * @brief Returns port for video streaming + */ + const uint16_t video_streaming_port() const OVERRIDE; + + /** + * @brief Returns port for audio streaming + */ + const uint16_t audio_streaming_port() const; - /** - * @brief Returns delimiter for SDL-generated TTS chunks - * @return TTS delimiter - */ - const std::string& tts_delimiter() const; + /** + * @brief Returns streaming timeout + */ + uint32_t stop_streaming_timeout() const; - /** - * @brief Returns recording file source name - */ - const std::string& recording_file_source() const; + /** + * @brief Returns port for time reports + */ + const uint16_t& time_testing_port() const; + + /** + * @brief Returns hmi capabilities file name + */ + const std::string& hmi_capabilities_file_name() const; + + /** + * @brief Returns help promt vector + */ + const std::vector<std::string>& help_prompt() const; + + /** + * @brief Returns help promt vector + */ + const std::vector<std::string>& time_out_promt() const; + + /** + * @brief Returns vr commands default for all apps + * such as Help. + */ + const std::vector<std::string>& vr_commands() const; + + /** + * @brief Maximum command id available for mobile app + */ + const uint32_t& max_cmd_id() const; + + /** + * @brief Default timeout for waiting for response to mobile app + */ + const uint32_t& default_timeout() const; + + /** + * @brief Default timeout for waiting for resuming + */ + const uint32_t& app_resuming_timeout() const; + const uint32_t& app_resumption_save_persistent_data_timeout() const; + + /** + * @brief Returns desirable thread stack size + */ + const uint64_t& thread_min_stack_size() const; + + /** + * @brief Returns true if audio mixing is supported + */ + bool is_mixing_audio_supported() const; - /** - * @brief Returns recording file name - */ - const std::string& recording_file_name() const; + /** + * @brief Returns true if video re-decoding enabled + */ + bool is_redecoding_enabled() const; - const std::string& mme_db_name() const; + /** + * @brief Returns title for Vr Help + */ + const std::string& vr_help_title() const; - const std::string& event_mq_name() const; + /** + * @brief Returns application directory quota size + */ + const uint32_t& app_dir_quota() const; - const std::string& ack_mq_name() const; + /** + * @brief Returns the video server type + */ + const std::string& video_server_type() const; - uint32_t application_list_update_timeout() const; + /** + * @brief Returns the audio server type + */ + const std::string& audio_server_type() const; - const std::pair<uint32_t, int32_t>& read_did_frequency() const; + /** + * @brief Returns the video pipe path + */ + const std::string& named_video_pipe_path() const; - const std::pair<uint32_t, int32_t>& get_vehicle_data_frequency() const; + /** + * @brief Returns the audio pipe path + */ + const std::string& named_audio_pipe_path() const; - const std::pair<uint32_t, int32_t>& start_stream_retry_amount() const; + /** + * @brief Returns time scale for max amount of requests for application + * in hmi level none. + */ + const uint32_t& app_hmi_level_none_time_scale() const; - /** - * @brief Returns max allowed threads number for handling mobile requests - */ - uint32_t thread_pool_size() const; + /** + * @brief Returns path to testing file to which redirects video stream + */ + const std::string& video_stream_file() const; - uint32_t default_hub_protocol_index() const; + /** + * @brief Returns path to testing file to which redirects audio stream + */ + const std::string& audio_stream_file() const; - const std::string& iap_legacy_protocol_mask() const; + /** + * @brief Returns timeout for SDL to wait for the next package of raw data + * over audio service + */ + const std::uint32_t audio_data_stopped_timeout() const; - const std::string& iap_hub_protocol_mask() const; + /** + * @brief Returns timeout for SDL to wait for the next package of raw data + * over video service + */ + const std::uint32_t video_data_stopped_timeout() const; - const std::string& iap_pool_protocol_mask() const; + /** + * @brief Returns allowable max amount of requests per time scale for + * application in hmi level none + * + */ + const uint32_t& app_hmi_level_none_time_scale_max_requests() const; - const std::string& iap_system_config() const; + /** + * @brief Returns application time scale for max amount of requests per it. + */ + const uint32_t& app_time_scale() const; - const std::string& iap2_system_config() const; + /** + * @brief Returns allowable max amount of requests per application + * time scale + */ + const uint32_t& app_time_scale_max_requests() const; - int iap2_hub_connect_attempts() const; + /** + * @brief Returns allowable amount of the system pending requests + */ + const uint32_t& pending_requests_amount() const; - /** - * @return seconds - */ - int iap_hub_connection_wait_timeout() const; + /** + * @brief Returns Max allowed number of PutFile requests for one + * application in NONE + */ + const uint32_t& put_file_in_none() const OVERRIDE; - /* - * ProtocolHandler section - */ - size_t maximum_payload_size() const; + /** + * @brief Returns Max allowed number of DeleteFile requests for one + * application in NONE + */ + const uint32_t& delete_file_in_none() const OVERRIDE; - size_t message_frequency_count() const; + /** + * @brief Returns Max allowed number of ListFiles requests for one + * application in NONE + */ + const uint32_t& list_files_in_none() const OVERRIDE; - size_t message_frequency_time() const; + /* + * @brief Returns file name for storing applications data + */ + const std::string& app_info_storage() const; - bool malformed_message_filtering() const; + /* + * @brief Path to preloaded policy file + */ + const std::string& preloaded_pt_file() const; - size_t malformed_frequency_count() const; + /** + * @brief Path to policies snapshot file + * @return file path + */ + const std::string& policies_snapshot_file_name() const; - size_t malformed_frequency_time() const; + /** + * @brief Should Policy be turned off? (Library not loaded) + * @return Flag + */ + bool enable_policy() const; - uint16_t attempts_to_open_policy_db() const; + // TransportManageSettings interface - uint16_t open_attempt_timeout_ms() const; + bool use_last_state() const OVERRIDE; - uint32_t resumption_delay_before_ign() const; + uint32_t transport_manager_disconnect_timeout() const OVERRIDE; - uint32_t resumption_delay_after_ign() const; + uint16_t transport_manager_tcp_adapter_port() const OVERRIDE; - uint32_t hash_string_size() const; + // TransportManageMMESettings interface - /* - * @brief Updates all related values from ini file - */ - void UpdateValues(); + const std::string& event_mq_name() const OVERRIDE; + const std::string& ack_mq_name() const OVERRIDE; - private: - /** - * Default constructor - * - * Unimplemented to avoid misusing - * - */ - Profile(); + uint32_t iap2_hub_connect_attempts() const OVERRIDE; + uint32_t default_hub_protocol_index() const OVERRIDE; - /** - * @brief Reads a boolean value from the profile - * - * @param value The value to return - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * - * @return FALSE if could not read the value out of the profile - * (then the value is not changed) - */ - bool ReadValue(bool* value, - const char* const pSection, - const char* const pKey) const; + const std::string& iap_legacy_protocol_mask() const OVERRIDE; - /** - * @brief Reads a string value from the profile and interpret it - * as \c true on "true" value or as \c false on any other value - * - * @param value The value to return - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * - * @return FALSE if could not read the value out of the profile - * (then the value is not changed) - */ - bool ReadValue(std::string* value, - const char* const pSection, - const char* const pKey) const; - - /** - * @brief Reads a pair of ints value from the profile - * - * @param value Result value - * @param default_value Value to use key wasn't found - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * - * @return FALSE if could not read the value out of the profile - * (then the value is not changed) - */ - bool ReadUintIntPairValue(std::pair<uint32_t, int32_t>* value, - const std::pair<uint32_t, uint32_t>& default_value, - const char* const pSection, - const char* const pKey) const; - - /** - * @brief Reads an uint16/32/64_t value from the profile - * - * @param value Result value - * @param default_value Value to use key wasn't found - * @param pSection The section to read the value in - * @param pKey The key whose value needs to be read out - * - * @return FALSE if could not read the value out of the profile - * (then the value is changed to default) - */ - bool ReadUIntValue(uint16_t* value, - uint16_t default_value, - const char* const pSection, - const char* const pKey) const; + const std::string& iap_hub_protocol_mask() const OVERRIDE; - bool ReadUIntValue(uint32_t* value, - uint32_t default_value, - const char* const pSection, - const char* const pKey) const; + const std::string& iap_pool_protocol_mask() const OVERRIDE; - bool ReadUIntValue(uint64_t* value, - uint64_t default_value, + const std::string& iap_system_config() const OVERRIDE; + + const std::string& iap2_system_config() const OVERRIDE; + + uint32_t iap_hub_connection_wait_timeout() const OVERRIDE; + // TransportManageSettings interface end + + /** + * @brief Returns supported diagnostic modes + */ + const std::vector<uint32_t>& supported_diag_modes() const OVERRIDE; + + /** + * @brief Returns system files folder path + */ + const std::string& system_files_path() const OVERRIDE; + + /** + * @brief Returns value of timeout after which sent + * tts global properties for VCA + */ + uint16_t tts_global_properties_timeout() const OVERRIDE; + +#ifdef ENABLE_SECURITY + /** + * @brief Returns name of Security Manager protocol + */ + const std::string& security_manager_protocol_name() const; + + /** + * @brief Returns SSL mode + */ + const std::string& ssl_mode() const; + + /** + * @brief Returns key path to pem file + */ + const std::string& key_path() const; + + /** + * @brief Returns certificate path to pem file + */ + const std::string& cert_path() const; + + /** + * @brief Returns ca certificate path to pem file + */ + const std::string& ca_cert_path() const; + + /** + * @brief Returns ciphers + */ + const std::string& ciphers_list() const; + + /** + * @brief Returns true if Mobile app certificate is verified + */ + bool verify_peer() const; + + /** + * @brief Return hours amount when PTU should be triggered + */ + size_t update_before_hours() const; + +#endif // ENABLE_SECURITY + /** + * @brief Reads a string value from the profile + * + * @param value Result value + * @param default_value Value to use key wasn't found + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * + * @return FALSE if could not read the value out of the profile + * (then the value is equal \c default_value) + */ + bool ReadStringValue(std::string* value, + const char* default_value, const char* const pSection, const char* const pKey) const; - /** - * @brief Checks, if path is relative - * @param path Path - * @return true, if is relative, otherwise - false - */ - bool IsRelativePath(const std::string& path); - - /** - * @brief Makes relative path absolute - * @param path Path - */ - void MakeAbsolutePath(std::string& path); - - /** - * @brief Converts input string to number - * @param input Input string - * @param output Output number - * @return true, if successfully converted, otherwise - false - */ - bool StringToNumber(const std::string& input, uint64_t& output) const; - -private: - std::string sdl_version_; - bool launch_hmi_; + /** + * @brief Reads an int32_t value from the profile + * + * @param value Result value + * @param default_value Value to use key wasn't found + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * + * @return FALSE if could not read the value out of the profile + * (then the value is equal \c default_value) + */ + bool ReadIntValue(int32_t* value, + int32_t default_value, + const char* const pSection, + const char* const pKey) const; + /** + * @brief Reads an bool value from the profile + * + * @param value Result value + * @param default_value Value to use key wasn't found + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * + * @return FALSE if could not read the value out of the profile + * (then the value is equal \c default_value) + */ + bool ReadBoolValue(bool* value, + const bool default_value, + const char* const pSection, + const char* const pKey) const; + /** + * @brief Reads an container of string values from the profile, + * which handle as "Value1, Value2, Value3" + * + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * @param out_result Pointer to bool value for result reading Section + * (could be NULL) + * + * @return container of values or empty continer + * if could not read the value out of the profile + */ + std::vector<std::string> ReadStringContainer(const char* const pSection, + const char* const pKey, + bool* out_result) const; + /** + * @brief Reads an container of hex int values from the profile, + * which handle as "0x01, 0xA0, 0XFF" + * + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * @param out_result Pointer to bool value for result reading Section + * (could be NULL) + * + * @return container of values or empty continer + * if could not read the value out of the profile + */ + std::vector<int> ReadIntContainer(const char* const pSection, + const char* const pKey, + bool* out_result) const; + + /** + * @brief Returns delimiter for SDL-generated TTS chunks + * @return TTS delimiter + */ + const std::string& tts_delimiter() const OVERRIDE; + + /** + * @brief Returns recording file name + */ + const std::string& recording_file_name() const OVERRIDE; + + uint32_t application_list_update_timeout() const OVERRIDE; + + /** + * @brief Returns max allowed threads number for handling mobile requests + */ + uint32_t thread_pool_size() const; + + /* + * ProtocolHandler section + */ + size_t maximum_payload_size() const OVERRIDE; + + size_t message_frequency_count() const OVERRIDE; + + size_t message_frequency_time() const OVERRIDE; + + bool malformed_message_filtering() const OVERRIDE; + + size_t malformed_frequency_count() const OVERRIDE; + + size_t malformed_frequency_time() const OVERRIDE; + + uint32_t multiframe_waiting_timeout() const OVERRIDE; + + uint32_t heart_beat_timeout() const OVERRIDE; + + uint16_t max_supported_protocol_version() const OVERRIDE; + +#ifdef ENABLE_SECURITY + const std::vector<int>& force_protected_service() const OVERRIDE; + + const std::vector<int>& force_unprotected_service() const OVERRIDE; +#endif // ENABLE_SECURITY + // ProtocolHandler section end + + uint16_t attempts_to_open_policy_db() const; + + uint16_t open_attempt_timeout_ms() const; + + uint32_t resumption_delay_before_ign() const; + + uint32_t resumption_delay_after_ign() const; + + uint32_t hash_string_size() const; + + bool logs_enabled() const; + + /** + * @brief Returns true if resumption ctrl uses db, returns false if + * resumption ctrl uses JSON. + */ + bool use_db_for_resumption() const; + + /** + * @brief Returns amount of attempts for opening resumption db + */ + uint16_t attempts_to_open_resumption_db() const; + + /** + * @brief Returns timeout between attempts + */ + uint16_t open_attempt_timeout_ms_resumption_db() const; + + /* + * @brief Updates all related values from ini file + */ + void UpdateValues(); + + const uint32_t& list_files_response_size() const OVERRIDE; + + const std::string& recording_file_source() const OVERRIDE; + + const std::pair<uint32_t, int32_t>& read_did_frequency() const OVERRIDE; + + const std::pair<uint32_t, int32_t>& get_vehicle_data_frequency() + const OVERRIDE; + + const std::pair<uint32_t, int32_t>& start_stream_retry_amount() + const OVERRIDE; + + private: + /** + * @brief Reads a string value from the profile and interpret it + * as \c true on "true" value or as \c false on any other value + * + * @param value The value to return + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * + * @return FALSE if could not read the value out of the profile + * (then the value is not changed) + */ + bool ReadValue(std::string* value, + const char* const pSection, + const char* const pKey) const; + + /** + * @brief Reads a boolean value from the profile + * + * @param value The value to return + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * + * @return FALSE if could not read the value out of the profile + * (then the value is not changed) + */ + bool ReadValue(bool* value, + const char* const pSection, + const char* const pKey) const; + + /** + * @brief Reads a pair of ints value from the profile + * + * @param value Result value + * @param default_value Value to use key wasn't found + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * + * @return FALSE if could not read the value out of the profile + * (then the value is not changed) + */ + bool ReadUintIntPairValue(std::pair<uint32_t, int32_t>* value, + const std::pair<uint32_t, uint32_t>& default_value, + const char* const pSection, + const char* const pKey) const; + + /** + * @brief Reads an uint16/32/64_t value from the profile + * + * @param value Result value + * @param default_value Value to use key wasn't found + * @param pSection The section to read the value in + * @param pKey The key whose value needs to be read out + * + * @return FALSE if could not read the value out of the profile + * (then the value is changed to default) + */ + bool ReadUIntValue(uint16_t* value, + uint16_t default_value, + const char* const pSection, + const char* const pKey) const; + + bool ReadUIntValue(uint32_t* value, + uint32_t default_value, + const char* const pSection, + const char* const pKey) const; + + bool ReadUIntValue(uint64_t* value, + uint64_t default_value, + const char* const pSection, + const char* const pKey) const; + + /** + * @brief Checks, if path is relative + * @param path Path + * @return true, if is relative, otherwise - false + */ + bool IsRelativePath(const std::string& path); + + /** + * @brief Makes relative path absolute + * @param path Path + */ + void MakeAbsolutePath(std::string& path); + + /** + * @brief Converts input string to number + * @param input Input string + * @param output Output number + * @return true, if successfully converted, otherwise - false + */ + bool StringToNumber(const std::string& input, uint64_t& output) const; + + private: + std::string sdl_version_; + bool launch_hmi_; #ifdef WEB_HMI - std::string link_to_web_hmi_; -#endif // WEB_HMI - std::string app_config_folder_; - std::string app_storage_folder_; - std::string app_resourse_folder_; - bool enable_protocol_4_; - std::string app_icons_folder_; - uint32_t app_icons_folder_max_size_; - uint32_t app_icons_amount_to_remove_; - std::string config_file_name_; - std::string server_address_; - uint16_t server_port_; - uint16_t video_streaming_port_; - uint16_t audio_streaming_port_; - uint32_t stop_streaming_timeout_; - uint16_t time_testing_port_; - std::string hmi_capabilities_file_name_; - std::vector<std::string> help_prompt_; - std::vector<std::string> time_out_promt_; - std::vector<std::string> vr_commands_; - uint64_t min_tread_stack_size_; - bool is_mixing_audio_supported_; - bool is_redecoding_enabled_; - uint32_t max_cmd_id_; - uint32_t default_timeout_; - uint32_t app_resuming_timeout_; - uint32_t app_resumption_save_persistent_data_timeout_; - std::string vr_help_title_; - uint32_t app_dir_quota_; - std::string video_consumer_type_; - std::string audio_consumer_type_; - std::string named_video_pipe_path_; - std::string named_audio_pipe_path_; - uint32_t app_hmi_level_none_time_scale_max_requests_; - uint32_t app_hmi_level_none_requests_time_scale_; - std::string video_stream_file_; - std::string audio_stream_file_; - uint32_t app_time_scale_max_requests_; - uint32_t app_requests_time_scale_; - uint32_t pending_requests_amount_; - uint32_t put_file_in_none_; - uint32_t delete_file_in_none_; - uint32_t list_files_in_none_; - std::string app_info_storage_; - uint32_t heart_beat_timeout_; - std::string preloaded_pt_file_; - std::string policy_snapshot_file_name_; - bool enable_policy_; - uint32_t transport_manager_disconnect_timeout_; - bool use_last_state_; - std::vector<uint32_t> supported_diag_modes_; - std::string system_files_path_; - uint16_t transport_manager_tcp_adapter_port_; - std::string tts_delimiter_; - std::uint32_t audio_data_stopped_timeout_; - std::uint32_t video_data_stopped_timeout_; - std::string mme_db_name_; - std::string event_mq_name_; - std::string ack_mq_name_; - std::string recording_file_source_; - std::string recording_file_name_; - uint32_t application_list_update_timeout_; - uint32_t max_thread_pool_size_; - uint32_t default_hub_protocol_index_; - /* - * first value is count of request - * second is time scale - */ - std::pair<uint32_t, int32_t> read_did_frequency_; - - /* - * first value is count of request - * second is time scale - */ - std::pair<uint32_t, int32_t> get_vehicle_data_frequency_; - - /** - * first value is count of retries for start stream - * second for timer - */ - std::pair<uint32_t, int32_t> start_stream_retry_amount_; - - std::string iap_legacy_protocol_mask_; - std::string iap_hub_protocol_mask_; - std::string iap_pool_protocol_mask_; - std::string iap_system_config_; - std::string iap2_system_config_; - int iap2_hub_connect_attempts_; - int iap_hub_connection_wait_timeout_; - uint16_t tts_global_properties_timeout_; - uint16_t attempts_to_open_policy_db_; - uint16_t open_attempt_timeout_ms_; - uint32_t resumption_delay_before_ign_; - uint32_t resumption_delay_after_ign_; - uint32_t hash_string_size_; - - FRIEND_BASE_SINGLETON_CLASS(Profile); - DISALLOW_COPY_AND_ASSIGN(Profile); + std::string link_to_web_hmi_; +#endif // WEB_HMI + std::string app_config_folder_; + std::string app_storage_folder_; + std::string app_resource_folder_; + bool enable_protocol_4_; + std::string app_icons_folder_; + uint32_t app_icons_folder_max_size_; + uint32_t app_icons_amount_to_remove_; + std::string config_file_name_; + std::string server_address_; + uint16_t server_port_; + uint16_t video_streaming_port_; + uint16_t audio_streaming_port_; + uint32_t stop_streaming_timeout_; + uint16_t time_testing_port_; + std::string hmi_capabilities_file_name_; + std::vector<std::string> help_prompt_; + std::vector<std::string> time_out_promt_; + std::vector<std::string> vr_commands_; + uint64_t min_tread_stack_size_; + bool is_mixing_audio_supported_; + bool is_redecoding_enabled_; + uint32_t max_cmd_id_; + uint32_t default_timeout_; + uint32_t app_resuming_timeout_; + uint32_t app_resumption_save_persistent_data_timeout_; + std::string vr_help_title_; + uint32_t app_dir_quota_; + std::string video_consumer_type_; + std::string audio_consumer_type_; + std::string named_video_pipe_path_; + std::string named_audio_pipe_path_; + uint32_t app_hmi_level_none_time_scale_max_requests_; + uint32_t app_hmi_level_none_requests_time_scale_; + std::string video_stream_file_; + std::string audio_stream_file_; + uint32_t app_time_scale_max_requests_; + uint32_t app_requests_time_scale_; + uint32_t pending_requests_amount_; + uint32_t put_file_in_none_; + uint32_t delete_file_in_none_; + uint32_t list_files_in_none_; + uint32_t list_files_response_size_; + std::string app_info_storage_; + uint32_t heart_beat_timeout_; + uint16_t max_supported_protocol_version_; + std::string preloaded_pt_file_; + std::string policy_snapshot_file_name_; + bool enable_policy_; + uint32_t transport_manager_disconnect_timeout_; + bool use_last_state_; + std::vector<uint32_t> supported_diag_modes_; + std::string system_files_path_; + uint16_t transport_manager_tcp_adapter_port_; + std::string tts_delimiter_; + std::uint32_t audio_data_stopped_timeout_; + std::uint32_t video_data_stopped_timeout_; + std::string mme_db_name_; + std::string event_mq_name_; + std::string ack_mq_name_; + std::string recording_file_source_; + std::string recording_file_name_; + uint32_t application_list_update_timeout_; + uint32_t max_thread_pool_size_; + uint32_t default_hub_protocol_index_; +#ifdef ENABLE_SECURITY + std::string cert_path_; + std::string ca_cert_path_; + std::string ssl_mode_; + std::string key_path_; + std::string ciphers_list_; + bool verify_peer_; + uint32_t update_before_hours_; + std::string security_manager_protocol_name_; + std::vector<int> force_protected_service_; + std::vector<int> force_unprotected_service_; +#endif + + /* + * first value is count of request + * second is time scale + */ + std::pair<uint32_t, int32_t> read_did_frequency_; + + /* + * first value is count of request + * second is time scale + */ + std::pair<uint32_t, int32_t> get_vehicle_data_frequency_; + + /** + * first value is count of retries for start stream + * second for timer + */ + std::pair<uint32_t, int32_t> start_stream_retry_amount_; + + std::string iap_legacy_protocol_mask_; + std::string iap_hub_protocol_mask_; + std::string iap_pool_protocol_mask_; + std::string iap_system_config_; + std::string iap2_system_config_; + int iap2_hub_connect_attempts_; + int iap_hub_connection_wait_timeout_; + uint16_t tts_global_properties_timeout_; + uint16_t attempts_to_open_policy_db_; + uint16_t open_attempt_timeout_ms_; + uint32_t resumption_delay_before_ign_; + uint32_t resumption_delay_after_ign_; + uint32_t hash_string_size_; + bool logs_enabled_; + bool use_db_for_resumption_; + uint16_t attempts_to_open_resumption_db_; + uint16_t open_attempt_timeout_ms_resumption_db_; + + DISALLOW_COPY_AND_ASSIGN(Profile); }; } // namespace profile diff --git a/src/components/config_profile/src/ini_file.cc b/src/components/config_profile/src/ini_file.cc index 236dd1ae2b..d6d72060e8 100644 --- a/src/components/config_profile/src/ini_file.cc +++ b/src/components/config_profile/src/ini_file.cc @@ -42,19 +42,19 @@ #ifndef _WIN32 #include <unistd.h> #else -#define PATH_MAX _MAX_PATH +#define PATH_MAX _MAX_PATH #endif #ifdef __linux__ -#define USE_MKSTEMP 1 +#define USE_MKSTEMP 1 #endif #include <string> namespace profile { -char* ini_write_inst(const char *fname, uint8_t flag) { - FILE *fp = 0; +char* ini_write_inst(const char* fname, uint8_t flag) { + FILE* fp = 0; if (NULL == fname) return NULL; @@ -89,15 +89,17 @@ char* ini_write_inst(const char *fname, uint8_t flag) { return const_cast<char*>(fname); } -char* ini_read_value(const char *fname, - const char *chapter, const char *item, char *value) { - FILE *fp = 0; - bool chapter_found = false; - char line[INI_LINE_LEN] = ""; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = ""; - - Ini_search_id result; +char* ini_read_value(const char* fname, + const char* chapter, + const char* item, + char* value) { + FILE* fp = 0; + bool chapter_found = false; + char line[INI_LINE_LEN] = ""; + char val[INI_LINE_LEN] = ""; + char tag[INI_LINE_LEN] = ""; + + Ini_search_id result; *line = '\0'; *val = '\0'; *tag = '\0'; @@ -146,19 +148,21 @@ char* ini_read_value(const char *fname, return NULL; } -char ini_write_value(const char *fname, - const char *chapter, const char *item, - const char *value, uint8_t flag) { - FILE *rd_fp, *wr_fp = 0; - uint16_t i, cr_count; - int32_t wr_result; - bool chapter_found = false; - bool value_written = false; - char line[INI_LINE_LEN] = ""; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = ""; - char temp_fname[PATH_MAX] = ""; - Ini_search_id result; +char ini_write_value(const char* fname, + const char* chapter, + const char* item, + const char* value, + uint8_t flag) { + FILE* rd_fp, * wr_fp = 0; + uint16_t i, cr_count; + int32_t wr_result; + bool chapter_found = false; + bool value_written = false; + char line[INI_LINE_LEN] = ""; + char val[INI_LINE_LEN] = ""; + char tag[INI_LINE_LEN] = ""; + char temp_fname[PATH_MAX] = ""; + Ini_search_id result; *line = '\0'; *val = '\0'; *tag = '\0'; @@ -177,12 +181,10 @@ char ini_write_value(const char *fname, #if USE_MKSTEMP { - char *temp_str; + const char* temp_str = "./"; int32_t fd = -1; - temp_str = static_cast<char*>(getenv("TMPDIR")); if (temp_str) { - snprintf(temp_fname, PATH_MAX, - "%s/ini.XXXXXX", temp_str); + snprintf(temp_fname, PATH_MAX, "%s/ini.XXXXXX", temp_str); fd = mkstemp(temp_fname); if (-1 == fd) { @@ -201,16 +203,17 @@ char ini_write_value(const char *fname, #else // #if USE_MKSTEMP tmpnam(temp_fname); if (0 == (wr_fp = fopen(temp_fname, "w"))) { - fclose(rd_fp); - return FALSE; + fclose(rd_fp); + return FALSE; } -#endif // #else #if USE_MKSTEMP +#endif // #else #if USE_MKSTEMP snprintf(tag, INI_LINE_LEN, "%s", chapter); - for (uint32_t i = 0; i < strlen (tag); i++) + for (uint32_t i = 0; i < strlen(tag); i++) tag[i] = toupper(tag[i]); - wr_result = 1; cr_count = 0; + wr_result = 1; + cr_count = 0; while ((NULL != fgets(line, INI_LINE_LEN, rd_fp)) && (0 < wr_result)) { // Now start the line parsing result = ini_parse_line(line, tag, val); @@ -221,7 +224,7 @@ char ini_write_value(const char *fname, chapter_found = true; // coding style snprintf(tag, INI_LINE_LEN, "%s", item); - for (uint32_t i = 0; i < strlen (tag); i++) + for (uint32_t i = 0; i < strlen(tag); i++) tag[i] = toupper(tag[i]); } } else { @@ -242,7 +245,7 @@ char ini_write_value(const char *fname, continue; } } - } /* if (!value_written) */ + } /* if (!value_written) */ if (0 == strcmp(val, "\n")) { cr_count++; @@ -263,7 +266,6 @@ char ini_write_value(const char *fname, } fprintf(wr_fp, "\n"); - fclose(wr_fp); fclose(rd_fp); @@ -276,10 +278,10 @@ char ini_write_value(const char *fname, return (value_written); } -Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { - const char *line_ptr; - char *temp_ptr; - char temp_str[INI_LINE_LEN] = ""; +Ini_search_id ini_parse_line(const char* line, const char* tag, char* value) { + const char* line_ptr; + char* temp_ptr; + char temp_str[INI_LINE_LEN] = ""; *temp_str = '\0'; snprintf(value, INI_LINE_LEN, "%s", line); @@ -287,13 +289,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { /* cut leading spaces */ line_ptr = line; for (uint32_t i = 0; i < strlen(line); i++) { - if ((line[i] == ' ') || - (line[i] == 9) || // TAB - (line[i] == 10) || // LF - (line[i] == 13)) { // CR + if ((line[i] == ' ') || (line[i] == 9) || // TAB + (line[i] == 10) || // LF + (line[i] == 13)) { // CR line_ptr++; } else { - break; + break; } } if ('\0' == *line_ptr) { @@ -301,7 +302,7 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { return INI_NOTHING; } - if ((*line_ptr == ';') || (*line_ptr == '*')) /* remark */ + if ((*line_ptr == ';') || (*line_ptr == '*')) /* remark */ return INI_REMARK; if (*line_ptr == '[' && strrchr(line_ptr, ']') != NULL) { @@ -310,13 +311,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { /* cut leading stuff */ uint16_t len = strlen(line_ptr); for (int32_t i = 0; i < len; i++) { - if ((*line_ptr == ' ') || - (*line_ptr == 9) || // TAB - (*line_ptr == 10) || // LF - (*line_ptr == 13)) { // CR + if ((*line_ptr == ' ') || (*line_ptr == 9) || // TAB + (*line_ptr == 10) || // LF + (*line_ptr == 13)) { // CR line_ptr++; } else { - break; + break; } } if (*line_ptr == '\0') @@ -332,13 +332,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { /* cut trailing stuff */ for (int32_t i = strlen(temp_str) - 1; i > 0; i--) { - if ((temp_str[i] == ' ') || - (temp_str[i] == 9) || // TAB - (temp_str[i] == 10) || // LF - (temp_str[i] == 13)) { // CR + if ((temp_str[i] == ' ') || (temp_str[i] == 9) || // TAB + (temp_str[i] == 10) || // LF + (temp_str[i] == 13)) { // CR temp_str[i] = '\0'; } else { - break; + break; } } @@ -356,11 +355,10 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { strncpy(temp_str, line_ptr, (strchr(line_ptr, '=') - line_ptr)); /* cut trailing stuff */ for (int32_t i = strlen(temp_str) - 1; i > 0; i--) { - if ((temp_str[i] == '=') || - (temp_str[i] == ' ') || - (temp_str[i] == 9) || // TAB - (temp_str[i] == 10) || // LF - (temp_str[i] == 13)) { // CR + if ((temp_str[i] == '=') || (temp_str[i] == ' ') || + (temp_str[i] == 9) || // TAB + (temp_str[i] == 10) || // LF + (temp_str[i] == 13)) { // CR temp_str[i] = '\0'; } else { break; @@ -369,17 +367,16 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { snprintf(value, INI_LINE_LEN, "%s", temp_str); - for (uint32_t i = 0; i < strlen (temp_str); i++) + for (uint32_t i = 0; i < strlen(temp_str); i++) temp_str[i] = toupper(temp_str[i]); if (strcmp(temp_str, tag) == 0) { line_ptr = strchr(line_ptr, '=') + 1; uint16_t len = strlen(line_ptr); /* cut trailing stuff */ for (uint32_t i = 0; i < len; i++) { - if ((*line_ptr == ' ') || - (*line_ptr == 9) || // TAB - (*line_ptr == 10) || // LF - (*line_ptr == 13)) { // CR + if ((*line_ptr == ' ') || (*line_ptr == 9) || // TAB + (*line_ptr == 10) || // LF + (*line_ptr == 13)) { // CR line_ptr++; } else { break; @@ -391,11 +388,10 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) { if (value[0] != '\0') { /* cut trailing stuff */ for (int32_t i = strlen(value) - 1; i > 0; i--) { - if ((value[i] == ' ') || - (value[i] == ';') || - (value[i] == 9) || // TAB - (value[i] == 10) || // LF - (value[i] == 13)) { // CR + if ((value[i] == ' ') || (value[i] == ';') || + (value[i] == 9) || // TAB + (value[i] == 10) || // LF + (value[i] == 13)) { // CR value[i] = '\0'; } else { break; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 700c52fff8..4eacbe88ec 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -43,22 +43,34 @@ #include "utils/threads/thread.h" #include "utils/file_system.h" +#ifdef ENABLE_SECURITY +#include <openssl/ssl.h> +#endif // ENABLE_SECURITY + namespace { -#define LOG_UPDATED_VALUE(value, key, section) {\ - LOG4CXX_INFO(logger_, "Setting value '" << value\ - << "' for key '" << key\ - << "' in section '" << section << "'.");\ -} +#define LOG_UPDATED_VALUE(value, key, section) \ + { \ + LOG4CXX_INFO(logger_, \ + "Setting value '" << value << "' for key '" << key \ + << "' in section '" << section << "'."); \ + } -#define LOG_UPDATED_BOOL_VALUE(value, key, section) {\ - LOG4CXX_INFO(logger_, "Setting value '" << std::boolalpha << value\ - << "' for key '" << key\ - << "' in section '" << section << "'.");\ -} +#define LOG_UPDATED_BOOL_VALUE(value, key, section) \ + { \ + LOG4CXX_INFO(logger_, \ + "Setting value '" << std::boolalpha << value << "' for key '" \ + << key << "' in section '" << section \ + << "'."); \ + } const char* kDefaultConfigFileName = "smartDeviceLink.ini"; const char* kMainSection = "MAIN"; +#ifdef ENABLE_SECURITY +const char* kSecuritySection = "Security Manager"; +const char* kForceProtectedService = "ForceProtectedService"; +const char* kForceUnprotectedService = "ForceUnprotectedService"; +#endif const char* kPolicySection = "Policy"; const char* kHmiSection = "HMI"; const char* kAppInfoSection = "AppInfo"; @@ -83,15 +95,18 @@ const char* kServerAddressKey = "ServerAddress"; const char* kAppInfoStorageKey = "AppInfoStorage"; const char* kAppStorageFolderKey = "AppStorageFolder"; const char* kAppResourseFolderKey = "AppResourceFolder"; +const char* kLogsEnabledKey = "LogsEnabled"; const char* kAppConfigFolderKey = "AppConfigFolder"; const char* kEnableProtocol4Key = "EnableProtocol4"; const char* kAppIconsFolderKey = "AppIconsFolder"; const char* kAppIconsFolderMaxSizeKey = "AppIconsFolderMaxSize"; const char* kAppIconsAmountToRemoveKey = "AppIconsAmountToRemove"; const char* kLaunchHMIKey = "LaunchHMI"; + +const char* kDefaultSDLVersion = ""; #ifdef WEB_HMI const char* kLinkToWebHMI = "LinkToWebHMI"; -#endif // WEB_HMI +#endif // WEB_HMI const char* kStartStreamRetry = "StartStreamRetry"; const char* kEnableRedecodingKey = "EnableRedecoding"; const char* kVideoStreamConsumerKey = "VideoStreamConsumer"; @@ -100,6 +115,18 @@ const char* kNamedVideoPipePathKey = "NamedVideoPipePath"; const char* kNamedAudioPipePathKey = "NamedAudioPipePath"; const char* kVideoStreamFileKey = "VideoStreamFile"; const char* kAudioStreamFileKey = "AudioStreamFile"; + +#ifdef ENABLE_SECURITY +const char* kSecurityProtocolKey = "Protocol"; +const char* kSecurityCertificatePathKey = "CertificatePath"; +const char* kSecurityCACertificatePathKey = "CACertificatePath"; +const char* kSecuritySSLModeKey = "SSLMode"; +const char* kSecurityKeyPathKey = "KeyPath"; +const char* kSecurityCipherListKey = "CipherList"; +const char* kSecurityVerifyPeerKey = "VerifyPeer"; +const char* kBeforeUpdateHours = "UpdateBeforeHours"; +#endif + const char* kAudioDataStoppedTimeoutKey = "AudioDataStoppedTimeout"; const char* kVideoDataStoppedTimeoutKey = "VideoDataStoppedTimeout"; const char* kMixingAudioSupportedKey = "MixingAudioSupported"; @@ -109,6 +136,7 @@ const char* kHelpTitleKey = "HelpTitle"; const char* kHelpCommandKey = "HelpCommand"; const char* kSystemFilesPathKey = "SystemFilesPath"; const char* kHeartBeatTimeoutKey = "HeartBeatTimeout"; +const char* kMaxSupportedProtocolVersionKey = "MaxSupportedProtocolVersion"; const char* kUseLastStateKey = "UseLastState"; const char* kTCPAdapterPortKey = "TCPAdapterPort"; const char* kServerPortKey = "ServerPort"; @@ -121,6 +149,7 @@ const char* kMaxCmdIdKey = "MaxCmdID"; const char* kPutFileRequestKey = "PutFileRequest"; const char* kDeleteFileRequestKey = "DeleteFileRequest"; const char* kListFilesRequestKey = "ListFilesRequest"; +const char* kListFilesResponseSizeKey = "ListFilesResponseSize"; const char* kDefaultTimeoutKey = "DefaultTimeout"; const char* kAppResumingTimeoutKey = "ApplicationResumingTimeout"; const char* kAppSavePersistentDataTimeoutKey = "AppSavePersistentDataTimeout"; @@ -140,7 +169,6 @@ const char* kTTSDelimiterKey = "TTSDelimiter"; const char* kRecordingFileNameKey = "RecordingFileName"; const char* kRecordingFileSourceKey = "RecordingFileSource"; const char* kEnablePolicy = "EnablePolicy"; -const char* kMmeDatabaseNameKey = "MMEDatabase"; const char* kEventMQKey = "EventMQ"; const char* kAckMQKey = "AckMQ"; const char* kApplicationListUpdateTimeoutKey = "ApplicationListUpdateTimeout"; @@ -161,12 +189,17 @@ const char* kFrequencyTime = "FrequencyTime"; const char* kMalformedMessageFiltering = "MalformedMessageFiltering"; const char* kMalformedFrequencyCount = "MalformedFrequencyCount"; const char* kMalformedFrequencyTime = "MalformedFrequencyTime"; +const char* kExpectedConsecutiveFramesTimeout = + "ExpectedConsecutiveFramesTimeout"; const char* kHashStringSizeKey = "HashStringSize"; +const char* kUseDBForResumptionKey = "UseDBForResumption"; +const char* kAttemptsToOpenResumptionDBKey = "AttemptsToOpenResumptionDB"; +const char* kOpenAttemptTimeoutMsResumptionDBKey = + "OpenAttemptTimeoutMsResumptionDB"; #ifdef WEB_HMI const char* kDefaultLinkToWebHMI = "HMI/index.html"; -#endif // WEB_HMI -const char* kDefaultSDLVersion = ""; +#endif // WEB_HMI const char* kDefaultPoliciesSnapshotFileName = "sdl_snapshot.json"; const char* kDefaultHmiCapabilitiesFileName = "hmi_capabilities.json"; const char* kDefaultPreloadedPTFileName = "sdl_preloaded_pt.json"; @@ -176,7 +209,6 @@ const char* kDefaultSystemFilesPath = "/tmp/fs/mp/images/ivsu_cache"; const char* kDefaultTtsDelimiter = ","; const uint32_t kDefaultAudioDataStoppedTimeout = 1000; const uint32_t kDefaultVideoDataStoppedTimeout = 1000; -const char* kDefaultMmeDatabaseName = "/dev/qdb/mediaservice_db"; const char* kDefaultEventMQ = "/dev/mqueue/ToSDLCoreUSBAdapter"; const char* kDefaultAckMQ = "/dev/mqueue/FromSDLCoreUSBAdapter"; const char* kDefaultRecordingFileSourceName = "audio.8bit.wav"; @@ -188,8 +220,16 @@ const char* kDefaultPoolProtocolMask = "com.smartdevicelink.prot"; const char* kDefaultIAPSystemConfig = "/fs/mp/etc/mm/ipod.cfg"; const char* kDefaultIAP2SystemConfig = "/fs/mp/etc/mm/iap2.cfg"; +#ifdef ENABLE_SECURITY +const char* kDefaultSecurityProtocol = "TLSv1.2"; +const char* kDefaultSSLMode = "CLIENT"; +const bool kDefaultVerifyPeer = false; +const uint32_t kDefaultBeforeUpdateHours = 24; +#endif // ENABLE_SECURITY + const uint32_t kDefaultHubProtocolIndex = 0; const uint32_t kDefaultHeartBeatTimeout = 0; +const uint16_t kDefaultMaxSupportedProtocolVersion = 3; const uint16_t kDefautTransportManagerTCPPort = 12345; const uint16_t kDefaultServerPort = 8087; const uint16_t kDefaultVideoStreamingPort = 5050; @@ -201,11 +241,12 @@ const uint32_t kDefaultPutFileRequestInNone = 5; const uint32_t kDefaultDeleteFileRequestInNone = 5; const uint32_t kDefaultListFilesRequestInNone = 5; const uint32_t kDefaultTimeout = 10000; -const uint32_t kDefaultAppResumingTimeout = 3; -const uint32_t kDefaultAppSavePersistentDataTimeout = 10; +const uint32_t kDefaultAppResumingTimeout = 3000; +const uint32_t kDefaultAppSavePersistentDataTimeout = 10000; const uint32_t kDefaultResumptionDelayBeforeIgn = 30; const uint32_t kDefaultResumptionDelayAfterIgn = 30; const uint32_t kDefaultHashStringSize = 32; +const uint32_t kDefaultListFilesResponseSize = 1000; const uint32_t kDefaultDirQuota = 104857600; const uint32_t kDefaultAppTimeScaleMaxRequests = 0; @@ -215,12 +256,13 @@ const uint32_t kDefaultAppHmiLevelNoneRequestsTimeScale = 10; const uint32_t kDefaultPendingRequestsAmount = 0; const uint32_t kDefaultTransportManagerDisconnectTimeout = 0; const uint32_t kDefaultApplicationListUpdateTimeout = 1; -const std::pair<uint32_t, uint32_t> kReadDIDFrequency = { 5, 1 }; -const std::pair<uint32_t, uint32_t> kGetVehicleDataFrequency = { 5, 1 }; -const std::pair<uint32_t, uint32_t> kStartStreamRetryAmount = { 3, 1 }; +const std::pair<uint32_t, uint32_t> kReadDIDFrequency = {5, 1}; +const std::pair<uint32_t, uint32_t> kGetVehicleDataFrequency = {5, 1}; +const std::pair<uint32_t, uint32_t> kStartStreamRetryAmount = {3, 1}; const uint32_t kDefaultMaxThreadPoolSize = 2; const int kDefaultIAP2HubConnectAttempts = 0; -const int kDefaultIAPHubConnectionWaitTimeout = 10; +const int kDefaultIAPHubConnectionWaitTimeout = 10000; +const int kDefaultIAPArmEventTimeout = 500; const uint16_t kDefaultTTSGlobalPropertiesTimeout = 20; // TCP MTU - header size = 1500 - 12 const size_t kDefaultMaximumPayloadSize = 1500 - 12; @@ -229,11 +271,13 @@ const size_t kDefaultFrequencyTime = 1000; const bool kDefaulMalformedMessageFiltering = true; const size_t kDefaultMalformedFrequencyCount = 10; const size_t kDefaultMalformedFrequencyTime = 1000; +const uint32_t kDefaultExpectedConsecutiveFramesTimeout = 10000; const uint16_t kDefaultAttemptsToOpenPolicyDB = 5; -const uint16_t kDefaultOpenAttemptTimeoutMsKey = 500; -const uint32_t kDefaultAppIconsFolderMaxSize = 1048576; +const uint16_t kDefaultOpenAttemptTimeoutMs = 500; +const uint32_t kDefaultAppIconsFolderMaxSize = 104857600; const uint32_t kDefaultAppIconsAmountToRemove = 1; - +const uint16_t kDefaultAttemptsToOpenResumptionDB = 5; +const uint16_t kDefaultOpenAttemptTimeoutMsResumptionDB = 500; } // namespace namespace profile { @@ -241,82 +285,84 @@ namespace profile { CREATE_LOGGERPTR_GLOBAL(logger_, "Profile") Profile::Profile() - : sdl_version_(kDefaultSDLVersion), - launch_hmi_(true), + : sdl_version_(kDefaultSDLVersion) + , launch_hmi_(true) + , #ifdef WEB_HMI - link_to_web_hmi_(kDefaultLinkToWebHMI), -#endif // WEB_HMI - app_config_folder_(), - app_storage_folder_(), - app_resourse_folder_(), - enable_protocol_4_(false), - app_icons_folder_(), - app_icons_folder_max_size_(kDefaultAppIconsFolderMaxSize), - app_icons_amount_to_remove_(kDefaultAppIconsAmountToRemove), - config_file_name_(kDefaultConfigFileName), - server_address_(kDefaultServerAddress), - server_port_(kDefaultServerPort), - video_streaming_port_(kDefaultVideoStreamingPort), - audio_streaming_port_(kDefaultAudioStreamingPort), - time_testing_port_(kDefaultTimeTestingPort), - hmi_capabilities_file_name_(kDefaultHmiCapabilitiesFileName), - help_prompt_(), - time_out_promt_(), - min_tread_stack_size_(threads::Thread::kMinStackSize), - is_mixing_audio_supported_(false), - is_redecoding_enabled_(false), - max_cmd_id_(kDefaultMaxCmdId), - default_timeout_(kDefaultTimeout), - app_resuming_timeout_(kDefaultAppResumingTimeout), - app_dir_quota_(kDefaultDirQuota), - app_hmi_level_none_time_scale_max_requests_( - kDefaultAppHmiLevelNoneTimeScaleMaxRequests), - app_hmi_level_none_requests_time_scale_( - kDefaultAppHmiLevelNoneRequestsTimeScale), - app_time_scale_max_requests_(kDefaultAppTimeScaleMaxRequests), - app_requests_time_scale_(kDefaultAppRequestsTimeScale), - pending_requests_amount_(kDefaultPendingRequestsAmount), - put_file_in_none_(kDefaultPutFileRequestInNone), - delete_file_in_none_(kDefaultDeleteFileRequestInNone), - list_files_in_none_(kDefaultListFilesRequestInNone), - app_info_storage_(kDefaultAppInfoFileName), - heart_beat_timeout_(kDefaultHeartBeatTimeout), - policy_snapshot_file_name_(kDefaultPoliciesSnapshotFileName), - enable_policy_(false), - transport_manager_disconnect_timeout_( - kDefaultTransportManagerDisconnectTimeout), - use_last_state_(false), - supported_diag_modes_(), - system_files_path_(kDefaultSystemFilesPath), - transport_manager_tcp_adapter_port_(kDefautTransportManagerTCPPort), - tts_delimiter_(kDefaultTtsDelimiter), - audio_data_stopped_timeout_(kDefaultAudioDataStoppedTimeout), - video_data_stopped_timeout_(kDefaultVideoDataStoppedTimeout), - mme_db_name_(kDefaultMmeDatabaseName), - event_mq_name_(kDefaultEventMQ), - ack_mq_name_(kDefaultAckMQ), - recording_file_source_(kDefaultRecordingFileSourceName), - recording_file_name_(kDefaultRecordingFileName), - application_list_update_timeout_(kDefaultApplicationListUpdateTimeout), - iap_legacy_protocol_mask_(kDefaultLegacyProtocolMask), - iap_hub_protocol_mask_(kDefaultHubProtocolMask), - iap_pool_protocol_mask_(kDefaultPoolProtocolMask), - iap_system_config_(kDefaultIAPSystemConfig), - iap2_system_config_(kDefaultIAP2SystemConfig), - iap2_hub_connect_attempts_(kDefaultIAP2HubConnectAttempts), - iap_hub_connection_wait_timeout_(kDefaultIAPHubConnectionWaitTimeout), - tts_global_properties_timeout_(kDefaultTTSGlobalPropertiesTimeout), - attempts_to_open_policy_db_(kDefaultAttemptsToOpenPolicyDB), - open_attempt_timeout_ms_(kDefaultAttemptsToOpenPolicyDB), - hash_string_size_(kDefaultHashStringSize) { - ReadStringValue(&sdl_version_, kDefaultSDLVersion, - kMainSection, kSDLVersionKey); -} - - - -Profile::~Profile() { -} + link_to_web_hmi_(kDefaultLinkToWebHMI) + , +#endif // WEB_HMI + app_config_folder_() + , app_storage_folder_() + , app_resource_folder_() + , enable_protocol_4_(false) + , app_icons_folder_() + , app_icons_folder_max_size_(kDefaultAppIconsFolderMaxSize) + , app_icons_amount_to_remove_(kDefaultAppIconsAmountToRemove) + , config_file_name_(kDefaultConfigFileName) + , server_address_(kDefaultServerAddress) + , server_port_(kDefaultServerPort) + , video_streaming_port_(kDefaultVideoStreamingPort) + , audio_streaming_port_(kDefaultAudioStreamingPort) + , time_testing_port_(kDefaultTimeTestingPort) + , hmi_capabilities_file_name_(kDefaultHmiCapabilitiesFileName) + , help_prompt_() + , time_out_promt_() + , min_tread_stack_size_(threads::Thread::kMinStackSize) + , is_mixing_audio_supported_(false) + , is_redecoding_enabled_(false) + , max_cmd_id_(kDefaultMaxCmdId) + , default_timeout_(kDefaultTimeout) + , app_resuming_timeout_(kDefaultAppResumingTimeout) + , app_dir_quota_(kDefaultDirQuota) + , app_hmi_level_none_time_scale_max_requests_( + kDefaultAppHmiLevelNoneTimeScaleMaxRequests) + , app_hmi_level_none_requests_time_scale_( + kDefaultAppHmiLevelNoneRequestsTimeScale) + , app_time_scale_max_requests_(kDefaultAppTimeScaleMaxRequests) + , app_requests_time_scale_(kDefaultAppRequestsTimeScale) + , pending_requests_amount_(kDefaultPendingRequestsAmount) + , put_file_in_none_(kDefaultPutFileRequestInNone) + , delete_file_in_none_(kDefaultDeleteFileRequestInNone) + , list_files_in_none_(kDefaultListFilesRequestInNone) + , list_files_response_size_(kDefaultListFilesResponseSize) + , app_info_storage_(kDefaultAppInfoFileName) + , heart_beat_timeout_(kDefaultHeartBeatTimeout) + , max_supported_protocol_version_(kDefaultMaxSupportedProtocolVersion) + , policy_snapshot_file_name_(kDefaultPoliciesSnapshotFileName) + , enable_policy_(false) + , transport_manager_disconnect_timeout_( + kDefaultTransportManagerDisconnectTimeout) + , use_last_state_(false) + , supported_diag_modes_() + , system_files_path_(kDefaultSystemFilesPath) + , transport_manager_tcp_adapter_port_(kDefautTransportManagerTCPPort) + , tts_delimiter_(kDefaultTtsDelimiter) + , audio_data_stopped_timeout_(kDefaultAudioDataStoppedTimeout) + , video_data_stopped_timeout_(kDefaultVideoDataStoppedTimeout) + , event_mq_name_(kDefaultEventMQ) + , ack_mq_name_(kDefaultAckMQ) + , recording_file_source_(kDefaultRecordingFileSourceName) + , recording_file_name_(kDefaultRecordingFileName) + , application_list_update_timeout_(kDefaultApplicationListUpdateTimeout) + , iap_legacy_protocol_mask_(kDefaultLegacyProtocolMask) + , iap_hub_protocol_mask_(kDefaultHubProtocolMask) + , iap_pool_protocol_mask_(kDefaultPoolProtocolMask) + , iap_system_config_(kDefaultIAPSystemConfig) + , iap2_system_config_(kDefaultIAP2SystemConfig) + , iap2_hub_connect_attempts_(kDefaultIAP2HubConnectAttempts) + , iap_hub_connection_wait_timeout_(kDefaultIAPHubConnectionWaitTimeout) + , tts_global_properties_timeout_(kDefaultTTSGlobalPropertiesTimeout) + , attempts_to_open_policy_db_(kDefaultAttemptsToOpenPolicyDB) + , open_attempt_timeout_ms_(kDefaultAttemptsToOpenPolicyDB) + , hash_string_size_(kDefaultHashStringSize) + , use_db_for_resumption_(false) + , attempts_to_open_resumption_db_(kDefaultAttemptsToOpenResumptionDB) + , open_attempt_timeout_ms_resumption_db_( + kDefaultOpenAttemptTimeoutMsResumptionDB) { +} + +Profile::~Profile() {} void Profile::config_file_name(const std::string& fileName) { if (false == fileName.empty()) { @@ -341,7 +387,7 @@ bool Profile::launch_hmi() const { std::string Profile::link_to_web_hmi() const { return link_to_web_hmi_; } -#endif // WEB_HMI +#endif // WEB_HMI const std::string& Profile::app_config_folder() const { return app_config_folder_; @@ -351,23 +397,23 @@ const std::string& Profile::app_storage_folder() const { return app_storage_folder_; } -const std::string& Profile::app_resourse_folder() const { - return app_resourse_folder_; +const std::string& Profile::app_resource_folder() const { + return app_resource_folder_; } bool Profile::enable_protocol_4() const { return enable_protocol_4_; } -const std::string&Profile::app_icons_folder() const { +const std::string& Profile::app_icons_folder() const { return app_icons_folder_; } -const uint32_t&Profile::app_icons_folder_max_size() const { +const uint32_t& Profile::app_icons_folder_max_size() const { return app_icons_folder_max_size_; } -const uint32_t&Profile::app_icons_amount_to_remove() const { +const uint32_t& Profile::app_icons_amount_to_remove() const { return app_icons_amount_to_remove_; } @@ -415,11 +461,11 @@ const uint16_t& Profile::server_port() const { return server_port_; } -const uint16_t& Profile::video_streaming_port() const { +const uint16_t Profile::video_streaming_port() const { return video_streaming_port_; } -const uint16_t& Profile::audio_streaming_port() const { +const uint16_t Profile::audio_streaming_port() const { return audio_streaming_port_; } @@ -511,14 +557,22 @@ const uint32_t& Profile::list_files_in_none() const { return list_files_in_none_; } +const uint32_t& Profile::list_files_response_size() const { + return list_files_response_size_; +} + const std::string& Profile::app_info_storage() const { return app_info_storage_; } -int32_t Profile::heart_beat_timeout() const { +uint32_t Profile::heart_beat_timeout() const { return heart_beat_timeout_; } +uint16_t Profile::max_supported_protocol_version() const { + return max_supported_protocol_version_; +} + const std::string& Profile::preloaded_pt_file() const { return preloaded_pt_file_; } @@ -558,15 +612,10 @@ const std::string& Profile::tts_delimiter() const { const std::string& Profile::recording_file_source() const { return recording_file_source_; } - -const std::string&Profile::recording_file_name() const { +const std::string& Profile::recording_file_name() const { return recording_file_name_; } -const std::string& Profile::mme_db_name() const { - return mme_db_name_; -} - const std::string& Profile::event_mq_name() const { return event_mq_name_; } @@ -583,7 +632,8 @@ const std::pair<uint32_t, int32_t>& Profile::read_did_frequency() const { return read_did_frequency_; } -const std::pair<uint32_t, int32_t>& Profile::get_vehicle_data_frequency() const { +const std::pair<uint32_t, int32_t>& Profile::get_vehicle_data_frequency() + const { return get_vehicle_data_frequency_; } @@ -619,55 +669,75 @@ const std::string& Profile::iap2_system_config() const { return iap2_system_config_; } -int Profile::iap2_hub_connect_attempts() const { +uint32_t Profile::iap2_hub_connect_attempts() const { return iap2_hub_connect_attempts_; } -int Profile::iap_hub_connection_wait_timeout() const { +uint32_t Profile::iap_hub_connection_wait_timeout() const { return iap_hub_connection_wait_timeout_; } size_t Profile::maximum_payload_size() const { size_t maximum_payload_size = 0; - ReadUIntValue(&maximum_payload_size, kDefaultMaximumPayloadSize, - kProtocolHandlerSection, kMaximumPayloadSizeKey); + ReadUIntValue(&maximum_payload_size, + kDefaultMaximumPayloadSize, + kProtocolHandlerSection, + kMaximumPayloadSizeKey); return maximum_payload_size; } size_t Profile::message_frequency_count() const { size_t message_frequency_count = 0; - ReadUIntValue(&message_frequency_count, kDefaultFrequencyCount, - kProtocolHandlerSection, kFrequencyCount); + ReadUIntValue(&message_frequency_count, + kDefaultFrequencyCount, + kProtocolHandlerSection, + kFrequencyCount); return message_frequency_count; } size_t Profile::message_frequency_time() const { size_t message_frequency_time = 0; - ReadUIntValue(&message_frequency_time, kDefaultFrequencyTime, - kProtocolHandlerSection, kFrequencyTime); + ReadUIntValue(&message_frequency_time, + kDefaultFrequencyTime, + kProtocolHandlerSection, + kFrequencyTime); return message_frequency_time; } bool Profile::malformed_message_filtering() const { bool malformed_message_filtering = 0; - ReadBoolValue(&malformed_message_filtering, kDefaulMalformedMessageFiltering, - kProtocolHandlerSection, kMalformedMessageFiltering); + ReadBoolValue(&malformed_message_filtering, + kDefaulMalformedMessageFiltering, + kProtocolHandlerSection, + kMalformedMessageFiltering); return malformed_message_filtering; } size_t Profile::malformed_frequency_count() const { size_t malformed_frequency_count = 0; - ReadUIntValue(&malformed_frequency_count, kDefaultMalformedFrequencyCount, - kProtocolHandlerSection, kMalformedFrequencyCount); + ReadUIntValue(&malformed_frequency_count, + kDefaultMalformedFrequencyCount, + kProtocolHandlerSection, + kMalformedFrequencyCount); return malformed_frequency_count; } size_t Profile::malformed_frequency_time() const { size_t malformed_frequency_time = 0; - ReadUIntValue(&malformed_frequency_time, kDefaultMalformedFrequencyTime, - kProtocolHandlerSection, kMalformedFrequencyTime); + ReadUIntValue(&malformed_frequency_time, + kDefaultMalformedFrequencyTime, + kProtocolHandlerSection, + kMalformedFrequencyTime); return malformed_frequency_time; } +uint32_t Profile::multiframe_waiting_timeout() const { + uint32_t multiframe_waiting_timeout = 0; + ReadUIntValue(&multiframe_waiting_timeout, + kDefaultExpectedConsecutiveFramesTimeout, + kProtocolHandlerSection, + kExpectedConsecutiveFramesTimeout); + return multiframe_waiting_timeout; +} uint16_t Profile::attempts_to_open_policy_db() const { return attempts_to_open_policy_db_; @@ -693,12 +763,71 @@ uint16_t Profile::tts_global_properties_timeout() const { return tts_global_properties_timeout_; } +#ifdef ENABLE_SECURITY + +const std::string& Profile::cert_path() const { + return cert_path_; +} + +const std::string& Profile::ca_cert_path() const { + return ca_cert_path_; +} + +const std::string& Profile::ssl_mode() const { + return ssl_mode_; +} + +const std::string& Profile::key_path() const { + return key_path_; +} + +const std::string& Profile::ciphers_list() const { + return ciphers_list_; +} + +bool Profile::verify_peer() const { + return verify_peer_; +} + +size_t Profile::update_before_hours() const { + return update_before_hours_; +} + +const std::string& Profile::security_manager_protocol_name() const { + return security_manager_protocol_name_; +} + +const std::vector<int>& Profile::force_protected_service() const { + return force_protected_service_; +} + +const std::vector<int>& Profile::force_unprotected_service() const { + return force_unprotected_service_; +} +#endif // ENABLE_SECURITY + +bool Profile::logs_enabled() const { + return logs_enabled_; +} + +bool Profile::use_db_for_resumption() const { + return use_db_for_resumption_; +} + +uint16_t Profile::attempts_to_open_resumption_db() const { + return attempts_to_open_resumption_db_; +} + +uint16_t Profile::open_attempt_timeout_ms_resumption_db() const { + return open_attempt_timeout_ms_resumption_db_; +} + void Profile::UpdateValues() { LOG4CXX_AUTO_TRACE(logger_); // SDL version - ReadStringValue(&sdl_version_, kDefaultSDLVersion, - kMainSection, kSDLVersionKey); + ReadStringValue( + &sdl_version_, kDefaultSDLVersion, kMainSection, kSDLVersionKey); LOG_UPDATED_VALUE(sdl_version_, kSDLVersionKey, kMainSection); @@ -711,19 +840,63 @@ void Profile::UpdateValues() { launch_hmi_ = false; } - LOG_UPDATED_BOOL_VALUE(launch_hmi_, kLaunchHMIKey, kHmiSection); + LOG_UPDATED_BOOL_VALUE(launch_hmi_, kLaunchHMIKey, kHmiSection); #ifdef WEB_HMI // Link to web HMI parameter - ReadStringValue(&link_to_web_hmi_, kDefaultLinkToWebHMI, - kHmiSection, kLinkToWebHMI); + ReadStringValue( + &link_to_web_hmi_, kDefaultLinkToWebHMI, kHmiSection, kLinkToWebHMI); LOG_UPDATED_BOOL_VALUE(link_to_web_hmi_, kLinkToWebHMI, kHmiSection); -#endif // WEB_HMI +#endif // WEB_HMI + +#ifdef ENABLE_SECURITY + + force_protected_service_ = + ReadIntContainer(kSecuritySection, kForceProtectedService, NULL); + + force_unprotected_service_ = + ReadIntContainer(kSecuritySection, kForceUnprotectedService, NULL); + + ReadStringValue(&security_manager_protocol_name_, + kDefaultSecurityProtocol, + kSecuritySection, + kSecurityProtocolKey); + + ReadStringValue( + &cert_path_, "", kSecuritySection, kSecurityCertificatePathKey); + ReadStringValue( + &ca_cert_path_, "", kSecuritySection, kSecurityCACertificatePathKey); + + ReadStringValue( + &ssl_mode_, kDefaultSSLMode, kSecuritySection, kSecuritySSLModeKey); + + ReadStringValue(&key_path_, "", kSecuritySection, kSecurityKeyPathKey); + + ReadStringValue( + &ciphers_list_, SSL_TXT_ALL, kSecuritySection, kSecurityCipherListKey); + + ReadBoolValue(&verify_peer_, + kDefaultVerifyPeer, + kSecuritySection, + kSecurityVerifyPeerKey); + + ReadUIntValue(&update_before_hours_, + kDefaultBeforeUpdateHours, + kSecuritySection, + kBeforeUpdateHours); + +#endif // ENABLE_SECURITY + + // Logs enabled + ReadBoolValue(&logs_enabled_, false, kMainSection, kLogsEnabledKey); + + LOG_UPDATED_BOOL_VALUE(logs_enabled_, kLogsEnabledKey, kMainSection); // Application config folder ReadStringValue(&app_config_folder_, file_system::CurrentWorkingDirectory().c_str(), - kMainSection, kAppConfigFolderKey); + kMainSection, + kAppConfigFolderKey); if (IsRelativePath(app_config_folder_)) { MakeAbsolutePath(app_config_folder_); @@ -734,7 +907,8 @@ void Profile::UpdateValues() { // Application storage folder ReadStringValue(&app_storage_folder_, file_system::CurrentWorkingDirectory().c_str(), - kMainSection, kAppStorageFolderKey); + kMainSection, + kAppStorageFolderKey); if (IsRelativePath(app_storage_folder_)) { MakeAbsolutePath(app_storage_folder_); @@ -743,16 +917,16 @@ void Profile::UpdateValues() { LOG_UPDATED_VALUE(app_storage_folder_, kAppStorageFolderKey, kMainSection); // Application resourse folder - ReadStringValue(&app_resourse_folder_, + ReadStringValue(&app_resource_folder_, file_system::CurrentWorkingDirectory().c_str(), - kMainSection, kAppResourseFolderKey); + kMainSection, + kAppResourseFolderKey); - if (IsRelativePath(app_resourse_folder_)) { - MakeAbsolutePath(app_resourse_folder_); + if (IsRelativePath(app_resource_folder_)) { + MakeAbsolutePath(app_resource_folder_); } - LOG_UPDATED_VALUE(app_resourse_folder_, kAppResourseFolderKey, - kMainSection); + LOG_UPDATED_VALUE(app_resource_folder_, kAppResourseFolderKey, kMainSection); // Enable protocol ver.4 parameter std::string enable_protocol_4_value; @@ -768,95 +942,108 @@ void Profile::UpdateValues() { // Application icon folder ReadStringValue(&app_icons_folder_, file_system::CurrentWorkingDirectory().c_str(), - kSDL4Section, kAppIconsFolderKey); + kSDL4Section, + kAppIconsFolderKey); if (IsRelativePath(app_icons_folder_)) { MakeAbsolutePath(app_icons_folder_); } - LOG_UPDATED_VALUE(app_icons_folder_, kAppIconsFolderKey, - kSDL4Section); + LOG_UPDATED_VALUE(app_icons_folder_, kAppIconsFolderKey, kSDL4Section); // Application icon folder maximum size - ReadUIntValue(&app_icons_folder_max_size_, kDefaultAppIconsFolderMaxSize, - kSDL4Section, kAppIconsFolderMaxSizeKey); + ReadUIntValue(&app_icons_folder_max_size_, + kDefaultAppIconsFolderMaxSize, + kSDL4Section, + kAppIconsFolderMaxSizeKey); if (app_icons_folder_max_size_ < kDefaultAppIconsFolderMaxSize) { app_icons_folder_max_size_ = kDefaultAppIconsFolderMaxSize; } - LOG_UPDATED_VALUE(app_icons_folder_max_size_, kAppIconsFolderMaxSizeKey, - kSDL4Section); + LOG_UPDATED_VALUE( + app_icons_folder_max_size_, kAppIconsFolderMaxSizeKey, kSDL4Section); // Application icon folder maximum size - ReadUIntValue(&app_icons_amount_to_remove_, kDefaultAppIconsAmountToRemove, - kSDL4Section, kAppIconsAmountToRemoveKey); + ReadUIntValue(&app_icons_amount_to_remove_, + kDefaultAppIconsAmountToRemove, + kSDL4Section, + kAppIconsAmountToRemoveKey); - LOG_UPDATED_VALUE(app_icons_amount_to_remove_, kAppIconsAmountToRemoveKey, - kSDL4Section); + LOG_UPDATED_VALUE( + app_icons_amount_to_remove_, kAppIconsAmountToRemoveKey, kSDL4Section); // Application info file name - ReadStringValue(&app_info_storage_, kDefaultAppInfoFileName, + ReadStringValue(&app_info_storage_, + kDefaultAppInfoFileName, kAppInfoSection, kAppInfoStorageKey); - LOG_UPDATED_VALUE(app_info_storage_, kAppInfoStorageKey, - kAppInfoSection); + LOG_UPDATED_VALUE(app_info_storage_, kAppInfoStorageKey, kAppInfoSection); // Server address - ReadStringValue(&server_address_, kDefaultServerAddress, kHmiSection, - kServerAddressKey); + ReadStringValue( + &server_address_, kDefaultServerAddress, kHmiSection, kServerAddressKey); LOG_UPDATED_VALUE(server_address_, kServerAddressKey, kHmiSection); // HMI capabilities - ReadStringValue(&hmi_capabilities_file_name_ , + ReadStringValue(&hmi_capabilities_file_name_, kDefaultHmiCapabilitiesFileName, - kMainSection, kHmiCapabilitiesKey); + kMainSection, + kHmiCapabilitiesKey); - hmi_capabilities_file_name_ = app_config_folder_ + "/" + - hmi_capabilities_file_name_; + hmi_capabilities_file_name_ = + app_config_folder_ + "/" + hmi_capabilities_file_name_; - LOG_UPDATED_VALUE(hmi_capabilities_file_name_, kHmiCapabilitiesKey, - kMainSection); + LOG_UPDATED_VALUE( + hmi_capabilities_file_name_, kHmiCapabilitiesKey, kMainSection); // Server port - ReadUIntValue(&server_port_, kDefaultServerPort, kHmiSection, - kServerPortKey); + ReadUIntValue(&server_port_, kDefaultServerPort, kHmiSection, kServerPortKey); LOG_UPDATED_VALUE(server_port_, kServerPortKey, kHmiSection); // Video streaming port - ReadUIntValue(&video_streaming_port_, kDefaultVideoStreamingPort, - kHmiSection, kVideoStreamingPortKey); + ReadUIntValue(&video_streaming_port_, + kDefaultVideoStreamingPort, + kHmiSection, + kVideoStreamingPortKey); - LOG_UPDATED_VALUE(video_streaming_port_, kVideoStreamingPortKey, - kHmiSection); + LOG_UPDATED_VALUE(video_streaming_port_, kVideoStreamingPortKey, kHmiSection); // Audio streaming port - ReadUIntValue(&audio_streaming_port_, kDefaultAudioStreamingPort, - kHmiSection, kAudioStreamingPortKey); + ReadUIntValue(&audio_streaming_port_, + kDefaultAudioStreamingPort, + kHmiSection, + kAudioStreamingPortKey); - LOG_UPDATED_VALUE(audio_streaming_port_, kAudioStreamingPortKey, - kHmiSection); + LOG_UPDATED_VALUE(audio_streaming_port_, kAudioStreamingPortKey, kHmiSection); // Streaming timeout - ReadUIntValue(&stop_streaming_timeout_, kDefaultStopStreamingTimeout, - kMediaManagerSection, kStopStreamingTimeout); + ReadUIntValue(&stop_streaming_timeout_, + kDefaultStopStreamingTimeout, + kMediaManagerSection, + kStopStreamingTimeout); - stop_streaming_timeout_ = std::max(kDefaultStopStreamingTimeout, stop_streaming_timeout_); + stop_streaming_timeout_ = + std::max(kDefaultStopStreamingTimeout, stop_streaming_timeout_); - LOG_UPDATED_VALUE(stop_streaming_timeout_, kStopStreamingTimeout, - kHmiSection); + LOG_UPDATED_VALUE( + stop_streaming_timeout_, kStopStreamingTimeout, kHmiSection); // Time testing port - ReadUIntValue(&time_testing_port_, kDefaultTimeTestingPort, kMainSection, + ReadUIntValue(&time_testing_port_, + kDefaultTimeTestingPort, + kMainSection, kTimeTestingPortKey); LOG_UPDATED_VALUE(time_testing_port_, kTimeTestingPortKey, kMainSection); // Minimum thread stack size - ReadUIntValue(&min_tread_stack_size_, threads::Thread::kMinStackSize, - kMainSection, kThreadStackSizeKey); + ReadUIntValue(&min_tread_stack_size_, + threads::Thread::kMinStackSize, + kMainSection, + kThreadStackSizeKey); if (min_tread_stack_size_ < threads::Thread::kMinStackSize) { min_tread_stack_size_ = threads::Thread::kMinStackSize; @@ -865,94 +1052,107 @@ void Profile::UpdateValues() { LOG_UPDATED_VALUE(min_tread_stack_size_, kThreadStackSizeKey, kMainSection); // Start stream retry frequency - ReadUintIntPairValue(&start_stream_retry_amount_, kStartStreamRetryAmount, - kMediaManagerSection, kStartStreamRetry); + ReadUintIntPairValue(&start_stream_retry_amount_, + kStartStreamRetryAmount, + kMediaManagerSection, + kStartStreamRetry); // Redecoding parameter std::string redecoding_value; - if (ReadValue(&redecoding_value, kMediaManagerSection, kEnableRedecodingKey) - && 0 == strcmp("true", redecoding_value.c_str())) { + if (ReadValue( + &redecoding_value, kMediaManagerSection, kEnableRedecodingKey) && + 0 == strcmp("true", redecoding_value.c_str())) { is_redecoding_enabled_ = true; } else { is_redecoding_enabled_ = false; } - LOG_UPDATED_BOOL_VALUE(is_redecoding_enabled_, kEnableRedecodingKey, - kMediaManagerSection); + LOG_UPDATED_BOOL_VALUE( + is_redecoding_enabled_, kEnableRedecodingKey, kMediaManagerSection); // Video consumer type - ReadStringValue(&video_consumer_type_, "", kMediaManagerSection, - kVideoStreamConsumerKey); + ReadStringValue( + &video_consumer_type_, "", kMediaManagerSection, kVideoStreamConsumerKey); - LOG_UPDATED_VALUE(video_consumer_type_, kVideoStreamConsumerKey, - kMediaManagerSection); + LOG_UPDATED_VALUE( + video_consumer_type_, kVideoStreamConsumerKey, kMediaManagerSection); // Audio stream consumer - ReadStringValue(&audio_consumer_type_, "", kMediaManagerSection, - kAudioStreamConsumerKey); + ReadStringValue( + &audio_consumer_type_, "", kMediaManagerSection, kAudioStreamConsumerKey); - LOG_UPDATED_VALUE(audio_consumer_type_, kAudioStreamConsumerKey, - kMediaManagerSection); + LOG_UPDATED_VALUE( + audio_consumer_type_, kAudioStreamConsumerKey, kMediaManagerSection); // Named video pipe path - ReadStringValue(&named_video_pipe_path_, "", kMediaManagerSection, + ReadStringValue(&named_video_pipe_path_, + "", + kMediaManagerSection, kNamedVideoPipePathKey); named_video_pipe_path_ = app_storage_folder_ + "/" + named_video_pipe_path_; - LOG_UPDATED_VALUE(named_video_pipe_path_, kNamedVideoPipePathKey, - kMediaManagerSection); + LOG_UPDATED_VALUE( + named_video_pipe_path_, kNamedVideoPipePathKey, kMediaManagerSection); // Named audio pipe path - ReadStringValue(&named_audio_pipe_path_, "", kMediaManagerSection, + ReadStringValue(&named_audio_pipe_path_, + "", + kMediaManagerSection, kNamedAudioPipePathKey); named_audio_pipe_path_ = app_storage_folder_ + "/" + named_audio_pipe_path_; - LOG_UPDATED_VALUE(named_audio_pipe_path_, kNamedAudioPipePathKey, - kMediaManagerSection); + LOG_UPDATED_VALUE( + named_audio_pipe_path_, kNamedAudioPipePathKey, kMediaManagerSection); // Video stream file - ReadStringValue(&video_stream_file_, "", kMediaManagerSection, - kVideoStreamFileKey); + ReadStringValue( + &video_stream_file_, "", kMediaManagerSection, kVideoStreamFileKey); video_stream_file_ = app_storage_folder_ + "/" + video_stream_file_; - LOG_UPDATED_VALUE(video_stream_file_, kVideoStreamFileKey, - kMediaManagerSection); + LOG_UPDATED_VALUE( + video_stream_file_, kVideoStreamFileKey, kMediaManagerSection); // Audio stream file - ReadStringValue(&audio_stream_file_, "", kMediaManagerSection, - kAudioStreamFileKey); + ReadStringValue( + &audio_stream_file_, "", kMediaManagerSection, kAudioStreamFileKey); audio_stream_file_ = app_storage_folder_ + "/" + audio_stream_file_; - LOG_UPDATED_VALUE(audio_stream_file_, kAudioStreamFileKey, - kMediaManagerSection); + LOG_UPDATED_VALUE( + audio_stream_file_, kAudioStreamFileKey, kMediaManagerSection); - ReadUIntValue(&audio_data_stopped_timeout_, kDefaultAudioDataStoppedTimeout, - kMediaManagerSection, kAudioDataStoppedTimeoutKey); + ReadUIntValue(&audio_data_stopped_timeout_, + kDefaultAudioDataStoppedTimeout, + kMediaManagerSection, + kAudioDataStoppedTimeoutKey); - LOG_UPDATED_VALUE(audio_data_stopped_timeout_, kAudioDataStoppedTimeoutKey, + LOG_UPDATED_VALUE(audio_data_stopped_timeout_, + kAudioDataStoppedTimeoutKey, kMediaManagerSection); - ReadUIntValue(&video_data_stopped_timeout_, kDefaultVideoDataStoppedTimeout, - kMediaManagerSection, kVideoDataStoppedTimeoutKey); + ReadUIntValue(&video_data_stopped_timeout_, + kDefaultVideoDataStoppedTimeout, + kMediaManagerSection, + kVideoDataStoppedTimeoutKey); - LOG_UPDATED_VALUE(video_data_stopped_timeout_, kVideoDataStoppedTimeoutKey, + LOG_UPDATED_VALUE(video_data_stopped_timeout_, + kVideoDataStoppedTimeoutKey, kMediaManagerSection); // Mixing audio parameter std::string mixing_audio_value; - if (ReadValue(&mixing_audio_value, kMainSection, kMixingAudioSupportedKey) - && 0 == strcmp("true", mixing_audio_value.c_str())) { + if (ReadValue(&mixing_audio_value, kMainSection, kMixingAudioSupportedKey) && + 0 == strcmp("true", mixing_audio_value.c_str())) { is_mixing_audio_supported_ = true; } else { is_mixing_audio_supported_ = false; } - LOG_UPDATED_BOOL_VALUE(is_mixing_audio_supported_, kMixingAudioSupportedKey, - kMainSection); + LOG_UPDATED_BOOL_VALUE( + is_mixing_audio_supported_, kMixingAudioSupportedKey, kMainSection); // Maximum command id value ReadUIntValue(&max_cmd_id_, kDefaultMaxCmdId, kMainSection, kMaxCmdIdKey); @@ -960,29 +1160,47 @@ void Profile::UpdateValues() { LOG_UPDATED_VALUE(max_cmd_id_, kMaxCmdIdKey, kMainSection); // PutFile restrictions - ReadUIntValue(&put_file_in_none_, kDefaultPutFileRequestInNone, - kFilesystemRestrictionsSection, kPutFileRequestKey); + ReadUIntValue(&put_file_in_none_, + kDefaultPutFileRequestInNone, + kFilesystemRestrictionsSection, + kPutFileRequestKey); - LOG_UPDATED_VALUE(put_file_in_none_, kPutFileRequestKey, - kFilesystemRestrictionsSection); + LOG_UPDATED_VALUE( + put_file_in_none_, kPutFileRequestKey, kFilesystemRestrictionsSection); // DeleteFileRestrictions - ReadUIntValue(&delete_file_in_none_, kDefaultDeleteFileRequestInNone, - kFilesystemRestrictionsSection, kDeleteFileRequestKey); + ReadUIntValue(&delete_file_in_none_, + kDefaultDeleteFileRequestInNone, + kFilesystemRestrictionsSection, + kDeleteFileRequestKey); - LOG_UPDATED_VALUE(delete_file_in_none_, kDeleteFileRequestKey, + LOG_UPDATED_VALUE(delete_file_in_none_, + kDeleteFileRequestKey, kFilesystemRestrictionsSection); // ListFiles restrictions - ReadUIntValue(&list_files_in_none_, kDefaultListFilesRequestInNone, - kFilesystemRestrictionsSection, kListFilesRequestKey); + ReadUIntValue(&list_files_in_none_, + kDefaultListFilesRequestInNone, + kFilesystemRestrictionsSection, + kListFilesRequestKey); - LOG_UPDATED_VALUE(list_files_in_none_, kListFilesRequestKey, + LOG_UPDATED_VALUE(list_files_in_none_, + kListFilesRequestKey, + kFilesystemRestrictionsSection); + + // ListFiles request size + ReadUIntValue(&list_files_response_size_, + kDefaultListFilesResponseSize, + kFilesystemRestrictionsSection, + kListFilesResponseSizeKey); + + LOG_UPDATED_VALUE(list_files_response_size_, + kListFilesResponseSizeKey, kFilesystemRestrictionsSection); // Default timeout - ReadUIntValue(&default_timeout_, kDefaultTimeout, kMainSection, - kDefaultTimeoutKey); + ReadUIntValue( + &default_timeout_, kDefaultTimeout, kMainSection, kDefaultTimeoutKey); if (default_timeout_ == 0) { default_timeout_ = kDefaultTimeout; @@ -991,25 +1209,29 @@ void Profile::UpdateValues() { LOG_UPDATED_VALUE(default_timeout_, kDefaultTimeoutKey, kMainSection); // Application resuming timeout - ReadUIntValue(&app_resuming_timeout_, kDefaultAppResumingTimeout, - kResumptionSection, kAppResumingTimeoutKey); + ReadUIntValue(&app_resuming_timeout_, + kDefaultAppResumingTimeout, + kResumptionSection, + kAppResumingTimeoutKey); if (app_resuming_timeout_ == 0) { app_resuming_timeout_ = kDefaultAppResumingTimeout; } // Save resumption info to File System - LOG_UPDATED_VALUE(app_resuming_timeout_, kAppSavePersistentDataTimeoutKey, + LOG_UPDATED_VALUE(app_resuming_timeout_, + kAppSavePersistentDataTimeoutKey, kResumptionSection); ReadUIntValue(&app_resumption_save_persistent_data_timeout_, kDefaultAppSavePersistentDataTimeout, - kResumptionSection, kAppSavePersistentDataTimeoutKey); + kResumptionSection, + kAppSavePersistentDataTimeoutKey); if (app_resuming_timeout_ == 0) { app_resuming_timeout_ = kDefaultAppSavePersistentDataTimeout; } - LOG_UPDATED_VALUE(app_resuming_timeout_, kAppResumingTimeoutKey, - kResumptionSection); + LOG_UPDATED_VALUE( + app_resuming_timeout_, kAppResumingTimeoutKey, kResumptionSection); // Open attempt timeout in ms ReadUIntValue(&resumption_delay_before_ign_, kDefaultResumptionDelayBeforeIgn, @@ -1017,7 +1239,8 @@ void Profile::UpdateValues() { kResumptionDelayBeforeIgnKey); LOG_UPDATED_VALUE(resumption_delay_before_ign_, - kResumptionDelayBeforeIgnKey, kResumptionSection); + kResumptionDelayBeforeIgnKey, + kResumptionSection); // Open attempt timeout in ms ReadUIntValue(&resumption_delay_after_ign_, @@ -1026,11 +1249,12 @@ void Profile::UpdateValues() { kResumptionDelayAfterIgnKey); LOG_UPDATED_VALUE(resumption_delay_after_ign_, - kResumptionDelayAfterIgnKey, kResumptionSection); + kResumptionDelayAfterIgnKey, + kResumptionSection); // Application directory quota - ReadUIntValue(&app_dir_quota_, kDefaultDirQuota, kMainSection, - kAppDirectoryQuotaKey); + ReadUIntValue( + &app_dir_quota_, kDefaultDirQuota, kMainSection, kAppDirectoryQuotaKey); if (app_dir_quota_ == 0) { app_dir_quota_ = kDefaultDirQuota; @@ -1040,68 +1264,62 @@ void Profile::UpdateValues() { // TTS delimiter // Should be gotten before any TTS prompts, since it should be appended back - ReadStringValue(&tts_delimiter_, kDefaultTtsDelimiter, - kGlobalPropertiesSection, kTTSDelimiterKey); + ReadStringValue(&tts_delimiter_, + kDefaultTtsDelimiter, + kGlobalPropertiesSection, + kTTSDelimiterKey); - LOG_UPDATED_VALUE(tts_delimiter_, kTTSDelimiterKey, - kGlobalPropertiesSection); + LOG_UPDATED_VALUE(tts_delimiter_, kTTSDelimiterKey, kGlobalPropertiesSection); // Help prompt help_prompt_.clear(); std::string help_prompt_value; - if (ReadValue(&help_prompt_value, kGlobalPropertiesSection, - kHelpPromptKey)) { + if (ReadValue(&help_prompt_value, kGlobalPropertiesSection, kHelpPromptKey)) { char* str = NULL; str = strtok(const_cast<char*>(help_prompt_value.c_str()), ","); while (str != NULL) { // Default prompt should have delimiter included for each item const std::string prompt_item = std::string(str) + tts_delimiter_; help_prompt_.push_back(prompt_item); - LOG_UPDATED_VALUE(prompt_item, kHelpPromptKey, - kGlobalPropertiesSection); + LOG_UPDATED_VALUE(prompt_item, kHelpPromptKey, kGlobalPropertiesSection); str = strtok(NULL, ","); } } else { help_prompt_value.clear(); - LOG_UPDATED_VALUE(help_prompt_value, kHelpPromptKey, - kGlobalPropertiesSection); + LOG_UPDATED_VALUE( + help_prompt_value, kHelpPromptKey, kGlobalPropertiesSection); } - - // Timeout prompt time_out_promt_.clear(); std::string timeout_prompt_value; - if (ReadValue(&timeout_prompt_value, kGlobalPropertiesSection, - kTimeoutPromptKey)) { + if (ReadValue( + &timeout_prompt_value, kGlobalPropertiesSection, kTimeoutPromptKey)) { char* str = NULL; str = strtok(const_cast<char*>(timeout_prompt_value.c_str()), ","); while (str != NULL) { // Default prompt should have delimiter included for each item const std::string prompt_item = std::string(str) + tts_delimiter_; time_out_promt_.push_back(prompt_item); - LOG_UPDATED_VALUE(prompt_item, kTimeoutPromptKey, - kGlobalPropertiesSection); + LOG_UPDATED_VALUE( + prompt_item, kTimeoutPromptKey, kGlobalPropertiesSection); str = strtok(NULL, ","); } } else { timeout_prompt_value.clear(); - LOG_UPDATED_VALUE(timeout_prompt_value, kTimeoutPromptKey, - kGlobalPropertiesSection); + LOG_UPDATED_VALUE( + timeout_prompt_value, kTimeoutPromptKey, kGlobalPropertiesSection); } // Voice recognition help title - ReadStringValue(&vr_help_title_, "", kGlobalPropertiesSection, - kHelpTitleKey); + ReadStringValue(&vr_help_title_, "", kGlobalPropertiesSection, kHelpTitleKey); - LOG_UPDATED_VALUE(vr_help_title_, kHelpTitleKey, - kGlobalPropertiesSection); + LOG_UPDATED_VALUE(vr_help_title_, kHelpTitleKey, kGlobalPropertiesSection); // Voice recognition help command vr_commands_.clear(); std::string vr_help_command_value; - if (ReadValue(&vr_help_command_value, kVrCommandsSection, - kHelpCommandKey)) { + if (ReadValue(&vr_help_command_value, kVrCommandsSection, kHelpCommandKey)) { char* str = NULL; str = strtok(const_cast<char*>(vr_help_command_value.c_str()), ","); while (str != NULL) { @@ -1112,17 +1330,18 @@ void Profile::UpdateValues() { } } else { vr_help_command_value.clear(); - LOG_UPDATED_VALUE(vr_help_command_value, kHelpCommandKey, - kVrCommandsSection); + LOG_UPDATED_VALUE( + vr_help_command_value, kHelpCommandKey, kVrCommandsSection); } - //TTS GlobalProperties timeout + // TTS GlobalProperties timeout ReadUIntValue(&tts_global_properties_timeout_, kDefaultTTSGlobalPropertiesTimeout, kGlobalPropertiesSection, kTTSGlobalPropertiesTimeoutKey); - LOG_UPDATED_VALUE(tts_global_properties_timeout_, kTTSGlobalPropertiesTimeoutKey, + LOG_UPDATED_VALUE(tts_global_properties_timeout_, + kTTSGlobalPropertiesTimeoutKey, kGlobalPropertiesSection); // Application time scale maximum requests @@ -1131,15 +1350,17 @@ void Profile::UpdateValues() { kMainSection, kAppTimeScaleMaxRequestsKey); - LOG_UPDATED_VALUE(app_time_scale_max_requests_, kAppTimeScaleMaxRequestsKey, - kMainSection); + LOG_UPDATED_VALUE( + app_time_scale_max_requests_, kAppTimeScaleMaxRequestsKey, kMainSection); // Application time scale - ReadUIntValue(&app_requests_time_scale_, kDefaultAppRequestsTimeScale, - kMainSection, kAppRequestsTimeScaleKey); + ReadUIntValue(&app_requests_time_scale_, + kDefaultAppRequestsTimeScale, + kMainSection, + kAppRequestsTimeScaleKey); - LOG_UPDATED_VALUE(app_requests_time_scale_, kAppRequestsTimeScaleKey, - kMainSection); + LOG_UPDATED_VALUE( + app_requests_time_scale_, kAppRequestsTimeScaleKey, kMainSection); // Application HMI level NONE time scale maximum requests ReadUIntValue(&app_hmi_level_none_time_scale_max_requests_, @@ -1162,21 +1383,25 @@ void Profile::UpdateValues() { kMainSection); // Amount of pending requests - ReadUIntValue(&pending_requests_amount_, kDefaultPendingRequestsAmount, - kMainSection, kPendingRequestsAmoundKey); + ReadUIntValue(&pending_requests_amount_, + kDefaultPendingRequestsAmount, + kMainSection, + kPendingRequestsAmoundKey); if (pending_requests_amount_ == 0) { pending_requests_amount_ = kDefaultPendingRequestsAmount; } - LOG_UPDATED_VALUE(pending_requests_amount_, kPendingRequestsAmoundKey, - kMainSection); + LOG_UPDATED_VALUE( + pending_requests_amount_, kPendingRequestsAmoundKey, kMainSection); // Supported diagnostic modes supported_diag_modes_.clear(); std::string supported_diag_modes_value; std::string correct_diag_modes; - if (ReadStringValue(&supported_diag_modes_value, "", kMainSection, + if (ReadStringValue(&supported_diag_modes_value, + "", + kMainSection, kSupportedDiagModesKey)) { char* str = NULL; str = strtok(const_cast<char*>(supported_diag_modes_value.c_str()), ","); @@ -1195,13 +1420,17 @@ void Profile::UpdateValues() { LOG_UPDATED_VALUE(correct_diag_modes, kSupportedDiagModesKey, kMainSection); // System files path - ReadStringValue(&system_files_path_, kDefaultSystemFilesPath, kMainSection, + ReadStringValue(&system_files_path_, + kDefaultSystemFilesPath, + kMainSection, kSystemFilesPathKey); LOG_UPDATED_VALUE(system_files_path_, kSystemFilesPathKey, kMainSection); // Heartbeat timeout - ReadUIntValue(&heart_beat_timeout_, kDefaultHeartBeatTimeout, kMainSection, + ReadUIntValue(&heart_beat_timeout_, + kDefaultHeartBeatTimeout, + kMainSection, kHeartBeatTimeoutKey); LOG_UPDATED_VALUE(heart_beat_timeout_, kHeartBeatTimeoutKey, kMainSection); @@ -1223,29 +1452,19 @@ void Profile::UpdateValues() { kTransportManagerSection, kTCPAdapterPortKey); - LOG_UPDATED_VALUE(transport_manager_tcp_adapter_port_, kTCPAdapterPortKey, + LOG_UPDATED_VALUE(transport_manager_tcp_adapter_port_, + kTCPAdapterPortKey, kTransportManagerSection); - // MME database name - ReadStringValue(&mme_db_name_, - kDefaultMmeDatabaseName, - kTransportManagerSection, - kMmeDatabaseNameKey); - - LOG_UPDATED_VALUE(mme_db_name_, kMmeDatabaseNameKey, kTransportManagerSection); // Event MQ - ReadStringValue(&event_mq_name_, - kDefaultEventMQ, - kTransportManagerSection, - kEventMQKey); + ReadStringValue( + &event_mq_name_, kDefaultEventMQ, kTransportManagerSection, kEventMQKey); LOG_UPDATED_VALUE(event_mq_name_, kEventMQKey, kTransportManagerSection); // Ack MQ - ReadStringValue(&ack_mq_name_, - kDefaultAckMQ, - kTransportManagerSection, - kAckMQKey); + ReadStringValue( + &ack_mq_name_, kDefaultAckMQ, kTransportManagerSection, kAckMQKey); LOG_UPDATED_VALUE(ack_mq_name_, kAckMQKey, kTransportManagerSection); @@ -1260,22 +1479,28 @@ void Profile::UpdateValues() { kTransportManagerSection); // Recording file - ReadStringValue(&recording_file_name_, kDefaultRecordingFileName, - kMediaManagerSection, kRecordingFileNameKey); + ReadStringValue(&recording_file_name_, + kDefaultRecordingFileName, + kMediaManagerSection, + kRecordingFileNameKey); - LOG_UPDATED_VALUE(recording_file_name_, kRecordingFileNameKey, kMediaManagerSection); + LOG_UPDATED_VALUE( + recording_file_name_, kRecordingFileNameKey, kMediaManagerSection); // Recording file source - ReadStringValue(&recording_file_source_, kDefaultRecordingFileSourceName, - kMediaManagerSection, kRecordingFileSourceKey); + ReadStringValue(&recording_file_source_, + kDefaultRecordingFileSourceName, + kMediaManagerSection, + kRecordingFileSourceKey); - LOG_UPDATED_VALUE(recording_file_source_, kRecordingFileSourceKey, - kMediaManagerSection); + LOG_UPDATED_VALUE( + recording_file_source_, kRecordingFileSourceKey, kMediaManagerSection); // Policy preloaded file ReadStringValue(&preloaded_pt_file_, kDefaultPreloadedPTFileName, - kPolicySection, kPreloadedPTKey); + kPolicySection, + kPreloadedPTKey); preloaded_pt_file_ = app_config_folder_ + '/' + preloaded_pt_file_; @@ -1284,10 +1509,11 @@ void Profile::UpdateValues() { // Policy snapshot file ReadStringValue(&policy_snapshot_file_name_, kDefaultPoliciesSnapshotFileName, - kPolicySection, kPathToSnapshotKey); + kPolicySection, + kPathToSnapshotKey); - LOG_UPDATED_VALUE(policy_snapshot_file_name_, kPathToSnapshotKey, - kPolicySection); + LOG_UPDATED_VALUE( + policy_snapshot_file_name_, kPathToSnapshotKey, kPolicySection); // Attempts number for opening policy DB ReadUIntValue(&attempts_to_open_policy_db_, @@ -1295,17 +1521,17 @@ void Profile::UpdateValues() { kPolicySection, kAttemptsToOpenPolicyDBKey); - LOG_UPDATED_VALUE(attempts_to_open_policy_db_, - kAttemptsToOpenPolicyDBKey, kPolicySection); + LOG_UPDATED_VALUE( + attempts_to_open_policy_db_, kAttemptsToOpenPolicyDBKey, kPolicySection); // Open attempt timeout in ms ReadUIntValue(&open_attempt_timeout_ms_, - kDefaultOpenAttemptTimeoutMsKey, + kDefaultOpenAttemptTimeoutMs, kPolicySection, kOpenAttemptTimeoutMsKey); - LOG_UPDATED_VALUE(open_attempt_timeout_ms_, - kOpenAttemptTimeoutMsKey, kPolicySection); + LOG_UPDATED_VALUE( + open_attempt_timeout_ms_, kOpenAttemptTimeoutMsKey, kPolicySection); // Turn Policy Off? std::string enable_policy_string; @@ -1316,6 +1542,18 @@ void Profile::UpdateValues() { enable_policy_ = false; } + // Max protocol version + ReadUIntValue(&max_supported_protocol_version_, + kDefaultMaxSupportedProtocolVersion, + kProtocolHandlerSection, + kMaxSupportedProtocolVersionKey); + + // if .ini file contains protocol version less than 2 or more than 3 + // max_supported_protocol_version_ = 3 + if (max_supported_protocol_version_ < 2) { + max_supported_protocol_version_ = 3; + } + LOG_UPDATED_BOOL_VALUE(enable_policy_, kEnablePolicy, kPolicySection); ReadUIntValue(&application_list_update_timeout_, @@ -1324,13 +1562,18 @@ void Profile::UpdateValues() { kApplicationListUpdateTimeoutKey); LOG_UPDATED_VALUE(application_list_update_timeout_, - kApplicationListUpdateTimeoutKey, kMainSection); + kApplicationListUpdateTimeoutKey, + kMainSection); - ReadUintIntPairValue(&read_did_frequency_, kReadDIDFrequency, - kMainSection, kReadDIDFrequencykey); + ReadUintIntPairValue(&read_did_frequency_, + kReadDIDFrequency, + kMainSection, + kReadDIDFrequencykey); - ReadUintIntPairValue(&get_vehicle_data_frequency_, kGetVehicleDataFrequency, - kMainSection, kGetVehicleDataFrequencyKey); + ReadUintIntPairValue(&get_vehicle_data_frequency_, + kGetVehicleDataFrequency, + kMainSection, + kGetVehicleDataFrequencyKey); ReadUIntValue(&max_thread_pool_size_, kDefaultMaxThreadPoolSize, @@ -1340,14 +1583,16 @@ void Profile::UpdateValues() { max_thread_pool_size_ = kDefaultMaxThreadPoolSize; } LOG_UPDATED_VALUE(max_thread_pool_size_, - kDefaultMaxThreadPoolSize, kApplicationManagerSection); + kDefaultMaxThreadPoolSize, + kApplicationManagerSection); ReadStringValue(&iap_legacy_protocol_mask_, kDefaultLegacyProtocolMask, kIAPSection, kLegacyProtocolMaskKey); - LOG_UPDATED_VALUE(iap_legacy_protocol_mask_, kLegacyProtocolMaskKey, kIAPSection); + LOG_UPDATED_VALUE( + iap_legacy_protocol_mask_, kLegacyProtocolMaskKey, kIAPSection); ReadStringValue(&iap_hub_protocol_mask_, kDefaultHubProtocolMask, @@ -1382,7 +1627,8 @@ void Profile::UpdateValues() { kIAPSection, kIAP2HubConnectAttemptskey); - LOG_UPDATED_VALUE(iap2_hub_connect_attempts_, kIAP2HubConnectAttemptskey, kIAPSection); + LOG_UPDATED_VALUE( + iap2_hub_connect_attempts_, kIAP2HubConnectAttemptskey, kIAPSection); ReadIntValue(&iap_hub_connection_wait_timeout_, kDefaultIAPHubConnectionWaitTimeout, @@ -1390,59 +1636,91 @@ void Profile::UpdateValues() { kIAPHubConnectionWaitTimeoutKey); LOG_UPDATED_VALUE(iap_hub_connection_wait_timeout_, - kIAPHubConnectionWaitTimeoutKey, kIAPSection); + kIAPHubConnectionWaitTimeoutKey, + kIAPSection); - ReadUIntValue(&default_hub_protocol_index_, kDefaultHubProtocolIndex, kIAPSection, kDefaultHubProtocolIndexKey); + ReadUIntValue(&default_hub_protocol_index_, + kDefaultHubProtocolIndex, + kIAPSection, + kDefaultHubProtocolIndexKey); - LOG_UPDATED_VALUE(default_hub_protocol_index_, kDefaultHubProtocolIndexKey, kIAPSection); + LOG_UPDATED_VALUE( + default_hub_protocol_index_, kDefaultHubProtocolIndexKey, kIAPSection); - ReadUIntValue(&hash_string_size_, + ReadUIntValue(&hash_string_size_, kDefaultHashStringSize, kApplicationManagerSection, kHashStringSizeKey); - LOG_UPDATED_VALUE(hash_string_size_, - kHashStringSizeKey, - kApplicationManagerSection); + LOG_UPDATED_VALUE( + hash_string_size_, kHashStringSizeKey, kApplicationManagerSection); + + ReadBoolValue(&use_db_for_resumption_, + false, + kResumptionSection, + kUseDBForResumptionKey); + + LOG_UPDATED_BOOL_VALUE( + use_db_for_resumption_, kUseDBForResumptionKey, kResumptionSection); + + ReadUIntValue(&attempts_to_open_resumption_db_, + kDefaultAttemptsToOpenResumptionDB, + kResumptionSection, + kAttemptsToOpenResumptionDBKey); + + LOG_UPDATED_VALUE(attempts_to_open_resumption_db_, + kAttemptsToOpenResumptionDBKey, + kResumptionSection); + + ReadUIntValue(&open_attempt_timeout_ms_resumption_db_, + kDefaultOpenAttemptTimeoutMsResumptionDB, + kResumptionSection, + kOpenAttemptTimeoutMsResumptionDBKey); + + LOG_UPDATED_VALUE(open_attempt_timeout_ms_resumption_db_, + kOpenAttemptTimeoutMsResumptionDBKey, + kResumptionSection); } -bool Profile::ReadValue(bool* value, const char* const pSection, +bool Profile::ReadValue(bool* value, + const char* const pSection, const char* const pKey) const { DCHECK(value); bool ret = false; char buf[INI_LINE_LEN + 1]; *buf = '\0'; - if ((0 != ini_read_value(config_file_name_.c_str(), pSection, pKey, buf)) - && ('\0' != *buf)) { - const int32_t tmpVal = atoi(buf); - if (0 == tmpVal) { - *value = false; - } else { + if ((0 != ini_read_value(config_file_name_.c_str(), pSection, pKey, buf)) && + ('\0' != *buf)) { + const int32_t tmpVal = atoi(buf); + if ((0 == strcmp("true", buf)) || (0 != tmpVal)) { *value = true; + } else { + *value = false; } - ret = true; } return ret; } -bool Profile::ReadValue(std::string* value, const char* const pSection, +bool Profile::ReadValue(std::string* value, + const char* const pSection, const char* const pKey) const { DCHECK(value); bool ret = false; char buf[INI_LINE_LEN + 1]; *buf = '\0'; - if ((0 != ini_read_value(config_file_name_.c_str(), pSection, pKey, buf)) - && ('\0' != *buf)) { + if ((0 != ini_read_value(config_file_name_.c_str(), pSection, pKey, buf)) && + ('\0' != *buf)) { *value = buf; ret = true; } return ret; } -bool Profile::ReadStringValue(std::string* value, const char* default_value, +bool Profile::ReadStringValue(std::string* value, + const char* default_value, const char* const pSection, const char* const pKey) const { DCHECK(value); @@ -1453,7 +1731,8 @@ bool Profile::ReadStringValue(std::string* value, const char* default_value, return true; } -bool Profile::ReadIntValue(int32_t* value, const int32_t default_value, +bool Profile::ReadIntValue(int32_t* value, + const int32_t default_value, const char* const pSection, const char* const pKey) const { DCHECK(value); @@ -1466,24 +1745,26 @@ bool Profile::ReadIntValue(int32_t* value, const int32_t default_value, return true; } -bool Profile::ReadUintIntPairValue(std::pair<uint32_t, int32_t>* value, +bool Profile::ReadUintIntPairValue( + std::pair<uint32_t, int32_t>* value, const std::pair<uint32_t, uint32_t>& default_value, - const char *const pSection, - const char *const pKey) const { + const char* const pSection, + const char* const pKey) const { std::string string_value; if (!ReadValue(&string_value, pSection, pKey)) { *value = default_value; return false; } std::string first_str = string_value.substr(0, string_value.find(",")); - std::string second_str = string_value.substr(string_value.find(",") + 1, - string_value.size() - first_str.size()); + std::string second_str = string_value.substr( + string_value.find(",") + 1, string_value.size() - first_str.size()); (*value).first = strtoul(first_str.c_str(), NULL, 10); (*value).second = strtoul(second_str.c_str(), NULL, 10); return true; } -bool Profile::ReadBoolValue(bool* value, const bool default_value, +bool Profile::ReadBoolValue(bool* value, + const bool default_value, const char* const pSection, const char* const pKey) const { DCHECK(value); @@ -1498,38 +1779,41 @@ int32_t hex_to_int(const std::string& value) { } } -std::list<int> Profile::ReadIntContainer( - const char * const pSection, const char * const pKey, - bool *out_result) const { - const std::list<std::string> string_list = +std::vector<int> Profile::ReadIntContainer(const char* const pSection, + const char* const pKey, + bool* out_result) const { + const std::vector<std::string> string_list = ReadStringContainer(pSection, pKey, out_result); - std::list<int> value_list; + std::vector<int> value_list; value_list.resize(string_list.size()); - std::transform(string_list.begin(), string_list.end(), - value_list.begin(), hex_to_int); + std::transform( + string_list.begin(), string_list.end(), value_list.begin(), hex_to_int); return value_list; } -std::list<std::string> Profile::ReadStringContainer( - const char * const pSection, const char * const pKey, - bool *out_result) const { +std::vector<std::string> Profile::ReadStringContainer( + const char* const pSection, + const char* const pKey, + bool* out_result) const { std::string string; const bool result = ReadValue(&string, pSection, pKey); if (out_result) *out_result = result; - std::list < std::string > value_container; + std::vector<std::string> value_container; if (result) { std::istringstream iss(string); std::string temp_str; while (iss) { - if (!getline( iss, temp_str, ',' )) break; + if (!getline(iss, temp_str, ',')) + break; value_container.push_back(temp_str); } } return value_container; } -bool Profile::ReadUIntValue(uint16_t* value, uint16_t default_value, +bool Profile::ReadUIntValue(uint16_t* value, + uint16_t default_value, const char* const pSection, const char* const pKey) const { std::string string_value; @@ -1542,13 +1826,17 @@ bool Profile::ReadUIntValue(uint16_t* value, uint16_t default_value, *value = default_value; return false; } - + if (user_value > (std::numeric_limits<uint16_t>::max)()) { + *value = default_value; + return false; + } *value = static_cast<uint16_t>(user_value); return true; } } -bool Profile::ReadUIntValue(uint32_t* value, uint32_t default_value, +bool Profile::ReadUIntValue(uint32_t* value, + uint32_t default_value, const char* const pSection, const char* const pKey) const { std::string string_value; @@ -1558,7 +1846,11 @@ bool Profile::ReadUIntValue(uint32_t* value, uint32_t default_value, } else { uint64_t user_value; if (!StringToNumber(string_value, user_value)) { - *value = default_value; + *value = default_value; + return false; + } + if (user_value > (std::numeric_limits<uint32_t>::max)()) { + *value = default_value; return false; } @@ -1567,7 +1859,8 @@ bool Profile::ReadUIntValue(uint32_t* value, uint32_t default_value, } } -bool Profile::ReadUIntValue(uint64_t* value, uint64_t default_value, +bool Profile::ReadUIntValue(uint64_t* value, + uint64_t default_value, const char* const pSection, const char* const pKey) const { std::string string_value; @@ -1613,4 +1906,4 @@ void Profile::MakeAbsolutePath(std::string& path) { path = file_system::CurrentWorkingDirectory() + "/" + path; } -}// namespace profile +} // namespace profile diff --git a/src/components/config_profile/test/CMakeLists.txt b/src/components/config_profile/test/CMakeLists.txt index e474d3fc20..1246bff066 100644 --- a/src/components/config_profile/test/CMakeLists.txt +++ b/src/components/config_profile/test/CMakeLists.txt @@ -31,9 +31,7 @@ if(BUILD_TESTS) include_directories ( - ${CMAKE_SOURCE_DIR}/src/3rd_party-static/gmock-1.7.0/include - ${CMAKE_SOURCE_DIR}/src/3rd_party-static/gmock-1.7.0/gtest/include - ${COMPONENTS_DIR}/include/utils + ${GMOCK_INCLUDE_DIRECTORY} ${COMPONENTS_DIR}/config_profile/include ) diff --git a/src/components/config_profile/test/ini_file_test.cc b/src/components/config_profile/test/ini_file_test.cc index 10d500df74..2f256c8b51 100644 --- a/src/components/config_profile/test/ini_file_test.cc +++ b/src/components/config_profile/test/ini_file_test.cc @@ -24,7 +24,7 @@ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * FERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. @@ -40,238 +40,234 @@ namespace profile { using namespace ::profile; -TEST(IniFileTest, DISABLED_WriteItemReadItem) { +TEST(IniFileTest, WriteItemReadItem) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * item = "Test_item"; - const char * value = "test_value"; - const bool write_result = ini_write_value(fname, chapter, item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* item = "Test_item"; + const char* value = "test_value"; + const bool write_result = + ini_write_value(fname, chapter, item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); - - // Read value from file - char search_value[INI_LINE_LEN] = ""; + char search_value[INI_LINE_LEN] = {0}; const bool read_result = ini_read_value(fname, chapter, item, search_value); + const char* res = search_value; EXPECT_TRUE(read_result); - EXPECT_EQ(*search_value, *value); + EXPECT_STREQ(res, value); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); } -TEST(IniFileTest, DISABLED_WriteItemWithoutValueReadItem) { +TEST(IniFileTest, WriteItemWithoutValueReadItem) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * test_item = "Test_item"; - const char * value = ""; - const bool write_result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* test_item = "Test_item"; + const char* value = ""; + const bool write_result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); // Read value from file - char search_value[INI_LINE_LEN] = ""; - const bool read_result = ini_read_value(fname, chapter, test_item, search_value); - + char search_value[INI_LINE_LEN] = {0}; + const bool read_result = + ini_read_value(fname, chapter, test_item, search_value); + const char* res = search_value; EXPECT_TRUE(read_result); - EXPECT_EQ(*search_value, *value); + EXPECT_STREQ(res, value); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); } -TEST(IniFileTest, DISABLED_WriteSameItemInDifferentChapters) { +TEST(IniFileTest, WriteSameItemInDifferentChapters) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter1 = "Chapter1"; - const char * test_item = "Test_item"; - const char * value = "test_value"; - const bool write_result = ini_write_value(fname, chapter1, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter1 = "Chapter1"; + const char* test_item = "Test_item"; + const char* value = "test_value"; + const bool write_result = + ini_write_value(fname, chapter1, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); - - char search_value[INI_LINE_LEN] = ""; - const bool read_result = ini_read_value(fname, chapter1, test_item, search_value); - + char search_value[INI_LINE_LEN] = {0}; + const bool read_result = + ini_read_value(fname, chapter1, test_item, search_value); + const char* res = search_value; EXPECT_TRUE(read_result); - EXPECT_EQ(*search_value, *value); + EXPECT_STREQ(res, value); // Create new chapter and write the same value - const char *chapter2 = "Chapter2"; + const char* chapter2 = "Chapter2"; - const bool write_result2 = ini_write_value(fname, chapter2, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const bool write_result2 = + ini_write_value(fname, chapter2, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result2); char value2[INI_LINE_LEN] = "test_value"; const bool read_result2 = ini_read_value(fname, chapter2, test_item, value2); - + const char* res2 = value2; EXPECT_TRUE(read_result2); - EXPECT_EQ(*value2, *value); - + EXPECT_STREQ(res2, res); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); } -TEST(IniFileTest, DISABLED_RewriteItem) { +TEST(IniFileTest, RewriteItem) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * item = "Test_item"; - const char * value = "test_value"; - bool write_result = ini_write_value(fname, chapter, item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* item = "Test_item"; + const char* value = "test_value"; + bool write_result = + ini_write_value(fname, chapter, item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); - - char search_value[INI_LINE_LEN] = ""; + char search_value[INI_LINE_LEN] = {0}; bool read_result = ini_read_value(fname, chapter, item, search_value); - + const char* res = search_value; EXPECT_TRUE(read_result); - EXPECT_EQ(*search_value, *value); + EXPECT_STREQ(res, value); // Write item again - const char * newvalue = "new_test_value"; - write_result = ini_write_value(fname, chapter, item, newvalue, - INI_FLAG_ITEM_UP_CREA); + const char* newvalue = "new_test_value"; + write_result = + ini_write_value(fname, chapter, item, newvalue, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); - - char new_search_value[INI_LINE_LEN] = ""; + char new_search_value[INI_LINE_LEN] = {0}; read_result = ini_read_value(fname, chapter, item, new_search_value); - + const char* new_res = new_search_value; EXPECT_TRUE(read_result); - EXPECT_EQ(*new_search_value, *newvalue); + EXPECT_STREQ(new_res, newvalue); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); } -TEST(IniFileTest, DISABLED_WriteTwoItemsInOneChapter) { +TEST(IniFileTest, WriteTwoItemsInOneChapter) { // Write line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * item = "Test_item"; - const char * value1 = "test_value"; + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* item = "Test_item"; + const char* value1 = "test_value"; - bool write_result = ini_write_value(fname, chapter, item, value1, - INI_FLAG_ITEM_UP_CREA); + bool write_result = + ini_write_value(fname, chapter, item, value1, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); // Write another line in the same chapter - const char * item2 = "Test_item2"; - const char * value2 = "test_value2"; + const char* item2 = "Test_item2"; + const char* value2 = "test_value2"; - write_result = ini_write_value(fname, chapter, item2, value2, - INI_FLAG_ITEM_UP_CREA); + write_result = + ini_write_value(fname, chapter, item2, value2, INI_FLAG_ITEM_UP_CREA); EXPECT_TRUE(write_result); // Search both values - char search_value[INI_LINE_LEN] = ""; + char search_value[INI_LINE_LEN] = {0}; bool read_result = ini_read_value(fname, chapter, item, search_value); - + const char* res = search_value; EXPECT_TRUE(read_result); - EXPECT_EQ(*search_value, *value1); + EXPECT_STREQ(res, value1); - char search_value2[INI_LINE_LEN] = ""; + char search_value2[INI_LINE_LEN] = {0}; read_result = ini_read_value(fname, chapter, item2, search_value2); - + const char* res2 = search_value2; EXPECT_TRUE(read_result); - EXPECT_EQ(*search_value2, *value2); - + EXPECT_STREQ(res2, value2); EXPECT_TRUE(file_system::DeleteFile("./test_ini_file.ini")); } TEST(IniFileTest, WriteEmptyItemWithValueReadItem) { - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * test_item = ""; - const char * value = "test_value"; - bool result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* test_item = ""; + const char* value = "test_value"; + bool result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_FALSE(result); } TEST(IniFileTest, WriteEmptyItemWithEmptyValue_ExpectFalse) { // Write empty line in chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = "Chapter"; - const char * test_item = ""; - const char * value = ""; - bool result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = "Chapter"; + const char* test_item = ""; + const char* value = ""; + bool result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_FALSE(result); } TEST(IniFileTest, WriteItemInEmptyChapter_ExpectFalse) { // Write line in empty chapter - const char * fname = "./test_ini_file.ini"; - const char *chapter = ""; - const char * test_item = "Test_item"; - const char * value = "test_value"; - bool result = ini_write_value(fname, chapter, test_item, value, - INI_FLAG_ITEM_UP_CREA); + const char* fname = "./test_ini_file.ini"; + const char* chapter = ""; + const char* test_item = "Test_item"; + const char* value = "test_value"; + bool result = + ini_write_value(fname, chapter, test_item, value, INI_FLAG_ITEM_UP_CREA); EXPECT_FALSE(result); } -TEST(IniFileTest,ParseEmptyLine) { - char line[INI_LINE_LEN] = ""; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "HMI"; +TEST(IniFileTest, ParseEmptyLine) { + char line[INI_LINE_LEN] = {0}; + char val[INI_LINE_LEN] = {0}; + const char* tag = "HMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_NOTHING, result); } -TEST(IniFileTest,ParseChapter) { - char line[INI_LINE_LEN] = "[HMI]"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "HMI"; +TEST(IniFileTest, ParseChapter) { + const char* line = "[HMI]"; + char val[INI_LINE_LEN] = {0}; + const char* tag = "HMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_RIGHT_CHAPTER, result); } -TEST(IniFileTest,ParseChapterTagEmpty) { - char line[INI_LINE_LEN] = "[HMI]"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = ""; +TEST(IniFileTest, ParseChapterTagEmpty) { + const char* line = "[HMI]"; + char val[INI_LINE_LEN] = {0}; + char tag[INI_LINE_LEN] = {0}; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_CHAPTER, result); } -TEST(IniFileTest,ParseChapterWithUppercaseTag) { - char line[INI_LINE_LEN] = "[Security Manager]"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "SECURITY MANAGER"; +TEST(IniFileTest, ParseChapterWithUppercaseTag) { + const char* line = "[Security Manager]"; + char val[INI_LINE_LEN] = {0}; + const char* tag = "SECURITY MANAGER"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_RIGHT_CHAPTER, result); } -TEST(IniFileTest,ParseChapterWithLowcaseTag) { - char line[INI_LINE_LEN] = "[Security Manager]"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "Security Manager"; +TEST(IniFileTest, ParseChapterWithLowcaseTag) { + const char* line = "[Security Manager]"; + char val[INI_LINE_LEN] = {0}; + const char* tag = "Security Manager"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_CHAPTER, result); } -TEST(IniFileTest,ParseWithWrongChapter) { - char line[INI_LINE_LEN] = "[HMI]"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "MAIN"; +TEST(IniFileTest, ParseWithWrongChapter) { + const char* line = "[HMI]"; + char val[INI_LINE_LEN] = {0}; + const char* tag = "MAIN"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_CHAPTER, result); } -TEST(IniFileTest,ParseLineWithItem) { +TEST(IniFileTest, ParseLineWithItem) { char line[INI_LINE_LEN] = "LaunchHMI = true"; char val[INI_LINE_LEN] = ""; char tag[INI_LINE_LEN] = "LAUNCHHMI"; @@ -284,50 +280,49 @@ TEST(IniFileTest,ParseLineWithItem) { EXPECT_EQ(*check_val, *val); } -TEST(IniFileTest,ParseLineWithoutItem) { - char line[INI_LINE_LEN] = "LaunchHMI = "; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "LAUNCHHMI"; +TEST(IniFileTest, ParseLineWithoutItem) { + const char* line = "LaunchHMI = "; + char val[INI_LINE_LEN] = {0}; + const char* tag = "LAUNCHHMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); + const char* res = val; + const char* check_val = ""; EXPECT_EQ(INI_RIGHT_ITEM, result); - - char check_val[INI_LINE_LEN] = ""; - EXPECT_EQ(*check_val, *val); + EXPECT_STREQ(check_val, res); } -TEST(IniFileTest,ParseLineWithEmptytag) { - char line[INI_LINE_LEN] = "LaunchHMI = true"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = ""; +TEST(IniFileTest, ParseLineWithEmptytag) { + const char* line = "LaunchHMI = true"; + char val[INI_LINE_LEN] = {0}; + char tag[INI_LINE_LEN] = {0}; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_ITEM, result); } -TEST(IniFileTest,ParseLineWithLowcaseTag) { - char line[INI_LINE_LEN] = "LaunchHMI = true"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "LaunchHmi"; +TEST(IniFileTest, ParseLineWithLowcaseTag) { + const char* line = "LaunchHMI = true"; + char val[INI_LINE_LEN] = {0}; + const char* tag = "LaunchHmi"; Ini_search_id result; result = ini_parse_line(line, tag, val); EXPECT_EQ(INI_WRONG_ITEM, result); } -TEST(IniFileTest,ParseLineWithComment) { - char line[INI_LINE_LEN] = "; [HMI]"; - char val[INI_LINE_LEN] = ""; - char tag[INI_LINE_LEN] = "HMI"; +TEST(IniFileTest, ParseLineWithComment) { + const char* line = "; [HMI]"; + char val[INI_LINE_LEN] = {0}; + const char* tag = "HMI"; Ini_search_id result; result = ini_parse_line(line, tag, val); + const char* res = val; EXPECT_EQ(INI_REMARK, result); - - char check_val[INI_LINE_LEN] = ";"; - EXPECT_EQ(*check_val, *val); + EXPECT_STREQ(line, res); } } // namespace profile diff --git a/src/components/config_profile/test/profile_test.cc b/src/components/config_profile/test/profile_test.cc index 9d9eca755f..59ebb2820b 100644 --- a/src/components/config_profile/test/profile_test.cc +++ b/src/components/config_profile/test/profile_test.cc @@ -30,9 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <algorithm> +#include <vector> + #include "gtest/gtest.h" #include "config_profile/profile.h" -#include <algorithm> #include "utils/file_system.h" #include "utils/threads/thread.h" @@ -44,746 +46,684 @@ using namespace ::profile; class ProfileTest : public ::testing::Test { protected: - virtual void SetUp() { - profile::Profile::destroy(); - } - virtual void TearDown() { - profile::Profile::destroy(); - } - + profile::Profile profile_; }; -TEST_F(ProfileTest, SingletonProfile) { - Profile::instance(); - EXPECT_TRUE(Profile::exists()); - profile::Profile::destroy(); - EXPECT_FALSE(Profile::exists()); -} - TEST_F(ProfileTest, UpdateConfigWithDefaultFile) { // Default value uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); + EXPECT_FALSE(profile_.enable_policy()); std::string vr_help_title_ = ""; - EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + EXPECT_EQ(vr_help_title_, profile_.vr_help_title()); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Value was updated thread_min_stack_size = 20480; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); + EXPECT_TRUE(profile_.enable_policy()); vr_help_title_ = "Available Vr Commands List"; - EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); + EXPECT_EQ(vr_help_title_, profile_.vr_help_title()); } TEST_F(ProfileTest, SetConfigFileWithoutCallUpdate) { // Default value uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); + EXPECT_FALSE(profile_.enable_policy()); std::string vr_help_title_ = ""; - EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + EXPECT_EQ(vr_help_title_, profile_.vr_help_title()); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); - Profile::instance()->config_file_name("smartDeviceLink.ini"); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink.ini"); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); // Value was updated thread_min_stack_size = 20480; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); + EXPECT_TRUE(profile_.enable_policy()); vr_help_title_ = "Available Vr Commands List"; - EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); + EXPECT_EQ(vr_help_title_, profile_.vr_help_title()); } TEST_F(ProfileTest, SetConfigFileWithUpdate) { // Default value uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); - Profile::instance()->config_file_name("smartDeviceLink.ini"); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); + profile_.config_file_name("smartDeviceLink.ini"); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); // Value was updated thread_min_stack_size = 20480; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Update config file again - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Value should be the same - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); } TEST_F(ProfileTest, UpdateManyTimesDefaultFile) { - //using for check logger's work - core dump when this test was started and log4cxx exists in test derictory - Profile::instance()->config_file_name("smartDeviceLink.ini"); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + // using for check logger's work - core dump when this test was started and + // log4cxx exists in test derictory + profile_.config_file_name("smartDeviceLink.ini"); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); // Update config many times for (int i = 0; i < 10; i++) { - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); } } TEST_F(ProfileTest, UpdateIntValues) { // Default value - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Set config file with default name - Profile::instance()->config_file_name("smartDeviceLink.ini"); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink.ini"); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); // Value changes thread_min_stack_size = 20480; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Update config file again - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are same - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Set new config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Value changes thread_min_stack_size = 21000; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Update config file again - profile::Profile::instance()->UpdateValues(); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.UpdateValues(); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Value should be the same - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Set config file with default name again - Profile::instance()->config_file_name("smartDeviceLink.ini"); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink.ini"); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); // Value should be changed thread_min_stack_size = 20480; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); } TEST_F(ProfileTest, UpdateBoolValues) { // Default values - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); + EXPECT_TRUE(profile_.launch_hmi()); + EXPECT_FALSE(profile_.enable_policy()); // Set config file - Profile::instance()->config_file_name("smartDeviceLink.ini"); + profile_.config_file_name("smartDeviceLink.ini"); // Check values - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_TRUE(profile_.launch_hmi()); + EXPECT_TRUE(profile_.enable_policy()); + EXPECT_FALSE(profile_.is_redecoding_enabled()); // Update config file again - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are same - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_TRUE(profile_.launch_hmi()); + EXPECT_TRUE(profile_.enable_policy()); + EXPECT_FALSE(profile_.is_redecoding_enabled()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Parameters after updating - EXPECT_FALSE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); - EXPECT_TRUE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_FALSE(profile_.launch_hmi()); + EXPECT_FALSE(profile_.enable_policy()); + EXPECT_TRUE(profile_.is_redecoding_enabled()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Parameters are same - EXPECT_FALSE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); - EXPECT_TRUE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_FALSE(profile_.launch_hmi()); + EXPECT_FALSE(profile_.enable_policy()); + EXPECT_TRUE(profile_.is_redecoding_enabled()); } TEST_F(ProfileTest, UpdateStringValue) { // Default values - std::string config_folder = ""; + std::string recording_file_name = "record.wav"; std::string tts_delimiter_ = ""; std::string vr_help_title_ = ""; + std::string app_resource_folder = ""; std::string server_address = "127.0.0.1"; - std::string app_resourse_folder = ""; - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); - EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - Profile::instance()->config_file_name("smartDeviceLink.ini"); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + EXPECT_EQ(recording_file_name, profile_.recording_file_name()); + EXPECT_EQ(server_address, profile_.server_address()); + + profile_.config_file_name("smartDeviceLink.ini"); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); // Check values - config_folder = file_system::CurrentWorkingDirectory(); - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); + app_resource_folder = file_system::CurrentWorkingDirectory(); + EXPECT_EQ(app_resource_folder, profile_.app_resource_folder()); tts_delimiter_ = ","; - EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); + EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter()); vr_help_title_ = "Available Vr Commands List"; - EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); - - EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - app_resourse_folder = file_system::CurrentWorkingDirectory(); - EXPECT_EQ(app_resourse_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(vr_help_title_, profile_.vr_help_title()); + EXPECT_EQ(server_address, profile_.server_address()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are the same - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); - EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); - EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title()); - EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - EXPECT_EQ(app_resourse_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter()); + EXPECT_EQ(vr_help_title_, profile_.vr_help_title()); + EXPECT_EQ(server_address, profile_.server_address()); } TEST_F(ProfileTest, UpdateInt_ValueAppearsInFileTwice) { // Default values uint32_t server_port = 8087; - EXPECT_EQ(server_port, Profile::instance()->server_port()); + EXPECT_EQ(server_port, profile_.server_port()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Update config file // First server_port = 8088 server_port = 8088; - EXPECT_EQ(server_port, Profile::instance()->server_port()); + EXPECT_EQ(server_port, profile_.server_port()); } TEST_F(ProfileTest, UpdateBool_ValueAppearsInFileTwice) { // Default values - EXPECT_FALSE(Profile::instance()->is_mixing_audio_supported()); + EXPECT_FALSE(profile_.is_mixing_audio_supported()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Update config file // First value is false - EXPECT_FALSE(profile::Profile::instance()->is_mixing_audio_supported()); + EXPECT_FALSE(profile_.is_mixing_audio_supported()); } TEST_F(ProfileTest, UpdateVectorOfString_ValueAppearsInFileTwice) { // Default values - std::vector < std::string > time_out_promt; - EXPECT_EQ(time_out_promt, Profile::instance()->time_out_promt()); + std::vector<std::string> time_out_promt; + EXPECT_EQ(time_out_promt, profile_.time_out_promt()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Update config file time_out_promt.push_back("Please say a command,"); - EXPECT_EQ(time_out_promt, Profile::instance()->time_out_promt()); + EXPECT_EQ(time_out_promt, profile_.time_out_promt()); } TEST_F(ProfileTest, UpdateString_ValueAppearsInFileTwice) { // Default values std::string recording_file_name = "record.wav"; - EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name()); + EXPECT_EQ(recording_file_name, profile_.recording_file_name()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Update config file recording_file_name = "video.wav"; - EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name()); + EXPECT_EQ(recording_file_name, profile_.recording_file_name()); } TEST_F(ProfileTest, UpdatePairsValue) { // Default values - std::pair < uint32_t, int32_t > value; + std::pair<uint32_t, int32_t> value; value.first = 0; value.second = 0; - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); - Profile::instance()->config_file_name("smartDeviceLink.ini"); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink.ini"); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); value.first = 5; value.second = 1; - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + profile_.UpdateValues(); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); } // Section with negative tests TEST_F(ProfileTest, PairsValueEmpty) { // Default values - std::pair < uint32_t, int32_t > value; + std::pair<uint32_t, int32_t> value; value.first = 0; value.second = 0; - EXPECT_EQ(value, Profile::instance()->read_did_frequency()); + EXPECT_EQ(value, profile_.read_did_frequency()); - Profile::instance()->config_file_name("smartDeviceLink_invalid_pairs.ini"); - EXPECT_EQ("smartDeviceLink_invalid_pairs.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_pairs.ini"); + EXPECT_EQ("smartDeviceLink_invalid_pairs.ini", profile_.config_file_name()); // Default values value.first = 5; value.second = 1; - EXPECT_EQ(value, Profile::instance()->read_did_frequency()); + EXPECT_EQ(value, profile_.read_did_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are same - EXPECT_EQ(value, Profile::instance()->read_did_frequency()); + EXPECT_EQ(value, profile_.read_did_frequency()); } TEST_F(ProfileTest, CharValueInPairInsteadOfInt) { - std::pair < uint32_t, int32_t > value; + std::pair<uint32_t, int32_t> value; value.first = 0; value.second = 0; - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); - Profile::instance()->config_file_name("smartDeviceLink_invalid_string.ini"); - EXPECT_EQ("smartDeviceLink_invalid_string.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_string.ini"); + EXPECT_EQ("smartDeviceLink_invalid_string.ini", profile_.config_file_name()); - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are same - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); } TEST_F(ProfileTest, EmptyValuesInPair) { - Profile::instance()->config_file_name("smartDeviceLink_invalid_pairs.ini"); - EXPECT_EQ("smartDeviceLink_invalid_pairs.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_pairs.ini"); + EXPECT_EQ("smartDeviceLink_invalid_pairs.ini", profile_.config_file_name()); - std::pair < uint32_t, int32_t > value; + std::pair<uint32_t, int32_t> value; value.first = 0; value.second = 0; - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are same - EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency()); + EXPECT_EQ(value, profile_.get_vehicle_data_frequency()); } -TEST_F(ProfileTest, DISABLED_IntInsteadOfPair) { +TEST_F(ProfileTest, IntInsteadOfPair) { // Default values - std::pair < uint32_t, int32_t > value; + std::pair<uint32_t, int32_t> value; value.first = 0; value.second = 0; - EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount()); + EXPECT_EQ(value, profile_.start_stream_retry_amount()); - Profile::instance()->config_file_name("smartDeviceLink_invalid_pairs.ini"); - EXPECT_EQ("smartDeviceLink_invalid_pairs.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_pairs.ini"); + EXPECT_EQ("smartDeviceLink_invalid_pairs.ini", profile_.config_file_name()); // Ini file includes only one element value.first = 9; - value.second = 1000; - EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount()); + value.second = 0; + EXPECT_EQ(value, profile_.start_stream_retry_amount()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are same - EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount()); + EXPECT_EQ(value, profile_.start_stream_retry_amount()); } TEST_F(ProfileTest, WrongIntValue) { // Default value - int32_t heart_beat_timeout = 0; - EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout()); + uint32_t heart_beat_timeout = 0; + EXPECT_EQ(heart_beat_timeout, profile_.heart_beat_timeout()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini"); - EXPECT_EQ("smartDeviceLink_invalid_int.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_int.ini"); + EXPECT_EQ("smartDeviceLink_invalid_int.ini", profile_.config_file_name()); // Value in file includes letters. Check that value is default heart_beat_timeout = 0; - EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout()); + EXPECT_EQ(heart_beat_timeout, profile_.heart_beat_timeout()); // Update config file - profile::Profile::instance()->UpdateValues(); - EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout()); + profile_.UpdateValues(); + EXPECT_EQ(heart_beat_timeout, profile_.heart_beat_timeout()); } -TEST_F(ProfileTest, DISABLED_WrongMaxIntValue) { +TEST_F(ProfileTest, WrongMaxIntValue) { // Default value uint32_t maxvalue = 2000000000; - EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); + EXPECT_EQ(maxvalue, profile_.max_cmd_id()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini"); - EXPECT_EQ("smartDeviceLink_invalid_int.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_int.ini"); + EXPECT_EQ("smartDeviceLink_invalid_int.ini", profile_.config_file_name()); // Value in file is more than could be saved. // Check that value is default - EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); + EXPECT_EQ(maxvalue, profile_.max_cmd_id()); // Update config file - profile::Profile::instance()->UpdateValues(); - EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); + profile_.UpdateValues(); + EXPECT_EQ(maxvalue, profile_.max_cmd_id()); } -TEST_F(ProfileTest, DISABLED_WrongMinIntValue) { +TEST_F(ProfileTest, WrongMinIntValue) { // Default value uint32_t minvalue = threads::Thread::kMinStackSize; - EXPECT_EQ(minvalue, Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(minvalue, profile_.thread_min_stack_size()); uint16_t server_port = 8087; - EXPECT_EQ(server_port, Profile::instance()->server_port()); + EXPECT_EQ(server_port, profile_.server_port()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini"); - EXPECT_EQ("smartDeviceLink_invalid_int.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_int.ini"); + EXPECT_EQ("smartDeviceLink_invalid_int.ini", profile_.config_file_name()); - //File include 0, value should be lefted as default - EXPECT_EQ(minvalue, Profile::instance()->thread_min_stack_size()); - //File include -1, value should be lefted as default - EXPECT_EQ(server_port, Profile::instance()->server_port()); + // File include 0, value should be lefted as default + EXPECT_EQ(minvalue, profile_.thread_min_stack_size()); + // File include -1, value should be lefted as default + EXPECT_EQ(server_port, profile_.server_port()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Default value should be lefted - EXPECT_EQ(minvalue, Profile::instance()->thread_min_stack_size()); - EXPECT_EQ(server_port, Profile::instance()->server_port()); + EXPECT_EQ(minvalue, profile_.thread_min_stack_size()); + EXPECT_EQ(server_port, profile_.server_port()); } -TEST_F(ProfileTest, DISABLED_CheckCorrectValueWhenOtherValueInvalid) { +TEST_F(ProfileTest, CheckCorrectValueWhenOtherValueInvalid) { // Default value uint32_t maxvalue = 2000000000; - EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); + EXPECT_EQ(maxvalue, profile_.max_cmd_id()); uint32_t thread_min_stack_size = threads::Thread::kMinStackSize; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); // Check that value is default maxvalue = 2000000000; - EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); + EXPECT_EQ(maxvalue, profile_.max_cmd_id()); // Other value is correct thread_min_stack_size = 21000; - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // In file the number is bigger than can be, default value should be lefted - EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id()); - EXPECT_EQ(thread_min_stack_size, - Profile::instance()->thread_min_stack_size()); + EXPECT_EQ(maxvalue, profile_.max_cmd_id()); + EXPECT_EQ(thread_min_stack_size, profile_.thread_min_stack_size()); } TEST_F(ProfileTest, PairsValueInsteadOfInt) { // Set new config file - Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini"); - EXPECT_EQ("smartDeviceLink_invalid_int.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_int.ini"); + EXPECT_EQ("smartDeviceLink_invalid_int.ini", profile_.config_file_name()); // Get first number uint32_t list_files_in_none = 5; - EXPECT_EQ(list_files_in_none, Profile::instance()->list_files_in_none()); + EXPECT_EQ(list_files_in_none, profile_.list_files_in_none()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are same - EXPECT_EQ(list_files_in_none, Profile::instance()->list_files_in_none()); + EXPECT_EQ(list_files_in_none, profile_.list_files_in_none()); } -TEST_F(ProfileTest, DISABLED_StringValueIncludeSlashesAndRussianLetters) { +TEST_F(ProfileTest, StringValueIncludeSlashesAndRussianLetters) { // Default values std::string config_folder = ""; - EXPECT_EQ(config_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(config_folder, profile_.app_resource_folder()); std::string tts_delimiter_ = ""; - std::string app_resourse_folder = ""; std::string app_storage_folder = ""; + std::string current_dir = file_system::CurrentWorkingDirectory(); - Profile::instance()->config_file_name("smartDeviceLink_invalid_string.ini"); - EXPECT_EQ("smartDeviceLink_invalid_string.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_string.ini"); + EXPECT_EQ("smartDeviceLink_invalid_string.ini", profile_.config_file_name()); // Check values - config_folder = "///"; - EXPECT_EQ(config_folder, Profile::instance()->app_config_folder()); tts_delimiter_ = "coma and point"; - EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); + EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter()); std::string server_address = "127.0.0.1 + слово"; - EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - app_resourse_folder = "new folder/"; - EXPECT_EQ(app_resourse_folder, Profile::instance()->app_resourse_folder()); - app_storage_folder = "\" \""; - EXPECT_EQ(app_storage_folder, Profile::instance()->app_storage_folder()); + EXPECT_EQ(server_address, profile_.server_address()); + app_storage_folder = "/\" \""; + EXPECT_EQ(current_dir + app_storage_folder, profile_.app_storage_folder()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are the same - EXPECT_EQ(config_folder, Profile::instance()->app_config_folder()); - EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter()); - EXPECT_EQ(server_address, profile::Profile::instance()->server_address()); - EXPECT_EQ(app_resourse_folder, Profile::instance()->app_resourse_folder()); + EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter()); + EXPECT_EQ(server_address, profile_.server_address()); } TEST_F(ProfileTest, StringUpperBoundValue) { // Default values std::string vr_help_title = ""; std::string recording_file_name = "record.wav"; - EXPECT_EQ(vr_help_title, Profile::instance()->vr_help_title()); - EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name()); + EXPECT_EQ(vr_help_title, profile_.vr_help_title()); + EXPECT_EQ(recording_file_name, profile_.recording_file_name()); - Profile::instance()->config_file_name("smartDeviceLink_invalid_string.ini"); - EXPECT_EQ("smartDeviceLink_invalid_string.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_string.ini"); + EXPECT_EQ("smartDeviceLink_invalid_string.ini", profile_.config_file_name()); // Total count of elements in ini file's string will be less 512 vr_help_title = - "0/0/0/1/2345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890abc!def@ghi"; - EXPECT_EQ(vr_help_title, Profile::instance()->vr_help_title()); - EXPECT_NE(vr_help_title, Profile::instance()->recording_file_name()); + "0/0/0/1/" + "2345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~" + "STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:" + "yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!" + "def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z," + "01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_" + "GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$" + "mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890abc!" + "def@ghi"; + EXPECT_EQ(vr_help_title, profile_.vr_help_title()); + EXPECT_NE(vr_help_title, profile_.recording_file_name()); recording_file_name = - "0/0/0/1/2345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890abc"; - EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name()); + "0/0/0/1/" + "2345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~" + "STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:" + "yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!" + "def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z," + "01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_" + "GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$" + "mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890abc"; + EXPECT_EQ(recording_file_name, profile_.recording_file_name()); // Update config file - profile::Profile::instance()->UpdateValues(); + profile_.UpdateValues(); // Values are the same - EXPECT_EQ(vr_help_title, Profile::instance()->vr_help_title()); - EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name()); + EXPECT_EQ(vr_help_title, profile_.vr_help_title()); + EXPECT_EQ(recording_file_name, profile_.recording_file_name()); } TEST_F(ProfileTest, CapitalLetterInBoolValue) { // Default values - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name()); + EXPECT_TRUE(profile_.launch_hmi()); + EXPECT_FALSE(profile_.enable_policy()); // Set config file - Profile::instance()->config_file_name("smartDeviceLink.ini"); + profile_.config_file_name("smartDeviceLink.ini"); // Check values - EXPECT_TRUE(profile::Profile::instance()->launch_hmi()); - EXPECT_TRUE(profile::Profile::instance()->enable_policy()); - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_TRUE(profile_.launch_hmi()); + EXPECT_TRUE(profile_.enable_policy()); + EXPECT_FALSE(profile_.is_redecoding_enabled()); // Change config file - Profile::instance()->config_file_name("smartDeviceLink_invalid_boolean.ini"); - EXPECT_EQ("smartDeviceLink_invalid_boolean.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_invalid_boolean.ini"); + EXPECT_EQ("smartDeviceLink_invalid_boolean.ini", profile_.config_file_name()); // Parameters after updating // Parameter launch_hmi = True - EXPECT_FALSE(profile::Profile::instance()->launch_hmi()); + EXPECT_FALSE(profile_.launch_hmi()); // EnablePolicy = TRUE - EXPECT_FALSE(profile::Profile::instance()->enable_policy()); + EXPECT_FALSE(profile_.enable_policy()); // EnableRedecoding = FALSE - EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled()); + EXPECT_FALSE(profile_.is_redecoding_enabled()); } TEST_F(ProfileTest, CheckReadStringValue) { // Set new config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); - - std::string app_resourse_folder_; - profile::Profile::instance()->ReadStringValue( - &app_resourse_folder_, file_system::CurrentWorkingDirectory().c_str(), - "MAIN", "AppResourceFolder"); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); + + std::string app_storage_folder_; + profile_.ReadStringValue( + &app_storage_folder_, "", "MAIN", "AppStorageFolder"); // Get default value - EXPECT_EQ(app_resourse_folder_, file_system::CurrentWorkingDirectory()); + EXPECT_EQ("storage", app_storage_folder_); // Get value from file std::string server_address; - profile::Profile::instance()->ReadStringValue(&server_address, "", "HMI", - "ServerAddress"); + profile_.ReadStringValue(&server_address, "", "HMI", "ServerAddress"); EXPECT_EQ("127.0.0.1", server_address); } -TEST_F(ProfileTest, DISABLED_CheckReadBoolValue) { +TEST_F(ProfileTest, CheckReadBoolValue) { // Set new config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); bool enable_policy; - profile::Profile::instance()->ReadBoolValue(&enable_policy, false, "Policy", - "EnablePolicy"); + profile_.ReadBoolValue(&enable_policy, false, "Policy", "EnablePolicy"); EXPECT_FALSE(enable_policy); - // Change config back - profile::Profile::destroy(); - EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name()); - - //get default value - bool launch_hmi; - profile::Profile::instance()->ReadBoolValue(&launch_hmi, true, "HMI", - "LaunchHMI"); - EXPECT_TRUE(launch_hmi); + bool use_last_state; + profile_.ReadBoolValue(&use_last_state, true, "MAIN", "UseLastState"); + EXPECT_TRUE(use_last_state); } TEST_F(ProfileTest, CheckReadIntValue) { // Set new config file - Profile::instance()->config_file_name("smartDeviceLink_test.ini"); - EXPECT_EQ("smartDeviceLink_test.ini", - Profile::instance()->config_file_name()); + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); int server_port = 0; - profile::Profile::instance()->ReadIntValue(&server_port, 0, "HMI", - "ServerPort"); + profile_.ReadIntValue(&server_port, 0, "HMI", "ServerPort"); EXPECT_EQ(8088, server_port); } -//TEST_F(ProfileTest, CheckIntContainer) { -// // Set new config file -// Profile::instance()->config_file_name("smartDeviceLink_test.ini"); -// EXPECT_EQ("smartDeviceLink_test.ini", -// Profile::instance()->config_file_name()); - -// bool isread = false; -// std::vector<int> diagmodes_list = -// profile::Profile::instance()->ReadIntContainer("MAIN", -// "SupportedDiagModes", -// &isread); -// EXPECT_TRUE(isread); - -// std::vector<int>::iterator diag_mode = std::find(diagmodes_list.begin(), -// diagmodes_list.end(), 0x12); - -// // This element doesn't appear in list -// EXPECT_EQ(diag_mode, diagmodes_list.end()); - -// // List includes 0x01 -// diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), 0x01); -// EXPECT_EQ(diag_mode, diagmodes_list.begin()); - -// // List includes 0x03 -// std::vector<int>::iterator element_mode = diagmodes_list.begin(); -// element_mode++; -// element_mode++; - -// diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), 0x03); -// EXPECT_EQ(diag_mode, element_mode); -//} - -//TEST_F(ProfileTest, CheckVectorContainer) { -// Profile::instance()->config_file_name("smartDeviceLink_test.ini"); -// EXPECT_EQ("smartDeviceLink_test.ini", -// Profile::instance()->config_file_name()); - -// // Get diag_modes after updating -// const std::vector<uint32_t> &diag_modes = profile::Profile::instance() -// ->supported_diag_modes(); - -// bool isread = false; -// std::vector<int> diagmodes_list = -// profile::Profile::instance()->ReadIntContainer("MAIN", -// "SupportedDiagModes", -// &isread); -// EXPECT_TRUE(isread); -// // Compare with result of ReadIntContainer -// ASSERT_EQ(diag_modes.size(), diagmodes_list.size()); -// bool isEqual = true; -// std::vector<int>::iterator iter = diagmodes_list.begin(); - -// for (std::vector<uint32_t>::const_iterator it = diag_modes.begin(); -// it != diag_modes.end(); it++) { - -// if ((uint32_t)(*iter) != (*it)) { -// isEqual = false; -// break; -// } -// iter++; -// } -// EXPECT_TRUE(isEqual); -//} - -//TEST_F(ProfileTest, CheckStringContainer) { -// // Set new config file -// Profile::instance()->config_file_name("smartDeviceLink_test.ini"); -// EXPECT_EQ("smartDeviceLink_test.ini", -// Profile::instance()->config_file_name()); - -// bool isread = false; -// std::vector < std::string > diagmodes_list = profile::Profile::instance() -// ->ReadStringContainer("MAIN", "SupportedDiagModes", &isread); -// EXPECT_TRUE(isread); - -// std::vector<std::string>::iterator diag_mode = -// std::find(diagmodes_list.begin(), diagmodes_list.end(), "0x12"); - -// // This element doesn't appear in list -// EXPECT_EQ(diag_mode, diagmodes_list.end()); - -// // List includes 0x01 -// diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), "0x01"); -// EXPECT_EQ(diag_mode, diagmodes_list.begin()); - -// // List includes 0x03 -// std::vector<std::string>::iterator element_mode = diagmodes_list.begin(); -// element_mode++; -// element_mode++; -// diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), " 0x03"); -// EXPECT_EQ(diag_mode, element_mode); -//} - -//#ifdef ENABLE_SECURITY -//TEST_F(ProfileTest, CheckIntContainerInSecurityData) { -// // Set new config file -// Profile::instance()->config_file_name("smartDeviceLink_test.ini"); -// EXPECT_EQ("smartDeviceLink_test.ini", -// Profile::instance()->config_file_name()); - -// std::vector<int> force_unprotected_list = -// profile::Profile::instance()->ReadIntContainer( -// "Security Manager", "ForceUnprotectedService", NULL); - -// std::vector<int> force_protected_list = -// profile::Profile::instance()->ReadIntContainer( -// "Security Manager", "ForceProtectedService", NULL); - -// std::vector<int>::iterator res_unprotect = std::find(force_unprotected_list.begin(), force_unprotected_list.end(), 0x07); -// std::vector<int>::iterator res_protect = std::find(force_protected_list.begin(), force_protected_list.end(), 0x07); -// // This element doesn't appear in both lists -// EXPECT_EQ(res_unprotect, force_unprotected_list.end() ); -// EXPECT_EQ(res_protect, force_protected_list.end() ); - -// // Both lists include 0 -// res_unprotect = std::find(force_unprotected_list.begin(), force_unprotected_list.end(), 0); -// res_protect = std::find(force_protected_list.begin(), force_protected_list.end(), 0); -// EXPECT_EQ(res_unprotect, force_unprotected_list.begin() ); -// EXPECT_EQ(res_protect, force_protected_list.begin() ); -//} -//#endif - -} // namespace profile -} // namespace components -} // namespace test +TEST_F(ProfileTest, CheckIntContainer) { + // Set new config file + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); + + bool isread = false; + std::vector<int> diagmodes_list = + profile_.ReadIntContainer("MAIN", "SupportedDiagModes", &isread); + EXPECT_TRUE(isread); + + std::vector<int>::iterator diag_mode = + std::find(diagmodes_list.begin(), diagmodes_list.end(), 0x12); + + // This element doesn't appear in list + EXPECT_EQ(diag_mode, diagmodes_list.end()); + + // List includes 0x01 + diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), 0x01); + EXPECT_EQ(diag_mode, diagmodes_list.begin()); + + // List includes 0x03 + std::vector<int>::iterator element_mode = diagmodes_list.begin(); + element_mode++; + element_mode++; + + diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), 0x03); + EXPECT_EQ(diag_mode, element_mode); +} + +TEST_F(ProfileTest, CheckVectorContainer) { + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); + + // Get diag_modes after updating + const std::vector<uint32_t>& diag_modes = profile_.supported_diag_modes(); + + bool isread = false; + std::vector<int> diagmodes_list = + profile_.ReadIntContainer("MAIN", "SupportedDiagModes", &isread); + EXPECT_TRUE(isread); + // Compare with result of ReadIntContainer + ASSERT_EQ(diag_modes.size(), diagmodes_list.size()); + bool isEqual = true; + std::vector<int>::iterator iter = diagmodes_list.begin(); + + for (std::vector<uint32_t>::const_iterator it = diag_modes.begin(); + it != diag_modes.end(); + it++) { + if ((uint32_t)(*iter) != (*it)) { + isEqual = false; + break; + } + iter++; + } + EXPECT_TRUE(isEqual); +} + +TEST_F(ProfileTest, CheckStringContainer) { + // Set new config file + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); + + bool isread = false; + std::vector<std::string> diagmodes_list = + profile_.ReadStringContainer("MAIN", "SupportedDiagModes", &isread); + EXPECT_TRUE(isread); + + std::vector<std::string>::iterator diag_mode = + std::find(diagmodes_list.begin(), diagmodes_list.end(), "0x12"); + + // This element doesn't appear in list + EXPECT_EQ(diag_mode, diagmodes_list.end()); + + // List includes 0x01 + diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), "0x01"); + EXPECT_EQ(diag_mode, diagmodes_list.begin()); + + // List includes 0x03 + std::vector<std::string>::iterator element_mode = diagmodes_list.begin(); + element_mode++; + element_mode++; + diag_mode = std::find(diagmodes_list.begin(), diagmodes_list.end(), " 0x03"); + EXPECT_EQ(diag_mode, element_mode); +} + +#ifdef ENABLE_SECURITY +TEST_F(ProfileTest, CheckIntContainerInSecurityData) { + // Set new config file + profile_.config_file_name("smartDeviceLink_test.ini"); + EXPECT_EQ("smartDeviceLink_test.ini", profile_.config_file_name()); + + std::vector<int> force_unprotected_list = profile_.ReadIntContainer( + "Security Manager", "ForceUnprotectedService", NULL); + + std::vector<int> force_protected_list = profile_.ReadIntContainer( + "Security Manager", "ForceProtectedService", NULL); + + std::vector<int>::iterator res_unprotect = std::find( + force_unprotected_list.begin(), force_unprotected_list.end(), 0x07); + std::vector<int>::iterator res_protect = + std::find(force_protected_list.begin(), force_protected_list.end(), 0x07); + // This element doesn't appear in both lists + EXPECT_EQ(res_unprotect, force_unprotected_list.end()); + EXPECT_EQ(res_protect, force_protected_list.end()); + + // Both lists include 0 + res_unprotect = std::find( + force_unprotected_list.begin(), force_unprotected_list.end(), 0); + res_protect = + std::find(force_protected_list.begin(), force_protected_list.end(), 0); + EXPECT_EQ(res_unprotect, force_unprotected_list.begin()); + EXPECT_EQ(res_protect, force_protected_list.begin()); +} +#endif + +} // namespace profile +} // namespace components +} // namespace test |