Implement Update::getInstalledJsonVersions().
This commit is contained in:
parent
94a658ce8a
commit
f8897c2950
@ -711,6 +711,112 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QString, QString>
|
||||||
|
Update::getInstalledJsonVersions(QStringList const& jsonFileNames) {
|
||||||
|
QMap<QString, QString> map;
|
||||||
|
|
||||||
|
if (!m_hw) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||||
|
<< "ERROR!!! m_hw == nullptr";
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 map;
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
|
||||||
|
uint8_t jsonNr = 0;
|
||||||
|
|
||||||
|
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 (fName.endsWith("device.json")) {
|
||||||
|
jsonNr = 2;
|
||||||
|
} else
|
||||||
|
if (fName.endsWith("cash.json")) {
|
||||||
|
jsonNr = 3;
|
||||||
|
} else {
|
||||||
|
QRegularExpressionMatch match;
|
||||||
|
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
|
||||||
|
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) {
|
||||||
|
// note: use 5 (instead of 4 -> index has been shifted)
|
||||||
|
jsonNr = n + 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jsonNr != 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[16] = '\0'; // the DC only handles 16 bytes
|
||||||
|
|
||||||
|
static const QByteArray cb(16, (char)0xff);
|
||||||
|
|
||||||
|
QString const installedVersion(QString::fromStdString(buf));
|
||||||
|
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
||||||
|
|
||||||
|
QFileInfo fi(jsonFileNames[i]);
|
||||||
|
|
||||||
|
if (cb == QByteArray(buf)) {
|
||||||
|
map.insert(fi.fileName(), "inst.vers.not.avail");
|
||||||
|
} else {
|
||||||
|
map.insert(fi.fileName(), installedVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
|
Loading…
Reference in New Issue
Block a user