diff --git a/buildSrc/src/main/kotlin/BuildVersionsSDK.kt b/buildSrc/src/main/kotlin/BuildVersionsSDK.kt index cde63f6..dbab74b 100644 --- a/buildSrc/src/main/kotlin/BuildVersionsSDK.kt +++ b/buildSrc/src/main/kotlin/BuildVersionsSDK.kt @@ -1,5 +1,5 @@ object BuildVersionsSDK { const val majorVersion = 0 const val minorVersion = 2 - const val patchVersion = 15 + const val patchVersion = 16 } diff --git a/sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt b/sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt index 55a92aa..ad865f2 100644 --- a/sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt +++ b/sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt @@ -36,18 +36,24 @@ import java.util.concurrent.atomic.AtomicBoolean import kotlin.coroutines.resume import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.suspendCancellableCoroutine +import uniffi.matrix_sdk.BackupDownloadStrategy +import uniffi.matrix_sdk.FfiConverterTypeBackupDownloadStrategy import uniffi.matrix_sdk.FfiConverterTypeRoomMemberRole import uniffi.matrix_sdk.FfiConverterTypeRoomPowerLevelChanges import uniffi.matrix_sdk.RoomMemberRole import uniffi.matrix_sdk.RoomPowerLevelChanges -import uniffi.matrix_sdk_ui.BackPaginationStatus +import uniffi.matrix_sdk_crypto.FfiConverterTypeUtdCause +import uniffi.matrix_sdk_crypto.UtdCause import uniffi.matrix_sdk_ui.EventItemOrigin -import uniffi.matrix_sdk_ui.FfiConverterTypeBackPaginationStatus import uniffi.matrix_sdk_ui.FfiConverterTypeEventItemOrigin +import uniffi.matrix_sdk_ui.FfiConverterTypePaginationStatus +import uniffi.matrix_sdk_ui.PaginationStatus +import uniffi.matrix_sdk.RustBuffer as RustBufferBackupDownloadStrategy import uniffi.matrix_sdk.RustBuffer as RustBufferRoomMemberRole import uniffi.matrix_sdk.RustBuffer as RustBufferRoomPowerLevelChanges -import uniffi.matrix_sdk_ui.RustBuffer as RustBufferBackPaginationStatus +import uniffi.matrix_sdk_crypto.RustBuffer as RustBufferUtdCause import uniffi.matrix_sdk_ui.RustBuffer as RustBufferEventItemOrigin +import uniffi.matrix_sdk_ui.RustBuffer as RustBufferPaginationStatus // This is a helper for safely working with byte buffers returned from the Rust code. // A rust-owned buffer is represented by its capacity, its current length, and a @@ -397,9 +403,6 @@ internal open class UniffiForeignFuture( } } -internal interface UniffiCallbackInterfaceBackPaginationStatusListenerMethod0 : com.sun.jna.Callback { - fun callback(`uniffiHandle`: Long,`status`: RustBufferBackPaginationStatus.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) -} internal interface UniffiCallbackInterfaceBackupStateListenerMethod0 : com.sun.jna.Callback { fun callback(`uniffiHandle`: Long,`status`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) } @@ -427,6 +430,9 @@ internal interface UniffiCallbackInterfaceIgnoredUsersListenerMethod0 : com.sun. internal interface UniffiCallbackInterfaceNotificationSettingsDelegateMethod0 : com.sun.jna.Callback { fun callback(`uniffiHandle`: Long,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) } +internal interface UniffiCallbackInterfacePaginationStatusListenerMethod0 : com.sun.jna.Callback { + fun callback(`uniffiHandle`: Long,`status`: RustBufferPaginationStatus.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) +} internal interface UniffiCallbackInterfaceProgressWatcherMethod0 : com.sun.jna.Callback { fun callback(`uniffiHandle`: Long,`progress`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) } @@ -488,22 +494,6 @@ internal interface UniffiCallbackInterfaceWidgetCapabilitiesProviderMethod0 : co fun callback(`uniffiHandle`: Long,`capabilities`: RustBuffer.ByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) } @Structure.FieldOrder("onUpdate", "uniffiFree") -internal open class UniffiVTableCallbackInterfaceBackPaginationStatusListener( - @JvmField internal var `onUpdate`: UniffiCallbackInterfaceBackPaginationStatusListenerMethod0? = null, - @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, -) : Structure() { - class UniffiByValue( - `onUpdate`: UniffiCallbackInterfaceBackPaginationStatusListenerMethod0? = null, - `uniffiFree`: UniffiCallbackInterfaceFree? = null, - ): UniffiVTableCallbackInterfaceBackPaginationStatusListener(`onUpdate`,`uniffiFree`,), Structure.ByValue - - internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceBackPaginationStatusListener) { - `onUpdate` = other.`onUpdate` - `uniffiFree` = other.`uniffiFree` - } - -} -@Structure.FieldOrder("onUpdate", "uniffiFree") internal open class UniffiVTableCallbackInterfaceBackupStateListener( @JvmField internal var `onUpdate`: UniffiCallbackInterfaceBackupStateListenerMethod0? = null, @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, @@ -620,6 +610,22 @@ internal open class UniffiVTableCallbackInterfaceNotificationSettingsDelegate( `uniffiFree` = other.`uniffiFree` } +} +@Structure.FieldOrder("onUpdate", "uniffiFree") +internal open class UniffiVTableCallbackInterfacePaginationStatusListener( + @JvmField internal var `onUpdate`: UniffiCallbackInterfacePaginationStatusListenerMethod0? = null, + @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null, +) : Structure() { + class UniffiByValue( + `onUpdate`: UniffiCallbackInterfacePaginationStatusListenerMethod0? = null, + `uniffiFree`: UniffiCallbackInterfaceFree? = null, + ): UniffiVTableCallbackInterfacePaginationStatusListener(`onUpdate`,`uniffiFree`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiVTableCallbackInterfacePaginationStatusListener) { + `onUpdate` = other.`onUpdate` + `uniffiFree` = other.`uniffiFree` + } + } @Structure.FieldOrder("transmissionProgress", "uniffiFree") internal open class UniffiVTableCallbackInterfaceProgressWatcher( @@ -1706,6 +1712,18 @@ internal open class UniffiVTableCallbackInterfaceWidgetCapabilitiesProvider( + + + + + + + + + + + + @@ -1729,7 +1747,6 @@ internal interface UniffiLib : Library { .also { lib: UniffiLib -> uniffiCheckContractApiVersion(lib) uniffiCheckApiChecksums(lib) - uniffiCallbackInterfaceBackPaginationStatusListener.register(lib) uniffiCallbackInterfaceBackupStateListener.register(lib) uniffiCallbackInterfaceBackupSteadyStateListener.register(lib) uniffiCallbackInterfaceClientDelegate.register(lib) @@ -1737,6 +1754,7 @@ internal interface UniffiLib : Library { uniffiCallbackInterfaceEnableRecoveryProgressListener.register(lib) uniffiCallbackInterfaceIgnoredUsersListener.register(lib) uniffiCallbackInterfaceNotificationSettingsDelegate.register(lib) + uniffiCallbackInterfacePaginationStatusListener.register(lib) uniffiCallbackInterfaceProgressWatcher.register(lib) uniffiCallbackInterfaceRecoveryStateListener.register(lib) uniffiCallbackInterfaceRoomDirectorySearchEntriesListener.register(lib) @@ -1891,6 +1909,12 @@ internal interface UniffiLib : Library { ): Pointer fun uniffi_matrix_sdk_ffi_fn_method_clientbuilder_add_root_certificates(`ptr`: Pointer,`certificates`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer + fun uniffi_matrix_sdk_ffi_fn_method_clientbuilder_auto_enable_backups(`ptr`: Pointer,`autoEnableBackups`: Byte,uniffi_out_err: UniffiRustCallStatus, + ): Pointer + fun uniffi_matrix_sdk_ffi_fn_method_clientbuilder_auto_enable_cross_signing(`ptr`: Pointer,`autoEnableCrossSigning`: Byte,uniffi_out_err: UniffiRustCallStatus, + ): Pointer + fun uniffi_matrix_sdk_ffi_fn_method_clientbuilder_backup_download_strategy(`ptr`: Pointer,`backupDownloadStrategy`: RustBufferBackupDownloadStrategy.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): Pointer fun uniffi_matrix_sdk_ffi_fn_method_clientbuilder_base_path(`ptr`: Pointer,`path`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_matrix_sdk_ffi_fn_method_clientbuilder_build(`ptr`: Pointer, @@ -1955,6 +1979,8 @@ internal interface UniffiLib : Library { ): Pointer fun uniffi_matrix_sdk_ffi_fn_method_encryption_wait_for_backup_upload_steady_state(`ptr`: Pointer,`progressListener`: RustBuffer.ByValue, ): Long + fun uniffi_matrix_sdk_ffi_fn_method_encryption_wait_for_e2ee_initialization_tasks(`ptr`: Pointer, + ): Long fun uniffi_matrix_sdk_ffi_fn_clone_eventtimelineitem(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_matrix_sdk_ffi_fn_free_eventtimelineitem(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -2139,8 +2165,8 @@ internal interface UniffiLib : Library { ): Unit fun uniffi_matrix_sdk_ffi_fn_method_room_invited_members_count(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Long - fun uniffi_matrix_sdk_ffi_fn_method_room_inviter(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, - ): RustBuffer.ByValue + fun uniffi_matrix_sdk_ffi_fn_method_room_inviter(`ptr`: Pointer, + ): Long fun uniffi_matrix_sdk_ffi_fn_method_room_is_direct(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Byte fun uniffi_matrix_sdk_ffi_fn_method_room_is_encrypted(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -2209,6 +2235,8 @@ internal interface UniffiLib : Library { ): Long fun uniffi_matrix_sdk_ffi_fn_method_room_timeline(`ptr`: Pointer, ): Long + fun uniffi_matrix_sdk_ffi_fn_method_room_timeline_focused_on_event(`ptr`: Pointer,`eventId`: RustBuffer.ByValue,`numContextEvents`: Short,`internalIdPrefix`: RustBuffer.ByValue, + ): Long fun uniffi_matrix_sdk_ffi_fn_method_room_topic(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun uniffi_matrix_sdk_ffi_fn_method_room_typing_notice(`ptr`: Pointer,`isTyping`: Byte, @@ -2267,7 +2295,7 @@ internal interface UniffiLib : Library { ): Long fun uniffi_matrix_sdk_ffi_fn_method_roomlistitem_id(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue - fun uniffi_matrix_sdk_ffi_fn_method_roomlistitem_init_timeline(`ptr`: Pointer,`eventTypeFilter`: RustBuffer.ByValue, + fun uniffi_matrix_sdk_ffi_fn_method_roomlistitem_init_timeline(`ptr`: Pointer,`eventTypeFilter`: RustBuffer.ByValue,`internalIdPrefix`: RustBuffer.ByValue, ): Long fun uniffi_matrix_sdk_ffi_fn_method_roomlistitem_is_direct(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Byte @@ -2407,6 +2435,8 @@ internal interface UniffiLib : Library { ): Unit fun uniffi_matrix_sdk_ffi_fn_method_timeline_fetch_members(`ptr`: Pointer, ): Long + fun uniffi_matrix_sdk_ffi_fn_method_timeline_focused_paginate_forwards(`ptr`: Pointer,`numEvents`: Short, + ): Long fun uniffi_matrix_sdk_ffi_fn_method_timeline_get_event_timeline_item_by_event_id(`ptr`: Pointer,`eventId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_matrix_sdk_ffi_fn_method_timeline_get_timeline_event_content_by_event_id(`ptr`: Pointer,`eventId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, @@ -2415,8 +2445,8 @@ internal interface UniffiLib : Library { ): Long fun uniffi_matrix_sdk_ffi_fn_method_timeline_mark_as_read(`ptr`: Pointer,`receiptType`: RustBuffer.ByValue, ): Long - fun uniffi_matrix_sdk_ffi_fn_method_timeline_paginate_backwards(`ptr`: Pointer,`opts`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, - ): Unit + fun uniffi_matrix_sdk_ffi_fn_method_timeline_paginate_backwards(`ptr`: Pointer,`numEvents`: Short, + ): Long fun uniffi_matrix_sdk_ffi_fn_method_timeline_retry_decryption(`ptr`: Pointer,`sessionIds`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Unit fun uniffi_matrix_sdk_ffi_fn_method_timeline_retry_send(`ptr`: Pointer,`txnId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, @@ -2496,7 +2526,7 @@ internal interface UniffiLib : Library { fun uniffi_matrix_sdk_ffi_fn_method_timelineitem_fmt_debug(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun uniffi_matrix_sdk_ffi_fn_method_timelineitem_unique_id(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, - ): Long + ): RustBuffer.ByValue fun uniffi_matrix_sdk_ffi_fn_clone_timelineitemcontent(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_matrix_sdk_ffi_fn_free_timelineitemcontent(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -2529,8 +2559,6 @@ internal interface UniffiLib : Library { ): Long fun uniffi_matrix_sdk_ffi_fn_method_widgetdriverhandle_send(`ptr`: Pointer,`msg`: RustBuffer.ByValue, ): Long - fun uniffi_matrix_sdk_ffi_fn_init_callback_vtable_backpaginationstatuslistener(`vtable`: UniffiVTableCallbackInterfaceBackPaginationStatusListener, - ): Unit fun uniffi_matrix_sdk_ffi_fn_init_callback_vtable_backupstatelistener(`vtable`: UniffiVTableCallbackInterfaceBackupStateListener, ): Unit fun uniffi_matrix_sdk_ffi_fn_init_callback_vtable_backupsteadystatelistener(`vtable`: UniffiVTableCallbackInterfaceBackupSteadyStateListener, @@ -2545,6 +2573,8 @@ internal interface UniffiLib : Library { ): Unit fun uniffi_matrix_sdk_ffi_fn_init_callback_vtable_notificationsettingsdelegate(`vtable`: UniffiVTableCallbackInterfaceNotificationSettingsDelegate, ): Unit + fun uniffi_matrix_sdk_ffi_fn_init_callback_vtable_paginationstatuslistener(`vtable`: UniffiVTableCallbackInterfacePaginationStatusListener, + ): Unit fun uniffi_matrix_sdk_ffi_fn_init_callback_vtable_progresswatcher(`vtable`: UniffiVTableCallbackInterfaceProgressWatcher, ): Unit fun uniffi_matrix_sdk_ffi_fn_init_callback_vtable_recoverystatelistener(`vtable`: UniffiVTableCallbackInterfaceRecoveryStateListener, @@ -2867,6 +2897,12 @@ internal interface UniffiLib : Library { ): Short fun uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_add_root_certificates( ): Short + fun uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_auto_enable_backups( + ): Short + fun uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_auto_enable_cross_signing( + ): Short + fun uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_backup_download_strategy( + ): Short fun uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_base_path( ): Short fun uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_build( @@ -2927,6 +2963,8 @@ internal interface UniffiLib : Library { ): Short fun uniffi_matrix_sdk_ffi_checksum_method_encryption_wait_for_backup_upload_steady_state( ): Short + fun uniffi_matrix_sdk_ffi_checksum_method_encryption_wait_for_e2ee_initialization_tasks( + ): Short fun uniffi_matrix_sdk_ffi_checksum_method_eventtimelineitem_can_be_replied_to( ): Short fun uniffi_matrix_sdk_ffi_checksum_method_eventtimelineitem_content( @@ -3145,6 +3183,8 @@ internal interface UniffiLib : Library { ): Short fun uniffi_matrix_sdk_ffi_checksum_method_room_timeline( ): Short + fun uniffi_matrix_sdk_ffi_checksum_method_room_timeline_focused_on_event( + ): Short fun uniffi_matrix_sdk_ffi_checksum_method_room_topic( ): Short fun uniffi_matrix_sdk_ffi_checksum_method_room_typing_notice( @@ -3283,6 +3323,8 @@ internal interface UniffiLib : Library { ): Short fun uniffi_matrix_sdk_ffi_checksum_method_timeline_fetch_members( ): Short + fun uniffi_matrix_sdk_ffi_checksum_method_timeline_focused_paginate_forwards( + ): Short fun uniffi_matrix_sdk_ffi_checksum_method_timeline_get_event_timeline_item_by_event_id( ): Short fun uniffi_matrix_sdk_ffi_checksum_method_timeline_get_timeline_event_content_by_event_id( @@ -3383,8 +3425,6 @@ internal interface UniffiLib : Library { ): Short fun uniffi_matrix_sdk_ffi_checksum_constructor_timelineeventtypefilter_include( ): Short - fun uniffi_matrix_sdk_ffi_checksum_method_backpaginationstatuslistener_on_update( - ): Short fun uniffi_matrix_sdk_ffi_checksum_method_backupstatelistener_on_update( ): Short fun uniffi_matrix_sdk_ffi_checksum_method_backupsteadystatelistener_on_update( @@ -3403,6 +3443,8 @@ internal interface UniffiLib : Library { ): Short fun uniffi_matrix_sdk_ffi_checksum_method_notificationsettingsdelegate_settings_did_change( ): Short + fun uniffi_matrix_sdk_ffi_checksum_method_paginationstatuslistener_on_update( + ): Short fun uniffi_matrix_sdk_ffi_checksum_method_progresswatcher_transmission_progress( ): Short fun uniffi_matrix_sdk_ffi_checksum_method_recoverystatelistener_on_update( @@ -3673,6 +3715,15 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_add_root_certificates() != 57950.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_auto_enable_backups() != 32504.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_auto_enable_cross_signing() != 27603.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_backup_download_strategy() != 2583.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_base_path() != 40888.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -3763,6 +3814,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_encryption_wait_for_backup_upload_steady_state() != 16813.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_matrix_sdk_ffi_checksum_method_encryption_wait_for_e2ee_initialization_tasks() != 41585.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_matrix_sdk_ffi_checksum_method_eventtimelineitem_can_be_replied_to() != 42922.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -3985,7 +4039,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_room_invited_members_count() != 1023.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_matrix_sdk_ffi_checksum_method_room_inviter() != 64006.toShort()) { + if (lib.uniffi_matrix_sdk_ffi_checksum_method_room_inviter() != 49874.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_matrix_sdk_ffi_checksum_method_room_is_direct() != 16947.toShort()) { @@ -4090,6 +4144,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_room_timeline() != 701.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_matrix_sdk_ffi_checksum_method_room_timeline_focused_on_event() != 54175.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_matrix_sdk_ffi_checksum_method_room_topic() != 59745.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -4153,7 +4210,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_roomlistitem_id() != 41176.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_matrix_sdk_ffi_checksum_method_roomlistitem_init_timeline() != 15676.toShort()) { + if (lib.uniffi_matrix_sdk_ffi_checksum_method_roomlistitem_init_timeline() != 16609.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_matrix_sdk_ffi_checksum_method_roomlistitem_is_direct() != 46873.toShort()) { @@ -4297,6 +4354,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_fetch_members() != 37994.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_focused_paginate_forwards() != 38096.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_get_event_timeline_item_by_event_id() != 33483.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -4309,7 +4369,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_mark_as_read() != 15734.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_paginate_backwards() != 40762.toShort()) { + if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_paginate_backwards() != 56939.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_retry_decryption() != 57065.toShort()) { @@ -4348,7 +4408,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_send_voice_message() != 50962.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_subscribe_to_back_pagination_status() != 9015.toShort()) { + if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_subscribe_to_back_pagination_status() != 58309.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_matrix_sdk_ffi_checksum_method_timeline_toggle_reaction() != 42402.toShort()) { @@ -4399,7 +4459,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_timelineitem_fmt_debug() != 38094.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_matrix_sdk_ffi_checksum_method_timelineitem_unique_id() != 8639.toShort()) { + if (lib.uniffi_matrix_sdk_ffi_checksum_method_timelineitem_unique_id() != 30409.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_matrix_sdk_ffi_checksum_method_timelineitemcontent_as_message() != 45784.toShort()) { @@ -4447,9 +4507,6 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_constructor_timelineeventtypefilter_include() != 21388.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_matrix_sdk_ffi_checksum_method_backpaginationstatuslistener_on_update() != 5891.toShort()) { - throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } if (lib.uniffi_matrix_sdk_ffi_checksum_method_backupstatelistener_on_update() != 24369.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -4477,6 +4534,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_matrix_sdk_ffi_checksum_method_notificationsettingsdelegate_settings_did_change() != 51708.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_matrix_sdk_ffi_checksum_method_paginationstatuslistener_on_update() != 21279.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_matrix_sdk_ffi_checksum_method_progresswatcher_transmission_progress() != 20412.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -6413,6 +6473,21 @@ public interface ClientBuilderInterface { fun `addRootCertificates`(`certificates`: List): ClientBuilder + /** + * Automatically create a backup version if no backup exists. + */ + fun `autoEnableBackups`(`autoEnableBackups`: kotlin.Boolean): ClientBuilder + + fun `autoEnableCrossSigning`(`autoEnableCrossSigning`: kotlin.Boolean): ClientBuilder + + /** + * Select a strategy to download room keys from the backup. By default + * we download after a decryption failure. + * + * Take a look at the [`BackupDownloadStrategy`] enum for more options. + */ + fun `backupDownloadStrategy`(`backupDownloadStrategy`: BackupDownloadStrategy): ClientBuilder + fun `basePath`(`path`: kotlin.String): ClientBuilder suspend fun `build`(): Client @@ -6543,6 +6618,48 @@ open class ClientBuilder: Disposable, AutoCloseable, ClientBuilderInterface { FfiConverterTypeClientBuilder.lift(it) } + + /** + * Automatically create a backup version if no backup exists. + */override fun `autoEnableBackups`(`autoEnableBackups`: kotlin.Boolean): ClientBuilder = + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_clientbuilder_auto_enable_backups(it, + FfiConverterBoolean.lower(`autoEnableBackups`), + _status) +} + }.let { + FfiConverterTypeClientBuilder.lift(it) + } + + override fun `autoEnableCrossSigning`(`autoEnableCrossSigning`: kotlin.Boolean): ClientBuilder = + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_clientbuilder_auto_enable_cross_signing(it, + FfiConverterBoolean.lower(`autoEnableCrossSigning`), + _status) +} + }.let { + FfiConverterTypeClientBuilder.lift(it) + } + + + /** + * Select a strategy to download room keys from the backup. By default + * we download after a decryption failure. + * + * Take a look at the [`BackupDownloadStrategy`] enum for more options. + */override fun `backupDownloadStrategy`(`backupDownloadStrategy`: BackupDownloadStrategy): ClientBuilder = + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_clientbuilder_backup_download_strategy(it, + FfiConverterTypeBackupDownloadStrategy.lower(`backupDownloadStrategy`), + _status) +} + }.let { + FfiConverterTypeClientBuilder.lift(it) + } + override fun `basePath`(`path`: kotlin.String): ClientBuilder = callWithPointer { uniffiRustCall() { _status -> @@ -6892,6 +7009,12 @@ public interface EncryptionInterface { suspend fun `waitForBackupUploadSteadyState`(`progressListener`: BackupSteadyStateListener?) + /** + * Waits for end-to-end encryption initialization tasks to finish, if any + * was running in the background. + */ + suspend fun `waitForE2eeInitializationTasks`() + companion object } @@ -7238,6 +7361,30 @@ open class Encryption: Disposable, AutoCloseable, EncryptionInterface { ) } + /** + * Waits for end-to-end encryption initialization tasks to finish, if any + * was running in the background. + */ + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `waitForE2eeInitializationTasks`() { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_encryption_wait_for_e2ee_initialization_tasks( + thisPtr, + + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_free_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) + } + @@ -10531,7 +10678,11 @@ public interface RoomInterface { fun `invitedMembersCount`(): kotlin.ULong - fun `inviter`(): RoomMember? + /** + * For rooms one is invited to, retrieves the room member information for + * the user who invited the logged-in user to a room. + */ + suspend fun `inviter`(): RoomMember? fun `isDirect`(): kotlin.Boolean @@ -10652,6 +10803,14 @@ public interface RoomInterface { suspend fun `timeline`(): Timeline + /** + * Returns a timeline focused on the given event. + * + * Note: this timeline is independent from that returned with + * [`Self::timeline`], and as such it is not cached. + */ + suspend fun `timelineFocusedOnEvent`(`eventId`: kotlin.String, `numContextEvents`: kotlin.UShort, `internalIdPrefix`: kotlin.String?): Timeline + fun `topic`(): kotlin.String? suspend fun `typingNotice`(`isTyping`: kotlin.Boolean) @@ -11166,17 +11325,29 @@ open class Room: Disposable, AutoCloseable, RoomInterface { FfiConverterULong.lift(it) } - override fun `inviter`(): RoomMember? = - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_room_inviter(it, - - _status) -} - }.let { - FfiConverterOptionalTypeRoomMember.lift(it) - } + /** + * For rooms one is invited to, retrieves the room member information for + * the user who invited the logged-in user to a room. + */ + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `inviter`() : RoomMember? { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_room_inviter( + thisPtr, + + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_free_rust_buffer(future) }, + // lift function + { FfiConverterOptionalTypeRoomMember.lift(it) }, + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) + } override fun `isDirect`(): kotlin.Boolean = callWithPointer { uniffiRustCall() { _status -> @@ -11736,6 +11907,32 @@ open class Room: Disposable, AutoCloseable, RoomInterface { ClientException.ErrorHandler, ) } + + /** + * Returns a timeline focused on the given event. + * + * Note: this timeline is independent from that returned with + * [`Self::timeline`], and as such it is not cached. + */ + @Throws(FocusEventException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `timelineFocusedOnEvent`(`eventId`: kotlin.String, `numContextEvents`: kotlin.UShort, `internalIdPrefix`: kotlin.String?) : Timeline { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_room_timeline_focused_on_event( + thisPtr, + FfiConverterString.lower(`eventId`),FfiConverterUShort.lower(`numContextEvents`),FfiConverterOptionalString.lower(`internalIdPrefix`), + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_poll_pointer(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_complete_pointer(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_free_pointer(future) }, + // lift function + { FfiConverterTypeTimeline.lift(it) }, + // Error FFI converter + FocusEventException.ErrorHandler, + ) + } override fun `topic`(): kotlin.String? = callWithPointer { uniffiRustCall() { _status -> @@ -12844,8 +13041,11 @@ public interface RoomListItemInterface { * * `event_type_filter` - An optional [`TimelineEventTypeFilter`] to be * used to filter timeline events besides the default timeline filter. If * `None` is passed, only the default timeline filter will be used. + * * `internal_id_prefix` - An optional String that will be prepended to + * all the timeline item's internal IDs, making it possible to + * distinguish different timeline instances from each other. */ - suspend fun `initTimeline`(`eventTypeFilter`: TimelineEventTypeFilter?) + suspend fun `initTimeline`(`eventTypeFilter`: TimelineEventTypeFilter?, `internalIdPrefix`: kotlin.String?) fun `isDirect`(): kotlin.Boolean @@ -13012,15 +13212,18 @@ open class RoomListItem: Disposable, AutoCloseable, RoomListItemInterface { * * `event_type_filter` - An optional [`TimelineEventTypeFilter`] to be * used to filter timeline events besides the default timeline filter. If * `None` is passed, only the default timeline filter will be used. + * * `internal_id_prefix` - An optional String that will be prepended to + * all the timeline item's internal IDs, making it possible to + * distinguish different timeline instances from each other. */ @Throws(RoomListException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - override suspend fun `initTimeline`(`eventTypeFilter`: TimelineEventTypeFilter?) { + override suspend fun `initTimeline`(`eventTypeFilter`: TimelineEventTypeFilter?, `internalIdPrefix`: kotlin.String?) { return uniffiRustCallAsync( callWithPointer { thisPtr -> UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_roomlistitem_init_timeline( thisPtr, - FfiConverterOptionalTypeTimelineEventTypeFilter.lower(`eventTypeFilter`), + FfiConverterOptionalTypeTimelineEventTypeFilter.lower(`eventTypeFilter`),FfiConverterOptionalString.lower(`internalIdPrefix`), ) }, { future, callback, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_poll_void(future, callback, continuation) }, @@ -16064,6 +16267,13 @@ public interface TimelineInterface { suspend fun `fetchMembers`() + /** + * Paginate forwards, when in focused mode. + * + * Returns whether we hit the end of the timeline or not. + */ + suspend fun `focusedPaginateForwards`(`numEvents`: kotlin.UShort): kotlin.Boolean + fun `getEventTimelineItemByEventId`(`eventId`: kotlin.String): EventTimelineItem fun `getTimelineEventContentByEventId`(`eventId`: kotlin.String): RoomMessageEventContentWithoutRelation @@ -16081,11 +16291,11 @@ public interface TimelineInterface { suspend fun `markAsRead`(`receiptType`: ReceiptType) /** - * Loads older messages into the timeline. + * Paginate backwards, whether we are in focused mode or in live mode. * - * Raises an exception if there are no timeline listeners. + * Returns whether we hit the end of the timeline or not. */ - fun `paginateBackwards`(`opts`: PaginationOptions) + suspend fun `paginateBackwards`(`numEvents`: kotlin.UShort): kotlin.Boolean fun `retryDecryption`(`sessionIds`: List) @@ -16111,7 +16321,7 @@ public interface TimelineInterface { fun `sendVoiceMessage`(`url`: kotlin.String, `audioInfo`: AudioInfo, `waveform`: List, `caption`: kotlin.String?, `formattedCaption`: FormattedBody?, `progressWatcher`: ProgressWatcher?): SendAttachmentJoinHandle - fun `subscribeToBackPaginationStatus`(`listener`: BackPaginationStatusListener): TaskHandle + fun `subscribeToBackPaginationStatus`(`listener`: PaginationStatusListener): TaskHandle fun `toggleReaction`(`eventId`: kotlin.String, `key`: kotlin.String) @@ -16314,6 +16524,31 @@ open class Timeline: Disposable, AutoCloseable, TimelineInterface { ) } + /** + * Paginate forwards, when in focused mode. + * + * Returns whether we hit the end of the timeline or not. + */ + @Throws(ClientException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `focusedPaginateForwards`(`numEvents`: kotlin.UShort) : kotlin.Boolean { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_timeline_focused_paginate_forwards( + thisPtr, + FfiConverterUShort.lower(`numEvents`), + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_poll_i8(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_complete_i8(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_free_i8(future) }, + // lift function + { FfiConverterBoolean.lift(it) }, + // Error FFI converter + ClientException.ErrorHandler, + ) + } + @Throws(ClientException::class)override fun `getEventTimelineItemByEventId`(`eventId`: kotlin.String): EventTimelineItem = callWithPointer { uniffiRustCallWithError(ClientException) { _status -> @@ -16387,20 +16622,29 @@ open class Timeline: Disposable, AutoCloseable, TimelineInterface { } /** - * Loads older messages into the timeline. + * Paginate backwards, whether we are in focused mode or in live mode. * - * Raises an exception if there are no timeline listeners. + * Returns whether we hit the end of the timeline or not. */ - @Throws(ClientException::class)override fun `paginateBackwards`(`opts`: PaginationOptions) = - callWithPointer { - uniffiRustCallWithError(ClientException) { _status -> - UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_timeline_paginate_backwards(it, - FfiConverterTypePaginationOptions.lower(`opts`), - _status) -} - } - - + @Throws(ClientException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `paginateBackwards`(`numEvents`: kotlin.UShort) : kotlin.Boolean { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_timeline_paginate_backwards( + thisPtr, + FfiConverterUShort.lower(`numEvents`), + ) + }, + { future, callback, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_poll_i8(future, callback, continuation) }, + { future, continuation -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_complete_i8(future, continuation) }, + { future -> UniffiLib.INSTANCE.ffi_matrix_sdk_ffi_rust_future_free_i8(future) }, + // lift function + { FfiConverterBoolean.lift(it) }, + // Error FFI converter + ClientException.ErrorHandler, + ) + } override fun `retryDecryption`(`sessionIds`: List) = callWithPointer { uniffiRustCall() { _status -> @@ -16530,11 +16774,11 @@ open class Timeline: Disposable, AutoCloseable, TimelineInterface { } - @Throws(ClientException::class)override fun `subscribeToBackPaginationStatus`(`listener`: BackPaginationStatusListener): TaskHandle = + @Throws(ClientException::class)override fun `subscribeToBackPaginationStatus`(`listener`: PaginationStatusListener): TaskHandle = callWithPointer { uniffiRustCallWithError(ClientException) { _status -> UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_timeline_subscribe_to_back_pagination_status(it, - FfiConverterTypeBackPaginationStatusListener.lower(`listener`), + FfiConverterTypePaginationStatusListener.lower(`listener`), _status) } }.let { @@ -17516,7 +17760,7 @@ public interface TimelineItemInterface { fun `fmtDebug`(): kotlin.String - fun `uniqueId`(): kotlin.ULong + fun `uniqueId`(): kotlin.String companion object } @@ -17635,7 +17879,7 @@ open class TimelineItem: Disposable, AutoCloseable, TimelineItemInterface { FfiConverterString.lift(it) } - override fun `uniqueId`(): kotlin.ULong = + override fun `uniqueId`(): kotlin.String = callWithPointer { uniffiRustCall() { _status -> UniffiLib.INSTANCE.uniffi_matrix_sdk_ffi_fn_method_timelineitem_unique_id(it, @@ -17643,7 +17887,7 @@ open class TimelineItem: Disposable, AutoCloseable, TimelineItemInterface { _status) } }.let { - FfiConverterULong.lift(it) + FfiConverterString.lift(it) } @@ -20089,6 +20333,13 @@ data class RoomInfo ( var `alternativeAliases`: List, var `membership`: Membership, var `latestEvent`: EventTimelineItem?, + /** + * Member who invited the current user to a room that's in the invited + * state. + * + * Can be missing if the room membership invite event is missing from the + * store. + */ var `inviter`: RoomMember?, var `activeMembersCount`: kotlin.ULong, var `invitedMembersCount`: kotlin.ULong, @@ -21073,7 +21324,12 @@ data class UnableToDecryptInfo ( * * If set, this is in milliseconds. */ - var `timeToDecryptMs`: kotlin.ULong? + var `timeToDecryptMs`: kotlin.ULong?, + /** + * What we know about what caused this UTD. E.g. was this event sent when + * we were not a member of this room? + */ + var `cause`: UtdCause ) { companion object @@ -21084,17 +21340,20 @@ public object FfiConverterTypeUnableToDecryptInfo: FfiConverterRustBuffer EncryptedMessage.MegolmV1AesSha2( FfiConverterString.read(buf), + FfiConverterTypeUtdCause.read(buf), ) 3 -> EncryptedMessage.Unknown else -> throw RuntimeException("invalid enum value, something is very wrong!!") @@ -22289,6 +22554,7 @@ public object FfiConverterTypeEncryptedMessage : FfiConverterRustBuffer { @@ -22309,6 +22575,7 @@ public object FfiConverterTypeEncryptedMessage : FfiConverterRustBuffer { buf.putInt(2) FfiConverterString.write(value.`sessionId`, buf) + FfiConverterTypeUtdCause.write(value.`cause`, buf) Unit } is EncryptedMessage.Unknown -> { @@ -22597,6 +22864,109 @@ public object FfiConverterTypeFilterTimelineEventType : FfiConverterRustBuffer { + override fun lift(error_buf: RustBuffer.ByValue): FocusEventException = FfiConverterTypeFocusEventError.lift(error_buf) + } + + +} + +public object FfiConverterTypeFocusEventError : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): FocusEventException { + + + return when(buf.getInt()) { + 1 -> FocusEventException.InvalidEventId( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + 2 -> FocusEventException.EventNotFound( + FfiConverterString.read(buf), + ) + 3 -> FocusEventException.Other( + FfiConverterString.read(buf), + ) + else -> throw RuntimeException("invalid error enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: FocusEventException): ULong { + return when(value) { + is FocusEventException.InvalidEventId -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`eventId`) + + FfiConverterString.allocationSize(value.`err`) + ) + is FocusEventException.EventNotFound -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`eventId`) + ) + is FocusEventException.Other -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`msg`) + ) + } + } + + override fun write(value: FocusEventException, buf: ByteBuffer) { + when(value) { + is FocusEventException.InvalidEventId -> { + buf.putInt(1) + FfiConverterString.write(value.`eventId`, buf) + FfiConverterString.write(value.`err`, buf) + Unit + } + is FocusEventException.EventNotFound -> { + buf.putInt(2) + FfiConverterString.write(value.`eventId`, buf) + Unit + } + is FocusEventException.Other -> { + buf.putInt(3) + FfiConverterString.write(value.`msg`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } + +} + + + + enum class LogLevel { ERROR, @@ -27688,9 +28058,9 @@ public object FfiConverterTypeWidgetEventFilter : FfiConverterRustBuffer: Ffi } } -// Put the implementation in an object so we don't pollute the top-level namespace -internal object uniffiCallbackInterfaceBackPaginationStatusListener { - internal object `onUpdate`: UniffiCallbackInterfaceBackPaginationStatusListenerMethod0 { - override fun callback(`uniffiHandle`: Long,`status`: RustBufferBackPaginationStatus.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { - val uniffiObj = FfiConverterTypeBackPaginationStatusListener.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`onUpdate`( - FfiConverterTypeBackPaginationStatus.lift(`status`), - ) - } - val writeReturn = { _: Unit -> Unit } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - - internal object uniffiFree: UniffiCallbackInterfaceFree { - override fun callback(handle: Long) { - FfiConverterTypeBackPaginationStatusListener.handleMap.remove(handle) - } - } - - internal var vtable = UniffiVTableCallbackInterfaceBackPaginationStatusListener( - `onUpdate`, - uniffiFree - ) - - // Registers the foreign callback with the Rust side. - // This method is generated for each callback interface. - internal fun register(lib: UniffiLib) { - lib.uniffi_matrix_sdk_ffi_fn_init_callback_vtable_backpaginationstatuslistener(vtable) - } -} - -// The ffiConverter which transforms the Callbacks in to handles to pass to Rust. -public object FfiConverterTypeBackPaginationStatusListener: FfiConverterCallbackInterface() - - - - - -public interface BackupStateListener { - - fun `onUpdate`(`status`: BackupState) - - companion object -} - - - // Put the implementation in an object so we don't pollute the top-level namespace internal object uniffiCallbackInterfaceBackupStateListener { internal object `onUpdate`: UniffiCallbackInterfaceBackupStateListenerMethod0 { @@ -28144,6 +28465,55 @@ public object FfiConverterTypeNotificationSettingsDelegate: FfiConverterCallback +public interface PaginationStatusListener { + + fun `onUpdate`(`status`: PaginationStatus) + + companion object +} + + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfacePaginationStatusListener { + internal object `onUpdate`: UniffiCallbackInterfacePaginationStatusListenerMethod0 { + override fun callback(`uniffiHandle`: Long,`status`: RustBufferPaginationStatus.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) { + val uniffiObj = FfiConverterTypePaginationStatusListener.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`onUpdate`( + FfiConverterTypePaginationStatus.lift(`status`), + ) + } + val writeReturn = { _: Unit -> Unit } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypePaginationStatusListener.handleMap.remove(handle) + } + } + + internal var vtable = UniffiVTableCallbackInterfacePaginationStatusListener( + `onUpdate`, + uniffiFree + ) + + // Registers the foreign callback with the Rust side. + // This method is generated for each callback interface. + internal fun register(lib: UniffiLib) { + lib.uniffi_matrix_sdk_ffi_fn_init_callback_vtable_paginationstatuslistener(vtable) + } +} + +// The ffiConverter which transforms the Callbacks in to handles to pass to Rust. +public object FfiConverterTypePaginationStatusListener: FfiConverterCallbackInterface() + + + + + public interface ProgressWatcher { fun `transmissionProgress`(`progress`: TransmissionProgress) @@ -31276,6 +31646,14 @@ public object FfiConverterMapStringSequenceString: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + BackupDownloadStrategy.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: BackupDownloadStrategy) = 4UL + + override fun write(value: BackupDownloadStrategy, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + /** * The role of a member in a room. */ diff --git a/sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_crypto/matrix_sdk_crypto.kt b/sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_crypto/matrix_sdk_crypto.kt new file mode 100644 index 0000000..64706df --- /dev/null +++ b/sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_crypto/matrix_sdk_crypto.kt @@ -0,0 +1,805 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +@file:Suppress("NAME_SHADOWING") + +package uniffi.matrix_sdk_crypto; + +// Common helper code. +// +// Ideally this would live in a separate .kt file where it can be unittested etc +// in isolation, and perhaps even published as a re-useable package. +// +// However, it's important that the details of how this helper code works (e.g. the +// way that different builtin types are passed across the FFI) exactly match what's +// expected by the Rust code on the other side of the interface. In practice right +// now that means coming from the exact some version of `uniffi` that was used to +// compile the Rust component. The easiest way to ensure this is to bundle the Kotlin +// helpers directly inline like we're doing here. + +import com.sun.jna.Library +import com.sun.jna.IntegerType +import com.sun.jna.Native +import com.sun.jna.Pointer +import com.sun.jna.Structure +import com.sun.jna.Callback +import com.sun.jna.ptr.* +import java.nio.ByteBuffer +import java.nio.ByteOrder +import java.nio.CharBuffer +import java.nio.charset.CodingErrorAction +import java.util.concurrent.atomic.AtomicLong +import java.util.concurrent.ConcurrentHashMap + +// This is a helper for safely working with byte buffers returned from the Rust code. +// A rust-owned buffer is represented by its capacity, its current length, and a +// pointer to the underlying data. + +@Structure.FieldOrder("capacity", "len", "data") +open class RustBuffer : Structure() { + // Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values. + // When dealing with these fields, make sure to call `toULong()`. + @JvmField var capacity: Long = 0 + @JvmField var len: Long = 0 + @JvmField var data: Pointer? = null + + class ByValue: RustBuffer(), Structure.ByValue + class ByReference: RustBuffer(), Structure.ByReference + + internal fun setValue(other: RustBuffer) { + capacity = other.capacity + len = other.len + data = other.data + } + + companion object { + internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status -> + // Note: need to convert the size to a `Long` value to make this work with JVM. + UniffiLib.INSTANCE.ffi_matrix_sdk_crypto_rustbuffer_alloc(size.toLong(), status) + }.also { + if(it.data == null) { + throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})") + } + } + + internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue { + var buf = RustBuffer.ByValue() + buf.capacity = capacity.toLong() + buf.len = len.toLong() + buf.data = data + return buf + } + + internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status -> + UniffiLib.INSTANCE.ffi_matrix_sdk_crypto_rustbuffer_free(buf, status) + } + } + + @Suppress("TooGenericExceptionThrown") + fun asByteBuffer() = + this.data?.getByteBuffer(0, this.len.toLong())?.also { + it.order(ByteOrder.BIG_ENDIAN) + } +} + +/** + * The equivalent of the `*mut RustBuffer` type. + * Required for callbacks taking in an out pointer. + * + * Size is the sum of all values in the struct. + */ +class RustBufferByReference : ByReference(16) { + /** + * Set the pointed-to `RustBuffer` to the given value. + */ + fun setValue(value: RustBuffer.ByValue) { + // NOTE: The offsets are as they are in the C-like struct. + val pointer = getPointer() + pointer.setLong(0, value.capacity) + pointer.setLong(8, value.len) + pointer.setPointer(16, value.data) + } + + /** + * Get a `RustBuffer.ByValue` from this reference. + */ + fun getValue(): RustBuffer.ByValue { + val pointer = getPointer() + val value = RustBuffer.ByValue() + value.writeField("capacity", pointer.getLong(0)) + value.writeField("len", pointer.getLong(8)) + value.writeField("data", pointer.getLong(16)) + + return value + } +} + +// This is a helper for safely passing byte references into the rust code. +// It's not actually used at the moment, because there aren't many things that you +// can take a direct pointer to in the JVM, and if we're going to copy something +// then we might as well copy it into a `RustBuffer`. But it's here for API +// completeness. + +@Structure.FieldOrder("len", "data") +open class ForeignBytes : Structure() { + @JvmField var len: Int = 0 + @JvmField var data: Pointer? = null + + class ByValue : ForeignBytes(), Structure.ByValue +} +// The FfiConverter interface handles converter types to and from the FFI +// +// All implementing objects should be public to support external types. When a +// type is external we need to import it's FfiConverter. +public interface FfiConverter { + // Convert an FFI type to a Kotlin type + fun lift(value: FfiType): KotlinType + + // Convert an Kotlin type to an FFI type + fun lower(value: KotlinType): FfiType + + // Read a Kotlin type from a `ByteBuffer` + fun read(buf: ByteBuffer): KotlinType + + // Calculate bytes to allocate when creating a `RustBuffer` + // + // This must return at least as many bytes as the write() function will + // write. It can return more bytes than needed, for example when writing + // Strings we can't know the exact bytes needed until we the UTF-8 + // encoding, so we pessimistically allocate the largest size possible (3 + // bytes per codepoint). Allocating extra bytes is not really a big deal + // because the `RustBuffer` is short-lived. + fun allocationSize(value: KotlinType): ULong + + // Write a Kotlin type to a `ByteBuffer` + fun write(value: KotlinType, buf: ByteBuffer) + + // Lower a value into a `RustBuffer` + // + // This method lowers a value into a `RustBuffer` rather than the normal + // FfiType. It's used by the callback interface code. Callback interface + // returns are always serialized into a `RustBuffer` regardless of their + // normal FFI type. + fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue { + val rbuf = RustBuffer.alloc(allocationSize(value)) + try { + val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also { + it.order(ByteOrder.BIG_ENDIAN) + } + write(value, bbuf) + rbuf.writeField("len", bbuf.position().toLong()) + return rbuf + } catch (e: Throwable) { + RustBuffer.free(rbuf) + throw e + } + } + + // Lift a value from a `RustBuffer`. + // + // This here mostly because of the symmetry with `lowerIntoRustBuffer()`. + // It's currently only used by the `FfiConverterRustBuffer` class below. + fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType { + val byteBuf = rbuf.asByteBuffer()!! + try { + val item = read(byteBuf) + if (byteBuf.hasRemaining()) { + throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!") + } + return item + } finally { + RustBuffer.free(rbuf) + } + } +} + +// FfiConverter that uses `RustBuffer` as the FfiType +public interface FfiConverterRustBuffer: FfiConverter { + override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value) + override fun lower(value: KotlinType) = lowerIntoRustBuffer(value) +} +// A handful of classes and functions to support the generated data structures. +// This would be a good candidate for isolating in its own ffi-support lib. + +internal const val UNIFFI_CALL_SUCCESS = 0.toByte() +internal const val UNIFFI_CALL_ERROR = 1.toByte() +internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte() + +@Structure.FieldOrder("code", "error_buf") +internal open class UniffiRustCallStatus : Structure() { + @JvmField var code: Byte = 0 + @JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue() + + class ByValue: UniffiRustCallStatus(), Structure.ByValue + + fun isSuccess(): Boolean { + return code == UNIFFI_CALL_SUCCESS + } + + fun isError(): Boolean { + return code == UNIFFI_CALL_ERROR + } + + fun isPanic(): Boolean { + return code == UNIFFI_CALL_UNEXPECTED_ERROR + } +} + +class InternalException(message: String) : Exception(message) + +// Each top-level error class has a companion object that can lift the error from the call status's rust buffer +interface UniffiRustCallStatusErrorHandler { + fun lift(error_buf: RustBuffer.ByValue): E; +} + +// Helpers for calling Rust +// In practice we usually need to be synchronized to call this safely, so it doesn't +// synchronize itself + +// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err +private inline fun uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler, callback: (UniffiRustCallStatus) -> U): U { + var status = UniffiRustCallStatus(); + val return_value = callback(status) + uniffiCheckCallStatus(errorHandler, status) + return return_value +} + +// Check UniffiRustCallStatus and throw an error if the call wasn't successful +private fun uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler, status: UniffiRustCallStatus) { + if (status.isSuccess()) { + return + } else if (status.isError()) { + throw errorHandler.lift(status.error_buf) + } else if (status.isPanic()) { + // when the rust code sees a panic, it tries to construct a rustbuffer + // with the message. but if that code panics, then it just sends back + // an empty buffer. + if (status.error_buf.len > 0) { + throw InternalException(FfiConverterString.lift(status.error_buf)) + } else { + throw InternalException("Rust panic") + } + } else { + throw InternalException("Unknown rust call status: $status.code") + } +} + +// UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR +object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): InternalException { + RustBuffer.free(error_buf) + return InternalException("Unexpected CALL_ERROR") + } +} + +// Call a rust function that returns a plain value +private inline fun uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U { + return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback); +} + +internal inline fun uniffiTraitInterfaceCall( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, +) { + try { + writeReturn(makeCall()) + } catch(e: Exception) { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } +} + +internal inline fun uniffiTraitInterfaceCallWithError( + callStatus: UniffiRustCallStatus, + makeCall: () -> T, + writeReturn: (T) -> Unit, + lowerError: (E) -> RustBuffer.ByValue +) { + try { + writeReturn(makeCall()) + } catch(e: Exception) { + if (e is E) { + callStatus.code = UNIFFI_CALL_ERROR + callStatus.error_buf = lowerError(e) + } else { + callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR + callStatus.error_buf = FfiConverterString.lower(e.toString()) + } + } +} +// Map handles to objects +// +// This is used pass an opaque 64-bit handle representing a foreign object to the Rust code. +internal class UniffiHandleMap { + private val map = ConcurrentHashMap() + private val counter = java.util.concurrent.atomic.AtomicLong(0) + + val size: Int + get() = map.size + + // Insert a new object into the handle map and get a handle for it + fun insert(obj: T): Long { + val handle = counter.getAndAdd(1) + map.put(handle, obj) + return handle + } + + // Get an object from the handle map + fun get(handle: Long): T { + return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle") + } + + // Remove an entry from the handlemap and get the Kotlin object back + fun remove(handle: Long): T { + return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle") + } +} + +// Contains loading, initialization code, +// and the FFI Function declarations in a com.sun.jna.Library. +@Synchronized +private fun findLibraryName(componentName: String): String { + val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride") + if (libOverride != null) { + return libOverride + } + return "matrix_sdk_ffi" +} + +private inline fun loadIndirect( + componentName: String +): Lib { + return Native.load(findLibraryName(componentName), Lib::class.java) +} + +// Define FFI callback types +internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback { + fun callback(`data`: Long,`pollResult`: Byte,) +} +internal interface UniffiForeignFutureFree : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback { + fun callback(`handle`: Long,) +} +@Structure.FieldOrder("handle", "free") +internal open class UniffiForeignFuture( + @JvmField internal var `handle`: Long = 0.toLong(), + @JvmField internal var `free`: UniffiForeignFutureFree? = null, +) : Structure() { + class UniffiByValue( + `handle`: Long = 0.toLong(), + `free`: UniffiForeignFutureFree? = null, + ): UniffiForeignFuture(`handle`,`free`,), Structure.ByValue + + internal fun uniffiSetValue(other: UniffiForeignFuture) { + `handle` = other.`handle` + `free` = other.`free` + } + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// A JNA Library to expose the extern-C FFI definitions. +// This is an implementation detail which will be called internally by the public API. + +internal interface UniffiLib : Library { + companion object { + internal val INSTANCE: UniffiLib by lazy { + loadIndirect(componentName = "matrix_sdk_crypto") + .also { lib: UniffiLib -> + uniffiCheckContractApiVersion(lib) + uniffiCheckApiChecksums(lib) + } + } + + } + + fun ffi_matrix_sdk_crypto_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + fun ffi_matrix_sdk_crypto_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + fun ffi_matrix_sdk_crypto_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, + ): Unit + fun ffi_matrix_sdk_crypto_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + fun ffi_matrix_sdk_crypto_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_u8(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_u8(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Byte + fun ffi_matrix_sdk_crypto_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_i8(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_i8(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Byte + fun ffi_matrix_sdk_crypto_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_u16(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_u16(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Short + fun ffi_matrix_sdk_crypto_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_i16(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_i16(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Short + fun ffi_matrix_sdk_crypto_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_u32(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_u32(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Int + fun ffi_matrix_sdk_crypto_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_i32(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_i32(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Int + fun ffi_matrix_sdk_crypto_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_u64(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_u64(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Long + fun ffi_matrix_sdk_crypto_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_i64(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_i64(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Long + fun ffi_matrix_sdk_crypto_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_f32(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_f32(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Float + fun ffi_matrix_sdk_crypto_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_f64(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_f64(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Double + fun ffi_matrix_sdk_crypto_rust_future_poll_pointer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_pointer(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_pointer(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_pointer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Pointer + fun ffi_matrix_sdk_crypto_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_rust_buffer(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_rust_buffer(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + fun ffi_matrix_sdk_crypto_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_cancel_void(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_free_void(`handle`: Long, + ): Unit + fun ffi_matrix_sdk_crypto_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus, + ): Unit + fun ffi_matrix_sdk_crypto_uniffi_contract_version( + ): Int + +} + +private fun uniffiCheckContractApiVersion(lib: UniffiLib) { + // Get the bindings contract version from our ComponentInterface + val bindings_contract_version = 26 + // Get the scaffolding contract version by calling the into the dylib + val scaffolding_contract_version = lib.ffi_matrix_sdk_crypto_uniffi_contract_version() + if (bindings_contract_version != scaffolding_contract_version) { + throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project") + } +} + +@Suppress("UNUSED_PARAMETER") +private fun uniffiCheckApiChecksums(lib: UniffiLib) { +} + +// Async support + +// Public interface members begin here. + + +// Interface implemented by anything that can contain an object reference. +// +// Such types expose a `destroy()` method that must be called to cleanly +// dispose of the contained objects. Failure to call this method may result +// in memory leaks. +// +// The easiest way to ensure this method is called is to use the `.use` +// helper method to execute a block and destroy the object at the end. +interface Disposable { + fun destroy() + companion object { + fun destroy(vararg args: Any?) { + args.filterIsInstance() + .forEach(Disposable::destroy) + } + } +} + +inline fun T.use(block: (T) -> R) = + try { + block(this) + } finally { + try { + // N.B. our implementation is on the nullable type `Disposable?`. + this?.destroy() + } catch (e: Throwable) { + // swallow + } + } + +/** Used to instantiate an interface without an actual pointer, for fakes in tests, mostly. */ +object NoPointer + +public object FfiConverterString: FfiConverter { + // Note: we don't inherit from FfiConverterRustBuffer, because we use a + // special encoding when lowering/lifting. We can use `RustBuffer.len` to + // store our length and avoid writing it out to the buffer. + override fun lift(value: RustBuffer.ByValue): String { + try { + val byteArr = ByteArray(value.len.toInt()) + value.asByteBuffer()!!.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } finally { + RustBuffer.free(value) + } + } + + override fun read(buf: ByteBuffer): String { + val len = buf.getInt() + val byteArr = ByteArray(len) + buf.get(byteArr) + return byteArr.toString(Charsets.UTF_8) + } + + fun toUtf8(value: String): ByteBuffer { + // Make sure we don't have invalid UTF-16, check for lone surrogates. + return Charsets.UTF_8.newEncoder().run { + onMalformedInput(CodingErrorAction.REPORT) + encode(CharBuffer.wrap(value)) + } + } + + override fun lower(value: String): RustBuffer.ByValue { + val byteBuf = toUtf8(value) + // Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us + // to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`. + val rbuf = RustBuffer.alloc(byteBuf.limit().toULong()) + rbuf.asByteBuffer()!!.put(byteBuf) + return rbuf + } + + // We aren't sure exactly how many bytes our string will be once it's UTF-8 + // encoded. Allocate 3 bytes per UTF-16 code unit which will always be + // enough. + override fun allocationSize(value: String): ULong { + val sizeForLength = 4UL + val sizeForString = value.length.toULong() * 3UL + return sizeForLength + sizeForString + } + + override fun write(value: String, buf: ByteBuffer) { + val byteBuf = toUtf8(value) + buf.putInt(byteBuf.limit()) + buf.put(byteBuf) + } +} + + + +/** + * The local trust state of a device. + */ + +enum class LocalTrust { + + /** + * The device has been verified and is trusted. + */ + VERIFIED, + /** + * The device been blacklisted from communicating. + */ + BLACK_LISTED, + /** + * The trust state of the device is being ignored. + */ + IGNORED, + /** + * The trust state is unset. + */ + UNSET; + companion object +} + + +public object FfiConverterTypeLocalTrust: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + LocalTrust.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: LocalTrust) = 4UL + + override fun write(value: LocalTrust, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +/** + * The result of a signature check. + */ + +enum class SignatureState { + + /** + * The signature is missing. + */ + MISSING, + /** + * The signature is invalid. + */ + INVALID, + /** + * The signature is valid but the device or user identity that created the + * signature is not trusted. + */ + VALID_BUT_NOT_TRUSTED, + /** + * The signature is valid and the device or user identity that created the + * signature is trusted. + */ + VALID_AND_TRUSTED; + companion object +} + + +public object FfiConverterTypeSignatureState: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + SignatureState.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: SignatureState) = 4UL + + override fun write(value: SignatureState, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +/** + * Our best guess at the reason why an event can't be decrypted. + */ + +enum class UtdCause { + + /** + * We don't have an explanation for why this UTD happened - it is probably + * a bug, or a network split between the two homeservers. + */ + UNKNOWN, + /** + * This event was sent when we were not a member of the room (or invited), + * so it is impossible to decrypt (without MSC3061). + */ + MEMBERSHIP; + companion object +} + + +public object FfiConverterTypeUtdCause: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + UtdCause.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: UtdCause) = 4UL + + override fun write(value: UtdCause, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + diff --git a/sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_ui/matrix_sdk_ui.kt b/sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_ui/matrix_sdk_ui.kt index 597ebf7..37df61f 100644 --- a/sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_ui/matrix_sdk_ui.kt +++ b/sdk/sdk-android/src/main/kotlin/uniffi/matrix_sdk_ui/matrix_sdk_ui.kt @@ -677,26 +677,38 @@ public object FfiConverterString: FfiConverter { +/** + * Where this event came. + */ -enum class BackPaginationStatus { +enum class EventItemOrigin { - IDLE, - PAGINATING, - TIMELINE_START_REACHED; + /** + * The event was created locally. + */ + LOCAL, + /** + * The event came from a sync response. + */ + SYNC, + /** + * The event came from pagination. + */ + PAGINATION; companion object } -public object FfiConverterTypeBackPaginationStatus: FfiConverterRustBuffer { +public object FfiConverterTypeEventItemOrigin: FfiConverterRustBuffer { override fun read(buf: ByteBuffer) = try { - BackPaginationStatus.values()[buf.getInt() - 1] + EventItemOrigin.values()[buf.getInt() - 1] } catch (e: IndexOutOfBoundsException) { throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun allocationSize(value: BackPaginationStatus) = 4UL + override fun allocationSize(value: EventItemOrigin) = 4UL - override fun write(value: BackPaginationStatus, buf: ByteBuffer) { + override fun write(value: EventItemOrigin, buf: ByteBuffer) { buf.putInt(value.ordinal + 1) } } @@ -706,37 +718,38 @@ public object FfiConverterTypeBackPaginationStatus: FfiConverterRustBuffer { +public object FfiConverterTypePaginationStatus: FfiConverterRustBuffer { override fun read(buf: ByteBuffer) = try { - EventItemOrigin.values()[buf.getInt() - 1] + PaginationStatus.values()[buf.getInt() - 1] } catch (e: IndexOutOfBoundsException) { throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun allocationSize(value: EventItemOrigin) = 4UL + override fun allocationSize(value: PaginationStatus) = 4UL - override fun write(value: EventItemOrigin, buf: ByteBuffer) { + override fun write(value: PaginationStatus, buf: ByteBuffer) { buf.putInt(value.ordinal + 1) } }