Index: sources/device/DeviceController.cpp =================================================================== diff -u -r7c86f3854db9ad02d95681203198d75a0d65c9fa -r0e122c98700951af539d9f47c5578e26d640fcc7 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 7c86f3854db9ad02d95681203198d75a0d65c9fa) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) @@ -256,7 +256,7 @@ static bool mOIsReady = false; bool mCIsReady = false; static bool mOIsReadOnly = false; bool mCIsReadOnly = false; static qint64 mOAvailable = 0; qint64 mCAvailable = 0; - static quint8 mOPercent = 0; quint8 mCPercent = 0; + static quint8 mOPercent = 0; quint8 mCPercent = 0; qint64 mCTotal = 0; @@ -477,15 +477,16 @@ vModel._data.mAccepted = false ; vModel._data.mReason = vError ; vModel._data.mMessage = DeviceError::deviceErrorText(vError, vError); - LOG_APPED(src + vModel._data.mMessage + " " + vExtraLogInfo); + LOG_APPED(" ," + src + vModel._data.mMessage + " " + vExtraLogInfo); emit didAttributeResponse(vModel._data); return true; } return false; } +///////////////////////////////////////////// DeviceBrightness /*! - * \brief DeviceController::doBrightness + * \brief DeviceController::onAttributeRequest * \details Sets the brightness level * \param vBrightness */ @@ -548,6 +549,61 @@ } } +///////////////////////////////////////////// DeviceCryptSetup +/*! + * \brief DeviceController::onAttributeRequest + * \details Calls the CryptSetup script with the model data DeviceCryptSetupRequestData + * \param vData - the model data + */ +void DeviceController::onAttributeRequest(const DeviceCryptSetupRequestData &vData) +{ + _deviceCryptSetupRequest._data = vData; + + // ----- check that script exists. + QString script; + if ( checkError( DeviceError::checkScript(script, Crypt_Setup), _deviceCryptSetupResponse, script) ) + return; + + // ----- check if the process is not running + if ( _processCryptSetup.state() != QProcess::NotRunning ) { + checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceCryptSetupResponse); + return; + } + + + // ----- run the process + int timeout = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processCryptSetup, script, timeout, { _deviceCryptSetupRequest._data.mCommand }); + _processCryptSetup.setEnvironment(QProcess::systemEnvironment() << QString("PASSWORD=%1").arg(_deviceCryptSetupRequest._data.mPassword)); + timedProcess->start(); + + MDeviceCryptSetupResponse model; + model._data.mAccepted = false; + model._data.mMessage = tr("Encrypted Partition %1 started.").arg(_deviceCryptSetupRequest._data.mCommand); + didAttributeResponse(model.data()); +} + +/*! + * \brief DeviceController::onProcessCryptSetupExitCode + * \param vExitCode + * \param vStatus + */ +void DeviceController::onProcessCryptSetupExitCode(int vExitCode, QProcess::ExitStatus vStatus) +{ + // The Exit code in this script is not used. + // any other checking is done by UI Software at the moment this script is called. + // The only thing matters is the pared device info in text and it will be empty string if error happens. + MDeviceCryptSetupResponse model; + QByteArray deviceInfo = _processCryptSetup.readAll(); + if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; + else deviceInfo = _processCryptSetup.readAll(); + model.fromByteArray( deviceInfo, &vExitCode ); + // DEBUG: qDebug() << model._data.mEchoInfo; + didAttributeResponse(model.data()); + LOG_APPED_UI(model.data().mMessage); +} + +///////////////////////////////////////////// DeviceBluetoothPaired void DeviceController::onAttributeRequest(const DeviceBluetoothPairedResetRequestData &) { // ----- check that script exists. @@ -578,6 +634,7 @@ didAttributeResponse(model.data()); } +///////////////////////////////////////////// DeviceBluetoothPairedQuery void DeviceController::onAttributeRequest(const DeviceBluetoothPairedQueryRequestData &) { // ----- check that script exists. @@ -598,7 +655,7 @@ void DeviceController::onProcessBluetoothPairedQueryExitCode(int vExitCode, QProcess::ExitStatus vStatus) { - // The Exit code in this script is not used and is not used. + // The Exit code in this script is not used. // any other checking is done by UI Software at the moment this script is called. // The only thing matters is the pared device info in text and it will be empty string if error happens. MDeviceBluetoothPairedQueryResponse model;