summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kutsan <AKutsan@luxoft.com>2015-04-16 12:41:18 +0300
committerAlexander Kutsan <AKutsan@luxoft.com>2015-04-22 09:42:19 +0300
commitd0f46699556995ecfdf660492e71967d0e8026e4 (patch)
treee5f14b3fc48d94c761cbff6333b0477d10813a42
parentcfa6b28f46024f3dc447be38f22783bc0e07a6fe (diff)
downloadsdl_core-d0f46699556995ecfdf660492e71967d0e8026e4.tar.gz
APPLINK-11859 move HMI link to config file, install web HMI to bin folder
-rw-r--r--src/appMain/CMakeLists.txt7
-rw-r--r--src/appMain/main.cc41
-rw-r--r--src/appMain/smartDeviceLink.ini1
-rw-r--r--src/components/config_profile/include/config_profile/profile.h10
-rw-r--r--src/components/config_profile/src/profile.cc163
-rw-r--r--src/components/policy/doc/readme.txt5
6 files changed, 115 insertions, 112 deletions
diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt
index 81aac61e0b..560cf46b7a 100644
--- a/src/appMain/CMakeLists.txt
+++ b/src/appMain/CMakeLists.txt
@@ -188,10 +188,6 @@ if (${QT_HMI})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/start_hmi.sh
"#!/bin/sh\n${start_command} ${command_arguments}\n")
-elseif (${WEB_HMI})
- file(COPY ${CMAKE_HOME_DIRECTORY}/src/components/HMI/ DESTINATION ${CMAKE_BINARY_DIR}/src/components/HMI/)
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/hmi_link
- "${CMAKE_BINARY_DIR}/src/components/HMI/index.html")
endif ()
# Install rules
@@ -202,9 +198,10 @@ install(
${CMAKE_SOURCE_DIR}/mycert.pem ${CMAKE_SOURCE_DIR}/mykey.pem
DESTINATION bin
)
+
if (${WEB_HMI})
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hmi_link DESTINATION bin)
+ install( DIRECTORY ${CMAKE_HOME_DIRECTORY}/src/components/HMI/ DESTINATION bin/HMI)
endif ()
elseif (${QT_HMI})
if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
diff --git a/src/appMain/main.cc b/src/appMain/main.cc
index 27e0eef2a3..01b1a792cd 100644
--- a/src/appMain/main.cc
+++ b/src/appMain/main.cc
@@ -82,33 +82,12 @@ const std::string kApplicationVersion = "Develop";
* @return true if success otherwise false.
*/
bool InitHmi() {
-
-struct stat sb;
-if (stat("hmi_link", &sb) == -1) {
- LOG4CXX_FATAL(logger_, "File with HMI link doesn't exist!");
- return false;
-}
-
-std::ifstream file_str;
-file_str.open("hmi_link");
-
-if (!file_str.is_open()) {
- LOG4CXX_FATAL(logger_, "File with HMI link was not opened!");
- return false;
-}
-
-std::string hmi_link;
-std::getline(file_str, hmi_link);
-
-
-LOG4CXX_INFO(logger_,
- "Input string:" << hmi_link << " length = " << hmi_link.size());
-file_str.close();
-
-if (stat(hmi_link.c_str(), &sb) == -1) {
- LOG4CXX_FATAL(logger_, "HMI index.html doesn't exist!");
- return false;
-}
+ std::string hmi_link = profile::Profile::instance()->link_to_web_hmi();
+ struct stat sb;
+ if (stat(hmi_link.c_str(), &sb) == -1) {
+ LOG4CXX_FATAL(logger_, "HMI index.html doesn't exist!");
+ return false;
+ }
return utils::System(kBrowser, kBrowserName).Add(kBrowserParams).Add(hmi_link)
.Execute();
}
@@ -206,12 +185,10 @@ int32_t main(int32_t argc, char** argv) {
#ifndef NO_HMI
if (!InitHmi()) {
- LOG4CXX_FATAL(logger_, "Failed to init HMI");
- main_namespace::LifeCycle::instance()->StopComponents();
- DEINIT_LOGGER();
- exit(EXIT_FAILURE);
+ LOG4CXX_INFO(logger_, "InitHmi successful");
+ } else {
+ LOG4CXX_WARN(logger_, "Failed to init HMI");
}
- LOG4CXX_INFO(logger_, "InitHmi successful");
#endif // #ifndef NO_HMI
}
}
diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini
index 0fa405e95e..eef038e09c 100644
--- a/src/appMain/smartDeviceLink.ini
+++ b/src/appMain/smartDeviceLink.ini
@@ -15,6 +15,7 @@
[HMI]
LaunchHMI = true
+LinkToWebHMI = HMI/index.html
ServerAddress = 127.0.0.1
ServerPort = 8087
VideoStreamingPort = 5050
diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h
index 8e5c3ffe8a..e81bda6fb9 100644
--- a/src/components/config_profile/include/config_profile/profile.h
+++ b/src/components/config_profile/include/config_profile/profile.h
@@ -61,7 +61,12 @@ class Profile : public utils::Singleton<Profile> {
* @brief Returns true if HMI should be started, otherwise false
*/
bool launch_hmi() const;
-
+#ifdef WEB_HMI
+ /**
+ * @brief Returns link to web hmi
+ */
+ std::string link_to_web_hmi() const;
+#endif // WEB_HMI
/**
* @brief Returns application configuration path
*/
@@ -601,6 +606,9 @@ class Profile : public utils::Singleton<Profile> {
private:
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_;
diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc
index 3454580be4..449c94b9a3 100644
--- a/src/components/config_profile/src/profile.cc
+++ b/src/components/config_profile/src/profile.cc
@@ -88,6 +88,9 @@ const char* kAppIconsFolderKey = "AppIconsFolder";
const char* kAppIconsFolderMaxSizeKey = "AppIconsFolderMaxSize";
const char* kAppIconsAmountToRemoveKey = "AppIconsAmountToRemove";
const char* kLaunchHMIKey = "LaunchHMI";
+#ifdef WEB_HMI
+const char* kLinkToWebHMI = "LinkToWebHMI";
+#endif // WEB_HMI
const char* kStartStreamRetry = "StartStreamRetry";
const char* kEnableRedecodingKey = "EnableRedecoding";
const char* kVideoStreamConsumerKey = "VideoStreamConsumer";
@@ -159,6 +162,9 @@ const char* kMalformedFrequencyCount = "MalformedFrequencyCount";
const char* kMalformedFrequencyTime = "MalformedFrequencyTime";
const char* kHashStringSizeKey = "HashStringSize";
+#ifdef WEB_HMI
+const char* kDefaultLinkToWebHMI = "HMI/index.html";
+#endif // WEB_HMI
const char* kDefaultPoliciesSnapshotFileName = "sdl_snapshot.json";
const char* kDefaultHmiCapabilitiesFileName = "hmi_capabilities.json";
const char* kDefaultPreloadedPTFileName = "sdl_preloaded_pt.json";
@@ -205,9 +211,9 @@ 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;
@@ -231,51 +237,54 @@ namespace profile {
CREATE_LOGGERPTR_GLOBAL(logger_, "Profile")
Profile::Profile()
- : launch_hmi_(true),
- 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),
+ : 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),
mme_db_name_(kDefaultMmeDatabaseName),
event_mq_name_(kDefaultEventMQ),
ack_mq_name_(kDefaultAckMQ),
@@ -289,7 +298,7 @@ Profile::Profile()
iap2_system_config_(kDefaultIAP2SystemConfig),
iap2_hub_connect_attempts_(kDefaultIAP2HubConnectAttempts),
iap_hub_connection_wait_timeout_(kDefaultIAPHubConnectionWaitTimeout),
- tts_global_properties_timeout_(kDefaultTTSGlobalPropertiesTimeout),
+ tts_global_properties_timeout_(kDefaultTTSGlobalPropertiesTimeout),
attempts_to_open_policy_db_(kDefaultAttemptsToOpenPolicyDB),
open_attempt_timeout_ms_(kDefaultAttemptsToOpenPolicyDB),
hash_string_size_(kDefaultHashStringSize) {
@@ -313,6 +322,12 @@ bool Profile::launch_hmi() const {
return launch_hmi_;
}
+#ifdef WEB_HMI
+std::string Profile::link_to_web_hmi() const {
+ return link_to_web_hmi_;
+}
+#endif // WEB_HMI
+
const std::string& Profile::app_config_folder() const {
return app_config_folder_;
}
@@ -401,7 +416,6 @@ const uint16_t& Profile::time_testing_port() const {
return time_testing_port_;
}
-
const uint64_t& Profile::thread_min_stack_size() const {
return min_tread_stack_size_;
}
@@ -543,23 +557,23 @@ uint32_t Profile::application_list_update_timeout() const {
return application_list_update_timeout_;
}
-const std::pair<uint32_t, int32_t>& Profile::read_did_frequency() const {
+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_;
}
-const std::pair<uint32_t, int32_t>& Profile::start_stream_retry_amount() const {
+const std::pair<uint32_t, int32_t>& Profile::start_stream_retry_amount() const {
return start_stream_retry_amount_;
}
-uint32_t Profile::thread_pool_size() const {
+uint32_t Profile::thread_pool_size() const {
return max_thread_pool_size_;
}
-uint32_t Profile::default_hub_protocol_index() const{
+uint32_t Profile::default_hub_protocol_index() const {
return default_hub_protocol_index_;
}
@@ -608,7 +622,7 @@ size_t Profile::message_frequency_count() const {
size_t Profile::message_frequency_time() const {
size_t message_frequency_time = 0;
ReadUIntValue(&message_frequency_time, kDefaultFrequencyTime,
- kProtocolHandlerSection,kFrequencyTime );
+ kProtocolHandlerSection, kFrequencyTime);
return message_frequency_time;
}
@@ -669,7 +683,14 @@ 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);
+ LOG_UPDATED_BOOL_VALUE(link_to_web_hmi_, kLinkToWebHMI, kHmiSection);
+#endif // WEB_HMI
// Application config folder
ReadStringValue(&app_config_folder_,
@@ -846,7 +867,7 @@ void Profile::UpdateValues() {
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_;
@@ -855,7 +876,7 @@ void Profile::UpdateValues() {
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_;
@@ -1011,7 +1032,7 @@ void Profile::UpdateValues() {
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_;
+ const std::string prompt_item = std::string(str) + tts_delimiter_;
help_prompt_.push_back(prompt_item);
LOG_UPDATED_VALUE(prompt_item, kHelpPromptKey,
kGlobalPropertiesSection);
@@ -1034,7 +1055,7 @@ void Profile::UpdateValues() {
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_;
+ const std::string prompt_item = std::string(str) + tts_delimiter_;
time_out_promt_.push_back(prompt_item);
LOG_UPDATED_VALUE(prompt_item, kTimeoutPromptKey,
kGlobalPropertiesSection);
@@ -1347,17 +1368,17 @@ void Profile::UpdateValues() {
LOG_UPDATED_VALUE(iap_hub_connection_wait_timeout_,
kIAPHubConnectionWaitTimeoutKey, kIAPSection);
-
+
ReadUIntValue(&default_hub_protocol_index_, kDefaultHubProtocolIndex, kIAPSection, kDefaultHubProtocolIndexKey);
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_,
+ LOG_UPDATED_VALUE(hash_string_size_,
kHashStringSizeKey,
kApplicationManagerSection);
}
@@ -1371,7 +1392,7 @@ bool Profile::ReadValue(bool* value, const char* const pSection,
*buf = '\0';
if ((0 != ini_read_value(config_file_name_.c_str(), pSection, pKey, buf))
&& ('\0' != *buf)) {
- const int32_t tmpVal = atoi(buf);
+ const int32_t tmpVal = atoi(buf);
if (0 == tmpVal) {
*value = false;
} else {
@@ -1423,7 +1444,7 @@ bool Profile::ReadIntValue(int32_t* value, const int32_t default_value,
}
bool Profile::ReadUintIntPairValue(std::pair<uint32_t, int32_t>* value,
- const std::pair<uint32_t, uint32_t>& default_value,
+ const std::pair<uint32_t, uint32_t>& default_value,
const char *const pSection,
const char *const pKey) const {
std::string string_value;
@@ -1456,7 +1477,7 @@ 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 {
+ bool *out_result) const {
const std::list<std::string> string_list =
ReadStringContainer(pSection, pKey, out_result);
std::list<int> value_list;
@@ -1468,12 +1489,12 @@ std::list<int> Profile::ReadIntContainer(
std::list<std::string> Profile::ReadStringContainer(
const char * const pSection, const char * const pKey,
- bool *out_result) const {
+ 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::list < std::string > value_container;
if (result) {
std::istringstream iss(string);
std::string temp_str;
@@ -1514,7 +1535,7 @@ 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;
}
@@ -1569,4 +1590,4 @@ void Profile::MakeAbsolutePath(std::string& path) {
path = file_system::CurrentWorkingDirectory() + "/" + path;
}
-} // namespace profile
+}// namespace profile
diff --git a/src/components/policy/doc/readme.txt b/src/components/policy/doc/readme.txt
index 86de7da08a..f80aed0ffd 100644
--- a/src/components/policy/doc/readme.txt
+++ b/src/components/policy/doc/readme.txt
@@ -19,10 +19,9 @@
For example Google Chromium. Install it using:
sudo apt-get install chromium-browser
In current implementation Chromium is required for autostart HMI feature.
- For HMI autostart please create in the executable folder file named hmi_link.
- This file should contain one string with full path to HMI index.html file.
+ For HMI autostart please set path to hmi in config file
For example:
- /home/user/projects/smart_device_link/src/components/HMI/index.html
+ LinkToWebHMI = ${path_to_HMI_repository}/index.html
* Running application
====================