Mercurial > trustbridge
annotate ui/listupdatedialog.cpp @ 96:37580703a870
Remove verbose debug output
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 21 Mar 2014 10:42:02 +0000 |
parents | e52df5870c4f |
children | 6090e673c707 |
rev | line source |
---|---|
71
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #include "listupdatedialog.h" |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 #include <QDebug> |
85
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
3 #include <QProcess> |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
4 #include <QPushButton> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
5 #include <QGroupBox> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
6 #include <QHBoxLayout> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
7 #include <QListWidget> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
8 #include <QVBoxLayout> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
9 #include "certificate.h" |
71
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 ListUpdateDialog::ListUpdateDialog(QDialog *parent, |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 const CertificateList &listToInstall) : |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 QDialog(parent), |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
14 mCertificateList(listToInstall) |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 { |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 qDebug() << "I am a happy list update dialog"; |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 setupGUI(); |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 } |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 void ListUpdateDialog::setupGUI() |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 { |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
22 /* Top level layout / widgets */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
23 QVBoxLayout *topLayout = new QVBoxLayout; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
24 QHBoxLayout *listLayout = new QHBoxLayout; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
25 QPushButton *executeUpdate = new QPushButton(tr("Update Stores")); |
85
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
26 connect(executeUpdate, &QPushButton::clicked, |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
27 this, &ListUpdateDialog::executeUpdate); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
28 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
29 /* The remove groups */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
30 QVBoxLayout *removeGroupLayout = new QVBoxLayout; |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
31 mRemoveListWidget = new QListWidget; |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
32 removeGroupLayout->addWidget(mRemoveListWidget); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
33 QGroupBox *removeGroup = new QGroupBox(tr("Select certificates to be removed")); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
34 removeGroup->setLayout(removeGroupLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
35 |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
36 foreach (const Certificate& cert, mCertificateList.getRemoveCertificates()) { |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
37 if (!cert.isValid()) { |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
38 qWarning() << "Invalid certificate in list"; |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
39 continue; |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
40 } |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
41 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
42 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
43 item->setCheckState(Qt::Checked); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
44 mRemoveListWidget->addItem(item); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
45 } |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
46 |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
47 /* The install group */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
48 QVBoxLayout *installGroupLayout = new QVBoxLayout; |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
49 mInstallListWidget = new QListWidget; |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
50 QGroupBox *installGroup = new QGroupBox(tr("Select certificates to install")); |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
51 installGroupLayout->addWidget(mInstallListWidget); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
52 installGroup->setLayout(installGroupLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
53 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
54 foreach (const Certificate& cert, mCertificateList.getInstallCertificates()) { |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
55 if (!cert.isValid()) { |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
56 qWarning() << "Invalid certificate in list"; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
57 continue; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
58 } |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
59 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
60 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); |
85
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
61 item->setData(Qt::ToolTipRole, cert.details()); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
62 item->setData(Qt::UserRole, cert.base64Line()); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
63 item->setCheckState(Qt::Checked); |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
64 mInstallListWidget->addItem(item); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
65 } |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
66 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
67 /* Add groups to layout */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
68 listLayout->addWidget(installGroup); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
69 listLayout->addWidget(removeGroup); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
70 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
71 /* Fill top level layout */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
72 topLayout->addLayout(listLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
73 topLayout->addWidget(executeUpdate); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
74 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
75 setLayout(topLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
76 |
71
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
77 return; |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
78 } |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
79 |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
80 void ListUpdateDialog::executeUpdate() { |
85
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
81 /* TODO move this in another dialog and call it async*/ |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
82 QProcess installerProcess; |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
83 |
85
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
84 installerProcess.setProgram("cinst"); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
85 installerProcess.start(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
86 installerProcess.waitForStarted(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
87 installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n"); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
88 installerProcess.write(mCertificateList.rawData().toLatin1()); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
89 installerProcess.write("-----END CERTIFICATE LIST-----\r\n"); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
90 |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
91 QList<QListWidgetItem *> selectedItems = mInstallListWidget->selectedItems(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
92 selectedItems << mRemoveListWidget->selectedItems(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
93 |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
94 foreach (const QListWidgetItem * item, selectedItems) { |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
95 installerProcess.write(item->data(Qt::UserRole).toString().toLatin1()); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
96 installerProcess.write("\r\n"); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
97 } |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
98 |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
99 installerProcess.closeWriteChannel(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
100 installerProcess.waitForFinished(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
101 qDebug() << "cinst output: " << installerProcess.readAllStandardOutput(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
102 qDebug() << " Done " << " exitCode: " << installerProcess.exitCode(); |
e52df5870c4f
Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
103 qDebug() << " Done " << " exitStatus: " << installerProcess.exitStatus(); |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
104 } |