summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2016-02-29 10:22:30 +0200
committerKozoriz <kozorizandriy@gmail.com>2016-03-04 10:11:18 +0200
commit7df5429476716d9fdba7da838e14ab92d0ce1126 (patch)
tree47418fc3c01092332d0cbf03c0618af1e0b1e4ad /src/components
parentccf13c773bca0b98c7dcdcf21f99e5d1766ade2d (diff)
downloadsdl_core-7df5429476716d9fdba7da838e14ab92d0ce1126.tar.gz
ConfigProfie correctives
Correctives in ConfigProfile after removing ConnectionHandler, ProticolHandler, HMIMessageHandler Related to : APPLINK-21440
Diffstat (limited to 'src/components')
-rw-r--r--src/components/config_profile/include/config_profile/profile.h48
-rw-r--r--src/components/config_profile/src/profile.cc44
-rw-r--r--src/components/config_profile/test/profile_test.cc28
3 files changed, 86 insertions, 34 deletions
diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h
index 7c8f3c3958..f21faa7e2b 100644
--- a/src/components/config_profile/include/config_profile/profile.h
+++ b/src/components/config_profile/include/config_profile/profile.h
@@ -39,13 +39,20 @@
#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"
+
namespace profile {
/**
* The Profile class
*/
-class Profile : public utils::Singleton<Profile> {
+class Profile :public protocol_handler::ProtocolHandlerSettings,
+ public connection_handler::ConnectionHandlerSettings,
+ public hmi_message_handler::HMIMessageHandlerSettings,
+ public utils::Singleton<Profile> {
public:
// Methods section
@@ -91,7 +98,7 @@ class Profile : public utils::Singleton<Profile> {
/**
* @brief Returns true, if SDL 4.0 is enabled
*/
- bool enable_protocol_4() const;
+ bool enable_protocol_4() const OVERRIDE;
/**
* @brief Returns application icons folder path
@@ -306,11 +313,6 @@ class Profile : public utils::Singleton<Profile> {
const std::string& app_info_storage() const;
/*
- * @brief Heartbeat timeout before closing connection
- */
- uint32_t heart_beat_timeout() const;
-
- /*
* @brief Path to preloaded policy file
*/
const std::string& preloaded_pt_file() const;
@@ -458,7 +460,7 @@ class Profile : public utils::Singleton<Profile> {
* @return container of values or empty continer
* if could not read the value out of the profile
*/
- std::list<std::string> ReadStringContainer(
+ std::vector<std::string> ReadStringContainer(
const char * const pSection,
const char * const pKey,
bool* out_result) const;
@@ -474,7 +476,7 @@ class Profile : public utils::Singleton<Profile> {
* @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,
+ std::vector<int> ReadIntContainer(const char * const pSection,
const char * const pKey,
bool* out_result) const;
@@ -533,19 +535,30 @@ class Profile : public utils::Singleton<Profile> {
/*
* ProtocolHandler section
*/
- size_t maximum_payload_size() const;
+ 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 message_frequency_count() const;
+ size_t malformed_frequency_time() const OVERRIDE;
- size_t message_frequency_time() const;
+ uint32_t multiframe_waiting_timeout() const OVERRIDE;
- bool malformed_message_filtering() const;
+ uint32_t heart_beat_timeout() const OVERRIDE;
- size_t malformed_frequency_count() const;
+ uint16_t max_supported_protocol_version() const OVERRIDE;
- size_t malformed_frequency_time() const;
+ #ifdef ENABLE_SECURITY
+ const std::vector<int>& force_protected_service() const OVERRIDE;
- uint32_t multiframe_waiting_timeout() const;
+ const std::vector<int>& force_unprotected_service() const OVERRIDE;
+ #endif // ENABLE_SECURITY
+ // ProtocolHandler section end
uint16_t attempts_to_open_policy_db() const;
@@ -731,6 +744,7 @@ private:
uint32_t list_files_in_none_;
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_;
@@ -759,6 +773,8 @@ private:
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
/*
diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc
index e75752e135..a052bb2282 100644
--- a/src/components/config_profile/src/profile.cc
+++ b/src/components/config_profile/src/profile.cc
@@ -66,6 +66,8 @@ 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";
@@ -145,6 +147,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";
@@ -234,6 +237,7 @@ const uint32_t kDefaultBeforeUpdateHours = 24;
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;
@@ -328,6 +332,7 @@ Profile::Profile()
list_files_in_none_(kDefaultListFilesRequestInNone),
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_(
@@ -566,6 +571,10 @@ 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_;
}
@@ -776,6 +785,13 @@ 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 {
@@ -823,6 +839,12 @@ void Profile::UpdateValues() {
#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);
@@ -1437,6 +1459,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_,
@@ -1638,26 +1672,26 @@ int32_t hex_to_int(const std::string& value) {
}
}
-std::list<int> Profile::ReadIntContainer(
+std::vector<int> Profile::ReadIntContainer(
const char * const pSection, const char * const pKey,
bool *out_result) const {
- const std::list<std::string> string_list =
+ 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);
return value_list;
}
-std::list<std::string> Profile::ReadStringContainer(
+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;
diff --git a/src/components/config_profile/test/profile_test.cc b/src/components/config_profile/test/profile_test.cc
index 32d2a369b4..1bcd28b83e 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"
@@ -670,13 +672,13 @@ TEST_F(ProfileTest, CheckIntContainer) {
Profile::instance()->config_file_name());
bool isread = false;
- std::list<int> diagmodes_list =
+ std::vector<int> diagmodes_list =
profile::Profile::instance()->ReadIntContainer("MAIN",
"SupportedDiagModes",
&isread);
EXPECT_TRUE(isread);
- std::list<int>::iterator diag_mode = std::find(diagmodes_list.begin(),
+ std::vector<int>::iterator diag_mode = std::find(diagmodes_list.begin(),
diagmodes_list.end(), 0x12);
// This element doesn't appear in list
@@ -687,7 +689,7 @@ TEST_F(ProfileTest, CheckIntContainer) {
EXPECT_EQ(diag_mode, diagmodes_list.begin());
// List includes 0x03
- std::list<int>::iterator element_mode = diagmodes_list.begin();
+ std::vector<int>::iterator element_mode = diagmodes_list.begin();
element_mode++;
element_mode++;
@@ -705,7 +707,7 @@ TEST_F(ProfileTest, CheckVectorContainer) {
->supported_diag_modes();
bool isread = false;
- std::list<int> diagmodes_list =
+ std::vector<int> diagmodes_list =
profile::Profile::instance()->ReadIntContainer("MAIN",
"SupportedDiagModes",
&isread);
@@ -713,7 +715,7 @@ TEST_F(ProfileTest, CheckVectorContainer) {
// Compare with result of ReadIntContainer
ASSERT_EQ(diag_modes.size(), diagmodes_list.size());
bool isEqual = true;
- std::list<int>::iterator iter = diagmodes_list.begin();
+ std::vector<int>::iterator iter = diagmodes_list.begin();
for (std::vector<uint32_t>::const_iterator it = diag_modes.begin();
it != diag_modes.end(); it++) {
@@ -734,11 +736,11 @@ TEST_F(ProfileTest, CheckStringContainer) {
Profile::instance()->config_file_name());
bool isread = false;
- std::list < std::string > diagmodes_list = profile::Profile::instance()
+ std::vector < std::string > diagmodes_list = profile::Profile::instance()
->ReadStringContainer("MAIN", "SupportedDiagModes", &isread);
EXPECT_TRUE(isread);
- std::list<std::string>::iterator diag_mode =
+ std::vector<std::string>::iterator diag_mode =
std::find(diagmodes_list.begin(), diagmodes_list.end(), "0x12");
// This element doesn't appear in list
@@ -749,7 +751,7 @@ TEST_F(ProfileTest, CheckStringContainer) {
EXPECT_EQ(diag_mode, diagmodes_list.begin());
// List includes 0x03
- std::list<std::string>::iterator element_mode = diagmodes_list.begin();
+ 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");
@@ -763,16 +765,16 @@ TEST_F(ProfileTest, CheckIntContainerInSecurityData) {
EXPECT_EQ("smartDeviceLink_test.ini",
Profile::instance()->config_file_name());
- std::list<int> force_unprotected_list =
+ std::vector<int> force_unprotected_list =
profile::Profile::instance()->ReadIntContainer(
"Security Manager", "ForceUnprotectedService", NULL);
- std::list<int> force_protected_list =
+ std::vector<int> force_protected_list =
profile::Profile::instance()->ReadIntContainer(
"Security Manager", "ForceProtectedService", NULL);
- std::list<int>::iterator res_unprotect = std::find(force_unprotected_list.begin(), force_unprotected_list.end(), 0x07);
- std::list<int>::iterator res_protect = std::find(force_protected_list.begin(), force_protected_list.end(), 0x07);
+ 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() );