matrix-rust-sdk/bindings/matrix-sdk-ffi/src/api.udl

361 lines
8.6 KiB
Plaintext

namespace matrix_sdk_ffi {};
interface TaskHandle {};
[Error]
interface ClientError {
Generic(string msg);
};
callback interface ClientDelegate {
void did_receive_auth_error(boolean is_soft_logout);
};
dictionary RequiredState {
string key;
string value;
};
dictionary RoomSubscription {
sequence<RequiredState>? required_state;
u32? timeline_limit;
};
dictionary UpdateSummary {
sequence<string> lists;
sequence<string> rooms;
};
callback interface SlidingSyncObserver {
void did_receive_sync_update(UpdateSummary summary);
};
enum SlidingSyncState {
/// Sliding Sync has not started to load anything yet.
"NotLoaded",
/// Sliding Sync has been preloaded, i.e. restored from a cache for example.
"Preloaded",
/// We are trying to load all remaining rooms, might be in batches
/// Updates are received from the loaded rooms, and new rooms are being fetched
/// in background
"PartiallyLoaded",
/// Updates are received for all the loaded rooms, and all rooms have been
/// loaded!
"FullyLoaded",
};
enum SlidingSyncMode {
/// Sync up the entire room list first, page by page
"PagingFullSync",
/// Sync up the entire room list first through a growing window
"GrowingFullSync",
/// Only ever sync the currently selected window
"Selective",
};
callback interface SlidingSyncListStateObserver {
void did_receive_update(SlidingSyncState new_state);
};
[Enum]
interface RoomListEntry {
Empty();
Invalidated(string room_id);
Filled(string room_id);
};
[Enum]
interface SlidingSyncListRoomsListDiff {
Append(sequence<RoomListEntry> values);
Insert(u32 index, RoomListEntry value);
Set(u32 index, RoomListEntry value);
Remove(u32 index);
PushBack(RoomListEntry value);
PushFront(RoomListEntry value);
PopBack();
PopFront();
Clear();
Reset(sequence<RoomListEntry> values);
};
callback interface SlidingSyncListRoomListObserver {
void did_receive_update(SlidingSyncListRoomsListDiff diff);
};
callback interface SlidingSyncListRoomsCountObserver {
void did_receive_update(u32 count);
};
callback interface SlidingSyncListRoomItemsObserver {
void did_receive_update();
};
interface SlidingSyncListBuilder {
constructor();
[Self=ByArc]
SlidingSyncListBuilder sync_mode(SlidingSyncMode mode);
[Self=ByArc]
SlidingSyncListBuilder send_updates_for_items(boolean enable);
[Throws=ClientError, Self=ByArc]
SlidingSyncList build();
};
interface SlidingSyncList {
TaskHandle observe_room_list(SlidingSyncListRoomListObserver observer);
TaskHandle observe_rooms_count(SlidingSyncListRoomsCountObserver observer);
TaskHandle observe_state(SlidingSyncListStateObserver observer);
TaskHandle observe_room_items(SlidingSyncListRoomItemsObserver observer);
};
interface SlidingSyncRoom {
[Throws=ClientError]
SlidingSyncSubscribeResult subscribe_and_add_timeline_listener(TimelineListener listener, RoomSubscription? settings);
[Throws=ClientError]
SlidingSyncSubscribeResult add_timeline_listener(TimelineListener listener);
};
dictionary SlidingSyncSubscribeResult {
sequence<TimelineItem> items;
TaskHandle task_handle;
};
interface SlidingSync {
void set_observer(SlidingSyncObserver? observer);
[Throws=ClientError]
void subscribe(string room_id, RoomSubscription? settings);
[Throws=ClientError]
void unsubscribe(string room_id);
[Throws=ClientError]
SlidingSyncRoom? get_room(string room_id);
[Throws=ClientError]
sequence<SlidingSyncRoom?> get_rooms(sequence<string> room_ids);
};
interface ClientBuilder {
constructor();
[Throws=ClientError, Self=ByArc]
Client build();
};
interface SlidingSyncBuilder {
[Throws=ClientError, Self=ByArc]
SlidingSyncBuilder homeserver(string url);
[Throws=ClientError, Self=ByArc]
SlidingSync build();
};
dictionary CreateRoomParameters {
string name;
string? topic = null;
boolean is_encrypted;
boolean is_direct = false;
RoomVisibility visibility;
RoomPreset preset;
sequence<string>? invite = null;
string? avatar = null;
};
enum RoomVisibility {
/// Indicates that the room will be shown in the published room list.
"Public",
/// Indicates that the room will not be shown in the published room list.
"Private",
};
enum RoomPreset {
/// `join_rules` is set to `invite` and `history_visibility` is set to
/// `shared`.
"PrivateChat",
/// `join_rules` is set to `public` and `history_visibility` is set to
/// `shared`.
"PublicChat",
/// Same as `PrivateChat`, but all initial invitees get the same power level
/// as the creator.
"TrustedPrivateChat",
};
interface Client {
void set_delegate(ClientDelegate? delegate);
[Throws=ClientError]
void login(string username, string password, string? initial_device_name, string? device_id);
[Throws=ClientError]
MediaFileHandle get_media_file(MediaSource source, string mime_type);
};
interface MediaFileHandle {
string path();
};
enum MembershipState {
/// The user is banned.
"Ban",
/// The user has been invited.
"Invite",
/// The user has joined.
"Join",
/// The user has requested to join.
"Knock",
/// The user has left.
"Leave",
};
dictionary RoomMember {
string user_id;
string? display_name;
string? avatar_url;
MembershipState membership;
boolean is_name_ambiguous;
i64 power_level;
i64 normalized_power_level;
};
interface Room {
[Throws=ClientError]
string display_name();
[Throws=ClientError]
boolean is_encrypted();
[Throws=ClientError]
sequence<RoomMember> members();
[Throws=ClientError]
string? member_avatar_url(string user_id);
[Throws=ClientError]
string? member_display_name(string user_id);
sequence<TimelineItem> add_timeline_listener(TimelineListener listener);
// Loads older messages into the timeline.
//
// Raises an exception if there are no timeline listeners.
[Throws=ClientError]
void paginate_backwards(PaginationOptions opts);
[Throws=ClientError]
void send_read_receipt(string event_id);
[Throws=ClientError]
void send_read_marker(string fully_read_event_id, string? read_receipt_event_id);
void send(RoomMessageEventContent msg, string? txn_id);
[Throws=ClientError]
void send_reply(string msg, string in_reply_to_event_id, string? txn_id);
[Throws=ClientError]
void edit(string new_msg, string original_event_id, string? txn_id);
[Throws=ClientError]
void redact(string event_id, string? reason, string? txn_id);
[Throws=ClientError]
void report_content(string event_id, i32? score, string? reason);
[Throws=ClientError]
void send_reaction(string event_id, string key);
[Throws=ClientError]
void leave();
[Throws=ClientError]
void reject_invitation();
[Throws=ClientError]
void set_topic(string topic);
[Throws=ClientError]
void upload_avatar(string mime_type, sequence<u8> data);
[Throws=ClientError]
void remove_avatar();
};
callback interface TimelineListener {
void on_update(TimelineDiff update);
};
interface TimelineItem {};
interface TimelineDiff {};
dictionary MoveData {
u32 old_index;
u32 new_index;
};
[Enum]
interface PaginationOptions {
SingleRequest(u16 event_limit);
UntilNumItems(u16 event_limit, u16 items);
};
interface RoomMessageEventContent {};
interface MediaSource {
string url();
};
interface AuthenticationService {
constructor(string base_path, string? passphrase, string? custom_sliding_sync_proxy);
};
dictionary NotificationItem {
TimelineItem item;
string title;
string? subtitle;
boolean is_noisy;
string? avatar_url;
};
interface NotificationService {
constructor(string base_path, string user_id);
[Throws=ClientError]
NotificationItem? get_notification_item(string room_id, string event_id);
};
interface SessionVerificationEmoji {};
callback interface SessionVerificationControllerDelegate {
void did_accept_verification_request();
void did_start_sas_verification();
void did_receive_verification_data(sequence<SessionVerificationEmoji> data);
void did_fail();
void did_cancel();
void did_finish();
};
interface SessionVerificationController {
void set_delegate(SessionVerificationControllerDelegate? delegate);
[Throws=ClientError]
void request_verification();
[Throws=ClientError]
void start_sas_verification();
[Throws=ClientError]
void approve_verification();
[Throws=ClientError]
void decline_verification();
[Throws=ClientError]
void cancel_verification();
};