Compare commits
	
		
			3 Commits
		
	
	
		
			39b5551e90
			...
			3069c3bd65
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3069c3bd65 | |||
| b5067ce044 | |||
| 3573279dfa | 
| @@ -26,11 +26,69 @@ int main(int argc, char **argv) { | |||||||
|     QCoreApplication::setApplicationName("ATBUpdateSync"); |     QCoreApplication::setApplicationName("ATBUpdateSync"); | ||||||
|     QCoreApplication::setApplicationVersion(APP_VERSION); |     QCoreApplication::setApplicationVersion(APP_VERSION); | ||||||
|  |  | ||||||
|  |     QDebug debug = qCritical(); | ||||||
|  |  | ||||||
|     if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling |     if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling | ||||||
|         atbInstallMessageHandler(nullptr); |         atbInstallMessageHandler(nullptr); | ||||||
|         //atbInstallMessageHandler(atbDebugOutput); |         //atbInstallMessageHandler(atbDebugOutput); | ||||||
|         setDebugLevel(LOG_NOTICE); |         setDebugLevel(LOG_NOTICE); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return 0; |     if (internal::customerRepoExists() == false) { | ||||||
|  |         qCritical().noquote() << internal::NO_CUSTOMER_REPOSITORY; | ||||||
|  |         return internal::NO_CUSTOMER_REPOSITORY_CODE; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     QString const crd = internal::customerRepoDir(); | ||||||
|  |     QString const etcInRepo = QDir::cleanPath(crd + QDir::separator() + "etc/"); | ||||||
|  |     QString const optInRepo = QDir::cleanPath(crd + QDir::separator() + "opt/"); | ||||||
|  |  | ||||||
|  |     if (!QDir(etcInRepo).exists()) { | ||||||
|  |         qCritical().noquote() << internal::NO_ETC_CUSTOMER_REPOSITORY; | ||||||
|  |         return internal::NO_ETC_CUSTOMER_REPOSITORY_CODE; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (!QDir(optInRepo).exists()) { | ||||||
|  |         qCritical().noquote() << internal::NO_OPT_CUSTOMER_REPOSITORY; | ||||||
|  |         return internal::NO_OPT_CUSTOMER_REPOSITORY_CODE; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
|  |     error codes for rsync: | ||||||
|  |         https://stackoverflow.com/questions/20737204/comprehensive-list-of-rsync-error-codes | ||||||
|  |  | ||||||
|  |      0     Success | ||||||
|  |      1     Syntax or usage error | ||||||
|  |      2     Protocol incompatibility | ||||||
|  |      3     Errors selecting input/output files, dirs | ||||||
|  |      4     Requested action not supported: an attempt was made to manipulate 64-bit | ||||||
|  |            files on a platform that cannot support them; or an option was specified | ||||||
|  |            that is supported by the client and not by the server. | ||||||
|  |      5     Error starting client-server protocol | ||||||
|  |      6     Daemon unable to append to log-file | ||||||
|  |     10     Error in socket I/O | ||||||
|  |     11     Error in file I/O | ||||||
|  |     12     Error in rsync protocol data stream | ||||||
|  |     13     Errors with program diagnostics | ||||||
|  |     14     Error in IPC code | ||||||
|  |     20     Received SIGUSR1 or SIGINT | ||||||
|  |     21     Some error returned by waitpid() | ||||||
|  |     22     Error allocating core memory buffers | ||||||
|  |     23     Partial transfer due to error | ||||||
|  |     24     Partial transfer due to vanished source files | ||||||
|  |     25     The --max-delete limit stopped deletions | ||||||
|  |     30     Timeout in data send/receive | ||||||
|  |     35     Timeout waiting for daemon connection | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     QStringList options({"-v", "--recursive", "--progress", "--checksum", | ||||||
|  |                          "--exclude=.*", "--include=*.bin", "--include=*.json", | ||||||
|  |                          "--include=*.ini"}); | ||||||
|  |     int ret = SyncCommand().exec("rsync", options << etcInRepo << "/etc"); | ||||||
|  |  | ||||||
|  |     if (ret == 0) { | ||||||
|  |        ret = SyncCommand().exec("rsync", options << optInRepo << "/opt"); | ||||||
|  |     } | ||||||
|  |     return ret; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,7 +12,10 @@ using namespace internal; | |||||||
| SyncCommand::SyncCommand() { | SyncCommand::SyncCommand() { | ||||||
| } | } | ||||||
|  |  | ||||||
| bool SyncCommand::exec(QString const &cmd, QStringList const &options, | int SyncCommand::exec(QString const &cmd, QStringList const &options, | ||||||
|                        int start_timeout, int finish_timeout) { |                        int start_timeout, int finish_timeout) { | ||||||
|     return false; |     Command c(cmd, options, internal::customerRepoDir(), | ||||||
|  |               start_timeout, finish_timeout); | ||||||
|  |     c.exec(); | ||||||
|  |     return c.exitCode(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ class SyncCommand { | |||||||
| public: | public: | ||||||
|     SyncCommand(); |     SyncCommand(); | ||||||
|  |  | ||||||
|     bool exec(QString const &cmd, QStringList const &options, |     int exec(QString const &cmd, QStringList const &options, | ||||||
|               int start_timeout = 100000, int finish_timeout = 100000); |               int start_timeout = 100000, int finish_timeout = 100000); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,6 +16,15 @@ | |||||||
| #include <QColor> | #include <QColor> | ||||||
| #include <QColorDialog> | #include <QColorDialog> | ||||||
|  |  | ||||||
|  | #define CHECK_BACKEND_CONNECTION    0 | ||||||
|  | #define CHECK_UPDATE_REQUEST        1 | ||||||
|  | #define UPDATE_CUSTOMER_REPOSITORY  2 | ||||||
|  | #define INSTALL_SW_PACKETS_DRY_RUN  3 | ||||||
|  | #define INSTALL_SW_PACKETS          4 | ||||||
|  | #define INSTALL_DC_CONFIGURATION    5 | ||||||
|  | #define SYNCHRONIZE_REPOSITORY      6 | ||||||
|  | #define UPDATE_DC                   7 | ||||||
|  |  | ||||||
|  |  | ||||||
| MainWindow::MainWindow(Worker *worker, QWidget *parent) | MainWindow::MainWindow(Worker *worker, QWidget *parent) | ||||||
|     : QMainWindow(parent) |     : QMainWindow(parent) | ||||||
| @@ -27,6 +36,25 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent) | |||||||
|  |  | ||||||
|     ui->setupUi(this); |     ui->setupUi(this); | ||||||
|  |  | ||||||
|  |     m_updateSteps.resize(8); | ||||||
|  |     m_updateSteps[CHECK_BACKEND_CONNECTION] = "Check backend connection (ISMAS) "; | ||||||
|  |     m_updateSteps[CHECK_UPDATE_REQUEST] = "Check update request "; | ||||||
|  |     m_updateSteps[UPDATE_CUSTOMER_REPOSITORY] = "Update customer repository "; | ||||||
|  |     m_updateSteps[INSTALL_SW_PACKETS_DRY_RUN] = "Install SW packets (dry run) "; | ||||||
|  |     m_updateSteps[INSTALL_SW_PACKETS] = "Install SW packets "; | ||||||
|  |     m_updateSteps[INSTALL_DC_CONFIGURATION] = "Install DC configuration "; | ||||||
|  |     m_updateSteps[SYNCHRONIZE_REPOSITORY] = "Synchronize repository/filesystem "; | ||||||
|  |     m_updateSteps[UPDATE_DC] = "Update DC"; | ||||||
|  |  | ||||||
|  |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         QString &tmp = m_updateSteps[i]; | ||||||
|  |         int len = m_showLineLength - tmp.length(); | ||||||
|  |         while (--len > 0) { | ||||||
|  |            tmp += " "; | ||||||
|  |         } | ||||||
|  |         ui->stepLabel->setText(tmp + "\n"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     this->setStatusBar(new QStatusBar(this)); |     this->setStatusBar(new QStatusBar(this)); | ||||||
|     QFont f; |     QFont f; | ||||||
|     f.setStyleHint(QFont::Monospace); |     f.setStyleHint(QFont::Monospace); | ||||||
| @@ -149,81 +177,68 @@ void MainWindow::onShowTariffUpdate(QString) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::onShowISMASConnectivity(QString status) { | void MainWindow::onShowISMASConnectivity(QString status) { | ||||||
|     // ausgabe: connected, not connected, connecting |     // qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |  | ||||||
|     m_stepLabelChopCount = 0; |     QString s = m_updateSteps[CHECK_BACKEND_CONNECTION].trimmed(); | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |  | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |  | ||||||
|  |  | ||||||
|     QString tmp("Check backend connection (ISMAS) "); |  | ||||||
|     int len = m_showLineLength - tmp.length(); |  | ||||||
|     while (--len > 0) { |  | ||||||
|        tmp += " "; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     bool const custRepoExists = internal::customerRepoExists(); |     bool const custRepoExists = internal::customerRepoExists(); | ||||||
|  |  | ||||||
|     if (status.contains(UpdateCommand::ISMAS_CONNECTED, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::ISMAS_CONNECTED, Qt::CaseInsensitive)) { | ||||||
|         if (custRepoExists) { |         if (custRepoExists) { | ||||||
|             s += QString("%1 <font color='Green'>connected</font><br />").arg(tmp); |             s += " <font color='Green'>connected</font>"; | ||||||
|         } else { |         } else { | ||||||
|             s += QString("%1 <font color='Green'>connected (initial configuration)</font><br />").arg(tmp); |             s += " <font color='Green'>connected (initial configuration)</font>"; | ||||||
|         } |         } | ||||||
|     } else |     } else | ||||||
|     if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Blue'>NOT CONNECTED</font><br />").arg(tmp); |         s += " <font color='Blue'>NOT CONNECTED</font>"; | ||||||
|     } else |     } else | ||||||
|     if (status.contains(UpdateCommand::ISMAS_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::ISMAS_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>connecting</font><br />").arg(tmp); |         s += " <font color='Green'>connecting</font>"; | ||||||
|     } else |     } else | ||||||
|     if (status.contains(UpdateCommand::ISMAS_NOT_CONNECTED, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::ISMAS_NOT_CONNECTED, Qt::CaseInsensitive)) { | ||||||
|         if (custRepoExists) { |         if (custRepoExists) { | ||||||
|             s += QString(  "%1 <font color='Red'>NOT CONNECTED. STOP</font><br />").arg(tmp); |             s += " <font color='Red'>NOT CONNECTED. STOP</font>"; | ||||||
|         } else { |         } else { | ||||||
|             s += QString(  "%1 <font color='Red'>not connected. (initial configuration)</font><br />").arg(tmp); |             s += " <font color='Red'>not connected. (initial configuration)</font>"; | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         s += QString(  "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp); |         s += " <font color='Red'>UNKNOWN STATUS</font>"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     m_stepLabelChopCount = -s.length(); |     m_updateSteps[CHECK_BACKEND_CONNECTION] = s; | ||||||
|     s += "Check update request"; |     s.clear(); | ||||||
|     m_stepLabelChopCount += s.length(); |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         s += m_updateSteps[i] + "<br />"; | ||||||
|  |     } | ||||||
|     ui->stepLabel->setText(s); |     ui->stepLabel->setText(s); | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::onShowCustRepoStatus(QString status) { | void MainWindow::onShowCustRepoStatus(QString status) { | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |     // qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |     QString s = m_updateSteps[UPDATE_CUSTOMER_REPOSITORY].trimmed(); | ||||||
|     s.chop(m_stepLabelChopCount); |  | ||||||
|  |  | ||||||
|     QString tmp("Update customer repository "); |  | ||||||
|     int len = m_showLineLength - tmp.length(); |  | ||||||
|     while (--len > 0) { |  | ||||||
|        tmp += " "; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (status.contains(internal::GIT_CUSTOMER_REPO_UP_TO_DATE, Qt::CaseInsensitive)) { |     if (status.contains(internal::GIT_CUSTOMER_REPO_UP_TO_DATE, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>%2</font><br />").arg(tmp).arg(internal::GIT_CUSTOMER_REPO_UP_TO_DATE); |         s += QString(" <font color='Green'>%1</font>").arg(internal::GIT_CUSTOMER_REPO_UP_TO_DATE); | ||||||
|     } else |     } else | ||||||
|     if (status.contains(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY, Qt::CaseInsensitive)) { |     if (status.contains(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>%2</font><br />").arg(tmp).arg(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY); |         s += QString(" <font color='Green'>%1</font>").arg(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY); | ||||||
|     } else { |     } else { | ||||||
|         s += QString(  "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp); |         s += " <font color='Red'>UNKNOWN STATUS</font>"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     m_stepLabelChopCount = -s.length(); |     m_updateSteps[UPDATE_CUSTOMER_REPOSITORY] = s; | ||||||
|     s += "Install SW packets (dry run)"; |     s.clear(); | ||||||
|     m_stepLabelChopCount += s.length(); |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         s += m_updateSteps[i] + "<br />"; | ||||||
|  |     } | ||||||
|     ui->stepLabel->setText(s); |     ui->stepLabel->setText(s); | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::onShowExecOpkgStatus(QString status) { | void MainWindow::onShowExecOpkgStatus(QString status) { | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |     qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |     return; | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |     QString s = ui->stepLabel->text(); | ||||||
|  |  | ||||||
| @@ -245,6 +260,7 @@ void MainWindow::onShowExecOpkgStatus(QString status) { | |||||||
|  |  | ||||||
| void MainWindow::onShowExecOpkgCommand(QString cmd) { | void MainWindow::onShowExecOpkgCommand(QString cmd) { | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "cmd" << cmd; |     qCritical() << __func__ << ":" << __LINE__ << "cmd" << cmd; | ||||||
|  |     return; | ||||||
|  |  | ||||||
|     if (cmd.back() != QChar('\n')) { |     if (cmd.back() != QChar('\n')) { | ||||||
|         cmd += "\n"; |         cmd += "\n"; | ||||||
| @@ -253,158 +269,132 @@ void MainWindow::onShowExecOpkgCommand(QString cmd) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::onShowExecOpkgOverallResult(QString status, bool noaction) { | void MainWindow::onShowExecOpkgOverallResult(QString status, bool noaction) { | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |     //qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |     QString s = noaction ? | ||||||
|     s.chop(m_stepLabelChopCount); |         m_updateSteps[INSTALL_SW_PACKETS_DRY_RUN].trimmed() : | ||||||
|  |         m_updateSteps[INSTALL_SW_PACKETS].trimmed(); | ||||||
|     QString tmp = noaction ? "Install SW packets (dry run) " : "Install SW packets "; |  | ||||||
|     int len = m_showLineLength - tmp.length(); |  | ||||||
|  |  | ||||||
|     while (--len > 0) { |  | ||||||
|        tmp += " "; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (status.contains(internal::EXEC_OPKG_COMMANDS_SUCCESS, Qt::CaseInsensitive)) { |     if (status.contains(internal::EXEC_OPKG_COMMANDS_SUCCESS, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>success</font><br />").arg(tmp); |         s += " <font color='Green'>success</font>"; | ||||||
|     } else |     } else | ||||||
|     if (status.contains(internal::EXEC_OPKG_COMMANDS_FAIL, Qt::CaseInsensitive)) { |     if (status.contains(internal::EXEC_OPKG_COMMANDS_FAIL, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Red'>%2</font><br />").arg(tmp).arg(internal::EXEC_OPKG_COMMANDS_FAIL); |         s += QString(" <font color='Red'>%1</font>").arg(internal::EXEC_OPKG_COMMANDS_FAIL); | ||||||
|     } else { |     } else { | ||||||
|         s += QString(  "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp); |         s += " <font color='Red'>UNKNOWN STATUS</font>"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (noaction) { |     if (noaction) { | ||||||
|         m_stepLabelChopCount = -s.length(); |         m_updateSteps[INSTALL_SW_PACKETS_DRY_RUN] = s; | ||||||
|         s += "Install SW packets"; |  | ||||||
|         m_stepLabelChopCount += s.length(); |  | ||||||
|     } else { |     } else { | ||||||
|         m_stepLabelChopCount = -s.length(); |         m_updateSteps[INSTALL_SW_PACKETS] = s; | ||||||
|         s += "Install DC configuration"; |     } | ||||||
|         m_stepLabelChopCount += s.length(); |  | ||||||
|  |     s.clear(); | ||||||
|  |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         s += m_updateSteps[i] + "<br />"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     ui->stepLabel->setText(s); |     ui->stepLabel->setText(s); | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::onShowDownloadDCJsonFilesStatus(QString status) { | void MainWindow::onShowDownloadDCJsonFilesStatus(QString status) { | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |     //qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |     QString s = m_updateSteps[INSTALL_DC_CONFIGURATION].trimmed(); | ||||||
|     s.chop(m_stepLabelChopCount); |  | ||||||
|  |  | ||||||
|     QString tmp = "Install DC configuration "; |  | ||||||
|     int len = m_showLineLength - tmp.length(); |  | ||||||
|  |  | ||||||
|     while (--len > 0) { |  | ||||||
|        tmp += " "; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (status.contains(UpdateCommand::UPDATE_DC_JSON_FILES_SUCCESS, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::UPDATE_DC_JSON_FILES_SUCCESS, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>success</font><br />").arg(tmp); |         s += " <font color='Green'>success</font>"; | ||||||
|     } else { |     } else { | ||||||
|         s += QString(  "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp); |         s += " <font color='Red'>UNKNOWN STATUS</font>"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     m_stepLabelChopCount = -s.length(); |     m_updateSteps[INSTALL_DC_CONFIGURATION] = s; | ||||||
|     s += "Synchronize repository/filesystem"; |     s.clear(); | ||||||
|     m_stepLabelChopCount += s.length(); |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         s += m_updateSteps[i] + "<br />"; | ||||||
|  |     } | ||||||
|     ui->stepLabel->setText(s); |     ui->stepLabel->setText(s); | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::onShowSyncCustRepoStatus(QString status) { | void MainWindow::onShowSyncCustRepoStatus(QString status) { | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |     //qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |     QString s = m_updateSteps[SYNCHRONIZE_REPOSITORY].trimmed(); | ||||||
|     s.chop(m_stepLabelChopCount); |  | ||||||
|  |  | ||||||
|     QString tmp = "Synchronize repository/filesystem "; |  | ||||||
|     int len = m_showLineLength - tmp.length(); |  | ||||||
|  |  | ||||||
|     while (--len > 0) { |  | ||||||
|        tmp += " "; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (status.contains(UpdateCommand::SYNC_CUSTOMER_REPO_FILES_SUCCESS, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::SYNC_CUSTOMER_REPO_FILES_SUCCESS, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>success</font><br />").arg(tmp); |         s += " <font color='Green'>success</font>"; | ||||||
|     } else { |     } else { | ||||||
|         s += QString(  "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp); |         s += " <font color='Red'>UNKNOWN STATUS</font>"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     m_stepLabelChopCount = -s.length(); |     m_updateSteps[SYNCHRONIZE_REPOSITORY] = s; | ||||||
|     s += "Update DC"; |     s.clear(); | ||||||
|     m_stepLabelChopCount += s.length(); |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         s += m_updateSteps[i] + "<br />"; | ||||||
|  |     } | ||||||
|     ui->stepLabel->setText(s); |     ui->stepLabel->setText(s); | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::onShowUpdateDCFirmware(QString status) { | void MainWindow::onShowUpdateDCFirmware(QString status) { | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |     // qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |     QString s = m_updateSteps[UPDATE_DC].trimmed(); | ||||||
|     s.chop(m_stepLabelChopCount); |  | ||||||
|  |  | ||||||
|     QString tmp = "Update DC "; |  | ||||||
|     int len = m_showLineLength - tmp.length(); |  | ||||||
|  |  | ||||||
|     while (--len > 0) { |  | ||||||
|        tmp += " "; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (status.contains(UpdateCommand::UPDATE_DC_FIRMARE_SUCCESS, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::UPDATE_DC_FIRMARE_SUCCESS, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>success</font><br />").arg(tmp); |         s += " <font color='Green'>success</font>"; | ||||||
|     } else { |     } else { | ||||||
|         s += QString(  "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp); |         s += " <font color='Red'>UNKNOWN STATUS</font>"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     m_updateSteps[UPDATE_DC] = s; | ||||||
|  |     s.clear(); | ||||||
|  |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         if (i != UPDATE_DC) { | ||||||
|  |             s += m_updateSteps[i] + "<br />"; | ||||||
|  |         } else { | ||||||
|  |             s += m_updateSteps[i]; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|     ui->stepLabel->setText(s); |     ui->stepLabel->setText(s); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void MainWindow::onShowUpdateRequest(QString status) { | void MainWindow::onShowUpdateRequest(QString status) { | ||||||
|  |     // qCritical() << __func__ << ":" << __LINE__ << "status" << status; | ||||||
|  |  | ||||||
|     qCritical() << __func__ << ":" << __LINE__ << "status" << status; |     QString s = m_updateSteps[CHECK_UPDATE_REQUEST].trimmed(); | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |  | ||||||
|     s.chop(m_stepLabelChopCount); |  | ||||||
|  |  | ||||||
|     QString tmp = "Check update request "; |  | ||||||
|     int len = m_showLineLength - tmp.length(); |  | ||||||
|  |  | ||||||
|     while (--len > 0) { |  | ||||||
|        tmp += " "; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     bool const custRepoExists = internal::customerRepoExists(); |     bool const custRepoExists = internal::customerRepoExists(); | ||||||
|  |  | ||||||
|     if (status.contains(UpdateCommand::UPDATE_NOT_REQUESTED, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::UPDATE_NOT_REQUESTED, Qt::CaseInsensitive)) { | ||||||
|         if (custRepoExists) { |         if (custRepoExists) { | ||||||
|             s += QString(  "%1 <font color='Red'>NOT REQUESTED. STOP.</font><br />").arg(tmp); |             s += " <font color='Red'>NOT REQUESTED. STOP.</font>"; | ||||||
|         } else { |         } else { | ||||||
|             s += QString("%1 <font color='Blue'>not requested (initial configuration)</font><br />").arg(tmp); |             s += " <font color='Blue'>not requested (initial configuration)</font>"; | ||||||
|         } |         } | ||||||
|     } else |     } else | ||||||
|     if (status.contains(UpdateCommand::UPDATE_REQUESTED, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::UPDATE_REQUESTED, Qt::CaseInsensitive)) { | ||||||
|         if (custRepoExists) { |         if (custRepoExists) { | ||||||
|             s += QString("%1 <font color='Green'>requested</font><br />").arg(tmp); |             s += " <font color='Green'>requested</font>"; | ||||||
|         } else { |         } else { | ||||||
|             s += QString("%1 <font color='Blue'>requested (initial configuration)</font><br />").arg(tmp); |             s += " <font color='Blue'>requested (initial configuration)</font>"; | ||||||
|         } |         } | ||||||
|     } else |     } else | ||||||
|     if (status.contains(UpdateCommand::UPDATE_NOT_NECESSARY, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::UPDATE_NOT_NECESSARY, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Green'>not necessary</font><br />").arg(tmp); |         s += " <font color='Green'>not necessary</font>"; | ||||||
|     } else |     } else | ||||||
|     if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) { |     if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) { | ||||||
|         s += QString("%1 <font color='Blue'>UNKNOWN (ISMAS not connected)</font><br />").arg(tmp); |         s += " <font color='Blue'>UNKNOWN (ISMAS not connected)</font>"; | ||||||
|     } else { |     } else { | ||||||
|         s += QString(  "%1 <font color='Red'>UNKNOWN</font><br />").arg(tmp); |         s += " <font color='Red'>UNKNOWN</font>"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     m_stepLabelChopCount = -s.length(); |     m_updateSteps[CHECK_UPDATE_REQUEST] = s; | ||||||
|     s += "Update customer repository"; |     s.clear(); | ||||||
|     m_stepLabelChopCount += s.length(); |     for (int i = 0; i < m_updateSteps.size(); ++i) { | ||||||
|  |         s += m_updateSteps[i] + "<br />"; | ||||||
|  |     } | ||||||
|     ui->stepLabel->setText(s); |     ui->stepLabel->setText(s); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -412,6 +402,7 @@ void MainWindow::onShowISMASChecks(QString) { | |||||||
|     // deprecated |     // deprecated | ||||||
|  |  | ||||||
|     QString s = ui->stepLabel->text(); |     QString s = ui->stepLabel->text(); | ||||||
|  |     return; | ||||||
|  |  | ||||||
|     QString tmp("Check ISMAS connectivity "); |     QString tmp("Check ISMAS connectivity "); | ||||||
|     int len = m_showLineLength - tmp.length(); |     int len = m_showLineLength - tmp.length(); | ||||||
|   | |||||||
| @@ -4,6 +4,8 @@ | |||||||
| #include <QMainWindow> | #include <QMainWindow> | ||||||
| #include <QTimer> | #include <QTimer> | ||||||
| #include <QStatusBar> | #include <QStatusBar> | ||||||
|  | #include <QVector> | ||||||
|  | #include <QString> | ||||||
|  |  | ||||||
| QT_BEGIN_NAMESPACE | QT_BEGIN_NAMESPACE | ||||||
| namespace Ui { class MainWindow; } | namespace Ui { class MainWindow; } | ||||||
| @@ -97,5 +99,8 @@ private: | |||||||
|     QTimer *m_statusTimer; |     QTimer *m_statusTimer; | ||||||
|     QString m_targetDcVersion; |     QString m_targetDcVersion; | ||||||
|     int m_stepLabelChopCount{}; |     int m_stepLabelChopCount{}; | ||||||
|  |  | ||||||
|  |     QVector<QString> m_updateSteps{}; | ||||||
|  |  | ||||||
| }; | }; | ||||||
| #endif // MAINWINDOW_H | #endif // MAINWINDOW_H | ||||||
|   | |||||||
| @@ -10,6 +10,11 @@ namespace internal { | |||||||
|     static constexpr const char *UPDATE_REQUESTED{"requested"}; |     static constexpr const char *UPDATE_REQUESTED{"requested"}; | ||||||
|  |  | ||||||
|     static constexpr const char *NO_CUSTOMER_REPOSITORY{"no customer repository"}; |     static constexpr const char *NO_CUSTOMER_REPOSITORY{"no customer repository"}; | ||||||
|  |     static constexpr const int NO_CUSTOMER_REPOSITORY_CODE{-8}; | ||||||
|  |     static constexpr const char *NO_ETC_CUSTOMER_REPOSITORY{"no etc/ in customer repository"}; | ||||||
|  |     static constexpr const int NO_ETC_CUSTOMER_REPOSITORY_CODE{-9}; | ||||||
|  |     static constexpr const char *NO_OPT_CUSTOMER_REPOSITORY{"no opt/ in customer repository"}; | ||||||
|  |     static constexpr const int NO_OPT_CUSTOMER_REPOSITORY_CODE{-10}; | ||||||
|  |  | ||||||
|     static constexpr const char *ISMAS_CONNECTED{"connected"}; |     static constexpr const char *ISMAS_CONNECTED{"connected"}; | ||||||
|     static constexpr const char *ISMAS_DISCONNECTED{"disconnected"}; |     static constexpr const char *ISMAS_DISCONNECTED{"disconnected"}; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user