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@256: #ifndef UI_INSTALLWRAPPER_H
aheinecke@256: #define UI_INSTALLWRAPPER_H
aheinecke@256: 
aheinecke@364: #include <QFileInfo>
aheinecke@256: #include <QString>
aheinecke@256: #include <QStringList>
aheinecke@364: #include <QTemporaryFile>
aheinecke@256: #include <QThread>
aheinecke@256: 
aheinecke@256: #include "certificate.h"
aheinecke@256: /** @file installwrapper.h
aheinecke@256:  * @brief Wrapper around the call to the updated process */
aheinecke@256: 
aheinecke@364: /** @brief Get the FileInfo for the installation process.
aheinecke@364:  *
aheinecke@364:  * This points to the file where the installation process is
aheinecke@364:  * supposed to be.
aheinecke@364:  *
aheinecke@364:  * @returns A FileInfo with the path of the installation process.*/
aheinecke@364: QFileInfo getCinstProcInfo();
aheinecke@364: 
aheinecke@256:  /** @brief wrapper around installer process
aheinecke@256:   *
aheinecke@256:   * This wrapper is mostly needed because QProcess executes
aheinecke@256:   * a process on Windows directly with CreateProcess and
aheinecke@256:   * thus can not be used to elevate the Process.
aheinecke@256:   *
aheinecke@256:   * On Windows this class uses ShellExecuteExW to control
aheinecke@256:   * the child process. On Linux systems QProcess is used.
aheinecke@256:   *
aheinecke@256:   * It subclasses QThread so the installation can be done
aheinecke@256:   * asynchronusly. */
aheinecke@256: class InstallWrapper : public QThread
aheinecke@256: {
aheinecke@256:     Q_OBJECT
aheinecke@256: 
aheinecke@256: public:
aheinecke@256:     /**
aheinecke@256:      * @brief Construct an installwrapper for a certificateList
aheinecke@256:      *
aheinecke@256:      * The install wrapper will start the cinst process to execute
aheinecke@256:      * the specified instructions with the provided certificatelist.
aheinecke@256:      *
aheinecke@256:      * The cinst executable is expected to be in the same directory
aheinecke@256:      * as the current application.
aheinecke@256:      *
aheinecke@256:      * @param[in] parent the parent object.
emanuel@1053:      * @param[in] path the absolute path to the certificatelist.
emanuel@1053:      * @param[in] instructions a list of R: / I: \<cert\> lines to execute.
aheinecke@256:      */
aheinecke@256:     InstallWrapper(QObject* parent, const QString& path,
aheinecke@256:                    const QStringList& instructions);
aheinecke@256: 
aheinecke@256: private:
andre@904:     /**@brief write the choices made into a temporary file
aheinecke@364:      *
aheinecke@364:      * @param[in] choicesFile the temporary file to write.
aheinecke@364:      *
aheinecke@364:      * @returns true on success. false on error.
aheinecke@364:      */
aheinecke@364:     bool writeChoices(QTemporaryFile* choicesFile) const;
aheinecke@364: 
aheinecke@256:     const QString mCertListFile;
aheinecke@364:     const QStringList mChoices;
aheinecke@256: 
aheinecke@256: protected:
aheinecke@256:     void run();
aheinecke@256: 
aheinecke@256: Q_SIGNALS:
aheinecke@256:     /**
aheinecke@256:      * @brief An error happened
aheinecke@256:      *
aheinecke@256:      * @param[out] message: A localized message to show. Can be empty.
aheinecke@256:      */
aheinecke@256:     void error(const QString &message);
andre@388: 
andre@388:     /**
andre@388:      * @brief The installation was successful
andre@388:      *
andre@388:      * This only means the installation was successful as far as we
andre@388:      * can tell as there is no backchannel from the installation processes.
andre@388:      */
andre@388:     void installationSuccessful();
aheinecke@256: };
aheinecke@256: 
aheinecke@256: #endif // UI_INSTALLWRAPPER_H