Add computeFilesToUpdate() and downloadFilesToPSA() helper functions.

This commit is contained in:
Gerhard Hoffmann 2023-11-07 09:10:45 +01:00
parent 90de2f415e
commit 14b4c035da

View File

@ -626,15 +626,31 @@ bool Worker::filesToUpdate() {
return false; return false;
} }
return true; return true;
} }
bool Worker::updateFiles() { bool Worker::computeFilesToDownload() {
m_filesToDownload.clear(); m_filesToDownload.clear();
m_displayIndex = 0; for (int i = 0; i < m_filesToUpdate.size(); ++i) {
QString const fName = m_filesToUpdate.at(i);
if (fName.contains("DC2C_print", Qt::CaseInsensitive) ||
fName.contains("DC2C_device", Qt::CaseInsensitive) ||
fName.contains("DC2C_conf", Qt::CaseInsensitive) ||
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
m_filesToDownload << fName; // download printer-config-files
} else {
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
if (fName.contains(version)) {
m_filesToDownload << fName; // download device controller
}
}
}
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::APPLY_REPOSITORY_CHANGES); return (m_filesToDownload.size() > 0);
}
bool Worker::execOpkgCommands() {
for (int i = 0; i < m_filesToUpdate.size(); ++i) { for (int i = 0; i < m_filesToUpdate.size(); ++i) {
QString const fName = m_filesToUpdate.at(i); QString const fName = m_filesToUpdate.at(i);
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) { if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
@ -711,31 +727,32 @@ bool Worker::updateFiles() {
} }
} }
} }
} else
if (fName.contains("DC2C_print", Qt::CaseInsensitive) ||
fName.contains("DC2C_device", Qt::CaseInsensitive) ||
fName.contains("DC2C_conf", Qt::CaseInsensitive) ||
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
m_filesToDownload << fName; // download printer-config-files
} else {
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
if (fName.contains(version)) {
m_filesToDownload << fName; // download device controller
} }
} }
return true;
} }
if (m_filesToDownload.size() > 0) { bool Worker::downloadFilesToPSAHardware() {
m_displayIndex = 0;
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE);
if (m_noUpdatePsaHardware == false) {
if (computeFilesToDownload()) {
CONSOLE(m_filesToDownload) << UPDATE_STEP::FILES_TO_DOWNLOAD; CONSOLE(m_filesToDownload) << UPDATE_STEP::FILES_TO_DOWNLOAD;
Update *update = m_mainWindow->getUpdate(); Update update(this,
if (update) { QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr),
return update->doUpdate(m_displayIndex, m_filesToDownload); m_customerNrStr,
m_branchName,
m_pluginDir,
m_pluginName,
m_workingDirectory);
return update.doUpdate(m_displayIndex, m_filesToDownload);
} else { } else {
CONSOLE(QStringList("UPDATE NOT SET")) << UPDATE_STEP::ERROR; CONSOLE(QStringList("NO FILES TO DOWNLOAD TO PSA-HW")) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE;
} }
} else {
CONSOLE(QStringList("NO FILES TO DOENLOAD TO PSA-HW")) << UPDATE_STEP::ERROR;
} }
return true; return true;