Index: sources/device/DeviceModels.cpp =================================================================== diff -u -ra2a273600d25e863214833ead3324a63fb4759f1 -r6e18f1d24b8cc3d84d26f46f36f73deb34e54371 --- sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision a2a273600d25e863214833ead3324a63fb4759f1) +++ sources/device/DeviceModels.cpp (.../DeviceModels.cpp) (revision 6e18f1d24b8cc3d84d26f46f36f73deb34e54371) @@ -193,7 +193,7 @@ _data.mAccepted = false; // check if the vExitCode passed and it has a value other than zero - if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_FactoryReset_Error; error = *vExitCode; } + if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_Decommission_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 @@ -211,6 +211,49 @@ } /*! + * \brief MDeviceRootSSHAccessResponse::fromByteArray + * \details Checks the response and sets up the model data. + * \param vExitCode - Passed script exit code + * \return true if passed. + */ +bool MDeviceRootSSHAccessResponse::fromByteArray(const QByteArray &vByteArray, int *vExitCode) +{ + // initialize data + bool ok = false; + int error = 0; + _data.mCompleted = true; + _data.mAccepted = false; + _data.mReason = Device::DeviceError::eDevice_OK; + + // set as default if the val is invalid. + _data.mRootSSHAccess = Qt::Unchecked; + + // get the value + QString val = vByteArray; + ok = ! val.isNull() && val.isSimpleText(); + + // check if the vExitCode passed and it has a value other than zero + if ( ! ok ){ _data.mReason = Device::DeviceError::eDevice_Scripts_Error_Incorrect_Rsp_Type ; goto lError; } // there is not a valid value + if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_RootSSHAccess_Error ; goto lApply; } + + // Now everything is good to extract the data + _data.mAccepted = true; + _data.mMessage = QObject::tr("The RootSSHAccess Command Complete."); goto lApply; // normal return + +lApply: + _data.mRootSSHAccess = static_cast(val.toInt()); + goto lOut; + + // immediate exit on fail exitcode and invalid returned value. +lError: + if ( vExitCode ) error = *vExitCode; + _data.mMessage = Device::DeviceError::deviceErrorText(static_cast(_data.mReason), error) + "\n" + vByteArray; + +lOut: + return _data.mAccepted; +} + +/*! * \brief MDeviceWifiListResponse::fromByteArray * \details Checks the response and sets up the model data. * \param vExitCode - Passed script exit code @@ -452,3 +495,42 @@ if ( vError && error ) *vError = error; return ""; } + +/*! + * \brief MDeviceDateTimeResponse::fromByteArray + * \details Checks the response and sets up the model data. + * \param vExitCode - Passed script exit code + * \return true if passed. + */ +bool MDeviceDateTimeResponse::fromByteArray(const QByteArray &vByteArray, int *vExitCode) +{ + // initialize data + bool ok = false; + int error = 0; + _data.mCompleted = true; + _data.mAccepted = false; + _data.mReason = Device::DeviceError::eDevice_OK; + + ok = true; + + // check if the vExitCode passed and it has a value other than zero + if ( ! ok ){ _data.mReason = Device::DeviceError::eDevice_Scripts_Error_Incorrect_Rsp_Type ; goto lError; } // there is not a valid value + if ( vExitCode && *vExitCode ){ _data.mReason = Device::DeviceError::eDevice_DateTime_Error ; goto lApply; } // there still a valid value + + // Now everything is good to extract the data + _data.mAccepted = true; + _data.mMessage = QObject::tr("The Date Time is complete.") ; goto lOut ; // normal return + +// apply returned value in case the passed value is valid (type, range) +// regardless of the exit code (success, fail) +lApply: + goto lOut; + +// immediate exit on fail exitcode and invalid returned value. +lError: + if ( vExitCode ) error = *vExitCode; + _data.mMessage = Device::DeviceError::deviceErrorText(static_cast(_data.mReason), error) + "\n" + vByteArray; + +lOut: + return _data.mAccepted; +}