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 aheinecke@16: aheinecke@16: #include "downloader.h" aheinecke@71: #include "certificatelist.h" aheinecke@0: class QMenu; aheinecke@0: class QAction; aheinecke@19: class QTimer; aheinecke@0: rrenkert@432: Q_DECLARE_METATYPE(Certificate); 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, 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); aheinecke@16: void checkUpdates(); 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(); rrenkert@155: void showSettings(); rrenkert@212: void showStatus(); rrenkert@155: void showHelp(); rrenkert@155: void showAbout(); rrenkert@189: void showDetails(QListWidgetItem*); rrenkert@271: void resizeButtons(); aheinecke@365: void installerError(const QString& errMsg); andre@389: void installerSuccess(); aheinecke@365: void installCerts(); aheinecke@0: 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: */ andre@372: bool saveUnselectedCertificates(); 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@0: private: aheinecke@71: /** @brief check the integrity of available files. aheinecke@71: * aheinecke@71: * Do not use this as a 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@16: void verifyAvailableData(); aheinecke@0: void createTrayIcon(); aheinecke@0: void createActions(); rrenkert@155: void createMenuBar(); rrenkert@187: void createContent(); rrenkert@189: void loadCertificateList(); aheinecke@2: rrenkert@445: /** @brief Create a separator item for the certificate list. rrenkert@445: * rrenkert@445: * The item uses a SeparatorItemDelegate for layout and styling at the given rrenkert@445: * index. rrenkert@445: * rrenkert@445: * @param[in] text The text for the item. rrenkert@445: * @param[in] index The index of the item. rrenkert@445: * rrenkert@445: * @return The new separator item. rrenkert@445: */ rrenkert@445: QListWidgetItem* createSeparator(const QString &text, int index); rrenkert@445: rrenkert@445: /** @brief Create a certificate list item for the list. rrenkert@445: * rrenkert@445: * The item uses a CertificateItemDelegate for layout and styling. rrenkert@445: * rrenkert@445: * @param[in] text The certificate to display. rrenkert@445: * @param[in] status The certificate status. rrenkert@445: * @param[in] index The index of the item. rrenkert@445: * rrenkert@445: * @return The new separator item. rrenkert@445: */ rrenkert@445: QListWidgetItem* createListItem(const Certificate &certificate, rrenkert@445: Certificate::Status status, int index); rrenkert@445: 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: aheinecke@365: QListWidget *mCertListWidget; rrenkert@432: rrenkert@432: QLabel *mSubjectCN; rrenkert@432: QLabel *mSubjectOU; rrenkert@432: QLabel *mIssuerCN; rrenkert@432: QLabel *mIssuerOU; rrenkert@432: QLabel *mValidFrom; rrenkert@432: QLabel *mValidTo; rrenkert@432: QLabel *mFingerprint; rrenkert@432: rrenkert@432: QCheckBox *mAutoUpdateOption; rrenkert@432: QCheckBox *mAutoStartOption; rrenkert@432: rrenkert@271: QPushButton *installButton; rrenkert@271: QPushButton *quitButton; aheinecke@0: }; aheinecke@0: aheinecke@0: #endif // MAINWINDOW_H