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: */ rrenkert@361: #ifndef CREATEINSTALLERDIALOG_H rrenkert@361: #define CREATEINSTALLERDIALOG_H rrenkert@361: rrenkert@361: #include rrenkert@361: #include rrenkert@361: #include aheinecke@516: #include aheinecke@516: #include aheinecke@571: #include rrenkert@361: /** rrenkert@361: * @file createinstallerdialog.h andre@1255: * @brief The dialog to select the input and create an installer. rrenkert@361: */ rrenkert@361: rrenkert@361: class QListWidget; aheinecke@571: class QTemporaryDir; rrenkert@361: andre@1255: /** @brief The dialog to select the input and create an installer. */ rrenkert@361: class CreateInstallerDialog : public QDialog rrenkert@361: { rrenkert@361: Q_OBJECT rrenkert@361: public: aheinecke@526: /** @brief Create a dialog showing settings for the create installer rrenkert@361: * process rrenkert@361: * */ rrenkert@361: CreateInstallerDialog(QMainWindow *parent); rrenkert@361: rrenkert@361: private: rrenkert@361: void setupGUI(); rrenkert@361: rrenkert@361: QLineEdit *mCertFile; aheinecke@515: QLineEdit *mBinaryFolder; rrenkert@361: QLineEdit *mSaveFile; rrenkert@361: aheinecke@516: QProcess mNSISProc; aheinecke@516: QProgressDialog mProgress; aheinecke@571: QString mInstallerPath; aheinecke@571: QTemporaryDir *mCurrentWorkingDir; aheinecke@516: aheinecke@515: /** @brief show an error message with QMessageBox aheinecke@515: * aheinecke@515: * @param [in] msg The message to show aheinecke@515: */ aheinecke@515: void showErrorMessage(const QString &msg); aheinecke@515: rrenkert@361: private slots: rrenkert@361: void openCertificateSelect(); aheinecke@515: void openFolderSelect(); rrenkert@361: void openSaveLocation(); aheinecke@571: aheinecke@571: /**@brief entry point for installer creation aheinecke@571: * aheinecke@571: * check the selected parameters (certificate / folder etc.) and aheinecke@571: * create the nsis installer. This also creates the signatures. */ rrenkert@361: void createInstaller(); aheinecke@516: aheinecke@571: /**@brief Create tempoary dir with signed binaries from sourcedir aheinecke@571: * aheinecke@571: * Copies all files from the sourceDir to a temporary directory aheinecke@571: * and signs all .exe files in that directory. aheinecke@571: * aheinecke@571: * The caller needs to delete the temporary directory. If an error aheinecke@571: * occurs NULL is returned. aheinecke@571: * aheinecke@571: * @param[in] sourceDir the directory with the binaries to sign aheinecke@571: * @returns a pointer to a temporary dir containing the signed binaries aheinecke@571: * or NULL. aheinecke@571: */ aheinecke@571: QTemporaryDir *codesignBinaries(const QDir& sourceDir); aheinecke@571: aheinecke@571: /**@brief Sign a file with the codesigning certificate from mCertFile aheinecke@571: * aheinecke@571: * Calls osslsigncode to sign the file pointed to in filePath. aheinecke@571: * The signing operation is logged. aheinecke@571: * aheinecke@571: * Sign information (hash algo / publisher / url) can be set at aheinecke@571: * build time or in the settings with the variables: aheinecke@571: * aheinecke@571: * sign_hash # the hash algorithm to use. Values are the same as in singtool aheinecke@571: * sign_publisher # the publisher information aheinecke@571: * sign_url # the product url to use in the signature aheinecke@571: * aheinecke@571: * @param[in] filePath the absolute path to the file. aheinecke@571: * @returns true on success, false on error aheinecke@571: */ aheinecke@571: bool signFile(QString filePath); aheinecke@571: andre@868: /* Slots for the creator process */ andre@868: void processError(QProcess::ProcessError error); andre@868: void processFinished(int exitCode, QProcess::ExitStatus exitStatus); andre@868: andre@868: public slots: andre@761: /**@brief Append a base64 encoded sha256 RSA signature to a file. andre@761: * emanuel@1053: * The format of the added signature line will be:
emanuel@1053: * S:\\\r\\n
andre@761: * For the signature the key in mCertFile is used. andre@761: * andre@761: * @param[in] input The absolute path of the file to sign andre@761: * @param[out] output The absolute path of the file to write andre@761: * andre@761: * @returns true on success, false on failure andre@761: */ andre@761: bool appendTextSignatureToFile(const QString& input, const QString& output); rrenkert@361: }; rrenkert@361: aheinecke@526: /** @brief The dialog shown after the installer was created. */ aheinecke@526: class FinishedDialog : public QDialog aheinecke@526: { aheinecke@526: Q_OBJECT aheinecke@526: aheinecke@526: public: aheinecke@526: /** @brief constructor for the dialog aheinecke@526: * aheinecke@526: * @param [in] parent the parent window aheinecke@526: * @param [in] msg the message to show aheinecke@526: * @param [in] details verbose information aheinecke@526: * @param [in] isErr if the dialog should be shown as an error*/ aheinecke@526: FinishedDialog(QDialog *parent, aheinecke@526: QString msg, aheinecke@526: QString details, aheinecke@526: bool isErr); aheinecke@526: aheinecke@526: }; aheinecke@526: aheinecke@526: rrenkert@361: #endif // CREATEINSTALLERDIALOG_H