diff --git a/DownloadDCJsonFiles/update.cpp b/DownloadDCJsonFiles/update.cpp index 420b895..c42103f 100644 --- a/DownloadDCJsonFiles/update.cpp +++ b/DownloadDCJsonFiles/update.cpp @@ -138,10 +138,11 @@ Update::~Update() { unloadDCPlugin(); } -bool Update::doUpdate(QStringList const &filesToWorkOn) { +bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) { if (!m_hw) { - qCritical() << "ERROR!!! m_hw == nullptr"; + qCritical() << "(" << __func__ << ":" << __LINE__ << "):" + << "ERROR!!! m_hw == nullptr"; return false; } @@ -149,10 +150,12 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) { while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) { // must deliver 'true', only then are all data from hwapi valid if (--tries < 0) { - qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED"; + qCritical() << "(" << __func__ << ":" << __LINE__ << "):" + << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED"; return false; } - qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")"; + qCritical() << "(" << __func__ << ":" << __LINE__ << "):" + << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")"; m_hw->dc_autoRequest(true); QThread::msleep(500); } @@ -161,7 +164,8 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) { QList::const_iterator it; for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) { - QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed()); + QString const &fToWorkOn = usbStickDetected ? QDir::cleanPath(it->trimmed()) + : QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed()); if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive) && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { res = true; @@ -203,6 +207,25 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) { } bool Update::checkJsonVersions(QStringList const& jsonFileNames) { + if (!m_hw) { + qCritical() << "(" << __func__ << ":" << __LINE__ << "):" + << "ERROR!!! m_hw == nullptr"; + return false; + } + + int tries = 20; + while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) { + // must deliver 'true', only then are all data from hwapi valid + if (--tries < 0) { + qCritical() << "(" << __func__ << ":" << __LINE__ << "):" + << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED"; + return false; + } + qCritical() << "(" << __func__ << ":" << __LINE__ << "):" + << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")"; + m_hw->dc_autoRequest(true); + QThread::msleep(500); + } for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) { @@ -231,6 +254,7 @@ bool Update::checkJsonVersions(QStringList const& jsonFileNames) { bool ok = false; int n = captured.toInt(&ok); if (ok) { + // note: use 5 (instead of 4 -> index has been shifted) jsonNr = n + 5; } } diff --git a/DownloadDCJsonFiles/update.h b/DownloadDCJsonFiles/update.h index 9e2496b..daa3037 100644 --- a/DownloadDCJsonFiles/update.h +++ b/DownloadDCJsonFiles/update.h @@ -58,7 +58,7 @@ public: virtual ~Update() override; - bool doUpdate(QStringList const &jsonFilesToDownload); + bool doUpdate(QStringList const &jsonFilesToDownload, bool usbStickDetected = false); bool updatePrinterTemplate(int templateIdx, QString fname) const; bool updateConfig(QString jsFileToSendToDC);