Index: sources/storage/Logger.cpp =================================================================== diff -u -r16bd55822fa77e5bea6fdfa7b54abf123c1da8bb -r142f2ddb8ce284c52c0add2acf3ac81f471b78de --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 16bd55822fa77e5bea6fdfa7b54abf123c1da8bb) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 142f2ddb8ce284c52c0add2acf3ac81f471b78de) @@ -337,15 +337,7 @@ */ bool Logger::exportLogs(const Gui::GuiStringIndexMap &vExportList) { - // DEBUG: - qDebug() << __FUNCTION__ << vExportList; return false; - // qDebug() << " ~~~~~~~~~~ " << QThread::currentThread()->objectName(); - int result = 0; - QString mDestination = USB_Mount_Point; - QString mCSource = _logPathNames[eLogAppED]; - // Copy Folder - result = FileHandler::copyFolder( mCSource, mDestination); - return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. + return exportList(vExportList, eLogAppED); } /*! @@ -356,15 +348,7 @@ */ bool Logger::exportErrs(const Gui::GuiStringIndexMap &vExportList) { - // DEBUG: - qDebug() << __FUNCTION__ << vExportList; return false; - // qDebug() << " ~~~~~~~~~~ " << QThread::currentThread()->objectName(); - int result = 0; - QString mDestination = USB_Mount_Point; - QString mSource = _logPathNames[eLogDebug]; - // Copy Folder - result = FileHandler::copyFolder( mSource, mDestination); - return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. + return exportList(vExportList, eLogDebug); } /*! @@ -375,15 +359,7 @@ */ bool Logger::exportTrts(const Gui::GuiStringIndexMap &vExportList) { - // DEBUG: - qDebug() << __FUNCTION__ << vExportList; return false; - // qDebug() << " ~~~~~~~~~~ " << QThread::currentThread()->objectName(); - int result = 0; - QString mDestination = USB_Mount_Point; - QString mSource = _logPathNames[eLogTrtmt]; - // Copy Folder - result = FileHandler::copyFolder( mSource, mDestination); - return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. + return exportList(vExportList, eLogTrtmt); } /*! @@ -607,3 +583,40 @@ { return _logPathNames[vLogType]; } + +/*! + * \brief Logger::exportList + * \details Exports files from the list if the vExportList has any item, otherwise exports all the log files of type vLogType. + * \param vExportList - List of files to export + * \param vLogType - type of the log files to get the correct location for export. + * \return true if the export is successful. + */ +bool Logger::exportList(const Gui::GuiStringIndexMap &vExportList, Logger::LogType vLogType) +{ + // DEBUG: qDebug() << __FUNCTION__ << vExportList; + // qDebug() << " ~~~~~~~~~~ " << QThread::currentThread()->objectName(); + + auto notifier = [this] (quint32 vIndex, const QString &vFileName, quint8 vPercent) { + emit didExportStat(vIndex, vFileName, vPercent); + // qDebug() << "0" << vIndex << vFileName << vPercent; + }; + + int result = 0; + QString mSource = _logPathNames[vLogType]; + QString mDestination = USB_Mount_Point; + if ( vExportList.isEmpty() ) { + // Copy Folder + result = FileHandler::copyFolder( mSource, mDestination); + } + else { + Gui::GuiStringIndexMapIterator it(vExportList); + while ( it.hasNext() ) { + it.next(); + // qDebug() << it.key() << it.value() << mSource << mDestination; + auto index = it.key (); + auto filename = it.value(); + result = FileHandler::copyFile(mSource, mDestination + _logBasePathNames[vLogType], filename, ¬ifier, index); + } + } + return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. +}