Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F62293983
D300.1775880004.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D300.1775880004.diff
View Options
diff --git a/src/contents/ui/device-mgmt/Device.qml b/src/contents/ui/device-mgmt/Device.qml
--- a/src/contents/ui/device-mgmt/Device.qml
+++ b/src/contents/ui/device-mgmt/Device.qml
@@ -9,11 +9,13 @@
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
+import '..' as Kazv
Kirigami.SwipeListItem {
id: device
property var item
property var userId
+ property bool sendingVerification: false
contentItem: RowLayout {
ColumnLayout {
@@ -136,9 +138,33 @@
onTriggered: {
popup.open();
}
+ },
+ Kirigami.Action {
+ objectName: 'requestVerifyAction'
+ text: l10n.get('device-verify-action')
+ enabled: !device.sendingVerification
+ icon.name: 'emblem-locked'
+ onTriggered: {
+ requestVerify.call();
+ }
}
]
+ property var requestVerify: Kazv.AsyncHandler {
+ trigger: () => {
+ device.sendingVerification = true;
+ return matrixSdk.requestVerifyDevice(userId, item.deviceId);
+ }
+ onResolved: (success, data) => {
+ device.sendingVerification = false;
+ if (success) {
+ pushVerificationsPage();
+ } else {
+ showPassiveNotification(l10n.get('device-verification-request-failed'));
+ }
+ }
+ }
+
function getTrustLevelIcon(level)
{
switch (level) {
diff --git a/src/l10n/cmn-Hans/100-ui.ftl b/src/l10n/cmn-Hans/100-ui.ftl
--- a/src/l10n/cmn-Hans/100-ui.ftl
+++ b/src/l10n/cmn-Hans/100-ui.ftl
@@ -339,6 +339,7 @@
device-set-trust-level-dialog-curve25519-key-label = Curve25519公钥:{ $key }
device-set-trust-level-dialog-save = 保存
device-set-trust-level-dialog-cancel = 取消
+device-verification-request-failed = 无法发送验证请求。错误码:{ $errorCode }。错误讯息:{ $errorMsg }。
settings-page-title = 设置
settings-save = 保存设置
diff --git a/src/l10n/en/100-ui.ftl b/src/l10n/en/100-ui.ftl
--- a/src/l10n/en/100-ui.ftl
+++ b/src/l10n/en/100-ui.ftl
@@ -361,6 +361,7 @@
device-set-trust-level-dialog-curve25519-key-label = Curve25519 public key: { $key }
device-set-trust-level-dialog-save = Save
device-set-trust-level-dialog-cancel = Cancel
+device-verification-request-failed = Unable to send verification request. Error code: { $errorCode }. Error message: { $errorMsg }.
settings-page-title = Settings
settings-save = Save settings
diff --git a/src/matrix-sdk.hpp b/src/matrix-sdk.hpp
--- a/src/matrix-sdk.hpp
+++ b/src/matrix-sdk.hpp
@@ -374,6 +374,14 @@
*/
MatrixPromise *importFromKeyBackupFile(QUrl fileUrl, QString password);
+ /**
+ * Send an outbound device verification request.
+ *
+ * @param userId The user id of the device to verify.
+ * @param deviceId The device id of the device to verify.
+ */
+ MatrixPromise *requestVerifyDevice(QString userId, QString deviceId);
+
private:
MatrixPromise *sendAccountDataImpl(Kazv::Event event);
diff --git a/src/matrix-sdk.cpp b/src/matrix-sdk.cpp
--- a/src/matrix-sdk.cpp
+++ b/src/matrix-sdk.cpp
@@ -1218,6 +1218,14 @@
));
}
+MatrixPromise *MatrixSdk::requestVerifyDevice(QString userId, QString deviceId)
+{
+ return new MatrixPromise(m_d->clientOnSecondaryRoot.requestOutgoingToDeviceVerification(
+ std::move(userId).toStdString(),
+ std::move(deviceId).toStdString()
+ ));
+}
+
void MatrixSdk::setUserDataDir(const std::string &userDataDir)
{
m_d->userDataDir = userDataDir;
diff --git a/src/tests/quick-tests/test-helpers/MatrixSdkMock.qml b/src/tests/quick-tests/test-helpers/MatrixSdkMock.qml
--- a/src/tests/quick-tests/test-helpers/MatrixSdkMock.qml
+++ b/src/tests/quick-tests/test-helpers/MatrixSdkMock.qml
@@ -39,6 +39,10 @@
'fileUrl',
'password',
])
+ property var requestVerifyDevice: mockHelper.promise([
+ 'userId',
+ 'deviceId',
+ ])
property var sessions: []
diff --git a/src/tests/quick-tests/tst_Device.qml b/src/tests/quick-tests/tst_Device.qml
--- a/src/tests/quick-tests/tst_Device.qml
+++ b/src/tests/quick-tests/tst_Device.qml
@@ -11,12 +11,15 @@
import 'test-helpers' as QmlHelpers
QmlHelpers.TestItem {
+ id: item
property var deviceItem: ({
deviceId: 'some-id',
displayName: 'name',
trustLevel: 'unseen'
})
+ property var pushVerificationsPage: mockHelper.noop();
+
KazvDM.Device {
id: device
}
@@ -30,9 +33,37 @@
device.item = deviceItem;
}
+ function init() {
+ item.mockHelper.clearAll();
+ }
+
function test_device() {
verify(findChild(device, 'deviceIdLabel').text === 'some-id');
verify(findChild(device, 'trustLevelLabel').text === l10n.get('device-trust-level-unseen'));
}
+
+ function test_verifyRequest() {
+ const action = findChild(device, 'requestVerifyAction');
+ verify(action.enabled);
+ action.trigger();
+ verify(!action.enabled);
+ verify(item.pushVerificationsPage.calledTimes() == 0);
+ verify(device.sendingVerification);
+ item.matrixSdk.requestVerifyDevice.lastRetVal().resolve(true, {});
+ verify(item.pushVerificationsPage.calledTimes() == 1);
+ }
+
+ function test_verifyRequestFailed() {
+ const action = findChild(device, 'requestVerifyAction');
+ verify(action.enabled);
+ action.trigger();
+ verify(!action.enabled);
+ verify(item.pushVerificationsPage.calledTimes() == 0);
+ verify(device.sendingVerification);
+ item.matrixSdk.requestVerifyDevice.lastRetVal().resolve(false, {});
+ verify(item.pushVerificationsPage.calledTimes() == 0);
+ verify(action.enabled);
+ verify(item.showPassiveNotification.calledTimes() == 1);
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 10, 9:00 PM (13 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1308880
Default Alt Text
D300.1775880004.diff (5 KB)
Attached To
Mode
D300: Add action to send outbound verification request
Attached
Detach File
Event Timeline
Log In to Comment