Index: .gitignore =================================================================== diff -u -r1313579ecd6a41b664c44bfdd11daee4df44131b -r0932b2beee9cc169291cbf69161f902f805237b1 --- .gitignore (.../.gitignore) (revision 1313579ecd6a41b664c44bfdd11daee4df44131b) +++ .gitignore (.../.gitignore) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -7,3 +7,7 @@ denali.pro.user.* *.sh~ + +sources/model/hd/alarm/MAlarmMapping.cpp + +AlarmMapping.csv Fisheye: Tag 0932b2beee9cc169291cbf69161f902f805237b1 refers to a dead (removed) revision in file `AlarmMapping.csv'. Fisheye: No comparison available. Pass `N' to diff? Index: sources/device/DeviceController.cpp =================================================================== diff -u -rcd589a3f0683918fc299652c4f265269ac83d945 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision cd589a3f0683918fc299652c4f265269ac83d945) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -39,6 +39,8 @@ using namespace Device; using namespace Storage; +DEVICE_DEV_DECLARATION_LIST + /*! * \brief DeviceController::DeviceController * \details Constructor @@ -586,8 +588,11 @@ * 3 - get no error when in onProcessBrightnessExitCode : MDeviceResponse.toString() * - in case 3 the specific model _data has to be filled prior to the toString to have it in the log. */ -void DeviceController::onProcessBrightnessExitCode(int vExitCode, QProcess::ExitStatus) +void DeviceController::onProcessBrightnessExitCode(int vExitCode, QProcess::ExitStatus vStatus) { + //DEBUG + qDebug() << __FUNCTION__ << vExitCode << vStatus; + if ( ! checkError(static_cast(vExitCode), _deviceBrightnessResponse, _deviceBrightnessResponse.toString()) ) { // has no error if (_deviceBrightnessRequest._data.mRead) { bool ok = false; @@ -1230,7 +1235,6 @@ ///////////////////////////////////////////// DeviceUSBMounting void DeviceController::onAttributeRequest(const DeviceUSBMountRequestData &vData) { - Q_UNUSED(vData) usbMountReq(vData.usbDevice, vData.isMountRequest); } @@ -1312,3 +1316,68 @@ // log error and exit return; } + +///////////////////////////////////////////// DeviceWifiList +void DeviceController::onAttributeRequest(const DeviceWifiListRequestData &) +{ + wifiListRequest(); +} + +/*! + * \brief DeviceController::wifiListRequest + * \details Calls the Wifi List script + * \note This function is created to be able to call independently if needed in this class. + */ +void DeviceController::wifiListRequest() +{ + // _deviceWifiListRequest._data + + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Wifi_Scan_For_Networks), _deviceWifiListResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processWifiList.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceWifiListResponse); + return; + } + + // ----- run the process + int timeout_ms = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processWifiList, script, timeout_ms, {}); + timedProcess->start(); + + MDeviceWifiListResponse model; + model._data.mCompleted = false; + model._data.mAccepted = false; + model._data.mMessage = tr("WiFi list scan started."); + emit didAttributeResponse(model.data()); +} + +/*! + * \brief DeviceController::onProcessUSBMountExitCode + * \param vExitCode + * \param vStatus + */ +void DeviceController::onProcessWifiListExitCode(int vExitCode, QProcess::ExitStatus vStatus) +{ + //DEBUG + qDebug() << __FUNCTION__ << vExitCode << vStatus; + + MDeviceWifiListResponse model; + model._data.mCompleted = true; + QByteArray deviceInfo; + if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; + else deviceInfo = _processWifiList.readAll(); + model.fromByteArray( deviceInfo, &vExitCode ); + emit didAttributeResponse(model.data()); + + bool ok = ! vStatus; + + // log error and exit + if ( ! ok ) { + LOG_DEBUG(QString("WiFi list scan filed [%1]").arg(vExitCode)); + } + return; +} Index: sources/device/DeviceController.h =================================================================== diff -u -r5687815256ae070a9a207107088e3f72dd464da0 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceController.h (.../DeviceController.h) (revision 5687815256ae070a9a207107088e3f72dd464da0) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -154,7 +154,7 @@ this , SLOT(onFinish (int))); } void start() { -#ifdef BUILD_FOR_DESKTOP +#ifndef BUILD_FOR_DESKTOP //FIXME : Revert this back to the #ifdef and remove the #if(n)def to avoid executing the shell scripts on VM. qDebug() << "DeviceController.TimedProcess: " << _timeout << _command << _arguments; QFileInfo fileInfo(_command); QString path = fileInfo.absolutePath(); @@ -442,6 +442,9 @@ void usbSpaceCheck(); void settingsPartitionSpaceCheck(); + // ----- WiFi + void wifiListRequest(); + SAFE_CALL_EX2(doAddWatch, const QString &, bool) }; } Index: sources/device/DeviceError.h =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceError.h (.../DeviceError.h) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceError.h (.../DeviceError.h) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -66,6 +66,7 @@ eDevice_CryptSetup_Error , eDevice_FactoryReset_Error , eDevice_Decommission_Error , + eDevice_WifiList_Error , eDevice_USBMount_Error , eDevice_Error_End Index: sources/device/DeviceGlobals.h =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -102,14 +102,34 @@ * \param vStatus - the status of the process \ */ \ void onProcess##vATTRIBUTEFLC##ExitCode(int vExitCode, QProcess::ExitStatus vStatus); \ + void onProcess##vATTRIBUTEFLC##ReadyOut(); \ + void onProcess##vATTRIBUTEFLC##ReadyErr(); \ private : +#define DEVICE_DEV_DECLARATION( vATTRIBUTEFLC ) \ + void DeviceController::onProcess##vATTRIBUTEFLC##ReadyOut() { \ + M##Device##vATTRIBUTEFLC##Response model; \ + model._data.mAccepted = false; \ + model._data.mMessage = _process##vATTRIBUTEFLC.readAllStandardOutput(); \ + emit didAttributeResponse(model.data()); \ + } \ + void DeviceController::onProcess##vATTRIBUTEFLC##ReadyErr() { \ + M##Device##vATTRIBUTEFLC##Response model; \ + model._data.mAccepted = false; \ + model._data.mMessage = QString("Err:") + _process##vATTRIBUTEFLC.readAllStandardError(); \ + emit didAttributeResponse(model.data()); \ + } + #define DEVICE_DEV_INIT_CONNECTIONS( vATTRIBUTEFLC ) \ /* App -> Dev //TODO: Add the error LOG connection */ \ connect(&_ApplicationController , SIGNAL(didAttributeRequest(const Device##vATTRIBUTEFLC##RequestData &)), \ this , SLOT( onAttributeRequest(const Device##vATTRIBUTEFLC##RequestData &))); \ connect(&_process##vATTRIBUTEFLC, SIGNAL( finished(int, QProcess::ExitStatus)), \ - this, SLOT(onProcess##vATTRIBUTEFLC##ExitCode(int, QProcess::ExitStatus))); + this, SLOT(onProcess##vATTRIBUTEFLC##ExitCode(int, QProcess::ExitStatus))); \ + connect(&_process##vATTRIBUTEFLC, SIGNAL( readyReadStandardOutput( )), \ + this, SLOT(onProcess##vATTRIBUTEFLC##ReadyOut( ))); \ + connect(&_process##vATTRIBUTEFLC, SIGNAL( readyReadStandardError ( )), \ + this, SLOT(onProcess##vATTRIBUTEFLC##ReadyErr( ))); \ /* ---------------------------- APP */ #define DEVICE_APP_BRIDGE_DEFINITION( vATTRIBUTEFLC ) \ @@ -164,6 +184,7 @@ /* ---------------------------- DEVICE DEFINITIONS LISTS */ /* Please list all the device attributes here for each list */ /* ---------------------------- DEV */ +// All the device attributes need to be listed here to be re-parented. #define DEVICE_DEV_PARENT_LIST \ DEVICE_DEV_PARENT ( Brightness ) \ DEVICE_DEV_PARENT ( BluetoothPairedReset ) \ @@ -173,7 +194,9 @@ DEVICE_DEV_PARENT ( FactoryReset ) \ DEVICE_DEV_PARENT ( Decommission ) \ DEVICE_DEV_PARENT ( USBMount ) \ + DEVICE_DEV_PARENT ( WifiList ) \ +// All the device attributes need to be listed here to be connected to the signal slots. #define DEVICE_DEV_INIT_CONNECTIONS_LIST \ DEVICE_DEV_INIT_CONNECTIONS ( Brightness ) \ DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedReset ) \ @@ -183,7 +206,9 @@ DEVICE_DEV_INIT_CONNECTIONS ( FactoryReset ) \ DEVICE_DEV_INIT_CONNECTIONS ( Decommission ) \ DEVICE_DEV_INIT_CONNECTIONS ( USBMount ) \ + DEVICE_DEV_INIT_CONNECTIONS ( WifiList ) \ +// All the device attributes need to be listed here to be defined with needed signal, slots, values, ... . #define DEVICE_DEV_DEFINITION_LIST \ DEVICE_DEV_DEFINITION ( Brightness ) \ DEVICE_DEV_DEFINITION ( BluetoothPairedReset ) \ @@ -192,10 +217,25 @@ DEVICE_DEV_DEFINITION ( RootSSHAccess ) \ DEVICE_DEV_DEFINITION ( FactoryReset ) \ DEVICE_DEV_DEFINITION ( Decommission ) \ + DEVICE_DEV_DEFINITION ( WifiList ) \ DEVICE_DEV_DEFINITION ( USBMount ) \ +// All the device attributes need to be listed here to be defined with needed signal, slots, values, ... . +#define DEVICE_DEV_DECLARATION_LIST \ + DEVICE_DEV_DECLARATION ( Brightness ) \ + DEVICE_DEV_DECLARATION ( BluetoothPairedReset ) \ + DEVICE_DEV_DECLARATION ( BluetoothPairedQuery ) \ + DEVICE_DEV_DECLARATION ( CryptSetup ) \ + DEVICE_DEV_DECLARATION ( RootSSHAccess ) \ + DEVICE_DEV_DECLARATION ( FactoryReset ) \ + DEVICE_DEV_DECLARATION ( Decommission ) \ + DEVICE_DEV_DECLARATION ( WifiList ) \ + DEVICE_DEV_DECLARATION ( USBMount ) \ + /* ---------------------------- APP */ +// All the device attributes if added here will make a connection on Application controller for the following: +// Gui -> App <- Dev #define DEVICE_APP_INIT_CONNECTIONS_LIST \ DEVICE_APP_INIT_CONNECTIONS ( Brightness ) \ DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedReset ) \ @@ -204,6 +244,7 @@ DEVICE_APP_INIT_CONNECTIONS ( RootSSHAccess ) \ DEVICE_APP_INIT_CONNECTIONS ( FactoryReset ) \ DEVICE_APP_INIT_CONNECTIONS ( Decommission ) \ + DEVICE_APP_INIT_CONNECTIONS ( WifiList ) \ #define DEVICE_APP_BRIDGE_DEFINITION_LIST \ DEVICE_APP_BRIDGE_DEFINITION( Brightness ) \ @@ -214,17 +255,11 @@ DEVICE_APP_BRIDGE_DEFINITION( FactoryReset ) \ DEVICE_APP_BRIDGE_DEFINITION( Decommission ) \ DEVICE_APP_BRIDGE_DEFINITION( USBMount ) \ + DEVICE_APP_BRIDGE_DEFINITION( WifiList ) \ /* ---------------------------- GUI */ -#define DEVICE_GUI_BRIDGE_DEFINITION_LIST \ - DEVICE_GUI_BRIDGE_DEFINITION( Brightness ) \ - DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedReset ) \ - DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedQuery ) \ - DEVICE_GUI_BRIDGE_DEFINITION( CryptSetup ) \ - DEVICE_GUI_BRIDGE_DEFINITION( RootSSHAccess ) \ - DEVICE_GUI_BRIDGE_DEFINITION( FactoryReset ) \ - DEVICE_GUI_BRIDGE_DEFINITION( Decommission ) \ - +// All the device attributes if added here will make a connection on Gui controller for the following: +// Gui <- App #define DEVICE_GUI_INIT_CONNECTIONS_LIST \ DEVICE_GUI_INIT_CONNECTIONS ( Brightness ) \ DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedReset ) \ @@ -233,8 +268,21 @@ DEVICE_GUI_INIT_CONNECTIONS ( RootSSHAccess ) \ DEVICE_GUI_INIT_CONNECTIONS ( FactoryReset ) \ DEVICE_GUI_INIT_CONNECTIONS ( Decommission ) \ + DEVICE_GUI_INIT_CONNECTIONS ( WifiList ) \ +#define DEVICE_GUI_BRIDGE_DEFINITION_LIST \ + DEVICE_GUI_BRIDGE_DEFINITION( Brightness ) \ + DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedReset ) \ + DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedQuery ) \ + DEVICE_GUI_BRIDGE_DEFINITION( CryptSetup ) \ + DEVICE_GUI_BRIDGE_DEFINITION( RootSSHAccess ) \ + DEVICE_GUI_BRIDGE_DEFINITION( FactoryReset ) \ + DEVICE_GUI_BRIDGE_DEFINITION( Decommission ) \ + DEVICE_GUI_BRIDGE_DEFINITION( WifiList ) \ + /* ---------------------------- VIEW */ +// All the device attributes if added here will make a connection on Gui controller for the following: +// Qml -> View <- Gui #define DEVICE_VIEW_INIT_CONNECTIONS_LIST \ DEVICE_VIEW_INIT_CONNECTIONS( Brightness ) \ DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedReset ) \ @@ -243,4 +291,5 @@ DEVICE_VIEW_INIT_CONNECTIONS( RootSSHAccess ) \ DEVICE_VIEW_INIT_CONNECTIONS( FactoryReset ) \ DEVICE_VIEW_INIT_CONNECTIONS( Decommission ) \ + DEVICE_VIEW_INIT_CONNECTIONS( WifiList ) \ Index: sources/device/DeviceModels.cpp =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -23,7 +23,7 @@ /*! * \brief MDeviceBluetoothPairedResetResponse::fromByteArray - * \details Checks the response and sets up the mode data. + * \details Checks the response and sets up the model data. * \param vExitCode - Passed script exit code * \return true if passed. */ @@ -53,7 +53,7 @@ /*! * \brief MDeviceCryptSetupResponse::fromByteArray - * \details Checks the response and sets up the mode data. + * \details Checks the response and sets up the model data. * \param vExitCode - Passed script exit code * \return true if passed. */ @@ -194,7 +194,7 @@ /*! * \brief MDeviceFactoryResetResponse::fromByteArray - * \details Checks the response and sets up the mode data. + * \details Checks the response and sets up the model data. * \param vExitCode - Passed script exit code * \return true if passed. */ @@ -225,7 +225,7 @@ /*! * \brief MDeviceDecommissionResponse::fromByteArray - * \details Checks the response and sets up the mode data. + * \details Checks the response and sets up the model data. * \param vExitCode - Passed script exit code * \return true if passed. */ @@ -254,8 +254,44 @@ } /*! + * \brief MDeviceWifiListResponse::fromByteArray + * \details Checks the response and sets up the model data. + * \param vExitCode - Passed script exit code + * \return true if passed. + */ +bool MDeviceWifiListResponse::fromByteArray(const QByteArray &vByteArray, int *vExitCode) +{ + //DEBUG + qDebug() << __FUNCTION__ << vByteArray; + + // initialize data + int error = 0; + _data.mAccepted = false; + + // check if the vExitCode passed and it has a value other than zero + if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_WifiList_Error; error = *vExitCode; } + else _data.mReason = Device::DeviceError::eDevice_OK; + + // if vExitCode is not zero go to error since the data is no longer valid + if ( _data.mReason ) goto lError; // non-zero Exit code + + // Now everything is good to extract the data + _data.mAccepted = true; + _data.mWifiList = vByteArray; + _data.mMessage = QObject::tr("The Wifi list scan Complete."); goto lOut ; // normal return + +lError: + _data.mMessage = Device::DeviceError::deviceErrorText(static_cast(_data.mReason), error) + "\n" + vByteArray; + +lOut: + + _data.mCompleted= true; + return _data.mAccepted; +} + +/*! * \brief MDeviceUSBMountResponse::fromByteArray - * \details Checks the response and sets up the mode data. + * \details Checks the response and sets up the model data. * \param vExitCode - Passed script exit code * \return true if passed. */ Index: sources/device/DeviceModels.h =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceModels.h (.../DeviceModels.h) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceModels.h (.../DeviceModels.h) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -67,10 +67,13 @@ QString infoText () const override { return QString("DeviceBase") ; } struct Data { - // by default it has to be accepted with no rejection reason - bool mAccepted = true; /*!< Accepted value of type quint32 extracted out */ - quint32 mReason = 0 ; /*!< Reason value of type quint32 extracted out */ - QString mMessage = "" ; /*!< Message value of type QString of the reason */ + bool mCompleted= false; /*!< Completed The mComplete is used to ensure the script ran and is complete, + since the responses may have been produced to inform the UI only like a progress + and the script is not complete unless we are done with the script. */ + bool mAccepted = false; /*!< Accepted The result of the script execution for the request + it could be sent back multiple times with accepted to false just to inform UI of a intermediary value like progress percentage.*/ + quint32 mReason = 0 ; /*!< Reason if the mAccepted is 0 then this includes why it has been rejected with an ID of the rejection reason. */ + QString mMessage = "" ; /*!< Message a message that can always be sent from the script. */ }; MDeviceResponseBase () { } @@ -79,7 +82,7 @@ }; -// ---------- MDeviceBrightness ---------- // +// ================================================= MDeviceBrightness /*! * \brief The MDeviceBrightnessRequest class * \details The model for the device brightness value modification request. @@ -145,7 +148,7 @@ Device::DeviceError::Scripts_Error_Enum setBrightnessPercent(quint8 vSysVal); }; -// ---------- MDeviceBluetoothPaired 'Reset' ---------- // +// ================================================= MDeviceBluetoothPaired 'Reset' /*! * \brief The MDeviceBluetoothPairedResetRequest class * \details The model for the bluetooth pared removal script call. @@ -174,7 +177,7 @@ bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; -// ---------- MDeviceBluetoothPaired 'Query' ---------- // +// ================================================= MDeviceBluetoothPaired 'Query' /*! * \brief The MDeviceBluetoothPairedQueryRequest class * \details The model for the bluetooth pared removal script call. @@ -213,7 +216,7 @@ bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; -// ---------- MDeviceCryptSetup ---------- // +// ================================================= MDeviceCryptSetup /*! * \brief The MDeviceCryptSetupRequest class * \details The model for the CryptSetup script call. @@ -244,7 +247,7 @@ bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; -// ---------- MDeviceRootSSHAccess ---------- // +// ================================================= MDeviceRootSSHAccess /*! * \brief The MDeviceRootSSHAccessRequest class * \details The model for the device RootSSHAccess value modification request. @@ -276,9 +279,7 @@ Data data () const { return _data; } }; - - -// ---------- MDeviceFactoryReset ---------- // +// ================================================= MDeviceFactoryReset /*! * \brief The MDeviceFactoryResetRequest class * \details The model for the factory reset script call. @@ -307,8 +308,7 @@ bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; - -// ---------- MDeviceDecommission ---------- // +// ================================================= MDeviceDecommission /*! * \brief The MDeviceDecommissionRequest class * \details The model for the decommission script call. @@ -338,7 +338,7 @@ bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; -// ---------- MDeviceUSBMount ---------- // +// ================================================= MDeviceUSBMount /*! * \brief The MDeviceUSBMountRequest class * \details The model for the usb unmount/mount script call. @@ -368,30 +368,64 @@ Data data ( ) const { return _data; } bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; }; + +// ================================================= MDeviceWifiList +/*! + * \brief The MDeviceMDeviceWifiListRequest class + * \details The model for the Wifi Lsit script call. + */ +class MDeviceWifiListRequest : public MDeviceRequestBase { +public: + struct Data { + } _data; + + QString toString() { + return MDeviceRequestBase::toString("WifiList", {}); + } +}; + +/*! + * \brief The MDeviceWifiListResponse class + * \details The model for the Wifi List script call returned value / response. + */ +class MDeviceWifiListResponse : public MDeviceResponseBase { +public: + struct Data : MDeviceResponseBase::Data { + QString mWifiList = ""; + } _data; + QVariantList parameters ( ) const override { return { }; } + QString infoText ( ) const override { return QString("WifiList"); } + Data data ( ) const { return _data; } + bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override; +}; } -typedef Model::MDeviceResponseBase ::Data DeviceResponseBaseData ; +typedef Model::MDeviceResponseBase ::Data DeviceResponseBaseData; -typedef Model::MDeviceBrightnessRequest ::Data DeviceBrightnessRequestData ; -typedef Model::MDeviceBrightnessResponse::Data DeviceBrightnessResponseData ; +typedef Model::MDeviceBrightnessRequest ::Data DeviceBrightnessRequestData ; +typedef Model::MDeviceBrightnessResponse ::Data DeviceBrightnessResponseData; -typedef Model::MDeviceBluetoothPairedResetRequest ::Data DeviceBluetoothPairedResetRequestData ; -typedef Model::MDeviceBluetoothPairedResetResponse::Data DeviceBluetoothPairedResetResponseData; +typedef Model::MDeviceBluetoothPairedResetRequest ::Data DeviceBluetoothPairedResetRequestData ; +typedef Model::MDeviceBluetoothPairedResetResponse ::Data DeviceBluetoothPairedResetResponseData; -typedef Model::MDeviceBluetoothPairedQueryRequest ::Data DeviceBluetoothPairedQueryRequestData ; -typedef Model::MDeviceBluetoothPairedQueryResponse::Data DeviceBluetoothPairedQueryResponseData; +typedef Model::MDeviceBluetoothPairedQueryRequest ::Data DeviceBluetoothPairedQueryRequestData ; +typedef Model::MDeviceBluetoothPairedQueryResponse ::Data DeviceBluetoothPairedQueryResponseData; -typedef Model::MDeviceCryptSetupRequest ::Data DeviceCryptSetupRequestData ; -typedef Model::MDeviceCryptSetupResponse::Data DeviceCryptSetupResponseData; +typedef Model::MDeviceCryptSetupRequest ::Data DeviceCryptSetupRequestData ; +typedef Model::MDeviceCryptSetupResponse ::Data DeviceCryptSetupResponseData; -typedef Model::MDeviceRootSSHAccessRequest ::Data DeviceRootSSHAccessRequestData ; -typedef Model::MDeviceRootSSHAccessResponse::Data DeviceRootSSHAccessResponseData ; +typedef Model::MDeviceRootSSHAccessRequest ::Data DeviceRootSSHAccessRequestData ; +typedef Model::MDeviceRootSSHAccessResponse ::Data DeviceRootSSHAccessResponseData; -typedef Model::MDeviceFactoryResetRequest ::Data DeviceFactoryResetRequestData ; -typedef Model::MDeviceFactoryResetResponse::Data DeviceFactoryResetResponseData; +typedef Model::MDeviceFactoryResetRequest ::Data DeviceFactoryResetRequestData ; +typedef Model::MDeviceFactoryResetResponse ::Data DeviceFactoryResetResponseData; -typedef Model::MDeviceDecommissionRequest ::Data DeviceDecommissionRequestData ; -typedef Model::MDeviceDecommissionResponse::Data DeviceDecommissionResponseData; +typedef Model::MDeviceDecommissionRequest ::Data DeviceDecommissionRequestData ; +typedef Model::MDeviceDecommissionResponse ::Data DeviceDecommissionResponseData; -typedef Model::MDeviceUSBMountRequest ::Data DeviceUSBMountRequestData ; -typedef Model::MDeviceUSBMountResponse::Data DeviceUSBMountResponseData; +typedef Model::MDeviceUSBMountRequest ::Data DeviceUSBMountRequestData ; +typedef Model::MDeviceUSBMountResponse ::Data DeviceUSBMountResponseData; + +typedef Model::MDeviceWifiListRequest ::Data DeviceWifiListRequestData ; +typedef Model::MDeviceWifiListResponse ::Data DeviceWifiListResponseData; + Index: sources/device/DeviceView.cpp =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -22,18 +22,28 @@ #include "DeviceController.h" #include "GuiGlobals.h" #include "encryption.h" +#include "MWifiNetwork.h" VIEW_DEF_CLASS(VDevice) void VDevice::initConnections() { DEVICE_VIEW_INIT_CONNECTIONS_LIST - connect(&_DeviceController , SIGNAL(didPOSTOSVersionData(QString)), this , SLOT( onPOSTOSVersionData(QString))); } -// developer implementation section +// ================================================================================================== +// ================================================= developer implementation section +// ================================================================================================== + +// ================================================= OS Version +void VDevice::onPOSTOSVersionData(const QString &vOSVersion) +{ + osVersion(vOSVersion); +} + +// ================================================= Brightness void VDevice::doInitBrightness() { // DEBUG : qDebug() << "HERE Request" << vValue; DeviceBrightnessRequestData data; @@ -89,7 +99,6 @@ } void VDevice::onAttributeResponse(const DeviceCryptSetupResponseData &vData) { - // DEBUG : qDebug() << "HERE Response" << vData.mBrightnessPercent; // this has to be called to let Gui to set to old value that device controller provided. // this response is not updating the cryptsetup attribute. // cryptsetup attribute will containe the command to be sent to the cryptsetup script @@ -174,7 +183,6 @@ } void VDevice::onAttributeResponse(const DeviceRootSSHAccessResponseData &vData) { - // DEBUG : qDebug() << "HERE Response" << vData.mBrightnessPercent; if ( vData.mAccepted ) { rootSSHAccess(vData.mRootSSHAccess); status(""); @@ -258,7 +266,186 @@ response(true); } -void VDevice::onPOSTOSVersionData(const QString &vOSVersion) +// ================================================= WifiList +void VDevice::doInitWifiList() { + wifiListRequest({}); +} + +void VDevice::wifiListRequest(const QStringList &) { + wifiListEnabled(false); + DeviceWifiListRequestData data; + emit didAttributeRequest(data); +} + +void VDevice::onAttributeResponse(const DeviceWifiListResponseData &vData) { + /// When calling a script, the last echo which is before the exit, is not where the script is completed. + /// therefore we need to store the last one to use it when the script is sending the data and then exits, + /// which is when we have the mComp;eted as true. + static QString result; + // DEBUG : + qDebug() << __FUNCTION__ << vData.mMessage << result << vData.mCompleted; + if ( vData.mCompleted ) { + if ( vData.mAccepted ) { + wifiList({ "SSID1" , "SSID2" }); + status(""); + wifiListEnabled(true); // TODO + parseWifiListResult(result); + status(vData.mMessage); + } + else { + // this has to be called to let Gui to set to old value that device controller provided. + // when not accepted could be a message only to update the screen. + emit wifiListChanged({}); + status(vData.mMessage); + } + } + + accepted(vData.mAccepted); + reason (vData.mReason ); + result = vData.mWifiList; + // has to be the last one + response(true); +} + +/*! + * \brief Network::parseWifiListResult + * \details Extract desired information from the WiFi scan output. Sorts by signal stength + * \param vResult - (QString) output collected from QProcess execution + * \return List of the Found SSIDs in a model. + */ +QVariantList VDevice::parseWifiListResult(const QString &vResult) { - osVersion(vOSVersion); + enum SSIDInfo_Enum { + eSSID , + eBSSID , + eFREQ , + eRATE , + eSIGNAL , + eSECURITY , + eWPA_FLAGS , + eRSN_FLAGS , + eIN_USE , + }; + enum ValueUnit_Enum { + eValue , + eUnit , + eCount , + }; + + struct SSIDInfo { + QString mSSID ; + QString mBSSID ; + QString mFREQ_Max ; + QString mRATE_Max ; + quint16 mSIGNAL_Max ; + QString mSECURITY ; + QString mFLAGS ; // eWPA_FLAGS, eRSN_FLAGS are exclusive + bool mIN_USE = false ; + bool mSupported = true ; + QString toString() { + QStringList fields = QStringList() + << mSSID + << mBSSID + << mFREQ_Max + << mRATE_Max + << QString::number(mSIGNAL_Max) + << mSECURITY + << mFLAGS + << (mSupported ? "T" : "") + << (mIN_USE ? "T" : ""); + return fields.join(','); + } + }; + + QString mResult = vResult; + + SSIDInfo data; + QHash mSSIDInfoList; + + // the Freq, Rate units + QString mSSID; + const QString mFREQ_Unit = " MHz"; + const QString mRATE_Unit = " Mbit/s"; + quint32 mFREQ_Value = 0; + quint32 mRATE_Value = 0; + // Removing the units once from the result to accelerate parsing. (will be added when done) + mResult.remove(mFREQ_Unit); + mResult.remove(mRATE_Unit); + + QStringList lines = mResult.split('\n'); + for ( int row = 0; row < lines.count(); row++ ) { + QStringList fields = lines[row].split(','); + if ( fields[eSSID].trimmed().isEmpty() ) continue; // hidden networks, or an incorrect entry + + QString mWPA_FLAGS; + QString mRSN_FLAGS; + + for ( int index = 0; index < fields.count(); index++ ) { // the list has to be sorted and the script is written that way. + QString field = fields[index].trimmed(); + + if ( row ) { // if is not first row + if ( mSSID == fields[eSSID] ) { // if is the same SSID just update necessary fields + quint32 value = 0; + switch (index) { + case eFREQ : + value = QString("%1").arg(field).toInt(); + if ( mFREQ_Value < value ) { mFREQ_Value = value; } break; + case eRATE : + value = QString("%1").arg(field).toInt(); + if ( mRATE_Value < value ) { mRATE_Value = value; } break; + case eSIGNAL : + value = QString("%1").arg(field).toInt(); + if ( data.mSIGNAL_Max < value ) { data.mSIGNAL_Max = value; } break; + case eIN_USE : data.mIN_USE = field.contains("*"); break; + default: break; + } + } + else { // else add the previous one and continue to the next. + if ( ! mSSID.trimmed().isEmpty() ) { + data.mSSID = mSSID; + data.mFREQ_Max += QString::number(mFREQ_Value) + mFREQ_Unit; + data.mRATE_Max += QString::number(mRATE_Value) + mRATE_Unit; + mSSIDInfoList[mSSID] = data; + qDebug() << data.toString(); + } + // clean up / reset + data.mFREQ_Max = ""; + data.mRATE_Max = ""; + data.mFLAGS = ""; + } + } + + switch (index) { // DO NOT USE default in this switch + case eSSID : mSSID = field; break; + case eBSSID :/* data.mBSSID = field; */ break; // not directly used for now + case eFREQ : mFREQ_Value = QString("%1").arg(field).toInt(); break; + case eRATE : mRATE_Value = QString("%1").arg(field).toInt(); break; + case eSIGNAL : data.mSIGNAL_Max = QString("%1").arg(field).toInt(); break; + case eIN_USE : data.mIN_USE = field.contains("*"); break; + + case eSECURITY : + data.mSECURITY = field; + if ( field.isEmpty() ) { + data.mSupported = false; + } else { + data.mSupported = field.remove(QRegExp("(WPA[23])")).trimmed().isEmpty(); + } + break; + + case eWPA_FLAGS : + if ( field.contains("tkip") ) { mWPA_FLAGS += " TKIP" ; data.mSupported = false; } + if ( field.contains("ccmp") ) { mWPA_FLAGS += " AES" ; } + if ( ! mWPA_FLAGS.isEmpty() ) { data.mFLAGS = mWPA_FLAGS.trimmed(); } + break; + + case eRSN_FLAGS : + if ( field.contains("tkip") ) { mRSN_FLAGS += " TKIP" ; data.mSupported = false; } + if ( field.contains("ccmp") ) { mRSN_FLAGS += " AES" ; } + if ( field.contains("sae" ) ) { mRSN_FLAGS += " SAE" ; } + if ( ! mRSN_FLAGS.isEmpty() ) { data.mFLAGS = mRSN_FLAGS.trimmed(); } + break; + } + } + } + return {}; } Index: sources/device/DeviceView.h =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/device/DeviceView.h (.../DeviceView.h) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -60,12 +60,20 @@ ATTRIBUTE ( QString , decommission , "", Decommission ) PROPERTY ( bool , decommissionEnabled , true ) + ATTRIBUTE ( QStringList , wifiList , {}, WifiList ) + READONLY ( bool , wifiListEnabled , true ) + + + + + VIEW_DEC_CLASS(VDevice) private slots: void onPOSTOSVersionData (const QString &vOSVersion); private: + QVariantList parseWifiListResult(const QString &vResult); bool isCompleteResponse(Model::MDeviceResponseBase::Data vData) { // Either the script exited successfully or the script failed and the reason is provided // There are situations that the script is using the attribute response to update the UI Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -rd866ef66b21f114f07cb80a07860900cd43daff0 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision d866ef66b21f114f07cb80a07860900cd43daff0) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -193,9 +193,8 @@ break case SettingsStack.WiFi: - vNetwork.doInit() + vDevice.doInitWifiList() push( _settingsWiFi ) - // _settingsWiFi.setFocus() // No keyboard popup. break case SettingsStack.Bluetooth: @@ -242,7 +241,7 @@ push( _SettingsRootSSHAccess) break - case SettingsStack.FactoryReset: + case SettingsStack.FactoryReset: push( _serviceFactoryReset ) break Index: sources/gui/qml/pages/settings/SettingsWiFi.qml =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/gui/qml/pages/settings/SettingsWiFi.qml (.../SettingsWiFi.qml) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/gui/qml/pages/settings/SettingsWiFi.qml (.../SettingsWiFi.qml) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -52,7 +52,7 @@ confirmEnabled : isValid confirmVisible : false // since the static setting is done one by one seems confirm is not needed for now. firstFocusInput : _ipAddress - notificationText: vNetwork.status + notificationText: vDevice.status onConfirmClicked: { vNetwork.doConfirm( _ipAddress .textInput.text , @@ -149,8 +149,8 @@ text.text : qsTr("SCAN") width : 350 isDefault : true - enabled :!vNetwork.scanInProgress - onClicked : vNetwork.doScan() + enabled : vDevice.wifiListEnabled + onClicked : vDevice.wifiList = "" } ScrollBar { flickable : _networkList Index: sources/model/MModel.h =================================================================== diff -u -r38ae7b93679d05a54fc460dac68891562d7da72d -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/model/MModel.h (.../MModel.h) (revision 38ae7b93679d05a54fc460dac68891562d7da72d) +++ sources/model/MModel.h (.../MModel.h) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -300,6 +300,8 @@ REGISTER_METATYPE( DeviceDecommissionResponseData ) \ REGISTER_METATYPE( DeviceUSBMountRequestData ) \ REGISTER_METATYPE( DeviceUSBMountResponseData ) \ + REGISTER_METATYPE( DeviceWifiListRequestData ) \ + REGISTER_METATYPE( DeviceWifiListResponseData ) \ /* Settings */ \ REGISTER_METATYPE( SettingsData ) \ REGISTER_METATYPE( WifiNetworkData ) \ Fisheye: Tag 0932b2beee9cc169291cbf69161f902f805237b1 refers to a dead (removed) revision in file `sources/model/hd/alarm/MAlarmMapping.cpp'. Fisheye: No comparison available. Pass `N' to diff? Index: sources/view/hd/data/VTreatmentRanges.cpp =================================================================== diff -u -rd9b9df9b23da89b4c27f4672ff6e7f570adcc48a -r0932b2beee9cc169291cbf69161f902f805237b1 --- sources/view/hd/data/VTreatmentRanges.cpp (.../VTreatmentRanges.cpp) (revision d9b9df9b23da89b4c27f4672ff6e7f570adcc48a) +++ sources/view/hd/data/VTreatmentRanges.cpp (.../VTreatmentRanges.cpp) (revision 0932b2beee9cc169291cbf69161f902f805237b1) @@ -41,8 +41,10 @@ treatmentRanges_Duration_Max ( vData.mDuration_Max ); treatmentRanges_Ultrafiltration_Volume_Min ( vData.mUltrafiltration_Volume_Min / 1000 ); // mL => L treatmentRanges_Ultrafiltration_Volume_Max ( vData.mUltrafiltration_Volume_Max / 1000 ); // mL => L - treatmentRanges_Dialysate_Flow_Min ( vData.mDialysate_Flow_Min - ( vData.mDialysate_Flow_Min % dialysateFlowRateRes() ) ); - treatmentRanges_Dialysate_Flow_Max ( vData.mDialysate_Flow_Max - ( vData.mDialysate_Flow_Max % dialysateFlowRateRes() ) ); + + quint32 mDialysateFlowRateRes = dialysateFlowRateRes(); + treatmentRanges_Dialysate_Flow_Min ( vData.mDialysate_Flow_Min - ( mDialysateFlowRateRes ? vData.mDialysate_Flow_Min % mDialysateFlowRateRes : 0 ) ); + treatmentRanges_Dialysate_Flow_Max ( vData.mDialysate_Flow_Max - ( mDialysateFlowRateRes ? vData.mDialysate_Flow_Min % mDialysateFlowRateRes : 0 ) ); } /*!