Index: sources/device/DeviceError.cpp =================================================================== diff -u -r9ae3b0d6624904693329309aaf8ff02784c17184 -r6c6f1f5d466badd9b4fd67be7c907234c342b2a2 --- sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 9ae3b0d6624904693329309aaf8ff02784c17184) +++ sources/device/DeviceError.cpp (.../DeviceError.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 DeviceController.cpp + * \file DeviceError.cpp * \author (last) Behrouz NematiPour - * \date (last) 29-May-2021 + * \date (last) 12-Dec-2021 * \author (original) Behrouz NematiPour - * \date (original) 17-Jul-2020 + * \date (original) 06-Jun-2021 * */ #include "DeviceError.h" @@ -27,13 +27,24 @@ using namespace Device; const char *DeviceError::Scripts_Error_Text[] = { - QT_TR_NOOP("The device script file is not found."), - QT_TR_NOOP("The device script file is not executable."), - QT_TR_NOOP("The request is already in progress."), - QT_TR_NOOP("The requested value is out of range."), - QT_TR_NOOP("The requested value is incorrect."), - QT_TR_NOOP("The response value is incorrect."), - QT_TR_NOOP("The watch file is not found."), + QT_TR_NOOP("The device script abnormal exit." ), // eDevice_Scripts_Error_Status + QT_TR_NOOP("The device script file is not found." ), // eDevice_Scripts_Error_NotFound + QT_TR_NOOP("The device script file is not executable." ), // eDevice_Scripts_Error_NotExecutable + QT_TR_NOOP("The request is already in progress." ), // eDevice_Scripts_Error_IsRunning + QT_TR_NOOP("The requested value is out of range." ), // eDevice_Scripts_Error_OutOfRange + QT_TR_NOOP("The requested value is incorrect." ), // eDevice_Scripts_Error_Incorrect_Req + QT_TR_NOOP("The response value is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp + + QT_TR_NOOP("The watch file is not found." ), // eDevice_Watch_Error_NotFound + QT_TR_NOOP("The watch file cannot be added." ), // eDevice_Watch_Error_NotAdded + + QT_TR_NOOP("The Bluetooth cuff pair clear error." ), // eDevice_BCuff_Error_Reset + + QT_TR_NOOP("The Bluetooth cuff pair query error." ), // eDevice_BCuff_Error_Query + QT_TR_NOOP("No paired Bluetooth cuff found." ), // eDevice_BCuff_Error_Query_Empty + QT_TR_NOOP("The Bluetooth cuff pair invalid address." ), // eDevice_BCuff_Error_Query_Addr + + QT_TR_NOOP("The Encrypted Partition error." ), // eDevice_CryptSetup_Error }; /*! @@ -47,23 +58,24 @@ DeviceError::Scripts_Error_Enum DeviceError::checkScript(QString &vScript, const QString &vShellScript) { DeviceError::Scripts_Error_Enum err = DeviceError::eDevice_OK; - vScript = _scriptsFolder + vShellScript; + vScript = Storage::Scripts_Path_Name() + vShellScript; QFileInfo info(vScript); - if ( ! info.exists () ) { err = DeviceError::eDevice_Scripts_Error_NotFound ; goto lOut; } - if ( ! info.isExecutable() ) { err = DeviceError::eDevice_Scripts_Error_NotExecutable ; goto lOut; } + if ( ! info.exists () ) { err = DeviceError::eDevice_Scripts_Error_NotFound ; goto lOut; } + if ( ! info.isExecutable() ) { err = DeviceError::eDevice_Scripts_Error_NotExecutable ; goto lOut; } lOut: return err; } -QString DeviceError::deviceErrorText(DeviceError::Scripts_Error_Enum vError) { +QString DeviceError::deviceErrorText(DeviceError::Scripts_Error_Enum vError, int vExitCode) { QString message; int idx = vError - eDevice_Scripts_Error_Start - 1; - int len = sizeof Scripts_Error_Text / sizeof Scripts_Error_Text[0]; - if (idx > len) { message = QObject::tr("Device error no text defined [%1]").arg(vError); goto lOut; } + int len = (sizeof Scripts_Error_Text / sizeof Scripts_Error_Text[0]); + // DEBUG: qDebug() << len << idx; + if (idx >= len) { message = QObject::tr("Unknown device error %2 [%1]").arg(vExitCode).arg(vError) ; goto lOut; } if (eDevice_Scripts_Error_Start < vError && vError < eDevice_Error_End) { - message = QObject::tr(Scripts_Error_Text[idx]); goto lOut; } + message = QObject::tr(Scripts_Error_Text[idx]) + (vExitCode ? QString(" [%1]").arg(vExitCode) : "") ; goto lOut; } - message = QObject::tr("Device error"); + message = QObject::tr("Device error [%1]").arg(vExitCode); lOut: return message; }