/*! * * Copyright (c) 2019-2020 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 * \author (last) Behrouz NematiPour * \date (last) 29-May-2021 * \author (original) Behrouz NematiPour * \date (original) 17-Jul-2020 * */ #include "DeviceError.h" // Linux // Qt #include // Project #include "DeviceGlobals.h" // namespace 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."), }; /*! * \brief DeviceController::checkScript * \details Prepends the script folder path to the script name and checks if the script exists and is executable. * \param vScript : The script name with full path which will be set in this parameter passed argument. * \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; 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; } lOut: return err; }