Mercurial > trustbridge
annotate ui/administratorwindow.cpp @ 1185:69f7d302cdb9
Fix build with changed documentation paths
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 22 Sep 2014 13:11:30 +0200 |
parents | 0b7bb4f68f5a |
children | bd2cb6bdb1c5 |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
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")); |
394
7e0a188d6848
Load the last certificate list from data dir on startup.
Raimund Renkert <rrenkert@intevation.de>
parents:
376
diff
changeset
|
40 QString path = QStandardPaths::locate( |
462
091ad56c2715
Change current certificates file name. Some cleanups.
Andre Heinecke <aheinecke@intevation.de>
parents:
453
diff
changeset
|
41 QStandardPaths::DataLocation, QString("current_certificates.txt")); |
453
6dec8101793c
Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents:
429
diff
changeset
|
42 mCertList.readList(path.toLocal8Bit()); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 createActions(); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 createMenuBar(); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 createContent(); |
394
7e0a188d6848
Load the last certificate list from data dir on startup.
Raimund Renkert <rrenkert@intevation.de>
parents:
376
diff
changeset
|
46 loadCertificateTable(); |
540 | 47 resize(1190, 500); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 } |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 void AdministratorWindow::createActions() |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 { |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 } |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 void AdministratorWindow::createMenuBar() |
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 menuBar = new QMenuBar(this); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 QMenu *menu = new QMenu(tr("Menu"), menuBar); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 menuBar->addMenu(menu); |
415
b19290d6b148
Removed obsolete menu entries.
Raimund Renkert <rrenkert@intevation.de>
parents:
412
diff
changeset
|
59 QAction *createInstaller = menu->addAction(tr("Create installer ...")); |
b19290d6b148
Removed obsolete menu entries.
Raimund Renkert <rrenkert@intevation.de>
parents:
412
diff
changeset
|
60 QAction *about = menu->addAction(tr("About TrustBridge")); |
1001
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
61 QAction *help = menu->addAction(tr("Help")); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
62 help->setIcon(QIcon(":/img/show-help_16.png")); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 menu->addSeparator(); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 QAction *quit = menu->addAction(tr("Quit")); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller())); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 connect(about, SIGNAL(triggered()), this, SLOT(showAbout())); |
1001
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
67 connect(help, SIGNAL(triggered()), this, SLOT(showHelp())); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit())); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 setMenuBar(menuBar); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 } |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 void AdministratorWindow::createContent() |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 { |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 // Create a central widget containing the main layout. |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 QWidget *base = new QWidget; |
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 // Layouts and Container |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 QVBoxLayout *mainLayout = new QVBoxLayout; |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 QVBoxLayout *certLayout = new QVBoxLayout; |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 QHBoxLayout *headerLayout = new QHBoxLayout; |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 QVBoxLayout *headerTextLayout = new QVBoxLayout; |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 QHBoxLayout *bottomLayout = new QHBoxLayout; |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 // The certificate list |
412
340b8759d005
Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
85 QGroupBox *certBox = new QGroupBox( |
426
d7cda835abd6
Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents:
415
diff
changeset
|
86 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
|
87 certificateView = new QTableView; |
343
e3d6de930c90
Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
335
diff
changeset
|
88 certificateModel = new CertificateTabelModel(); |
398
9e6a2c2033ed
Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents:
396
diff
changeset
|
89 QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(this); |
9e6a2c2033ed
Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents:
396
diff
changeset
|
90 filterModel->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
|
91 CertificateTableDelegate *delegate = new CertificateTableDelegate(certificateView); |
398
9e6a2c2033ed
Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents:
396
diff
changeset
|
92 certificateView->setModel(filterModel); |
348
e6aa82466420
Use the table item delegate for certificates and make the model editable.
Raimund Renkert <rrenkert@intevation.de>
parents:
344
diff
changeset
|
93 certificateView->setItemDelegate(delegate); |
426
d7cda835abd6
Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents:
415
diff
changeset
|
94 certificateView->horizontalHeader()->setStretchLastSection(true); |
395
a63601810211
Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents:
394
diff
changeset
|
95 certificateView->resizeColumnsToContents(); |
a63601810211
Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents:
394
diff
changeset
|
96 certificateView->setColumnWidth(0, 60); |
343
e3d6de930c90
Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
335
diff
changeset
|
97 certificateView->setSelectionBehavior(QAbstractItemView::SelectRows); |
376
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
98 connect(certificateView, SIGNAL(clicked(const QModelIndex&)), this, |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
99 SLOT(clickedCertificate(const QModelIndex&))); |
343
e3d6de930c90
Updated the table ui in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
335
diff
changeset
|
100 certificateView->verticalHeader()->setVisible(false); |
398
9e6a2c2033ed
Enable sorting in certifacte table view.
Raimund Renkert <rrenkert@intevation.de>
parents:
396
diff
changeset
|
101 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
|
102 certLayout->addWidget(certificateView); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 certBox->setLayout(certLayout); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 // The header (icon, about text) |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 QImage *logoImage = new QImage(":/img/logo.png"); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 QLabel *logo = new QLabel; |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 logo->setBackgroundRole(QPalette::Base); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 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
|
110 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
|
111 QLabel *subTitle = new QLabel( |
340b8759d005
Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
112 tr("Management application of the BSI certificate installer")); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
113 headerTextLayout->addWidget(title); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
114 headerTextLayout->addWidget(subTitle); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
115 headerLayout->addWidget(logo); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 headerLayout->addLayout(headerTextLayout); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
117 headerLayout->setStretch(0, 0); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 headerLayout->setStretch(1, 10); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
119 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
120 // The buttons. |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
121 bottomLayout->setAlignment(Qt::AlignBottom); |
412
340b8759d005
Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
122 saveButton = new QPushButton(QIcon(":/img/document-save.png"), tr("Save list")); |
368
f9c98f9e9f76
Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents:
362
diff
changeset
|
123 connect(saveButton, SIGNAL(clicked()), this, SLOT(saveCertificateFile())); |
412
340b8759d005
Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
124 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
|
125 connect(loadButton, SIGNAL(clicked()), this, SLOT(loadCertificateFile())); |
412
340b8759d005
Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
126 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
|
127 connect(addButton, SIGNAL(clicked()), this, SLOT(addCertificates())); |
412
340b8759d005
Wording und icons in TrustBridge Administration main window.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
128 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
|
129 removeButton->setEnabled(false); |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
130 connect(removeButton, SIGNAL(clicked()), this, SLOT(removeCertificates())); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
131 bottomLayout->addWidget(saveButton); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
132 bottomLayout->addWidget(loadButton); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
133 bottomLayout->addWidget(addButton); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
134 bottomLayout->addWidget(removeButton); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
135 bottomLayout->insertStretch(4, 10); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
136 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
137 mainLayout->addLayout(headerLayout); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
138 mainLayout->addWidget(certBox); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
139 mainLayout->addLayout(bottomLayout); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
140 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
141 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
142 // 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
|
143 // managed in the central widget. |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
144 base->setLayout(mainLayout); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
145 setCentralWidget(base); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
146 } |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
147 |
344
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
148 void AdministratorWindow::loadCertificateFile() |
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
149 { |
515
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
462
diff
changeset
|
150 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
|
151 QString certFile = QFileDialog::getOpenFileName( |
515
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
462
diff
changeset
|
152 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
|
153 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
|
154 return; |
75e39c52aa94
Check if cert-list filename is null (user canceled open file dialog).
Raimund Renkert <rrenkert@intevation.de>
parents:
566
diff
changeset
|
155 } |
453
6dec8101793c
Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents:
429
diff
changeset
|
156 mCertList.readList(certFile.toLocal8Bit().constData()); |
6dec8101793c
Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents:
429
diff
changeset
|
157 if (!mCertList.isValid()) { |
515
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
462
diff
changeset
|
158 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
|
159 } else { |
396
26651cc0cc47
Remove all certificates if a new list is loaded from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
395
diff
changeset
|
160 certificateModel->removeAll(); |
344
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
161 loadCertificateTable(); |
515
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
462
diff
changeset
|
162 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
|
163 } |
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
164 } |
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
165 |
368
f9c98f9e9f76
Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents:
362
diff
changeset
|
166 void AdministratorWindow::saveCertificateFile() |
f9c98f9e9f76
Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents:
362
diff
changeset
|
167 { |
566
8728ae882b6a
Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
565
diff
changeset
|
168 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
|
169 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
|
170 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
|
171 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
|
172 dialog->show(); |
8728ae882b6a
Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
565
diff
changeset
|
173 } |
368
f9c98f9e9f76
Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents:
362
diff
changeset
|
174 } |
f9c98f9e9f76
Show the new dialog on save button click.
Raimund Renkert <rrenkert@intevation.de>
parents:
362
diff
changeset
|
175 |
358
9ba7b4b4c1de
Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
348
diff
changeset
|
176 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
|
177 { |
429
f07bc5de2a87
Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents:
427
diff
changeset
|
178 QStringList certFiles = QFileDialog::getOpenFileNames( |
529
c81123298387
Also allow cer files,..
Andre Heinecke <aheinecke@intevation.de>
parents:
515
diff
changeset
|
179 this, tr("Select certificate"), QDir::homePath(), "*.pem *.der *.crt *.cer"); |
429
f07bc5de2a87
Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents:
427
diff
changeset
|
180 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
|
181 QString certFile = certFiles.at(i); |
f07bc5de2a87
Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents:
427
diff
changeset
|
182 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
|
183 addToCertificateTable(certs); |
f07bc5de2a87
Adminstration: "Add certificate" can now load multiple certificate files.
Raimund Renkert <rrenkert@intevation.de>
parents:
427
diff
changeset
|
184 } |
427
d08e39b913ee
Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
185 certificateView->resizeColumnsToContents(); |
d08e39b913ee
Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
186 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
|
187 } |
9ba7b4b4c1de
Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
348
diff
changeset
|
188 |
376
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
189 void AdministratorWindow::removeCertificates() |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
190 { |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
191 QModelIndexList list = certificateView->selectionModel()->selectedRows(); |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
192 for (int i = list.size() -1 ; i >= 0; i--) { |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
193 certificateModel->removeRow(list.at(i).row(), list.at(i)); |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
194 } |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
195 } |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
196 |
344
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
197 void AdministratorWindow::loadCertificateTable() { |
453
6dec8101793c
Rename settings and certlist and add accessors
Andre Heinecke <aheinecke@intevation.de>
parents:
429
diff
changeset
|
198 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
|
199 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
|
200 } |
395
a63601810211
Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents:
394
diff
changeset
|
201 certificateView->resizeColumnsToContents(); |
a63601810211
Resized administrator main window and columns.
Raimund Renkert <rrenkert@intevation.de>
parents:
394
diff
changeset
|
202 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
|
203 } |
9ba7b4b4c1de
Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
348
diff
changeset
|
204 |
9ba7b4b4c1de
Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
348
diff
changeset
|
205 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
|
206 { |
9ba7b4b4c1de
Implemented the load from certificate file and set the edit state of certificates.
Raimund Renkert <rrenkert@intevation.de>
parents:
348
diff
changeset
|
207 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
|
208 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
|
209 } |
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
210 } |
4454a4dc73a3
Added file dialog to load a certificate list from file.
Raimund Renkert <rrenkert@intevation.de>
parents:
343
diff
changeset
|
211 |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
212 void AdministratorWindow::showAbout() |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
213 { |
427
d08e39b913ee
Added about dialog content and open the dialog via administration app.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
214 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
|
215 dialog->show(); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
216 } |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
217 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
218 void AdministratorWindow::createInstaller() |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
219 { |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
220 qDebug() << "create Installer"; |
362
857ae1ffdd6f
Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents:
358
diff
changeset
|
221 CreateInstallerDialog *dialog = new CreateInstallerDialog(this); |
857ae1ffdd6f
Open the new dialog from the main menu.
Raimund Renkert <rrenkert@intevation.de>
parents:
358
diff
changeset
|
222 dialog->show(); |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
223 } |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
224 |
376
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
225 void AdministratorWindow::clickedCertificate(const QModelIndex &index) |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
226 { |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
227 if (index.data(Qt::UserRole).toBool()) { |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
228 removeButton->setEnabled(false); |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
229 } |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
230 else { |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
231 removeButton->setEnabled(true); |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
232 } |
9731d28b95af
Implemented 'remove certificate' in administrator app.
Raimund Renkert <rrenkert@intevation.de>
parents:
368
diff
changeset
|
233 } |
562
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
234 |
679
75cd2fbf9ac6
(Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents:
570
diff
changeset
|
235 void AdministratorWindow::logChanges(const QString ¤tCerts, 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
|
236 { |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
241 if (!logFile.open(QIODevice::Append)) { |
570
c9d296f04995
Inform the user when logging fails.
Andre Heinecke <aheinecke@intevation.de>
parents:
567
diff
changeset
|
242 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
|
243 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
|
244 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
|
245 return; |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
246 } |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
247 |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
248 CertificateList newCertList; |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
249 newCertList.readList(currentCerts.toLocal8Bit()); |
679
75cd2fbf9ac6
(Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents:
570
diff
changeset
|
250 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
|
251 if(logFile.write(entries) != entries.size()) { |
570
c9d296f04995
Inform the user when logging fails.
Andre Heinecke <aheinecke@intevation.de>
parents:
567
diff
changeset
|
252 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
|
253 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
|
254 return; |
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 logFile.close(); |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
257 } |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
258 |
679
75cd2fbf9ac6
(Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents:
570
diff
changeset
|
259 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
|
260 { |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
261 QByteArray entries; |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
262 QByteArray removeListEntries; |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
263 |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
268 entries.append("##### " + |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
269 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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 "#####\r\n"); |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
275 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
|
276 entries.append(keyFingerprint); |
75cd2fbf9ac6
(Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents:
570
diff
changeset
|
277 |
75cd2fbf9ac6
(Issue 9) Log key's sha256 fingerprint
Andre Heinecke <andre.heinecke@intevation.de>
parents:
570
diff
changeset
|
278 entries.append(tr("\r\nnew 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
|
279 |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 } |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
286 else { |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
287 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
|
288 } |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
289 } |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
290 } |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
291 |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
292 entries.append(tr("certificates marked to remove:\r\n")); |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
293 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
|
294 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
|
295 |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
296 return entries; |
ccdc4c6b97ce
Log diff between initial certificate list and saved list to a logfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
540
diff
changeset
|
297 } |
565
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
298 |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
299 QList<Certificate> AdministratorWindow::currentChanges() |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
300 { |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
301 QList<Certificate> changed; |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
302 foreach(const Certificate& cert, certificates()) { |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
303 if (!mCertList.getCertificates().contains(cert)) { |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
304 changed.append(cert); |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
305 } |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
306 } |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
307 return changed; |
9db7034b2d6c
Added method to get the current certificate list changes.
Raimund Renkert <rrenkert@intevation.de>
parents:
562
diff
changeset
|
308 } |
1001
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
309 |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
310 void AdministratorWindow::showHelp() |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
311 { |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
312 char *inst_dir = get_install_dir(); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
313 if (!inst_dir) { |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
314 qDebug() << "Failed to find install dir"; |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
315 return; |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
316 } |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
317 QString helpPath = QString::fromUtf8(inst_dir); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
318 helpPath += HELP_PATH; |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
319 QFileInfo fiHelp(helpPath); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
320 qDebug() << "Opening help: " << fiHelp.absoluteFilePath(); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
321 if (!fiHelp.exists()) { |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
322 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
|
323 return; |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
324 } |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
325 #ifdef Q_OS_WIN |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
326 QDesktopServices::openUrl(QUrl("file:///" + fiHelp.absoluteFilePath())); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
327 #else |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
328 QDesktopServices::openUrl(QUrl(fiHelp.absoluteFilePath())); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
329 #endif |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
330 free (inst_dir); |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
331 return; |
0b7bb4f68f5a
(issue89) Add Help button
Andre Heinecke <andre.heinecke@intevation.de>
parents:
679
diff
changeset
|
332 } |