diff --git a/mainwindow.cpp b/mainwindow.cpp index e426c0c..b46b310 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -77,7 +77,8 @@ void MainWindow::onRestartExitTimer() { void MainWindow::onQuit() { if (!m_worker->updateProcessRunning()) { - qApp->quit(); + // qApp->quit(); + qApp->exit(m_worker->returnCode()); } } @@ -91,12 +92,16 @@ void MainWindow::onAppendText(QString text, QString suffix) { for (int i=0; iupdateStatus->setPlainText(editText); - } else { + if (suffix.contains("[SUCCESS]")) { editText += QString("\n").leftJustified(m_width-3, '='); editText += QString("\n").leftJustified(m_width-12) + " [SUCCESS]"; + } else + if (suffix.contains(" [fail]")) { + editText += QString("\n").leftJustified(m_width-3, '='); + editText += QString("\n").leftJustified(m_width-9) + " [fail]"; + } else { + editText += text.leftJustified(m_width-9) + suffix; + ui->updateStatus->setPlainText(editText); } ui->updateStatus->setText(editText); ui->updateStatus->setEnabled(true); diff --git a/worker.cpp b/worker.cpp index 6f3c001..f143a96 100644 --- a/worker.cpp +++ b/worker.cpp @@ -65,7 +65,8 @@ Worker::Worker(hwinf *hw, , m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS) , m_waitForNewUpdates(this) , m_filesToUpdate() - , m_updateProcessRunning(false) { + , m_updateProcessRunning(false) + , m_returnCode(0) { QDir::setCurrent(m_workingDirectory); @@ -127,6 +128,7 @@ void Worker::privateUpdate() { bool sentIsmasLastVersionNotification = false; + m_returnCode = -1; QDir customerRepository(m_customerRepository); if (!customerRepository.exists()) { if (m_gc.gitCloneAndCheckoutBranch()) { @@ -146,10 +148,7 @@ void Worker::privateUpdate() { m_ismasClient.setProgressInPercent(95); IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated()); - - //emit setProgress(100); - //m_ismasClient.setProgressInPercent(100); - //emit appendText(QString(""), UPDATE_STEP_SUCCESS); + m_returnCode = 0; } } else { // checkout branch @@ -199,22 +198,51 @@ void Worker::privateUpdate() { IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated()); + + m_returnCode = 0; + } else { + m_returnCode = -9; } + } else { + m_returnCode = -8; } + } else { + m_returnCode = -7; } + } else { + m_returnCode = -6; } + } else { + m_returnCode = -5; } + } else { + m_returnCode = -4; } + } else { + m_returnCode = -3; } + } else { + m_returnCode = -2; } + } else { + m_returnCode = -1; } } if (!sentIsmasLastVersionNotification) { // try even if the backend is not connected - sendIsmasLastVersionNotification(); emit setProgress(100); m_ismasClient.setProgressInPercent(100); - emit appendText(QString(""), UPDATE_STEP_SUCCESS); + + if (m_returnCode == 0) { + IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, + QString("#M=APISM#C=CMD_EVENT#J=") + + m_ismasClient.updateOfPSASucceeded("")); + emit appendText(QString(""), UPDATE_STEP_SUCCESS); + } else { + emit appendText(QString(""), UPDATE_STEP_FAIL); + } + + sendIsmasLastVersionNotification(); } m_updateProcessRunning = false; @@ -253,7 +281,7 @@ bool Worker::backendConnected() { bool ismas = obj.value("ISMAS").toBool(); QString status = obj.value("Broker").toString(); - qCritical() << "XXXXXXXXXX STATUS" << status; + qCritical() << "STATUS" << status; if (ismas) { if (status == "Connected") { @@ -494,7 +522,9 @@ bool Worker::updateFiles(quint8 percent) { } } - qCritical() << "XXXXXXXXXXXXXXXXXXX FILES_TO_WORK_ON" << filesToDownload; + if (filesToDownload.size() > 0) { + qCritical() << "FILES_TO_WORK_ON" << filesToDownload; + } return m_update->doUpdate(m_displayIndex, filesToDownload); } diff --git a/worker.h b/worker.h index 3aba0db..94a01e4 100644 --- a/worker.h +++ b/worker.h @@ -122,6 +122,7 @@ class Worker : public QObject { QStringList m_filesToUpdate; bool m_updateProcessRunning; int m_displayIndex; + int m_returnCode; bool executeOpkgCommand(QString opkgCommand); QString getOsVersion() const; @@ -156,6 +157,7 @@ public: IsmasClient const &getIsmasClient() const { return m_ismasClient; } bool updateProcessRunning() const { return m_updateProcessRunning; } + bool returnCode() const { return m_returnCode; } int machineNr() const { return m_machineNr; } int customerNr() const { return m_customerNr; }