Fix: shift jsonNr by 1 in checkDownloadedJsonVersions(); print-templates start now with 6 instead of 5.

This commit is contained in:
Gerhard Hoffmann 2024-05-08 16:17:28 +02:00
parent 2e3af64c02
commit 1d64769094

View File

@ -627,58 +627,78 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
uint8_t jsonNr = 0;
QFileInfo fInfo(jsonFileNames[i]);
if (fInfo.fileName().endsWith("conf.json")) {
QString const &fName = jsonFileNames[i];
// send one request for every single version
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
// 6=printer template 1 ..... 36= template 32
if (fName.endsWith("conf.json")) {
jsonNr = 1;
} else
if (fInfo.fileName().endsWith("device.json")) {
if (fName.endsWith("device.json")) {
jsonNr = 2;
} else
if (fInfo.fileName().endsWith("cash.json")) {
if (fName.endsWith("cash.json")) {
jsonNr = 3;
} else {
QRegularExpressionMatch match;
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
int idx = fInfo.fileName().indexOf(re, 0, &match);
int idx = fName.indexOf(re, 0, &match);
if (idx != -1) {
QString captured = match.captured(match.lastCapturedIndex());
bool ok = false;
int n = captured.toInt(&ok);
if (ok) {
jsonNr = n + 4;
jsonNr = n + 5;
}
}
}
if (jsonNr != 0) {
#if 0
// send one request for every single version
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
// 5=printer template 1 ..... 36= template 32
m_hw->sys_requestJsonVersions(jsonNr);
QThread::msleep(500);
char buf[64];
memset(buf, 0x00, sizeof(buf));
m_hw->sys_getJsonVersions(jsonNr, buf);
buf[sizeof(buf)-1] = '\0';
buf[16] = '\0'; // the DC only handles 16 bytes
QString const installedVersion(buf);
static const QByteArray cb(16, (char)0xff);
QString const installedVersion(QString::fromStdString(buf));
QString const fileVersion = getFileVersion(jsonFileNames[i]);
qCritical() << "installed version:" << installedVersion;
qCritical() << " file version:" << fileVersion;
QFileInfo fi(jsonFileNames[i]);
qCritical() << endl;
qCritical() << " json request nr:" << jsonNr;
if (installedVersion == fileVersion) {
qCritical() << " json file:" << fi.fileName();
qCritical() << " installed version in DC:" << installedVersion;
} else
if (cb == QByteArray(buf) && fileVersion == "") {
qCritical() << "unknown json file (repo and DC):" << fi.fileName();
} else {
qCritical() << " json file:" << fi.fileName();
qCritical() << " installed version in DC:" << installedVersion;
qCritical() << " file version in repository:" << fileVersion;
}
#endif
} else {
qCritical() << "CANNOT FIND JSON-NR FOR" << jsonFileNames[i];
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
}
}
return false;
}
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
if (!m_hw) {