From 33c91102a58e2fbcf9d7a66e33b41a65fa3f0e0c Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Tue, 16 Jun 2020 00:41:57 +0200 Subject: Adds improved client certificate management, adds server certificate management. --- src/settingsdialog.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'src/settingsdialog.cpp') diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 3581f03..7ef05fb 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "kristall.hpp" @@ -85,6 +86,22 @@ SettingsDialog::SettingsDialog(QWidget *parent) : this->on_presets_currentIndexChanged(-1); } + this->ui->trust_level->clear(); + this->ui->trust_level->addItem("Trust on first encounter", QVariant::fromValue(SslTrust::TrustOnFirstUse)); + this->ui->trust_level->addItem("Trust everything", QVariant::fromValue(SslTrust::TrustEverything)); + this->ui->trust_level->addItem("Manually verify fingerprints", QVariant::fromValue(SslTrust::TrustNoOne)); + + this->ui->trusted_hosts->setModel(&this->current_trust.trusted_hosts); + + this->ui->trusted_hosts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); + this->ui->trusted_hosts->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + this->ui->trusted_hosts->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); + + connect( + this->ui->trusted_hosts->selectionModel(), + &QItemSelectionModel::currentChanged, + this, + &SettingsDialog::on_trusted_server_selection); } SettingsDialog::~SettingsDialog() @@ -201,6 +218,27 @@ void SettingsDialog::setUiTheme(const QString &theme) } +SslTrust SettingsDialog::sslTrust() const +{ + return this->current_trust; +} + +void SettingsDialog::setSslTrust(const SslTrust &trust) +{ + this->current_trust = trust; + + this->ui->trust_level->setCurrentIndex( + this->ui->trust_level->findData(QVariant::fromValue(trust.trust_level)) + ); + + if(trust.enable_ca) + this->ui->trust_enable_ca->setChecked(true); + else + this->ui->trust_disable__ca->setChecked(true); + + this->ui->trusted_hosts->resizeColumnsToContents(); +} + void SettingsDialog::reloadStylePreview() { auto const document = R"gemini(# H1 Header @@ -295,6 +333,15 @@ void SettingsDialog::updateColor(QColor &input) } } +void SettingsDialog::on_trusted_server_selection(const QModelIndex ¤t, const QModelIndex &previous) +{ + if(auto host = this->current_trust.trusted_hosts.get(current); host) { + this->ui->trust_revoke_selected->setEnabled(true); + } else { + this->ui->trust_revoke_selected->setEnabled(false); + } +} + void SettingsDialog::on_std_change_color_clicked() { updateColor(current_style.standard_color); @@ -531,3 +578,23 @@ void SettingsDialog::on_preset_export_clicked() this->predefined_styles.value(name).save(export_settings); export_settings.sync(); } + +void SettingsDialog::on_trust_enable_ca_clicked() +{ + this->current_trust.enable_ca = true; +} + +void SettingsDialog::on_trust_disable__ca_clicked() +{ + this->current_trust.enable_ca = false; +} + +void SettingsDialog::on_trust_level_currentIndexChanged(int index) +{ + this->current_trust.trust_level = SslTrust::TrustLevel(this->ui->trust_level->itemData(index).toInt()); +} + +void SettingsDialog::on_trust_revoke_selected_clicked() +{ + this->current_trust.trusted_hosts.remove(this->ui->trusted_hosts->currentIndex()); +} -- cgit v1.2.3