annotate ui/administratorwindow.cpp @ 1371:23df332b2a4c

(issue179) Read install signature timestamp from config This also changes the way the sigDt is propgated to the MainWindow. It no longer uses the settings but hands it over as a parameter directly.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 24 Nov 2014 15:48:49 +0100
parents b6fb5d347023
children
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 401
diff changeset
7 */
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 #include "administratorwindow.h"
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 #include <QDebug>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 #include <QMessageBox>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 #include <QAction>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 #include <QMenu>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 #include <QApplication>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 #include <QHBoxLayout>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 #include <QVBoxLayout>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 #include <QGroupBox>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 #include <QSplitter>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 #include <QLabel>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 #include <QImage>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 #include <QCheckBox>
335
811eec4e1b99 Use a table view with the new certificate table model in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 333
diff changeset
22 #include <QHeaderView>
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
23 #include <QFileDialog>
394
7e0a188d6848 Load the last certificate list from data dir on startup.
Raimund Renkert <rrenkert@intevation.de>
parents: 376
diff changeset
24 #include <QStandardPaths>
398
9e6a2c2033ed Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents: 396
diff changeset
25 #include <QSortFilterProxyModel>
1001
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
26 #include <QDesktopServices>
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
27 #include <QFileInfo>
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
29 #include "certificatetabledelegate.h"
362
857ae1ffdd6f Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents: 358
diff changeset
30 #include "createinstallerdialog.h"
368
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
31 #include "createcertlistdialog.h"
566
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 565
diff changeset
32 #include "certificatediffdialog.h"
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
33 #include "aboutdialog.h"
1001
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
34 #include "util.h"
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
35
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
36 #define HELP_PATH "/doc/index.html"
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
37
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 AdministratorWindow::AdministratorWindow() {
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
39 setWindowTitle(tr("TrustBridge Administration"));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 createActions();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 createMenuBar();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 createContent();
1317
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
43 loadCurrentCertificates();
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
44 resize(1190, 500);
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
45 }
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
46
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
47 void AdministratorWindow::loadCurrentCertificates()
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
48 {
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
49 QString path = QStandardPaths::locate(
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
50 QStandardPaths::DataLocation, QString("current_certificates.txt"));
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
51 certificateModel->removeAll();
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
52 mCertList.readList(path.toLocal8Bit());
394
7e0a188d6848 Load the last certificate list from data dir on startup.
Raimund Renkert <rrenkert@intevation.de>
parents: 376
diff changeset
53 loadCertificateTable();
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 void AdministratorWindow::createActions()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 void AdministratorWindow::createMenuBar()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 menuBar = new QMenuBar(this);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 QMenu *menu = new QMenu(tr("Menu"), menuBar);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 menuBar->addMenu(menu);
415
b19290d6b148 Removed obsolete menu entries.
Raimund Renkert <rrenkert@intevation.de>
parents: 412
diff changeset
65 QAction *createInstaller = menu->addAction(tr("Create installer ..."));
b19290d6b148 Removed obsolete menu entries.
Raimund Renkert <rrenkert@intevation.de>
parents: 412
diff changeset
66 QAction *about = menu->addAction(tr("About TrustBridge"));
1001
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
67 QAction *help = menu->addAction(tr("Help"));
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
68 help->setIcon(QIcon(":/img/show-help_16.png"));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 menu->addSeparator();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 QAction *quit = menu->addAction(tr("Quit"));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller()));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
1001
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
73 connect(help, SIGNAL(triggered()), this, SLOT(showHelp()));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 setMenuBar(menuBar);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78 void AdministratorWindow::createContent()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 // Create a central widget containing the main layout.
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 QWidget *base = new QWidget;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 // Layouts and Container
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 QVBoxLayout *mainLayout = new QVBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 QVBoxLayout *certLayout = new QVBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 QHBoxLayout *headerLayout = new QHBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 QVBoxLayout *headerTextLayout = new QVBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 QHBoxLayout *bottomLayout = new QHBoxLayout;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 // The certificate list
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
91 QGroupBox *certBox = new QGroupBox(
426
d7cda835abd6 Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents: 415
diff changeset
92 tr("All managed root certificates of the certificate list: "));
335
811eec4e1b99 Use a table view with the new certificate table model in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 333
diff changeset
93 certificateView = new QTableView;
343
e3d6de930c90 Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 335
diff changeset
94 certificateModel = new CertificateTabelModel();
1316
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
95 mFilterModel = new QSortFilterProxyModel(this);
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
96 mFilterModel->setSourceModel(certificateModel);
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
97 CertificateTableDelegate *delegate = new CertificateTableDelegate(certificateView);
1316
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
98 certificateView->setModel(mFilterModel);
348
e6aa82466420 Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents: 344
diff changeset
99 certificateView->setItemDelegate(delegate);
426
d7cda835abd6 Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents: 415
diff changeset
100 certificateView->horizontalHeader()->setStretchLastSection(true);
395
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
101 certificateView->resizeColumnsToContents();
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
102 certificateView->setColumnWidth(0, 60);
343
e3d6de930c90 Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 335
diff changeset
103 certificateView->setSelectionBehavior(QAbstractItemView::SelectRows);
1323
c582b935c120 (issue166) Disable multiple selection for certificates.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1318
diff changeset
104 certificateView->setSelectionMode(QAbstractItemView::SingleSelection);
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
105 connect(certificateView, SIGNAL(clicked(const QModelIndex&)), this,
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
106 SLOT(clickedCertificate(const QModelIndex&)));
343
e3d6de930c90 Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 335
diff changeset
107 certificateView->verticalHeader()->setVisible(false);
398
9e6a2c2033ed Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents: 396
diff changeset
108 certificateView->setSortingEnabled(true);
335
811eec4e1b99 Use a table view with the new certificate table model in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 333
diff changeset
109 certLayout->addWidget(certificateView);
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 certBox->setLayout(certLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 // The header (icon, about text)
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 QImage *logoImage = new QImage(":/img/logo.png");
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 QLabel *logo = new QLabel;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115 logo->setBackgroundRole(QPalette::Base);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 logo->setPixmap(QPixmap::fromImage(*logoImage));
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
117 QLabel *title = new QLabel("<h2>" + tr("TrustBridge Administration") + "</h2>");
412
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
118 QLabel *subTitle = new QLabel(
340b8759d005 Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents: 404
diff changeset
119 tr("Management application of the BSI certificate installer"));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 headerTextLayout->addWidget(title);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 headerTextLayout->addWidget(subTitle);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 headerLayout->addWidget(logo);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 headerLayout->addLayout(headerTextLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
124 headerLayout->setStretch(0, 0);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
125 headerLayout->setStretch(1, 10);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
126
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
127 // The buttons.
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
128 bottomLayout->setAlignment(Qt::AlignBottom);
1274
f1f4059ec320 (admin) Updated strings.
Emanuel Schuetze <emanuel@intevation.de>
parents: 1199
diff changeset
129 saveButton = new QPushButton(QIcon(":/img/document-save.png"), " " + tr("Create list"));
368
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
130 connect(saveButton, SIGNAL(clicked()), this, SLOT(saveCertificateFile()));
1199
bd2cb6bdb1c5 (admin) Fixed translations and added whitespace between pushbutton icon and text.
Emanuel Schuetze <emanuel@intevation.de>
parents: 1001
diff changeset
131 loadButton = new QPushButton(QIcon(":/img/document-open.png"), " " + tr("Load list"));
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
132 connect(loadButton, SIGNAL(clicked()), this, SLOT(loadCertificateFile()));
1199
bd2cb6bdb1c5 (admin) Fixed translations and added whitespace between pushbutton icon and text.
Emanuel Schuetze <emanuel@intevation.de>
parents: 1001
diff changeset
133 addButton = new QPushButton(QIcon(":/img/document-new.png"), " " + tr("Add certificate"));
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
134 connect(addButton, SIGNAL(clicked()), this, SLOT(addCertificates()));
1199
bd2cb6bdb1c5 (admin) Fixed translations and added whitespace between pushbutton icon and text.
Emanuel Schuetze <emanuel@intevation.de>
parents: 1001
diff changeset
135 removeButton = new QPushButton(QIcon(":/img/document-close.png"), " " + tr("Remove certificate"));
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
136 removeButton->setEnabled(false);
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
137 connect(removeButton, SIGNAL(clicked()), this, SLOT(removeCertificates()));
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138 bottomLayout->addWidget(saveButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
139 bottomLayout->addWidget(loadButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
140 bottomLayout->addWidget(addButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
141 bottomLayout->addWidget(removeButton);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
142 bottomLayout->insertStretch(4, 10);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
143
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
144 mainLayout->addLayout(headerLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
145 mainLayout->addWidget(certBox);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
146 mainLayout->addLayout(bottomLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
147
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
148
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
149 // QMainWindow allready has a layout. All child layouts and widgets are
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
150 // managed in the central widget.
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
151 base->setLayout(mainLayout);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
152 setCentralWidget(base);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
153 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
154
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
155 void AdministratorWindow::loadCertificateFile()
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
156 {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
157 QString lastCertFile = mSettings.value("LastCertList", QDir::homePath()).toString();
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
158 QString certFile = QFileDialog::getOpenFileName(
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
159 this, tr("Select certificate list file"), lastCertFile, "*.txt");
567
75e39c52aa94 Check if cert-list filename is null (user canceled open file dialog).
Raimund Renkert <rrenkert@intevation.de>
parents: 566
diff changeset
160 if (certFile.isNull()) {
75e39c52aa94 Check if cert-list filename is null (user canceled open file dialog).
Raimund Renkert <rrenkert@intevation.de>
parents: 566
diff changeset
161 return;
75e39c52aa94 Check if cert-list filename is null (user canceled open file dialog).
Raimund Renkert <rrenkert@intevation.de>
parents: 566
diff changeset
162 }
453
6dec8101793c Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents: 429
diff changeset
163 mCertList.readList(certFile.toLocal8Bit().constData());
6dec8101793c Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents: 429
diff changeset
164 if (!mCertList.isValid()) {
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
165 QMessageBox::warning(this, tr("Error!"), tr("Failed to load the certificate list."));
462
091ad56c2715 Change current certificates file name. Some cleanups.
Andre Heinecke <aheinecke@intevation.de>
parents: 453
diff changeset
166 } else {
396
26651cc0cc47 Remove all certificates if a new list is loaded from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 395
diff changeset
167 certificateModel->removeAll();
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
168 loadCertificateTable();
515
9d3880db6ba7 Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
169 mSettings.setValue("LastCertList", certFile);
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
170 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
171 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
172
368
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
173 void AdministratorWindow::saveCertificateFile()
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
174 {
566
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 565
diff changeset
175 CertificateDiffDialog *diffDialog = new CertificateDiffDialog(this);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 565
diff changeset
176 int ret = diffDialog->exec();
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 565
diff changeset
177 if (ret == QDialog::Accepted) {
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 565
diff changeset
178 CreateCertListDialog *dialog = new CreateCertListDialog(this);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 565
diff changeset
179 dialog->show();
1317
d009da9cfa10 (issue157) Reload list after successful creation
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1316
diff changeset
180 connect (dialog, SIGNAL(creationSuccessful()), this, SLOT(loadCurrentCertificates()));
566
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 565
diff changeset
181 }
368
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
182 }
f9c98f9e9f76 Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents: 362
diff changeset
183
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
184 void AdministratorWindow::addCertificates()
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
185 {
429
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
186 QStringList certFiles = QFileDialog::getOpenFileNames(
1324
b6fb5d347023 Store last folder from which certificates were added.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1323
diff changeset
187 this, tr("Select certificate"), mSettings.value("LastCertAddDir", QDir::homePath()).toString(),
b6fb5d347023 Store last folder from which certificates were added.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1323
diff changeset
188 "*.pem *.der *.crt *.cer");
429
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
189 for (int i = 0; i < certFiles.size(); i++) {
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
190 QString certFile = certFiles.at(i);
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
191 QList<Certificate> certs = Certificate::fromFileName(certFile);
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
192 addToCertificateTable(certs);
1324
b6fb5d347023 Store last folder from which certificates were added.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1323
diff changeset
193 QDir certDir (certFile);
b6fb5d347023 Store last folder from which certificates were added.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1323
diff changeset
194 mSettings.setValue("LastCertAddDir", certDir.absolutePath());
429
f07bc5de2a87 Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents: 427
diff changeset
195 }
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
196 certificateView->resizeColumnsToContents();
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
197 certificateView->setColumnWidth(0, 60);
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
198 }
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
199
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
200 void AdministratorWindow::removeCertificates()
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
201 {
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
202 QModelIndexList list = certificateView->selectionModel()->selectedRows();
1316
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
203 foreach (QModelIndex idx, list) {
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
204 QModelIndex realidx = mFilterModel->mapToSource(idx);
1318
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
205 if (!idx.data(Qt::UserRole).toBool()) {
1316
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
206 certificateModel->removeRow(realidx.row(), realidx.parent());
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
207 } else {
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
208 qDebug() << "Tried to remove old certificate at idx: " << realidx.row();;
ff9cd05e861e (issue166) Fix certificiate removal
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1283
diff changeset
209 }
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
210 }
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
211 }
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
212
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
213 void AdministratorWindow::loadCertificateTable() {
453
6dec8101793c Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents: 429
diff changeset
214 foreach(const Certificate &cert, mCertList.getCertificates()) {
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
215 certificateModel->addCertificate(cert, true);
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
216 }
395
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
217 certificateView->resizeColumnsToContents();
a63601810211 Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents: 394
diff changeset
218 certificateView->setColumnWidth(0, 60);
358
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
219 }
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
220
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
221 void AdministratorWindow::addToCertificateTable(const QList<Certificate> &certs)
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
222 {
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
223 foreach(const Certificate &cert, certs) {
9ba7b4b4c1de Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents: 348
diff changeset
224 certificateModel->addCertificate(cert, false);
344
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
225 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
226 }
4454a4dc73a3 Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents: 343
diff changeset
227
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
228 void AdministratorWindow::showAbout()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
229 {
427
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
230 AboutDialog *dialog = new AboutDialog(this);
d08e39b913ee Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents: 426
diff changeset
231 dialog->show();
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
232 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
233
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
234 void AdministratorWindow::createInstaller()
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
235 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
236 qDebug() << "create Installer";
362
857ae1ffdd6f Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents: 358
diff changeset
237 CreateInstallerDialog *dialog = new CreateInstallerDialog(this);
857ae1ffdd6f Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents: 358
diff changeset
238 dialog->show();
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
239 }
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
240
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
241 void AdministratorWindow::clickedCertificate(const QModelIndex &index)
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
242 {
1318
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
243 QModelIndexList list = certificateView->selectionModel()->selectedRows();
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
244 bool all_are_removable = true;
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
245 foreach (QModelIndex idx, list) {
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
246 if (idx.data(Qt::UserRole).toBool()) {
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
247 all_are_removable = false;
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
248 break;
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
249 }
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
250 }
1318
45082ec23e76 (issue166) Only acticate removal if all selected certificates can be remvoed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1317
diff changeset
251 removeButton->setEnabled(all_are_removable);
376
9731d28b95af Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents: 368
diff changeset
252 }
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
253
679
75cd2fbf9ac6 (Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents: 570
diff changeset
254 void AdministratorWindow::logChanges(const QString &currentCerts, const QString& keyFingerprint)
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
255 {
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
256 QDir logDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
257 QString logFilePath = logDir.filePath("log.txt");
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
258 QFile logFile(logFilePath);
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
259
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
260 if (!logFile.open(QIODevice::Append)) {
570
c9d296f04995 Inform the user when logging fails.
Andre Heinecke <aheinecke@intevation.de>
parents: 567
diff changeset
261 QMessageBox::warning(this, tr("Error!"), tr("Failed to open log file: ") +
c9d296f04995 Inform the user when logging fails.
Andre Heinecke <aheinecke@intevation.de>
parents: 567
diff changeset
262 logFilePath + tr(" Changes are not logged!"));
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
263 qDebug() << "Failed to open log file: " << logFilePath;
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
264 return;
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
265 }
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
266
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
267 CertificateList newCertList;
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
268 newCertList.readList(currentCerts.toLocal8Bit());
679
75cd2fbf9ac6 (Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents: 570
diff changeset
269 QByteArray entries = createLogEntries(newCertList, keyFingerprint);
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
270 if(logFile.write(entries) != entries.size()) {
570
c9d296f04995 Inform the user when logging fails.
Andre Heinecke <aheinecke@intevation.de>
parents: 567
diff changeset
271 QMessageBox::warning(this, tr("Error!"), tr("Failed to write log file: ") +
c9d296f04995 Inform the user when logging fails.
Andre Heinecke <aheinecke@intevation.de>
parents: 567
diff changeset
272 logFilePath + tr(" Changes are not logged!"));
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
273 return;
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
274 }
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
275 logFile.close();
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
276 }
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
277
679
75cd2fbf9ac6 (Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents: 570
diff changeset
278 QByteArray AdministratorWindow::createLogEntries(const CertificateList &list, const QString& keyFingerprint)
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
279 {
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
280 QByteArray entries;
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
281 QByteArray removeListEntries;
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
282
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
283 QDateTime currentDate = QDateTime::currentDateTime();
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
284 QDateTime newListDate = list.date();
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
285 QDateTime listDate = mCertList.date();
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
286
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
287 entries.append("##### " +
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
288 currentDate.toString("yyyy-MM-dd hh:mm") +
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
289 tr(" new certificatelist ") +
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
290 newListDate.toString(Qt::ISODate) +
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
291 tr(" based on list from ") +
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
292 listDate.toString(Qt::ISODate) +
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
293 "#####\r\n");
1283
38d3dce323b4 Do not include hard linebreaks in translation strings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1274
diff changeset
294 entries.append(tr("signing certificate:") + "\r\n");
679
75cd2fbf9ac6 (Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents: 570
diff changeset
295 entries.append(keyFingerprint);
75cd2fbf9ac6 (Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents: 570
diff changeset
296
1283
38d3dce323b4 Do not include hard linebreaks in translation strings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1274
diff changeset
297 entries.append(QString::fromLatin1("\r\n") + tr("new certificates:") +"\r\n");
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
298
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
299 foreach (const Certificate& cert, list.getCertificates()) {
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
300 if (!mCertList.getCertificates().contains(cert)) {
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
301 QString certEntry(cert.subjectCN() + ": " + cert.base64Line() + "\r\n");
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
302 if (cert.isInstallCert()) {
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
303 entries.append(certEntry);
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
304 }
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
305 else {
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
306 removeListEntries.append(certEntry);
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
307 }
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
308 }
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
309 }
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
310
1283
38d3dce323b4 Do not include hard linebreaks in translation strings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1274
diff changeset
311 entries.append(tr("certificates marked to remove:") + "\r\n");
562
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
312 entries.append(removeListEntries);
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
313 entries.append("\r\n");
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
314
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
315 return entries;
ccdc4c6b97ce Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents: 540
diff changeset
316 }
565
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
317
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
318 QList<Certificate> AdministratorWindow::currentChanges()
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
319 {
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
320 QList<Certificate> changed;
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
321 foreach(const Certificate& cert, certificates()) {
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
322 if (!mCertList.getCertificates().contains(cert)) {
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
323 changed.append(cert);
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
324 }
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
325 }
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
326 return changed;
9db7034b2d6c Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 562
diff changeset
327 }
1001
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
328
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
329 void AdministratorWindow::showHelp()
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
330 {
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
331 char *inst_dir = get_install_dir();
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
332 if (!inst_dir) {
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
333 qDebug() << "Failed to find install dir";
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
334 return;
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
335 }
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
336 QString helpPath = QString::fromUtf8(inst_dir);
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
337 helpPath += HELP_PATH;
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
338 QFileInfo fiHelp(helpPath);
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
339 qDebug() << "Opening help: " << fiHelp.absoluteFilePath();
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
340 if (!fiHelp.exists()) {
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
341 QMessageBox::warning(this, tr("Error!"), tr ("Failed to find the manual"));
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
342 return;
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
343 }
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
344 #ifdef Q_OS_WIN
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
345 QDesktopServices::openUrl(QUrl("file:///" + fiHelp.absoluteFilePath()));
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
346 #else
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
347 QDesktopServices::openUrl(QUrl(fiHelp.absoluteFilePath()));
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
348 #endif
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
349 free (inst_dir);
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
350 return;
0b7bb4f68f5a (issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 679
diff changeset
351 }

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