../components/smart_objects/include/
../components/media_manager/include/
../components/policies/include/
+ ../components/resumption/include/
../thirdPartyLibs/MessageBroker/include
../thirdPartyLibs/encryption/include
${CMAKE_SOURCE_DIR}/src/components/
#include "./life_cycle.h"
#include "utils/signals.h"
#include "config_profile/profile.h"
+#include "resumption/last_state.h"
using threads::Thread;
#endif // QT_HMI
void LifeCycle::StopComponents() {
+ LOG4CXX_INFO(logger_, "Destroying Last State");
+ resumption::LastState::destroy();
+
hmi_handler_->set_message_observer(NULL);
connection_handler_->set_connection_handler_observer(NULL);
protocol_handler_->RemoveProtocolObserver(app_manager_);
PendingRequestsAmount = 1000
HeartBeatTimeout = 0
SupportedDiagModes = 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x09, 0x0A, 0x18, 0x19, 0x22, 0x3E
+SystemFilesPath = /tmp/fs/mp/images/ivsu_cache
+UseLastState = true
[MEDIA MANAGER]
EnableRedecoding = false
(void) ReadIntValue(&heart_beat_timeout_, kDefaultHeartBeatTimeout,
kMainSection, "HeartBeatTimeout");
+
+ *value = '\0';
+ if ((0 != ini_read_value(config_file_name_.c_str(),
+ "MAIN", "UseLastState", value))
+ && ('\0' != *value)) {
+ if (0 == strcmp("true", value)) {
+ use_last_state_ = true;
+ }
+ LOG4CXX_INFO(logger_, "Set UseLastState to " << value);
+ }
}
bool Profile::ReadValue(bool* value, const char* const pSection,
-/**
- * Copyright (c) 2013, Ford Motor Company
+/*
+ * Copyright (c) 2014, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
Json::Value dictionary;
- private:
-
- /**
- * @brief File to save Dictionary
- */
+ private:
+/**
+ * @brief File to save Dictionary
+ */
static const std::string filename;
-
- /**
- * @brief Saving dictionary to filesystem as Json
- */
+/**
+ * @brief Saving dictionary to filesystem
+ */
void SaveToFileSystem();
-
- /**
- * @brief Load dictionary from filesystem as Json
- */
+/**
+ * @brief Load dictionary from filesystem
+ */
void LoadFromFileSystem();
-
- /**
+/**
* @brief Private default constructor
*/
LastState();
+/**
+ * @brief Private destructor
+ */
~LastState();
namespace resumption {
+const std::string LastState::filename = "LastState.dat";
+
void LastState::SaveToFileSystem() {
const std::string& str = dictionary.toStyledString();
const std::vector<uint8_t> char_vector_pdata(
SaveToFileSystem();
}
-const std::string LastState::filename = "TM.dat";
}
*/
virtual bool ToBeAutoConnected(DeviceSptr device) const;
- private:
/**
* @brief Find connection that has state - ESTABLISHED.
*
* @return ConnectionSptr smart pointer to the connection.
*/
ConnectionSptr FindEstablishedConnection(const DeviceUID& device_handle,
- const ApplicationHandle& app_handle);
+ const ApplicationHandle& app_handle) const;
+
+ private:
/**
* @brief Connect to all applications discovered on device
* @param device Pointer to device
ApplicationList app_ids = bluetooth_device->GetApplicationList();
for (ApplicationList::const_iterator j = app_ids.begin(); j != app_ids.end(); ++j) {
ApplicationHandle app_handle = *j;
- uint8_t rfcomm_channel;
- bluetooth_device->GetRfcommChannel(app_handle, &rfcomm_channel);
- Json::Value application_dictionary;
- char rfcomm_channel_record[4];
- sprintf(rfcomm_channel_record, "%ud", rfcomm_channel);
- application_dictionary["rfcomm_channel"] = std::string(rfcomm_channel_record);
- applications_dictionary.append(application_dictionary);
+ if (FindEstablishedConnection(bluetooth_device->name(), app_handle)) {
+ uint8_t rfcomm_channel;
+ bluetooth_device->GetRfcommChannel(app_handle, &rfcomm_channel);
+ Json::Value application_dictionary;
+ char rfcomm_channel_record[4];
+ sprintf(rfcomm_channel_record, "%u", rfcomm_channel);
+ application_dictionary["rfcomm_channel"] = std::string(rfcomm_channel_record);
+ applications_dictionary.append(application_dictionary);
+ }
+ }
+ if (!applications_dictionary.empty()) {
+ device_dictionary["applications"] = applications_dictionary;
+ devices_dictionary.append(device_dictionary);
}
- device_dictionary["applications"] = applications_dictionary;
- devices_dictionary.append(device_dictionary);
}
bluetooth_adapter_dictionary["devices"] = devices_dictionary;
- resumption::LastState::instance()->dictionary["BluetoothAdapter"] =
+ resumption::LastState::instance()->dictionary["TransportManager"]["BluetoothAdapter"] =
bluetooth_adapter_dictionary;
LOG4CXX_TRACE_EXIT(logger_);
}
LOG4CXX_TRACE_ENTER(logger_);
bool errors_occured = false;
const Json::Value bluetooth_adapter_dictionary =
- resumption::LastState::instance()->dictionary["BluetoothAdapter"];
+ resumption::LastState::instance()->dictionary["TransportManager"]["BluetoothAdapter"];
const Json::Value devices_dictionary = bluetooth_adapter_dictionary["devices"];
for (Json::Value::const_iterator i = devices_dictionary.begin();
i != devices_dictionary.end(); ++i) {
ApplicationList app_ids = tcp_device->GetApplicationList();
for (ApplicationList::const_iterator j = app_ids.begin(); j != app_ids.end(); ++j) {
ApplicationHandle app_handle = *j;
- int port = tcp_device->GetApplicationPort(app_handle);
- if (port != -1) { // don't want to store incoming applications
- Json::Value application_dictionary;
- char port_record[12];
- sprintf(port_record, "%d", port);
- application_dictionary["port"] = std::string(port_record);
- applications_dictionary.append(application_dictionary);
+ if (FindEstablishedConnection(tcp_device->name(), app_handle)) {
+ int port = tcp_device->GetApplicationPort(app_handle);
+ if (port != -1) { // don't want to store incoming applications
+ Json::Value application_dictionary;
+ char port_record[12];
+ sprintf(port_record, "%d", port);
+ application_dictionary["port"] = std::string(port_record);
+ applications_dictionary.append(application_dictionary);
+ }
}
}
- device_dictionary["applications"] = applications_dictionary;
- devices_dictionary.append(device_dictionary);
+ if (!applications_dictionary.empty()) {
+ device_dictionary["applications"] = applications_dictionary;
+ devices_dictionary.append(device_dictionary);
+ }
}
tcp_adapter_dictionary["devices"] = devices_dictionary;
- resumption::LastState::instance()->dictionary["TcpAdapter"] =
+ resumption::LastState::instance()->dictionary["TransportManager"]["TcpAdapter"] =
tcp_adapter_dictionary;
LOG4CXX_TRACE_EXIT(logger_);
}
LOG4CXX_TRACE_ENTER(logger_);
bool errors_occured = false;
const Json::Value tcp_adapter_dictionary =
- resumption::LastState::instance()->dictionary["TcpAdapter"];
+ resumption::LastState::instance()->dictionary["TransportManager"]["TcpAdapter"];
const Json::Value devices_dictionary = tcp_adapter_dictionary["devices"];
for (Json::Value::const_iterator i = devices_dictionary.begin();
i != devices_dictionary.end(); ++i) {
}
pthread_mutex_unlock(&devices_mutex_);
}
+
+ Store();
}
void TransportAdapterImpl::DataReceiveDone(const DeviceUID& device_id,
for (TransportAdapterListenerList::iterator it = listeners_.begin();
it != listeners_.end(); ++it)
(*it)->OnConnectDone(this, device_id, app_handle);
+
+ Store();
}
void TransportAdapterImpl::ConnectFailed(const DeviceUID& device_id,
}
ConnectionSptr TransportAdapterImpl::FindEstablishedConnection(
- const DeviceUID& device_id, const ApplicationHandle& app_handle) {
+ const DeviceUID& device_id, const ApplicationHandle& app_handle) const {
ConnectionSptr connection;
pthread_mutex_lock(&connections_mutex_);
- ConnectionMap::iterator it =
+ ConnectionMap::const_iterator it =
connections_.find(std::make_pair(device_id, app_handle));
if (it != connections_.end()) {
- ConnectionInfo& info = it->second;
+ const ConnectionInfo& info = it->second;
if (info.state == ConnectionInfo::ESTABLISHED) connection = info.connection;
}
pthread_mutex_unlock(&connections_mutex_);