cleaning up source code. move summary-handling to main-window.
This commit is contained in:
		@@ -185,7 +185,7 @@ Worker::Worker(int customerNr,
 | 
				
			|||||||
  , m_pluginVersionPrmCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin_ConfigUi.so"))
 | 
					  , m_pluginVersionPrmCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin_ConfigUi.so"))
 | 
				
			||||||
  , m_pluginVersionTcpZvt(getPluginVersion("/opt/app/ATBAPP/plugins/libTCP_ZVT_CCPlugin.so"))
 | 
					  , m_pluginVersionTcpZvt(getPluginVersion("/opt/app/ATBAPP/plugins/libTCP_ZVT_CCPlugin.so"))
 | 
				
			||||||
  , m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
 | 
					  , m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
 | 
				
			||||||
  , m_waitForNewUpdates(this)
 | 
					  , m_summaryTimer(this)
 | 
				
			||||||
  , m_filesToUpdate()
 | 
					  , m_filesToUpdate()
 | 
				
			||||||
  , m_updateProcessRunning(true)
 | 
					  , m_updateProcessRunning(true)
 | 
				
			||||||
  , m_mainWindow(nullptr) /* contains plugin */
 | 
					  , m_mainWindow(nullptr) /* contains plugin */
 | 
				
			||||||
@@ -202,8 +202,8 @@ Worker::Worker(int customerNr,
 | 
				
			|||||||
    int next = 1;
 | 
					    int next = 1;
 | 
				
			||||||
    m_workList.push_back(
 | 
					    m_workList.push_back(
 | 
				
			||||||
                std::make_unique<CheckIsmasConnectivityCommand>(
 | 
					                std::make_unique<CheckIsmasConnectivityCommand>(
 | 
				
			||||||
                    //QString("echo CheckIsmasConnectivityCommand")
 | 
					                    QString("echo ATBUpdateCheck --ismas-connected")
 | 
				
			||||||
                    QString("/opt/app/tools/atbupdate/ATBUpdateCheck --ismas-connected")
 | 
					                    //QString("/opt/app/tools/atbupdate/ATBUpdateCheck --ismas-connected")
 | 
				
			||||||
                    , this, ++next));
 | 
					                    , this, ++next));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // *** check if update activated in ISMAS ***
 | 
					    // *** check if update activated in ISMAS ***
 | 
				
			||||||
@@ -211,8 +211,8 @@ Worker::Worker(int customerNr,
 | 
				
			|||||||
    // if the update has been activated via ISMAS.
 | 
					    // if the update has been activated via ISMAS.
 | 
				
			||||||
    m_workList.push_back(
 | 
					    m_workList.push_back(
 | 
				
			||||||
                std::make_unique<CheckUpdateActivationCommand>(
 | 
					                std::make_unique<CheckUpdateActivationCommand>(
 | 
				
			||||||
                    //QString("echo CheckUpdateActivationCommand")
 | 
					                    QString("echo ATBUpdateCheck --update-requested")
 | 
				
			||||||
                    QString("/opt/app/tools/atbupdate/ATBUpdateCheck --update-requested")
 | 
					                    //QString("/opt/app/tools/atbupdate/ATBUpdateCheck --update-requested")
 | 
				
			||||||
                    , this, ++next));
 | 
					                    , this, ++next));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // *** check and fetch git-customer repository ***
 | 
					    // *** check and fetch git-customer repository ***
 | 
				
			||||||
@@ -221,24 +221,24 @@ Worker::Worker(int customerNr,
 | 
				
			|||||||
    //      the corresponding branch, and check the integrity of the repository.
 | 
					    //      the corresponding branch, and check the integrity of the repository.
 | 
				
			||||||
    m_workList.push_back(
 | 
					    m_workList.push_back(
 | 
				
			||||||
                std::make_unique<CheckAndFetchCustomerRepositoryCommand>(
 | 
					                std::make_unique<CheckAndFetchCustomerRepositoryCommand>(
 | 
				
			||||||
                    // QString("echo CheckAndFetchCustomerRepositoryCommand")
 | 
					                    QString("echo ATBUpdateGit")
 | 
				
			||||||
                    QString("/opt/app/tools/atbupdate/ATBUpdateGit")
 | 
					                    // QString("/opt/app/tools/atbupdate/ATBUpdateGit")
 | 
				
			||||||
                    , this, ++next));
 | 
					                    , this, ++next));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // *** exec opkg-commands (noaction) ***
 | 
					    // *** exec opkg-commands (noaction) ***
 | 
				
			||||||
    // NOTE: first run the opkg commands with no action -> dry-run
 | 
					    // NOTE: first run the opkg commands with no action -> dry-run
 | 
				
			||||||
    m_workList.push_back(
 | 
					    m_workList.push_back(
 | 
				
			||||||
                std::make_unique<ExecOpkgCommand>(
 | 
					                std::make_unique<ExecOpkgCommand>(
 | 
				
			||||||
                    // QString("echo ExecOpkgCommand noaction")
 | 
					                    QString("echo ATBUpdateOpkg --noaction")
 | 
				
			||||||
                    QString("/opt/app/tools/atbupdate/ATBUpdateOpkg --noaction")
 | 
					                    // QString("/opt/app/tools/atbupdate/ATBUpdateOpkg --noaction")
 | 
				
			||||||
                    , this, ++next, true));
 | 
					                    , this, ++next, true));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // *** exec opkg-commands ***
 | 
					    // *** exec opkg-commands ***
 | 
				
			||||||
    // NOTE: first run the opkg commands with action -> no dry-run
 | 
					    // NOTE: first run the opkg commands with action -> no dry-run
 | 
				
			||||||
    m_workList.push_back(
 | 
					    m_workList.push_back(
 | 
				
			||||||
                std::make_unique<ExecOpkgCommand>(
 | 
					                std::make_unique<ExecOpkgCommand>(
 | 
				
			||||||
                    //QString("echo ExecOpkgCommand run")
 | 
					                    QString("echo ExecOpkgCommand run")
 | 
				
			||||||
                    QString("/opt/app/tools/atbupdate/ATBUpdateOpkg")
 | 
					                    // QString("/opt/app/tools/atbupdate/ATBUpdateOpkg")
 | 
				
			||||||
                    , this, ++next, false));
 | 
					                    , this, ++next, false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // *** send json files down to device controller ***
 | 
					    // *** send json files down to device controller ***
 | 
				
			||||||
@@ -257,14 +257,14 @@ Worker::Worker(int customerNr,
 | 
				
			|||||||
    // send device-controller firmware down to device-controller-hardware
 | 
					    // send device-controller firmware down to device-controller-hardware
 | 
				
			||||||
    m_workList.push_back(
 | 
					    m_workList.push_back(
 | 
				
			||||||
                std::make_unique<UpdateDCCommand>(
 | 
					                std::make_unique<UpdateDCCommand>(
 | 
				
			||||||
                    QString("echo ATBDownloadDCFirmware")
 | 
					                    // QString("echo ATBUpdateDC")
 | 
				
			||||||
                    // QString("/opt/app/tools/atbupdate/ATBDownloadDCFirmware --read-dc-version true")
 | 
					                    QString("/opt/app/tools/atbupdate/ATBUpdateDC")
 | 
				
			||||||
                    , this, ++next));
 | 
					                    , this, ++next));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // show/send software-status
 | 
					    // show/send software-status
 | 
				
			||||||
    m_workList.push_back(
 | 
					    m_workList.push_back(
 | 
				
			||||||
                std::make_unique<ShowSoftwareStatusCommand>(
 | 
					                std::make_unique<ShowSoftwareStatusCommand>(
 | 
				
			||||||
                    QString("echo ATBUpdateShowPSAInstalled")
 | 
					                    QString("echo ATBUpdateShow")
 | 
				
			||||||
                    , this, -1));
 | 
					                    , this, -1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // reboot machine
 | 
					    // reboot machine
 | 
				
			||||||
@@ -1615,78 +1615,3 @@ bool Worker::jsUpdate() {
 | 
				
			|||||||
bool Worker::dcUpdate() {
 | 
					bool Worker::dcUpdate() {
 | 
				
			||||||
    return m_dcDownloadFirmware->start("/opt/app/tools/atbupdate");
 | 
					    return m_dcDownloadFirmware->start("/opt/app/tools/atbupdate");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
void Worker::summary() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    QString summary, first, second, line, tmp;
 | 
					 | 
				
			||||||
    QVector<QPair<QString, QString>> vec = Utils::installedPackages();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    vec.append(Utils::installedTariffFiles(this, m_customerRepository));
 | 
					 | 
				
			||||||
    vec.append(Utils::installedJsonFiles(this, m_customerRepository));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int max_first = 0, max_second = 0;
 | 
					 | 
				
			||||||
    for (int i = 0; i < vec.size(); ++i) {
 | 
					 | 
				
			||||||
        max_first = std::max(max_first, vec[i].first.length());
 | 
					 | 
				
			||||||
        max_second = std::max(max_second, vec[i].second.length());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    max_first += 5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    summary = "UPDATE SUMMARY\n\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    first = QString("%1").arg("start", max_first, QChar(' '));
 | 
					 | 
				
			||||||
    tmp = QString("%1").arg(start().toString(Qt::ISODate));
 | 
					 | 
				
			||||||
    second = QString("%1").arg(tmp, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
    line = first + ": " + second;
 | 
					 | 
				
			||||||
    summary += line + "\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    first = QString("%1").arg("update tool version", max_first, QChar(' '));
 | 
					 | 
				
			||||||
    tmp = QString("%1 - %2 %3").arg(APP_VERSION).arg(APP_BUILD_DATE).arg(APP_BUILD_TIME);
 | 
					 | 
				
			||||||
    second = QString("%1").arg(tmp, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
    line = first + ": " + second;
 | 
					 | 
				
			||||||
    summary += line + "\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    first = QString("%1").arg("machine number", max_first, QChar(' '));
 | 
					 | 
				
			||||||
    tmp = QString("%1").arg(machineNr());
 | 
					 | 
				
			||||||
    second = QString("%1").arg(tmp, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
    line = first + ": " + second;
 | 
					 | 
				
			||||||
    summary += line + "\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    first = QString("%1").arg("customer number", max_first, QChar(' '));
 | 
					 | 
				
			||||||
    tmp = QString("%1").arg(customerNr());
 | 
					 | 
				
			||||||
    second = QString("%1").arg(tmp, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
    line = first + ": " + second;
 | 
					 | 
				
			||||||
    summary += line + "\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    first = QString("%1").arg("zone number", max_first, QChar(' '));
 | 
					 | 
				
			||||||
    tmp = QString("%1").arg(zoneNr());
 | 
					 | 
				
			||||||
    second = QString("%1").arg(tmp, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
    line = first + ": " + second;
 | 
					 | 
				
			||||||
    summary += line + "\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (m_mainWindow) {
 | 
					 | 
				
			||||||
        tmp = m_mainWindow->targetDcVersion();
 | 
					 | 
				
			||||||
        if (!tmp.isEmpty()) {
 | 
					 | 
				
			||||||
            first = QString("%1").arg("target device controller", max_first, QChar(' '));
 | 
					 | 
				
			||||||
            second = QString("%1").arg(tmp, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
            line = first + ": " + second;
 | 
					 | 
				
			||||||
            summary += line + "\n";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    first = QString("%1").arg("apism", max_first, QChar(' '));
 | 
					 | 
				
			||||||
    tmp = QString("%1").arg(apismVersion());
 | 
					 | 
				
			||||||
    second = QString("%1").arg(tmp, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
    line = first + ": " + second;
 | 
					 | 
				
			||||||
    summary += line + "\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int i = 0; i < vec.size(); ++i) {
 | 
					 | 
				
			||||||
        first = QString("%1").arg(vec[i].first, max_first, QChar(' '));
 | 
					 | 
				
			||||||
        second = QString("%1").arg(vec[i].second, -max_second, QChar(' '));
 | 
					 | 
				
			||||||
        line = first + ": " + second;
 | 
					 | 
				
			||||||
        summary += line + "\n";
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    emit showSummary(summary);
 | 
					 | 
				
			||||||
    emit enableExit();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -178,7 +178,7 @@ class Worker : public QThread{
 | 
				
			|||||||
    QString const m_pluginVersionTcpZvt;
 | 
					    QString const m_pluginVersionTcpZvt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int m_ismasUpdateRequests;
 | 
					    int m_ismasUpdateRequests;
 | 
				
			||||||
    QTimer m_waitForNewUpdates;
 | 
					    QTimer m_summaryTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QStringList m_filesToUpdate;
 | 
					    QStringList m_filesToUpdate;
 | 
				
			||||||
    QStringList m_filesToDownload;
 | 
					    QStringList m_filesToDownload;
 | 
				
			||||||
@@ -453,6 +453,8 @@ public:
 | 
				
			|||||||
    void setHW(hwinf *hw) { m_hw = hw; }
 | 
					    void setHW(hwinf *hw) { m_hw = hw; }
 | 
				
			||||||
    hwinf *getHW() { return m_hw; }
 | 
					    hwinf *getHW() { return m_hw; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString customerRepository() { return m_customerRepository; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    IsmasClient &getIsmasClient() { return m_ismasClient; }
 | 
					    IsmasClient &getIsmasClient() { return m_ismasClient; }
 | 
				
			||||||
    IsmasClient const &getIsmasClient() const { return m_ismasClient; }
 | 
					    IsmasClient const &getIsmasClient() const { return m_ismasClient; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -473,7 +475,6 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    bool jsUpdate();
 | 
					    bool jsUpdate();
 | 
				
			||||||
    bool dcUpdate();
 | 
					    bool dcUpdate();
 | 
				
			||||||
    void summary();
 | 
					 | 
				
			||||||
    QDateTime start() { return m_start; }
 | 
					    QDateTime start() { return m_start; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QByteArray standardOutput() const { return m_standardOutput; }
 | 
					    QByteArray standardOutput() const { return m_standardOutput; }
 | 
				
			||||||
@@ -481,6 +482,8 @@ public:
 | 
				
			|||||||
    WorkList const &workList() const { return m_workList; }
 | 
					    WorkList const &workList() const { return m_workList; }
 | 
				
			||||||
    WorkList &workList() { return m_workList; }
 | 
					    WorkList &workList() { return m_workList; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QTimer *summaryTimer() { return &m_summaryTimer; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
    void appendText(QString, QString suffix = "");
 | 
					    void appendText(QString, QString suffix = "");
 | 
				
			||||||
    void insertText(QString);
 | 
					    void insertText(QString);
 | 
				
			||||||
@@ -507,6 +510,7 @@ signals:
 | 
				
			|||||||
    void showDownloadDCJsonFilesStatus(QString);
 | 
					    void showDownloadDCJsonFilesStatus(QString);
 | 
				
			||||||
    void showSyncCustRepoStatus(QString);
 | 
					    void showSyncCustRepoStatus(QString);
 | 
				
			||||||
    void showUpdateDCFirmware(QString);
 | 
					    void showUpdateDCFirmware(QString);
 | 
				
			||||||
 | 
					    void summary();
 | 
				
			||||||
    void showSummary(QString);
 | 
					    void showSummary(QString);
 | 
				
			||||||
    void setDcDownloadProgress(int);
 | 
					    void setDcDownloadProgress(int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user