Index: sources/device/DeviceController.h =================================================================== diff -u -rf7394a2cb3477d81896b9993308dd9654cd3e42e -r6c6f1f5d466badd9b4fd67be7c907234c342b2a2 --- sources/device/DeviceController.h (.../DeviceController.h) (revision f7394a2cb3477d81896b9993308dd9654cd3e42e) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision 6c6f1f5d466badd9b4fd67be7c907234c342b2a2) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file DeviceController.h * \author (last) Behrouz NematiPour - * \date (last) 29-May-2021 + * \date (last) 19-Dec-2022 * \author (original) Behrouz NematiPour - * \date (original) 17-Jul-2020 + * \date (original) 03-Jun-2021 * */ #pragma once @@ -21,7 +21,6 @@ // Project #include "main.h" // Doxygen : do not remove -#include "Threads.h" #include "DeviceGlobals.h" #include "DeviceModels.h" #include "DeviceError.h" @@ -43,27 +42,28 @@ Q_OBJECT explicit TimedProcess(QObject *parent = nullptr) : QObject(parent) { } - int _id = 0; - int _timeout = 0; + int _pid = 0; + int _timeout = 0; QProcess *_process = nullptr; QString _command = ""; + QStringList _arguments = {}; private slots: void onFinish(int) { - killTimer(_id); + killTimer(_pid); _process->kill(); _process = nullptr; deleteLater(); } public: - TimedProcess(QProcess *vProcess, const QString &vCommand, int vTimeout) - : QObject(), _timeout(vTimeout), _process(vProcess), _command(vCommand) { + TimedProcess(QProcess *vProcess, const QString &vCommand, int vTimeout, QStringList vArguments = {}) + : QObject(), _timeout(vTimeout), _process(vProcess), _command(vCommand), _arguments(vArguments) { connect(_process, SIGNAL( finished(int)), this , SLOT(onFinish (int))); } void start() { - _id = startTimer(_timeout); - _process->start(_command); + _pid = startTimer(_timeout); + _process->start(_command, _arguments); } protected: @@ -100,33 +100,56 @@ bool _mounted = false; bool _umounted = false; bool _removed = false; - const char *_usbDrive = ""; const int _interval = 1000; // in ms const qint8 _minRequiredAvailableSpacePercent = 10; QThread *_thread = nullptr; bool _init = false; - bool _pauseSpaceCheck = false; - QFileSystemWatcher _fileSystemWatcher; + QString _macEthernet = ""; + QString _macWireless = ""; + QString _macBluetooth = ""; + QString _netCloudSync = ""; + + bool _hasThread = false; + bool _hasSalt = false; + //TODO: all of these should use the TimesProcess (instead of QProcess) // to be able to kill the process automatically after the set time out. DEVICE_DEV_DEFINITION_LIST public slots: bool init(); bool init(QThread &vThread); + void quit(); void doScreenshot(const QImage &vImage, const QString &vFileName); private slots: - void quit(); - void onRemoveLogs(bool vInProgress); void onScreenshot(const QImage &vImage, const QString &vFileName); + void onUSBDriveUmount(); + void onWatchFileChanged(const QString &vFile); + + + void onEventThreadChange (); + + /*! + * \brief didPOSTData + * \details These signals will be emitted when UI is done with the POST and will let DeviceView update its property(ies). + * \param vMacEthernet - Ethernet Mac Adress + * \param vMacWireless - Wireless Mac Adress + * \param vMacBluetooth - Bluetooth Mac Adress + * \param vNetCloudSync - CloudSync IP Adress + */ + void onPOSTEthernetData (const QString &vMacAddress); + void onPOSTWirelessData (const QString &vMacAddress); + void onPOSTBluetoothData (const QString &vMacAddress); + void onPOSTCloudSyncData (const QString &vNetAddress); + protected: void timerEvent(QTimerEvent *) override; @@ -146,6 +169,8 @@ bool addWatch(const QString &vFilePath); + void checkConfugurationMountReady(); + signals: /*! * \brief didScreenshot @@ -173,6 +198,9 @@ */ void didUSBDriveRemove(); + void didUSBStateChange(bool vIsReady, bool vIsReadOnly); + void didUSBSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); + /*! * \brief didSDCardFreeSpaceChange * \param vReady - Device is mounted and ready @@ -202,25 +230,40 @@ */ void didSDCardSpaceTooLow(quint8 vAvailablePercent); - void didActionReceive( const DeviceBrightnessResponseData &vBrightness ); + void didActionReceive( const DeviceBrightnessResponseData &vBrightness ); + void didActionReceive( const DeviceRootSSHAccessResponseData &vRootSSHAccess); void didWatchFileChange(const QString &vFile); -private slots: - // ----- USB - void usbCheck(); + /*! + * \brief didEventThreadChange + * \details this signal will be emitted when the curr + */ + void didEventThreadChange (QPrivateSignal); - bool usbMount (const QString &vDevice); - bool usbUmount(const QString &vDevice); - void usbRemove(); - void usbError (const QString &vDevice); + void didPOSTEthernetData (const QString &vMacAddress); + void didPOSTWirelessData (const QString &vMacAddress); + void didPOSTBluetoothData (const QString &vMacAddress); + void didPOSTCloudSyncData (const QString &vNetAddress); - void onUSBDriveUmount(); + /*! + * \brief didCryptSetupMount + * \details will be emitted when decrypting the configuration partition is. + * to notify the ApplicationController to call initSettings + */ + void didCryptSetupMount ( bool vPass ); - void onWatchFileChanged(const QString &vFile); +private: + // ----- USB + void usbCheck (); + void usbError (const QString &vDevice ); + void usbMountReq(const QString &vDevice, bool vIsMount = true ); + void usbMount (const QString &vDevice ); + void usbUmount (const QString &vDevice ); + void usbRemove (); - // ----- SDCard void sdcardSpaceCheck(); + void usbSpaceCheck(); SAFE_CALL_EX(doAddWatch, const QString &) };