Permalink
Browse files

Add "Encrypted session" checkbox for sslmode.

sslmode was already changeable through the parameters as a free
text but it requires that the user knows the exact syntax.
Now require/disable/whatever is available through a tri-state checkbox.
  • Loading branch information...
manitou-mail committed Jul 8, 2017
1 parent 7804642 commit 5881ed4193d76e803586c28b9d8ab95daa13caf5
Showing with 28 additions and 2 deletions.
  1. +24 −1 src/login.cpp
  2. +4 −1 src/login.h
View
@@ -1,4 +1,4 @@
/* Copyright (C) 2004-2016 Daniel Verite
/* Copyright (C) 2004-2017 Daniel Verite
This file is part of Manitou-Mail (see http://www.manitou-mail.org)
@@ -24,6 +24,7 @@
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QCheckBox>
#include <QLabel>
#include <QMessageBox>
#include <QVBoxLayout>
@@ -69,6 +70,10 @@ login_dialog::login_dialog() : QDialog(0)
grid->addWidget(m_params, row, 1);
row++;
m_tls = new QCheckBox(tr("Encrypted session"));
m_tls->setTristate();
grid->addWidget(m_tls, row, 1);
QHBoxLayout* hbox = new QHBoxLayout();
top_layout->addLayout(hbox);
@@ -103,6 +108,11 @@ login_dialog::init_settings()
set_dbname(settings.value("dbname").toString());
set_host(settings.value("host").toString());
set_params(settings.value("params").toString());
bool ok=false;
// serialized tri-state value corresponding to Qt::CheckState
int tls_state = settings.value("tls").toInt(&ok);
if (ok && tls_state>=0 && tls_state<=2)
set_tls((Qt::CheckState)tls_state);
}
void
@@ -137,6 +147,12 @@ login_dialog::connect_string()
if (!m_params->text().isEmpty()) {
res.append(" " + m_params->text());
}
if (m_tls->checkState()==Qt::Checked)
res.append(" sslmode=require");
else if (m_tls->checkState()==Qt::Unchecked)
res.append(" sslmode=disable");
/* if Qt::PartiallyChecked, do not specify sslmode. The user can
direct it through m_params */
return res.trimmed();
}
@@ -186,6 +202,12 @@ login_dialog::set_host(const QString host)
m_host->setText(host);
}
void
login_dialog::set_tls(Qt::CheckState state)
{
m_tls->setCheckState(state);
}
// focus on the password if login is set
void
login_dialog::set_focus()
@@ -244,6 +266,7 @@ login_dialog::db_connect()
settings.setValue("dbname", dbnames()); // stringlist
settings.setValue("host", host());
settings.setValue("params", params());
settings.setValue("tls", m_tls->checkState());
accept();
}
}
View
@@ -1,4 +1,4 @@
/* Copyright (C) 2004-2016 Daniel Verite
/* Copyright (C) 2004-2017 Daniel Verite
This file is part of Manitou-Mail (see http://www.manitou-mail.org)
@@ -25,6 +25,7 @@
class QLineEdit;
class QComboBox;
class QCheckBox;
class login_dialog: public QDialog
{
@@ -37,6 +38,7 @@ class login_dialog: public QDialog
void set_dbname(const QString dbname); // list of values separated by ';'
void set_params(const QString params);
void set_host(const QString host);
void set_tls(Qt::CheckState);
void set_focus(); // focus on the password if login is set
QString login() const;
QString dbnames() const;
@@ -52,6 +54,7 @@ class login_dialog: public QDialog
QLineEdit* m_password;
QLineEdit* m_host;
QLineEdit* m_params;
QCheckBox* m_tls;
private slots:
void db_connect();
void ok();

0 comments on commit 5881ed4

Please sign in to comment.