annotate ui/listupdatedialog.cpp @ 298:56507c3d5f1e

Adapt remaining cinstprocesstest to new arg pattern
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 02 Apr 2014 16:13:37 +0000
parents 06089ba2614a
children
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>
257
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
13 #include <QMessageBox>
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
14
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
15
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
16 #include "certificate.h"
257
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
17 #include "installwrapper.h"
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18
153
252ffe6e27fd Changed type of MainWindow from QDialog to QMainWindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 129
diff changeset
19 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
20 const CertificateList &listToInstall) :
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 QDialog(parent),
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 mCertificateList(listToInstall)
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 setupGUI();
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 }
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 void ListUpdateDialog::setupGUI()
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 {
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
29 /* Top level layout / widgets */
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
30 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
31 QHBoxLayout *headerLayout = new QHBoxLayout;
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
32 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
33 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
34
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 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
45 QPushButton *executeUpdate = new QPushButton(tr("Update Stores"));
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
46 connect(executeUpdate, &QPushButton::clicked,
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
47 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
48 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
49 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
50 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
51 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
52 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
53 bottomLayout->addWidget(later);
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
54
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
55 /* 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
66 foreach (const Certificate& cert, mCertificateList.getCertificates()) {
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
67 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
68 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
69 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
70 }
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 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
72 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
73 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
74 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
75 item->setCheckState(Qt::Checked);
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
76 QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png") :
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
77 new QIcon(":/img/list-remove.png");
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
78 item->setIcon(*certIcon);
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
79
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
80 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
81 }
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
82
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
83 /* 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
84 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
85 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
86 topLayout->addLayout(bottomLayout);
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
87
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
88 setLayout(topLayout);
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
89
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
90 return;
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
91 }
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
92
257
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
93 void ListUpdateDialog::installerError(const QString& errMsg) {
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
94 QMessageBox::warning(this, tr("Installation Error"), errMsg);
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
95 }
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
96
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
97 void ListUpdateDialog::executeUpdate() {
257
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
98
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
99 QStringList instructions;
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
100
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
101 for (int i = 0; i < mCertListWidget->count(); i++) {
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
102 QListWidgetItem *item = mCertListWidget->item(i);
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
103 if (item->checkState() == Qt::Checked) {
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
104 instructions << item->data(Qt::UserRole).toString();
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
105 }
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
106
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
107 /* TODO: Check if it was an install instruction for an old certificate
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
108 * (already installed) and remove it in case it is unchecked. */
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
109 }
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
110
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
111 InstallWrapper *instWrap = new InstallWrapper(this,
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
112 mCertificateList.fileName(),
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
113 instructions);
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
114 connect(instWrap, SIGNAL(finished()), instWrap, SLOT(deleteLater()));
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
115 connect(instWrap, SIGNAL(error(const QString &)),
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
116 this, SLOT(installerError(const QString &)));
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
117 instWrap->start();
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
118
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
119 #if 0
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
120 /* 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
121 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
122 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
123 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
124 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
125 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
126 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
127 }
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
128 QString instPath = myDir.absoluteFilePath(instProcName);
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
129
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
130 installerProcess.setProgram(instPath);
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
131 installerProcess.start();
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
132 installerProcess.waitForStarted();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
133 if (installerProcess.state() == QProcess::NotRunning) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
134 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
135 /* 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
136 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
137 }
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
138
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
139 installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
140 installerProcess.write(mCertificateList.rawData().toLatin1());
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
141 installerProcess.write("-----END CERTIFICATE LIST-----\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
142
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
143 /* 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
144 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
145 QListWidgetItem *item = mCertListWidget->item(i);
221
431b058e903d Fix typo that happend in rebase conflict resolution
Andre Heinecke <aheinecke@intevation.de>
parents: 214
diff changeset
146 if (item->checkState() != 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
147 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
148 continue;
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
149 }
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
150 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
151 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
152 }
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
153
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
154 /* 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
155 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
156 QListWidgetItem *item = mCertListWidget->item(i);
214
aab742690bee Fix check for selected items and wait for bytes written.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 213
diff changeset
157 if (!item->checkState() != 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
158 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
159 continue;
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
160 }
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
161 installerProcess.write(item->data(Qt::UserRole).toString().toLatin1());
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
162 installerProcess.write("\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
163 }
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
164
214
aab742690bee Fix check for selected items and wait for bytes written.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 213
diff changeset
165 installerProcess.waitForBytesWritten();
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
166 installerProcess.closeWriteChannel();
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
167 installerProcess.waitForFinished();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
168
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
169 if (installerProcess.exitStatus() == QProcess::CrashExit) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
170 /* Woops */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
171 qWarning() << "Installer process crashed";
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
172 } 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
173 /* 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
174 * qt changed.. */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
175 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
176 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
177 }
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
178
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
179 if (installerProcess.exitCode() == 0) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
180 qDebug() << "Success!";
129
39b7930fbca9 Print debug output also on success
Andre Heinecke <aheinecke@intevation.de>
parents: 128
diff changeset
181 qDebug() << "output: " << installerProcess.readAllStandardOutput();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
182 } else {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
183 /* 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
184 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
185 qDebug() << "output: " << installerProcess.readAllStandardOutput();
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
186 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
187 }
257
06089ba2614a Use Installwrapper to call certificate installation process
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
188 #endif
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
189 }
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
190
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
191 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
192 {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
193 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
194 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
195 }

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