Index: sources/device/DeviceController.cpp =================================================================== diff -u -re38423dd3840e625ed0728d9b0fb3f9eb9292500 -ra527408b1941641fe0f60e866d0c122fdf519551 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision e38423dd3840e625ed0728d9b0fb3f9eb9292500) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision a527408b1941641fe0f60e866d0c122fdf519551) @@ -970,44 +970,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 +1073,8 @@ */ void DeviceController::findPendingLogs() { + if ( ! gLongLogName ) return; + static QString pendingLog = ""; if( _pendingCounter ) { _pendingCounter -- ; @@ -1061,9 +1086,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 +1138,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 +1157,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 +1189,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 +1208,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 +1252,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 +1267,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