GODT-1344: notifications for ApiCertError and NoActiveKeyForRecipient.

Phase 1: added the two event in bridge-gui-tester.
Phase 2: implemented QML notifications.
This commit is contained in:
Xavier Michelon
2022-10-12 09:42:52 +02:00
parent 9035dc6bf7
commit b2efed71d3
6 changed files with 106 additions and 29 deletions

View File

@ -43,6 +43,9 @@ SettingsTab::SettingsTab(QWidget *parent)
connect(ui_.buttonInternetOn, &QPushButton::clicked, []() { app().grpc().sendEvent(newInternetStatusEvent(true)); });
connect(ui_.buttonInternetOff, &QPushButton::clicked, []() { app().grpc().sendEvent(newInternetStatusEvent(false)); });
connect(ui_.buttonShowMainWindow, &QPushButton::clicked, []() { app().grpc().sendEvent(newShowMainWindowEvent()); });
connect(ui_.buttonAPICertIssue, &QPushButton::clicked, []() {app().grpc().sendEvent(newApiCertIssueEvent()); });
connect(ui_.buttonNoActiveKeyForRecipient, &QPushButton::clicked, [&]() {app().grpc().sendEvent(
newNoActiveKeyForRecipientEvent(ui_.editNoActiveKeyForRecipient->text())); });
connect(ui_.checkNextCacheChangeWillSucceed, &QCheckBox::toggled, this, &SettingsTab::updateGUIState);
this->resetUI();
this->updateGUIState();

View File

@ -703,19 +703,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonInternetOn">
<property name="text">
@ -723,19 +710,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonShowMainWindow">
<property name="text">
@ -743,6 +717,31 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonAPICertIssue">
<property name="text">
<string>API cert. Issue</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPushButton" name="buttonNoActiveKeyForRecipient">
<property name="text">
<string>No Active Key For Recipient</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="editNoActiveKeyForRecipient">
<property name="text">
<string>dummy.user@proton.me</string>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -68,6 +68,7 @@ Dialog {
Label {
Layout.alignment: Qt.AlignHCenter
horizontalAlignment: Text.AlignHCenter
Layout.bottomMargin: 8
colorScheme: root.colorScheme
text: root.notification.title

View File

@ -128,4 +128,14 @@ Item {
colorScheme: root.colorScheme
notification: root.notifications.rebuildKeychain
}
NotificationDialog {
colorScheme: root.colorScheme
notification: root.notifications.apiCertIssue
}
NotificationDialog {
colorScheme: root.colorScheme
notification: root.notifications.noActiveKeyForRecipient
}
}

View File

@ -77,7 +77,9 @@ QtObject {
root.deleteAccount,
root.noKeychain,
root.rebuildKeychain,
root.addressChanged
root.addressChanged,
root.apiCertIssue,
root.noActiveKeyForRecipient
]
// Connection
@ -1051,4 +1053,63 @@ QtObject {
}
]
}
property Notification apiCertIssue: Notification {
title: qsTr("Unable to establish a \nsecure connection to \nProton servers")
description: qsTr("Bridge cannot verify the authenticity of Proton servers on your current network due to a TLS certificate error. " +
"Start Bridge again after ensuring your connection is secure and/or connecting to a VPN. Learn more about TLS pinning " +
"<a href=\"https://proton.me/blog/tls-ssl-certificate#Extra-security-precautions-taken-by-ProtonMail\">here</a>.")
brief: title
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Dialogs | Notifications.Group.Connection
Connections {
target: Backend
function onApiCertIssue() {
root.apiCertIssue.active = true
}
}
action: [
Action {
text: qsTr("Quit Bridge")
onTriggered: {
root.apiCertIssue.active = false;
Backend.quit()
}
}
]
}
property Notification noActiveKeyForRecipient: Notification {
title: qsTr("Unable to send \nencrypted message")
description: "#PlaceholderText#"
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Dialogs | Notifications.Group.Connection
Connections {
target: Backend
function onNoActiveKeyForRecipient(email) {
root.noActiveKeyForRecipient.description = qsTr("There are no active keys to encrypt your message to %1. "+
"Please update the setting for this contact.").arg(email)
root.noActiveKeyForRecipient.active = true
}
}
action: [
Action {
text: qsTr("OK")
onTriggered: {
root.noActiveKeyForRecipient.active = false
}
}
]
}
}

View File

@ -1382,9 +1382,12 @@ void GRPCClient::processMailEvent(MailEvent const &event)
switch (event.event_case())
{
case MailEvent::kNoActiveKeyForRecipientEvent:
this->logTrace("Mail event received: kNoActiveKeyForRecipientEvent.");
emit noActiveKeyForRecipient(QString::fromStdString(event.noactivekeyforrecipientevent().email()));
{
QString const email = QString::fromStdString(event.noactivekeyforrecipientevent().email());
this->logTrace(QString("Mail event received: NoActiveKeyForRecipient (email = %1).").arg(email));
emit noActiveKeyForRecipient(email);
break;
}
case MailEvent::kAddressChanged:
this->logTrace("Mail event received: AddressChanged.");
emit addressChanged(QString::fromStdString(event.addresschanged().address()));