mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-09 16:34:32 -04:00
chore(FFI): update bindings for changes to the NotificationClient builder
This commit is contained in:
@@ -32,6 +32,7 @@ use matrix_sdk::{
|
||||
},
|
||||
AuthApi, AuthSession, Client as MatrixClient, SessionChange,
|
||||
};
|
||||
use matrix_sdk_ui::notification_client::NotificationProcessSetup as MatrixNotificationProcessSetup;
|
||||
use ruma::{
|
||||
api::client::discovery::discover_homeserver::AuthenticationServerInfo,
|
||||
push::{HttpPusherData as RumaHttpPusherData, PushFormat as RumaPushFormat},
|
||||
@@ -44,8 +45,11 @@ use url::Url;
|
||||
|
||||
use super::{room::Room, session_verification::SessionVerificationController, RUNTIME};
|
||||
use crate::{
|
||||
client, notification::NotificationClientBuilder, notification_settings::NotificationSettings,
|
||||
sync_service::SyncServiceBuilder, ClientError,
|
||||
client,
|
||||
notification::NotificationClientBuilder,
|
||||
notification_settings::NotificationSettings,
|
||||
sync_service::{SyncService, SyncServiceBuilder},
|
||||
ClientError,
|
||||
};
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
@@ -710,8 +714,11 @@ impl Client {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn notification_client(&self) -> Result<Arc<NotificationClientBuilder>, ClientError> {
|
||||
NotificationClientBuilder::new(self.inner.clone())
|
||||
pub fn notification_client(
|
||||
&self,
|
||||
process_setup: NotificationProcessSetup,
|
||||
) -> Result<Arc<NotificationClientBuilder>, ClientError> {
|
||||
NotificationClientBuilder::new(self.inner.clone(), process_setup.into())
|
||||
}
|
||||
|
||||
pub fn sync_service(&self) -> Arc<SyncServiceBuilder> {
|
||||
@@ -728,6 +735,27 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(uniffi::Enum)]
|
||||
pub enum NotificationProcessSetup {
|
||||
MultipleProcesses,
|
||||
SingleProcess { sync_service: Arc<SyncService> },
|
||||
}
|
||||
|
||||
impl From<NotificationProcessSetup> for MatrixNotificationProcessSetup {
|
||||
fn from(value: NotificationProcessSetup) -> Self {
|
||||
match value {
|
||||
NotificationProcessSetup::MultipleProcesses => {
|
||||
MatrixNotificationProcessSetup::MultipleProcesses
|
||||
}
|
||||
NotificationProcessSetup::SingleProcess { sync_service } => {
|
||||
MatrixNotificationProcessSetup::SingleProcess {
|
||||
sync_service: sync_service.inner.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(uniffi::Record)]
|
||||
pub struct SearchUsersResults {
|
||||
pub results: Vec<UserProfile>,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use matrix_sdk_ui::notification_client::{
|
||||
NotificationClient as MatrixNotificationClient,
|
||||
NotificationClientBuilder as MatrixNotificationClientBuilder,
|
||||
NotificationItem as MatrixNotificationItem,
|
||||
NotificationItem as MatrixNotificationItem, NotificationProcessSetup,
|
||||
};
|
||||
use ruma::{EventId, RoomId};
|
||||
|
||||
@@ -80,9 +80,12 @@ pub struct NotificationClientBuilder {
|
||||
}
|
||||
|
||||
impl NotificationClientBuilder {
|
||||
pub(crate) fn new(client: matrix_sdk::Client) -> Result<Arc<Self>, ClientError> {
|
||||
let builder =
|
||||
RUNTIME.block_on(async { MatrixNotificationClient::builder(client).await })?;
|
||||
pub(crate) fn new(
|
||||
client: matrix_sdk::Client,
|
||||
process_setup: NotificationProcessSetup,
|
||||
) -> Result<Arc<Self>, ClientError> {
|
||||
let builder = RUNTIME
|
||||
.block_on(async { MatrixNotificationClient::builder(client, process_setup).await })?;
|
||||
Ok(Arc::new(Self { builder }))
|
||||
}
|
||||
}
|
||||
@@ -99,14 +102,9 @@ impl NotificationClientBuilder {
|
||||
|
||||
/// Automatically retry decryption once, if the notification was received
|
||||
/// encrypted.
|
||||
///
|
||||
/// The boolean indicates whether we're making use of a cross-process lock
|
||||
/// for the crypto-store. This should be set to true, if and only if,
|
||||
/// the notification is received in a process that's different from the
|
||||
/// main app.
|
||||
pub fn retry_decryption(self: Arc<Self>, with_cross_process_lock: bool) -> Arc<Self> {
|
||||
pub fn retry_decryption(self: Arc<Self>) -> Arc<Self> {
|
||||
let this = unwrap_or_clone_arc(self);
|
||||
let builder = this.builder.retry_decryption(with_cross_process_lock);
|
||||
let builder = this.builder.retry_decryption();
|
||||
Arc::new(Self { builder })
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ pub trait SyncServiceStateObserver: Send + Sync + Debug {
|
||||
|
||||
#[derive(uniffi::Object)]
|
||||
pub struct SyncService {
|
||||
inner: MatrixSyncService,
|
||||
pub(crate) inner: Arc<MatrixSyncService>,
|
||||
}
|
||||
|
||||
#[uniffi::export(async_runtime = "tokio")]
|
||||
@@ -107,6 +107,6 @@ impl SyncServiceBuilder {
|
||||
|
||||
pub async fn finish(self: Arc<Self>) -> Result<Arc<SyncService>, ClientError> {
|
||||
let this = unwrap_or_clone_arc(self);
|
||||
Ok(Arc::new(SyncService { inner: this.builder.build().await? }))
|
||||
Ok(Arc::new(SyncService { inner: Arc::new(this.builder.build().await?) }))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user