Add account / device security settings page
This commit is contained in:
@@ -286,6 +286,7 @@ qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN
|
|||||||
qml/SpaceHierarchyDelegate.qml
|
qml/SpaceHierarchyDelegate.qml
|
||||||
qml/RemoveChildDialog.qml
|
qml/RemoveChildDialog.qml
|
||||||
qml/SelectParentDialog.qml
|
qml/SelectParentDialog.qml
|
||||||
|
qml/Security.qml
|
||||||
RESOURCES
|
RESOURCES
|
||||||
qml/confetti.png
|
qml/confetti.png
|
||||||
qml/glowdot.png
|
qml/glowdot.png
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <Quotient/csapi/content-repo.h>
|
#include <Quotient/csapi/content-repo.h>
|
||||||
#include <Quotient/csapi/profile.h>
|
#include <Quotient/csapi/profile.h>
|
||||||
|
#include <Quotient/database.h>
|
||||||
#include <Quotient/qt_connection_util.h>
|
#include <Quotient/qt_connection_util.h>
|
||||||
#include <Quotient/settings.h>
|
#include <Quotient/settings.h>
|
||||||
#include <Quotient/user.h>
|
#include <Quotient/user.h>
|
||||||
@@ -234,4 +235,21 @@ void NeoChatConnection::openOrCreateDirectChat(User *user)
|
|||||||
requestDirectChat(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"
|
#include "moc_neochatconnection.cpp"
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class NeoChatConnection : public Quotient::Connection
|
|||||||
* Set to an empty string to remove the label.
|
* Set to an empty string to remove the label.
|
||||||
*/
|
*/
|
||||||
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
|
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:
|
public:
|
||||||
NeoChatConnection(QObject *parent = nullptr);
|
NeoChatConnection(QObject *parent = nullptr);
|
||||||
@@ -68,6 +70,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE void openOrCreateDirectChat(Quotient::User *user);
|
Q_INVOKABLE void openOrCreateDirectChat(Quotient::User *user);
|
||||||
|
|
||||||
|
QString deviceKey() const;
|
||||||
|
QString encryptionKey() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void labelChanged();
|
void labelChanged();
|
||||||
};
|
};
|
||||||
|
|||||||
36
src/qml/Security.qml
Normal file
36
src/qml/Security.qml
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,17 @@ KirigamiSettings.CategorizedSettings {
|
|||||||
icon.name: "preferences-desktop-notification"
|
icon.name: "preferences-desktop-notification"
|
||||||
page: Qt.resolvedUrl("GlobalNotificationsPage.qml")
|
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 {
|
KirigamiSettings.SettingAction {
|
||||||
actionName: "accounts"
|
actionName: "accounts"
|
||||||
text: i18n("Accounts")
|
text: i18n("Accounts")
|
||||||
|
|||||||
Reference in New Issue
Block a user