Index: sources/device/DeviceView.cpp =================================================================== diff -u -re2dc7bd9995a3bb410aa472a1f95c1cc9ba3136d -r6c6f1f5d466badd9b4fd67be7c907234c342b2a2 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision e2dc7bd9995a3bb410aa472a1f95c1cc9ba3136d) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (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 VDevice.cpp + * \file DeviceView.cpp * \author (last) Behrouz NematiPour - * \date (last) 16-Oct-2020 + * \date (last) 11-Nov-2021 * \author (original) Behrouz NematiPour - * \date (original) 23-Aug-2020 + * \date (original) 03-Jun-2021 * */ #include "DeviceView.h" @@ -20,6 +20,7 @@ #include "ApplicationController.h" #include "GuiController.h" #include "GuiGlobals.h" +#include "encryption.h" VIEW_DEF_CLASS(VDevice) @@ -43,19 +44,6 @@ emit didAttributeRequest(data); } -/*! - * \brief VDevice::onAttributeResponse - * \param vData - * - * HERE Request 100 - * _GuiController doAttributeRequest - * _ApplicationController onAttributeRequest - * _DeviceController onAttributeRequest - * _ApplicationController onAttributeResponse - * _GuiController onAttributeResponse - * HERE Response 100 - * - */ void VDevice::onAttributeResponse(const DeviceBrightnessResponseData &vData) { // DEBUG : qDebug() << "HERE Response" << vData.mBrightnessPercent; if ( vData.mAccepted ) { @@ -75,27 +63,58 @@ response(true); } -// -------------------------------- -// developer implementation section -// -------------------------------- +// ================================================= Crypt Setup +void VDevice::doInitCryptSetup() { + // Nothing for now. +} +void VDevice::cryptSetupRequest(const QString &vCommand) { + // DEBUG : qDebug() << "HERE Request" << vValue; + cryptSetupEnabled(false); + + DeviceCryptSetupRequestData data; + data.mCommand = vCommand; + bool ok = false; + data.mPassword = encryption::configurationsPassword( ok ); + if ( ! ok ) { // not enough infromation to create a secure passowrd + status(tr("Not enough secure information provided")); + } + else { + emit didAttributeRequest(data); + } +} + +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 + // and the retrurned message can be the model message in vData.mMessage + status(vData.mMessage); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + cryptSetupEnabled(isCompleteResponse(vData)); + + // has to be the last one + response(true); +} + +// ================================================= Bluetooth Paired Reset void VDevice::doInitBluetoothPairedReset() { - // DEBUG : - qDebug() << "HERE Init"; + // DEBUG : qDebug() << "HERE Init"; DeviceBluetoothPairedResetRequestData data; emit didAttributeRequest(data); } void VDevice::bluetoothPairedResetRequest(const quint8 &) { - // DEBUG : - qDebug() << "HERE Request"; - // DeviceBluetoothPairedResetRequestData data; - // emit didAttributeRequest(data); + // DEBUG : qDebug() << "HERE Request"; + // Nothing to be done here. This property will not be assigned. } void VDevice::onAttributeResponse(const DeviceBluetoothPairedResetResponseData &vData) { - // DEBUG : - qDebug() << "HERE Response" << vData.mAccepted << vData.mReason << vData.mMessage; + // DEBUG : qDebug() << "HERE Response" << vData.mAccepted << vData.mReason << vData.mMessage; // this has to be called to let Gui to set to old value that device controller provided. status(vData.mMessage); @@ -107,3 +126,128 @@ response(true); } +// ================================================= Bluetooth Paired Query +void VDevice::doInitBluetoothPairedQuery() { + // DEBUG : qDebug() << "HERE Init"; + DeviceBluetoothPairedQueryRequestData data; + emit didAttributeRequest(data); +} + +void VDevice::bluetoothPairedQueryRequest(const QStringList &) { + // DEBUG : qDebug() << "HERE Request"; + // Nothing to be done here. This property will not be assigned. +} + +void VDevice::onAttributeResponse(const DeviceBluetoothPairedQueryResponseData &vData) { + // DEBUG : qDebug() << "HERE Response" << vData.mAccepted << vData.mReason << vData.mMessage; + // this has to be called to let Gui to set to old value that device controller provided. + status(vData.mMessage); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + emit bluetoothPairedQueryChanged(vData.mInfo); + response(true); +} + +// ================================================= RootSSHAccess +void VDevice::doInitRootSSHAccess() { + // DEBUG : qDebug() << "HERE Request" << vValue; + DeviceRootSSHAccessRequestData data; + data.mIsGet = true; + emit didAttributeRequest(data); +} + +void VDevice::rootSSHAccessRequest(const bool &vValue) { + // DEBUG : qDebug() << "HERE Request" << vValue; + DeviceRootSSHAccessRequestData data; + data.mIsGet = false; + data.mRootSSHAccess = vValue; + emit didAttributeRequest(data); +} + +void VDevice::onAttributeResponse(const DeviceRootSSHAccessResponseData &vData) { + // DEBUG : qDebug() << "HERE Response" << vData.mBrightnessPercent; + if ( vData.mAccepted ) { + rootSSHAccess(vData.mRootSSHAccess); + status(""); + } + else { + // this has to be called to let Gui to set to old value that device controller provided. + emit rootSSHAccessChanged(vData.mRootSSHAccess); + status(vData.mMessage); + } + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + response(true); +} + +// ================================================= Factory Reset +void VDevice::doInitFactoryReset() { + // Nothing for now. +} + +void VDevice::factoryResetRequest(const QString &vCommand) { + Q_UNUSED(vCommand) + // DEBUG : qDebug() << "HERE Request" << vCommand; + + factoryResetEnabled(false); + + DeviceFactoryResetRequestData data; + emit didAttributeRequest(data); +} + +void VDevice::onAttributeResponse(const DeviceFactoryResetResponseData &vData) { + // QDEBUG : qDebug() << "HERE Response " << Q_FUNC_INFO << " accepted: " << vData.mAccepted; + // this has to be called to let Gui to set to old value that device controller provided. + status(vData.mMessage); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + factoryResetEnabled(isCompleteResponse(vData)); + + // has to be the last one + response(true); +} + +// ================================================= Decommission +void VDevice::doInitDecommission() { + // Nothing for now. +} + +void VDevice::decommissionRequest(const QString &vCommand) { + Q_UNUSED(vCommand) + // DEBUG : qDebug() << "HERE Request" << vCommand; + + decommissionEnabled(true); + + DeviceDecommissionRequestData data; + bool ok = false; + data.mPassword = encryption::configurationsPassword( ok ); + if ( ! ok ) { // not enough infromation to create a secure passowrd + status(tr("Not enough secure information provided")); + } + else { + emit didAttributeRequest(data); + } + emit didAttributeRequest(data); +} + +void VDevice::onAttributeResponse(const DeviceDecommissionResponseData &vData) { + //QDEBUG : qDebug() << "HERE Response " << Q_FUNC_INFO << " accepted: "<< vData.mAccepted << vData.mReason; + // this has to be called to let Gui to set to old value that device controller provided. + status(vData.mMessage); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + decommissionEnabled(isCompleteResponse(vData)); + + // has to be the last one + response(true); +}