GODT-1901: Allow to set IMAP SSL from UI

This commit is contained in:
Leander Beernaert
2022-10-13 10:58:11 +02:00
committed by James Houlahan
parent 209c315a76
commit e10cd2a3ed
116 changed files with 3713 additions and 973 deletions

View File

@ -306,6 +306,16 @@ void QMLBackend::toggleUseSSLforSMTP(bool makeItActive)
app().grpc().setUseSSLForSMTP(makeItActive);
}
//****************************************************************************************************************************************************
/// \param[in] makeItActive Should SSL for IMAP be enabled.
//****************************************************************************************************************************************************
void QMLBackend::toggleUseSSLforIMAP(bool makeItActive)
{
// if call succeed, app will restart. No need to emit a value change signal, because it will trigger a read-back via gRPC that will fail.
emit hideMainWindow();
app().grpc().setUseSSLForIMAP(makeItActive);
}
//****************************************************************************************************************************************************
/// \param[in] imapPort The IMAP port.

View File

@ -68,6 +68,7 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
Q_PROPERTY(QString colorSchemeName READ colorSchemeName NOTIFY colorSchemeNameChanged) // _ string `property:"colorSchemeName"`
Q_PROPERTY(QUrl diskCachePath READ diskCachePath NOTIFY diskCachePathChanged) // _ core.QUrl `property:"diskCachePath"`
Q_PROPERTY(bool useSSLforSMTP READ useSSLForSMTP NOTIFY useSSLforSMTPChanged) // _ bool `property:"useSSLforSMTP"`
Q_PROPERTY(bool useSSLforIMAP READ useSSLForIMAP NOTIFY useSSLforIMAPChanged) // _ bool `property:"useSSLforIMAP"`
Q_PROPERTY(int portIMAP READ portIMAP NOTIFY portIMAPChanged) // _ int `property:"portIMAP"`
Q_PROPERTY(int portSMTP READ portSMTP NOTIFY portSMTPChanged) // _ int `property:"portSMTP"`
Q_PROPERTY(bool isDoHEnabled READ isDoHEnabled NOTIFY isDoHEnabledChanged) // _ bool `property:"isDoHEnabled"`
@ -99,6 +100,7 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
QString colorSchemeName() const { QString name; app().grpc().colorSchemeName(name); return name; }
QUrl diskCachePath() const { QUrl path; app().grpc().diskCachePath(path); return path; }
bool useSSLForSMTP() const{ bool useSSL; app().grpc().useSSLForSMTP(useSSL); return useSSL; }
bool useSSLForIMAP() const{ bool useSSL; app().grpc().useSSLForIMAP(useSSL); return useSSL; }
int portIMAP() const { int port; app().grpc().portIMAP(port); return port; }
int portSMTP() const { int port; app().grpc().portSMTP(port); return port; }
bool isDoHEnabled() const { bool isEnabled; app().grpc().isDoHEnabled(isEnabled); return isEnabled;}
@ -116,6 +118,7 @@ signals: // Signal used by the Qt property system. Many of them are unused but r
void goosChanged(QString const &value);
void diskCachePathChanged(QUrl const &url);
void useSSLforSMTPChanged(bool value);
void useSSLforIMAPChanged(bool value);
void isAutomaticUpdateOnChanged(bool value);
void isBetaEnabledChanged(bool value);
void isAllMailVisibleChanged(bool value);
@ -149,6 +152,7 @@ public slots: // slot for signals received from QML -> To be forwarded to Bridge
void login2Password(QString const& username, QString const& password) { app().grpc().login2Passwords(username, password);} // _ func(username, password string) `slot:"login2Password"`
void loginAbort(QString const& username){ app().grpc().loginAbort(username);} // _ func(username string) `slot:"loginAbort"`
void toggleUseSSLforSMTP(bool makeItActive); // _ func(makeItActive bool) `slot:"toggleUseSSLforSMTP"`
void toggleUseSSLforIMAP(bool makeItActive); // _ func(makeItActive bool) `slot:"toggleUseSSLforIMAP"`
void changePorts(int imapPort, int smtpPort); // _ func(imapPort, smtpPort int) `slot:"changePorts"`
void toggleDoH(bool active); // _ func(makeItActive bool) `slot:"toggleDoH"`
void toggleAutomaticUpdate(bool makeItActive); // _ func(makeItActive bool) `slot:"toggleAutomaticUpdate"`

View File

@ -100,6 +100,7 @@
<file>qml/SetupGuide.qml</file>
<file>qml/SignIn.qml</file>
<file>qml/SMTPSettings.qml</file>
<file>qml/IMAPSettings.qml</file>
<file>qml/SplashScreen.qml</file>
<file>qml/Status.qml</file>
<file>qml/StatusWindow.qml</file>

View File

@ -231,7 +231,7 @@ Item {
port: Backend.portIMAP.toString()
username: configuration.currentAddress
password: root.user ? root.user.password : ""
security: "STARTTLS"
security : Backend.useSSLforIMAP ? "SSL" : "STARTTLS"
}
Configuration {

View File

@ -365,6 +365,14 @@ Item {
}
}
IMAPSettings { // 9
colorScheme: root.colorScheme
onBack: {
rightContent.showGeneralSettings()
}
}
function showAccount(index) {
if (index !== undefined && index >= 0){
accounts.currentIndex = index
@ -380,6 +388,7 @@ Item {
function showLocalCacheSettings () { rightContent.currentIndex = 6 }
function showHelpView () { rightContent.currentIndex = 7 }
function showBugReport () { rightContent.currentIndex = 8 }
function showIMAPSettings () { rightContent.currentIndex = 9 }
Connections {
target: Backend

View File

@ -182,6 +182,19 @@ SettingsView {
Layout.fillWidth: true
}
SettingsItem {
id: imap
visible: root._isAdvancedShown
colorScheme: root.colorScheme
text: qsTr("IMAP connection mode")
actionText: qsTr("Change")
description: qsTr("Change the protocol Bridge and your client use to connect.")
type: SettingsItem.Button
onClicked: root.parent.showIMAPSettings()
Layout.fillWidth: true
}
SettingsItem {
id: smtp
visible: root._isAdvancedShown

View File

@ -0,0 +1,121 @@
// Copyright (c) 2022 Proton AG
//
// This file is part of Proton Mail Bridge.
//
// Proton Mail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Proton Mail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.impl
import Proton
SettingsView {
id: root
fillHeight: false
Label {
colorScheme: root.colorScheme
text: qsTr("IMAP connection mode")
type: Label.Heading
Layout.fillWidth: true
}
Label {
colorScheme: root.colorScheme
text: qsTr("Changes require reconfiguration of email client. Bridge will automatically restart.")
type: Label.Body
color: root.colorScheme.text_weak
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
ColumnLayout {
spacing: 16
ButtonGroup{ id: protocolSelection }
Label {
colorScheme: root.colorScheme
text: qsTr("IMAP connection security")
}
RadioButton {
id: sslButton
colorScheme: root.colorScheme
ButtonGroup.group: protocolSelection
text: qsTr("SSL")
}
RadioButton {
id: starttlsButton
colorScheme: root.colorScheme
ButtonGroup.group: protocolSelection
text: qsTr("STARTTLS")
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: root.colorScheme.border_weak
}
RowLayout {
spacing: 12
Button {
id: submitButton
colorScheme: root.colorScheme
text: qsTr("Save and restart")
onClicked: {
submitButton.loading = true
root.submit()
}
enabled: sslButton.checked !== Backend.useSSLforIMAP
}
Button {
colorScheme: root.colorScheme
text: qsTr("Cancel")
onClicked: root.back()
secondary: true
}
Connections {
target: Backend
function onToggleUseSSLFinished() {
submitButton.loading = false
}
}
}
function submit(){
submitButton.loading = true
Backend.toggleUseSSLforIMAP(sslButton.checked)
}
function setDefaultValues(){
sslButton.checked = Backend.useSSLforIMAP
starttlsButton.checked = !Backend.useSSLforIMAP
}
onVisibleChanged: {
root.setDefaultValues()
}
}