annotate ui/listupdatedialog.cpp @ 213:3ebebd055d3a

Refactored the list update dialog. Now it looks a bit more like the mainwindow.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 27 Mar 2014 09:08:44 +0100
parents 252ffe6e27fd
children aab742690bee
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"
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
2 #include <QCoreApplication>
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 #include <QDebug>
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
4 #include <QDir>
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
5 #include <QFileInfo>
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
6 #include <QProcess>
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
7 #include <QPushButton>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
8 #include <QGroupBox>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
9 #include <QHBoxLayout>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
10 #include <QListWidget>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
11 #include <QVBoxLayout>
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
12 #include <QLabel>
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
13 #include "certificate.h"
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14
153
252ffe6e27fd Changed type of MainWindow from QDialog to QMainWindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 129
diff changeset
15 ListUpdateDialog::ListUpdateDialog(QMainWindow *parent,
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 const CertificateList &listToInstall) :
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 QDialog(parent),
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 mCertificateList(listToInstall)
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 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
21 setupGUI();
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 }
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 void ListUpdateDialog::setupGUI()
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 {
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
26 /* Top level layout / widgets */
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
27 QVBoxLayout *topLayout = new QVBoxLayout;
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
28 QHBoxLayout *headerLayout = new QHBoxLayout;
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
29 QHBoxLayout *listLayout = new QHBoxLayout;
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
30 QHBoxLayout *bottomLayout = new QHBoxLayout;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
31
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
32 QImage *logoImage = new QImage(":/img/logo-small.png");
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
33 QLabel *logo = new QLabel;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
34 logo->setBackgroundRole(QPalette::Base);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
35 logo->setPixmap(QPixmap::fromImage(*logoImage));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
36 QLabel *title = new QLabel("<h3>" + tr("Update Certificate") + "</h3>");
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
37 headerLayout->addWidget(logo);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
38 headerLayout->addWidget(title);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
39 headerLayout->setStretch(0, 0);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
40 headerLayout->setStretch(1, 10);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
41
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
42 QPushButton *executeUpdate = new QPushButton(tr("Update Stores"));
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
43 connect(executeUpdate, &QPushButton::clicked,
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
44 this, &ListUpdateDialog::executeUpdate);
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
45 QPushButton *install = new QPushButton(tr("Install selected"));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
46 QPushButton *later = new QPushButton(tr("Remind me later"));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
47 bottomLayout->insertStretch(0, 10);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
48 bottomLayout->addWidget(executeUpdate);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
49 bottomLayout->addWidget(install);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
50 bottomLayout->addWidget(later);
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
51
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
52 /* The certificate groups */
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
53 mCertListWidget = new QListWidget;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
54 connect(mCertListWidget, SIGNAL(itemClicked(QListWidgetItem*)),
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
55 this, SLOT(showDetails(QListWidgetItem*)));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
56 mDetailWidget = new QTextEdit;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
57 mDetailWidget->setReadOnly(true);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
58 listLayout->addWidget(mCertListWidget);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
59 listLayout->addWidget(mDetailWidget);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
60 QGroupBox *certGroup = new QGroupBox(tr("Select certificates"));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
61 certGroup->setLayout(listLayout);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
62
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
63 foreach (const Certificate& cert, mCertificateList.getInstallCertificates()) {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
64 if (!cert.isValid()) {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
65 qWarning() << "Invalid certificate in list";
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
66 continue;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
67 }
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
68 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
69 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
70 item->setData(Qt::ToolTipRole, cert.details());
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
71 item->setData(Qt::UserRole, cert.base64Line());
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
72 item->setCheckState(Qt::Checked);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
73 QIcon *certIcon = new QIcon(":/img/list-add.png");
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
74 item->setIcon(*certIcon);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
75 mCertListWidget->addItem(item);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
76 }
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
77
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
78 foreach (const Certificate& cert, mCertificateList.getRemoveCertificates()) {
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
79 if (!cert.isValid()) {
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
80 qWarning() << "Invalid certificate in list";
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
81 continue;
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
82 }
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
83 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
84 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
85 item->setData(Qt::ToolTipRole, cert.details());
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
86 item->setData(Qt::UserRole, cert.base64Line());
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
87 item->setCheckState(Qt::Checked);
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
88 QIcon *certIcon = new QIcon(":/img/list-remove.png");
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
89 item->setIcon(*certIcon);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
90 mCertListWidget->addItem(item);
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
91 }
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
92
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
93
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
94 /* Fill top level layout */
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
95 topLayout->addLayout(headerLayout);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
96 topLayout->addWidget(certGroup);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
97 topLayout->addLayout(bottomLayout);
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
98
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
99 setLayout(topLayout);
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
100
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
101 return;
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
102 }
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
103
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
104 void ListUpdateDialog::executeUpdate() {
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
105 /* 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
106 QProcess installerProcess;
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
107 QFileInfo fi(QCoreApplication::applicationFilePath());
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
108 QDir myDir = fi.absoluteDir();
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
109 QString instProcName = "cinst";
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
110 if (!fi.suffix().isEmpty()) {
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
111 instProcName += "." + fi.suffix();
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
112 }
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
113 QString instPath = myDir.absoluteFilePath(instProcName);
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
114
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
115 installerProcess.setProgram(instPath);
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
116 installerProcess.start();
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
117 installerProcess.waitForStarted();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
118 if (installerProcess.state() == QProcess::NotRunning) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
119 qWarning() << "Failed to start installer Process.";
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
120 /* TODO ERROR message for the user */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
121 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
122 }
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
123
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
124 installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
125 installerProcess.write(mCertificateList.rawData().toLatin1());
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
126 installerProcess.write("-----END CERTIFICATE LIST-----\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
127
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
128 /* Items to install */
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
129 for (int i = 0; i < mCertListWidget->count(); i++) {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
130 QListWidgetItem *item = mCertListWidget->item(i);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
131 if (!item->checkState() == Qt::Checked &&
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
132 item->data(Qt::UserRole).toString().startsWith("I:")) {
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
133 continue;
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
134 }
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
135 installerProcess.write(item->data(Qt::UserRole).toString().toLatin1());
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
136 installerProcess.write("\r\n");
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
137 }
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
138
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
139 /* Items to remove */
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
140 for (int i = 0; i < mCertListWidget->count(); i++) {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
141 QListWidgetItem *item = mCertListWidget->item(i);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
142 if (!item->checkState() == Qt::Checked &&
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
143 item->data(Qt::UserRole).toString().startsWith("R:")) {
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
144 continue;
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
145 }
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
146 installerProcess.write(item->data(Qt::UserRole).toString().toLatin1());
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
147 installerProcess.write("\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
148 }
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
149
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
150 installerProcess.closeWriteChannel();
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
151 installerProcess.waitForFinished();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
152
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
153 if (installerProcess.exitStatus() == QProcess::CrashExit) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
154 /* Woops */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
155 qWarning() << "Installer process crashed";
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
156 } else if (installerProcess.exitStatus() != QProcess::NormalExit) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
157 /* Can not Happen. there are only those two values but maybe
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
158 * qt changed.. */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
159 qWarning() << "Exit status neither normal nor crash.";
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
160 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
161 }
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
162
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
163 if (installerProcess.exitCode() == 0) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
164 qDebug() << "Success!";
129
39b7930fbca9 Print debug output also on success
Andre Heinecke <aheinecke@intevation.de>
parents: 128
diff changeset
165 qDebug() << "output: " << installerProcess.readAllStandardOutput();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
166 } else {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
167 /* TODO handle errors defined by errorcodes.h */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
168 qDebug() << "Installer Process returned: " << installerProcess.exitCode();
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
169 qDebug() << "output: " << installerProcess.readAllStandardOutput();
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
170 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
171 }
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
172 }
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
173
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
174 void ListUpdateDialog::showDetails(QListWidgetItem *item)
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
175 {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
176 QString details = item->data(Qt::ToolTipRole).toString();
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
177 mDetailWidget->setPlainText(details);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
178 }

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