From 12df1f38ed2aa5b71466279e101fbfa11b4fb2a6 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 15 Jun 2023 11:23:45 +0200 Subject: [PATCH] ffi: Remove remaining callback interfaces from UDL --- bindings/matrix-sdk-ffi/src/api.udl | 21 --------------------- bindings/matrix-sdk-ffi/src/client.rs | 4 +++- bindings/matrix-sdk-ffi/src/lib.rs | 2 +- bindings/matrix-sdk-ffi/src/notification.rs | 1 + 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/api.udl b/bindings/matrix-sdk-ffi/src/api.udl index 986f58987..7799ea481 100644 --- a/bindings/matrix-sdk-ffi/src/api.udl +++ b/bindings/matrix-sdk-ffi/src/api.udl @@ -1,26 +1,5 @@ namespace matrix_sdk_ffi {}; -callback interface ClientDelegate { - void did_receive_auth_error(boolean is_soft_logout); -}; - -callback interface NotificationDelegate { - void did_receive_notification(NotificationItem notification); -}; - -dictionary NotificationItem { - TimelineEvent event; - string room_id; - string? sender_display_name; - string? sender_avatar_url; - string room_display_name; - string? room_avatar_url; - string? room_canonical_alias; - boolean is_noisy; - boolean is_direct; - boolean? is_encrypted; -}; - interface TimelineEvent {}; enum SlidingSyncState { diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 72696a2ee..22a2826a6 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -36,7 +36,7 @@ use tracing::{debug, error, warn}; use url::Url; use super::{room::Room, session_verification::SessionVerificationController, RUNTIME}; -use crate::{client, ClientError, NotificationItem}; +use crate::{client, notification::NotificationItem, ClientError}; #[derive(Clone, uniffi::Record)] pub struct PusherIdentifiers { @@ -98,10 +98,12 @@ impl From for RumaPushFormat { } } +#[uniffi::export(callback_interface)] pub trait ClientDelegate: Sync + Send { fn did_receive_auth_error(&self, is_soft_logout: bool); } +#[uniffi::export(callback_interface)] pub trait NotificationDelegate: Sync + Send { fn did_receive_notification(&self, notification: NotificationItem); } diff --git a/bindings/matrix-sdk-ffi/src/lib.rs b/bindings/matrix-sdk-ffi/src/lib.rs index 297ef4ba3..4b3ab9072 100644 --- a/bindings/matrix-sdk-ffi/src/lib.rs +++ b/bindings/matrix-sdk-ffi/src/lib.rs @@ -44,7 +44,7 @@ use matrix_sdk::{ }; use self::{ - client::*, error::ClientError, event::*, notification::*, platform::*, session_verification::*, + client::*, error::ClientError, event::*, platform::*, session_verification::*, task_handle::TaskHandle, timeline::MediaSourceExt, }; diff --git a/bindings/matrix-sdk-ffi/src/notification.rs b/bindings/matrix-sdk-ffi/src/notification.rs index 76dd2d113..686406304 100644 --- a/bindings/matrix-sdk-ffi/src/notification.rs +++ b/bindings/matrix-sdk-ffi/src/notification.rs @@ -8,6 +8,7 @@ use ruma::{ use crate::event::TimelineEvent; +#[derive(uniffi::Record)] pub struct NotificationItem { pub event: Arc, pub room_id: String,