Index: sources/device/DeviceError.cpp =================================================================== diff -u -rf38edd22f7b63694c21b83d6f4b69ea618390126 -r9ae3b0d6624904693329309aaf8ff02784c17184 --- sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision f38edd22f7b63694c21b83d6f4b69ea618390126) +++ sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 9ae3b0d6624904693329309aaf8ff02784c17184) @@ -17,6 +17,7 @@ // Linux // Qt +#include #include // Project @@ -32,6 +33,7 @@ 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."), }; /*! @@ -41,13 +43,27 @@ * \param vShellScript : The shell script name * \return true if succeeds and false otherwise */ + DeviceError::Scripts_Error_Enum DeviceError::checkScript(QString &vScript, const QString &vShellScript) { - DeviceError::Scripts_Error_Enum err = DeviceError::eScripts_OK; + DeviceError::Scripts_Error_Enum err = DeviceError::eDevice_OK; vScript = _scriptsFolder + vShellScript; QFileInfo info(vScript); - if ( ! info.exists () ) { err = DeviceError::eScripts_Error_NotFound ; goto lOut; } - if ( ! info.isExecutable() ) { err = DeviceError::eScripts_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 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; } + if (eDevice_Scripts_Error_Start < vError && vError < eDevice_Error_End) { + message = QObject::tr(Scripts_Error_Text[idx]); goto lOut; } + + message = QObject::tr("Device error"); +lOut: + return message; +}