From 27cf710009b50f92a6dc4844ff370f187afd45eb Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 21 Apr 2023 11:27:24 +0200 Subject: [PATCH] crypto-ffi: Use proc-macros for VerificationRequest methods --- bindings/matrix-sdk-crypto-ffi/src/olm.udl | 30 +------------------ .../matrix-sdk-crypto-ffi/src/verification.rs | 5 +++- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/src/olm.udl b/bindings/matrix-sdk-crypto-ffi/src/olm.udl index 4361387fc..0ae3ec019 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/olm.udl +++ b/bindings/matrix-sdk-crypto-ffi/src/olm.udl @@ -139,35 +139,7 @@ callback interface QrCodeListener { void on_change(QrCodeState state); }; -interface VerificationRequest { - string other_user_id(); - string? other_device_id(); - string flow_id(); - string? room_id(); - boolean we_started(); - boolean is_ready(); - boolean is_done(); - boolean is_passive(); - boolean is_cancelled(); - CancelInfo? cancel_info(); - - sequence? their_supported_methods(); - sequence? our_supported_methods(); - - OutgoingVerificationRequest? accept(sequence methods); - - [Throws=CryptoStoreError] - StartSasResult? start_sas_verification(); - - [Throws=CryptoStoreError] - QrCode? start_qr_verification(); - ScanResult? scan_qr_code([ByRef] string data); - - OutgoingVerificationRequest? cancel(); - - void set_changes_listener(VerificationRequestListener listener); - VerificationRequestState state(); -}; +interface VerificationRequest {}; [Enum] interface VerificationRequestState { diff --git a/bindings/matrix-sdk-crypto-ffi/src/verification.rs b/bindings/matrix-sdk-crypto-ffi/src/verification.rs index 3901ff753..17436c5e5 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/verification.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/verification.rs @@ -566,6 +566,7 @@ pub struct VerificationRequest { pub(crate) runtime: Handle, } +#[uniffi::export] impl VerificationRequest { /// The id of the other user that is participating in this verification /// request. @@ -712,7 +713,7 @@ impl VerificationRequest { /// /// * `data` - The data that was extracted from the scanned QR code as an /// base64 encoded string, without padding. - pub fn scan_qr_code(&self, data: &str) -> Option { + pub fn scan_qr_code(&self, data: String) -> Option { let data = STANDARD_NO_PAD.decode(data).ok()?; let data = QrVerificationData::from_bytes(data).ok()?; @@ -741,7 +742,9 @@ impl VerificationRequest { pub fn state(&self) -> VerificationRequestState { self.inner.state().into() } +} +impl VerificationRequest { async fn changes_listener( mut stream: impl Stream + std::marker::Unpin, listener: Box,