1183 lines
50 KiB
C++
1183 lines
50 KiB
C++
#include "worker.h"
|
|
#include "update.h"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QApplication>
|
|
#include <QDebug>
|
|
#include <QTimer>
|
|
#include <QFileInfo>
|
|
#include <QDir>
|
|
#include <QDirIterator>
|
|
#include <QThread>
|
|
#include <QRegularExpression>
|
|
#include <QDateTime>
|
|
#include <QString>
|
|
#include <QMessageBox>
|
|
#include <QPushButton>
|
|
#include <QJsonParseError>
|
|
|
|
#include <thread>
|
|
|
|
#include "message_handler.h"
|
|
#include "plugins/interfaces.h"
|
|
#include "ismas/ismas_client.h"
|
|
#include "progress_event.h"
|
|
#include "mainwindow.h"
|
|
|
|
QString const Worker::UPDATE_STEP_OK(" [ ok]");
|
|
QString const Worker::UPDATE_STEP_DONE(" [done]");
|
|
QString const Worker::UPDATE_STEP_FAIL(" [FAIL]");
|
|
QString const Worker::UPDATE_STEP_SUCCESS(" [SUCCESS]");
|
|
|
|
Worker::Worker(hwinf *hw,
|
|
int customerNr,
|
|
int machineNr,
|
|
int zoneNr,
|
|
QString branchName,
|
|
QString workingDirectory,
|
|
bool dryRun,
|
|
QObject *parent,
|
|
char const *serialInterface,
|
|
char const *baudrate)
|
|
: m_hw(hw)
|
|
, m_workerThread("workerThread")
|
|
, m_customerNr(customerNr)
|
|
, m_customerNrStr(QString("customer_") + QString::number(m_customerNr).rightJustified(3, '0'))
|
|
, m_machineNr(machineNr)
|
|
, m_zoneNr(zoneNr)
|
|
, m_workingDirectory(workingDirectory)
|
|
, 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_update(new Update(m_hw, this, m_customerRepository, m_customerNrStr, m_branchName,
|
|
m_workingDirectory, dryRun, parent, serialInterface, baudrate))
|
|
, m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this)
|
|
, 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_waitForNewUpdates(this)
|
|
, m_filesToUpdate()
|
|
, m_updateProcessRunning(false)
|
|
, m_returnCode(0)
|
|
, m_progressValue(0)
|
|
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
|
|
|
QDir::setCurrent(m_workingDirectory);
|
|
|
|
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
|
|
qInfo() << "OS VERSION ................." << m_osVersion;
|
|
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
|
|
qInfo() << "CPU SERIAL ................." << m_cpuSerial;
|
|
qInfo() << "CUSTOMER_NR ................" << m_customerNr;
|
|
qInfo() << "CUSTOMER_NR_STR ............" << m_customerNrStr;
|
|
qInfo() << "CUSTOMER_REPOSITORY_PATH ..." << m_customerRepositoryPath;
|
|
qInfo() << "CUSTOMER_REPOSITORY ........" << m_customerRepository;
|
|
qInfo() << "MACHINE_NR ................." << m_machineNr;
|
|
qInfo() << "ZONE_NR ...................." << m_zoneNr;
|
|
qInfo() << "BRANCH_NAME ................" << m_branchName;
|
|
qInfo() << "WORKING_DIRECTORY .........." << m_workingDirectory;
|
|
|
|
this->moveToThread(&m_workerThread);
|
|
m_workerThread.start();
|
|
|
|
int cnt = 0;
|
|
while (!m_workerThread.isRunning()) {
|
|
if (++cnt > 5) {
|
|
qCritical() << "starting worker thread FAILED";
|
|
return;
|
|
}
|
|
QThread::sleep(1);
|
|
}
|
|
}
|
|
|
|
Worker::~Worker() {
|
|
int cnt = 0;
|
|
m_workerThread.quit();
|
|
while (!m_workerThread.isFinished()) {
|
|
if (!m_workerThread.wait(1000)) {
|
|
if (++cnt > 5) {
|
|
qCritical() << "stopping worker thread FAILED";
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
if (m_update) {
|
|
delete m_update;
|
|
}
|
|
}
|
|
|
|
void Worker::setProgress(int progress) {
|
|
if (m_mainWindow) {
|
|
m_progressValue = progress;
|
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, progress));
|
|
}
|
|
}
|
|
|
|
void Worker::startProgressLoop() {
|
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::START_PROGRESS_LOOP));
|
|
}
|
|
|
|
void Worker::stopProgressLoop() {
|
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::STOP_PROGRESS_LOOP));
|
|
}
|
|
|
|
static std::once_flag once;
|
|
void Worker::update() {
|
|
// user should not start the update process several times
|
|
std::call_once(once, &Worker::privateUpdate, this);
|
|
}
|
|
|
|
void Worker::privateUpdate() {
|
|
m_updateProcessRunning = true;
|
|
|
|
bool sentIsmasLastVersionNotification = false;
|
|
|
|
//emit appendText("\nRestart APISM ...");
|
|
//startProgressLoop();
|
|
//Command c("systemctl restart apism");
|
|
//if (c.execute("/tmp")) {
|
|
// QThread::sleep(10); // give APISM some time to reconnect
|
|
// stopProgressLoop();
|
|
// emit replaceLast("Restart APISM ...", UPDATE_STEP_DONE);
|
|
//} else {
|
|
// stopProgressLoop();
|
|
// emit replaceLast("Restart APISM ...", UPDATE_STEP_FAIL);
|
|
//}
|
|
|
|
emit disableExit();
|
|
|
|
m_returnCode = -1;
|
|
QDir customerRepository(m_customerRepository);
|
|
if (!customerRepository.exists()) {
|
|
emit appendText("\nInitializing customer environment ...");
|
|
startProgressLoop();
|
|
if (m_gc.gitCloneAndCheckoutBranch()) {
|
|
stopProgressLoop();
|
|
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
|
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.cloneAndCheckoutCustomerRepository(
|
|
m_updateStatus.m_statusDescription));
|
|
|
|
setProgress(progress + 10);
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.updateOfPSASucceeded(""));
|
|
|
|
setProgress(100);
|
|
m_ismasClient.setProgressInPercent(100);
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated());
|
|
|
|
m_returnCode = 0;
|
|
} else {
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
|
|
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
|
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.errorGitClone(100, m_updateStatus.m_statusDescription));
|
|
|
|
m_returnCode = -3;
|
|
}
|
|
} else {
|
|
qInfo() << "CHECKOUT BRANCH...";
|
|
emit appendText("\nInitializing customer environment ...");
|
|
startProgressLoop();
|
|
if (m_gc.gitCheckoutBranch()) {
|
|
stopProgressLoop();
|
|
emit replaceLast("Initializing customer environment ...", UPDATE_STEP_DONE);
|
|
setProgress(100);
|
|
|
|
m_ismasClient.setProgressInPercent(10);
|
|
//m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
|
// QString("CHECKED OUT BRANCH: ") + m_gc.branchName());
|
|
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
// m_ismasClient.checkoutBranch(
|
|
// m_updateStatus.m_statusDescription, ""));
|
|
|
|
qInfo() << "CHECKED OUT BRANCH";
|
|
if (backendConnected()) {
|
|
m_ismasClient.setProgressInPercent(20);
|
|
if (updateTriggerSet()) {
|
|
m_ismasClient.setProgressInPercent(30);
|
|
if (customerEnvironment()) {
|
|
m_ismasClient.setProgressInPercent(40);
|
|
if (filesToUpdate()) {
|
|
m_ismasClient.setProgressInPercent(50);
|
|
if (updateFiles(50)) {
|
|
m_ismasClient.setProgressInPercent(60);
|
|
if (syncCustomerRepositoryAndFS()) {
|
|
m_ismasClient.setProgressInPercent(70);
|
|
if (sendIsmasLastVersionNotification()) {
|
|
m_ismasClient.setProgressInPercent(80);
|
|
sentIsmasLastVersionNotification = true;
|
|
if (saveLogFile()) {
|
|
m_ismasClient.setProgressInPercent(90);
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.updateOfPSASucceeded(""));
|
|
|
|
// mark update as activated -> this resets the WAIT button
|
|
m_ismasClient.setProgressInPercent(95);
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.updateOfPSAActivated());
|
|
|
|
m_returnCode = 0;
|
|
} else {
|
|
m_returnCode = -12;
|
|
}
|
|
} else {
|
|
m_returnCode = -11;
|
|
}
|
|
} else {
|
|
m_returnCode = -10;
|
|
}
|
|
} else {
|
|
m_returnCode = -9;
|
|
}
|
|
} else {
|
|
m_returnCode = -8;
|
|
}
|
|
} else {
|
|
m_returnCode = -7;
|
|
}
|
|
} else {
|
|
m_returnCode = -6;
|
|
}
|
|
} else {
|
|
m_returnCode = -5;
|
|
}
|
|
} else {
|
|
m_returnCode = -4;
|
|
}
|
|
}
|
|
|
|
m_ismasClient.setProgressInPercent(100);
|
|
|
|
if (!sentIsmasLastVersionNotification) {
|
|
// try even if the backend is not connected
|
|
sendIsmasLastVersionNotification();
|
|
}
|
|
|
|
if (m_returnCode != 0) {
|
|
stopProgressLoop();
|
|
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
|
} else {
|
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
|
}
|
|
|
|
setProgress(100);
|
|
m_updateProcessRunning = false;
|
|
emit enableExit();
|
|
emit restartExitTimer();
|
|
}
|
|
|
|
bool Worker::backendConnected() {
|
|
if (m_withoutIsmasDirectPort) { // useful for testing
|
|
return true;
|
|
}
|
|
|
|
emit appendText("\nConnecting backend ...");
|
|
|
|
for (int repeat = 0; repeat < 50; ++repeat) {
|
|
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
|
startProgressLoop();
|
|
std::optional<QString> result
|
|
= IsmasClient::sendRequestReceiveResponse(
|
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
|
if (result) {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
|
|
QString msg = result.value();
|
|
qInfo() << "In backendConnected() -> APISM response" << msg;
|
|
QJsonParseError parseError;
|
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
|
if (parseError.error != QJsonParseError::NoError) {
|
|
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
|
<< parseError.error << parseError.errorString();
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
if (!document.isObject()) {
|
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
|
|
setProgress(progress + 1);
|
|
|
|
QJsonObject obj = document.object();
|
|
QStringList keys = obj.keys();
|
|
for (QString const& key : keys ) {
|
|
if (key.contains("CMD_GET_APISMSTATUS_RESPONSE")) {
|
|
QJsonValue v = obj.value(key);
|
|
if (v.isObject()) {
|
|
obj = v.toObject();
|
|
bool ismas = obj.value("ISMAS").toBool();
|
|
QString status = obj.value("Broker").toString();
|
|
qInfo() << "REPEAT" << repeat << "In backendConnected() Broker=<"
|
|
<< status << ">, ISMAS=<" << (ismas ? "true>" : "false>");
|
|
if (ismas) {
|
|
if (status == "Connected") {
|
|
// do not send, as this would result in a corrupted wait button
|
|
// but update the user-interface
|
|
setProgress(100);
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_OK);
|
|
return true;
|
|
}
|
|
}
|
|
emit showErrorMessage("Check backend connection",
|
|
QString ("REPEAT %1 Broker=<").arg(repeat)
|
|
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>"));
|
|
QThread::sleep(6);
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
}
|
|
}
|
|
|
|
setProgress(100);
|
|
|
|
emit replaceLast("Connecting backend", UPDATE_STEP_FAIL);
|
|
emit showErrorMessage("Error", "Backend not available");
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_NOT_CONNECTED,
|
|
QString("NO BACKEND CONNECTION"));
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.errorBackendNotConnected(m_updateStatus.m_statusDescription, ""));
|
|
|
|
return false;
|
|
}
|
|
|
|
bool Worker::updateTriggerSet() {
|
|
if (m_withoutIsmasDirectPort) { // useful for testing
|
|
return true;
|
|
}
|
|
|
|
emit appendText("\nUpdate trigger set ...");
|
|
QString triggerValue("");
|
|
|
|
for (int repeat = 0; repeat < 50; ++repeat) {
|
|
startProgressLoop();
|
|
if (std::optional<QString> result
|
|
= IsmasClient::sendRequestReceiveResponse(
|
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
|
|
QString msg = result.value();
|
|
|
|
qInfo() << "REPEAT" << repeat << "APISM RESPONSE" << msg;
|
|
|
|
QJsonParseError parseError;
|
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
|
if (parseError.error != QJsonParseError::NoError) {
|
|
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
|
<< parseError.error << parseError.errorString();
|
|
emit showErrorMessage("check update trigger",
|
|
QString("invalid json ") + msg.mid(0, 20));
|
|
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
if (!document.isObject()) {
|
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
|
emit showErrorMessage("check update trigger",
|
|
QString("not a json object") + msg);
|
|
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
|
|
setProgress(progress + 1);
|
|
|
|
QJsonObject obj = document.object();
|
|
// sanity check: cust_nr and machine_nr of PSA correct ?
|
|
// note: this check has to be done here, as the cust_nr and the machine_nr
|
|
// of the PSA are sent by ISMAS.
|
|
if (obj.contains("Dev_ID")) {
|
|
QJsonValue v = obj.value("Dev_ID");
|
|
if (v.isObject()) {
|
|
QJsonObject obj = v.toObject();
|
|
if (obj.contains("Custom_ID") && obj.contains("Device_ID")) {
|
|
QJsonValue const c = obj.value("Custom_ID");
|
|
QJsonValue const m = obj.value("Device_ID");
|
|
int customerNr = c.toInt(-1);
|
|
int machineNr = m.toInt(-1);
|
|
if (customerNr != m_customerNr) {
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
|
.arg(customerNr).arg(m_customerNr));
|
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
m_updateStatus.m_statusDescription));
|
|
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
if (machineNr != m_machineNr) {
|
|
setProgress(100);
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
|
.arg(machineNr).arg(m_machineNr));
|
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
m_updateStatus.m_statusDescription));
|
|
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
setProgress(progress + 1);
|
|
|
|
if (obj.contains("Fileupload")) {
|
|
QJsonValue v = obj.value("Fileupload");
|
|
if (v.isObject()) {
|
|
obj = v.toObject();
|
|
if (obj.contains("TRG")) {
|
|
v = obj.value("TRG");
|
|
if (v.isString()) {
|
|
triggerValue = v.toString();
|
|
|
|
qInfo() << "REPEAT" << repeat
|
|
<< "In updateTriggerSet() TRG value=<"
|
|
<< triggerValue << ">";
|
|
|
|
if (triggerValue == "WAIT") {
|
|
setProgress(100);
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_SET,
|
|
QString("UPDATE TRIGGER SET. CONTINUE. "));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.updateTriggerSet(m_updateStatus.m_statusDescription, ""));
|
|
|
|
emit replaceLast("Update trigger set ...", UPDATE_STEP_OK);
|
|
return true;
|
|
} else {
|
|
emit showErrorMessage("check update trigger",
|
|
QString ("TRG value=<") + triggerValue
|
|
+ ">\n(reset download button?)");
|
|
QThread::sleep(6);
|
|
continue;
|
|
}
|
|
}
|
|
} else {
|
|
emit showErrorMessage("check update trigger", "TRG key not contained");
|
|
}
|
|
} else {
|
|
emit showErrorMessage("check update trigger", "Fileupload not a json-object");
|
|
}
|
|
}
|
|
|
|
if (obj.contains("error")) {
|
|
QString value = obj.value("error").toString();
|
|
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
|
|
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
|
|
<< value << ">";
|
|
}
|
|
} else {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
emit showErrorMessage("check update trigger", "no ISMAS response");
|
|
QThread::sleep(6);
|
|
}
|
|
}
|
|
|
|
setProgress(100);
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
|
QString("UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
|
triggerValue + ")");
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.errorUpdateTrigger(m_updateStatus.m_statusDescription, ""));
|
|
|
|
emit replaceLast("Update trigger set ...", UPDATE_STEP_OK);
|
|
return false;
|
|
}
|
|
|
|
bool Worker::customerEnvironment() {
|
|
emit appendText("\nPrepare customer environment ...");
|
|
if (QDir(m_customerRepository).exists()) {
|
|
startProgressLoop();
|
|
if (m_gc.gitCheckoutBranch()) {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
|
QString("CHECKED-OUT BRANCH ") + m_gc.branchName());
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.checkoutBranch(m_updateStatus.m_statusDescription, ""));
|
|
|
|
setProgress(100);
|
|
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE);
|
|
qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE";
|
|
return true;
|
|
} else {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
emit showErrorMessage("cust-env",
|
|
QString("Checkout ") + m_customerRepository + " failed");
|
|
qCritical() << QString(80, '*');
|
|
qCritical() << "CHECKOUT OF" << m_customerRepository << "FAILED";
|
|
qCritical() << QString(80, '*');
|
|
}
|
|
} else {
|
|
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
|
qCritical() << QString(80, '*');
|
|
qCritical() << m_customerRepository << "DOES NOT EXIST";
|
|
qCritical() << QString(80, '*');
|
|
}
|
|
|
|
setProgress(100);
|
|
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
|
|
bool Worker::filesToUpdate() {
|
|
emit appendText("\nFetch changes files ...");
|
|
startProgressLoop();
|
|
if (std::optional<QString> changes = m_gc.gitFetch()) {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
|
QString("FETCHING OF ") + m_customerRepositoryPath +
|
|
QString(" INTO ") + m_customerRepository);
|
|
|
|
setProgress(progress + 10);
|
|
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
|
setProgress(progress + 20);
|
|
if (m_gc.gitPull()) {
|
|
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
|
|
m_filesToUpdate = changedFileNames.value();
|
|
|
|
qInfo() << QString(80, '*');
|
|
qInfo() << "FILES-TO-UPDATE" << m_filesToUpdate;
|
|
qInfo() << QString(80, '*');
|
|
|
|
int const size = m_filesToUpdate.size();
|
|
if (size > 1) {
|
|
emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE);
|
|
for (int i = 0; i < size; ++i) {
|
|
emit appendText(QString("\n ") + m_filesToUpdate.at(i));
|
|
}
|
|
} else {
|
|
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
|
|
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
|
|
}
|
|
return true;
|
|
}
|
|
emit showErrorMessage("files to update", "pulling files failed");
|
|
|
|
qCritical() << QString(80, '*');
|
|
qCritical() << "PULLING FILES FAILED";
|
|
qCritical() << QString(80, '*');
|
|
|
|
} else {
|
|
emit showErrorMessage("files to update", "no files to update (checked-in any files?)");
|
|
|
|
qCritical() << QString(80, '*');
|
|
qCritical() << "NO FILES TO UPDATE (CHECKED IN ANY FILES?)";
|
|
qCritical() << QString(80, '*');
|
|
}
|
|
setProgress(progress + 30);
|
|
} else {
|
|
stopProgressLoop();
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
setProgress(progress + 30);
|
|
|
|
emit showErrorMessage("files to update",
|
|
QString("no changes in ") + m_customerRepository +
|
|
" (checked-in any files?)");
|
|
|
|
qCritical() << QString(80, '*');
|
|
qCritical() << "NO CHANGES IN" << m_customerRepository << "(CHECKED IN ANY FILES?)";
|
|
qCritical() << QString(80, '*');
|
|
}
|
|
|
|
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
|
|
setProgress(100);
|
|
return false;
|
|
}
|
|
|
|
bool Worker::updateFiles(quint8 percent) {
|
|
QStringList filesToDownload;
|
|
m_displayIndex = 0;
|
|
|
|
startProgressLoop();
|
|
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
|
QString fName = m_filesToUpdate.at(i);
|
|
|
|
qInfo() << QString(80, '*');
|
|
qInfo() << "FNAME" << fName;
|
|
qInfo() << QString(80, '*');
|
|
|
|
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
|
emit appendText("\n( ) Update opkg pakets ...");
|
|
// execute opkg commands
|
|
if (QDir::setCurrent(m_customerRepository)) {
|
|
QFile f(fName);
|
|
if (f.exists()) {
|
|
if (f.open(QIODevice::ReadOnly)) {
|
|
QTextStream in(&f);
|
|
int cmdCount = 0;
|
|
while (!in.atEnd()) {
|
|
QString line = in.readLine();
|
|
static const QRegularExpression comment("^\\s*#.*$");
|
|
if (line.indexOf(comment, 0) == -1) {
|
|
// found opkg command
|
|
QString opkgCommand = line.trimmed();
|
|
executeOpkgCommand(opkgCommand);
|
|
++cmdCount;
|
|
|
|
m_ismasClient.setProgressInPercent(++percent);
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
|
|
QString("EXEC OPKG-COMMAND ") + opkgCommand);
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
m_ismasClient.execOpkgCommand(m_updateStatus.m_statusDescription, ""));
|
|
}
|
|
}
|
|
f.close();
|
|
if (cmdCount > 0) {
|
|
m_displayIndex = 1;
|
|
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
|
+ QString(" Update opkg pakets ... "), UPDATE_STEP_DONE);
|
|
} else {
|
|
m_displayIndex = 1;
|
|
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
|
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else
|
|
if (fName.contains("print", Qt::CaseInsensitive)) {
|
|
filesToDownload << fName; // download printer-config-files
|
|
} else {
|
|
static const QRegularExpression version("^.*dc2c[.][0-9][0-9][.][0-9][0-9][.]bin.*$");
|
|
if (fName.contains(version)) {
|
|
filesToDownload << fName; // download device controller
|
|
}
|
|
}
|
|
}
|
|
|
|
stopProgressLoop();
|
|
setProgress(100);
|
|
bool ret = true;
|
|
|
|
if (filesToDownload.size() > 0) {
|
|
qInfo() << QString(80, '*');
|
|
qInfo() << "FILES_TO_WORK_ON" << filesToDownload;
|
|
qInfo() << QString(80, '*');
|
|
ret = m_update->doUpdate(m_displayIndex, filesToDownload);
|
|
} else {
|
|
qInfo() << QString(80, '*');
|
|
qInfo() << "NO FILES_TO_WORK_ON";
|
|
qInfo() << QString(80, '*');
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool Worker::syncCustomerRepositoryAndFS() {
|
|
setProgress(0);
|
|
emit appendText("\nSync customer environment with filesystem ...");
|
|
if (QDir(m_customerRepository).exists()) {
|
|
if (QDir::setCurrent(m_customerRepository)) {
|
|
int progress = 10;
|
|
setProgress(progress);
|
|
QString const params("-vv "
|
|
"--recursive "
|
|
"--progress "
|
|
"--checksum "
|
|
"--exclude=.* "
|
|
"--include=*.bin "
|
|
"--include=*.json "
|
|
"--include=opkg_commands "
|
|
"--include=*.ini");
|
|
QStringList cmds;
|
|
cmds << QString("rsync ") + params.simplified() + " etc/ /etc";
|
|
cmds << QString("rsync ") + params.simplified() + " opt/ /opt";
|
|
|
|
QString cmd;
|
|
bool error = false;
|
|
foreach (cmd, cmds) {
|
|
progress += 5;
|
|
setProgress(progress);
|
|
if (!error) {
|
|
Command c("bash");
|
|
qInfo() << "EXECUTING CMD..." << cmd;
|
|
if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) {
|
|
QStringList result = c.getCommandResult().split('\n');
|
|
for (int i = 0; i < result.size(); ++i) {
|
|
qInfo() << result.at(i);
|
|
}
|
|
qInfo() << "SUCCESS";
|
|
} else {
|
|
qCritical() << QString(80, '*');
|
|
qCritical() << "CMD" << cmd << "FAILED";
|
|
qCritical() << c.getCommandResult().split('\n');
|
|
qCritical() << QString(80, '*');
|
|
error = true;
|
|
}
|
|
}
|
|
}
|
|
progress += 5;
|
|
setProgress(progress);
|
|
if (!error) {
|
|
setProgress(100);
|
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
setProgress(100);
|
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
|
|
return false;
|
|
}
|
|
|
|
bool Worker::sendIsmasLastVersionNotification() {
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_SENDVERSION#J=") +
|
|
m_ismasClient.updateOfPSASendVersion(getPSAInstalled()));
|
|
emit appendText(QString("Send last version info "), UPDATE_STEP_DONE);
|
|
return true;
|
|
}
|
|
|
|
bool Worker::saveLogFile() {
|
|
return true;
|
|
}
|
|
QString Worker::getOsVersion() const {
|
|
QString const cmd = QString("echo -n $(cat /etc/os-release | head -n 1 | cut -d'\"' -f2 | tr -d '\"')");
|
|
Command c("bash");
|
|
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
|
return c.getCommandResult();
|
|
}
|
|
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;
|
|
}
|
|
|
|
bool Worker::executeOpkgCommand(QString opkgCommand) {
|
|
Command c(opkgCommand);
|
|
if (c.execute(m_workingDirectory)) {
|
|
QString const r = c.getCommandResult();
|
|
qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS,
|
|
QString("EXECUTE OPKG COMMAND %1 OK: %2")
|
|
.arg(opkgCommand)
|
|
.arg(c.getCommandResult()));
|
|
return true;
|
|
} else {
|
|
qCritical() << QString(80, '*');
|
|
qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE,
|
|
QString("EXECUTE OPKG COMMAND %1 FAILED")
|
|
.arg(opkgCommand));
|
|
qCritical() << QString(80, '*');
|
|
}
|
|
return false;
|
|
}
|
|
|
|
PSAInstalled Worker::getPSAInstalled() {
|
|
QStringList const dcVersion = getDCVersion();
|
|
QString const deviceControllerVersionHW = dcVersion.first();
|
|
QString const deviceControllerVersionSW = dcVersion.last();
|
|
|
|
qInfo() << "CURRENT DC-HW-VERSION: " << deviceControllerVersionHW;
|
|
qInfo() << "CURRENT DC-SW-VERSION: " << deviceControllerVersionSW;
|
|
|
|
QString const deviceControllerGitBlob = "N/A";
|
|
QString const deviceControllerGitLastCommit = "N/A";
|
|
|
|
PSAInstalled psaInstalled;
|
|
QString printSysDir("/etc/psa_config");
|
|
QString tariffSysDir("/etc/psa_tariff");
|
|
QString absPathName;
|
|
|
|
if (m_zoneNr != 0) {
|
|
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
|
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
|
absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name);
|
|
psaInstalled.tariff.blob = m_gc.gitBlob(absPathName);
|
|
psaInstalled.tariff.size = getFileSize(absPathName);
|
|
psaInstalled.tariff.zone = m_zoneNr;
|
|
}
|
|
psaInstalled.tariff.project = "Szeged";
|
|
psaInstalled.tariff.info = "N/A";
|
|
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);
|
|
}
|
|
|
|
return psaInstalled;
|
|
}
|
|
|
|
QString Worker::sendCmdSendVersionToIsmas() {
|
|
|
|
QStringList const dcVersion = getDCVersion();
|
|
QString const deviceControllerVersionHW = dcVersion.first();
|
|
QString const deviceControllerVersionSW = dcVersion.last();
|
|
|
|
qInfo() << "CURRENT DC-HW-VERSION: " << deviceControllerVersionHW;
|
|
qInfo() << "CURRENT DC-SW-VERSION: " << deviceControllerVersionSW;
|
|
|
|
QString const deviceControllerGitBlob = "N/A";
|
|
QString const deviceControllerGitLastCommit = "N/A";
|
|
|
|
PSAInstalled psaInstalled;
|
|
QString printSysDir("/etc/psa_config");
|
|
QString tariffSysDir("/etc/psa_tariff");
|
|
QString absPathName;
|
|
|
|
if (m_zoneNr != 0) {
|
|
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
|
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
|
absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name);
|
|
psaInstalled.tariff.blob = m_gc.gitBlob(absPathName);
|
|
psaInstalled.tariff.size = getFileSize(absPathName);
|
|
psaInstalled.tariff.zone = m_zoneNr;
|
|
}
|
|
psaInstalled.tariff.project = "Szeged";
|
|
psaInstalled.tariff.info = "N/A";
|
|
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);
|
|
}
|
|
|
|
// QByteArray data = "#M=APISM#C=CMD_SENDVERSION#J=";
|
|
return m_ismasClient.updateOfPSASendVersion(psaInstalled);
|
|
}
|
|
|
|
/************************************************************************************************
|
|
* operators
|
|
*/
|
|
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
|
switch(status.m_updateStatus) {
|
|
case UPDATE_STATUS::UPDATE_PROCESS_SUCCESS:
|
|
debug << QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ")
|
|
<< status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING:
|
|
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING: ")
|
|
<< status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE:
|
|
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE: ")
|
|
<< status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_TIMEOUT:
|
|
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_: ")
|
|
<< status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS:
|
|
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS: ")
|
|
<< status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
|
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ")
|
|
<< 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::UPDATE_PROCESS_SUCCESS:
|
|
str = QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ");
|
|
str += status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING:
|
|
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING: ");
|
|
str += status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS:
|
|
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS: ");
|
|
str += status.m_statusDescription;
|
|
break;
|
|
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
|
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ");
|
|
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;
|
|
}
|