diff --git a/Cargo.lock b/Cargo.lock index ab79b39ae..b7cc44ad3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2978,6 +2978,8 @@ dependencies = [ "futures-util", "log-panics", "matrix-sdk", + "matrix-sdk-sled", + "matrix-sdk-sqlite", "mime", "once_cell", "opentelemetry", diff --git a/bindings/matrix-sdk-ffi/Cargo.toml b/bindings/matrix-sdk-ffi/Cargo.toml index 8dec0adf4..3482e941a 100644 --- a/bindings/matrix-sdk-ffi/Cargo.toml +++ b/bindings/matrix-sdk-ffi/Cargo.toml @@ -23,6 +23,8 @@ eyeball-im = { workspace = true } extension-trait = "1.0.1" futures-core = "0.3.17" futures-util = { version = "0.3.17", default-features = false } +matrix-sdk-sqlite = { path = "../../crates/matrix-sdk-sqlite", features = ["crypto-store"] } +matrix-sdk-sled = { path = "../../crates/matrix-sdk-sled" } mime = "0.3.16" # FIXME: we currently can't feature flag anything in the api.udl, therefore we must enforce experimental-sliding-sync being exposed here.. # see https://github.com/matrix-org/matrix-rust-sdk/issues/1014 @@ -59,7 +61,6 @@ features = [ "experimental-timeline", "e2e-encryption", "markdown", - "sled", "socks", "rustls-tls", ] @@ -74,6 +75,5 @@ features = [ "e2e-encryption", "markdown", "native-tls", - "sled", "socks", ] diff --git a/bindings/matrix-sdk-ffi/src/client_builder.rs b/bindings/matrix-sdk-ffi/src/client_builder.rs index 3200c7e03..ca77642a6 100644 --- a/bindings/matrix-sdk-ffi/src/client_builder.rs +++ b/bindings/matrix-sdk-ffi/src/client_builder.rs @@ -2,6 +2,7 @@ use std::{fs, path::PathBuf, sync::Arc}; use anyhow::anyhow; use matrix_sdk::{ + config::StoreConfig, ruma::{ api::{error::UnknownVersionError, MatrixVersion}, ServerName, UserId, @@ -102,7 +103,24 @@ impl ClientBuilder { let data_path = PathBuf::from(base_path).join(sanitize(username)); fs::create_dir_all(&data_path)?; - inner_builder = inner_builder.sled_store(data_path, builder.passphrase.as_deref()); + let mut state_store = + matrix_sdk_sled::SledStateStore::builder().path(data_path.to_owned()); + + if let Some(passphrase) = builder.passphrase.as_deref() { + state_store = state_store.passphrase(passphrase.to_owned()); + } + + let state_store = state_store.build()?; + + let crypto_store = RUNTIME.block_on(matrix_sdk_sqlite::SqliteCryptoStore::open( + &data_path, + builder.passphrase.as_deref(), + ))?; + + let store_config = + StoreConfig::new().state_store(state_store).crypto_store(crypto_store); + + inner_builder = inner_builder.store_config(store_config) } // Determine server either from URL, server name or user ID.