diff --git a/include/f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp b/include/f1x/openauto/autoapp/Configuration/BluetoothAdapterType.hpp similarity index 86% rename from include/f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp rename to include/f1x/openauto/autoapp/Configuration/BluetoothAdapterType.hpp index 8185411..9e9bab1 100644 --- a/include/f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp +++ b/include/f1x/openauto/autoapp/Configuration/BluetoothAdapterType.hpp @@ -18,17 +18,10 @@ #pragma once -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace configuration -{ -enum class BluetoothAdapterType -{ +namespace f1x::openauto::autoapp::configuration { + + enum class BluetoothAdapterType { NONE, LOCAL, REMOTE @@ -37,4 +30,6 @@ enum class BluetoothAdapterType } } } -} + + + diff --git a/include/f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp b/include/f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp index 68bc416..cc6fe5b 100644 --- a/include/f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp +++ b/include/f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp @@ -23,13 +23,7 @@ #pragma once -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace projection +namespace f1x::openauto::autoapp::projection { class LocalBluetoothDevice: public QObject, public IBluetoothDevice @@ -37,7 +31,7 @@ class LocalBluetoothDevice: public QObject, public IBluetoothDevice Q_OBJECT public: - LocalBluetoothDevice(); + LocalBluetoothDevice(const QString &adapterAddress = QString(), QObject *parent = nullptr); void stop() override; bool isPaired(const std::string& address) const override; @@ -68,6 +62,6 @@ private: }; } -} -} -} + + + diff --git a/include/f1x/openauto/autoapp/Service/IService.hpp b/include/f1x/openauto/autoapp/Service/IService.hpp index 9731894..e798ae1 100644 --- a/include/f1x/openauto/autoapp/Service/IService.hpp +++ b/include/f1x/openauto/autoapp/Service/IService.hpp @@ -24,32 +24,29 @@ #include #include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ -class IService -{ -public: +namespace f1x::openauto::autoapp::service { + + class IService { + public: typedef std::shared_ptr Pointer; virtual ~IService() = default; virtual void start() = 0; + virtual void stop() = 0; + virtual void pause() = 0; + virtual void resume() = 0; - virtual void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse& response) = 0; -}; -typedef std::vector ServiceList; + virtual void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) = 0; + }; + + typedef std::vector ServiceList; } -} -} -} + + + diff --git a/include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp b/include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp index 4f72cca..b872c71 100644 --- a/include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp +++ b/include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp @@ -26,60 +26,60 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace sensor { - class SensorService : - public aasdk::channel::sensorsource::ISensorSourceServiceEventHandler, - public IService, - public std::enable_shared_from_this { - public: - SensorService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger); - bool isNight = false; - bool previous = false; - bool stopPolling = false; +namespace f1x::openauto::autoapp::service::sensor { + class SensorService : + public aasdk::channel::sensorsource::ISensorSourceServiceEventHandler, + public IService, + public std::enable_shared_from_this { + public: + SensorService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger); - void start() override; - void stop() override; - void pause() override; - void resume() override; - void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; + bool isNight = false; + bool previous = false; + bool stopPolling = false; - void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override; + void start() override; - void onSensorStartRequest( - const aap_protobuf::service::sensorsource::message::SensorRequest &request) override; + void stop() override; - void onChannelError(const aasdk::error::Error &e) override; + void pause() override; - private: - using std::enable_shared_from_this::shared_from_this; + void resume() override; - void sendDrivingStatusUnrestricted(); + void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; - void sendNightData(); + void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override; - void sendGPSLocationData(); + void onSensorStartRequest( + const aap_protobuf::service::sensorsource::message::SensorRequest &request) override; - bool is_file_exist(const char *filename); + void onChannelError(const aasdk::error::Error &e) override; - void sensorPolling(); + private: + using std::enable_shared_from_this::shared_from_this; + + void sendDrivingStatusUnrestricted(); + + void sendNightData(); + + void sendGPSLocationData(); + + bool is_file_exist(const char *filename); + + void sensorPolling(); + + bool firstRun = true; + + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::sensorsource::SensorSourceService::Pointer channel_; + struct gps_data_t gpsData_; + bool gpsEnabled_ = false; + }; + +} - bool firstRun = true; - boost::asio::deadline_timer timer_; - boost::asio::io_service::strand strand_; - aasdk::channel::sensorsource::SensorSourceService::Pointer channel_; - struct gps_data_t gpsData_; - bool gpsEnabled_ = false; - }; - } - } - } - } -} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/Service.hpp b/include/f1x/openauto/autoapp/Service/Service.hpp index 7157f2b..7cd3d22 100644 --- a/include/f1x/openauto/autoapp/Service/Service.hpp +++ b/include/f1x/openauto/autoapp/Service/Service.hpp @@ -22,33 +22,26 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { +namespace f1x::openauto::autoapp::service { - class Service - : public IService { - public: - Service(boost::asio::io_service &ioService); + class Service + : public IService { + public: + Service(boost::asio::io_service &ioService); - void start() override; + void start() override; - void stop() override; + void stop() override; - void pause() override; + void pause() override; - void resume() override; + void resume() override; - void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; + void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; - private: + private: - boost::asio::io_service::strand strand_; + boost::asio::io_service::strand strand_; - }; - } - } - } - } -} \ No newline at end of file + }; +} diff --git a/include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp b/include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp index 88db0eb..df90afe 100644 --- a/include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp +++ b/include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp @@ -23,39 +23,39 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace vendorextension { - class VendorExtensionService : - public aasdk::channel::vendorextension::IVendorExtensionServiceEventHandler, - public IService, - public std::enable_shared_from_this { - public: - VendorExtensionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger); +namespace f1x::openauto::autoapp::service::vendorextension { - void start() override; - void stop() override; - void pause() override; - void resume() override; - void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; + class VendorExtensionService : + public aasdk::channel::vendorextension::IVendorExtensionServiceEventHandler, + public IService, + public std::enable_shared_from_this { + public: + VendorExtensionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger); - void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override; + void start() override; - void onChannelError(const aasdk::error::Error &e) override; + void stop() override; + + void pause() override; + + void resume() override; + + void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; + + void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override; + + void onChannelError(const aasdk::error::Error &e) override; + + + private: + using std::enable_shared_from_this::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::vendorextension::VendorExtensionService::Pointer channel_; + }; + +} - private: - using std::enable_shared_from_this::shared_from_this; - boost::asio::deadline_timer timer_; - boost::asio::io_service::strand strand_; - aasdk::channel::vendorextension::VendorExtensionService::Pointer channel_; - }; - } - } - } - } -} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp b/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp index 322732e..3b0bd5f 100644 --- a/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp +++ b/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp @@ -23,41 +23,42 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace wifiprojection { - class WifiProjectionService : - public aasdk::channel::wifiprojection::IWifiProjectionServiceEventHandler, - public IService, - public std::enable_shared_from_this { - public: - WifiProjectionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger); +namespace f1x::openauto::autoapp::service::wifiprojection { - void start() override; - void stop() override; - void pause() override; - void resume() override; - void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; + class WifiProjectionService : + public aasdk::channel::wifiprojection::IWifiProjectionServiceEventHandler, + public IService, + public std::enable_shared_from_this { + public: + WifiProjectionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger); - void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override; + void start() override; - void onChannelError(const aasdk::error::Error &e) override; + void stop() override; + + void pause() override; + + void resume() override; + + void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override; + + void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override; + + void onChannelError(const aasdk::error::Error &e) override; + + void + onWifiCredentialsRequest( + const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) override; + + private: + using std::enable_shared_from_this::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::wifiprojection::WifiProjectionService::Pointer channel_; + }; + +} - void - onWifiCredentialsRequest(const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) override; - private: - using std::enable_shared_from_this::shared_from_this; - boost::asio::deadline_timer timer_; - boost::asio::io_service::strand strand_; - aasdk::channel::wifiprojection::WifiProjectionService::Pointer channel_; - }; - } - } - } - } -} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp index 03d7dbc..bedaad4 100644 --- a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp @@ -35,13 +35,7 @@ namespace Ui class SettingsWindow; } -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace ui +namespace f1x::openauto::autoapp::ui { class SettingsWindow : public QWidget @@ -112,6 +106,6 @@ private: }; } -} -} -} + + + diff --git a/src/autoapp/App.cpp b/src/autoapp/App.cpp index dc77ae3..751c7cd 100644 --- a/src/autoapp/App.cpp +++ b/src/autoapp/App.cpp @@ -22,171 +22,145 @@ #include #include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ +namespace f1x::openauto::autoapp { -App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, service::IAndroidAutoEntityFactory& androidAutoEntityFactory, - aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator) - : ioService_(ioService) - , usbWrapper_(usbWrapper) - , tcpWrapper_(tcpWrapper) - , strand_(ioService_) - , androidAutoEntityFactory_(androidAutoEntityFactory) - , usbHub_(std::move(usbHub)) - , connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator)) - , acceptor_(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000 )) - , isStopped_(false) -{ + App::App(boost::asio::io_service &ioService, aasdk::usb::USBWrapper &usbWrapper, aasdk::tcp::ITCPWrapper &tcpWrapper, + service::IAndroidAutoEntityFactory &androidAutoEntityFactory, + aasdk::usb::IUSBHub::Pointer usbHub, + aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator) + : ioService_(ioService), usbWrapper_(usbWrapper), tcpWrapper_(tcpWrapper), strand_(ioService_), + androidAutoEntityFactory_(androidAutoEntityFactory), usbHub_(std::move(usbHub)), + connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator)), + acceptor_(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000)), isStopped_(false) { -} + } -void App::waitForUSBDevice() -{ + void App::waitForUSBDevice() { strand_.dispatch([this, self = this->shared_from_this()]() { - try - { - this->waitForDevice(); - } - catch(...) - { - OPENAUTO_LOG(error) << "[App] waitForUSBDevice() -exception caused by this->waitForDevice();"; - } - try - { - this->enumerateDevices(); - } - catch(...) - { - OPENAUTO_LOG(error) << "[App] waitForUSBDevice() exception caused by this->enumerateDevices()"; - } + try { + this->waitForDevice(); + } + catch (...) { + OPENAUTO_LOG(error) << "[App] waitForUSBDevice() -exception caused by this->waitForDevice();"; + } + try { + this->enumerateDevices(); + } + catch (...) { + OPENAUTO_LOG(error) << "[App] waitForUSBDevice() exception caused by this->enumerateDevices()"; + } }); -} + } -void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket) -{ + void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket) { strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable { - OPENAUTO_LOG(info) << "Start from socket"; - if(androidAutoEntity_ != nullptr) - { + OPENAUTO_LOG(info) << "Start from socket"; + if (androidAutoEntity_ != nullptr) { // tcpWrapper_.close(*socket); // OPENAUTO_LOG(warning) << "[App] android auto entity is still running."; // return; - try { - androidAutoEntity_->stop(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();"; - } - try { - androidAutoEntity_.reset(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();"; - } + try { + androidAutoEntity_->stop(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();"; } + try { + androidAutoEntity_.reset(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();"; + } + } - try - { + try { // usbHub_->cancel(); // connectedAccessoriesEnumerator_->cancel(); - auto tcpEndpoint(std::make_shared(tcpWrapper_, std::move(socket))); - androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(tcpEndpoint)); - androidAutoEntity_->start(*this); - } - catch(const aasdk::error::Error& error) - { - OPENAUTO_LOG(error) << "[App] TCP AndroidAutoEntity create error: " << error.what(); + auto tcpEndpoint(std::make_shared(tcpWrapper_, std::move(socket))); + androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(tcpEndpoint)); + androidAutoEntity_->start(*this); + } + catch (const aasdk::error::Error &error) { + OPENAUTO_LOG(error) << "[App] TCP AndroidAutoEntity create error: " << error.what(); - //androidAutoEntity_.reset(); - this->waitForDevice(); - } + //androidAutoEntity_.reset(); + this->waitForDevice(); + } }); -} + } -void App::stop() -{ + void App::stop() { strand_.dispatch([this, self = this->shared_from_this()]() { - isStopped_ = true; - try { - connectedAccessoriesEnumerator_->cancel(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] stop: exception caused by connectedAccessoriesEnumerator_->cancel()"; - } - try { - usbHub_->cancel(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] stop: exception caused by usbHub_->cancel();"; - } + isStopped_ = true; + try { + connectedAccessoriesEnumerator_->cancel(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] stop: exception caused by connectedAccessoriesEnumerator_->cancel()"; + } + try { + usbHub_->cancel(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] stop: exception caused by usbHub_->cancel();"; + } - if(androidAutoEntity_ != nullptr) - { - try { - androidAutoEntity_->stop(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_->stop();"; - } - try { - androidAutoEntity_.reset(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_.reset();"; - } + if (androidAutoEntity_ != nullptr) { + try { + androidAutoEntity_->stop(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_->stop();"; } + try { + androidAutoEntity_.reset(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_.reset();"; + } + } }); -} + } -void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle) -{ + void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle) { OPENAUTO_LOG(info) << "[App] Device connected."; - if(androidAutoEntity_ != nullptr) - { - OPENAUTO_LOG(warning) << "[App] android auto entity is still running."; - return; + if (androidAutoEntity_ != nullptr) { + OPENAUTO_LOG(warning) << "[App] android auto entity is still running."; + return; } - try - { - // ignore autostart if exit to csng was used - if (!disableAutostartEntity) { - OPENAUTO_LOG(info) << "[App] Start Android Auto allowed - let's go."; - connectedAccessoriesEnumerator_->cancel(); + try { + // ignore autostart if exit to csng was used + if (!disableAutostartEntity) { + OPENAUTO_LOG(info) << "[App] Start Android Auto allowed - let's go."; + connectedAccessoriesEnumerator_->cancel(); - auto aoapDevice(aasdk::usb::AOAPDevice::create(usbWrapper_, ioService_, deviceHandle)); - androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(aoapDevice)); - androidAutoEntity_->start(*this); - } else { - OPENAUTO_LOG(info) << "[App] Start Android Auto not allowed - skip."; - } + auto aoapDevice(aasdk::usb::AOAPDevice::create(usbWrapper_, ioService_, deviceHandle)); + androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(aoapDevice)); + androidAutoEntity_->start(*this); + } else { + OPENAUTO_LOG(info) << "[App] Start Android Auto not allowed - skip."; + } } - catch(const aasdk::error::Error& error) - { - OPENAUTO_LOG(error) << "[App] USB AndroidAutoEntity create error: " << error.what(); + catch (const aasdk::error::Error &error) { + OPENAUTO_LOG(error) << "[App] USB AndroidAutoEntity create error: " << error.what(); - androidAutoEntity_.reset(); - this->waitForDevice(); + androidAutoEntity_.reset(); + this->waitForDevice(); } -} + } -void App::enumerateDevices() -{ + void App::enumerateDevices() { auto promise = aasdk::usb::IConnectedAccessoriesEnumerator::Promise::defer(strand_); promise->then([this, self = this->shared_from_this()](auto result) { - OPENAUTO_LOG(info) << "[App] Devices enumeration result: " << result; - }, - [this, self = this->shared_from_this()](auto e) { - OPENAUTO_LOG(error) << "[App] Devices enumeration failed: " << e.what(); - }); + OPENAUTO_LOG(info) << "[App] Devices enumeration result: " << result; + }, + [this, self = this->shared_from_this()](auto e) { + OPENAUTO_LOG(error) << "[App] Devices enumeration failed: " << e.what(); + }); connectedAccessoriesEnumerator_->enumerate(std::move(promise)); -} + } -void App::waitForDevice() -{ + void App::waitForDevice() { OPENAUTO_LOG(info) << "[App] Waiting for device..."; auto promise = aasdk::usb::IUSBHub::Promise::defer(strand_); @@ -194,80 +168,75 @@ void App::waitForDevice() std::bind(&App::onUSBHubError, this->shared_from_this(), std::placeholders::_1)); usbHub_->start(std::move(promise)); startServerSocket(); -} + } -void App::startServerSocket() { + void App::startServerSocket() { strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "startServerSocket() - Listening for WIFI Clients on Port 5000"; - auto socket = std::make_shared(ioService_); - acceptor_.async_accept( - *socket, - std::bind(&App::handleNewClient, this, socket, std::placeholders::_1) - ); + OPENAUTO_LOG(info) << "startServerSocket() - Listening for WIFI Clients on Port 5000"; + auto socket = std::make_shared(ioService_); + acceptor_.async_accept( + *socket, + std::bind(&App::handleNewClient, this, socket, std::placeholders::_1) + ); }); -} + } -void App::handleNewClient(std::shared_ptr socket, const boost::system::error_code &err) { + void + App::handleNewClient(std::shared_ptr socket, const boost::system::error_code &err) { OPENAUTO_LOG(info) << "handleNewClient() - Handle WIFI Client Connection"; if (!err) { - start(std::move(socket)); + start(std::move(socket)); } -} + } -void App::pause() -{ + void App::pause() { strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[App] pause..."; - androidAutoEntity_->pause(); + OPENAUTO_LOG(info) << "[App] pause..."; + androidAutoEntity_->pause(); }); -} + } -void App::resume() -{ + void App::resume() { strand_.dispatch([this, self = this->shared_from_this()]() { - if(androidAutoEntity_ != nullptr) - { - OPENAUTO_LOG(info) << "[App] resume..."; - androidAutoEntity_->resume(); - } else { - OPENAUTO_LOG(info) << "[App] Ignore resume -> no androidAutoEntity_ ..."; - } + if (androidAutoEntity_ != nullptr) { + OPENAUTO_LOG(info) << "[App] resume..."; + androidAutoEntity_->resume(); + } else { + OPENAUTO_LOG(info) << "[App] Ignore resume -> no androidAutoEntity_ ..."; + } }); -} + } -void App::onAndroidAutoQuit() -{ + void App::onAndroidAutoQuit() { strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[App] onAndroidAutoQuit()"; + OPENAUTO_LOG(info) << "[App] onAndroidAutoQuit()"; - //acceptor_.close(); + //acceptor_.close(); - if (androidAutoEntity_ != nullptr) { - try { - androidAutoEntity_->stop(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();"; - } - try { - androidAutoEntity_.reset(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();"; - } + if (androidAutoEntity_ != nullptr) { + try { + androidAutoEntity_->stop(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();"; } - - if(!isStopped_) - { - try { - this->waitForDevice(); - } catch (...) { - OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by this->waitForDevice();"; - } + try { + androidAutoEntity_.reset(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();"; } + } + + if (!isStopped_) { + try { + this->waitForDevice(); + } catch (...) { + OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by this->waitForDevice();"; + } + } }); -} + } -void App::onUSBHubError(const aasdk::error::Error& error) -{ + void App::onUSBHubError(const aasdk::error::Error &error) { OPENAUTO_LOG(error) << "[App] onUSBHubError(): " << error.what(); // if(error != aasdk::error::ErrorCode::OPERATION_ABORTED && @@ -279,8 +248,8 @@ void App::onUSBHubError(const aasdk::error::Error& error) // OPENAUTO_LOG(error) << "[App] onUSBHubError: exception caused by this->waitForDevice();"; // } // } -} + } } -} -} + + diff --git a/src/autoapp/Configuration/Configuration.cpp b/src/autoapp/Configuration/Configuration.cpp index 2c99c1f..9069544 100644 --- a/src/autoapp/Configuration/Configuration.cpp +++ b/src/autoapp/Configuration/Configuration.cpp @@ -20,13 +20,10 @@ #include #include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace configuration + + + +namespace f1x::openauto::autoapp::configuration { const std::string Configuration::cConfigFileName = "openauto.ini"; @@ -766,6 +763,6 @@ void Configuration::writeButtonCodes(boost::property_tree::ptree& iniConfig) } } -} -} -} + + + diff --git a/src/autoapp/Projection/DummyBluetoothDevice.cpp b/src/autoapp/Projection/DummyBluetoothDevice.cpp index cf45ac4..4147683 100644 --- a/src/autoapp/Projection/DummyBluetoothDevice.cpp +++ b/src/autoapp/Projection/DummyBluetoothDevice.cpp @@ -18,13 +18,10 @@ #include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace projection + + + +namespace f1x::openauto::autoapp::projection { void DummyBluetoothDevice::stop() @@ -53,6 +50,6 @@ bool DummyBluetoothDevice::isAvailable() const } } -} -} -} + + + diff --git a/src/autoapp/Projection/LocalBluetoothDevice.cpp b/src/autoapp/Projection/LocalBluetoothDevice.cpp index 6c24d71..ccd987b 100644 --- a/src/autoapp/Projection/LocalBluetoothDevice.cpp +++ b/src/autoapp/Projection/LocalBluetoothDevice.cpp @@ -22,14 +22,7 @@ #include #include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace projection -{ +namespace f1x::openauto::autoapp::projection { LocalBluetoothDevice::LocalBluetoothDevice() { @@ -183,7 +176,3 @@ void LocalBluetoothDevice::onHostModeStateChanged(QBluetoothLocalDevice::HostMod } } -} -} -} -} diff --git a/src/autoapp/Service/Bluetooth/BluetoothService.cpp b/src/autoapp/Service/Bluetooth/BluetoothService.cpp index 4e6dbc4..14f4c05 100644 --- a/src/autoapp/Service/Bluetooth/BluetoothService.cpp +++ b/src/autoapp/Service/Bluetooth/BluetoothService.cpp @@ -19,50 +19,46 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace bluetooth { +namespace f1x::openauto::autoapp::service::bluetooth { - BluetoothService::BluetoothService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger, - projection::IBluetoothDevice::Pointer bluetoothDevice) - : strand_(ioService), - channel_(std::make_shared(strand_, std::move(messenger))), - bluetoothDevice_(std::move(bluetoothDevice)) { + BluetoothService::BluetoothService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IBluetoothDevice::Pointer bluetoothDevice) + : strand_(ioService), + channel_(std::make_shared(strand_, std::move(messenger))), + bluetoothDevice_(std::move(bluetoothDevice)) { - } + } - void BluetoothService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[BluetoothService] start()"; - channel_->receive(this->shared_from_this()); - }); - } + void BluetoothService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[BluetoothService] start()"; + channel_->receive(this->shared_from_this()); + }); + } - void BluetoothService::stop() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[BluetoothService] stop()"; - bluetoothDevice_->stop(); - }); - } + void BluetoothService::stop() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[BluetoothService] stop()"; + bluetoothDevice_->stop(); + }); + } - void BluetoothService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[BluetoothService] pause()"; - }); - } + void BluetoothService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[BluetoothService] pause()"; + }); + } - void BluetoothService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[BluetoothService] resume()"; - }); - } + void BluetoothService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[BluetoothService] resume()"; + }); + } - void BluetoothService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[BluetoothService] fillFeatures()"; + void BluetoothService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[BluetoothService] fillFeatures()"; if (bluetoothDevice_->isAvailable()) { OPENAUTO_LOG(info) << "[BluetoothService] Local Address: " << bluetoothDevice_->getLocalAddress(); @@ -82,76 +78,81 @@ namespace f1x { } } - void BluetoothService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[BluetoothService] onChannelOpenRequest()"; - OPENAUTO_LOG(debug) << "[BluetoothService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); + void + BluetoothService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[BluetoothService] onChannelOpenRequest()"; + OPENAUTO_LOG(debug) << "[BluetoothService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); - aap_protobuf::service::control::message::ChannelOpenResponse response; - const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; - response.set_status(status); + aap_protobuf::service::control::message::ChannelOpenResponse response; + const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; + response.set_status(status); - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendChannelOpenResponse(response, std::move(promise)); - - channel_->receive(this->shared_from_this()); - } - - void BluetoothService::onBluetoothPairingRequest( - const aap_protobuf::service::bluetooth::message::BluetoothPairingRequest &request) { - OPENAUTO_LOG(info) << "[BluetoothService] onBluetoothPairingRequest()"; - OPENAUTO_LOG(info) << "[BluetoothService] Phone Address: " << request.phone_address(); - - aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response; - - const auto isPaired = bluetoothDevice_->isPaired(request.phone_address()); - if (isPaired) { - OPENAUTO_LOG(info) << "[BluetoothService] Phone is Already Paired"; - } else { - OPENAUTO_LOG(info) << "[BluetoothService] Phone is Not Paired"; - } - - /* - * The HU must always sent a STATUS_SUCCESS response, - * or STATUS_BLUETOOTH_PAIRING_DELAYED if: - * there's a delay in allowing bluetooth - * the HU is already engaged in a bluetooth call - */ - response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); - response.set_already_paired(isPaired); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then(std::bind(&BluetoothService::sendBluetoothAuthenticationData, this->shared_from_this()), std::bind(&BluetoothService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendBluetoothPairingResponse(response, std::move(promise)); - channel_->receive(this->shared_from_this()); - } - - void BluetoothService::sendBluetoothAuthenticationData() { - aap_protobuf::service::bluetooth::message::BluetoothAuthenticationData data; - data.set_auth_data("123456"); - data.set_pairing_method(aap_protobuf::service::bluetooth::message::BluetoothPairingMethod::BLUETOOTH_PAIRING_PIN); - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendBluetoothAuthenticationData(data, std::move(promise)); - channel_->receive(this->shared_from_this()); - } - - void BluetoothService::onBluetoothAuthenticationResult(const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult &request) { - OPENAUTO_LOG(info) << "[BluetoothService] onBluetoothAuthenticationResult()"; - OPENAUTO_LOG(info) << "[BluetoothService] AuthData " << request.status(); - aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response; - - channel_->receive(this->shared_from_this()); - } - - void BluetoothService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[BluetoothService] onChannelError(): " << e.what(); - } - } - } - } + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendChannelOpenResponse(response, std::move(promise)); + channel_->receive(this->shared_from_this()); } -} \ No newline at end of file + + void BluetoothService::onBluetoothPairingRequest( + const aap_protobuf::service::bluetooth::message::BluetoothPairingRequest &request) { + OPENAUTO_LOG(info) << "[BluetoothService] onBluetoothPairingRequest()"; + OPENAUTO_LOG(info) << "[BluetoothService] Phone Address: " << request.phone_address(); + + aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response; + + const auto isPaired = bluetoothDevice_->isPaired(request.phone_address()); + if (isPaired) { + OPENAUTO_LOG(info) << "[BluetoothService] Phone is Already Paired"; + } else { + OPENAUTO_LOG(info) << "[BluetoothService] Phone is Not Paired"; + } + + /* + * The HU must always sent a STATUS_SUCCESS response, + * or STATUS_BLUETOOTH_PAIRING_DELAYED if: + * there's a delay in allowing bluetooth + * the HU is already engaged in a bluetooth call + */ + response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); + response.set_already_paired(isPaired); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then(std::bind(&BluetoothService::sendBluetoothAuthenticationData, this->shared_from_this()), + std::bind(&BluetoothService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendBluetoothPairingResponse(response, std::move(promise)); + channel_->receive(this->shared_from_this()); + } + + void BluetoothService::sendBluetoothAuthenticationData() { + OPENAUTO_LOG(info) << "[BluetoothService] sendBluetoothAuthenticationData()"; + + aap_protobuf::service::bluetooth::message::BluetoothAuthenticationData data; + // TODO: Bluetooth Authentication Data + data.set_auth_data("123456"); + data.set_pairing_method(aap_protobuf::service::bluetooth::message::BluetoothPairingMethod::BLUETOOTH_PAIRING_PIN); + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendBluetoothAuthenticationData(data, std::move(promise)); + channel_->receive(this->shared_from_this()); + } + + void BluetoothService::onBluetoothAuthenticationResult( + const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult &request) { + OPENAUTO_LOG(info) << "[BluetoothService] onBluetoothAuthenticationResult()"; + OPENAUTO_LOG(info) << "[BluetoothService] AuthData " << request.status(); + aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response; + + channel_->receive(this->shared_from_this()); + } + + void BluetoothService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[BluetoothService] onChannelError(): " << e.what(); + } +} + + + diff --git a/src/autoapp/Service/GenericNotification/GenericNotificationService.cpp b/src/autoapp/Service/GenericNotification/GenericNotificationService.cpp index a446e36..1b29e49 100644 --- a/src/autoapp/Service/GenericNotification/GenericNotificationService.cpp +++ b/src/autoapp/Service/GenericNotification/GenericNotificationService.cpp @@ -21,75 +21,73 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace genericnotification { +namespace f1x::openauto::autoapp::service::genericnotification { - GenericNotificationService::GenericNotificationService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger) - : strand_(ioService), - timer_(ioService), - channel_(std::make_shared(strand_, std::move(messenger))) { + GenericNotificationService::GenericNotificationService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger) + : strand_(ioService), + timer_(ioService), + channel_(std::make_shared(strand_, std::move( + messenger))) { - } - - void GenericNotificationService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[GenericNotificationService] start()"; - }); - } - - void GenericNotificationService::stop() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[GenericNotificationService] stop()"; - }); - } - - void GenericNotificationService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[GenericNotificationService] pause()"; - }); - } - - void GenericNotificationService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[GenericNotificationService] resume()"; - }); - } - - void GenericNotificationService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[GenericNotificationService] fillFeatures()"; - - auto *service = response.add_channels(); - service->set_id(static_cast(channel_->getId())); - - auto *genericNotification = service->mutable_wifi_projection_service(); - } - - void GenericNotificationService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[GenericNotificationService] onChannelOpenRequest()"; - OPENAUTO_LOG(debug) << "[GenericNotificationService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); - - aap_protobuf::service::control::message::ChannelOpenResponse response; - const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; - response.set_status(status); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&GenericNotificationService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendChannelOpenResponse(response, std::move(promise)); - - channel_->receive(this->shared_from_this()); - } - - void GenericNotificationService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[GenericNotificationService] onChannelError(): " << e.what(); - } - } - } - } } -} \ No newline at end of file + + void GenericNotificationService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[GenericNotificationService] start()"; + }); + } + + void GenericNotificationService::stop() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[GenericNotificationService] stop()"; + }); + } + + void GenericNotificationService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[GenericNotificationService] pause()"; + }); + } + + void GenericNotificationService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[GenericNotificationService] resume()"; + }); + } + + void GenericNotificationService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[GenericNotificationService] fillFeatures()"; + + auto *service = response.add_channels(); + service->set_id(static_cast(channel_->getId())); + + auto *genericNotification = service->mutable_wifi_projection_service(); + } + + void GenericNotificationService::onChannelOpenRequest( + const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[GenericNotificationService] onChannelOpenRequest()"; + OPENAUTO_LOG(debug) << "[GenericNotificationService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); + + aap_protobuf::service::control::message::ChannelOpenResponse response; + const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; + response.set_status(status); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&GenericNotificationService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendChannelOpenResponse(response, std::move(promise)); + + channel_->receive(this->shared_from_this()); + } + + void GenericNotificationService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[GenericNotificationService] onChannelError(): " << e.what(); + } +} + + + diff --git a/src/autoapp/Service/MediaSink/GuidanceAudioService.cpp b/src/autoapp/Service/MediaSink/GuidanceAudioService.cpp index 1acf33a..6597e30 100644 --- a/src/autoapp/Service/MediaSink/GuidanceAudioService.cpp +++ b/src/autoapp/Service/MediaSink/GuidanceAudioService.cpp @@ -18,26 +18,22 @@ #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace mediasink { - using f1x::openauto::autoapp::service::mediasink::GuidanceAudioService; - using f1x::openauto::autoapp::service::mediasink::AudioMediaSinkService; - using aasdk::channel::mediasink::audio::channel::GuidanceAudioChannel; - GuidanceAudioService::GuidanceAudioService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger, - projection::IAudioOutput::Pointer audioOutput) - : AudioMediaSinkService( - ioService, - std::make_shared(strand_, std::move(messenger)), - std::move(audioOutput)) { +namespace f1x::openauto::autoapp::service::mediasink { + using f1x::openauto::autoapp::service::mediasink::GuidanceAudioService; + using f1x::openauto::autoapp::service::mediasink::AudioMediaSinkService; + using aasdk::channel::mediasink::audio::channel::GuidanceAudioChannel; + + GuidanceAudioService::GuidanceAudioService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IAudioOutput::Pointer audioOutput) + : AudioMediaSinkService( + ioService, + std::make_shared(strand_, std::move(messenger)), + std::move(audioOutput)) { - } - } - } - } } -} \ No newline at end of file +} + + + diff --git a/src/autoapp/Service/MediaSink/MediaAudioService.cpp b/src/autoapp/Service/MediaSink/MediaAudioService.cpp index 73e3901..a392966 100644 --- a/src/autoapp/Service/MediaSink/MediaAudioService.cpp +++ b/src/autoapp/Service/MediaSink/MediaAudioService.cpp @@ -19,24 +19,18 @@ #include +namespace f1x::openauto::autoapp::service::mediasink { + MediaAudioService::MediaAudioService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IAudioOutput::Pointer audioOutput) + : AudioMediaSinkService(ioService, + std::make_shared(strand_, + std::move( + messenger)), + std::move(audioOutput)) { -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace mediasink { - MediaAudioService::MediaAudioService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger, - projection::IAudioOutput::Pointer audioOutput) - : AudioMediaSinkService(ioService, - std::make_shared(strand_, - std::move( - messenger)), - std::move(audioOutput)) { - - } - } - } - } } -} \ No newline at end of file +} + + + diff --git a/src/autoapp/Service/MediaSink/SystemAudioService.cpp b/src/autoapp/Service/MediaSink/SystemAudioService.cpp index 4b92cf9..e44bb3f 100644 --- a/src/autoapp/Service/MediaSink/SystemAudioService.cpp +++ b/src/autoapp/Service/MediaSink/SystemAudioService.cpp @@ -19,23 +19,20 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace mediasink { - SystemAudioService::SystemAudioService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger, - projection::IAudioOutput::Pointer audioOutput) - : AudioMediaSinkService(ioService, - std::make_shared(strand_, - std::move(messenger)), - std::move(audioOutput)) { - } +namespace f1x::openauto::autoapp::service::mediasink { + SystemAudioService::SystemAudioService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IAudioOutput::Pointer audioOutput) + : AudioMediaSinkService(ioService, + std::make_shared(strand_, + std::move( + messenger)), + std::move(audioOutput)) { - } - } - } } -} \ No newline at end of file + +} + + + diff --git a/src/autoapp/Service/MediaSource/MediaSourceService.cpp b/src/autoapp/Service/MediaSource/MediaSourceService.cpp index 3481f69..86a96d0 100644 --- a/src/autoapp/Service/MediaSource/MediaSourceService.cpp +++ b/src/autoapp/Service/MediaSource/MediaSourceService.cpp @@ -16,256 +16,258 @@ * along with openauto. If not, see . */ -#include #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace mediasource { - MediaSourceService::MediaSourceService(boost::asio::io_service &ioService, - aasdk::channel::mediasource::IMediaSourceService::Pointer channel, - projection::IAudioInput::Pointer audioInput) - : strand_(ioService), channel_(std::move(channel)), audioInput_(std::move(audioInput)), session_(-1) { +namespace f1x::openauto::autoapp::service::mediasource { - } + MediaSourceService::MediaSourceService(boost::asio::io_service &ioService, + aasdk::channel::mediasource::IMediaSourceService::Pointer channel, + projection::IAudioInput::Pointer audioInput) + : strand_(ioService), channel_(std::move(channel)), audioInput_(std::move(audioInput)), session_(-1) { - void MediaSourceService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[MediaSourceService] start()"; - channel_->receive(this->shared_from_this()); - }); - } + } - void MediaSourceService::stop() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[MediaSourceService] stop()"; - audioInput_->stop(); - }); - } + void MediaSourceService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[MediaSourceService] start()"; + channel_->receive(this->shared_from_this()); + }); + } - void MediaSourceService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[MediaSourceService] pause()"; - }); - } + void MediaSourceService::stop() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[MediaSourceService] stop()"; + audioInput_->stop(); + }); + } - void MediaSourceService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[MediaSourceService] resume()"; - }); - } + void MediaSourceService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[MediaSourceService] pause()"; + }); + } - /* - * Service Discovery - */ + void MediaSourceService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[MediaSourceService] resume()"; + }); + } - /** - * Fill Features of Service - * @param response - */ - void MediaSourceService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[MediaSourceService] fillFeatures()"; + /* + * Service Discovery + */ - auto *service = response.add_channels(); - service->set_id(static_cast(channel_->getId())); + /** + * Fill Features of Service + * @param response + */ + void MediaSourceService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[MediaSourceService] fillFeatures()"; - auto *avInputChannel = service->mutable_media_source_service(); - avInputChannel->set_available_type( - aap_protobuf::service::media::shared::message::MediaCodecType::MEDIA_CODEC_AUDIO_PCM); + auto *service = response.add_channels(); + service->set_id(static_cast(channel_->getId())); - auto audioConfig = avInputChannel->mutable_audio_config(); - audioConfig->set_sampling_rate(audioInput_->getSampleRate()); - audioConfig->set_number_of_bits(audioInput_->getSampleSize()); - audioConfig->set_number_of_channels(audioInput_->getChannelCount()); - } + auto *avInputChannel = service->mutable_media_source_service(); + avInputChannel->set_available_type( + aap_protobuf::service::media::shared::message::MediaCodecType::MEDIA_CODEC_AUDIO_PCM); - /* - * Base Channel Handling - */ + auto audioConfig = avInputChannel->mutable_audio_config(); + audioConfig->set_sampling_rate(audioInput_->getSampleRate()); + audioConfig->set_number_of_bits(audioInput_->getSampleSize()); + audioConfig->set_number_of_channels(audioInput_->getChannelCount()); + } - /** - * Open Service Channel Request - * @param request - */ - void MediaSourceService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[MediaSourceService] onChannelOpenRequest()"; - OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); + /* + * Base Channel Handling + */ - const aap_protobuf::shared::MessageStatus status = audioInput_->open() - ? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS - : aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR; + /** + * Open Service Channel Request + * @param request + */ + void + MediaSourceService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[MediaSourceService] onChannelOpenRequest()"; + OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); - OPENAUTO_LOG(info) << "[MediaSourceService] Status determined: " << aap_protobuf::shared::MessageStatus_Name(status); + const aap_protobuf::shared::MessageStatus status = audioInput_->open() + ? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS + : aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR; - aap_protobuf::service::control::message::ChannelOpenResponse response; - response.set_status(status); + OPENAUTO_LOG(info) << "[MediaSourceService] Status determined: " + << aap_protobuf::shared::MessageStatus_Name(status); - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, - std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); + aap_protobuf::service::control::message::ChannelOpenResponse response; + response.set_status(status); - channel_->sendChannelOpenResponse(response, std::move(promise)); - channel_->receive(this->shared_from_this()); - } + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, + std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); - /** - * Generic Channel Error - * @param e - */ - void MediaSourceService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[MediaSourceService] onChannelError(): " << e.what(); - } + channel_->sendChannelOpenResponse(response, std::move(promise)); + channel_->receive(this->shared_from_this()); + } - /* - * Media Channel Handling - */ + /** + * Generic Channel Error + * @param e + */ + void MediaSourceService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[MediaSourceService] onChannelError(): " << e.what(); + } - /** - * Generic Media Channel Setup Request - * @param request - */ - void - MediaSourceService::onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) { + /* + * Media Channel Handling + */ - OPENAUTO_LOG(info) << "[MediaSourceService] onMediaChannelSetupRequest()"; - OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId()) << ", Codec: " << MediaCodecType_Name(request.type()); + /** + * Generic Media Channel Setup Request + * @param request + */ + void + MediaSourceService::onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) { - aap_protobuf::service::media::shared::message::Config response; - auto status = aap_protobuf::service::media::shared::message::Config::STATUS_READY; - response.set_status(status); - response.set_max_unacked(1); - response.add_configuration_indices(0); + OPENAUTO_LOG(info) << "[MediaSourceService] onMediaChannelSetupRequest()"; + OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId()) + << ", Codec: " << MediaCodecType_Name(request.type()); - auto promise = aasdk::channel::SendPromise::defer(strand_); + aap_protobuf::service::media::shared::message::Config response; + auto status = aap_protobuf::service::media::shared::message::Config::STATUS_READY; + response.set_status(status); + response.set_max_unacked(1); + response.add_configuration_indices(0); - promise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendChannelSetupResponse(response, std::move(promise)); - channel_->receive(this->shared_from_this()); - } + auto promise = aasdk::channel::SendPromise::defer(strand_); - /** - * Generic Media Ack - */ - void MediaSourceService::onMediaChannelAckIndication( - const aap_protobuf::service::media::source::message::Ack &) { - OPENAUTO_LOG(debug) << "[MediaSourceService] onMediaChannelAckIndication()"; - channel_->receive(this->shared_from_this()); - } + promise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendChannelSetupResponse(response, std::move(promise)); + channel_->receive(this->shared_from_this()); + } - /* - * Source Media Channel Handling - */ + /** + * Generic Media Ack + */ + void MediaSourceService::onMediaChannelAckIndication( + const aap_protobuf::service::media::source::message::Ack &) { + OPENAUTO_LOG(debug) << "[MediaSourceService] onMediaChannelAckIndication()"; + channel_->receive(this->shared_from_this()); + } - /** - * Handle request to Open or Close Microphone Source Channel - * @param request - */ - void MediaSourceService::onMediaSourceOpenRequest( - const aap_protobuf::service::media::source::message::MicrophoneRequest &request) { - OPENAUTO_LOG(info) << "[MediaSourceService] onMediaSourceOpenRequest()"; - OPENAUTO_LOG(info) << "[MediaSourceService] Request to Open?: " << request.open() << ", anc: " << request.anc_enabled() << ", ec: " << request.ec_enabled() << ", max unacked: " << request.max_unacked(); + /* + * Source Media Channel Handling + */ - if (request.open()) { - // Request for Channel Open - auto startPromise = projection::IAudioInput::StartPromise::defer(strand_); - startPromise->then(std::bind(&MediaSourceService::onMediaSourceOpenSuccess, this->shared_from_this()), - [this, self = this->shared_from_this()]() { - OPENAUTO_LOG(error) << "[MediaSourceService] Media Source Open Failed"; + /** + * Handle request to Open or Close Microphone Source Channel + * @param request + */ + void MediaSourceService::onMediaSourceOpenRequest( + const aap_protobuf::service::media::source::message::MicrophoneRequest &request) { + OPENAUTO_LOG(info) << "[MediaSourceService] onMediaSourceOpenRequest()"; + OPENAUTO_LOG(info) << "[MediaSourceService] Request to Open?: " << request.open() << ", anc: " + << request.anc_enabled() << ", ec: " << request.ec_enabled() << ", max unacked: " + << request.max_unacked(); - aap_protobuf::service::media::source::message::MicrophoneResponse response; - response.set_session_id(session_); + if (request.open()) { + // Request for Channel Open + auto startPromise = projection::IAudioInput::StartPromise::defer(strand_); + startPromise->then(std::bind(&MediaSourceService::onMediaSourceOpenSuccess, this->shared_from_this()), + [this, self = this->shared_from_this()]() { + OPENAUTO_LOG(error) << "[MediaSourceService] Media Source Open Failed"; - response.set_status(aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR); + aap_protobuf::service::media::source::message::MicrophoneResponse response; + response.set_session_id(session_); - auto sendPromise = aasdk::channel::SendPromise::defer(strand_); - sendPromise->then([]() {}, - std::bind(&MediaSourceService::onChannelError, - this->shared_from_this(), - std::placeholders::_1)); - channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise)); - }); + response.set_status(aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR); - audioInput_->start(std::move(startPromise)); - } else { - // Request for Channel Close - audioInput_->stop(); + auto sendPromise = aasdk::channel::SendPromise::defer(strand_); + sendPromise->then([]() {}, + std::bind(&MediaSourceService::onChannelError, + this->shared_from_this(), + std::placeholders::_1)); + channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise)); + }); - aap_protobuf::service::media::source::message::MicrophoneResponse response; - response.set_session_id(session_); + audioInput_->start(std::move(startPromise)); + } else { + // Request for Channel Close + audioInput_->stop(); - response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); + aap_protobuf::service::media::source::message::MicrophoneResponse response; + response.set_session_id(session_); - auto sendPromise = aasdk::channel::SendPromise::defer(strand_); - sendPromise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise)); - } + response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); - channel_->receive(this->shared_from_this()); - } + auto sendPromise = aasdk::channel::SendPromise::defer(strand_); + sendPromise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise)); + } + + channel_->receive(this->shared_from_this()); + } - /** - * Sends response to advise Microphone is Open - */ - void MediaSourceService::onMediaSourceOpenSuccess() { - OPENAUTO_LOG(error) << "[MediaSourceService] onMediaSourceOpenSuccess()"; + /** + * Sends response to advise Microphone is Open + */ + void MediaSourceService::onMediaSourceOpenSuccess() { + OPENAUTO_LOG(error) << "[MediaSourceService] onMediaSourceOpenSuccess()"; - aap_protobuf::service::media::source::message::MicrophoneResponse response; - response.set_session_id(session_); - response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); + aap_protobuf::service::media::source::message::MicrophoneResponse response; + response.set_session_id(session_); + response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); - auto sendPromise = aasdk::channel::SendPromise::defer(strand_); - sendPromise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); + auto sendPromise = aasdk::channel::SendPromise::defer(strand_); + sendPromise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); - channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise)); + channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise)); - this->readMediaSource(); - } + this->readMediaSource(); + } - /** - * Resolves promise from readMediaSource. Sends Media with Timestamp Indication to channel. - * @param data - */ - void MediaSourceService::onMediaSourceDataReady(aasdk::common::Data data) { - OPENAUTO_LOG(error) << "[MediaSourceService] onMediaSourceDataReady()"; - auto sendPromise = aasdk::channel::SendPromise::defer(strand_); - sendPromise->then(std::bind(&MediaSourceService::readMediaSource, this->shared_from_this()), - std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); + /** + * Resolves promise from readMediaSource. Sends Media with Timestamp Indication to channel. + * @param data + */ + void MediaSourceService::onMediaSourceDataReady(aasdk::common::Data data) { + OPENAUTO_LOG(error) << "[MediaSourceService] onMediaSourceDataReady()"; + auto sendPromise = aasdk::channel::SendPromise::defer(strand_); + sendPromise->then(std::bind(&MediaSourceService::readMediaSource, this->shared_from_this()), + std::bind(&MediaSourceService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); - auto timestamp = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now().time_since_epoch()); - channel_->sendMediaSourceWithTimestampIndication(timestamp.count(), std::move(data), std::move(sendPromise)); - } + auto timestamp = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now().time_since_epoch()); + channel_->sendMediaSourceWithTimestampIndication(timestamp.count(), std::move(data), std::move(sendPromise)); + } - /** - * Reads audio from a MediaSource (eg Microphone). Promise resolves to onMediaSourceDataReady. - */ - void MediaSourceService::readMediaSource() { - OPENAUTO_LOG(debug) << "[MediaSourceService] readMediaSource()"; - if (audioInput_->isActive()) { - auto readPromise = projection::IAudioInput::ReadPromise::defer(strand_); - readPromise->then( - std::bind(&MediaSourceService::onMediaSourceDataReady, this->shared_from_this(), - std::placeholders::_1), - [this, self = this->shared_from_this()]() { - OPENAUTO_LOG(debug) << "[MediaSourceService] audio input read rejected."; - }); + /** + * Reads audio from a MediaSource (eg Microphone). Promise resolves to onMediaSourceDataReady. + */ + void MediaSourceService::readMediaSource() { + OPENAUTO_LOG(debug) << "[MediaSourceService] readMediaSource()"; + if (audioInput_->isActive()) { + auto readPromise = projection::IAudioInput::ReadPromise::defer(strand_); + readPromise->then( + std::bind(&MediaSourceService::onMediaSourceDataReady, this->shared_from_this(), + std::placeholders::_1), + [this, self = this->shared_from_this()]() { + OPENAUTO_LOG(debug) << "[MediaSourceService] audio input read rejected."; + }); - audioInput_->read(std::move(readPromise)); - } - } - } - } + audioInput_->read(std::move(readPromise)); } } } + + + + diff --git a/src/autoapp/Service/MediaSource/MicrophoneMediaSourceService.cpp b/src/autoapp/Service/MediaSource/MicrophoneMediaSourceService.cpp index 7d14c4a..23f407f 100644 --- a/src/autoapp/Service/MediaSource/MicrophoneMediaSourceService.cpp +++ b/src/autoapp/Service/MediaSource/MicrophoneMediaSourceService.cpp @@ -19,22 +19,18 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace mediasource { - MicrophoneMediaSourceService::MicrophoneMediaSourceService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger, - projection::IAudioInput::Pointer audioOutput) - : MediaSourceService(ioService, std::make_shared(strand_, - std::move( - messenger)), - std::move(audioOutput)) { +namespace f1x::openauto::autoapp::service::mediasource { + MicrophoneMediaSourceService::MicrophoneMediaSourceService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IAudioInput::Pointer audioOutput) + : MediaSourceService(ioService, + std::make_shared(strand_, + std::move( + messenger)), + std::move(audioOutput)) { - } - } - } - } } -} \ No newline at end of file +} + + + diff --git a/src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp b/src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp index 0e03ee4..76a8648 100644 --- a/src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp +++ b/src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp @@ -21,89 +21,90 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace navigationstatus { +namespace f1x::openauto::autoapp::service::navigationstatus { - NavigationStatusService::NavigationStatusService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger) - : strand_(ioService), - timer_(ioService), - channel_(std::make_shared(strand_, std::move(messenger))) { + NavigationStatusService::NavigationStatusService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger) + : strand_(ioService), + timer_(ioService), + channel_(std::make_shared(strand_, + std::move(messenger))) { - } - - void NavigationStatusService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[NavigationStatusService] start()"; - }); - } - - void NavigationStatusService::stop() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[NavigationStatusService] stop()"; - }); - } - - void NavigationStatusService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[NavigationStatusService] pause()"; - }); - } - - void NavigationStatusService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[NavigationStatusService] resume()"; - }); - } - - void NavigationStatusService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[NavigationStatusService] fillFeatures()"; - - auto *service = response.add_channels(); - service->set_id(static_cast(channel_->getId())); - - auto *navigationStatus = service->mutable_navigation_status_service(); - } - - void NavigationStatusService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[NavigationStatusService] onChannelOpenRequest()"; - OPENAUTO_LOG(info) << "[NavigationStatusService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); - - aap_protobuf::service::control::message::ChannelOpenResponse response; - const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; - response.set_status(status); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&NavigationStatusService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendChannelOpenResponse(response, std::move(promise)); - - channel_->receive(this->shared_from_this()); - } - - void NavigationStatusService::onStatusUpdate(const aap_protobuf::service::navigationstatus::message::NavigationStatus &navStatus) { - channel_->receive(this->shared_from_this()); - } - - - void NavigationStatusService::onTurnEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent &turnEvent) { - channel_->receive(this->shared_from_this()); - } - - void NavigationStatusService::onDistanceEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent &distanceEvent) { - channel_->receive(this->shared_from_this()); - } - - - void NavigationStatusService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[NavigationStatusService] onChannelError(): " << e.what(); - } - } - } - } } -} \ No newline at end of file + + void NavigationStatusService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[NavigationStatusService] start()"; + }); + } + + void NavigationStatusService::stop() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[NavigationStatusService] stop()"; + }); + } + + void NavigationStatusService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[NavigationStatusService] pause()"; + }); + } + + void NavigationStatusService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[NavigationStatusService] resume()"; + }); + } + + void NavigationStatusService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[NavigationStatusService] fillFeatures()"; + + auto *service = response.add_channels(); + service->set_id(static_cast(channel_->getId())); + + auto *navigationStatus = service->mutable_navigation_status_service(); + } + + void NavigationStatusService::onChannelOpenRequest( + const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[NavigationStatusService] onChannelOpenRequest()"; + OPENAUTO_LOG(info) << "[NavigationStatusService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); + + aap_protobuf::service::control::message::ChannelOpenResponse response; + const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; + response.set_status(status); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&NavigationStatusService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendChannelOpenResponse(response, std::move(promise)); + + channel_->receive(this->shared_from_this()); + } + + void NavigationStatusService::onStatusUpdate( + const aap_protobuf::service::navigationstatus::message::NavigationStatus &navStatus) { + channel_->receive(this->shared_from_this()); + } + + + void NavigationStatusService::onTurnEvent( + const aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent &turnEvent) { + channel_->receive(this->shared_from_this()); + } + + void NavigationStatusService::onDistanceEvent( + const aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent &distanceEvent) { + channel_->receive(this->shared_from_this()); + } + + + void NavigationStatusService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[NavigationStatusService] onChannelError(): " << e.what(); + } +} + + + diff --git a/src/autoapp/Service/Pinger.cpp b/src/autoapp/Service/Pinger.cpp index 72aca5a..75778cf 100644 --- a/src/autoapp/Service/Pinger.cpp +++ b/src/autoapp/Service/Pinger.cpp @@ -19,86 +19,60 @@ #include #include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ +namespace f1x::openauto::autoapp::service { -Pinger::Pinger(boost::asio::io_service& ioService, time_t duration) - : strand_(ioService) - , timer_(ioService) - , duration_(duration) - , cancelled_(false) - , pingsCount_(0) - , pongsCount_(0) -{ + Pinger::Pinger(boost::asio::io_service &ioService, time_t duration) + : strand_(ioService), timer_(ioService), duration_(duration), cancelled_(false), pingsCount_(0), pongsCount_(0) { -} + } -void Pinger::ping(Promise::Pointer promise) -{ + void Pinger::ping(Promise::Pointer promise) { strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { - cancelled_ = false; + cancelled_ = false; - if(promise_ != nullptr) - { - promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)); - } - else - { - ++pingsCount_; - OPENAUTO_LOG(debug) << "[Pinger] Ping counter: " << pingsCount_; + if (promise_ != nullptr) { + promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)); + } else { + ++pingsCount_; + OPENAUTO_LOG(debug) << "[Pinger] Ping counter: " << pingsCount_; - promise_ = std::move(promise); - timer_.expires_from_now(boost::posix_time::milliseconds(duration_)); - timer_.async_wait(strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1))); - } + promise_ = std::move(promise); + timer_.expires_from_now(boost::posix_time::milliseconds(duration_)); + timer_.async_wait( + strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1))); + } }); -} + } -void Pinger::pong() -{ + void Pinger::pong() { strand_.dispatch([this, self = this->shared_from_this()]() { - ++pongsCount_; - OPENAUTO_LOG(debug) << "[Pinger] Pong counter: " << pongsCount_; + ++pongsCount_; + OPENAUTO_LOG(debug) << "[Pinger] Pong counter: " << pongsCount_; }); -} + } -void Pinger::onTimerExceeded(const boost::system::error_code& error) -{ - if(promise_ == nullptr) - { - return; - } - else if(error == boost::asio::error::operation_aborted || cancelled_) - { - promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_ABORTED)); - } - else if(pingsCount_ - pongsCount_ > 4) - { - promise_->reject(aasdk::error::Error()); - } - else - { - promise_->resolve(); + void Pinger::onTimerExceeded(const boost::system::error_code &error) { + if (promise_ == nullptr) { + return; + } else if (error == boost::asio::error::operation_aborted || cancelled_) { + promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_ABORTED)); + } else if (pingsCount_ - pongsCount_ > 4) { + promise_->reject(aasdk::error::Error()); + } else { + promise_->resolve(); } promise_.reset(); -} + } -void Pinger::cancel() -{ + void Pinger::cancel() { strand_.dispatch([this, self = this->shared_from_this()]() { - cancelled_ = true; - timer_.cancel(); + cancelled_ = true; + timer_.cancel(); }); -} + } } -} -} -} + + + diff --git a/src/autoapp/Service/Radio/RadioService.cpp b/src/autoapp/Service/Radio/RadioService.cpp index e4b2372..eb8363e 100644 --- a/src/autoapp/Service/Radio/RadioService.cpp +++ b/src/autoapp/Service/Radio/RadioService.cpp @@ -21,78 +21,74 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace radio { +namespace f1x::openauto::autoapp::service::radio { - RadioService::RadioService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger) - : strand_(ioService), - timer_(ioService), - channel_(std::make_shared(strand_, std::move(messenger))) { + RadioService::RadioService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger) + : strand_(ioService), + timer_(ioService), + channel_(std::make_shared(strand_, std::move(messenger))) { - } - - void RadioService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(debug) << "[RadioService] start()"; - }); - } - - void RadioService::stop() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(debug) << "[RadioService] stop()"; - }); - } - - void RadioService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(debug) << "[RadioService] pause()"; - }); - } - - void RadioService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(debug) << "[RadioService] resume()"; - }); - } - - void RadioService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[RadioService] fillFeatures()"; - - auto *service = response.add_channels(); - service->set_id(static_cast(channel_->getId())); - - auto *radio = service->mutable_radio_service(); - } - - void RadioService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[RadioService] onChannelOpenRequest()"; - OPENAUTO_LOG(debug) << "[RadioService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); - - - aap_protobuf::service::control::message::ChannelOpenResponse response; - const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; - response.set_status(status); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&RadioService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendChannelOpenResponse(response, std::move(promise)); - - channel_->receive(this->shared_from_this()); - } - - void RadioService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[RadioService] onChannelError(): " << e.what(); - } - - - } - } - } } -} \ No newline at end of file + + void RadioService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(debug) << "[RadioService] start()"; + }); + } + + void RadioService::stop() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(debug) << "[RadioService] stop()"; + }); + } + + void RadioService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(debug) << "[RadioService] pause()"; + }); + } + + void RadioService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(debug) << "[RadioService] resume()"; + }); + } + + void RadioService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[RadioService] fillFeatures()"; + + auto *service = response.add_channels(); + service->set_id(static_cast(channel_->getId())); + + auto *radio = service->mutable_radio_service(); + } + + void RadioService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[RadioService] onChannelOpenRequest()"; + OPENAUTO_LOG(debug) << "[RadioService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); + + + aap_protobuf::service::control::message::ChannelOpenResponse response; + const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; + response.set_status(status); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&RadioService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendChannelOpenResponse(response, std::move(promise)); + + channel_->receive(this->shared_from_this()); + } + + void RadioService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[RadioService] onChannelError(): " << e.what(); + } + + +} + + + diff --git a/src/autoapp/Service/Sensor/SensorService.cpp b/src/autoapp/Service/Sensor/SensorService.cpp index 493f4c2..b66c23a 100644 --- a/src/autoapp/Service/Sensor/SensorService.cpp +++ b/src/autoapp/Service/Sensor/SensorService.cpp @@ -23,230 +23,224 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace sensor { - SensorService::SensorService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger) - : strand_(ioService), - timer_(ioService), - channel_(std::make_shared(strand_, std::move(messenger))) { +namespace f1x::openauto::autoapp::service::sensor { + SensorService::SensorService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger) + : strand_(ioService), + timer_(ioService), + channel_(std::make_shared(strand_, std::move(messenger))) { - } + } - void SensorService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - if (gps_open("127.0.0.1", "2947", &this->gpsData_)) { - OPENAUTO_LOG(warning) << "[SensorService] can't connect to GPSD."; - } else { - OPENAUTO_LOG(info) << "[SensorService] Connected to GPSD."; - gps_stream(&this->gpsData_, WATCH_ENABLE | WATCH_JSON, NULL); - this->gpsEnabled_ = true; - } - - if (is_file_exist("/tmp/night_mode_enabled")) { - this->isNight = true; - } - this->sensorPolling(); - - OPENAUTO_LOG(info) << "[SensorService] start()"; - channel_->receive(this->shared_from_this()); - }); - - } - - void SensorService::stop() { - this->stopPolling = true; - - strand_.dispatch([this, self = this->shared_from_this()]() { - if (this->gpsEnabled_) { - gps_stream(&this->gpsData_, WATCH_DISABLE, NULL); - gps_close(&this->gpsData_); - this->gpsEnabled_ = false; - } - - OPENAUTO_LOG(info) << "[SensorService] stop()"; - }); - } - - void SensorService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[SensorService] pause()"; - }); - } - - void SensorService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[SensorService] resume()"; - }); - } - - void SensorService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[SensorService] fillFeatures()"; - - auto *service = response.add_channels(); - service->set_id(static_cast(channel_->getId())); - - auto *sensorChannel = service->mutable_sensor_source_service(); - sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensorsource::message::SensorType::SENSOR_DRIVING_STATUS_DATA); - sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensorsource::message::SensorType::SENSOR_LOCATION); - sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE); - } - - void SensorService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[SensorService] onChannelOpenRequest()"; - OPENAUTO_LOG(debug) << "[SensorService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); - - aap_protobuf::service::control::message::ChannelOpenResponse response; - const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; - response.set_status(status); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, - std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - channel_->sendChannelOpenResponse(response, std::move(promise)); - - channel_->receive(this->shared_from_this()); - } - - void SensorService::onSensorStartRequest( - const aap_protobuf::service::sensorsource::message::SensorRequest &request) { - OPENAUTO_LOG(info) << "[SensorService] onSensorStartRequest()"; - OPENAUTO_LOG(debug) << "[SensorService] Request Type: "<< request.type(); - - aap_protobuf::service::sensorsource::message::SensorStartResponseMessage response; - response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - - if (request.type() == aap_protobuf::service::sensorsource::message::SENSOR_DRIVING_STATUS_DATA) - { - promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()), - std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - } - else if (request.type() == aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE) - { - promise->then(std::bind(&SensorService::sendNightData, this->shared_from_this()), - std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - } - else - { - promise->then([]() {}, - std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - } - - channel_->sendSensorStartResponse(response, std::move(promise)); - channel_->receive(this->shared_from_this()); - } - - void SensorService::sendDrivingStatusUnrestricted() { - OPENAUTO_LOG(info) << "[SensorService] sendDrivingStatusUnrestricted()"; - aap_protobuf::service::sensorsource::message::SensorBatch indication; - indication.add_driving_status_data()->set_status(aap_protobuf::service::sensorsource::message::DrivingStatus::DRIVE_STATUS_UNRESTRICTED); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() { }, - std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - channel_->sendSensorEventIndication(indication, std::move(promise)); - } - - void SensorService::sendNightData() { - OPENAUTO_LOG(info) << "[SensorService] sendNightData()"; - aap_protobuf::service::sensorsource::message::SensorBatch indication; - - if (SensorService::isNight) { - OPENAUTO_LOG(info) << "[SensorService] Night Mode Triggered"; - indication.add_night_mode_data()->set_night_mode(true); - } else { - OPENAUTO_LOG(info) << "[SensorService] Day Mode Triggered"; - indication.add_night_mode_data()->set_night_mode(false); - } - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, - std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - channel_->sendSensorEventIndication(indication, std::move(promise)); - if (this->firstRun) { - this->firstRun = false; - this->previous = this->isNight; - } - } - - void SensorService::sendGPSLocationData() { - OPENAUTO_LOG(info) << "[SensorService] sendGPSLocationData()"; - aap_protobuf::service::sensorsource::message::SensorBatch indication; - - auto *locInd = indication.add_location_data(); - - // epoch seconds - // locInd->set_timestamp(this->gpsData_.fix.time * 1e3); - // degrees - locInd->set_latitude_e7(this->gpsData_.fix.latitude * 1e7); - locInd->set_longitude_e7(this->gpsData_.fix.longitude * 1e7); - // meters - auto accuracy = sqrt(pow(this->gpsData_.fix.epx, 2) + pow(this->gpsData_.fix.epy, 2)); - locInd->set_accuracy_e3(accuracy * 1e3); - - if (this->gpsData_.set & ALTITUDE_SET) { - // meters above ellipsoid - locInd->set_altitude_e2(this->gpsData_.fix.altitude * 1e2); - } - if (this->gpsData_.set & SPEED_SET) { - // meters per second to knots - locInd->set_speed_e3(this->gpsData_.fix.speed * 1.94384 * 1e3); - } - if (this->gpsData_.set & TRACK_SET) { - // degrees - locInd->set_bearing_e6(this->gpsData_.fix.track * 1e6); - } - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, - std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - channel_->sendSensorEventIndication(indication, std::move(promise)); - } - - void SensorService::sensorPolling() { - OPENAUTO_LOG(info) << "[SensorService] sensorPolling()"; - if (!this->stopPolling) { - strand_.dispatch([this, self = this->shared_from_this()]() { - this->isNight = is_file_exist("/tmp/night_mode_enabled"); - if (this->previous != this->isNight && !this->firstRun) { - this->previous = this->isNight; - this->sendNightData(); - } - - if ((this->gpsEnabled_) && - (gps_waiting(&this->gpsData_, 0)) && - (gps_read(&this->gpsData_) > 0) && - (this->gpsData_.status != STATUS_NO_FIX) && - (this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) && - (this->gpsData_.set & TIME_SET) && - (this->gpsData_.set & LATLON_SET)) - { - this->sendGPSLocationData(); - } - - timer_.expires_from_now(boost::posix_time::milliseconds(250)); - timer_.async_wait(strand_.wrap(std::bind(&SensorService::sensorPolling, this->shared_from_this()))); - }); - } - } - - bool SensorService::is_file_exist(const char *fileName) { - OPENAUTO_LOG(info) << "[SensorService] is_file_exist()"; - std::ifstream ifile(fileName, std::ios::in); - return ifile.good(); - } - - void SensorService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[SensorService] onChannelError(): " << e.what(); - } - } + void SensorService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + if (gps_open("127.0.0.1", "2947", &this->gpsData_)) { + OPENAUTO_LOG(warning) << "[SensorService] can't connect to GPSD."; + } else { + OPENAUTO_LOG(info) << "[SensorService] Connected to GPSD."; + gps_stream(&this->gpsData_, WATCH_ENABLE | WATCH_JSON, NULL); + this->gpsEnabled_ = true; } + + if (is_file_exist("/tmp/night_mode_enabled")) { + this->isNight = true; + } + this->sensorPolling(); + + OPENAUTO_LOG(info) << "[SensorService] start()"; + channel_->receive(this->shared_from_this()); + }); + + } + + void SensorService::stop() { + this->stopPolling = true; + + strand_.dispatch([this, self = this->shared_from_this()]() { + if (this->gpsEnabled_) { + gps_stream(&this->gpsData_, WATCH_DISABLE, NULL); + gps_close(&this->gpsData_); + this->gpsEnabled_ = false; + } + + OPENAUTO_LOG(info) << "[SensorService] stop()"; + }); + } + + void SensorService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[SensorService] pause()"; + }); + } + + void SensorService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[SensorService] resume()"; + }); + } + + void SensorService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[SensorService] fillFeatures()"; + + auto *service = response.add_channels(); + service->set_id(static_cast(channel_->getId())); + + auto *sensorChannel = service->mutable_sensor_source_service(); + sensorChannel->add_sensors()->set_sensor_type( + aap_protobuf::service::sensorsource::message::SensorType::SENSOR_DRIVING_STATUS_DATA); + sensorChannel->add_sensors()->set_sensor_type( + aap_protobuf::service::sensorsource::message::SensorType::SENSOR_LOCATION); + sensorChannel->add_sensors()->set_sensor_type( + aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE); + } + + void SensorService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[SensorService] onChannelOpenRequest()"; + OPENAUTO_LOG(debug) << "[SensorService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); + + aap_protobuf::service::control::message::ChannelOpenResponse response; + const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; + response.set_status(status); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, + std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); + channel_->sendChannelOpenResponse(response, std::move(promise)); + + channel_->receive(this->shared_from_this()); + } + + void SensorService::onSensorStartRequest( + const aap_protobuf::service::sensorsource::message::SensorRequest &request) { + OPENAUTO_LOG(info) << "[SensorService] onSensorStartRequest()"; + OPENAUTO_LOG(debug) << "[SensorService] Request Type: " << request.type(); + + aap_protobuf::service::sensorsource::message::SensorStartResponseMessage response; + response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + + if (request.type() == aap_protobuf::service::sensorsource::message::SENSOR_DRIVING_STATUS_DATA) { + promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()), + std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); + } else if (request.type() == aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE) { + promise->then(std::bind(&SensorService::sendNightData, this->shared_from_this()), + std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); + } else { + promise->then([]() {}, + std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); + } + + channel_->sendSensorStartResponse(response, std::move(promise)); + channel_->receive(this->shared_from_this()); + } + + void SensorService::sendDrivingStatusUnrestricted() { + OPENAUTO_LOG(info) << "[SensorService] sendDrivingStatusUnrestricted()"; + aap_protobuf::service::sensorsource::message::SensorBatch indication; + indication.add_driving_status_data()->set_status( + aap_protobuf::service::sensorsource::message::DrivingStatus::DRIVE_STATUS_UNRESTRICTED); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, + std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); + channel_->sendSensorEventIndication(indication, std::move(promise)); + } + + void SensorService::sendNightData() { + OPENAUTO_LOG(info) << "[SensorService] sendNightData()"; + aap_protobuf::service::sensorsource::message::SensorBatch indication; + + if (SensorService::isNight) { + OPENAUTO_LOG(info) << "[SensorService] Night Mode Triggered"; + indication.add_night_mode_data()->set_night_mode(true); + } else { + OPENAUTO_LOG(info) << "[SensorService] Day Mode Triggered"; + indication.add_night_mode_data()->set_night_mode(false); + } + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, + std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); + channel_->sendSensorEventIndication(indication, std::move(promise)); + if (this->firstRun) { + this->firstRun = false; + this->previous = this->isNight; } } -} \ No newline at end of file + + void SensorService::sendGPSLocationData() { + OPENAUTO_LOG(info) << "[SensorService] sendGPSLocationData()"; + aap_protobuf::service::sensorsource::message::SensorBatch indication; + + auto *locInd = indication.add_location_data(); + + // epoch seconds + // locInd->set_timestamp(this->gpsData_.fix.time * 1e3); + // degrees + locInd->set_latitude_e7(this->gpsData_.fix.latitude * 1e7); + locInd->set_longitude_e7(this->gpsData_.fix.longitude * 1e7); + // meters + auto accuracy = sqrt(pow(this->gpsData_.fix.epx, 2) + pow(this->gpsData_.fix.epy, 2)); + locInd->set_accuracy_e3(accuracy * 1e3); + + if (this->gpsData_.set & ALTITUDE_SET) { + // meters above ellipsoid + locInd->set_altitude_e2(this->gpsData_.fix.altitude * 1e2); + } + if (this->gpsData_.set & SPEED_SET) { + // meters per second to knots + locInd->set_speed_e3(this->gpsData_.fix.speed * 1.94384 * 1e3); + } + if (this->gpsData_.set & TRACK_SET) { + // degrees + locInd->set_bearing_e6(this->gpsData_.fix.track * 1e6); + } + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, + std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1)); + channel_->sendSensorEventIndication(indication, std::move(promise)); + } + + void SensorService::sensorPolling() { + OPENAUTO_LOG(info) << "[SensorService] sensorPolling()"; + if (!this->stopPolling) { + strand_.dispatch([this, self = this->shared_from_this()]() { + this->isNight = is_file_exist("/tmp/night_mode_enabled"); + if (this->previous != this->isNight && !this->firstRun) { + this->previous = this->isNight; + this->sendNightData(); + } + + if ((this->gpsEnabled_) && + (gps_waiting(&this->gpsData_, 0)) && + (gps_read(&this->gpsData_) > 0) && + (this->gpsData_.status != STATUS_NO_FIX) && + (this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) && + (this->gpsData_.set & TIME_SET) && + (this->gpsData_.set & LATLON_SET)) { + this->sendGPSLocationData(); + } + + timer_.expires_from_now(boost::posix_time::milliseconds(250)); + timer_.async_wait(strand_.wrap(std::bind(&SensorService::sensorPolling, this->shared_from_this()))); + }); + } + } + + bool SensorService::is_file_exist(const char *fileName) { + OPENAUTO_LOG(info) << "[SensorService] is_file_exist()"; + std::ifstream ifile(fileName, std::ios::in); + return ifile.good(); + } + + void SensorService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[SensorService] onChannelError(): " << e.what(); + } +} + + + diff --git a/src/autoapp/Service/ServiceFactory.cpp b/src/autoapp/Service/ServiceFactory.cpp index 4a51dc8..aa0fac8 100644 --- a/src/autoapp/Service/ServiceFactory.cpp +++ b/src/autoapp/Service/ServiceFactory.cpp @@ -49,30 +49,28 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { +namespace f1x::openauto::autoapp::service { - ServiceFactory::ServiceFactory(boost::asio::io_service &ioService, - configuration::IConfiguration::Pointer configuration) - : ioService_(ioService), configuration_(std::move(configuration)) { + ServiceFactory::ServiceFactory(boost::asio::io_service &ioService, + configuration::IConfiguration::Pointer configuration) + : ioService_(ioService), configuration_(std::move(configuration)) { - } + } - ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messenger) { - OPENAUTO_LOG(info) << "[ServiceFactory] create()"; - ServiceList serviceList; + ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messenger) { + OPENAUTO_LOG(info) << "[ServiceFactory] create()"; + ServiceList serviceList; - this->createMediaSinkServices(serviceList, messenger); - this->createMediaSourceServices(serviceList, messenger); - serviceList.emplace_back(this->createSensorService(messenger)); - serviceList.emplace_back(this->createBluetoothService(messenger)); - serviceList.emplace_back(this->createInputService(messenger)); - //serviceList.emplace_back(this->createWifiProjectionService(messenger)); + this->createMediaSinkServices(serviceList, messenger); + this->createMediaSourceServices(serviceList, messenger); + serviceList.emplace_back(this->createSensorService(messenger)); + serviceList.emplace_back(this->createBluetoothService(messenger)); + serviceList.emplace_back(this->createInputService(messenger)); + // TODO: What is WiFi Projection Service? + //serviceList.emplace_back(this->createWifiProjectionService(messenger)); - return serviceList; - } + return serviceList; + } IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger) { OPENAUTO_LOG(info) << "[ServiceFactory] createBluetoothService()"; @@ -97,123 +95,123 @@ namespace f1x { break; } - return std::make_shared(ioService_, messenger, std::move(bluetoothDevice)); - } + return std::make_shared(ioService_, messenger, std::move(bluetoothDevice)); + } - IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger) { - OPENAUTO_LOG(info) << "[ServiceFactory] createInputService()"; - QRect videoGeometry; - switch (configuration_->getVideoResolution()) { - case aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1280x720: - OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 1280x720"; - videoGeometry = QRect(0, 0, 1280, 720); - break; - case aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1920x1080: - OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 1920x1080"; - videoGeometry = QRect(0, 0, 1920, 1080); - break; - default: - OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 800x480"; - videoGeometry = QRect(0, 0, 800, 480); - break; - } + IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger) { + OPENAUTO_LOG(info) << "[ServiceFactory] createInputService()"; + QRect videoGeometry; + switch (configuration_->getVideoResolution()) { + case aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1280x720: + OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 1280x720"; + videoGeometry = QRect(0, 0, 1280, 720); + break; + case aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1920x1080: + OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 1920x1080"; + videoGeometry = QRect(0, 0, 1920, 1080); + break; + default: + OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 800x480"; + videoGeometry = QRect(0, 0, 800, 480); + break; + } - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry(); - projection::IInputDevice::Pointer inputDevice( - std::make_shared(*QApplication::instance(), configuration_, - std::move(screenGeometry), std::move(videoGeometry))); + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry(); + projection::IInputDevice::Pointer inputDevice( + std::make_shared(*QApplication::instance(), configuration_, + std::move(screenGeometry), std::move(videoGeometry))); - return std::make_shared(ioService_, messenger, std::move(inputDevice)); - } + return std::make_shared(ioService_, messenger, std::move(inputDevice)); + } - void ServiceFactory::createMediaSinkServices(ServiceList &serviceList, - aasdk::messenger::IMessenger::Pointer messenger) { - OPENAUTO_LOG(info) << "[ServiceFactory] createMediaSinkServices()"; - if (configuration_->musicAudioChannelEnabled()) { - OPENAUTO_LOG(info) << "[ServiceFactory] Media Audio Channel enabled"; - auto mediaAudioOutput = - configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? - std::make_shared(2, 16, 48000) : - projection::IAudioOutput::Pointer(new projection::QtAudioOutput(2, 16, 48000), - std::bind(&QObject::deleteLater, std::placeholders::_1)); + void ServiceFactory::createMediaSinkServices(ServiceList &serviceList, + aasdk::messenger::IMessenger::Pointer messenger) { + OPENAUTO_LOG(info) << "[ServiceFactory] createMediaSinkServices()"; + if (configuration_->musicAudioChannelEnabled()) { + OPENAUTO_LOG(info) << "[ServiceFactory] Media Audio Channel enabled"; + auto mediaAudioOutput = + configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? + std::make_shared(2, 16, 48000) : + projection::IAudioOutput::Pointer(new projection::QtAudioOutput(2, 16, 48000), + std::bind(&QObject::deleteLater, std::placeholders::_1)); - serviceList.emplace_back( - std::make_shared(ioService_, messenger, std::move(mediaAudioOutput))); - } + serviceList.emplace_back( + std::make_shared(ioService_, messenger, std::move(mediaAudioOutput))); + } - if (configuration_->guidanceAudioChannelEnabled()) { - OPENAUTO_LOG(info) << "[ServiceFactory] Guidance Audio Channel enabled"; - auto guidanceAudioOutput = - configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? - std::make_shared(1, 16, 16000) : - projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), - std::bind(&QObject::deleteLater, std::placeholders::_1)); + if (configuration_->guidanceAudioChannelEnabled()) { + OPENAUTO_LOG(info) << "[ServiceFactory] Guidance Audio Channel enabled"; + auto guidanceAudioOutput = + configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? + std::make_shared(1, 16, 16000) : + projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), + std::bind(&QObject::deleteLater, std::placeholders::_1)); - serviceList.emplace_back( - std::make_shared(ioService_, messenger, - std::move(guidanceAudioOutput))); - } + serviceList.emplace_back( + std::make_shared(ioService_, messenger, + std::move(guidanceAudioOutput))); + } - if (configuration_->telephonyAudioChannelEnabled()) { - OPENAUTO_LOG(info) << "[ServiceFactory] Telephony Audio Channel enabled"; - auto telephonyAudioOutput = - configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? - std::make_shared(1, 16, 16000) : - projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), - std::bind(&QObject::deleteLater, std::placeholders::_1)); + if (configuration_->telephonyAudioChannelEnabled()) { + OPENAUTO_LOG(info) << "[ServiceFactory] Telephony Audio Channel enabled"; + auto telephonyAudioOutput = + configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? + std::make_shared(1, 16, 16000) : + projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), + std::bind(&QObject::deleteLater, std::placeholders::_1)); - serviceList.emplace_back( - std::make_shared(ioService_, messenger, - std::move(telephonyAudioOutput))); - } + serviceList.emplace_back( + std::make_shared(ioService_, messenger, + std::move(telephonyAudioOutput))); + } - /* - * No Need to Check for systemAudioChannelEnabled - MUST be enabled by default. - */ + /* + * No Need to Check for systemAudioChannelEnabled - MUST be enabled by default. + */ - OPENAUTO_LOG(info) << "[ServiceFactory] System Audio Channel enabled"; - auto systemAudioOutput = - configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? - std::make_shared(1, 16, 16000) : - projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), - std::bind(&QObject::deleteLater, std::placeholders::_1)); + OPENAUTO_LOG(info) << "[ServiceFactory] System Audio Channel enabled"; + auto systemAudioOutput = + configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? + std::make_shared(1, 16, 16000) : + projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), + std::bind(&QObject::deleteLater, std::placeholders::_1)); - serviceList.emplace_back( - std::make_shared(ioService_, messenger, std::move(systemAudioOutput))); + serviceList.emplace_back( + std::make_shared(ioService_, messenger, std::move(systemAudioOutput))); #ifdef USE_OMX - auto videoOutput(std::make_shared(configuration_)); + auto videoOutput(std::make_shared(configuration_)); #else - projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_), - std::bind(&QObject::deleteLater, std::placeholders::_1)); + projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_), + std::bind(&QObject::deleteLater, std::placeholders::_1)); #endif - OPENAUTO_LOG(info) << "[ServiceFactory] Video Channel enabled"; - serviceList.emplace_back( - std::make_shared(ioService_, messenger, std::move(videoOutput))); - } - - void ServiceFactory::createMediaSourceServices(f1x::openauto::autoapp::service::ServiceList &serviceList, - aasdk::messenger::IMessenger::Pointer messenger) { - OPENAUTO_LOG(info) << "[ServiceFactory] createMediaSourceServices()"; - projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000), - std::bind(&QObject::deleteLater, std::placeholders::_1)); - serviceList.emplace_back(std::make_shared(ioService_, messenger, - std::move(audioInput))); - } - - IService::Pointer ServiceFactory::createSensorService(aasdk::messenger::IMessenger::Pointer messenger) { - OPENAUTO_LOG(info) << "[ServiceFactory] createSensorService()"; - return std::make_shared(ioService_, messenger); - } - - IService::Pointer ServiceFactory::createWifiProjectionService(aasdk::messenger::IMessenger::Pointer messenger) { - OPENAUTO_LOG(info) << "[ServiceFactory] createWifiProjectionService()"; - return std::make_shared(ioService_, messenger); - } - - } - } + OPENAUTO_LOG(info) << "[ServiceFactory] Video Channel enabled"; + serviceList.emplace_back( + std::make_shared(ioService_, messenger, std::move(videoOutput))); } + + void ServiceFactory::createMediaSourceServices(f1x::openauto::autoapp::service::ServiceList &serviceList, + aasdk::messenger::IMessenger::Pointer messenger) { + OPENAUTO_LOG(info) << "[ServiceFactory] createMediaSourceServices()"; + projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000), + std::bind(&QObject::deleteLater, std::placeholders::_1)); + serviceList.emplace_back(std::make_shared(ioService_, messenger, + std::move(audioInput))); + } + + IService::Pointer ServiceFactory::createSensorService(aasdk::messenger::IMessenger::Pointer messenger) { + OPENAUTO_LOG(info) << "[ServiceFactory] createSensorService()"; + return std::make_shared(ioService_, messenger); + } + + IService::Pointer ServiceFactory::createWifiProjectionService(aasdk::messenger::IMessenger::Pointer messenger) { + OPENAUTO_LOG(info) << "[ServiceFactory] createWifiProjectionService()"; + return std::make_shared(ioService_, messenger); + } + } + + + diff --git a/src/autoapp/Service/VendorExtension/VendorExtensionService.cpp b/src/autoapp/Service/VendorExtension/VendorExtensionService.cpp index a6b8ca9..333eb13 100644 --- a/src/autoapp/Service/VendorExtension/VendorExtensionService.cpp +++ b/src/autoapp/Service/VendorExtension/VendorExtensionService.cpp @@ -21,74 +21,72 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace vendorextension { +namespace f1x::openauto::autoapp::service::vendorextension { - VendorExtensionService::VendorExtensionService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger) - : strand_(ioService), - timer_(ioService), - channel_(std::make_shared(strand_, std::move(messenger))) { + VendorExtensionService::VendorExtensionService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger) + : strand_(ioService), + timer_(ioService), + channel_( + std::make_shared(strand_, std::move(messenger))) { - } - - void VendorExtensionService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[VendorExtensionService] start()"; - }); - } - - void VendorExtensionService::stop() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[VendorExtensionService] stop()"; - }); - } - - void VendorExtensionService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[VendorExtensionService] pause()"; - }); - } - - void VendorExtensionService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[VendorExtensionService] resume()"; - }); - } - - void VendorExtensionService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[VendorExtensionService] fillFeatures()"; - - auto *service = response.add_channels(); - service->set_id(static_cast(channel_->getId())); - - auto *vendorExtension = service->mutable_vendor_extension_service(); - } - - void VendorExtensionService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[VendorExtensionService] onChannelError(): " << e.what(); - } - - void VendorExtensionService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[VendorExtensionService] onChannelOpenRequest()"; - OPENAUTO_LOG(info) << "[VendorExtensionService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); - - aap_protobuf::service::control::message::ChannelOpenResponse response; - const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; - response.set_status(status); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&VendorExtensionService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendChannelOpenResponse(response, std::move(promise)); - channel_->receive(this->shared_from_this()); - } - } - } - } } -} \ No newline at end of file + + void VendorExtensionService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[VendorExtensionService] start()"; + }); + } + + void VendorExtensionService::stop() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[VendorExtensionService] stop()"; + }); + } + + void VendorExtensionService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[VendorExtensionService] pause()"; + }); + } + + void VendorExtensionService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[VendorExtensionService] resume()"; + }); + } + + void VendorExtensionService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[VendorExtensionService] fillFeatures()"; + + auto *service = response.add_channels(); + service->set_id(static_cast(channel_->getId())); + + auto *vendorExtension = service->mutable_vendor_extension_service(); + } + + void VendorExtensionService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[VendorExtensionService] onChannelError(): " << e.what(); + } + + void VendorExtensionService::onChannelOpenRequest( + const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[VendorExtensionService] onChannelOpenRequest()"; + OPENAUTO_LOG(info) << "[VendorExtensionService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); + + aap_protobuf::service::control::message::ChannelOpenResponse response; + const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; + response.set_status(status); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&VendorExtensionService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendChannelOpenResponse(response, std::move(promise)); + channel_->receive(this->shared_from_this()); + } +} + + + diff --git a/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp b/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp index d4956c3..080a898 100644 --- a/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp +++ b/src/autoapp/Service/WifiProjection/WifiProjectionService.cpp @@ -22,97 +22,97 @@ #include #include -namespace f1x { - namespace openauto { - namespace autoapp { - namespace service { - namespace wifiprojection { - WifiProjectionService::WifiProjectionService(boost::asio::io_service &ioService, - aasdk::messenger::IMessenger::Pointer messenger) - : strand_(ioService), - timer_(ioService), - channel_(std::make_shared(strand_, std::move(messenger))) { - } +namespace f1x::openauto::autoapp::service::wifiprojection { + WifiProjectionService::WifiProjectionService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger) + : strand_(ioService), + timer_(ioService), + channel_( + std::make_shared(strand_, std::move(messenger))) { - void WifiProjectionService::start() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[WifiProjectionService] start()"; - }); - } - - void WifiProjectionService::stop() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[WifiProjectionService] stop()"; - }); - } - - void WifiProjectionService::pause() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[WifiProjectionService] pause()"; - }); - } - - void WifiProjectionService::resume() { - strand_.dispatch([this, self = this->shared_from_this()]() { - OPENAUTO_LOG(info) << "[WifiProjectionService] resume()"; - }); - } - - void WifiProjectionService::fillFeatures( - aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { - OPENAUTO_LOG(info) << "[WifiProjectionService] fillFeatures()"; - - auto *service = response.add_channels(); - service->set_id(static_cast(channel_->getId())); - - auto *wifiChannel = service->mutable_wifi_projection_service(); - wifiChannel->set_car_wifi_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString()); - } - - void WifiProjectionService::onWifiCredentialsRequest( - const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) { - - OPENAUTO_LOG(info) << "[WifiProjectionService] onWifiCredentialsRequest()"; - - aap_protobuf::service::wifiprojection::message::WifiCredentialsResponse response; - - response.set_access_point_type(aap_protobuf::service::wifiprojection::message::AccessPointType::STATIC); - response.set_car_wifi_ssid("CRANKSHAFT-NG"); - response.set_car_wifi_password("1234567890"); - response.set_car_wifi_security_mode(aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_PERSONAL); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&WifiProjectionService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendWifiCredentialsResponse(response, std::move(promise)); - channel_->receive(this->shared_from_this()); - - } - - void WifiProjectionService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) { - OPENAUTO_LOG(info) << "[WifiProjectionService] onChannelOpenRequest()"; - OPENAUTO_LOG(debug) << "[WifiProjectionService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); - - aap_protobuf::service::control::message::ChannelOpenResponse response; - const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; - response.set_status(status); - - auto promise = aasdk::channel::SendPromise::defer(strand_); - promise->then([]() {}, std::bind(&WifiProjectionService::onChannelError, this->shared_from_this(), - std::placeholders::_1)); - channel_->sendChannelOpenResponse(response, std::move(promise)); - - channel_->receive(this->shared_from_this()); - } - - void WifiProjectionService::onChannelError(const aasdk::error::Error &e) { - OPENAUTO_LOG(error) << "[WifiProjectionService] onChannelError(): " << e.what(); - } - - - } - } - } } -} \ No newline at end of file + + void WifiProjectionService::start() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[WifiProjectionService] start()"; + }); + } + + void WifiProjectionService::stop() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[WifiProjectionService] stop()"; + }); + } + + void WifiProjectionService::pause() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[WifiProjectionService] pause()"; + }); + } + + void WifiProjectionService::resume() { + strand_.dispatch([this, self = this->shared_from_this()]() { + OPENAUTO_LOG(info) << "[WifiProjectionService] resume()"; + }); + } + + void WifiProjectionService::fillFeatures( + aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) { + OPENAUTO_LOG(info) << "[WifiProjectionService] fillFeatures()"; + + auto *service = response.add_channels(); + service->set_id(static_cast(channel_->getId())); + + auto *wifiChannel = service->mutable_wifi_projection_service(); + wifiChannel->set_car_wifi_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString()); + } + + void WifiProjectionService::onWifiCredentialsRequest( + const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) { + + OPENAUTO_LOG(info) << "[WifiProjectionService] onWifiCredentialsRequest()"; + + aap_protobuf::service::wifiprojection::message::WifiCredentialsResponse response; + + response.set_access_point_type(aap_protobuf::service::wifiprojection::message::AccessPointType::STATIC); + response.set_car_wifi_ssid("CRANKSHAFT-NG"); + response.set_car_wifi_password("1234567890"); + response.set_car_wifi_security_mode( + aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_PERSONAL); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&WifiProjectionService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendWifiCredentialsResponse(response, std::move(promise)); + channel_->receive(this->shared_from_this()); + + } + + void WifiProjectionService::onChannelOpenRequest( + const aap_protobuf::service::control::message::ChannelOpenRequest &request) { + OPENAUTO_LOG(info) << "[WifiProjectionService] onChannelOpenRequest()"; + OPENAUTO_LOG(debug) << "[WifiProjectionService] Channel Id: " << request.service_id() << ", Priority: " + << request.priority(); + + aap_protobuf::service::control::message::ChannelOpenResponse response; + const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; + response.set_status(status); + + auto promise = aasdk::channel::SendPromise::defer(strand_); + promise->then([]() {}, std::bind(&WifiProjectionService::onChannelError, this->shared_from_this(), + std::placeholders::_1)); + channel_->sendChannelOpenResponse(response, std::move(promise)); + + channel_->receive(this->shared_from_this()); + } + + void WifiProjectionService::onChannelError(const aasdk::error::Error &e) { + OPENAUTO_LOG(error) << "[WifiProjectionService] onChannelError(): " << e.what(); + } + + +} + + + diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index f07a0b3..d7840a6 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -15,34 +15,39 @@ * You should have received a copy of the GNU General Public License * along with openauto. If not, see . */ - -#include +#include +#include #include -#include "ui_settingswindow.h" // AutoGenerated at Compile Time +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include #include -#include -#include #include +#include +#include +#include +#include "ui_settingswindow.h" // AutoGenerated at Compile Time #ifdef MAC_OS + #include #include #include #include #include #include + #endif -namespace f1x { - namespace openauto { - namespace autoapp { - namespace ui { + +namespace f1x::openauto::autoapp::ui { SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent) : QWidget(parent), ui_(new Ui::SettingsWindow), configuration_(std::move(configuration)) { @@ -100,101 +105,101 @@ namespace f1x { connect(ui_->pushButtonSambaStop, &QPushButton::clicked, [&]() { system("/usr/local/bin/crankshaft samba stop &"); }); - // menu - ui_->tab1->show(); - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); + // menu + ui_->tab1->show(); + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); ui_->horizontalGroupBox->hide(); ui_->labelBluetoothAdapterAddress->hide(); ui_->lineEditExternalBluetoothAdapterAddress->hide(); ui_->labelTestInProgress->hide(); - connect(ui_->pushButtonTab1, &QPushButton::clicked, this, &SettingsWindow::show_tab1); - connect(ui_->pushButtonTab2, &QPushButton::clicked, this, &SettingsWindow::show_tab2); - connect(ui_->pushButtonTab3, &QPushButton::clicked, this, &SettingsWindow::show_tab3); - connect(ui_->pushButtonTab4, &QPushButton::clicked, this, &SettingsWindow::show_tab4); - connect(ui_->pushButtonTab5, &QPushButton::clicked, this, &SettingsWindow::show_tab5); - connect(ui_->pushButtonTab5, &QPushButton::clicked, this, &SettingsWindow::updateNetworkInfo); - connect(ui_->pushButtonTab6, &QPushButton::clicked, this, &SettingsWindow::show_tab6); - connect(ui_->pushButtonTab6, &QPushButton::clicked, this, &SettingsWindow::updateSystemInfo); - connect(ui_->pushButtonTab7, &QPushButton::clicked, this, &SettingsWindow::show_tab7); - connect(ui_->pushButtonTab8, &QPushButton::clicked, this, &SettingsWindow::show_tab8); - connect(ui_->pushButtonTab9, &QPushButton::clicked, this, &SettingsWindow::show_tab9); + connect(ui_->pushButtonTab1, &QPushButton::clicked, this, &SettingsWindow::show_tab1); + connect(ui_->pushButtonTab2, &QPushButton::clicked, this, &SettingsWindow::show_tab2); + connect(ui_->pushButtonTab3, &QPushButton::clicked, this, &SettingsWindow::show_tab3); + connect(ui_->pushButtonTab4, &QPushButton::clicked, this, &SettingsWindow::show_tab4); + connect(ui_->pushButtonTab5, &QPushButton::clicked, this, &SettingsWindow::show_tab5); + connect(ui_->pushButtonTab5, &QPushButton::clicked, this, &SettingsWindow::updateNetworkInfo); + connect(ui_->pushButtonTab6, &QPushButton::clicked, this, &SettingsWindow::show_tab6); + connect(ui_->pushButtonTab6, &QPushButton::clicked, this, &SettingsWindow::updateSystemInfo); + connect(ui_->pushButtonTab7, &QPushButton::clicked, this, &SettingsWindow::show_tab7); + connect(ui_->pushButtonTab8, &QPushButton::clicked, this, &SettingsWindow::show_tab8); + connect(ui_->pushButtonTab9, &QPushButton::clicked, this, &SettingsWindow::show_tab9); - QTime time = QTime::currentTime(); - QString time_text_hour = time.toString("hh"); - QString time_text_minute = time.toString("mm"); - ui_->spinBoxHour->setValue((time_text_hour).toInt()); - ui_->spinBoxMinute->setValue((time_text_minute).toInt()); - ui_->label_modeswitchprogress->setText("Ok"); - ui_->label_notavailable->hide(); + QTime time = QTime::currentTime(); + QString time_text_hour = time.toString("hh"); + QString time_text_minute = time.toString("mm"); + ui_->spinBoxHour->setValue((time_text_hour).toInt()); + ui_->spinBoxMinute->setValue((time_text_minute).toInt()); + ui_->label_modeswitchprogress->setText("Ok"); + ui_->label_notavailable->hide(); - QString wifi_ssid = configuration_->getCSValue("WIFI_SSID"); - QString wifi2_ssid = configuration_->getCSValue("WIFI2_SSID"); + QString wifi_ssid = configuration_->getCSValue("WIFI_SSID"); + QString wifi2_ssid = configuration_->getCSValue("WIFI2_SSID"); - ui_->pushButtonNetwork0->setText(wifi_ssid); - ui_->pushButtonNetwork1->setText(wifi2_ssid); + ui_->pushButtonNetwork0->setText(wifi_ssid); + ui_->pushButtonNetwork1->setText(wifi2_ssid); - if (!std::ifstream("/boot/crankshaft/network1.conf")) { - ui_->pushButtonNetwork1->hide(); - ui_->pushButtonNetwork0->show(); - } - if (!std::ifstream("/boot/crankshaft/network0.conf")) { - ui_->pushButtonNetwork1->hide(); - ui_->pushButtonNetwork0->setText(configuration_->getCSValue("WIFI2_SSID")); - } - if (!std::ifstream("/boot/crankshaft/network0.conf") && !std::ifstream("/boot/crankshaft/network1.conf")) { - ui_->pushButtonNetwork0->hide(); - ui_->pushButtonNetwork1->hide(); - ui_->pushButtonNetworkAuto->hide(); - ui_->label_notavailable->show(); - } + if (!std::ifstream("/boot/crankshaft/network1.conf")) { + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetwork0->show(); + } + if (!std::ifstream("/boot/crankshaft/network0.conf")) { + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetwork0->setText(configuration_->getCSValue("WIFI2_SSID")); + } + if (!std::ifstream("/boot/crankshaft/network0.conf") && !std::ifstream("/boot/crankshaft/network1.conf")) { + ui_->pushButtonNetwork0->hide(); + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetworkAuto->hide(); + ui_->label_notavailable->show(); + } - if (std::ifstream("/tmp/hotspot_active")) { - ui_->radioButtonClient->setChecked(0); - ui_->radioButtonHotspot->setChecked(1); - ui_->lineEditWifiSSID->setText(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf", "ssid")); - ui_->lineEditPassword->show(); - ui_->label_password->show(); - ui_->lineEditPassword->setText("1234567890"); - ui_->clientNetworkSelect->hide(); - ui_->label_notavailable->show(); - } else { - ui_->radioButtonClient->setChecked(1); - ui_->radioButtonHotspot->setChecked(0); - ui_->lineEditWifiSSID->setText(configuration_->readFileContent("/tmp/wifi_ssid")); - ui_->lineEditPassword->hide(); - ui_->label_password->hide(); - ui_->lineEditPassword->setText(""); - ui_->clientNetworkSelect->hide(); - ui_->label_notavailable->show(); - } + if (std::ifstream("/tmp/hotspot_active")) { + ui_->radioButtonClient->setChecked(0); + ui_->radioButtonHotspot->setChecked(1); + ui_->lineEditWifiSSID->setText(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf", "ssid")); + ui_->lineEditPassword->show(); + ui_->label_password->show(); + ui_->lineEditPassword->setText("1234567890"); + ui_->clientNetworkSelect->hide(); + ui_->label_notavailable->show(); + } else { + ui_->radioButtonClient->setChecked(1); + ui_->radioButtonHotspot->setChecked(0); + ui_->lineEditWifiSSID->setText(configuration_->readFileContent("/tmp/wifi_ssid")); + ui_->lineEditPassword->hide(); + ui_->label_password->hide(); + ui_->lineEditPassword->setText(""); + ui_->clientNetworkSelect->hide(); + ui_->label_notavailable->show(); + } - if (std::ifstream("/tmp/samba_running")) { - ui_->labelSambaStatus->setText("running"); - ui_->pushButtonSambaStart->hide(); - ui_->pushButtonSambaStop->show(); - } else { - ui_->labelSambaStatus->setText("stopped"); - ui_->pushButtonSambaStop->hide(); - ui_->pushButtonSambaStart->show(); - } + if (std::ifstream("/tmp/samba_running")) { + ui_->labelSambaStatus->setText("running"); + ui_->pushButtonSambaStart->hide(); + ui_->pushButtonSambaStop->show(); + } else { + ui_->labelSambaStatus->setText("stopped"); + ui_->pushButtonSambaStop->hide(); + ui_->pushButtonSambaStart->show(); + } - QTimer *refresh = new QTimer(this); - connect(refresh, SIGNAL(timeout()), this, SLOT(updateInfo())); - refresh->start(5000); - } + QTimer *refresh = new QTimer(this); + connect(refresh, SIGNAL(timeout()), this, SLOT(updateInfo())); + refresh->start(5000); + } - SettingsWindow::~SettingsWindow() { - delete ui_; - } + SettingsWindow::~SettingsWindow() { + delete ui_; + } void SettingsWindow::updateInfo() { if (ui_->tab6->isVisible() == true) { @@ -205,61 +210,57 @@ namespace f1x { } } - void SettingsWindow::onSave() { - configuration_->setHandednessOfTrafficType( - ui_->radioButtonLeftHandDrive->isChecked() ? configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE - : configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE); + void SettingsWindow::onSave() { + configuration_->setHandednessOfTrafficType( + ui_->radioButtonLeftHandDrive->isChecked() ? configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE + : configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE); - configuration_->showClock(ui_->checkBoxShowClock->isChecked()); - configuration_->showBigClock(ui_->checkBoxShowBigClock->isChecked()); - configuration_->oldGUI(ui_->checkBoxOldGUI->isChecked()); - configuration_->setAlphaTrans(static_cast(ui_->horizontalSliderAlphaTrans->value())); - configuration_->hideMenuToggle(ui_->checkBoxHideMenuToggle->isChecked()); - configuration_->showLux(ui_->checkBoxShowLux->isChecked()); - configuration_->showCursor(ui_->checkBoxShowCursor->isChecked()); - configuration_->hideBrightnessControl(ui_->checkBoxHideBrightnessControl->isChecked()); - configuration_->showNetworkinfo(ui_->checkBoxNetworkinfo->isChecked()); - configuration_->mp3AutoPlay(ui_->checkBoxAutoPlay->isChecked()); - configuration_->showAutoPlay(ui_->checkBoxShowPlayer->isChecked()); - configuration_->instantPlay(ui_->checkBoxInstantPlay->isChecked()); - configuration_->hideWarning(ui_->checkBoxDontShowAgain->isChecked()); + configuration_->showClock(ui_->checkBoxShowClock->isChecked()); + configuration_->showBigClock(ui_->checkBoxShowBigClock->isChecked()); + configuration_->oldGUI(ui_->checkBoxOldGUI->isChecked()); + configuration_->setAlphaTrans(static_cast(ui_->horizontalSliderAlphaTrans->value())); + configuration_->hideMenuToggle(ui_->checkBoxHideMenuToggle->isChecked()); + configuration_->showLux(ui_->checkBoxShowLux->isChecked()); + configuration_->showCursor(ui_->checkBoxShowCursor->isChecked()); + configuration_->hideBrightnessControl(ui_->checkBoxHideBrightnessControl->isChecked()); + configuration_->showNetworkinfo(ui_->checkBoxNetworkinfo->isChecked()); + configuration_->mp3AutoPlay(ui_->checkBoxAutoPlay->isChecked()); + configuration_->showAutoPlay(ui_->checkBoxShowPlayer->isChecked()); + configuration_->instantPlay(ui_->checkBoxInstantPlay->isChecked()); + configuration_->hideWarning(ui_->checkBoxDontShowAgain->isChecked()); - configuration_->setVideoFPS(ui_->radioButton30FPS->isChecked() - ? aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_30 - : aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_60); + configuration_->setVideoFPS(ui_->radioButton30FPS->isChecked() + ? aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_30 + : aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_60); - if (ui_->radioButton480p->isChecked()) { - configuration_->setVideoResolution( - aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_800x480); - } else if (ui_->radioButton720p->isChecked()) { - configuration_->setVideoResolution( - aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1280x720); - } else if (ui_->radioButton1080p->isChecked()) { - configuration_->setVideoResolution( - aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1920x1080); - } + if (ui_->radioButton480p->isChecked()) { + configuration_->setVideoResolution( + aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_800x480); + } else if (ui_->radioButton720p->isChecked()) { + configuration_->setVideoResolution( + aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1280x720); + } else if (ui_->radioButton1080p->isChecked()) { + configuration_->setVideoResolution( + aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1920x1080); + } - configuration_->setScreenDPI(static_cast(ui_->horizontalSliderScreenDPI->value())); - configuration_->setOMXLayerIndex(ui_->spinBoxOmxLayerIndex->value()); + configuration_->setScreenDPI(static_cast(ui_->horizontalSliderScreenDPI->value())); + configuration_->setOMXLayerIndex(ui_->spinBoxOmxLayerIndex->value()); - QRect videoMargins(0, 0, ui_->spinBoxVideoMarginWidth->value(), ui_->spinBoxVideoMarginHeight->value()); - configuration_->setVideoMargins(std::move(videoMargins)); + QRect videoMargins(0, 0, ui_->spinBoxVideoMarginWidth->value(), ui_->spinBoxVideoMarginHeight->value()); + configuration_->setVideoMargins(std::move(videoMargins)); - configuration_->setTouchscreenEnabled(ui_->checkBoxEnableTouchscreen->isChecked()); - this->saveButtonCheckBoxes(); + configuration_->setTouchscreenEnabled(ui_->checkBoxEnableTouchscreen->isChecked()); + this->saveButtonCheckBoxes(); - configuration_->playerButtonControl(ui_->checkBoxPlayerControl->isChecked()); + configuration_->playerButtonControl(ui_->checkBoxPlayerControl->isChecked()); - if (ui_->radioButtonDisableBluetooth->isChecked()) { - configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::NONE); - } else if (ui_->radioButtonUseLocalBluetoothAdapter->isChecked()) { - configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::LOCAL); - } else if (ui_->radioButtonUseExternalBluetoothAdapter->isChecked()) { - configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::REMOTE); - } - - configuration_->setBluetoothRemoteAdapterAddress( - ui_->lineEditExternalBluetoothAdapterAddress->text().toStdString()); + if (ui_->comboBoxBluetooth->currentText() == "none") { + configuration_->setBluetoothAdapterAddress(""); // or any string that indicates no adapter + } else { + configuration_->setBluetoothAdapterAddress( + ui_->comboBoxBluetooth->currentData().toString().toStdString()); + } configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->isChecked()); configuration_->setGuidanceAudioChannelEnabled(ui_->checkBoxSpeechAudioChannel->isChecked()); @@ -267,273 +268,278 @@ namespace f1x { configuration_->setAudioOutputBackendType( ui_->radioButtonRtAudio->isChecked() ? configuration::AudioOutputBackendType::RTAUDIO : configuration::AudioOutputBackendType::QT); + configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->isChecked()); + configuration_->setGuidanceAudioChannelEnabled(ui_->checkBoxSpeechAudioChannel->isChecked()); + configuration_->setAudioOutputBackendType( + ui_->radioButtonRtAudio->isChecked() ? configuration::AudioOutputBackendType::RTAUDIO + : configuration::AudioOutputBackendType::QT); - configuration_->save(); + configuration_->save(); - // generate param string for autoapp_helper - std::string params; - params.append(std::to_string(ui_->horizontalSliderSystemVolume->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderSystemCapture->value())); - params.append("#"); - params.append(std::to_string(ui_->spinBoxDisconnect->value())); - params.append("#"); - params.append(std::to_string(ui_->spinBoxShutdown->value())); - params.append("#"); - params.append(std::to_string(ui_->spinBoxDay->value())); - params.append("#"); - params.append(std::to_string(ui_->spinBoxNight->value())); - params.append("#"); - if (ui_->checkBoxGPIO->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append(std::string(ui_->comboBoxDevMode->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxInvert->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxX11->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxRearcam->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxAndroid->currentText().toStdString())); - params.append("#"); - if (ui_->radioButtonX11->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - if (ui_->radioButtonScreenRotated->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append( - std::string("'") + std::string(ui_->comboBoxPulseOutput->currentText().toStdString()) + std::string("'")); - params.append("#"); - params.append( - std::string("'") + std::string(ui_->comboBoxPulseInput->currentText().toStdString()) + std::string("'")); - params.append("#"); - params.append(std::string(ui_->comboBoxHardwareRTC->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxTZ->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxHardwareDAC->currentText().toStdString())); - params.append("#"); - if (ui_->checkBoxDisableShutdown->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - if (ui_->checkBoxDisableScreenOff->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - if (ui_->radioButtonDebugmodeEnabled->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append(std::string(ui_->comboBoxGPIOShutdown->currentText().toStdString())); - params.append("#"); - params.append(std::to_string(ui_->spinBoxGPIOShutdownDelay->value())); - params.append("#"); - if (ui_->checkBoxHotspot->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append(std::string(ui_->comboBoxCam->currentText().toStdString())); - params.append("#"); - if (ui_->checkBoxBluetoothAutoPair->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append(std::string(ui_->comboBoxBluetooth->currentText().toStdString())); - params.append("#"); - if (ui_->checkBoxHardwareSave->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append(std::string(ui_->comboBoxUSBCam->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxLS->currentText().split(" ")[0].toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxDayNight->currentText().toStdString())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderDay->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderNight->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderLux1->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderBrightness1->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderLux2->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderBrightness2->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderLux3->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderBrightness3->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderLux4->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderBrightness4->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderLux5->value())); - params.append("#"); - params.append(std::to_string(ui_->horizontalSliderBrightness5->value())); - params.append("#"); - params.append(std::string(ui_->comboBoxCheckInterval->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxNightmodeStep->currentText().toStdString())); - params.append("#"); - if (ui_->checkBoxDisableDayNightRTC->isChecked()) { - params.append("0"); - } else { - params.append("1"); - } - params.append("#"); - if (ui_->radioButtonAnimatedCSNG->isChecked()) { - params.append("0"); - } else if (ui_->radioButtonCSNG->isChecked()) { - params.append("1"); - } else if (ui_->radioButtonCustom->isChecked()) { - params.append("2"); - } - params.append("#"); - params.append( - std::string(ui_->comboBoxCountryCode->currentText().split("|")[0].replace(" ", "").toStdString())); - params.append("#"); - if (ui_->checkBoxBlankOnly->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - if (ui_->checkBoxFlipX->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - if (ui_->checkBoxFlipY->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append(std::string(ui_->comboBoxRotation->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxResolution->currentText().toStdString())); - params.append("#"); - params.append(std::string((ui_->comboBoxFPS->currentText()).replace(" (not @1080)", "").toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxAWB->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxEXP->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxLoopTime->currentText().toStdString())); - params.append("#"); - params.append(std::string(ui_->comboBoxLoopCount->currentText().toStdString())); - params.append("#"); - if (ui_->checkBoxAutoRecording->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - if (ui_->checkBoxFlipXUSB->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - if (ui_->checkBoxFlipYUSB->isChecked()) { - params.append("1"); - } else { - params.append("0"); - } - params.append("#"); - params.append(std::string(ui_->comboBoxUSBRotation->currentText().replace("180", "1").toStdString())); - params.append("#"); - system((std::string("/usr/local/bin/autoapp_helper setparams#") + std::string(params) + - std::string(" &")).c_str()); + // generate param string for autoapp_helper + std::string params; + params.append(std::to_string(ui_->horizontalSliderSystemVolume->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderSystemCapture->value())); + params.append("#"); + params.append(std::to_string(ui_->spinBoxDisconnect->value())); + params.append("#"); + params.append(std::to_string(ui_->spinBoxShutdown->value())); + params.append("#"); + params.append(std::to_string(ui_->spinBoxDay->value())); + params.append("#"); + params.append(std::to_string(ui_->spinBoxNight->value())); + params.append("#"); + if (ui_->checkBoxGPIO->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append(std::string(ui_->comboBoxDevMode->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxInvert->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxX11->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxRearcam->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxAndroid->currentText().toStdString())); + params.append("#"); + if (ui_->radioButtonX11->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->radioButtonScreenRotated->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append( + std::string("'") + std::string(ui_->comboBoxPulseOutput->currentText().toStdString()) + std::string("'")); + params.append("#"); + params.append( + std::string("'") + std::string(ui_->comboBoxPulseInput->currentText().toStdString()) + std::string("'")); + params.append("#"); + params.append(std::string(ui_->comboBoxHardwareRTC->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxTZ->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxHardwareDAC->currentText().toStdString())); + params.append("#"); + if (ui_->checkBoxDisableShutdown->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->checkBoxDisableScreenOff->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->radioButtonDebugmodeEnabled->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append(std::string(ui_->comboBoxGPIOShutdown->currentText().toStdString())); + params.append("#"); + params.append(std::to_string(ui_->spinBoxGPIOShutdownDelay->value())); + params.append("#"); + if (ui_->checkBoxHotspot->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append(std::string(ui_->comboBoxCam->currentText().toStdString())); + params.append("#"); + if (ui_->checkBoxBluetoothAutoPair->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append(std::string(ui_->comboBoxBluetooth->currentText().toStdString())); + params.append("#"); + if (ui_->checkBoxHardwareSave->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append(std::string(ui_->comboBoxUSBCam->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxLS->currentText().split(" ")[0].toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxDayNight->currentText().toStdString())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderDay->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderNight->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderLux1->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderBrightness1->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderLux2->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderBrightness2->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderLux3->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderBrightness3->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderLux4->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderBrightness4->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderLux5->value())); + params.append("#"); + params.append(std::to_string(ui_->horizontalSliderBrightness5->value())); + params.append("#"); + params.append(std::string(ui_->comboBoxCheckInterval->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxNightmodeStep->currentText().toStdString())); + params.append("#"); + if (ui_->checkBoxDisableDayNightRTC->isChecked()) { + params.append("0"); + } else { + params.append("1"); + } + params.append("#"); + if (ui_->radioButtonAnimatedCSNG->isChecked()) { + params.append("0"); + } else if (ui_->radioButtonCSNG->isChecked()) { + params.append("1"); + } else if (ui_->radioButtonCustom->isChecked()) { + params.append("2"); + } + params.append("#"); + params.append( + std::string(ui_->comboBoxCountryCode->currentText().split("|")[0].replace(" ", "").toStdString())); + params.append("#"); + if (ui_->checkBoxBlankOnly->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->checkBoxFlipX->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->checkBoxFlipY->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append(std::string(ui_->comboBoxRotation->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxResolution->currentText().toStdString())); + params.append("#"); + params.append(std::string((ui_->comboBoxFPS->currentText()).replace(" (not @1080)", "").toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxAWB->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxEXP->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxLoopTime->currentText().toStdString())); + params.append("#"); + params.append(std::string(ui_->comboBoxLoopCount->currentText().toStdString())); + params.append("#"); + if (ui_->checkBoxAutoRecording->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->checkBoxFlipXUSB->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->checkBoxFlipYUSB->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append(std::string(ui_->comboBoxUSBRotation->currentText().replace("180", "1").toStdString())); + params.append("#"); + system((std::string("/usr/local/bin/autoapp_helper setparams#") + std::string(params) + + std::string(" &")).c_str()); - this->close(); - } + this->close(); + } - void SettingsWindow::onResetToDefaults() { - QMessageBox confirmationMessage(QMessageBox::Question, "Confirmation", - "Are you sure you want to reset settings?", - QMessageBox::Yes | QMessageBox::Cancel); - //confirmationMessage.setWindowFlags(Qt::WindowStaysOnTopHint); - if (confirmationMessage.exec() == QMessageBox::Yes) { - configuration_->reset(); - this->load(); - } - } + void SettingsWindow::onResetToDefaults() { + QMessageBox confirmationMessage(QMessageBox::Question, "Confirmation", + "Are you sure you want to reset settings?", + QMessageBox::Yes | QMessageBox::Cancel); + //confirmationMessage.setWindowFlags(Qt::WindowStaysOnTopHint); + if (confirmationMessage.exec() == QMessageBox::Yes) { + configuration_->reset(); + this->load(); + } + } - void SettingsWindow::showEvent(QShowEvent *event) { - QWidget::showEvent(event); - this->load(); - } + void SettingsWindow::showEvent(QShowEvent *event) { + QWidget::showEvent(event); + this->load(); + } - void SettingsWindow::load() { - ui_->radioButtonLeftHandDrive->setChecked( - configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE); - ui_->radioButtonRightHandDrive->setChecked( - configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE); - ui_->checkBoxShowClock->setChecked(configuration_->showClock()); - ui_->horizontalSliderAlphaTrans->setValue(static_cast(configuration_->getAlphaTrans())); + void SettingsWindow::load() { + ui_->radioButtonLeftHandDrive->setChecked( + configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE); + ui_->radioButtonRightHandDrive->setChecked( + configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE); + ui_->checkBoxShowClock->setChecked(configuration_->showClock()); + ui_->horizontalSliderAlphaTrans->setValue(static_cast(configuration_->getAlphaTrans())); - ui_->checkBoxShowBigClock->setChecked(configuration_->showBigClock()); - ui_->checkBoxOldGUI->setChecked(configuration_->oldGUI()); - ui_->checkBoxHideMenuToggle->setChecked(configuration_->hideMenuToggle()); - ui_->checkBoxShowLux->setChecked(configuration_->showLux()); - ui_->checkBoxShowCursor->setChecked(configuration_->showCursor()); - ui_->checkBoxHideBrightnessControl->setChecked(configuration_->hideBrightnessControl()); - ui_->checkBoxNetworkinfo->setChecked(configuration_->showNetworkinfo()); - ui_->checkBoxAutoPlay->setChecked(configuration_->mp3AutoPlay()); - ui_->checkBoxShowPlayer->setChecked(configuration_->showAutoPlay()); - ui_->checkBoxInstantPlay->setChecked(configuration_->instantPlay()); - ui_->checkBoxDontShowAgain->setChecked(configuration_->hideWarning()); + ui_->checkBoxShowBigClock->setChecked(configuration_->showBigClock()); + ui_->checkBoxOldGUI->setChecked(configuration_->oldGUI()); + ui_->checkBoxHideMenuToggle->setChecked(configuration_->hideMenuToggle()); + ui_->checkBoxShowLux->setChecked(configuration_->showLux()); + ui_->checkBoxShowCursor->setChecked(configuration_->showCursor()); + ui_->checkBoxHideBrightnessControl->setChecked(configuration_->hideBrightnessControl()); + ui_->checkBoxNetworkinfo->setChecked(configuration_->showNetworkinfo()); + ui_->checkBoxAutoPlay->setChecked(configuration_->mp3AutoPlay()); + ui_->checkBoxShowPlayer->setChecked(configuration_->showAutoPlay()); + ui_->checkBoxInstantPlay->setChecked(configuration_->instantPlay()); + ui_->checkBoxDontShowAgain->setChecked(configuration_->hideWarning()); - ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == - aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_30); - ui_->radioButton60FPS->setChecked(configuration_->getVideoFPS() == - aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_60); + ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == + aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_30); + ui_->radioButton60FPS->setChecked(configuration_->getVideoFPS() == + aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_60); - ui_->radioButton480p->setChecked(configuration_->getVideoResolution() == - aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_800x480); - ui_->radioButton720p->setChecked(configuration_->getVideoResolution() == - aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1280x720); - ui_->radioButton1080p->setChecked(configuration_->getVideoResolution() == - aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1920x1080); - ui_->horizontalSliderScreenDPI->setValue(static_cast(configuration_->getScreenDPI())); - ui_->spinBoxOmxLayerIndex->setValue(configuration_->getOMXLayerIndex()); + ui_->radioButton480p->setChecked(configuration_->getVideoResolution() == + aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_800x480); + ui_->radioButton720p->setChecked(configuration_->getVideoResolution() == + aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1280x720); + ui_->radioButton1080p->setChecked(configuration_->getVideoResolution() == + aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1920x1080); + ui_->horizontalSliderScreenDPI->setValue(static_cast(configuration_->getScreenDPI())); + ui_->spinBoxOmxLayerIndex->setValue(configuration_->getOMXLayerIndex()); - const auto &videoMargins = configuration_->getVideoMargins(); - ui_->spinBoxVideoMarginWidth->setValue(videoMargins.width()); - ui_->spinBoxVideoMarginHeight->setValue(videoMargins.height()); + const auto &videoMargins = configuration_->getVideoMargins(); + ui_->spinBoxVideoMarginWidth->setValue(videoMargins.width()); + ui_->spinBoxVideoMarginHeight->setValue(videoMargins.height()); - ui_->checkBoxEnableTouchscreen->setChecked(configuration_->getTouchscreenEnabled()); - this->loadButtonCheckBoxes(); - ui_->checkBoxPlayerControl->setChecked(configuration_->playerButtonControl()); + ui_->checkBoxEnableTouchscreen->setChecked(configuration_->getTouchscreenEnabled()); + this->loadButtonCheckBoxes(); + ui_->checkBoxPlayerControl->setChecked(configuration_->playerButtonControl()); ui_->radioButtonDisableBluetooth->setChecked( configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::NONE); @@ -550,541 +556,543 @@ namespace f1x { ui_->checkBoxSpeechAudioChannel->setChecked(configuration_->guidanceAudioChannelEnabled()); ui_->telephonyAudioChannelEnabled->setChecked(configuration_->guidanceAudioChannelEnabled()); - const auto &audioOutputBackendType = configuration_->getAudioOutputBackendType(); - ui_->radioButtonRtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::RTAUDIO); - ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::QT); + const auto &audioOutputBackendType = configuration_->getAudioOutputBackendType(); + ui_->radioButtonRtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::RTAUDIO); + ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::QT); - ui_->checkBoxHardwareSave->setChecked(false); - QStorageInfo storage("/media/USBDRIVES/CSSTORAGE"); - storage.refresh(); - if (storage.isValid() && storage.isReady()) { - if (storage.isReadOnly()) { - ui_->labelStorage->setText("Storage is read only! (" + storage.device() + - ") - This can be caused by demaged filesystem on CSSTORAGE. Try a reboot."); - } else { - ui_->labelStorage->setText( - "Device: " + storage.device() + " Label: " + storage.displayName() + " Total: " + - QString::number(storage.bytesTotal() / 1024 / 1024 / 1024) + "GB Free: " + - QString::number(storage.bytesFree() / 1024 / 1024 / 1024) + "GB (" + storage.fileSystemType() + ")"); - } - } else { - ui_->labelStorage->setText("Storage is not ready or missing!"); - } - } + ui_->checkBoxHardwareSave->setChecked(false); + QStorageInfo storage("/media/USBDRIVES/CSSTORAGE"); + storage.refresh(); + if (storage.isValid() && storage.isReady()) { + if (storage.isReadOnly()) { + ui_->labelStorage->setText("Storage is read only! (" + storage.device() + + ") - This can be caused by demaged filesystem on CSSTORAGE. Try a reboot."); + } else { + ui_->labelStorage->setText( + "Device: " + storage.device() + " Label: " + storage.displayName() + " Total: " + + QString::number(storage.bytesTotal() / 1024 / 1024 / 1024) + "GB Free: " + + QString::number(storage.bytesFree() / 1024 / 1024 / 1024) + "GB (" + storage.fileSystemType() + ")"); + } + } else { + ui_->labelStorage->setText("Storage is not ready or missing!"); + } + } - void SettingsWindow::loadButtonCheckBoxes() { - const auto &buttonCodes = configuration_->getButtonCodes(); - ui_->checkBoxPlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY) != + void SettingsWindow::loadButtonCheckBoxes() { + const auto &buttonCodes = configuration_->getButtonCodes(); + ui_->checkBoxPlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY) != + buttonCodes.end()); + ui_->checkBoxPauseButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PAUSE) != + buttonCodes.end()); + ui_->checkBoxTogglePlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE) != buttonCodes.end()); - ui_->checkBoxPauseButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PAUSE) != - buttonCodes.end()); - ui_->checkBoxTogglePlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE) != - buttonCodes.end()); - ui_->checkBoxNextTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_NEXT) != - buttonCodes.end()); - ui_->checkBoxPreviousTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PREVIOUS) != - buttonCodes.end()); - ui_->checkBoxHomeButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_HOME) != - buttonCodes.end()); - ui_->checkBoxPhoneButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_CALL) != - buttonCodes.end()); - ui_->checkBoxCallEndButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ENDCALL) != - buttonCodes.end()); - ui_->checkBoxVoiceCommandButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_SEARCH) != - buttonCodes.end()); - ui_->checkBoxLeftButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_LEFT) != - buttonCodes.end()); - ui_->checkBoxRightButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_RIGHT) != - buttonCodes.end()); - ui_->checkBoxUpButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_UP) != - buttonCodes.end()); - ui_->checkBoxDownButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_DOWN) != - buttonCodes.end()); - ui_->checkBoxScrollWheelButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER) != - buttonCodes.end()); - ui_->checkBoxBackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_BACK) != - buttonCodes.end()); - ui_->checkBoxEnterButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_CENTER) != - buttonCodes.end()); - ui_->checkBoxNavButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_NAVIGATION) != + ui_->checkBoxNextTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_NEXT) != buttonCodes.end()); + ui_->checkBoxPreviousTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PREVIOUS) != + buttonCodes.end()); + ui_->checkBoxHomeButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_HOME) != + buttonCodes.end()); + ui_->checkBoxPhoneButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_CALL) != + buttonCodes.end()); + ui_->checkBoxCallEndButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ENDCALL) != + buttonCodes.end()); + ui_->checkBoxVoiceCommandButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_SEARCH) != + buttonCodes.end()); + ui_->checkBoxLeftButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_LEFT) != + buttonCodes.end()); + ui_->checkBoxRightButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_RIGHT) != + buttonCodes.end()); + ui_->checkBoxUpButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_UP) != + buttonCodes.end()); + ui_->checkBoxDownButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_DOWN) != + buttonCodes.end()); + ui_->checkBoxScrollWheelButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER) != + buttonCodes.end()); + ui_->checkBoxBackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_BACK) != + buttonCodes.end()); + ui_->checkBoxEnterButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_CENTER) != + buttonCodes.end()); + ui_->checkBoxNavButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_NAVIGATION) != + buttonCodes.end()); + } + + void SettingsWindow::setButtonCheckBoxes(bool value) { + ui_->checkBoxPlayButton->setChecked(value); + ui_->checkBoxPauseButton->setChecked(value); + ui_->checkBoxTogglePlayButton->setChecked(value); + ui_->checkBoxNextTrackButton->setChecked(value); + ui_->checkBoxPreviousTrackButton->setChecked(value); + ui_->checkBoxHomeButton->setChecked(value); + ui_->checkBoxPhoneButton->setChecked(value); + ui_->checkBoxCallEndButton->setChecked(value); + ui_->checkBoxVoiceCommandButton->setChecked(value); + ui_->checkBoxLeftButton->setChecked(value); + ui_->checkBoxRightButton->setChecked(value); + ui_->checkBoxUpButton->setChecked(value); + ui_->checkBoxDownButton->setChecked(value); + ui_->checkBoxScrollWheelButton->setChecked(value); + ui_->checkBoxBackButton->setChecked(value); + ui_->checkBoxEnterButton->setChecked(value); + ui_->checkBoxNavButton->setChecked(value); + } + + void SettingsWindow::saveButtonCheckBoxes() { + configuration::IConfiguration::ButtonCodes buttonCodes; + this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY); + this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PAUSE); + this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE); + this->saveButtonCheckBox(ui_->checkBoxNextTrackButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_NEXT); + this->saveButtonCheckBox(ui_->checkBoxPreviousTrackButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PREVIOUS); + this->saveButtonCheckBox(ui_->checkBoxHomeButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_HOME); + this->saveButtonCheckBox(ui_->checkBoxPhoneButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_CALL); + this->saveButtonCheckBox(ui_->checkBoxCallEndButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ENDCALL); + this->saveButtonCheckBox(ui_->checkBoxVoiceCommandButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_SEARCH); + this->saveButtonCheckBox(ui_->checkBoxLeftButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_LEFT); + this->saveButtonCheckBox(ui_->checkBoxRightButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_RIGHT); + this->saveButtonCheckBox(ui_->checkBoxUpButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_UP); + this->saveButtonCheckBox(ui_->checkBoxDownButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_DOWN); + this->saveButtonCheckBox(ui_->checkBoxScrollWheelButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER); + this->saveButtonCheckBox(ui_->checkBoxBackButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_BACK); + this->saveButtonCheckBox(ui_->checkBoxEnterButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_CENTER); + this->saveButtonCheckBox(ui_->checkBoxNavButton, buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_NAVIGATION); + configuration_->setButtonCodes(buttonCodes); + } + + void SettingsWindow::saveButtonCheckBox(const QCheckBox *checkBox, + configuration::IConfiguration::ButtonCodes &buttonCodes, + aap_protobuf::service::media::sink::message::KeyCode buttonCode) { + if (checkBox->isChecked()) { + buttonCodes.push_back(buttonCode); + } + } + + void SettingsWindow::onUpdateScreenDPI(int value) { + ui_->labelScreenDPIValue->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateAlphaTrans(int value) { + double alpha = value / 100.0; + ui_->labelAlphaTransValue->setText(QString::number(alpha)); + } + + void SettingsWindow::onUpdateBrightnessDay(int value) { + ui_->labelBrightnessDay->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateBrightnessNight(int value) { + ui_->labelBrightnessNight->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateSystemVolume(int value) { + ui_->labelSystemVolumeValue->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateSystemCapture(int value) { + ui_->labelSystemCaptureValue->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateLux1(int value) { + ui_->valueLux1->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateLux2(int value) { + ui_->valueLux2->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateLux3(int value) { + ui_->valueLux3->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateLux4(int value) { + ui_->valueLux4->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateLux5(int value) { + ui_->valueLux5->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateBrightness1(int value) { + ui_->valueBrightness1->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateBrightness2(int value) { + ui_->valueBrightness2->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateBrightness3(int value) { + ui_->valueBrightness3->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateBrightness4(int value) { + ui_->valueBrightness4->setText(QString::number(value)); + } + + void SettingsWindow::onUpdateBrightness5(int value) { + ui_->valueBrightness5->setText(QString::number(value)); + } + + void SettingsWindow::unpairAll() { + system("/usr/local/bin/crankshaft bluetooth unpair &"); + } + + void SettingsWindow::setTime() { + // generate param string for autoapp_helper + std::string params; + params.append(std::to_string(ui_->spinBoxHour->value())); + params.append("#"); + params.append(std::to_string(ui_->spinBoxMinute->value())); + params.append("#"); + system((std::string("/usr/local/bin/autoapp_helper settime#") + std::string(params) + + std::string(" &")).c_str()); + } + + void SettingsWindow::syncNTPTime() { + system("/usr/local/bin/crankshaft rtc sync &"); + } + + void SettingsWindow::loadSystemValues() { + // set brightness slider attribs + ui_->horizontalSliderDay->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderDay->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderDay->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderDay->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderDay->setValue(configuration_->getCSValue("BR_DAY").toInt()); + + ui_->horizontalSliderNight->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderNight->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderNight->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderNight->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderNight->setValue(configuration_->getCSValue("BR_NIGHT").toInt()); + + ui_->horizontalSliderBrightness1->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness1->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness1->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness1->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + + ui_->horizontalSliderBrightness2->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness2->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness2->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness2->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + + ui_->horizontalSliderBrightness3->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness3->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness3->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness3->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + + ui_->horizontalSliderBrightness4->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness4->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness4->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness4->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + + ui_->horizontalSliderBrightness5->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness5->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness5->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness5->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + + // set tsl2561 slider attribs + ui_->horizontalSliderLux1->setValue(configuration_->getCSValue("LUX_LEVEL_1").toInt()); + ui_->horizontalSliderBrightness1->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_1").toInt()); + ui_->horizontalSliderLux2->setValue(configuration_->getCSValue("LUX_LEVEL_2").toInt()); + ui_->horizontalSliderBrightness2->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_2").toInt()); + ui_->horizontalSliderLux3->setValue(configuration_->getCSValue("LUX_LEVEL_3").toInt()); + ui_->horizontalSliderBrightness3->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_3").toInt()); + ui_->horizontalSliderLux4->setValue(configuration_->getCSValue("LUX_LEVEL_4").toInt()); + ui_->horizontalSliderBrightness4->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_4").toInt()); + ui_->horizontalSliderLux5->setValue(configuration_->getCSValue("LUX_LEVEL_5").toInt()); + ui_->horizontalSliderBrightness5->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_5").toInt()); + ui_->comboBoxCheckInterval->setCurrentText(configuration_->getCSValue("TSL2561_CHECK_INTERVAL")); + ui_->comboBoxNightmodeStep->setCurrentText(configuration_->getCSValue("TSL2561_DAYNIGHT_ON_STEP")); + + if (std::ifstream("/tmp/return_value")) { + QString return_values = configuration_->readFileContent("/tmp/return_value"); + QStringList getparams = return_values.split("#"); + + // version string + ui_->valueSystemVersion->setText(configuration_->readFileContent("/etc/crankshaft.build")); + // date string + ui_->valueSystemBuildDate->setText(configuration_->readFileContent("/etc/crankshaft.date")); + // set volume + ui_->labelSystemVolumeValue->setText(configuration_->readFileContent("/boot/crankshaft/volume")); + ui_->horizontalSliderSystemVolume->setValue( + configuration_->readFileContent("/boot/crankshaft/volume").toInt()); + // set cap volume + ui_->labelSystemCaptureValue->setText(configuration_->readFileContent("/boot/crankshaft/capvolume")); + ui_->horizontalSliderSystemCapture->setValue( + configuration_->readFileContent("/boot/crankshaft/capvolume").toInt()); + // set shutdown + ui_->valueShutdownTimer->setText("- - -"); + ui_->spinBoxShutdown->setValue(configuration_->getCSValue("DISCONNECTION_POWEROFF_MINS").toInt()); + // set disconnect + ui_->valueDisconnectTimer->setText("- - -"); + ui_->spinBoxDisconnect->setValue(configuration_->getCSValue("DISCONNECTION_SCREEN_POWEROFF_SECS").toInt()); + // set day/night + ui_->spinBoxDay->setValue(configuration_->getCSValue("RTC_DAY_START").toInt()); + ui_->spinBoxNight->setValue(configuration_->getCSValue("RTC_NIGHT_START").toInt()); + // set gpios + if (configuration_->getCSValue("ENABLE_GPIO") == "1") { + ui_->checkBoxGPIO->setChecked(true); + } else { + ui_->checkBoxGPIO->setChecked(false); + } + ui_->comboBoxDevMode->setCurrentText(configuration_->getCSValue("DEV_PIN")); + ui_->comboBoxInvert->setCurrentText(configuration_->getCSValue("INVERT_PIN")); + ui_->comboBoxX11->setCurrentText(configuration_->getCSValue("X11_PIN")); + ui_->comboBoxRearcam->setCurrentText(configuration_->getCSValue("REARCAM_PIN")); + ui_->comboBoxAndroid->setCurrentText(configuration_->getCSValue("ANDROID_PIN")); + // set mode + if (configuration_->getCSValue("START_X11") == "0") { + ui_->radioButtonEGL->setChecked(true); + } else { + ui_->radioButtonX11->setChecked(true); + } + // set rotation + if (configuration_->getCSValue("FLIP_SCREEN") == "0") { + ui_->radioButtonScreenNormal->setChecked(true); + } else { + ui_->radioButtonScreenRotated->setChecked(true); + } + + populateBluetoothComboBox(ui_->comboBoxBluetooth); + + if (std::ifstream("/tmp/get_inputs")) { + QFile inputsFile(QString("/tmp/get_inputs")); + inputsFile.open(QIODevice::ReadOnly); + QTextStream data_return(&inputsFile); + QStringList inputs = data_return.readAll().split("\n"); + inputsFile.close(); + int cleaner = ui_->comboBoxPulseInput->count(); + while (cleaner > -1) { + ui_->comboBoxPulseInput->removeItem(cleaner); + cleaner--; } - - void SettingsWindow::setButtonCheckBoxes(bool value) { - ui_->checkBoxPlayButton->setChecked(value); - ui_->checkBoxPauseButton->setChecked(value); - ui_->checkBoxTogglePlayButton->setChecked(value); - ui_->checkBoxNextTrackButton->setChecked(value); - ui_->checkBoxPreviousTrackButton->setChecked(value); - ui_->checkBoxHomeButton->setChecked(value); - ui_->checkBoxPhoneButton->setChecked(value); - ui_->checkBoxCallEndButton->setChecked(value); - ui_->checkBoxVoiceCommandButton->setChecked(value); - ui_->checkBoxLeftButton->setChecked(value); - ui_->checkBoxRightButton->setChecked(value); - ui_->checkBoxUpButton->setChecked(value); - ui_->checkBoxDownButton->setChecked(value); - ui_->checkBoxScrollWheelButton->setChecked(value); - ui_->checkBoxBackButton->setChecked(value); - ui_->checkBoxEnterButton->setChecked(value); - ui_->checkBoxNavButton->setChecked(value); + int indexin = inputs.count(); + int countin = 0; + while (countin < indexin - 1) { + ui_->comboBoxPulseInput->addItem(inputs[countin]); + countin++; } + } - void SettingsWindow::saveButtonCheckBoxes() { - configuration::IConfiguration::ButtonCodes buttonCodes; - this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY); - this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PAUSE); - this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE); - this->saveButtonCheckBox(ui_->checkBoxNextTrackButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_NEXT); - this->saveButtonCheckBox(ui_->checkBoxPreviousTrackButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PREVIOUS); - this->saveButtonCheckBox(ui_->checkBoxHomeButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_HOME); - this->saveButtonCheckBox(ui_->checkBoxPhoneButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_CALL); - this->saveButtonCheckBox(ui_->checkBoxCallEndButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ENDCALL); - this->saveButtonCheckBox(ui_->checkBoxVoiceCommandButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_SEARCH); - this->saveButtonCheckBox(ui_->checkBoxLeftButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_LEFT); - this->saveButtonCheckBox(ui_->checkBoxRightButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_RIGHT); - this->saveButtonCheckBox(ui_->checkBoxUpButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_UP); - this->saveButtonCheckBox(ui_->checkBoxDownButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_DOWN); - this->saveButtonCheckBox(ui_->checkBoxScrollWheelButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER); - this->saveButtonCheckBox(ui_->checkBoxBackButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_BACK); - this->saveButtonCheckBox(ui_->checkBoxEnterButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_CENTER); - this->saveButtonCheckBox(ui_->checkBoxNavButton, buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_NAVIGATION); - configuration_->setButtonCodes(buttonCodes); + if (std::ifstream("/tmp/get_outputs")) { + QFile outputsFile(QString("/tmp/get_outputs")); + outputsFile.open(QIODevice::ReadOnly); + QTextStream data_return(&outputsFile); + QStringList outputs = data_return.readAll().split("\n"); + outputsFile.close(); + int cleaner = ui_->comboBoxPulseOutput->count(); + while (cleaner > -1) { + ui_->comboBoxPulseOutput->removeItem(cleaner); + cleaner--; } - - void SettingsWindow::saveButtonCheckBox(const QCheckBox *checkBox, - configuration::IConfiguration::ButtonCodes &buttonCodes, - aap_protobuf::service::media::sink::message::KeyCode buttonCode) { - if (checkBox->isChecked()) { - buttonCodes.push_back(buttonCode); - } + int indexout = outputs.count(); + int countout = 0; + while (countout < indexout - 1) { + ui_->comboBoxPulseOutput->addItem(outputs[countout]); + countout++; } + } - void SettingsWindow::onUpdateScreenDPI(int value) { - ui_->labelScreenDPIValue->setText(QString::number(value)); + ui_->comboBoxPulseOutput->setCurrentText(configuration_->readFileContent("/tmp/get_default_output")); + ui_->comboBoxPulseInput->setCurrentText(configuration_->readFileContent("/tmp/get_default_input")); + + if (std::ifstream("/tmp/timezone_listing")) { + QFile zoneFile(QString("/tmp/timezone_listing")); + zoneFile.open(QIODevice::ReadOnly); + QTextStream data_return(&zoneFile); + QStringList zones = data_return.readAll().split("\n"); + zoneFile.close(); + int cleaner = ui_->comboBoxTZ->count(); + while (cleaner > 0) { + ui_->comboBoxTZ->removeItem(cleaner); + cleaner--; } - - void SettingsWindow::onUpdateAlphaTrans(int value) { - double alpha = value / 100.0; - ui_->labelAlphaTransValue->setText(QString::number(alpha)); + int indexout = zones.count(); + int countzone = 0; + while (countzone < indexout - 1) { + ui_->comboBoxTZ->addItem(zones[countzone]); + countzone++; } + } - void SettingsWindow::onUpdateBrightnessDay(int value) { - ui_->labelBrightnessDay->setText(QString::number(value)); - } + // set rtc + QString rtcstring = configuration_->getParamFromFile("/boot/config.txt", "dtoverlay=i2c-rtc"); + if (rtcstring != "") { + QStringList rtc = rtcstring.split(","); + ui_->comboBoxHardwareRTC->setCurrentText(rtc[1].trimmed()); + // set timezone + ui_->comboBoxTZ->setCurrentText(configuration_->readFileContent("/etc/timezone")); + } else { + ui_->comboBoxHardwareRTC->setCurrentText("none"); + ui_->comboBoxTZ->setCurrentText(configuration_->readFileContent("/etc/timezone")); + } - void SettingsWindow::onUpdateBrightnessNight(int value) { - ui_->labelBrightnessNight->setText(QString::number(value)); - } + // set dac + QString dac = "Custom"; + if (getparams[4] == "allo-boss-dac-pcm512x-audio") { + dac = "Allo - Boss"; + } + if (getparams[4] == "allo-piano-dac-pcm512x-audio") { + dac = "Allo - Piano"; + } + if (getparams[4] == "iqaudio-dacplus") { + dac = "IQaudIO - Pi-DAC Plus/Pro/Zero"; + } + if (getparams[4] == "iqaudio-dacplus,unmute_amp") { + dac = "IQaudIO - Pi-Digi Amp Plus"; + } + if (getparams[4] == "iqaudio-dacplus,auto_mute_amp") { + dac = "IQaudIO - Pi-Digi Amp Plus - Automute"; + } + if (getparams[4] == "iqaudio-digi-wm8804-audio") { + dac = "IQaudIO - Pi-Digi Plus"; + } + if (getparams[4] == "audioinjector-wm8731-audio") { + dac = "Audioinjector - Zero/Stereo"; + } + if (getparams[4] == "hifiberry-dac") { + dac = "Hifiberry - DAC"; + } + if (getparams[4] == "hifiberry-dacplus") { + dac = "Hifiberry - DAC Plus"; + } + if (getparams[4] == "hifiberry-digi") { + dac = "Hifiberry - Digi"; + } + if (getparams[4] == "hifiberry-digi-pro") { + dac = "Hifiberry - Digi Pro"; + } + if (getparams[4] == "hifiberry-amp") { + dac = "Hifiberry - DAC Amp"; + } + if (getparams[4] == "audio") { + dac = "Raspberry Pi - Onboard"; + } + ui_->comboBoxHardwareDAC->setCurrentText(dac); - void SettingsWindow::onUpdateSystemVolume(int value) { - ui_->labelSystemVolumeValue->setText(QString::number(value)); - } + // set shutdown disable + if (configuration_->getCSValue("DISCONNECTION_POWEROFF_DISABLE") == "1") { + ui_->checkBoxDisableShutdown->setChecked(true); + } else { + ui_->checkBoxDisableShutdown->setChecked(false); + } - void SettingsWindow::onUpdateSystemCapture(int value) { - ui_->labelSystemCaptureValue->setText(QString::number(value)); - } + // set screen off disable + if (configuration_->getCSValue("DISCONNECTION_SCREEN_POWEROFF_DISABLE") == "1") { + ui_->checkBoxDisableScreenOff->setChecked(true); + } else { + ui_->checkBoxDisableScreenOff->setChecked(false); + } - void SettingsWindow::onUpdateLux1(int value) { - ui_->valueLux1->setText(QString::number(value)); - } + // set custom brightness command + if (configuration_->getCSValue("CUSTOM_BRIGHTNESS_COMMAND") != "") { + ui_->labelCustomBrightnessCommand->setText( + configuration_->getCSValue("CUSTOM_BRIGHTNESS_COMMAND") + " brvalue"); + } else { + ui_->labelCustomBrightnessCommand->setText("Disabled"); + } - void SettingsWindow::onUpdateLux2(int value) { - ui_->valueLux2->setText(QString::number(value)); - } + // set debug mode + if (configuration_->getCSValue("DEBUG_MODE") == "1") { + ui_->radioButtonDebugmodeEnabled->setChecked(true); + } else { + ui_->radioButtonDebugmodeDisabled->setChecked(true); + } - void SettingsWindow::onUpdateLux3(int value) { - ui_->valueLux3->setText(QString::number(value)); - } + // GPIO based shutdown + ui_->comboBoxGPIOShutdown->setCurrentText(configuration_->getCSValue("IGNITION_PIN")); + ui_->spinBoxGPIOShutdownDelay->setValue(configuration_->getCSValue("IGNITION_DELAY").toInt()); - void SettingsWindow::onUpdateLux4(int value) { - ui_->valueLux4->setText(QString::number(value)); - } + // Wifi Hotspot + if (configuration_->getCSValue("ENABLE_HOTSPOT") == "1") { + ui_->checkBoxHotspot->setChecked(true); + } else { + ui_->checkBoxHotspot->setChecked(false); + } - void SettingsWindow::onUpdateLux5(int value) { - ui_->valueLux5->setText(QString::number(value)); - } + // set cam + if (configuration_->getParamFromFile("/boot/config.txt", "start_x") == "1") { + ui_->comboBoxCam->setCurrentText("enabled"); + } else { + ui_->comboBoxCam->setCurrentText("disabled"); + } + if (configuration_->getCSValue("RPICAM_HFLIP") == "1") { + ui_->checkBoxFlipX->setChecked(true); + } else { + ui_->checkBoxFlipX->setChecked(false); + } + if (configuration_->getCSValue("RPICAM_VFLIP") == "1") { + ui_->checkBoxFlipY->setChecked(true); + } else { + ui_->checkBoxFlipY->setChecked(false); + } + ui_->comboBoxRotation->setCurrentText(configuration_->getCSValue("RPICAM_ROTATION")); + ui_->comboBoxResolution->setCurrentText(configuration_->getCSValue("RPICAM_RESOLUTION")); + ui_->comboBoxFPS->setCurrentText(configuration_->getCSValue("RPICAM_FPS")); + ui_->comboBoxAWB->setCurrentText(configuration_->getCSValue("RPICAM_AWB")); + ui_->comboBoxEXP->setCurrentText(configuration_->getCSValue("RPICAM_EXP")); + ui_->comboBoxLoopTime->setCurrentText(configuration_->getCSValue("RPICAM_LOOPTIME")); + ui_->comboBoxLoopCount->setCurrentText(configuration_->getCSValue("RPICAM_LOOPCOUNT")); - void SettingsWindow::onUpdateBrightness1(int value) { - ui_->valueBrightness1->setText(QString::number(value)); - } + if (configuration_->getCSValue("RPICAM_AUTORECORDING") == "1") { + ui_->checkBoxAutoRecording->setChecked(true); + } else { + ui_->checkBoxAutoRecording->setChecked(false); + } - void SettingsWindow::onUpdateBrightness2(int value) { - ui_->valueBrightness2->setText(QString::number(value)); - } - - void SettingsWindow::onUpdateBrightness3(int value) { - ui_->valueBrightness3->setText(QString::number(value)); - } - - void SettingsWindow::onUpdateBrightness4(int value) { - ui_->valueBrightness4->setText(QString::number(value)); - } - - void SettingsWindow::onUpdateBrightness5(int value) { - ui_->valueBrightness5->setText(QString::number(value)); - } - - void SettingsWindow::unpairAll() { - system("/usr/local/bin/crankshaft bluetooth unpair &"); - } - - void SettingsWindow::setTime() { - // generate param string for autoapp_helper - std::string params; - params.append(std::to_string(ui_->spinBoxHour->value())); - params.append("#"); - params.append(std::to_string(ui_->spinBoxMinute->value())); - params.append("#"); - system((std::string("/usr/local/bin/autoapp_helper settime#") + std::string(params) + - std::string(" &")).c_str()); - } - - void SettingsWindow::syncNTPTime() { - system("/usr/local/bin/crankshaft rtc sync &"); - } - - void SettingsWindow::loadSystemValues() { - // set brightness slider attribs - ui_->horizontalSliderDay->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); - ui_->horizontalSliderDay->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); - ui_->horizontalSliderDay->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderDay->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderDay->setValue(configuration_->getCSValue("BR_DAY").toInt()); - - ui_->horizontalSliderNight->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); - ui_->horizontalSliderNight->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); - ui_->horizontalSliderNight->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderNight->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderNight->setValue(configuration_->getCSValue("BR_NIGHT").toInt()); - - ui_->horizontalSliderBrightness1->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); - ui_->horizontalSliderBrightness1->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); - ui_->horizontalSliderBrightness1->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness1->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - - ui_->horizontalSliderBrightness2->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); - ui_->horizontalSliderBrightness2->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); - ui_->horizontalSliderBrightness2->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness2->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - - ui_->horizontalSliderBrightness3->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); - ui_->horizontalSliderBrightness3->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); - ui_->horizontalSliderBrightness3->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness3->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - - ui_->horizontalSliderBrightness4->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); - ui_->horizontalSliderBrightness4->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); - ui_->horizontalSliderBrightness4->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness4->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - - ui_->horizontalSliderBrightness5->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); - ui_->horizontalSliderBrightness5->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); - ui_->horizontalSliderBrightness5->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness5->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - - // set tsl2561 slider attribs - ui_->horizontalSliderLux1->setValue(configuration_->getCSValue("LUX_LEVEL_1").toInt()); - ui_->horizontalSliderBrightness1->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_1").toInt()); - ui_->horizontalSliderLux2->setValue(configuration_->getCSValue("LUX_LEVEL_2").toInt()); - ui_->horizontalSliderBrightness2->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_2").toInt()); - ui_->horizontalSliderLux3->setValue(configuration_->getCSValue("LUX_LEVEL_3").toInt()); - ui_->horizontalSliderBrightness3->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_3").toInt()); - ui_->horizontalSliderLux4->setValue(configuration_->getCSValue("LUX_LEVEL_4").toInt()); - ui_->horizontalSliderBrightness4->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_4").toInt()); - ui_->horizontalSliderLux5->setValue(configuration_->getCSValue("LUX_LEVEL_5").toInt()); - ui_->horizontalSliderBrightness5->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_5").toInt()); - ui_->comboBoxCheckInterval->setCurrentText(configuration_->getCSValue("TSL2561_CHECK_INTERVAL")); - ui_->comboBoxNightmodeStep->setCurrentText(configuration_->getCSValue("TSL2561_DAYNIGHT_ON_STEP")); - - if (std::ifstream("/tmp/return_value")) { - QString return_values = configuration_->readFileContent("/tmp/return_value"); - QStringList getparams = return_values.split("#"); - - // version string - ui_->valueSystemVersion->setText(configuration_->readFileContent("/etc/crankshaft.build")); - // date string - ui_->valueSystemBuildDate->setText(configuration_->readFileContent("/etc/crankshaft.date")); - // set volume - ui_->labelSystemVolumeValue->setText(configuration_->readFileContent("/boot/crankshaft/volume")); - ui_->horizontalSliderSystemVolume->setValue( - configuration_->readFileContent("/boot/crankshaft/volume").toInt()); - // set cap volume - ui_->labelSystemCaptureValue->setText(configuration_->readFileContent("/boot/crankshaft/capvolume")); - ui_->horizontalSliderSystemCapture->setValue( - configuration_->readFileContent("/boot/crankshaft/capvolume").toInt()); - // set shutdown - ui_->valueShutdownTimer->setText("- - -"); - ui_->spinBoxShutdown->setValue(configuration_->getCSValue("DISCONNECTION_POWEROFF_MINS").toInt()); - // set disconnect - ui_->valueDisconnectTimer->setText("- - -"); - ui_->spinBoxDisconnect->setValue(configuration_->getCSValue("DISCONNECTION_SCREEN_POWEROFF_SECS").toInt()); - // set day/night - ui_->spinBoxDay->setValue(configuration_->getCSValue("RTC_DAY_START").toInt()); - ui_->spinBoxNight->setValue(configuration_->getCSValue("RTC_NIGHT_START").toInt()); - // set gpios - if (configuration_->getCSValue("ENABLE_GPIO") == "1") { - ui_->checkBoxGPIO->setChecked(true); - } else { - ui_->checkBoxGPIO->setChecked(false); - } - ui_->comboBoxDevMode->setCurrentText(configuration_->getCSValue("DEV_PIN")); - ui_->comboBoxInvert->setCurrentText(configuration_->getCSValue("INVERT_PIN")); - ui_->comboBoxX11->setCurrentText(configuration_->getCSValue("X11_PIN")); - ui_->comboBoxRearcam->setCurrentText(configuration_->getCSValue("REARCAM_PIN")); - ui_->comboBoxAndroid->setCurrentText(configuration_->getCSValue("ANDROID_PIN")); - // set mode - if (configuration_->getCSValue("START_X11") == "0") { - ui_->radioButtonEGL->setChecked(true); - } else { - ui_->radioButtonX11->setChecked(true); - } - // set rotation - if (configuration_->getCSValue("FLIP_SCREEN") == "0") { - ui_->radioButtonScreenNormal->setChecked(true); - } else { - ui_->radioButtonScreenRotated->setChecked(true); - } - - if (std::ifstream("/tmp/get_inputs")) { - QFile inputsFile(QString("/tmp/get_inputs")); - inputsFile.open(QIODevice::ReadOnly); - QTextStream data_return(&inputsFile); - QStringList inputs = data_return.readAll().split("\n"); - inputsFile.close(); - int cleaner = ui_->comboBoxPulseInput->count(); - while (cleaner > -1) { - ui_->comboBoxPulseInput->removeItem(cleaner); - cleaner--; - } - int indexin = inputs.count(); - int countin = 0; - while (countin < indexin - 1) { - ui_->comboBoxPulseInput->addItem(inputs[countin]); - countin++; - } - } - - if (std::ifstream("/tmp/get_outputs")) { - QFile outputsFile(QString("/tmp/get_outputs")); - outputsFile.open(QIODevice::ReadOnly); - QTextStream data_return(&outputsFile); - QStringList outputs = data_return.readAll().split("\n"); - outputsFile.close(); - int cleaner = ui_->comboBoxPulseOutput->count(); - while (cleaner > -1) { - ui_->comboBoxPulseOutput->removeItem(cleaner); - cleaner--; - } - int indexout = outputs.count(); - int countout = 0; - while (countout < indexout - 1) { - ui_->comboBoxPulseOutput->addItem(outputs[countout]); - countout++; - } - } - - ui_->comboBoxPulseOutput->setCurrentText(configuration_->readFileContent("/tmp/get_default_output")); - ui_->comboBoxPulseInput->setCurrentText(configuration_->readFileContent("/tmp/get_default_input")); - - if (std::ifstream("/tmp/timezone_listing")) { - QFile zoneFile(QString("/tmp/timezone_listing")); - zoneFile.open(QIODevice::ReadOnly); - QTextStream data_return(&zoneFile); - QStringList zones = data_return.readAll().split("\n"); - zoneFile.close(); - int cleaner = ui_->comboBoxTZ->count(); - while (cleaner > 0) { - ui_->comboBoxTZ->removeItem(cleaner); - cleaner--; - } - int indexout = zones.count(); - int countzone = 0; - while (countzone < indexout - 1) { - ui_->comboBoxTZ->addItem(zones[countzone]); - countzone++; - } - } - - // set rtc - QString rtcstring = configuration_->getParamFromFile("/boot/config.txt", "dtoverlay=i2c-rtc"); - if (rtcstring != "") { - QStringList rtc = rtcstring.split(","); - ui_->comboBoxHardwareRTC->setCurrentText(rtc[1].trimmed()); - // set timezone - ui_->comboBoxTZ->setCurrentText(configuration_->readFileContent("/etc/timezone")); - } else { - ui_->comboBoxHardwareRTC->setCurrentText("none"); - ui_->comboBoxTZ->setCurrentText(configuration_->readFileContent("/etc/timezone")); - } - - // set dac - QString dac = "Custom"; - if (getparams[4] == "allo-boss-dac-pcm512x-audio") { - dac = "Allo - Boss"; - } - if (getparams[4] == "allo-piano-dac-pcm512x-audio") { - dac = "Allo - Piano"; - } - if (getparams[4] == "iqaudio-dacplus") { - dac = "IQaudIO - Pi-DAC Plus/Pro/Zero"; - } - if (getparams[4] == "iqaudio-dacplus,unmute_amp") { - dac = "IQaudIO - Pi-Digi Amp Plus"; - } - if (getparams[4] == "iqaudio-dacplus,auto_mute_amp") { - dac = "IQaudIO - Pi-Digi Amp Plus - Automute"; - } - if (getparams[4] == "iqaudio-digi-wm8804-audio") { - dac = "IQaudIO - Pi-Digi Plus"; - } - if (getparams[4] == "audioinjector-wm8731-audio") { - dac = "Audioinjector - Zero/Stereo"; - } - if (getparams[4] == "hifiberry-dac") { - dac = "Hifiberry - DAC"; - } - if (getparams[4] == "hifiberry-dacplus") { - dac = "Hifiberry - DAC Plus"; - } - if (getparams[4] == "hifiberry-digi") { - dac = "Hifiberry - Digi"; - } - if (getparams[4] == "hifiberry-digi-pro") { - dac = "Hifiberry - Digi Pro"; - } - if (getparams[4] == "hifiberry-amp") { - dac = "Hifiberry - DAC Amp"; - } - if (getparams[4] == "audio") { - dac = "Raspberry Pi - Onboard"; - } - ui_->comboBoxHardwareDAC->setCurrentText(dac); - - // set shutdown disable - if (configuration_->getCSValue("DISCONNECTION_POWEROFF_DISABLE") == "1") { - ui_->checkBoxDisableShutdown->setChecked(true); - } else { - ui_->checkBoxDisableShutdown->setChecked(false); - } - - // set screen off disable - if (configuration_->getCSValue("DISCONNECTION_SCREEN_POWEROFF_DISABLE") == "1") { - ui_->checkBoxDisableScreenOff->setChecked(true); - } else { - ui_->checkBoxDisableScreenOff->setChecked(false); - } - - // set custom brightness command - if (configuration_->getCSValue("CUSTOM_BRIGHTNESS_COMMAND") != "") { - ui_->labelCustomBrightnessCommand->setText( - configuration_->getCSValue("CUSTOM_BRIGHTNESS_COMMAND") + " brvalue"); - } else { - ui_->labelCustomBrightnessCommand->setText("Disabled"); - } - - // set debug mode - if (configuration_->getCSValue("DEBUG_MODE") == "1") { - ui_->radioButtonDebugmodeEnabled->setChecked(true); - } else { - ui_->radioButtonDebugmodeDisabled->setChecked(true); - } - - // GPIO based shutdown - ui_->comboBoxGPIOShutdown->setCurrentText(configuration_->getCSValue("IGNITION_PIN")); - ui_->spinBoxGPIOShutdownDelay->setValue(configuration_->getCSValue("IGNITION_DELAY").toInt()); - - // Wifi Hotspot - if (configuration_->getCSValue("ENABLE_HOTSPOT") == "1") { - ui_->checkBoxHotspot->setChecked(true); - } else { - ui_->checkBoxHotspot->setChecked(false); - } - - // set cam - if (configuration_->getParamFromFile("/boot/config.txt", "start_x") == "1") { - ui_->comboBoxCam->setCurrentText("enabled"); - } else { - ui_->comboBoxCam->setCurrentText("disabled"); - } - if (configuration_->getCSValue("RPICAM_HFLIP") == "1") { - ui_->checkBoxFlipX->setChecked(true); - } else { - ui_->checkBoxFlipX->setChecked(false); - } - if (configuration_->getCSValue("RPICAM_VFLIP") == "1") { - ui_->checkBoxFlipY->setChecked(true); - } else { - ui_->checkBoxFlipY->setChecked(false); - } - ui_->comboBoxRotation->setCurrentText(configuration_->getCSValue("RPICAM_ROTATION")); - ui_->comboBoxResolution->setCurrentText(configuration_->getCSValue("RPICAM_RESOLUTION")); - ui_->comboBoxFPS->setCurrentText(configuration_->getCSValue("RPICAM_FPS")); - ui_->comboBoxAWB->setCurrentText(configuration_->getCSValue("RPICAM_AWB")); - ui_->comboBoxEXP->setCurrentText(configuration_->getCSValue("RPICAM_EXP")); - ui_->comboBoxLoopTime->setCurrentText(configuration_->getCSValue("RPICAM_LOOPTIME")); - ui_->comboBoxLoopCount->setCurrentText(configuration_->getCSValue("RPICAM_LOOPCOUNT")); - - if (configuration_->getCSValue("RPICAM_AUTORECORDING") == "1") { - ui_->checkBoxAutoRecording->setChecked(true); - } else { - ui_->checkBoxAutoRecording->setChecked(false); - } - - if (configuration_->getCSValue("USBCAM_USE") == "1") { - ui_->comboBoxUSBCam->setCurrentText("enabled"); - } else { - ui_->comboBoxUSBCam->setCurrentText("none"); - } - if (configuration_->getCSValue("USBCAM_ROTATION") == "1") { - ui_->comboBoxUSBRotation->setCurrentText("180"); - } else { - ui_->comboBoxUSBRotation->setCurrentText("0"); - } - if (configuration_->getCSValue("USBCAM_HFLIP") == "1") { - ui_->checkBoxFlipXUSB->setChecked(true); - } else { - ui_->checkBoxFlipXUSB->setChecked(false); - } - if (configuration_->getCSValue("USBCAM_VFLIP") == "1") { - ui_->checkBoxFlipYUSB->setChecked(true); - } else { - ui_->checkBoxFlipYUSB->setChecked(false); - } + if (configuration_->getCSValue("USBCAM_USE") == "1") { + ui_->comboBoxUSBCam->setCurrentText("enabled"); + } else { + ui_->comboBoxUSBCam->setCurrentText("none"); + } + if (configuration_->getCSValue("USBCAM_ROTATION") == "1") { + ui_->comboBoxUSBRotation->setCurrentText("180"); + } else { + ui_->comboBoxUSBRotation->setCurrentText("0"); + } + if (configuration_->getCSValue("USBCAM_HFLIP") == "1") { + ui_->checkBoxFlipXUSB->setChecked(true); + } else { + ui_->checkBoxFlipXUSB->setChecked(false); + } + if (configuration_->getCSValue("USBCAM_VFLIP") == "1") { + ui_->checkBoxFlipYUSB->setChecked(true); + } else { + ui_->checkBoxFlipYUSB->setChecked(false); + } // set bluetooth if (configuration_->getCSValue("ENABLE_BLUETOOTH") == "1") { @@ -1117,265 +1125,267 @@ namespace f1x { ui_->comboBoxBluetooth->setCurrentText("none"); } - // set lightsensor - if (std::ifstream("/etc/cs_lightsensor")) { - ui_->comboBoxLS->setCurrentIndex(1); - ui_->groupBoxSliderDay->hide(); - ui_->groupBoxSliderNight->hide(); - } else { - ui_->comboBoxLS->setCurrentIndex(0); - ui_->pushButtonTab9->hide(); - ui_->groupBoxSliderDay->show(); - ui_->groupBoxSliderNight->show(); - } - ui_->comboBoxDayNight->setCurrentText(configuration_->getCSValue("DAYNIGHT_PIN")); - if (configuration_->getCSValue("RTC_DAYNIGHT") == "1") { - ui_->checkBoxDisableDayNightRTC->setChecked(false); - } else { - ui_->checkBoxDisableDayNightRTC->setChecked(true); - } - QString theme = configuration_->getParamFromFile("/etc/plymouth/plymouthd.conf", "Theme"); - if (theme == "csnganimation") { - ui_->radioButtonAnimatedCSNG->setChecked(true); - } else if (theme == "crankshaft") { - ui_->radioButtonCSNG->setChecked(true); - } else if (theme == "custom") { - ui_->radioButtonCustom->setChecked(true); - } - // wifi country code - ui_->comboBoxCountryCode->setCurrentIndex( - ui_->comboBoxCountryCode->findText(configuration_->getCSValue("WIFI_COUNTRY"), - Qt::MatchFlag::MatchStartsWith)); - // set screen blank instead off - if (configuration_->getCSValue("SCREEN_POWEROFF_OVERRIDE") == "1") { - ui_->checkBoxBlankOnly->setChecked(true); - } else { - ui_->checkBoxBlankOnly->setChecked(false); - } - } - // update network info - updateNetworkInfo(); - } - void SettingsWindow::onStartHotspot() { - ui_->label_modeswitchprogress->setText("Wait ..."); - ui_->clientNetworkSelect->hide(); - ui_->label_notavailable->show(); - ui_->radioButtonClient->setEnabled(0); - ui_->radioButtonHotspot->setEnabled(0); - ui_->lineEdit_wlan0->setText(""); - ui_->lineEditWifiSSID->setText(""); - ui_->pushButtonNetworkAuto->hide(); - qApp->processEvents(); - std::remove("/tmp/manual_hotspot_control"); - std::ofstream("/tmp/manual_hotspot_control"); - system("/opt/crankshaft/service_hotspot.sh start &"); - } - - void SettingsWindow::onStopHotspot() { - ui_->label_modeswitchprogress->setText("Wait ..."); - ui_->clientNetworkSelect->hide(); - ui_->label_notavailable->show(); - ui_->radioButtonClient->setEnabled(0); - ui_->radioButtonHotspot->setEnabled(0); - ui_->lineEdit_wlan0->setText(""); - ui_->lineEditWifiSSID->setText(""); - ui_->lineEditPassword->setText(""); - ui_->pushButtonNetworkAuto->hide(); - qApp->processEvents(); - system("/opt/crankshaft/service_hotspot.sh stop &"); - } - -#ifdef MAC_OS - void SettingsWindow::getMacMemoryInfo(QString& freeMemory) { - mach_port_t host_port; - vm_size_t page_size; - vm_statistics64_data_t vm_stats; - - host_port = mach_host_self(); - mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; - host_page_size(host_port, &page_size); - if (host_statistics64(host_port, HOST_VM_INFO64, (host_info64_t)&vm_stats, &count) != KERN_SUCCESS) { - freeMemory = "Error in getting memory info"; - return; - } - - natural_t free_count = vm_stats.free_count; - uint64_t free_memory = (uint64_t)free_count * (uint64_t)page_size; - freeMemory = QString::number(free_memory / (1024 * 1024)) + " MB"; - } -#endif - - void SettingsWindow::updateSystemInfo() { -#ifdef MAC_OS - QString freeMem; - getMacMemoryInfo(freeMem); - ui_->valueSystemFreeMem->setText(freeMem); -#else - struct sysinfo info; - sysinfo(&info); - ui_->valueSystemFreeMem->setText(QString::number(info.freeram / 1024 / 1024) + " MB"); -#endif - - // current cpu speed - QString freq = configuration_->readFileContent("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq"); - int currentfreq = freq.toInt() / 1000; - ui_->valueSystemCPUFreq->setText(QString::number(currentfreq) + "MHz"); - // current cpu temp - QString temp = configuration_->readFileContent("/sys/class/thermal/thermal_zone0/temp"); - int currenttemp = temp.toInt() / 1000; - ui_->valueSystemCPUTemp->setText(QString::number(currenttemp) + "°C"); - // get remaining times - QProcess process; - process.start("/bin/bash", - QStringList() << "-c" << "systemctl list-timers -all | grep disconnect | awk {'print $1'}"); - process.waitForFinished(-1); - QString stdout = process.readAllStandardOutput(); - if (stdout.simplified() != "n/a") { - process.start("/bin/bash", QStringList() << "-c" - << "systemctl list-timers -all | grep disconnect | awk {'print $5\" \"$6'}"); - process.waitForFinished(-1); - QString stdout = process.readAllStandardOutput(); - if (stdout.simplified() != "") { - ui_->valueDisconnectTimer->setText(stdout.simplified()); - } else { - ui_->valueDisconnectTimer->setText("Stopped"); - } - } else { - ui_->valueDisconnectTimer->setText("Stopped"); - } - process.start("/bin/bash", - QStringList() << "-c" << "systemctl list-timers -all | grep shutdown | awk {'print $1'}"); - process.waitForFinished(-1); - stdout = process.readAllStandardOutput(); - if (stdout.simplified() != "n/a") { - process.start("/bin/bash", QStringList() << "-c" - << "systemctl list-timers -all | grep shutdown | awk {'print $5\" \"$6'}"); - process.waitForFinished(-1); - QString stdout = process.readAllStandardOutput(); - if (stdout.simplified() != "") { - ui_->valueShutdownTimer->setText(stdout.simplified()); - } else { - ui_->valueShutdownTimer->setText("Stopped"); - } - } else { - ui_->valueShutdownTimer->setText("Stopped"); - } - } - - void SettingsWindow::show_tab1() { - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); - ui_->tab1->show(); - } - - void SettingsWindow::show_tab2() { - ui_->tab1->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); - ui_->tab2->show(); - } - - void SettingsWindow::show_tab3() { - ui_->tab1->hide(); - ui_->tab2->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); - ui_->tab3->show(); - } - - void SettingsWindow::show_tab4() { - ui_->tab1->hide(); - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); - ui_->tab4->show(); - } - - void SettingsWindow::show_tab5() { - ui_->tab1->hide(); - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); - ui_->tab5->show(); - } - - void SettingsWindow::show_tab6() { - ui_->tab1->hide(); - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); - ui_->tab6->show(); - } - - void SettingsWindow::show_tab7() { - ui_->tab1->hide(); - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab8->hide(); - ui_->tab9->hide(); - ui_->tab7->show(); - } - - void SettingsWindow::show_tab8() { - ui_->tab1->hide(); - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab9->hide(); - ui_->tab8->show(); - } - - void SettingsWindow::show_tab9() { - ui_->tab1->hide(); - ui_->tab2->hide(); - ui_->tab3->hide(); - ui_->tab4->hide(); - ui_->tab5->hide(); - ui_->tab6->hide(); - ui_->tab7->hide(); - ui_->tab8->hide(); - ui_->tab9->show(); - } + // set lightsensor + if (std::ifstream("/etc/cs_lightsensor")) { + ui_->comboBoxLS->setCurrentIndex(1); + ui_->groupBoxSliderDay->hide(); + ui_->groupBoxSliderNight->hide(); + } else { + ui_->comboBoxLS->setCurrentIndex(0); + ui_->pushButtonTab9->hide(); + ui_->groupBoxSliderDay->show(); + ui_->groupBoxSliderNight->show(); + } + ui_->comboBoxDayNight->setCurrentText(configuration_->getCSValue("DAYNIGHT_PIN")); + if (configuration_->getCSValue("RTC_DAYNIGHT") == "1") { + ui_->checkBoxDisableDayNightRTC->setChecked(false); + } else { + ui_->checkBoxDisableDayNightRTC->setChecked(true); + } + QString theme = configuration_->getParamFromFile("/etc/plymouth/plymouthd.conf", "Theme"); + if (theme == "csnganimation") { + ui_->radioButtonAnimatedCSNG->setChecked(true); + } else if (theme == "crankshaft") { + ui_->radioButtonCSNG->setChecked(true); + } else if (theme == "custom") { + ui_->radioButtonCustom->setChecked(true); + } + // wifi country code + ui_->comboBoxCountryCode->setCurrentIndex( + ui_->comboBoxCountryCode->findText(configuration_->getCSValue("WIFI_COUNTRY"), + Qt::MatchFlag::MatchStartsWith)); + // set screen blank instead off + if (configuration_->getCSValue("SCREEN_POWEROFF_OVERRIDE") == "1") { + ui_->checkBoxBlankOnly->setChecked(true); + } else { + ui_->checkBoxBlankOnly->setChecked(false); } } + // update network info + updateNetworkInfo(); } + + void SettingsWindow::onStartHotspot() { + ui_->label_modeswitchprogress->setText("Wait ..."); + ui_->clientNetworkSelect->hide(); + ui_->label_notavailable->show(); + ui_->radioButtonClient->setEnabled(0); + ui_->radioButtonHotspot->setEnabled(0); + ui_->lineEdit_wlan0->setText(""); + ui_->lineEditWifiSSID->setText(""); + ui_->pushButtonNetworkAuto->hide(); + qApp->processEvents(); + std::remove("/tmp/manual_hotspot_control"); + std::ofstream("/tmp/manual_hotspot_control"); + system("/opt/crankshaft/service_hotspot.sh start &"); + } + + void SettingsWindow::onStopHotspot() { + ui_->label_modeswitchprogress->setText("Wait ..."); + ui_->clientNetworkSelect->hide(); + ui_->label_notavailable->show(); + ui_->radioButtonClient->setEnabled(0); + ui_->radioButtonHotspot->setEnabled(0); + ui_->lineEdit_wlan0->setText(""); + ui_->lineEditWifiSSID->setText(""); + ui_->lineEditPassword->setText(""); + ui_->pushButtonNetworkAuto->hide(); + qApp->processEvents(); + system("/opt/crankshaft/service_hotspot.sh stop &"); + } + +#ifdef MAC_OS + + void SettingsWindow::getMacMemoryInfo(QString &freeMemory) { + mach_port_t host_port; + vm_size_t page_size; + vm_statistics64_data_t vm_stats; + + host_port = mach_host_self(); + mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; + host_page_size(host_port, &page_size); + if (host_statistics64(host_port, HOST_VM_INFO64, (host_info64_t) &vm_stats, &count) != KERN_SUCCESS) { + freeMemory = "Error in getting memory info"; + return; + } + + natural_t free_count = vm_stats.free_count; + uint64_t free_memory = (uint64_t) free_count * (uint64_t) page_size; + freeMemory = QString::number(free_memory / (1024 * 1024)) + " MB"; + } + +#endif + + void SettingsWindow::updateSystemInfo() { +#ifdef MAC_OS + QString freeMem; + getMacMemoryInfo(freeMem); + ui_->valueSystemFreeMem->setText(freeMem); +#else + struct sysinfo info; + sysinfo(&info); + ui_->valueSystemFreeMem->setText(QString::number(info.freeram / 1024 / 1024) + " MB"); +#endif + + // current cpu speed + QString freq = configuration_->readFileContent("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq"); + int currentfreq = freq.toInt() / 1000; + ui_->valueSystemCPUFreq->setText(QString::number(currentfreq) + "MHz"); + // current cpu temp + QString temp = configuration_->readFileContent("/sys/class/thermal/thermal_zone0/temp"); + int currenttemp = temp.toInt() / 1000; + ui_->valueSystemCPUTemp->setText(QString::number(currenttemp) + "°C"); + // get remaining times + QProcess process; + process.start("/bin/bash", + QStringList() << "-c" << "systemctl list-timers -all | grep disconnect | awk {'print $1'}"); + process.waitForFinished(-1); + QString stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "n/a") { + process.start("/bin/bash", QStringList() << "-c" + << "systemctl list-timers -all | grep disconnect | awk {'print $5\" \"$6'}"); + process.waitForFinished(-1); + QString stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "") { + ui_->valueDisconnectTimer->setText(stdout.simplified()); + } else { + ui_->valueDisconnectTimer->setText("Stopped"); + } + } else { + ui_->valueDisconnectTimer->setText("Stopped"); + } + process.start("/bin/bash", + QStringList() << "-c" << "systemctl list-timers -all | grep shutdown | awk {'print $1'}"); + process.waitForFinished(-1); + stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "n/a") { + process.start("/bin/bash", QStringList() << "-c" + << "systemctl list-timers -all | grep shutdown | awk {'print $5\" \"$6'}"); + process.waitForFinished(-1); + QString stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "") { + ui_->valueShutdownTimer->setText(stdout.simplified()); + } else { + ui_->valueShutdownTimer->setText("Stopped"); + } + } else { + ui_->valueShutdownTimer->setText("Stopped"); + } + } + + void SettingsWindow::show_tab1() { + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); + ui_->tab1->show(); + } + + void SettingsWindow::show_tab2() { + ui_->tab1->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); + ui_->tab2->show(); + } + + void SettingsWindow::show_tab3() { + ui_->tab1->hide(); + ui_->tab2->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); + ui_->tab3->show(); + } + + void SettingsWindow::show_tab4() { + ui_->tab1->hide(); + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); + ui_->tab4->show(); + } + + void SettingsWindow::show_tab5() { + ui_->tab1->hide(); + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); + ui_->tab5->show(); + } + + void SettingsWindow::show_tab6() { + ui_->tab1->hide(); + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); + ui_->tab6->show(); + } + + void SettingsWindow::show_tab7() { + ui_->tab1->hide(); + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab8->hide(); + ui_->tab9->hide(); + ui_->tab7->show(); + } + + void SettingsWindow::show_tab8() { + ui_->tab1->hide(); + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab9->hide(); + ui_->tab8->show(); + } + + void SettingsWindow::show_tab9() { + ui_->tab1->hide(); + ui_->tab2->hide(); + ui_->tab3->hide(); + ui_->tab4->hide(); + ui_->tab5->hide(); + ui_->tab6->hide(); + ui_->tab7->hide(); + ui_->tab8->hide(); + ui_->tab9->show(); + } + } + void f1x::openauto::autoapp::ui::SettingsWindow::on_pushButtonAudioTest_clicked() { ui_->labelTestInProgress->show(); ui_->pushButtonAudioTest->hide();