From fd8725f649f822f4b94798352f24130f0417ddfc Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Mon, 6 May 2024 21:12:54 +0200 Subject: [PATCH] Add basic cross-signing support (cherry picked from commit e1795076c8c41a34b91c31df35d1e344d0b14887) --- src/controller.cpp | 9 +++++++++ src/controller.h | 2 ++ src/qml/AccountMenu.qml | 6 ++++++ src/qml/DirectChatDrawerHeader.qml | 27 +++++++++++++++++++++------ src/qml/RoomInformation.qml | 10 ++++++++++ 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 62698e0ed..30b981236 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -417,3 +417,12 @@ bool Controller::ssssSupported() const return false; #endif } + +bool Controller::csSupported() const +{ +#if Quotient_VERSION_MINOR > 9 + return true; +#else + return false; +#endif +} diff --git a/src/controller.h b/src/controller.h index d48bf52fe..6b1d4122c 100644 --- a/src/controller.h +++ b/src/controller.h @@ -51,6 +51,7 @@ class Controller : public QObject Q_PROPERTY(QStringList accountsLoading MEMBER m_accountsLoading NOTIFY accountsLoadingChanged) Q_PROPERTY(bool ssssSupported READ ssssSupported CONSTANT) + Q_PROPERTY(bool csSupported READ csSupported CONSTANT) public: static Controller &instance(); @@ -97,6 +98,7 @@ public: Q_INVOKABLE void removeConnection(const QString &userId); bool ssssSupported() const; + bool csSupported() const; private: explicit Controller(QObject *parent = nullptr); diff --git a/src/qml/AccountMenu.qml b/src/qml/AccountMenu.qml index 7ae7edf29..214485898 100644 --- a/src/qml/AccountMenu.qml +++ b/src/qml/AccountMenu.qml @@ -72,6 +72,12 @@ QQC2.Menu { }) enabled: Controller.ssssSupported } + QQC2.MenuItem { + text: i18nc("@action:inmenu", "Verify this Device") + icon.name: "security-low" + onTriggered: root.connection.startSelfVerification() + enabled: Controller.csSupported + } QQC2.MenuItem { text: i18n("Logout") icon.name: "list-remove-user" diff --git a/src/qml/DirectChatDrawerHeader.qml b/src/qml/DirectChatDrawerHeader.qml index 471f3e9d2..04a046929 100644 --- a/src/qml/DirectChatDrawerHeader.qml +++ b/src/qml/DirectChatDrawerHeader.qml @@ -59,12 +59,27 @@ ColumnLayout { } } - Kirigami.Heading { + RowLayout { Layout.fillWidth: true - type: Kirigami.Heading.Type.Primary - wrapMode: QQC2.Label.Wrap - text: root.room.displayName - textFormat: Text.PlainText - horizontalAlignment: Text.AlignHCenter + Layout.alignment: Qt.AlignHCenter + Kirigami.Icon { + id: securityIcon + //TODO figure out how to make this update + source: room.connection.isUserVerified(root.room.directChatRemoteMember.id) ? + (room.connection.allSessionsSelfVerified(root.room.directChatRemoteMember.id) ? "security-high" : "security-medium") + : "security-low" + + } + Kirigami.Heading { + type: Kirigami.Heading.Type.Primary + wrapMode: QQC2.Label.Wrap + text: root.room.displayName + textFormat: Text.PlainText + horizontalAlignment: Text.AlignHCenter + } + Item { + Layout.preferredWidth: visible ? securityIcon.width : 0 + visible: securityIcon.visible + } } } diff --git a/src/qml/RoomInformation.qml b/src/qml/RoomInformation.qml index e0ab4de59..23449bad9 100644 --- a/src/qml/RoomInformation.qml +++ b/src/qml/RoomInformation.qml @@ -89,6 +89,16 @@ QQC2.ScrollView { } } + Delegates.RoundedItemDelegate { + visible: root.room.isDirectChat() && Controller.csSupported + icon.name: "security-low-symbolic" + text: i18nc("@action:button", "Verify user") + + onClicked: root.room.startVerification() + + Layout.fillWidth: true + } + Delegates.RoundedItemDelegate { id: favouriteButton visible: !root.room.isSpace