aheinecke@404: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik aheinecke@404: * Software engineering by Intevation GmbH aheinecke@404: * aheinecke@404: * This file is Free Software under the GNU GPL (v>=2) aheinecke@404: * and comes with ABSOLUTELY NO WARRANTY! aheinecke@404: * See LICENSE.txt for details. aheinecke@404: */ aheinecke@0: #ifndef MAINWINDOW_H aheinecke@0: #define MAINWINDOW_H aheinecke@0: aheinecke@71: /** aheinecke@71: * @file mainwindow.h aheinecke@71: * @brief Main UI controller aheinecke@71: */ aheinecke@71: aheinecke@0: #include rrenkert@153: #include aheinecke@16: #include rrenkert@155: #include rrenkert@189: #include rrenkert@189: #include rrenkert@271: #include rrenkert@432: #include rrenkert@432: #include rrenkert@584: #include aheinecke@16: aheinecke@16: #include "downloader.h" aheinecke@71: #include "certificatelist.h" rrenkert@584: #include "certificatelistwidget.h" aheinecke@0: class QMenu; aheinecke@0: class QAction; aheinecke@19: class QTimer; aheinecke@0: rrenkert@432: rrenkert@153: class MainWindow : public QMainWindow aheinecke@0: { aheinecke@0: Q_OBJECT aheinecke@0: aheinecke@0: public: aheinecke@365: /**@brief create a new Main Window object aheinecke@365: * aheinecke@365: * In tray mode this window is not shown and only shows aheinecke@365: * notification messages if there is some actionable state aheinecke@365: * reached. If tray mode is true it also exits after aheinecke@365: * an update check. aheinecke@365: * aheinecke@365: * @param[in] trayMode set the tray mode aheinecke@365: * */ aheinecke@365: MainWindow(bool trayMode); aheinecke@0: aheinecke@0: void setMessage(const QString message) {mCurMessage = message;} aheinecke@0: QString getMessage() {return mCurMessage;} aheinecke@0: aheinecke@16: enum CurrentState { aheinecke@16: BeforeDownload, aheinecke@16: NewListAvailable, aheinecke@16: NewSoftwareAvailable, aheinecke@551: DownloadingSW, andre@389: TransferError, andre@389: NothingChanged aheinecke@16: }; aheinecke@16: CurrentState getState() {return mCurState;} aheinecke@16: void setState(CurrentState state) {mCurState = state;} aheinecke@16: aheinecke@0: private slots: aheinecke@0: void showMessage(); aheinecke@0: void iconActivated(QSystemTrayIcon::ActivationReason reason); rrenkert@461: void checkUpdates(bool downloadSW = false); aheinecke@16: void handleNewList(const QString& fileName, const QDateTime& modDate); aheinecke@16: void handleNewSW(const QString& fileName, const QDateTime& modDate); aheinecke@45: void downloaderError(const QString &message, SSLConnection::ErrorCode error); aheinecke@71: /** @brief Trigger the appropiate action depending on the state */ aheinecke@71: void messageClicked(); aheinecke@365: void installerError(const QString& errMsg); andre@389: void installerSuccess(); aheinecke@365: void installCerts(); rrenkert@640: void toggleInManual(bool state, const Certificate &cert); rrenkert@640: void removeFromManual(bool state, const Certificate &cert); aheinecke@551: rrenkert@584: void togglePages(int button); rrenkert@584: void toggleUpdatesNew(); rrenkert@584: void toggleUpdatesRemove(); rrenkert@584: void toggleUpdatesManual(); rrenkert@628: void listChanged(int selected); rrenkert@584: andre@609: /** @brief check for running software that needs to close before installing andre@609: * andre@609: * This function calls installCerts if no software is running otherwise andre@609: * it informs the user about the software that still needs to be closed. andre@609: */ andre@609: void checkAndInstallCerts(); andre@609: aheinecke@551: /** @brief get the last modified date on the download server for aheinecke@551: * the current version. aheinecke@551: * aheinecke@551: * After the initial installation this function can be used to aheinecke@551: * determine the DateTime that corresponds to the currently installed aheinecke@551: * version on the download server. aheinecke@551: * aheinecke@551: * Calls setLastModifiedSWDate on success. Otherwise downloaderError aheinecke@551: * is triggered. */ aheinecke@551: void getLastModForCurrentVersion(); aheinecke@551: aheinecke@551: /** @brief set the last modified software date/time aheinecke@551: * aheinecke@551: * The last modifiedSWDate is the corresponding last modified aheinecke@551: * timestamp from the download server vor the currently installed version. aheinecke@551: */ aheinecke@551: void setLastModifiedSWDate(const QDateTime &date); rrenkert@486: andre@372: /** @brief saves the currently unselected certificates andre@372: * andre@372: * This creates / updates a qsettings section that andre@372: * [unselected] that contains the certificates that andre@372: * were unselected previously. andre@372: * andre@372: * Unselected are certificates that are unchecked andre@372: * in the certListWidget andre@372: * andre@372: * Returns false on error. andre@372: */ rrenkert@640: bool saveUnselectedCertificates(QStringList unselected); andre@372: andre@372: /** @brief loads previously unselected certificates from settings andre@372: * andre@372: * The certificates are strored in the list mPreviouslyUnselected. andre@372: * andre@372: * On error mPreviouslyUnselected is empty after this call. andre@372: */ andre@372: void loadUnselectedCertificates(); andre@372: aheinecke@559: protected slots: aheinecke@559: /** @brief cleanup and close the main window aheinecke@559: * aheinecke@559: * Perform a clean exit (saving state etc.) and close aheinecke@559: * the application */ aheinecke@563: virtual void closeApp(); rrenkert@447: aheinecke@559: /* @brief Execute the file fileName to install the softwareupdate. aheinecke@559: * aheinecke@559: * Once the installer process is started this function terminates aheinecke@559: * the application. */ aheinecke@559: void installNewSW(const QString& fileName, const QDateTime& modDate); aheinecke@559: aheinecke@0: private: aheinecke@587: /** @brief check the integrity of available certificate lists. aheinecke@71: * aheinecke@594: * Note: Do not use this as a local trust check as this only works on aheinecke@71: * FileNames where the underlying files can change. This aheinecke@71: * is just meant to check if the downloaded data was somehow andre@389: * removed or corrupted. It also initializes mListToInstall andre@389: * and mInstalledList. aheinecke@71: */ aheinecke@587: void verifyListData(); aheinecke@587: aheinecke@587: /** @brief check the integrity of available software updates. aheinecke@587: * aheinecke@594: * Note: Do not use this as a local trust check as this only works on aheinecke@587: * FileNames where the underlying files can change. This aheinecke@587: * is just meant to check if the downloaded data was somehow aheinecke@587: * removed or corrupted. aheinecke@587: */ aheinecke@587: void verifySWData(); aheinecke@587: aheinecke@0: void createTrayIcon(); aheinecke@0: void createActions(); rrenkert@187: void createContent(); rrenkert@189: void loadCertificateList(); aheinecke@2: aheinecke@365: /* Are we running in tray mode ?*/ aheinecke@365: const bool mTrayMode; aheinecke@365: /* The message currently shown at intervals */ aheinecke@0: QString mCurMessage; aheinecke@16: QString mInstalledSWVersion; aheinecke@16: QString mInstalledListVersion; aheinecke@16: aheinecke@17: QSettings mSettings; aheinecke@0: aheinecke@0: QSystemTrayIcon *mTrayIcon; aheinecke@19: QTimer *mMessageTimer; aheinecke@0: QMenu *mTrayMenu; aheinecke@0: QAction *mCheckUpdates; aheinecke@2: QAction *mQuitAction; aheinecke@16: CurrentState mCurState; rrenkert@155: QMenuBar *mMenuBar; aheinecke@71: andre@372: /* The current list that should be installed */ aheinecke@71: CertificateList mListToInstall; andre@389: /* The last list that we installed */ andre@389: CertificateList mInstalledList; andre@372: /* Previously made "unselect" choices in the form of andre@372: * base64lines with I:/R: prefix */ andre@372: QStringList mPreviouslyUnselected; rrenkert@189: rrenkert@456: QLabel *mCurrentListDate; rrenkert@456: QLabel *mNewListDate; rrenkert@456: rrenkert@584: QButtonGroup *mButtonGroup; rrenkert@584: QScrollArea *mUpdatesPanel; rrenkert@584: QWidget *mUpdatesWidget; rrenkert@584: QScrollArea *mInstallPanel; rrenkert@584: QScrollArea *mRemovePanel; rrenkert@584: QScrollArea *mInfoPanel; rrenkert@584: rrenkert@628: QLabel *mUpdatesHeader; rrenkert@628: QLabel *mLastCertUpdate; rrenkert@628: QLabel *mLastSWupdate; rrenkert@628: QLabel *mUpdatesNewCertificates; rrenkert@628: QLabel *mUpdatesRemoveCertificates; rrenkert@628: QLabel *mUpdatesManualCertificates; rrenkert@628: rrenkert@584: CertificateListWidget *mUpdatesNew; rrenkert@584: CertificateListWidget *mUpdatesRemove; rrenkert@584: CertificateListWidget *mUpdatesManual; rrenkert@584: CertificateListWidget *mInstallList; rrenkert@628: CertificateListWidget *mRemoveList; rrenkert@652: rrenkert@652: QPushButton *mUpdatesDetailsNew; rrenkert@652: QPushButton *mUpdatesDetailsRemove; rrenkert@652: QPushButton *mUpdatesDetailsManual; aheinecke@0: }; aheinecke@0: aheinecke@0: #endif // MAINWINDOW_H