view ui/createinstallerdialog.h @ 1088:508c96e72f62

(issue124) Switch server URL and remove some RELEASE_BUILD options As the test server speaks ECDSA we do not need so much #ifndef RELEASE_BUILD options anymore.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 12 Sep 2014 15:38:42 +0200
parents 78798d3af8f0
children 2a1aa9df8f11
line wrap: on
line source
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=2)
 * and comes with ABSOLUTELY NO WARRANTY!
 * See LICENSE.txt for details.
 */
#ifndef CREATEINSTALLERDIALOG_H
#define CREATEINSTALLERDIALOG_H

#include <QDialog>
#include <QMainWindow>
#include <QLineEdit>
#include <QProcess>
#include <QProgressDialog>
#include <QDir>
/**
 * @file createinstallerdialog.h
 * @brief The dialog to show settings and create an installer.
 */

class QListWidget;
class QTemporaryDir;

class CreateInstallerDialog : public QDialog
{
    Q_OBJECT
public:
    /** @brief Create a dialog showing settings for the create installer
     * process
     * */
    CreateInstallerDialog(QMainWindow *parent);

private:
    void setupGUI();

    QLineEdit *mCertFile;
    QLineEdit *mBinaryFolder;
    QLineEdit *mSaveFile;

    QProcess mNSISProc;
    QProgressDialog mProgress;
    QString mInstallerPath;
    QTemporaryDir *mCurrentWorkingDir;

    /** @brief show an error message with QMessageBox
     *
     * @param [in] msg The message to show
     */
    void showErrorMessage(const QString &msg);

private slots:
    void openCertificateSelect();
    void openFolderSelect();
    void openSaveLocation();

    /**@brief entry point for installer creation
     *
     * check the selected parameters (certificate / folder etc.) and
     * create the nsis installer. This also creates the signatures. */
    void createInstaller();

    /**@brief Create tempoary dir with signed binaries from sourcedir
     *
     * Copies all files from the sourceDir to a temporary directory
     * and signs all .exe files in that directory.
     *
     * The caller needs to delete the temporary directory. If an error
     * occurs NULL is returned.
     *
     * @param[in] sourceDir the directory with the binaries to sign
     * @returns a pointer to a temporary dir containing the signed binaries
     * or NULL.
     */
    QTemporaryDir *codesignBinaries(const QDir& sourceDir);

    /**@brief Sign a file with the codesigning certificate from mCertFile
     *
     * Calls osslsigncode to sign the file pointed to in filePath.
     * The signing operation is logged.
     *
     * Sign information (hash algo / publisher / url) can be set at
     * build time or in the settings with the variables:
     *
     * sign_hash # the hash algorithm to use. Values are the same as in singtool
     * sign_publisher # the publisher information
     * sign_url # the product url to use in the signature
     *
     * @param[in] filePath the absolute path to the file.
     * @returns true on success, false on error
     */
    bool signFile(QString filePath);

    /* Slots for the creator process */
    void processError(QProcess::ProcessError error);
    void processFinished(int exitCode, QProcess::ExitStatus exitStatus);

public slots:
    /**@brief Append a base64 encoded sha256 RSA signature to a file.
     *
     * The format of the added signature line will be:<BR>
     * S:\<signature\>\\r\\n<BR>
     * For the signature the key in mCertFile is used.
     *
     * @param[in] input The absolute path of the file to sign
     * @param[out] output The absolute path of the file to write
     *
     * @returns true on success, false on failure
     */
    bool appendTextSignatureToFile(const QString& input, const QString& output);
};

/** @brief The dialog shown after the installer was created. */
class FinishedDialog : public QDialog
{
    Q_OBJECT

    public:
        /** @brief constructor for the dialog
         *
         * @param [in] parent the parent window
         * @param [in] msg the message to show
         * @param [in] details verbose information
         * @param [in] isErr if the dialog should be shown as an error*/
        FinishedDialog(QDialog *parent,
                       QString msg,
                       QString details,
                       bool isErr);

};


#endif // CREATEINSTALLERDIALOG_H

http://wald.intevation.org/projects/trustbridge/