Commit Graph

2058 Commits

Author SHA1 Message Date
Jonas Platte
2a140770a0 fix: Move runtime module from matrix-sdk-common to matrix-sdk-ffi (#5184)
This module only builds on non-wasm with the patched async-compat from
the workspace Cargo.toml's patch section, and it is only used by the ffi
crate. It is currently breaking the use of the SDK as a git dependency,
and would prevent the publishing of matrix-sdk-common (unless using
--no-verify, but then that would just break all users of the newly
published crates.io version).

This bug was introduced in
https://github.com/matrix-org/matrix-rust-sdk/pull/5089.

Signed-off-by: Jonas Platte <jplatte+matrix@posteo.de>
2025-06-05 19:30:15 +00:00
Jorge Martín
becbb63ad7 feat(ffi): Subscribe to a room's RoomInfo through Client
This helps in the case we want to observe the membership state changes - or some other info - for a room that's still not known so we can't just use `Client::get_room` to fetch it.
2025-06-05 16:49:39 +02:00
Johannes Marbach
b8ae210e4a feat(ffi): Add reply_params to GalleryUploadParameters (#5173)
Looks like I forgot adding this in
https://github.com/matrix-org/matrix-rust-sdk/pull/5163, sorry.
Everything below the FFI layer was already prepared for replies.

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2025-06-05 10:07:32 +01:00
Daniel Salinas
a3225e5cd7 feat(wasm): Wasm equivalent of get_runtime_handle and corresponding tokio types (#5089)
Adds a Wasm equivalent of the get_runtime_handle method provided by
tokio, as well as Handle/Runtime types that can be used on either Wasm
or non-Wasm platforms interchangeably.

Dependent on https://github.com/matrix-org/matrix-rust-sdk/pull/5088
<!-- description of the changes in this PR -->

- [ ] Public API changes documented in changelogs (optional)

<!-- Sign-off, if not part of the commits -->
<!-- See CONTRIBUTING.md if you don't know what this is -->
Signed-off-by: Daniel Salinas

---------

Signed-off-by: Daniel Salinas <zzorba@users.noreply.github.com>
Co-authored-by: Daniel Salinas <danielsalinas@Daniels-MacBook-Pro-2.local>
Co-authored-by: Daniel Salinas <danielsalinas@daniels-mbp-2.myfiosgateway.com>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2025-06-05 08:07:01 +02:00
Johannes Marbach
d38f409351 feat(ffi): Expose method for sending galleries (#5163)
Addendum to https://github.com/matrix-org/matrix-rust-sdk/pull/5125 to
allow sending galleries from the FFI crate. This is the final PR for
galleries (apart from possible enhancements to report the upload status
in https://github.com/matrix-org/matrix-rust-sdk/pull/5008).

This is somewhat lengthy again, apologies. Most of the changes are just
wrappers and type mapping, however. So I was hoping that it's relatively
straightforward to review in bulk. Happy to try and elaborate on the
changes or break them up into smaller commits if that helps, however.

---------

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2025-06-04 16:41:03 +02:00
Daniel Salinas
58b8a2560c feat(wasm): Comprehensive Send+Sync bound improvements for Wasm compatibility (#5082)
This commit systematically replaces Send+Sync trait bounds throughout
the matrix-rust-sdk codebase to enable Wasm compatibility while
maintaining thread safety on native targets.

Key changes:
- Use SendOutsideWasm/SyncOutsideWasm traits instead of Send/Sync for
trait bounds
- Apply conditional compilation for error types and trait objects
- Update FFI trait definitions to use Wasm-compatible bounds
- Fix event handler and type alias definitions for cross-platform
compatibility
- Maintain existing functionality while enabling WebAssembly target
support

The SendOutsideWasm/SyncOutsideWasm traits are empty on Wasm (allowing
all types) and alias to Send/Sync on native targets, ensuring zero-cost
abstraction.

Files updated:
- All FFI bindings (30+ trait definitions)
- Core SDK error types and type aliases
- Event handler infrastructure
- Store and crypto abstractions
- UI service filters and sorters
- Timeline and authentication modules

<!-- description of the changes in this PR -->

- [ ] Public API changes documented in changelogs (optional)

<!-- Sign-off, if not part of the commits -->
<!-- See CONTRIBUTING.md if you don't know what this is -->
Signed-off-by: Daniel Salinas

---------

Signed-off-by: Daniel Salinas <zzorba@users.noreply.github.com>
Co-authored-by: Daniel Salinas <danielsalinas@Daniels-MacBook-Pro-2.local>
Co-authored-by: Daniel Salinas <danielsalinas@daniels-mbp-2.myfiosgateway.com>
2025-06-04 15:59:37 +02:00
Daniel Salinas
edb7a0f433 Add Wasm platform aware test to export proc-macro 2025-06-04 12:32:33 +02:00
Valere Fedronic
0f73ffde68 feat(crypto): Add the EncryptionInfo to the Decrypted ProcessedToDeviceEvent variant
The `ProcessedToDeviceEvent::Decrypted` variant now also have an
`EncryptionInfo` field.

The enum variant  changed from `Decrypted(Raw<AnyToDeviceEvent>)` to `Decrypted {
raw: Raw<AnyToDeviceEvent>, encryption_info: EncryptionInfo) }`
2025-06-04 11:54:38 +02:00
Andy Balaam
ca63d60068 doc(crypto): Add missing word 'verify' in 'verify_device' docs 2025-06-03 17:04:48 +02:00
Benjamin Bouvier
281faa7a0b refactor(ffi): simplify From<TimelineDetails<Profile>> for ProfileDetails 2025-06-03 16:28:25 +02:00
Benjamin Bouvier
7962253ebd refactor(timeline): only use the publicly exposed content/sender/sender_profile on EmbeddedEvent 2025-06-03 16:28:25 +02:00
Benjamin Bouvier
dd14df086e refactor(ffi): simplify FFI layer and use only EmbeddedEventDetails there for both thread latest event + replied-to event item 2025-06-03 16:28:25 +02:00
Benjamin Bouvier
c426138971 refactor(timeline): rename RepliedToEvent to EmbeddedEvent and reuse it for the thread summary 2025-06-03 16:28:25 +02:00
Benjamin Bouvier
aa291079d0 feat(event cache): include the reply count in the ThreadSummary 2025-06-03 16:28:25 +02:00
Johannes Marbach
ee06965d2e feat(timeline): Expose method to send galleries in matrix-sdk-ui (#5125)
This was broken out of
https://github.com/matrix-org/matrix-rust-sdk/pull/4838 and is a step
towards implementing
https://github.com/matrix-org/matrix-spec-proposals/pull/4274. Building
upon https://github.com/matrix-org/matrix-rust-sdk/pull/4977, a new
method `Timeline::send_gallery` in matrix-sdk-ui for sending galleries.

- [x] Public API changes documented in changelogs (optional)

---------

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2025-06-03 15:24:02 +02:00
Jorge Martín
edabb2362b refactor: revert some method removals in SendRequest 2025-06-03 12:59:00 +02:00
Jorge Martín
7d03d4ce0d feat(ffi): Add Client::get_max_media_upload_size function
This allows the clients to know the max upload size for a media file and try to compress if it's too large for the homeserver.
2025-06-03 12:59:00 +02:00
Richard van der Hoff
a1e2eed467 sdk: Add ClientBuilder::with_enable_share_history_on_invite (#5141)
Replace `experimental-share-history-on-invite` feature flag with a
runtime flag on the `Client`.
2025-06-03 11:36:48 +01:00
Daniel Salinas
0f877a3e80 feat(wasm): Replace async_trait with wasm aware cfg conditional 2025-06-02 23:07:05 +02:00
Daniel Salinas
ba8998623e Fix annotations on comments for new StreamExt
Hook up use of new extension in matrix-sdk-ffi crate
2025-06-02 12:26:52 +02:00
Jonas Platte
8eec683793 refactor: Use inline format arguments more
Automated with cargo clippy --fix --workspace --all-targets.
2025-05-29 13:19:59 +02:00
Jorge Martín
ed245a0cf0 refactor(ffi): When mapping ffi::StateEventContent, log any unsupported event types
The same was done for unsupported message-like event contents.
2025-05-29 09:54:39 +02:00
Jorge Martín
4626c4caaf refactor(ffi): When mapping ffi::MessageLikeEventContent, log any unsupported event types
At the moment, the logs just say 'Unsupported Event Type', which is not that helpful.
2025-05-29 09:54:39 +02:00
Ivan Enderlin
0f5f24527b chore(ffi): Remove Room::is_tombstoned.
This patch removes the `Room::is_tombstoned` method as using
`Room::successor_room` plays the same role and its returned value is
always useful.
2025-05-27 17:35:31 +02:00
Ivan Enderlin
da60c1488e feat(ffi): Add the DeduplicateVersions room list filter.
This patch adds `RoomListEntriesDynamicFilterKind::DeduplicateVersions`
to use `new_filter_deduplicate_versions`.
2025-05-27 17:35:31 +02:00
Ivan Enderlin
3e89b6b8f9 feat(ffi): Add SuccessorRoom and PredecessorRoom.
This patch removes `RoomTombstoneInfo` and replaces it by
`SuccessorRoom`. This patch renames `RoomInfo::tombstone` to
`RoomInfo::success_room`.

This patch also implements `Room::successor_room()` and
`Room::predecessor_room()`, and adds documentation.
2025-05-27 17:35:31 +02:00
Mauro
7531167824 feat: Let the media preview config return an optional
This allows applications to decide what they'd like to do if there isn't a value present. It allows the application to decide what the default should be.
2025-05-27 16:24:41 +02:00
Benjamin Bouvier
206857bc9e feat(ffi): remove the state store when clearing caches
This is a dangerous operation, and requires that the sync service must
be stopped while we're touching this. Since this is an internal method,
that shouldn't be used in most clients anyways (as it usually papers
over actual issues happening elsewhere, on the server for instance), I
kept it simple with a scary doc comment explaining the preconditions,
but we could assert them at runtime, with a little bit more effort.
2025-05-27 08:59:59 +02:00
Benjamin Bouvier
4a397f5ab4 refactor(ffi): pass the UTD hook when constructing a Room from the room list (again!) 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
be927730fa refactor(ffi): get rid of RoomListItem
It is simply a Room now.
2025-05-26 14:48:16 +02:00
Benjamin Bouvier
81036da44c refactor(ffi): rename the SDK Room import to SdkRoom 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
b016f60e46 refactor(ffi): move methods from RoomListItem to Room
Only code motion. Most methods already existed on the `Room` impl block.
2025-05-26 14:48:16 +02:00
Benjamin Bouvier
cd76cec089 refactor(ffi): also pass the UTD hook to the notification client 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
820c73dd2f refactor(ffi): get rid of the timeline stored in a Room 2025-05-26 14:48:16 +02:00
Benjamin Bouvier
42a4a6c1a8 refactor(ui): get rid of the RoomListService::Room wrapper
It's just a room, now! Since there were some users of the
`latest_event()` that returned an `EventTimelineItem`, I kept this
method as a method in the Room trait extension that's in the UI crate,
so it's still convenient to use.
2025-05-26 14:48:16 +02:00
Stefan Ceriu
f0c7370637 feat(ffi): expose the inviter directly on the room to avoid having to fetch the room preview
The room preview doesn't actually contain the inviter but instead retrieves it from the room invite details.
2025-05-24 10:49:44 +03:00
Ivan Enderlin
9c227c2321 feat(base): Add Room::successor_room and Room::predecessor_room.
First off, this patch renames `Room::tombstone` to
`Room::tombstone_content` (to be consistent with other methods, such as
`Room::create_content`).

Second, this patch adds the `Room::successor_room` and
`Room::predecessor_room` methods, along with the `SuccessorRoom` and
`PredecessorRoom` types. This naming more or less comes from the Matrix
specification:

- the term _predecessor_ is part of the specification,
- the term _successor_ isn't present _per se_, the words _replacement
  room_ are used instead, but I prefer _successor_ as it brings a nice
  symmetry with _predecessor_.
2025-05-23 11:35:53 +02:00
Jonas Platte
3aa356dcd6 chore: Use shorter syntax for workspace inheritance where possible 2025-05-23 10:23:36 +02:00
Jonas Platte
491f7cd529 chore: Clean up Cargo.toml formatting 2025-05-23 10:23:36 +02:00
Timo
6d5ad4eddc feat(widget-driver): Add to-device support
The widget Driver should be able to send and receive to-device events.
This is useful for element call encryption keys.

This PR focusses on the widget driver and machine logic. To
send/communicate the events from the widget to the driver.

It skips any encryption logic. Some of the encryption logic will be part
of crypto crate and the code in the widget driver crate should be kept
minimal once the crypto crate is ready.

---------

Co-authored-by: Valere <bill.carson@valrsoft.com>
2025-05-22 13:38:28 +02:00
Jorge Martín
fe8f77ed93 refactor: when leaving an Invited room also forget it
This behaviour was added only at the `RoomPreview::leave` method, but since we're slowly moving away from it we should move the forget action to the `Room::leave` method instead
2025-05-22 12:07:19 +02:00
Benjamin Bouvier
2984030f90 chore(ffi): configure the sentry dependency differently on android
On Android, we should use rustls instead of native-tls; this requires
unsetting the default features of the `sentry` crate, and specifying
them by hand instead.

For consistency, I've done the same for the non-android sentry
dependency.
2025-05-22 11:50:13 +02:00
Benjamin Bouvier
c8474511a7 feat(ffi): add support for sentry logging 2025-05-22 11:50:13 +02:00
Benjamin Bouvier
4a627baae8 feat(timeline): indicate when the replied-to event is not a standalone item
If the replied-to event is an aggregation, the
`RepliedToEvent::try_from_timeline_event` will now return `Ok(None)`,
and the caller may handle this as they please.

In the FFI layer, this will be filled with an error message indicating
that the event is unsupported.
2025-05-21 15:52:31 +02:00
Benjamin Bouvier
560e33c27b refactor(timeline): deduplicate parsing of events when making a RepliedToEvent 2025-05-21 15:52:31 +02:00
Stefan Ceriu
d84cf0614d change(ffi): return errors if the client or utd delegates were already set 2025-05-21 16:38:20 +03:00
Stefan Ceriu
3f1bc2591e chore(ffi): report an error if the timeline is set to report UTDs but the hook manager isn't configured 2025-05-21 16:38:20 +03:00
Stefan Ceriu
8e83b724da chore(ffi): rename the utd_hook to utd_hook_manager 2025-05-21 16:38:20 +03:00
Stefan Ceriu
767b10f5e2 change(ffi): remove now unused ClientDelegate did_refresh_tokens callback (dropped in favor of the ClientSessionDelegate) 2025-05-21 16:38:20 +03:00
Stefan Ceriu
4e2b5562f1 change(ffi): use a OnceLock to guard against multiple settings of the ClientDelegate 2025-05-21 16:38:20 +03:00