From 457c5f4fa332ea943658890f1cf670c1f5609d2c Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Thu, 17 Nov 2022 11:24:39 +0000 Subject: [PATCH] Add cancel methods and rename callback method --- bindings/matrix-sdk-crypto-ffi/src/olm.udl | 7 ++++++- .../matrix-sdk-crypto-ffi/src/verification.rs | 20 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/src/olm.udl b/bindings/matrix-sdk-crypto-ffi/src/olm.udl index cacae3dce..55226d36f 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/olm.udl +++ b/bindings/matrix-sdk-crypto-ffi/src/olm.udl @@ -162,7 +162,7 @@ interface Sas { sequence? get_emoji_indices(); sequence? get_decimals(); - void changes(SasListener callback); + void set_changes_listener(SasListener callback); SasState state(); }; @@ -192,6 +192,7 @@ interface QrCode { string? room_id(); boolean we_started(); boolean is_done(); + boolean is_cancelled(); CancelInfo? cancel_info(); boolean reciprocated(); @@ -211,6 +212,8 @@ interface VerificationRequest { boolean is_ready(); boolean is_done(); boolean is_passive(); + boolean is_cancelled(); + CancelInfo? cancel_info(); sequence? their_supported_methods(); sequence? our_supported_methods(); @@ -223,6 +226,8 @@ interface VerificationRequest { [Throws=CryptoStoreError] QrCode? start_qr_verification(); ScanResult? scan_qr_code([ByRef] string data); + + OutgoingVerificationRequest? cancel(); }; dictionary RequestVerificationResult { diff --git a/bindings/matrix-sdk-crypto-ffi/src/verification.rs b/bindings/matrix-sdk-crypto-ffi/src/verification.rs index 5a8bf2250..1d9530da5 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/verification.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/verification.rs @@ -194,7 +194,7 @@ impl Sas { self.inner.decimals().map(|v| [v.0.into(), v.1.into(), v.2.into()].to_vec()) } - /// Listen for changes in the SAS verification process. + /// Set a listener for changes in the SAS verification process. /// /// The given callback will be called whenever the state changes. /// @@ -239,7 +239,7 @@ impl Sas { /// │ Done │ /// └───────┘ /// ``` - pub fn changes(&self, callback: Box) { + pub fn set_changes_listener(&self, callback: Box) { let stream = self.inner.changes(); self.runtime.spawn(Self::changes_callback(stream, callback)); @@ -302,6 +302,11 @@ impl QrCode { self.inner.is_done() } + /// Has the verification flow been cancelled. + pub fn is_cancelled(&self) -> bool { + self.inner.is_cancelled() + } + /// Did we initiate the verification flow. pub fn we_started(&self) -> bool { self.inner.we_started() @@ -469,6 +474,17 @@ impl VerificationRequest { self.inner.is_passive() } + /// Has the verification flow that been cancelled. + pub fn is_cancelled(&self) -> bool { + self.inner.is_cancelled() + } + + /// Get info about the cancellation if the verification request has been + /// cancelled. + pub fn cancel_info(&self) -> Option { + self.inner.cancel_info().map(|v| v.into()) + } + /// Get the supported verification methods of the other side. /// /// Will be present only if the other side requested the verification or if