mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Show different verification errors
This commit is contained in:
parent
bca29a4227
commit
8a4d85f801
7 changed files with 35 additions and 20 deletions
|
@ -6,7 +6,6 @@ import im.nheko 1.0
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
property var flow
|
property var flow
|
||||||
property var tran_id
|
|
||||||
|
|
||||||
title: stack.currentItem.title
|
title: stack.currentItem.title
|
||||||
id: dialog
|
id: dialog
|
||||||
|
|
|
@ -2,23 +2,29 @@ import QtQuick 2.3
|
||||||
import QtQuick.Controls 2.10
|
import QtQuick.Controls 2.10
|
||||||
import QtQuick.Layouts 1.10
|
import QtQuick.Layouts 1.10
|
||||||
|
|
||||||
|
import im.nheko 1.0
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
property string title: qsTr("Verification timed out")
|
property string title: qsTr("Verification failed")
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 16
|
spacing: 16
|
||||||
Text {
|
Text {
|
||||||
|
id: content
|
||||||
|
|
||||||
Layout.maximumWidth: 400
|
Layout.maximumWidth: 400
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
id: content
|
|
||||||
text: switch (flow.error) {
|
text: switch (flow.error) {
|
||||||
case VerificationStatus.UnknownMethod: return qsTr("Device verification timed out.")
|
case DeviceVerificationFlow.UnknownMethod: return qsTr("Other client does not support our verification protocol.")
|
||||||
case VerificationStatus.MismatchedCommitment: return qsTr("Device verification timed out.")
|
case DeviceVerificationFlow.MismatchedCommitment:
|
||||||
case VerificationStatus.MismatchedSAS: return qsTr("Device verification timed out.")
|
case DeviceVerificationFlow.MismatchedSAS:
|
||||||
case VerificationStatus.KeyMismatch: return qsTr("Device verification timed out.")
|
case DeviceVerificationFlow.KeyMismatch: return qsTr("Key mismatch detected!")
|
||||||
case VerificationStatus.Timeout: return qsTr("Device verification timed out.")
|
case DeviceVerificationFlow.Timeout: return qsTr("Device verification timed out.")
|
||||||
case VerificationStatus.OutOfOrder: return qsTr("Device verification timed out.")
|
case DeviceVerificationFlow.User: return qsTr("Other party canceled the verification.")
|
||||||
|
case DeviceVerificationFlow.OutOfOrder: return qsTr("Device verification timed out.")
|
||||||
|
default: return "Unknown verification error.";
|
||||||
}
|
}
|
||||||
color:colors.text
|
color:colors.text
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
@ -31,11 +37,7 @@ Pane {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
text: qsTr("Close")
|
text: qsTr("Close")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: dialog.close()
|
||||||
deviceVerificationList.remove(tran_id);
|
|
||||||
flow.deleteFlow();
|
|
||||||
dialog.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ Pane {
|
||||||
case "WaitingForMac": return qsTr("Waiting for other side to complete the verification request.")
|
case "WaitingForMac": return qsTr("Waiting for other side to complete the verification request.")
|
||||||
}
|
}
|
||||||
|
|
||||||
color:colors.text
|
color: colors.text
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
palette: color
|
palette: colors
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Button {
|
Button {
|
||||||
|
|
|
@ -64,7 +64,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *,
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(timeout, &QTimer::timeout, this, [this]() {
|
connect(timeout, &QTimer::timeout, this, [this]() {
|
||||||
this->cancelVerification(DeviceVerificationFlow::Error::Timeout);
|
if (state_ != Success && state_ != Failed)
|
||||||
|
this->cancelVerification(DeviceVerificationFlow::Error::Timeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ChatPage::instance(),
|
connect(ChatPage::instance(),
|
||||||
|
@ -114,7 +115,7 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
error_ = User;
|
error_ = User;
|
||||||
emit errorChanged();
|
Emit errorChanged();
|
||||||
setState(Failed);
|
setState(Failed);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class DeviceVerificationFlow : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
|
// Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
|
||||||
Q_PROPERTY(QString state READ state NOTIFY stateChanged)
|
Q_PROPERTY(QString state READ state NOTIFY stateChanged)
|
||||||
Q_PROPERTY(Error error READ error CONSTANT)
|
Q_PROPERTY(Error error READ error NOTIFY errorChanged)
|
||||||
Q_PROPERTY(QString userId READ getUserId CONSTANT)
|
Q_PROPERTY(QString userId READ getUserId CONSTANT)
|
||||||
Q_PROPERTY(QString deviceId READ getDeviceId CONSTANT)
|
Q_PROPERTY(QString deviceId READ getDeviceId CONSTANT)
|
||||||
Q_PROPERTY(bool sender READ getSender CONSTANT)
|
Q_PROPERTY(bool sender READ getSender CONSTANT)
|
||||||
|
@ -203,7 +203,7 @@ private:
|
||||||
mtx::common::RelatesTo relation;
|
mtx::common::RelatesTo relation;
|
||||||
|
|
||||||
State state_ = PromptStartVerification;
|
State state_ = PromptStartVerification;
|
||||||
Error error_;
|
Error error_ = UnknownMethod;
|
||||||
|
|
||||||
bool isMacVerified = false;
|
bool isMacVerified = false;
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,18 @@ TimelineViewManager::verifyUser(QString userid)
|
||||||
tr("No share room with this user found. Create an "
|
tr("No share room with this user found. Create an "
|
||||||
"encrypted room with this user and try again."));
|
"encrypted room with this user and try again."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimelineViewManager::removeVerificationFlow(DeviceVerificationFlow *flow)
|
||||||
|
{
|
||||||
|
for (auto it = dvList.keyValueBegin(); it != dvList.keyValueEnd(); ++it) {
|
||||||
|
if (it->second == flow) {
|
||||||
|
dvList.remove(it->first);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::verifyDevice(QString userid, QString deviceid)
|
TimelineViewManager::verifyDevice(QString userid, QString deviceid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
Q_INVOKABLE void openMemberListDialog() const;
|
Q_INVOKABLE void openMemberListDialog() const;
|
||||||
Q_INVOKABLE void openLeaveRoomDialog() const;
|
Q_INVOKABLE void openLeaveRoomDialog() const;
|
||||||
Q_INVOKABLE void openRoomSettings() const;
|
Q_INVOKABLE void openRoomSettings() const;
|
||||||
|
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
|
||||||
|
|
||||||
void verifyUser(QString userid);
|
void verifyUser(QString userid);
|
||||||
void verifyDevice(QString userid, QString deviceid);
|
void verifyDevice(QString userid, QString deviceid);
|
||||||
|
|
Loading…
Reference in a new issue