Added fetching apism-version. Fixed calls to final_result().
This commit is contained in:
parent
12ffa71455
commit
507586f9dc
303
worker.cpp
303
worker.cpp
@ -205,122 +205,110 @@ void Worker::privateUpdate() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_ismasClient.setProgressInPercent(10);
|
m_ismasClient.setProgressInPercent(10);
|
||||||
if (backendConnected()) {
|
if (updateTriggerSet()) {
|
||||||
m_ismasClient.setProgressInPercent(20);
|
m_ismasClient.setProgressInPercent(20);
|
||||||
if (updateTriggerSet()) {
|
if (customerEnvironment()) {
|
||||||
m_ismasClient.setProgressInPercent(30);
|
m_ismasClient.setProgressInPercent(30);
|
||||||
if (customerEnvironment()) {
|
if (filesToUpdate()) {
|
||||||
|
// send message to ISMAS about files which have been
|
||||||
|
// checked in into git repository
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
||||||
|
QString("Files to update: ") + m_filesToUpdate.join(','));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_ismasClient.setProgressInPercent(40);
|
m_ismasClient.setProgressInPercent(40);
|
||||||
if (filesToUpdate()) {
|
if (updateFiles(50)) {
|
||||||
// send message to ISMAS about files which have been
|
|
||||||
// checked in into git repository
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
|
||||||
QString("Files to update: ") + m_filesToUpdate.join(','));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
m_ismasClient.setProgressInPercent(50);
|
m_ismasClient.setProgressInPercent(50);
|
||||||
if (updateFiles(50)) {
|
if (syncCustomerRepositoryAndFS()) {
|
||||||
m_ismasClient.setProgressInPercent(60);
|
m_ismasClient.setProgressInPercent(60);
|
||||||
if (syncCustomerRepositoryAndFS()) {
|
if (sendIsmasLastVersionNotification()) {
|
||||||
m_ismasClient.setProgressInPercent(70);
|
m_ismasClient.setProgressInPercent(70);
|
||||||
if (sendIsmasLastVersionNotification()) {
|
sentIsmasLastVersionNotification = true;
|
||||||
|
if (saveLogFile()) {
|
||||||
m_ismasClient.setProgressInPercent(80);
|
m_ismasClient.setProgressInPercent(80);
|
||||||
sentIsmasLastVersionNotification = true;
|
|
||||||
if (saveLogFile()) {
|
|
||||||
m_ismasClient.setProgressInPercent(90);
|
|
||||||
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSASucceeded(""));
|
m_ismasClient.updateOfPSASucceeded(""));
|
||||||
|
|
||||||
// mark update as activated -> this resets the WAIT button
|
// mark update as activated -> this resets the WAIT button
|
||||||
m_ismasClient.setProgressInPercent(95);
|
m_ismasClient.setProgressInPercent(95);
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAActivated());
|
m_ismasClient.updateOfPSAActivated());
|
||||||
|
|
||||||
m_returnCode = 0;
|
m_returnCode = 0;
|
||||||
} else {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
|
|
||||||
QString("Saving log files failed"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"SAVE-LOG-FILES",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
m_returnCode = -11;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
|
||||||
QString("Sending ISMAS last version failed"));
|
QString("Saving log files failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"ISMAS-SEND-LAST-VERSION",
|
"SAVE-LOG-FILES",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -10;
|
m_returnCode = -11;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
|
||||||
QString("Syncing files to update failed"));
|
QString("Sending ISMAS last version failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"RSYNC-UPDATE-FILES",
|
"ISMAS-SEND-LAST-VERSION",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -9;
|
m_returnCode = -10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
|
||||||
QString("Updating files failed"));
|
QString("Syncing files to update failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"UPDATE-FILES",
|
"RSYNC-UPDATE-FILES",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -8;
|
m_returnCode = -9;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
|
||||||
QString("No files to update"));
|
QString("Updating files failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"FETCH-FILES-TO-UPDATE",
|
"UPDATE-FILES",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -7;
|
m_returnCode = -8;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
||||||
QString("Configuring customer environment failed"));
|
QString("No files to update"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"GIT-CHECKOUT-BRANCH",
|
"FETCH-FILES-TO-UPDATE",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -6;
|
m_returnCode = -7;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
||||||
QString("ISMAS update trigger wrong"));
|
QString("Configuring customer environment failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"CHECK-UPDATE-TRIGGER",
|
"GIT-CHECKOUT-BRANCH",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -5;
|
m_returnCode = -6;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
||||||
QString("ISMAS backend not available"));
|
QString("ISMAS update trigger wrong"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"ISMAS-BACKEND-CHECK",
|
"CHECK-UPDATE-TRIGGER",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -4;
|
m_returnCode = -5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +322,6 @@ void Worker::privateUpdate() {
|
|||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
||||||
QString("Update process failed"));
|
QString("Update process failed"));
|
||||||
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"FINAL-UPDATE-RESULT",
|
|
||||||
m_updateStatus.m_statusDescription)) {
|
m_updateStatus.m_statusDescription)) {
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
@ -343,9 +330,8 @@ void Worker::privateUpdate() {
|
|||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
||||||
QString("Update process succeeded"));
|
QString("Update process succeeded. Reset WAIT."));
|
||||||
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
||||||
"FINAL-UPDATE-RESULT",
|
|
||||||
m_updateStatus.m_statusDescription)) {
|
m_updateStatus.m_statusDescription)) {
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
@ -362,137 +348,62 @@ void Worker::privateUpdate() {
|
|||||||
emit restartExitTimer();
|
emit restartExitTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::backendConnected() {
|
std::optional<QString> Worker::getApismVersion() {
|
||||||
// deactivated: REQ_SELF does not really help. Observation was that even
|
for (int repeat = 0; repeat < 10; ++repeat) {
|
||||||
// id ISMAS is reported as 'true', a following check of the update-trigger
|
qInfo() << "REPEAT" << repeat << "In getApismVersion() -> #M=APISM#C=REQ_SELF#J={}";
|
||||||
// button has no access to ISMAS.
|
std::optional<QString> result
|
||||||
return true;
|
= IsmasClient::sendRequestReceiveResponse(
|
||||||
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
||||||
emit appendText("\nConnecting backend ...");
|
if (result) {
|
||||||
|
QString msg = result.value();
|
||||||
if (false) { // so linker removes dead code
|
qInfo() << "In getApismVersion() -> APISM response" << msg;
|
||||||
for (int repeat = 0; repeat < 100; ++repeat) {
|
QJsonParseError parseError;
|
||||||
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
startProgressLoop();
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
std::optional<QString> result
|
qCritical() << "(1) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
||||||
= IsmasClient::sendRequestReceiveResponse(
|
<< parseError.error << parseError.errorString();
|
||||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
if (result) {
|
QString("(2) INVALID JSON %1 %2 %3")
|
||||||
stopProgressLoop();
|
.arg(msg)
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
.arg(parseError.error)
|
||||||
setProgress(progress);
|
.arg(parseError.errorString()));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString msg = result.value();
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
qInfo() << "In backendConnected() -> APISM response" << msg;
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
QJsonParseError parseError;
|
m_updateStatus.m_statusDescription));
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
return std::nullopt;
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
|
||||||
qCritical() << "(1) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
|
||||||
<< parseError.error << parseError.errorString();
|
|
||||||
setProgress(100);
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
|
||||||
QString("(2) INVALID JSON %1 %2 %3")
|
|
||||||
.arg(msg)
|
|
||||||
.arg(parseError.error)
|
|
||||||
.arg(parseError.errorString()));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!document.isObject()) {
|
|
||||||
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
|
||||||
setProgress(100);
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
|
||||||
QString("NOT A JSON-OBJECT %1").arg(msg));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setProgress(progress + 1);
|
|
||||||
|
|
||||||
QJsonObject obj = document.object();
|
|
||||||
QStringList keys = obj.keys().filter("CMD_GET_APISMSTATUS_RESPONSE");
|
|
||||||
if (keys.size() == 1) {
|
|
||||||
QString const key = keys.at(0);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK,
|
|
||||||
QString ("REPEAT %1 Broker=<").arg(repeat)
|
|
||||||
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>"));
|
|
||||||
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
// m_ismasClient.updateOfPSAContinues("BACKEND-CHECK", m_updateStatus.m_statusDescription));
|
|
||||||
|
|
||||||
qInfo() << "BACKEND-CHECK" << m_updateStatus.m_statusDescription;
|
|
||||||
emit showErrorMessage("Check backend connection", m_updateStatus.m_statusDescription);
|
|
||||||
QThread::sleep(6);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
setProgress(100);
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
|
||||||
"CMD_GET_APISM_STATUS_RESPONSE KEY NOT A JSON-OBJECT");
|
|
||||||
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 showErrorMessage("check backend connection", m_updateStatus.m_statusDescription);
|
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setProgress(100);
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
|
||||||
"CMD_GET_APISMSTATUS_RESPONSE KEY NOT AVAILABLE");
|
|
||||||
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 showErrorMessage("check backend connection", m_updateStatus.m_statusDescription);
|
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
}
|
}
|
||||||
|
if (!document.isObject()) {
|
||||||
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
|
QString("NOT A JSON-OBJECT %1").arg(msg));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
QJsonObject obj = document.object();
|
||||||
|
QStringList keys = obj.keys().filter("CMD_GET_APISMSTATUS_RESPONSE");
|
||||||
|
if (keys.size() != 1) {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||||
|
"CMD_GET_APISMSTATUS_RESPONSE KEY NOT AVAILABLE");
|
||||||
|
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 showErrorMessage("apism response", m_updateStatus.m_statusDescription);
|
||||||
|
return std::nullopt;
|
||||||
|
} else {
|
||||||
|
QString const key = keys.at(0);
|
||||||
|
QJsonValue v = obj.value(key);
|
||||||
|
return v.toObject().value("Version").toString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QThread::sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
||||||
|
Loading…
Reference in New Issue
Block a user