/*! * * Copyright (c) 2021-2024 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 DeviceView.h * \author (last) Behrouz NematiPour * \date (last) 10-Sep-2023 * \author (original) Behrouz NematiPour * \date (original) 03-Jun-2021 * */ #pragma once // Qt #include #include // Project #include "main.h" // Doxygen : do not remove #include "VView.h" #include "DeviceGlobals.h" #include "DeviceModels.h" #include "MListModel.h" // define // namespace namespace View { /*! * \brief The VDevice class * \details The device view to interact with the UI. * */ class VDevice : public QObject { Q_OBJECT enum DataRole { eRole_Start = Qt::UserRole , // ----- WiFi eRole_WifiMacAddress , eRole_WifiSsid , eRole_WifiSecurityTypes , eRole_WifiSignalLevel , eRole_WifiSupported , eRole_WifiConnected , // ----- Bluetooth eRole_BLE_UNUSED , }; private: TRIGGER ( bool , response , true) PROPERTY ( QString , status , "") READONLY ( bool , accepted , 0) TRIGGER ( quint32 , reason , 0) READONLY ( QString , osVersion , "") ATTRIBUTE ( quint8 , brightness , 0, Brightness ) ATTRIBUTE ( quint8 , bluetoothPairedReset, 0, BluetoothPairedReset ) ATTRIBUTE ( QStringList , bluetoothPairedQuery, {}, BluetoothPairedQuery ) ATTRIBUTE ( QString , cryptSetup , "", CryptSetup ) READONLY ( bool , cryptSetupEnabled , true ) ATTRIBUTE ( Qt::CheckState, rootSSHAccess , Qt::Unchecked , RootSSHAccess ) ATTRIBUTE ( QString , factoryReset , "", FactoryReset ) READONLY ( bool , factoryResetEnabled , true ) ATTRIBUTE ( QString , decommission , "", Decommission ) READONLY ( bool , decommissionEnabled , true ) ATTRIBUTE ( QString , dateTime , "", DateTime ) ATTRIBUTE ( QStringList , wifiList , {}, WifiList ) ATTRIBUTE ( QStringList , wifiInfo , {}, WifiInfo ) ATTRIBUTE ( bool , wifiConnect , false, WifiConnect ) READONLY ( bool , wifiListEnabled , true ) READONLY ( QString , ssid , "" ) READONLY ( QString , ipAddress , "" ) READONLY ( QString , gateway , "" ) READONLY ( QString , subnetMask , "" ) READONLY ( QString , dns , "" ) Q_PROPERTY(MListModel* model READ model NOTIFY didModelChange ) VIEW_DEC_CLASS(VDevice) public slots: void doWifiConnect(bool vConnect, const QString &vSsid, const QString &vPassword); void doDateTime ( const QString &vYear, const QString &vMonth, const QString &vDay, const QString &vHour, const QString &vMinute, bool vNTP); private slots: void onPOSTOSVersionData (const QString &vOSVersion); void onWiFiIP (const QString &vData, bool vWifiError); private: void parseWifiListResult(const QString &vResult); void parseWifiInfoResult(const QString &vResult); void updateWifiList(); MListModel* model () { return &_wifiModel; } MListModel _wifiModel; 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 // but it is not the final/completed response return vData.mAccepted || (!vData.mAccepted && vData.mReason != 0 ); } signals: void didModelChange(); }; }