Additinal UPDATE_STATE constants.

Added struct UpdateStatus for printing debug messages.
Added member variables used for sending SENDCMD to ISMAS.A
Added helper functions
    getATBQTVersion(),
    getCPUSerial(),
    getRaucVersion(),
    getOpkgVersion(),
    getPluginVersion(),
    getDCVersion(),
    getFileSize().

Removed automatic restart of Apism.
Added emergency timer to end application after 10 mintes.
onHandleChangedFilenames():
    handling of opkg_commands
    handling of json/dc -> deactivated for the moment.
Re-implemented onSendCmdSendVersionToIsmas(): use only one parameter of type PSAInstalled.
Implemented operators<<() to print debug messages.
This commit is contained in:
Gerhard Hoffmann 2023-07-19 16:42:18 +02:00
parent 088d7c8aa0
commit 0e0363f131

View File

@ -43,7 +43,8 @@ Worker::Worker(hwinf *hw,
QObject *parent, QObject *parent,
char const *serialInterface, char const *serialInterface,
char const *baudrate) char const *baudrate)
: m_workerThread("workerThread") : m_hw(hw)
, m_workerThread("workerThread")
, m_apismClient(0, 0, 0, this) // TODO , m_apismClient(0, 0, 0, this) // TODO
, m_customerNr(customerNr) , m_customerNr(customerNr)
, m_customerNrStr(QString("customer_") + QString::number(m_customerNr).rightJustified(3, '0')) , m_customerNrStr(QString("customer_") + QString::number(m_customerNr).rightJustified(3, '0'))
@ -51,10 +52,22 @@ Worker::Worker(hwinf *hw,
, m_zoneNr(zoneNr) , m_zoneNr(zoneNr)
, m_workingDirectory(workingDirectory) , m_workingDirectory(workingDirectory)
, m_branchName(branchName) , m_branchName(branchName)
, m_customerRepositoryPath(QString("https://git.mimbach49.de/GerhardHoffmann/%1.git").arg(m_customerNrStr))
, m_customerRepository(QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr)) , m_customerRepository(QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr))
, m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this) , m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this)
, m_maintenanceMode(maintenanceMode) , m_maintenanceMode(maintenanceMode)
, m_osVersion(getOsVersion()) , m_osVersion(getOsVersion())
, m_atbqtVersion(getATBQTVersion())
, m_cpuSerial(getCPUSerial())
, m_raucVersion(getRaucVersion())
, m_opkgVersion(getOpkgVersion())
, m_pluginVersionATBDeciceController(getPluginVersion("/opt/app/ATBAPP/plugins/libATBDeviceControllerPlugin.so"))
, m_pluginVersionIngenicoISelf(getPluginVersion("/opt/app/ATBAPP/plugins/libIngenicoISelf_CCPlugin.so"))
, m_pluginVersionMobilisisCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin.so"))
, m_pluginVersionMobilisisCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin_ConfigUi.so"))
, m_pluginVersionPrmCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin.so"))
, m_pluginVersionPrmCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin_ConfigUi.so"))
, m_pluginVersionTcpZvt(getPluginVersion("/opt/app/ATBAPP/plugins/libTCP_ZVT_CCPlugin.so"))
, m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS) , m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
, m_waitForNewUpdates(this) { , m_waitForNewUpdates(this) {
@ -62,21 +75,23 @@ Worker::Worker(hwinf *hw,
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate); qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
qInfo() << "OS VERSION ................." << m_osVersion; qInfo() << "OS VERSION ................." << m_osVersion;
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
qInfo() << "CPU SERIAL ................." << m_cpuSerial;
qInfo() << "CUSTOMER_NR ................" << m_customerNr; qInfo() << "CUSTOMER_NR ................" << m_customerNr;
qInfo() << "CUSTOMER_NR_STR ............" << m_customerNrStr; qInfo() << "CUSTOMER_NR_STR ............" << m_customerNrStr;
qInfo() << "CUSTOMER_REPOSITORY_PATH ..." << QString("https://git.mimbach49.de/GerhardHoffmann/%1.git").arg(m_customerNrStr); qInfo() << "CUSTOMER_REPOSITORY_PATH ..." << m_customerRepositoryPath;
qInfo() << "CUSTOMER_REPOSITORY ........" << m_customerRepository; qInfo() << "CUSTOMER_REPOSITORY ........" << m_customerRepository;
qInfo() << "MACHINE_NR ................." << m_machineNr; qInfo() << "MACHINE_NR ................." << m_machineNr;
qInfo() << "ZONE_NR ...................." << m_zoneNr; qInfo() << "ZONE_NR ...................." << m_zoneNr;
qInfo() << "BRANCH_NAME ................" << m_branchName; qInfo() << "BRANCH_NAME ................" << m_branchName;
qInfo() << "WORKING_DIRECTORY .........." << m_workingDirectory; qInfo() << "WORKING_DIRECTORY .........." << m_workingDirectory;
QProcess p; //QProcess p;
p.start("/bin/systemctl", {"restart", "apism"}); //p.start("/bin/systemctl", {"restart", "apism"});
if (!p.waitForStarted(5000) || !p.waitForFinished(5000)) { //if (!p.waitForStarted(5000) || !p.waitForFinished(5000)) {
qCritical() << "APISM-RESTART-FAILURE"; // qCritical() << "APISM-RESTART-FAILURE";
return; // return;
} //}
this->moveToThread(&m_workerThread); this->moveToThread(&m_workerThread);
m_workerThread.start(); m_workerThread.start();
@ -105,15 +120,22 @@ Worker::Worker(hwinf *hw,
connect(this, SIGNAL(terminateUpdateProcess()), this, connect(this, SIGNAL(terminateUpdateProcess()), this,
SLOT(onTerminateUpdateProcess()), Qt::QueuedConnection); SLOT(onTerminateUpdateProcess()), Qt::QueuedConnection);
connect(&m_emergencyTimer, SIGNAL(timeout()), this, SLOT(onTerminateUpdateProcess()), Qt::QueuedConnection);
m_emergencyTimer.setSingleShot(true);
m_emergencyTimer.start(1000 * 60 * 10);
QDir customerRepository(m_customerRepository); QDir customerRepository(m_customerRepository);
if (!customerRepository.exists()) { if (!customerRepository.exists()) {
if (m_gc.gitCloneAndCheckoutBranch()) { if (m_gc.gitCloneAndCheckoutBranch()) {
// do nothing else, not even executing opkg-commands // do nothing else, not even executing opkg-commands
onFinishUpdateProcess(false); emit this->finishUpdateProcess(false);
} }
} else { } else {
m_update = new Update(hw, m_customerRepository, m_customerNrStr, m_update = new Update(m_hw,
m_branchName, m_workingDirectory, m_customerRepository,
m_customerNrStr,
m_branchName,
m_workingDirectory,
dryRun, parent, serialInterface, baudrate); dryRun, parent, serialInterface, baudrate);
connect(&m_startUpdateProcess, SIGNAL(timeout()), this, SLOT(askIsmasForNewData()), Qt::QueuedConnection); connect(&m_startUpdateProcess, SIGNAL(timeout()), this, SLOT(askIsmasForNewData()), Qt::QueuedConnection);
@ -150,36 +172,111 @@ QString Worker::getOsVersion() const {
return "N/A"; return "N/A";
} }
QString Worker::getATBQTVersion() const {
QString const cmd = QString("echo -n $(/opt/app/ATBAPP/ATBQT -v | head -n 2 | cut -d':' -f2)");
Command c("bash");
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
return c.getCommandResult();
}
return "N/A";
}
QString Worker::getCPUSerial() const {
QString const cmd = QString("echo -n $(cat /proc/cpuinfo | grep -i Serial | cut -d':' -f2)");
Command c("bash");
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
return c.getCommandResult();
}
return "N/A";
}
QString Worker::getRaucVersion() const {
QString const cmd = QString("echo -n $(rauc --version)");
Command c("bash");
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
return c.getCommandResult();
}
return "N/A";
}
QString Worker::getOpkgVersion() const {
QString const cmd = QString("echo -n $(opkg --version)");
Command c("bash");
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
return c.getCommandResult();
}
return "N/A";
}
QString Worker::getPluginVersion(QString const &pluginFileName) const {
QString const cmd = QString("echo -n $(strings %1 | grep \\\"Version\\\" | cut -d':' -f2 | tr -d '\"' | tr -d ',')").arg(pluginFileName);
Command c("bash");
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
return c.getCommandResult();
}
return "N/A";
}
QStringList Worker::getDCVersion() const {
QStringList lst = (QStringList() << "N/A" << "N/A");
if (m_hw) {
m_hw->dc_autoRequest(true); // turn auto-request setting on
QByteArray const cmp(8, char(0));
QByteArray hw(""), sw("");
for (int i=0; i<5; ++i) {
hw = m_hw->dc_getHWversion().toUtf8();
sw = m_hw->dc_getSWversion().toUtf8();
if (!hw.startsWith(cmp)) {
lst.clear();
qInfo() << hw << sw;
lst << hw << sw;
break;
}
QThread::sleep(1);
}
}
return lst;
}
qint64 Worker::getFileSize(QString const &fileName) const {
// fileName has to be an absolute path
QFileInfo fInfo(fileName);
return fInfo.exists() ? fInfo.size() : -1;
}
void Worker::onHandleChangedFiles(QStringList changedFiles) { void Worker::onHandleChangedFiles(QStringList changedFiles) {
qCritical() << QDir::currentPath() << "ON HANDLE CHANGED FILES" << changedFiles;
QString opkg_commands; QString opkg_commands;
static const QRegularExpression re("^.*opkg_commands\\s*$"); static const QRegularExpression re("^.*opkg_commands\\s*$");
static const QRegularExpression comment("^\\s*#.*$"); static const QRegularExpression comment("^\\s*#.*$");
int idx = changedFiles.indexOf(re); int idx = changedFiles.indexOf(re);
if (idx != -1) { if (idx != -1) {
m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMANDS_REQUEST;
m_statusDescription = "EXECUTE OPKG COMMANDS";
opkg_commands = changedFiles.takeAt(idx); opkg_commands = changedFiles.takeAt(idx);
QFile f(opkg_commands); qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMANDS,
if (f.open(QIODevice::ReadOnly)) { QString("EXEC OPKG-COMMANDS FOR ") + opkg_commands);
QTextStream in(&f);
while (!in.atEnd()) { if (QDir::setCurrent(m_customerRepository)) {
QString line = in.readLine(); QFile f(opkg_commands);
if (line.indexOf(comment, 0) == -1) { if (f.exists()) {
// found opkg command if (f.open(QIODevice::ReadOnly)) {
QString opkgCommand = line.trimmed(); QTextStream in(&f);
executeOpkgCommand(opkgCommand); while (!in.atEnd()) {
QString line = in.readLine();
if (line.indexOf(comment, 0) == -1) {
// found opkg command
QString opkgCommand = line.trimmed();
executeOpkgCommand(opkgCommand);
}
}
f.close();
qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS,
QString("EXECUTING OPKG-COMMANDS OK"));
} }
} }
} }
// m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS;
// m_statusDescription = QString("EXECUTE OPKG COMMANDS %1 OK").arg(opkgCommands.join('\n'));
f.close();
} }
if (m_update->doUpdate(changedFiles)) { // first update the hardware if (m_update->doUpdate(changedFiles)) { // first update the hardware
@ -213,7 +310,7 @@ void Worker::onHandleChangedFiles(QStringList changedFiles) {
} }
} }
if (!error) { if (!error) {
onFinishUpdateProcess(true); emit this->finishUpdateProcess(true);
return; return;
} }
} }
@ -277,11 +374,14 @@ void Worker::executeOpkgCommand(QString opkgCommand) {
Command c(opkgCommand); Command c(opkgCommand);
if (c.execute(m_workingDirectory)) { if (c.execute(m_workingDirectory)) {
QString const r = c.getCommandResult(); QString const r = c.getCommandResult();
m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS; qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS,
m_statusDescription = QString("EXECUTE OPKG COMMAND %1 OK").arg(opkgCommand); QString("EXECUTE OPKG COMMAND %1 OK: %2")
.arg(opkgCommand)
.arg(c.getCommandResult()));
} else { } else {
m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE; qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE,
m_statusDescription = QString("EXECUTE OPKG COMMAND %1 FAILED").arg(opkgCommand); QString("EXECUTE OPKG COMMAND %1 FAILED")
.arg(opkgCommand));
onTerminateUpdateProcess(); onTerminateUpdateProcess();
return; return;
} }
@ -289,8 +389,14 @@ void Worker::executeOpkgCommand(QString opkgCommand) {
// sollte ParameterResponse heissen // sollte ParameterResponse heissen
void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) { void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
qInfo() << "IN ON_ISMAS_RESPONSE_RECEIVED" << QThread::currentThread()->objectName();
if (!ismasResponse.isEmpty()) { if (!ismasResponse.isEmpty()) {
QStringList const keys = ismasResponse.keys(); QStringList const keys = ismasResponse.keys();
qInfo() << UpdateStatus(UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED,
QString("RECEIVED JSON WITH KEYS: ") + keys.join(","));
static QRegularExpression re("^REQ_ISMASPARAMETER.*"); static QRegularExpression re("^REQ_ISMASPARAMETER.*");
if(keys.indexOf(re) >= 0) { if(keys.indexOf(re) >= 0) {
m_waitForNewUpdates.stop(); // stop asking ISMAS for updates m_waitForNewUpdates.stop(); // stop asking ISMAS for updates
@ -328,10 +434,19 @@ void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
if (!v.isNull() && !v.isUndefined()) { if (!v.isNull() && !v.isUndefined()) {
QString const s = v.toString(""); QString const s = v.toString("");
if (s == "WAIT") { if (s == "WAIT") {
m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS;
m_ismasUpdateRequests = ISMAS_UPDATE_REQUESTS; m_ismasUpdateRequests = ISMAS_UPDATE_REQUESTS;
m_statusDescription = "ISMAS UPDATES AVAILABLE";
qInfo() << UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS,
"DETECTED AVAILABLE ISMAS-DOWNLOAD");
QString const &data = m_ismasClient.updateOfPSAActivated();
m_apismClient.onSendCmdEventToIsmas(data);
emit m_gc.ismasUpdatesAvailable(); emit m_gc.ismasUpdatesAvailable();
} else {
// TODO: enorm wichtig
qCritical() << "DID NOT RECEIVE 'WAIT' BUT" << s;
onTerminateUpdateProcess();
} }
} }
} else { } else {
@ -339,6 +454,7 @@ void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
m_statusDescription = "NO FILEUPLOAD KEY AVAILABLE"; m_statusDescription = "NO FILEUPLOAD KEY AVAILABLE";
return; return;
} }
} }
} else { } else {
m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_FAILURE; m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_FAILURE;
@ -347,64 +463,108 @@ void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
} }
void Worker::onFinishUpdateProcess(bool changes) { void Worker::onFinishUpdateProcess(bool changes) {
qCritical() << "ON FINISH UPDATE PROCESS. CHANGES=" << changes; Q_UNUSED(changes);
qInfo() << "ON FINISH UPDATE PROCESS" << QThread::currentThread()->objectName();
// m_emergencyTimer.stop();
onSendCmdSendVersionToIsmas(); // final message to ISMAS
m_workerThread.quit(); m_workerThread.quit();
QApplication::quit(); QApplication::quit();
exit(0);
} }
void Worker::onTerminateUpdateProcess() { void Worker::onTerminateUpdateProcess() {
qCritical() << "ON TERMINATE UPDATE PROCESS"; qCritical() << "ON TERMINATE UPDATE PROCESS";
onSendCmdSendVersionToIsmas(); // final message to ISMAS
m_workerThread.quit(); m_workerThread.quit();
QApplication::quit(); QApplication::quit();
exit(-1);
} }
void Worker::onSendCmdSendVersionToIsmas() { void Worker::onSendCmdSendVersionToIsmas() {
QString const tariffVersion = "0.0.1"; QStringList const dcVersion = getDCVersion();
QString const tariffProject = "test_project"; QString const deviceControllerVersionHW = dcVersion.first();
int tariffZone = 1; QString const deviceControllerVersionSW = dcVersion.last();
QString const tariffInfo = "test_tariff_info";
QString const tariffLoadTime = QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
// QString const linuxVersion = "test_linux_version";
QString const cpuSerial = "test_cpu_serial";
QString const deviceControllerVersion = "test_dc_version";
QString const deviceControllerGitBlob = "test_dc_blob_2a3b4f50";
QString const deviceControllerGitLastCommit = "test_dc_commit_12345abc";
QString const raucVersion = "test_rauc_version";
QString const opkgVersion = "test_opkg_version";
QString const atbQTVersion = "test_qtbqt_version";
QString const atbQTGitDescribe = "test_atbqt_git_describe";
QString const deviceControllerPluginVersion = "test_CAmaster_version";
QString const ingenicoISelfCCPluginVersion = "test_ingenico_plugin_version";
QString const mobilisisCalculatePricePluginVersion = "test_mobilisis_plugin_version";
QString const mobilisisCalculatePriceConfigUiVersion = "test_mobilisis_config_ui_plugin";
QString const prmCalculatePricePluginVersion = "test_prm_calculate_price_plugin";
QString const prmCalculatePriceConfigUiPluginVersion = "test_prm_calculate_price_config_ui_plugin";
QString const tcpZVTPluginVersion = "test_tcp_zvt_plugin";
QString data = m_ismasClient.updateOfPSASendVersion(tariffVersion, qInfo() << "CURRENT DC-HW-VERSION: " << deviceControllerVersionHW;
tariffProject, qInfo() << "CURRENT DC-SW-VERSION: " << deviceControllerVersionSW;
tariffZone,
tariffInfo, QString const deviceControllerGitBlob = "N/A";
tariffLoadTime, QString const deviceControllerGitLastCommit = "N/A";
m_osVersion,
cpuSerial, PSAInstalled psaInstalled;
deviceControllerVersion, QString printSysDir("/etc/psa_config");
deviceControllerGitBlob, QString tariffSysDir("/etc/psa_tariff");
deviceControllerGitLastCommit, QString absPathName;
raucVersion,
opkgVersion, if (m_zoneNr != 0) {
atbQTVersion, QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
atbQTGitDescribe, psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
deviceControllerPluginVersion, absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name);
ingenicoISelfCCPluginVersion, psaInstalled.tariff.blob = m_gc.gitBlob(absPathName);
mobilisisCalculatePricePluginVersion, psaInstalled.tariff.size = getFileSize(absPathName);
mobilisisCalculatePriceConfigUiVersion, psaInstalled.tariff.zone = m_zoneNr;
prmCalculatePricePluginVersion, }
prmCalculatePriceConfigUiPluginVersion, psaInstalled.tariff.project = "Szeged";
tcpZVTPluginVersion); psaInstalled.tariff.info = "N/A";
m_apismClient.sendCmdSendVersionToIsmas(data); psaInstalled.tariff.loadTime = "N/A"; // QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
psaInstalled.tariff.version = "N/A";
psaInstalled.hw.linuxVersion = m_osVersion;
psaInstalled.hw.cpuSerial = m_cpuSerial;
psaInstalled.dc.versionHW = deviceControllerVersionHW;
psaInstalled.dc.versionSW = deviceControllerVersionSW;
psaInstalled.dc.gitBlob = "N/A";
psaInstalled.dc.gitLastCommit = "N/A";
psaInstalled.dc.size = -1;
psaInstalled.sw.raucVersion = m_raucVersion;
psaInstalled.sw.opkgVersion = m_opkgVersion;
psaInstalled.sw.atbQTVersion = m_atbqtVersion;
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;
psaInstalled.pluginVersion.ingenicoISelfCC = m_pluginVersionIngenicoISelf;
psaInstalled.pluginVersion.mobilisisCalculatePrice = m_pluginVersionMobilisisCalc;
psaInstalled.pluginVersion.mobilisisCalculatePriceConfigUi = m_pluginVersionMobilisisCalcConfig;
psaInstalled.pluginVersion.prmCalculatePrice = m_pluginVersionPrmCalc;
psaInstalled.pluginVersion.prmCalculatePriceConfigUi = m_pluginVersionPrmCalcConfig;
psaInstalled.pluginVersion.tcpZVT = m_pluginVersionTcpZvt;
psaInstalled.cash.name = "DC2C_cash.json";
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.cash.name);
psaInstalled.cash.blob = m_gc.gitBlob(absPathName);
psaInstalled.cash.size = getFileSize(absPathName);
psaInstalled.conf.name = "DC2C_conf.json";
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.conf.name);
psaInstalled.conf.blob = m_gc.gitBlob(absPathName);
psaInstalled.conf.size = getFileSize(absPathName);
psaInstalled.device.name = "DC2C_device.json";
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.device.name);
psaInstalled.device.blob = m_gc.gitBlob(absPathName);
psaInstalled.device.size = getFileSize(absPathName);
for (int i=0; i < 32; ++i) {
QString const &n = QString("%1").arg(i+1).rightJustified(2, '0');
psaInstalled.print[i].name = QString("DC2C_print%1.json").arg(n);
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.print[i].name);
psaInstalled.print[i].blob = m_gc.gitBlob(absPathName);
psaInstalled.print[i].size = getFileSize(absPathName);
}
QString data = m_ismasClient.updateOfPSASendVersion(psaInstalled);
// printf("data=%s\n", data.toStdString().c_str());
m_apismClient.onSendCmdSendVersionToIsmas(data);
} }
void Worker::askIsmasForNewData() { void Worker::askIsmasForNewData() {
@ -413,7 +573,14 @@ void Worker::askIsmasForNewData() {
QString data = m_ismasClient.setUpdatesAvailable(); QString data = m_ismasClient.setUpdatesAvailable();
m_apismClient.emulateUpdatesAvailable(data); m_apismClient.emulateUpdatesAvailable(data);
} }
m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING;
//m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING;
//m_statusDescription = "Ask ISMAS IF NEW DATA AVAILABLE";
qInfo() << UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING,
QString("ASK ISMAS IF NEW DATA AVAILABLE") +
QString(" (%1)").arg(m_ismasUpdateRequests));
m_apismClient.requestAvailableIsmasUpdates(); m_apismClient.requestAvailableIsmasUpdates();
if (--m_ismasUpdateRequests > 0) { if (--m_ismasUpdateRequests > 0) {
@ -425,3 +592,116 @@ void Worker::askIsmasForNewData() {
onTerminateUpdateProcess(); onTerminateUpdateProcess();
} }
} }
/************************************************************************************************
* operators
*/
QDebug operator<< (QDebug debug, UpdateStatus status) {
switch(status.m_updateStatus) {
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING:
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS:
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST:
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE:
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS:
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS:
debug << QString("UPDATE_STATUS::GIT_PULL_UPDATES_REQUEST: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE:
debug << QString("UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS:
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE:
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE: ")
<< status.m_statusDescription;
break;
default:;
}
return debug;
}
QString& operator<< (QString& str, UpdateStatus status) {
switch(status.m_updateStatus) {
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING:
str = QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS:
str = QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST:
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE:
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS:
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS:
str = QString("UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE:
str = QString("UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
str = QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS:
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE:
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE: ");
str += status.m_statusDescription;
break;
default:;
}
return str;
}