Implemented checkJsonVersions().
This commit is contained in:
		@@ -202,13 +202,18 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) {
 | 
				
			|||||||
    return res;
 | 
					    return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
 | 
					bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
 | 
					    for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        uint8_t jsonNr = 0;
 | 
					        uint8_t jsonNr = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QString const &fName = jsonFileNames[i];
 | 
					        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")) {
 | 
					        if (fName.endsWith("conf.json")) {
 | 
				
			||||||
            jsonNr = 1;
 | 
					            jsonNr = 1;
 | 
				
			||||||
        } else
 | 
					        } else
 | 
				
			||||||
@@ -226,31 +231,45 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
 | 
				
			|||||||
                bool ok = false;
 | 
					                bool ok = false;
 | 
				
			||||||
                int n = captured.toInt(&ok);
 | 
					                int n = captured.toInt(&ok);
 | 
				
			||||||
                if (ok) {
 | 
					                if (ok) {
 | 
				
			||||||
                    jsonNr = n + 4;
 | 
					                    jsonNr = n + 5;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (jsonNr != 0) {
 | 
					        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);
 | 
					            m_hw->sys_requestJsonVersions(jsonNr);
 | 
				
			||||||
            QThread::msleep(500);
 | 
					            QThread::msleep(500);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            char buf[64];
 | 
					            char buf[64];
 | 
				
			||||||
            memset(buf, 0x00, sizeof(buf));
 | 
					            memset(buf, 0x00, sizeof(buf));
 | 
				
			||||||
            m_hw->sys_getJsonVersions(jsonNr, 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]);
 | 
					            QString const fileVersion = getFileVersion(jsonFileNames[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            qCritical() << "installed version:" << installedVersion;
 | 
					            QFileInfo fi(jsonFileNames[i]);
 | 
				
			||||||
            qCritical() << "     file version:" << fileVersion;
 | 
					
 | 
				
			||||||
 | 
					            qCritical() << endl;
 | 
				
			||||||
 | 
					            qCritical() << "                json request nr:" << jsonNr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (installedVersion == fileVersion) {
 | 
					            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 {
 | 
					        } else {
 | 
				
			||||||
            qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
 | 
					            qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user