Mercurial > trustbridge
annotate ui/installwrapper.h @ 285:f23e0ccd5d14
Fix call to windows process.
This now uses the correct parameters, emits the signals
correctly as errors and waits for the process to finish instead
of relying on NOASYNC which did not work for runas and also
made it impossible to get the return code
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 02 Apr 2014 13:45:57 +0000 |
parents | 84ae353688e0 |
children | dc4efb0a70cb |
rev | line source |
---|---|
256
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #ifndef UI_INSTALLWRAPPER_H |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 #define UI_INSTALLWRAPPER_H |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 #include <QString> |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 #include <QStringList> |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 #include <QThread> |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 #include "certificate.h" |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 /** @file installwrapper.h |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 * @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
|
11 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 /** @brief wrapper around installer process |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
14 * This wrapper is mostly needed because QProcess executes |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 * a process on Windows directly with CreateProcess and |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 * 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
|
17 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 * On Windows this class uses ShellExecuteExW to control |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 * 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
|
20 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 * 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
|
22 * asynchronusly. */ |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
23 class InstallWrapper : public QThread |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
24 { |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
25 Q_OBJECT |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
26 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
27 public: |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 /** |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 * @brief Construct an installwrapper for a certificateList |
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 * The install wrapper will start the cinst process to execute |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 * the specified instructions with the provided certificatelist. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
33 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 * The cinst executable is expected to be in the same directory |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 * as the current application. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 * |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 * @param[in] parent the parent object. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 * @param[in] listFileName the absolute path to the certificatelist. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 * @param[in] instructions a list of instructions to execute. |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 */ |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 InstallWrapper(QObject* parent, const QString& path, |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 const QStringList& instructions); |
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 private: |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 const QString mCertListFile; |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 const QStringList mInstructions; |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 protected: |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 void run(); |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
50 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
51 Q_SIGNALS: |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
52 /** |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
53 * @brief An error happened |
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[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
|
56 */ |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
57 void error(const QString &message); |
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 |
84ae353688e0
Add installwrapper class to handle process communication
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
60 #endif // UI_INSTALLWRAPPER_H |