diff --git a/bindings/matrix-sdk-ffi/src/authentication_service.rs b/bindings/matrix-sdk-ffi/src/authentication_service.rs index 916ccbe96..544767856 100644 --- a/bindings/matrix-sdk-ffi/src/authentication_service.rs +++ b/bindings/matrix-sdk-ffi/src/authentication_service.rs @@ -591,6 +591,12 @@ impl AuthenticationService { .passphrase(self.passphrase.clone()) .homeserver_url(homeserver_url) .sliding_sync_proxy(sliding_sync_proxy) + .with_encryption_settings(matrix_sdk::encryption::EncryptionSettings { + auto_enable_cross_signing: true, + backup_download_strategy: + matrix_sdk::encryption::BackupDownloadStrategy::AfterDecryptionFailure, + auto_enable_backups: true, + }) .username(user_id.to_string()); if let Some(id) = &self.cross_process_refresh_lock_id { diff --git a/bindings/matrix-sdk-ffi/src/client_builder.rs b/bindings/matrix-sdk-ffi/src/client_builder.rs index 1326736d1..0dbe2d6e7 100644 --- a/bindings/matrix-sdk-ffi/src/client_builder.rs +++ b/bindings/matrix-sdk-ffi/src/client_builder.rs @@ -1,7 +1,7 @@ use std::{fs, path::PathBuf, sync::Arc}; use matrix_sdk::{ - encryption::{BackupDownloadStrategy, EncryptionSettings}, + encryption::EncryptionSettings, ruma::{ api::{error::UnknownVersionError, MatrixVersion}, ServerName, UserId, @@ -43,7 +43,22 @@ pub struct ClientBuilder { impl ClientBuilder { #[uniffi::constructor] pub fn new() -> Arc { - Arc::new(Self::default()) + Arc::new(Self { + base_path: None, + username: None, + server_name: None, + homeserver_url: None, + server_versions: None, + passphrase: Zeroizing::new(None), + user_agent: None, + sliding_sync_proxy: None, + proxy: None, + disable_ssl_verification: false, + disable_automatic_token_refresh: false, + inner: MatrixClient::builder(), + cross_process_refresh_lock_id: None, + session_delegate: None, + }) } pub fn enable_cross_process_refresh_lock( @@ -136,6 +151,15 @@ impl ClientBuilder { } impl ClientBuilder { + pub(crate) fn with_encryption_settings( + self: Arc, + settings: EncryptionSettings, + ) -> Arc { + let mut builder = unwrap_or_clone_arc(self); + builder.inner = builder.inner.with_encryption_settings(settings); + Arc::new(builder) + } + pub(crate) fn enable_cross_process_refresh_lock_inner( self: Arc, process_id: String, @@ -247,31 +271,3 @@ impl ClientBuilder { )?) } } - -impl Default for ClientBuilder { - fn default() -> Self { - let encryption_settings = EncryptionSettings { - auto_enable_cross_signing: true, - auto_enable_backups: true, - backup_download_strategy: BackupDownloadStrategy::AfterDecryptionFailure, - }; - let inner = MatrixClient::builder().with_encryption_settings(encryption_settings); - - Self { - base_path: None, - username: None, - server_name: None, - homeserver_url: None, - server_versions: None, - passphrase: Zeroizing::new(None), - user_agent: None, - sliding_sync_proxy: None, - proxy: None, - disable_ssl_verification: false, - disable_automatic_token_refresh: false, - inner, - cross_process_refresh_lock_id: None, - session_delegate: None, - } - } -}