Commit Graph

867 Commits

Author SHA1 Message Date
Ivan Enderlin
08559b58b6 Merge branch 'main' into feat-ui-roomlist 2023-06-05 19:22:33 +02:00
Jonas Platte
e59562725d ui: Move gappy sync response handling out of FFI 2023-06-05 17:46:22 +02:00
Jonas Platte
3a5f83d9dc ffi: Include causes when stringifying anyhow::Error 2023-06-05 17:29:53 +02:00
Benjamin Bouvier
61c3a2a2c7 sliding sync: infer the storage key from the loop id and user id (#2008)
* sliding sync: infer the storage key from the loop id and user id
* chore: rename `sync_id` to `id`
* chore: check that the sliding sync id is less than 16 chars
* chore: rejigger the storage key creation logic

Now the prefix is visible only in the `format_storage_key_prefix` function, and other `format_storage_key` function will be based off that.

* chore: update sliding sync README with API updates and fix outdated information
* chore: clippy + fix test

Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-06-05 14:51:40 +00:00
Ivan Enderlin
537f95b683 feat(sdk): SlidingSync::get_rooms? are now async. 2023-06-02 20:59:26 +02:00
Benjamin Bouvier
28c8e5df71 feat(sdk): move bump_event_types to the list sub-request
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-06-01 18:57:45 +02:00
Ivan Enderlin
f5c950c54a fix(ffi): Update according to last commits. 2023-06-01 15:58:58 +02:00
Jonas Platte
3e2bc3a514 Drop matrix-sdk-sled 2023-06-01 12:06:35 +02:00
Damir Jelić
036d9bf261 Add a test to check that the backup decryption works 2023-06-01 09:31:31 +02:00
Ivan Enderlin
ae25ad557a Merge branch 'main' into fix-sdk-sliding-sync-drain-internal-channel 2023-05-31 17:34:48 +02:00
Jonas Platte
d27ae257ec ffi: Remove unnecessary Deref implementations 2023-05-31 17:32:46 +02:00
Ivan Enderlin
d0d23afa5c feat(sdk): Introduce SlidingSync::internal_channel_send_if_possible.
The only reason why a sender can fail to send a message is because there
is no receiver. In the current design of `SlidingSync`, there is only
one receiver active per sync-loop. Thus, calling `SlidingSync::add_list`
may fail if `sync` has not been started. Hence the need for a new
`internal_channel_send_if_possible` method which will never fail: it
will send a message is possible, otherwise it won't do anything.

This turns more functions infallible.
2023-05-31 16:53:03 +02:00
Ivan Enderlin
875f379035 feat(sdk): Change SlidingSync's internal channel to MPMC.
`tokio::sync::broadcast` is interesting as it's possible to
generate receivers per subscribers. Being able to do that allows
us to remove the new for an `AsyncLock` around the receiver in
`SlidingSync::internal_channel`, and it can even remove the need to hold
a receiver entirely!

Another improvement is that new receivers can't receive past messages,
so we no longer need to drain the internal channel.

Another improvement is that the sender' `send` method is synchronous!
Which helps to make many functions no longer `async`.
2023-05-31 16:41:50 +02:00
Benjamin Bouvier
4ca8d61c56 feat(ffi): expose set_sync_mode on the sliding sync list
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-30 17:20:05 +02:00
Benjamin Bouvier
ce9a079882 feat(sdk): use the builder pattern for the other sliding sync mode too
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-26 15:08:21 +02:00
Benjamin Bouvier
fa25e4d9fc sliding sync: Rejigger the range API (#1955)
* feat: introduce SlidingSyncSelectiveModeBuilder
* feat: get rid of `CannotModifyRanges` \o/
* chore: rustfmt
* chore: remove scope in test
* chore: move request generator update to its own mod, gets rid of `set_ranges`
* chore: add comments on the request generator methods
* chore: sink one range_end definition into the match arm that matters
* ffi: remove unused `add_range` method
* test: update incorrect test expectation
* chore: make clippy happy
* address first review comments
* review: don't reuse the ranges field for two things
* chore: use a builder pattern for sliding sync selective mode
* address review comments + CI

Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-26 13:40:46 +02:00
Jonas Platte
ebe97623aa Upgrade Ruma 2023-05-26 12:26:00 +02:00
Benjamin Bouvier
829eb30e7e chore: get rid of SlidingSync::reset_lists as it's unused
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-25 16:17:46 +02:00
Benjamin Bouvier
dbd491383f chore: get rid of SlidingSyncListBuilder::reset_ranges
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-25 16:17:46 +02:00
Jonas Platte
5197e263a0 Revert "bindings: Use native async support for latest_room_message"
This reverts commit 2660e7bcf1.
2023-05-25 13:33:43 +02:00
Benjamin Bouvier
b4c192509b chore: remove unused FFI add_common_extensions
Signed-off-by: Benjamin Bouvier <public@benj.me>
2023-05-25 11:26:32 +02:00
Damir Jelić
2e09bf63a6 Add a message id to our encrypted to-device events 2023-05-24 12:29:15 +02:00
Ivan Enderlin
17f4ba5c9b fix(sdk): Client::sliding_sync doesn't need to be async
fix(sdk): `Client::sliding_sync` doesn't need to be `async`
2023-05-24 12:26:33 +02:00
Ivan Enderlin
a2a1b35622 fix(sdk): Client::sliding_sync doesn't need to be async.
The `Client::sliding_sync` method was declared as async. However, it's
not necessary as everything happening here is sync.
2023-05-24 11:56:38 +02:00
Ivan Enderlin
b60a317174 feat(sdk): Implement SlidingSync::stop_sync
feat(sdk): Implement `SlidingSync::stop_sync`
2023-05-24 11:52:19 +02:00
Jonas Platte
ac106c7059 bindings: Use native async for SessionVerificationController 2023-05-24 11:31:33 +02:00
Jonas Platte
2660e7bcf1 bindings: Use native async support for latest_room_message 2023-05-24 11:31:33 +02:00
Jonas Platte
ffc8453c63 bindings: Use async-compat tokio runtime 2023-05-24 11:31:33 +02:00
Ivan Enderlin
415778d44d feat(ffi): Implement SlidingSync::stop_sync. 2023-05-24 09:03:03 +02:00
Ivan Enderlin
b8580b76f7 feat(sdk): Rename SlidingSync::stream to ::sync.
Because it doesn't start a stream, but a sync-loop.
2023-05-24 08:20:29 +02:00
Damir Jelić
c042e1e63c Disable automatic-key-forwarding for the matrix-sdk-ffi bindings
Not completely sure why disabling this didn't work the first time. The
feature is now disabled by default in the matrix-sdk-crypto crate.
2023-05-23 16:42:34 +02:00
Damir Jelić
e9c3aa1a2e Add a state for the VerificationRequest for when a request transitions
The `VerificationRequest` object is used to control the flow of the
verification but only up to a certain point.

Once we start handling of different specific verification flows (i.e.
SAS or QR code verification) the `VerificationRequest` object creates a
child object of the Verification type.

This patch adds a new `VerificationRequestState` variant called
`Transitioned` which holds the child verification object as associated
data.

This makes it much simpler to go through the whole verification flow by
allowing users to just listen to the `VerificationRequest::changes()`
method.
2023-05-23 16:10:05 +02:00
Florian Renaud
2cce236f4d feat(bindings): exposed set_name in Room 2023-05-22 17:58:14 +02:00
Jonas Platte
2f243bce55 Stop unconditionally enabling native-tls from matrix-sdk-ffi 2023-05-22 16:26:40 +02:00
Ivan Enderlin
d27754cb61 Replace the libolm backup encryption code with a native Rust version
Replace the libolm backup encryption code with a native Rust version
2023-05-22 14:56:21 +02:00
Damir Jelić
34aed2f939 Replace the libolm backup encryption code with a native Rust version
This patch removes our dependency to libolm completely. This should
allow WASM targets to use the backups_v1 feature of the
matrix-sdk-crypto crate as well.
2023-05-18 10:52:51 +02:00
Jonas Platte
f68fd6c7cf Use workspace dependencies for futures-core 2023-05-17 17:20:55 +02:00
Ivan Enderlin
51e6e80b3b feat(sdk): SlidingSyncMode has richer variants
feat(sdk): `SlidingSyncMode` has richer variants
2023-05-17 17:10:26 +02:00
Ivan Enderlin
1a60983e8f feat(ffi): Add SlidingSyncListBuilder::sync_mode_*.
This patch replaces `sync_mode` on `SlidingSyncListBuilder` by
`sync_mode_selective`, `sync_mode_paging` and `sync_mode_growing`, which
removes the need to use `SlidingSyncMode` directly.

This patch also removes `batch_size`, `room_limit` and `no_room_limit`
as it's now arguments of `sync_mode_paging` and `sync_mode_growing`.
2023-05-17 15:18:51 +02:00
Ivan Enderlin
c618b03f12 feat(sdk): SlidingSync::add_list has an immediate effect
feat(sdk): `SlidingSync::add_list` has an immediate effect
2023-05-17 13:56:35 +02:00
Ivan Enderlin
39aba1dd95 fix(sdk): Rename SlidingSyncSubscribeResult to SlidingSyncAddTimelineListenerResult. 2023-05-17 13:13:17 +02:00
Ivan Enderlin
b85b585bd7 feat(ffi): Make some methods async.
`SlidingSync::subscribe`, `::unsubscribe` and `::add_list` are
now async. `subscribe` has been renamed to `subscribe_to_room` and
`unsubscribe` to `unsubscribe_from_room`.

`SlidingSyncRoom::subscribe_and_add_timeline_listener` has
been removed, and replaced by a new `::subscribe_to_room` and
`::unsubscribe_from_room` methods (the `::add_timeline_listener` method
already exists).

`TaskHandle::finalizer` is no longer necessary, thus this code has been
cleaned up.
2023-05-17 13:13:17 +02:00
Ivan Enderlin
63257e6226 fix(sdk): Remove room unsubscriptions once the server has received them
fix(sdk): Remove room unsubscriptions once the server has received them
2023-05-17 11:59:16 +02:00
Damir Jelić
1510576ce1 Expose the git description and commit hash in the crypto-ffi bindings
Co-authored-by: Jonas Platte <jplatte@matrix.org>
2023-05-17 09:31:52 +00:00
Ivan Enderlin
501b990248 chore(sdk): Rename SlidingSync::unsubscribe_to_room to …_from_room. 2023-05-17 11:29:26 +02:00
Ivan Enderlin
9b7122768f chore(sdk): Rename SlidingSync room subscriptions and unsubscriptions API.
Notably, this patch renames `SlidingSync::subscribe` and `::unsubscribe`
to `subscribe_to_room` and `unsubscribe_to_room`.
2023-05-17 10:01:55 +02:00
Jonas Platte
cfc8effa66 Move timeline API into a new crate
… aimed at interactive user interfaces.
2023-05-17 09:58:31 +02:00
Jonas Platte
c796302a98 ffi: Fix typo in variant name 2023-05-16 11:32:15 +02:00
Richard van der Hoff
6c0afae0f4 Merge remote-tracking branch 'origin/main' into release-matrix-sdk-crypto-js-0.1.0-alpha.9 2023-05-15 18:59:52 +01:00
Richard van der Hoff
923d425585 crypto-js: expose a constructor for SigningKeysUploadRequest (#1925)
... to help with testing.
2023-05-15 18:58:38 +01:00