Add account / device security settings page

This commit is contained in:
Tobias Fella
2023-10-30 20:20:55 +01:00
parent 4033f07272
commit 8af20885ab
5 changed files with 71 additions and 0 deletions

View File

@@ -286,6 +286,7 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
qml/SpaceHierarchyDelegate.qml
qml/RemoveChildDialog.qml
qml/SelectParentDialog.qml
qml/Security.qml
RESOURCES
qml/confetti.png
qml/glowdot.png

View File

@@ -16,6 +16,7 @@
#include <Quotient/csapi/content-repo.h>
#include <Quotient/csapi/profile.h>
#include <Quotient/database.h>
#include <Quotient/qt_connection_util.h>
#include <Quotient/settings.h>
#include <Quotient/user.h>
@@ -234,4 +235,21 @@ void NeoChatConnection::openOrCreateDirectChat(User *user)
requestDirectChat(user);
}
QString NeoChatConnection::deviceKey() const
{
return edKeyForUserDevice(userId(), deviceId());
}
QString NeoChatConnection::encryptionKey() const
{
auto query = database()->prepareQuery(QStringLiteral("SELECT curveKey FROM tracked_devices WHERE matrixId=:matrixId AND deviceid=:deviceId LIMIT 1;"));
query.bindValue(QStringLiteral(":matrixId"), userId());
query.bindValue(QStringLiteral(":deviceId"), deviceId());
database()->execute(query);
if (!query.next()) {
return {};
}
return query.value(0).toString();
}
#include "moc_neochatconnection.cpp"

View File

@@ -23,6 +23,8 @@ class NeoChatConnection : public Quotient::Connection
* Set to an empty string to remove the label.
*/
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
Q_PROPERTY(QString deviceKey READ deviceKey CONSTANT)
Q_PROPERTY(QString encryptionKey READ encryptionKey CONSTANT)
public:
NeoChatConnection(QObject *parent = nullptr);
@@ -68,6 +70,9 @@ public:
*/
Q_INVOKABLE void openOrCreateDirectChat(Quotient::User *user);
QString deviceKey() const;
QString encryptionKey() const;
Q_SIGNALS:
void labelChanged();
};

36
src/qml/Security.qml Normal file
View File

@@ -0,0 +1,36 @@
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick
import QtQuick.Controls
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.neochat
FormCard.FormCardPage {
id: root
required property NeoChatConnection connection
title: i18nc("@title", "Security")
FormCard.FormHeader {
title: i18nc("@title", "Keys")
}
FormCard.FormCard {
FormCard.FormTextDelegate {
text: connection.deviceKey
description: i18n("Device key")
}
FormCard.FormTextDelegate {
text: connection.encryptionKey
description: i18n("Encryption Key")
}
FormCard.FormTextDelegate {
text: connection.deviceId
description: i18n("Device id")
}
}
}

View File

@@ -33,6 +33,17 @@ KirigamiSettings.CategorizedSettings {
icon.name: "preferences-desktop-notification"
page: Qt.resolvedUrl("GlobalNotificationsPage.qml")
},
KirigamiSettings.SettingAction {
actionName: "security"
text: i18n("Security")
icon.name: "preferences-security"
page: Qt.resolvedUrl("Security.qml")
initialProperties: {
return {
connection: root.connection
}
}
},
KirigamiSettings.SettingAction {
actionName: "accounts"
text: i18n("Accounts")