Index: sources/device/DeviceController.cpp =================================================================== diff -u -r2467780df22b7fdfb309612abe987d116a657327 -r9a4884724d8d203b6529def6a7108d179018bf41 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 2467780df22b7fdfb309612abe987d116a657327) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 9a4884724d8d203b6529def6a7108d179018bf41) @@ -565,7 +565,7 @@ } // ----- run the process - int timeout_ms = 1000; + int timeout_ms = 10000; QStringList params; params << QString::number(_deviceBrightnessRequest._data.mBrightness_val); TimedProcess *timedProcess = new TimedProcess(&_processBrightness, script, timeout_ms, params); @@ -632,9 +632,10 @@ } // ----- run the process + int timeout_ms = 10000; QStringList params; if ( ! _deviceRootSSHAccessRequest._data.mIsGet ) params << FSN(_deviceRootSSHAccessRequest._data.mRootSSHAccess); - TimedProcess *timedProcess = new TimedProcess(&_processRootSSHAccess, script, 1000, params); + TimedProcess *timedProcess = new TimedProcess(&_processRootSSHAccess, script, timeout_ms, params); timedProcess->start(); } @@ -796,7 +797,8 @@ } // ----- run the process - TimedProcess *timedProcess = new TimedProcess(&_processBluetoothPairedReset, script, 2000); + int timeout_ms = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processBluetoothPairedReset, script, timeout_ms); timedProcess->start(); } @@ -827,7 +829,8 @@ } // ----- run the process - TimedProcess *timedProcess = new TimedProcess(&_processBluetoothPairedQuery, script, 1000); + int timeout_ms = 10000; + TimedProcess *timedProcess = new TimedProcess(&_processBluetoothPairedQuery, script, timeout_ms); timedProcess->start(); } @@ -970,44 +973,67 @@ emit didPOSTCloudSyncData (vNetAddress); } -void DeviceController::onLogBackup(const QString &vFileName) +bool DeviceController::logBackup(const QString &vFileName) { + if ( ! gLongLogName ) return false; + + bool ok = true; QFileInfo fileInfo(vFileName); QString filePath(fileInfo.absolutePath()); QString fileBase(fileInfo.baseName()); - // ------------------------------------------------------------------------ TODO: Improve : get pending type extention - QString fileSufx(fileInfo.completeSuffix().prepend("u.")); + QString fileSufx(fileInfo.completeSuffix().prepend(_Logger.logFileNamePendingSubExt())); QString fileDest(QString("%1/%2.%3").arg(filePath, fileBase, fileSufx)); // DEBUG // qDebug() << ""; // qDebug() << vFileName; // qDebug() << fileDest; - QFile::rename(vFileName, fileDest); + ok = QFile::rename(vFileName, fileDest); + return ok; } -void DeviceController::onLogUpload(const QString &vFileName) +void DeviceController::onLogBackup(const QString &vFileName) { + if ( ! gLongLogName ) return; + + bool ok = true; + ok = logBackup( vFileName); + emit didLogBackup(ok, vFileName); +} + +bool DeviceController::logUpload(const QString &vFileName) +{ + if ( ! gLongLogName ) return false; + + bool ok = true; QFileInfo fileInfo(vFileName); - QString filePath(Storage::Log_Folder_Base); + QString filePath; QString fileBase(fileInfo.baseName()); - // ------------------------------------------------------------------------ TODO: Improve : get pending type extention - QString fileSufx(fileInfo.completeSuffix().remove("u.")); - // ------------------------------------------------------------------------ TODO: Improve : get type - if( fileSufx == "log" ) { - filePath += Storage::Log_Folder_Application; - } - // ------------------------------------------------------------------------ TODO: Improve : get type - if( fileSufx == "err" ) { - filePath += Storage::Log_Folder_Service; - } - QString fileDest(QString("%1.%2").arg(fileBase, fileSufx)); + QString ext = _Logger.logFileNamePendingSubExt(); + QString fileSufx(fileInfo.completeSuffix().remove(ext)); + QString fileDest = QString("%1.%2").arg(fileBase, fileSufx); + + Logger::LogType logType = _Logger.logFileLogType(vFileName, filePath); + ok = logType != Logger::eLogNone; + if ( ! ok ) { LOG_APPED_UI(QString("CS Incorrect log upload type [%1]").arg(fileSufx)); goto lOut; } // DEBUG // qDebug() << ""; // qDebug() << vFileName; // qDebug() << fileDest; - QFile::rename(filePath + vFileName, filePath + fileDest); + + ok = QFile::rename(filePath + vFileName, filePath + fileDest); +lOut: + return ok; } +void DeviceController::onLogUpload(const QString &vFileName) +{ + if ( ! gLongLogName ) return; + + bool ok = true; + ok = logUpload( vFileName); + emit didLogUpload(ok, vFileName); +} + /*! * \brief DeviceController::checkConfugurationMountReady * \details Cheks if the system is ready to mount the encrypted partition. @@ -1050,6 +1076,8 @@ */ void DeviceController::findPendingLogs() { + if ( ! gLongLogName ) return; + static QString pendingLog = ""; if( _pendingCounter ) { _pendingCounter -- ; @@ -1061,9 +1089,7 @@ QFileInfoList pendingFiles; QString logLoc = Log_Folder_Base; - // ------------------------------------------------------------------------ TODO: Improve : get pending type extention - QString logExt = "*.u.*"; - + QString logExt = QString("*.%1*").arg(_Logger.logFileNamePendingSubExt()); // "*.u.*"; for( auto logFolder : { Log_Folder_Application, Log_Folder_Service/*, Log_Folder_CloudSync*/ } ) { pendingFiles = Storage::FileHandler::find( logLoc + logFolder, { logExt } ); // look into the list. @@ -1115,7 +1141,7 @@ MDeviceFactoryResetResponse model; model._data.mAccepted = false; // will indirectly set the property factoryResetEnabled model._data.mMessage = tr("Factory Reset started."); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } /*! @@ -1134,8 +1160,8 @@ else deviceInfo = _processFactoryReset.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); // DEBUG: qDebug() << model._data.mMessage << deviceInfo; - emit didAttributeResponse(model.data()); - emit didFactoryReset(model._data.mAccepted); + emit didAttributeResponse (model.data()); + emit didFactoryReset (model._data.mAccepted); LOG_APPED_UI(model.data().mMessage); } @@ -1166,7 +1192,7 @@ MDeviceDecommissionResponse model; model._data.mAccepted = false; // will indirectly set the property decommissionEnabled model._data.mMessage = tr("Decommissioning started."); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } /*! @@ -1185,7 +1211,9 @@ else deviceInfo = _processDecommission.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); // DEBUG: qDebug() << model._data.mMessage << deviceInfo; - didAttributeResponse(model.data()); + emit didAttributeResponse (model.data()); + emit didDecommissioning (model._data.mAccepted); + LOG_APPED_UI(model.data().mMessage); } @@ -1227,7 +1255,7 @@ MDeviceUSBMountResponse model; model._data.mAccepted = false; model._data.mMessage = vIsMount ? tr("USB unmount started.") : tr("USB mount started"); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); } /*! @@ -1242,7 +1270,7 @@ if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; else deviceInfo = _processUSBMount.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); - didAttributeResponse(model.data()); + emit didAttributeResponse(model.data()); // Re-evaluate the USB space available - need to call this here to avoid // visual lag caused by waiting to call this function on the timer timeout