Mercurial > trustbridge
annotate ui/installwrapper.h @ 1203:b4185dd3810f
(issue68) Added license information in new README.
author | Emanuel Schuetze <emanuel@intevation.de> |
---|---|
date | Tue, 23 Sep 2014 14:51:53 +0200 |
parents | c8f698ca6355 |
children |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 #ifndef UI_INSTALLWRAPPER_H |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 #define UI_INSTALLWRAPPER_H |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 |
364 | 11 #include <QFileInfo> |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 #include <QString> |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 #include <QStringList> |
364 | 14 #include <QTemporaryFile> |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 #include <QThread> |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 #include "certificate.h" |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 /** @file installwrapper.h |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 * @brief Wrapper around the call to the updated process */ |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 |
364 | 21 /** @brief Get the FileInfo for the installation process. |
22 * | |
23 * This points to the file where the installation process is | |
24 * supposed to be. | |
25 * | |
26 * @returns A FileInfo with the path of the installation process.*/ | |
27 QFileInfo getCinstProcInfo(); | |
28 | |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 /** @brief wrapper around installer process |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
30 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 * This wrapper is mostly needed because QProcess executes |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 * a process on Windows directly with CreateProcess and |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
33 * thus can not be used to elevate the Process. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 * On Windows this class uses ShellExecuteExW to control |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 * the child process. On Linux systems QProcess is used. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 * It subclasses QThread so the installation can be done |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 * asynchronusly. */ |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 class InstallWrapper : public QThread |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 { |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 Q_OBJECT |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
44 public: |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 /** |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 * @brief Construct an installwrapper for a certificateList |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 * |
1176
c8f698ca6355
(issue128) Rename cinst to trustbridge-certificate-installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
48 * The install wrapper will start the certificate installer |
c8f698ca6355
(issue128) Rename cinst to trustbridge-certificate-installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
49 * process to execute the specified instructions with the |
c8f698ca6355
(issue128) Rename cinst to trustbridge-certificate-installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
50 * provided certificatelist. |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
51 * |
1176
c8f698ca6355
(issue128) Rename cinst to trustbridge-certificate-installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
52 * The trustbridge-certificate-installer executable is expected |
c8f698ca6355
(issue128) Rename cinst to trustbridge-certificate-installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
53 * to be in the same directory as the current application. |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
54 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
55 * @param[in] parent the parent object. |
1053
78798d3af8f0
Fixed doxygen build warnings.
Emanuel Schuetze <emanuel@intevation.de>
parents:
904
diff
changeset
|
56 * @param[in] path the absolute path to the certificatelist. |
78798d3af8f0
Fixed doxygen build warnings.
Emanuel Schuetze <emanuel@intevation.de>
parents:
904
diff
changeset
|
57 * @param[in] instructions a list of R: / I: \<cert\> lines to execute. |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
58 */ |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
59 InstallWrapper(QObject* parent, const QString& path, |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
60 const QStringList& instructions); |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
61 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
62 private: |
904
f89b41fa7048
Fix whitespace errors
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
63 /**@brief write the choices made into a temporary file |
364 | 64 * |
65 * @param[in] choicesFile the temporary file to write. | |
66 * | |
67 * @returns true on success. false on error. | |
68 */ | |
69 bool writeChoices(QTemporaryFile* choicesFile) const; | |
70 | |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
71 const QString mCertListFile; |
364 | 72 const QStringList mChoices; |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
73 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
74 protected: |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
75 void run(); |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
76 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
77 Q_SIGNALS: |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
78 /** |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
79 * @brief An error happened |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
80 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
81 * @param[out] message: A localized message to show. Can be empty. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
82 */ |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
83 void error(const QString &message); |
388
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
84 |
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
85 /** |
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
86 * @brief The installation was successful |
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
87 * |
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
88 * This only means the installation was successful as far as we |
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
89 * can tell as there is no backchannel from the installation processes. |
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
90 */ |
a507e5f1b999
Emit a signal if no errors happened during installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
364
diff
changeset
|
91 void installationSuccessful(); |
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
92 }; |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
93 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
94 #endif // UI_INSTALLWRAPPER_H |