refactor: MainWindow new localFingerprint method to read the local fingerprint from the db, this is split from showMyFingerprint
This commit is contained in:
parent
9eede5470c
commit
2c6c65f71e
2 changed files with 28 additions and 22 deletions
|
|
@ -525,28 +525,7 @@ void MainWindow::updateSize()
|
||||||
|
|
||||||
void MainWindow::showMyFingerprint()
|
void MainWindow::showMyFingerprint()
|
||||||
{
|
{
|
||||||
if (!QFile::exists(Settings::tlsLocalDb())) {
|
Fingerprint sha256Print = localFingerprint();
|
||||||
if (regenerateLocalFingerprints())
|
|
||||||
showMyFingerprint();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FingerprintDatabase db;
|
|
||||||
db.read(Settings::tlsLocalDb());
|
|
||||||
if (db.fingerprints().isEmpty()) {
|
|
||||||
if (regenerateLocalFingerprints())
|
|
||||||
showMyFingerprint();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Fingerprint sha256Print;
|
|
||||||
for (const auto &f : std::as_const(db.fingerprints())) {
|
|
||||||
if (f.type == Fingerprint::Type::SHA256) {
|
|
||||||
sha256Print = f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FingerprintDialog fingerprintDialog(this, sha256Print);
|
FingerprintDialog fingerprintDialog(this, sha256Print);
|
||||||
fingerprintDialog.exec();
|
fingerprintDialog.exec();
|
||||||
}
|
}
|
||||||
|
|
@ -1208,6 +1187,30 @@ bool MainWindow::regenerateLocalFingerprints()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fingerprint MainWindow::localFingerprint()
|
||||||
|
{
|
||||||
|
if (!QFile::exists(Settings::tlsLocalDb())) {
|
||||||
|
if (regenerateLocalFingerprints())
|
||||||
|
return localFingerprint();
|
||||||
|
}
|
||||||
|
|
||||||
|
FingerprintDatabase db;
|
||||||
|
db.read(Settings::tlsLocalDb());
|
||||||
|
if (db.fingerprints().isEmpty()) {
|
||||||
|
if (regenerateLocalFingerprints())
|
||||||
|
return localFingerprint();
|
||||||
|
}
|
||||||
|
|
||||||
|
Fingerprint sha256Print;
|
||||||
|
for (const auto &f : std::as_const(db.fingerprints())) {
|
||||||
|
if (f.type == Fingerprint::Type::SHA256) {
|
||||||
|
sha256Print = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sha256Print;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::serverClientsChanged(const QStringList &clients)
|
void MainWindow::serverClientsChanged(const QStringList &clients)
|
||||||
{
|
{
|
||||||
if (m_coreProcess.mode() != CoreMode::Server || !m_coreProcess.isStarted())
|
if (m_coreProcess.mode() != CoreMode::Server || !m_coreProcess.isStarted())
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "gui/core/ServerConnection.h"
|
#include "gui/core/ServerConnection.h"
|
||||||
#include "gui/core/WaylandWarnings.h"
|
#include "gui/core/WaylandWarnings.h"
|
||||||
#include "gui/tls/TlsUtility.h"
|
#include "gui/tls/TlsUtility.h"
|
||||||
|
#include "net/Fingerprint.h"
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include "gui/OSXHelpers.h"
|
#include "gui/OSXHelpers.h"
|
||||||
|
|
@ -159,6 +160,8 @@ private:
|
||||||
// Returns true if successful
|
// Returns true if successful
|
||||||
bool regenerateLocalFingerprints();
|
bool regenerateLocalFingerprints();
|
||||||
|
|
||||||
|
Fingerprint localFingerprint();
|
||||||
|
|
||||||
void serverClientsChanged(const QStringList &clients);
|
void serverClientsChanged(const QStringList &clients);
|
||||||
|
|
||||||
inline static const auto m_guiSocketName = QStringLiteral("deskflow-gui");
|
inline static const auto m_guiSocketName = QStringLiteral("deskflow-gui");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue