Index: sources/device/DeviceView.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r2a0e56982ad45cdd98a6d0425c53e52610c29961 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 2a0e56982ad45cdd98a6d0425c53e52610c29961) @@ -20,6 +20,7 @@ #include "ApplicationController.h" #include "GuiController.h" #include "GuiGlobals.h" +#include "encryption.h" VIEW_DEF_CLASS(VDevice) @@ -62,6 +63,40 @@ response(true); } +void VDevice::doInitCryptSetup() { + // Nothing for now. +} + +void VDevice::cryptSetupRequest(const QString &vCommand) { + // DEBUG : qDebug() << "HERE Request" << vValue; + DeviceCryptSetupRequestData data; + data.mCommand = vCommand; + bool ok = false; + data.mPassword = encryption::defaultServicePassword( 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); + cryptSetupEnabled(vData.mAccepted); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + response(true); +} + void VDevice::doInitBluetoothPairedReset() { // DEBUG : qDebug() << "HERE Init"; DeviceBluetoothPairedResetRequestData data; @@ -109,3 +144,65 @@ emit bluetoothPairedQueryChanged(vData.mInfo); response(true); } + +// ================================================= Factory Reset +void VDevice::doInitFactoryReset() { + // Nothing for now. +} + +void VDevice::factoryResetRequest(const QString &vCommand) { + Q_UNUSED(vCommand) + // DEBUG : qDebug() << "HERE Request" << vCommand; + 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); + + // Either the script exited successfully or the script failed and the reason is provided + factoryResetEnabled(vData.mAccepted || (!vData.mAccepted && vData.mReason!=0)); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // 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; + DeviceDecommissionRequestData data; + bool ok = false; + data.mPassword = encryption::defaultServicePassword( 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); + + // Either the script exited successfully or the script failed and the reason is provided + decommissionEnabled(vData.mAccepted || (!vData.mAccepted && vData.mReason!=0)); + + accepted(vData.mAccepted); + reason (vData.mReason ); + + // has to be the last one + response(true); +}