Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,484 changes: 3,084 additions & 1,400 deletions android/src/main/java/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt

Large diffs are not rendered by default.

137 changes: 135 additions & 2 deletions android/src/main/java/uniffi/matrix_sdk/matrix_sdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,47 @@ public object FfiConverterTypeRoomPowerLevelChanges: FfiConverterRustBuffer<Room



/**
* Information about the server vendor obtained from the federation API.
*/
data class ServerVendorInfo (
/**
* The server name.
*/
var `serverName`: kotlin.String,
/**
* The server version.
*/
var `version`: kotlin.String
) {

companion object
}

/**
* @suppress
*/
public object FfiConverterTypeServerVendorInfo: FfiConverterRustBuffer<ServerVendorInfo> {
override fun read(buf: ByteBuffer): ServerVendorInfo {
return ServerVendorInfo(
FfiConverterString.read(buf),
FfiConverterString.read(buf),
)
}

override fun allocationSize(value: ServerVendorInfo) = (
FfiConverterString.allocationSize(value.`serverName`) +
FfiConverterString.allocationSize(value.`version`)
)

override fun write(value: ServerVendorInfo, buf: ByteBuffer) {
FfiConverterString.write(value.`serverName`, buf)
FfiConverterString.write(value.`version`, buf)
}
}



/**
* Properties to create a new virtual Element Call widget.
*/
Expand Down Expand Up @@ -1657,7 +1698,12 @@ data class VirtualElementCallWidgetOptions (
* - `false`: the webview shows a a list of devices injected by the
* client. (used on ios & android)
*/
var `controlledMediaDevices`: kotlin.Boolean
var `controlledMediaDevices`: kotlin.Boolean,
/**
* Whether and what type of notification Element Call should send, when
* starting a call.
*/
var `sendNotificationType`: NotificationType?
) {

companion object
Expand Down Expand Up @@ -1689,6 +1735,7 @@ public object FfiConverterTypeVirtualElementCallWidgetOptions: FfiConverterRustB
FfiConverterOptionalString.read(buf),
FfiConverterOptionalString.read(buf),
FfiConverterBoolean.read(buf),
FfiConverterOptionalTypeNotificationType.read(buf),
)
}

Expand All @@ -1712,7 +1759,8 @@ public object FfiConverterTypeVirtualElementCallWidgetOptions: FfiConverterRustB
FfiConverterOptionalString.allocationSize(value.`rageshakeSubmitUrl`) +
FfiConverterOptionalString.allocationSize(value.`sentryDsn`) +
FfiConverterOptionalString.allocationSize(value.`sentryEnvironment`) +
FfiConverterBoolean.allocationSize(value.`controlledMediaDevices`)
FfiConverterBoolean.allocationSize(value.`controlledMediaDevices`) +
FfiConverterOptionalTypeNotificationType.allocationSize(value.`sendNotificationType`)
)

override fun write(value: VirtualElementCallWidgetOptions, buf: ByteBuffer) {
Expand All @@ -1736,6 +1784,7 @@ public object FfiConverterTypeVirtualElementCallWidgetOptions: FfiConverterRustB
FfiConverterOptionalString.write(value.`sentryDsn`, buf)
FfiConverterOptionalString.write(value.`sentryEnvironment`, buf)
FfiConverterBoolean.write(value.`controlledMediaDevices`, buf)
FfiConverterOptionalTypeNotificationType.write(value.`sendNotificationType`, buf)
}
}

Expand Down Expand Up @@ -1978,6 +2027,45 @@ public object FfiConverterTypeIntent: FfiConverterRustBuffer<Intent> {



/**
* Types of call notifications.
*/

enum class NotificationType {

/**
* The receiving client should display a visual notification.
*/
NOTIFICATION,
/**
* The receiving client should ring with an audible sound.
*/
RING;
companion object
}


/**
* @suppress
*/
public object FfiConverterTypeNotificationType: FfiConverterRustBuffer<NotificationType> {
override fun read(buf: ByteBuffer) = try {
NotificationType.values()[buf.getInt() - 1]
} catch (e: IndexOutOfBoundsException) {
throw RuntimeException("invalid enum value, something is very wrong!!", e)
}

override fun allocationSize(value: NotificationType) = 4UL

override fun write(value: NotificationType, buf: ByteBuffer) {
buf.putInt(value.ordinal + 1)
}
}





/**
* Current state of a [`Paginator`].
*/
Expand Down Expand Up @@ -2166,6 +2254,19 @@ public object FfiConverterTypeQRCodeLoginError : FfiConverterRustBuffer<QrCodeLo

enum class RoomMemberRole {

/**
* The member is a creator.
*
* A creator has an infinite power level and cannot be demoted, so this
* role is immutable. A room can have several creators.
*
* It is available in room versions where
* `explicitly_privilege_room_creators` in [`AuthorizationRules`] is set to
* `true`.
*
* [`AuthorizationRules`]: ruma::room_version_rules::AuthorizationRules
*/
CREATOR,
/**
* The member is an administrator.
*/
Expand Down Expand Up @@ -2470,3 +2571,35 @@ public object FfiConverterOptionalTypeIntent: FfiConverterRustBuffer<Intent?> {
}
}




/**
* @suppress
*/
public object FfiConverterOptionalTypeNotificationType: FfiConverterRustBuffer<NotificationType?> {
override fun read(buf: ByteBuffer): NotificationType? {
if (buf.get().toInt() == 0) {
return null
}
return FfiConverterTypeNotificationType.read(buf)
}

override fun allocationSize(value: NotificationType?): ULong {
if (value == null) {
return 1UL
} else {
return 1UL + FfiConverterTypeNotificationType.allocationSize(value)
}
}

override fun write(value: NotificationType?, buf: ByteBuffer) {
if (value == null) {
buf.put(0)
} else {
buf.put(1)
FfiConverterTypeNotificationType.write(value, buf)
}
}
}

87 changes: 87 additions & 0 deletions android/src/main/java/uniffi/matrix_sdk_ui/matrix_sdk_ui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,29 @@ inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
* */
object NoPointer

/**
* @suppress
*/
public object FfiConverterBoolean: FfiConverter<Boolean, Byte> {
override fun lift(value: Byte): Boolean {
return value.toInt() != 0
}

override fun read(buf: ByteBuffer): Boolean {
return lift(buf.get())
}

override fun lower(value: Boolean): Byte {
return if (value) 1.toByte() else 0.toByte()
}

override fun allocationSize(value: Boolean) = 1UL

override fun write(value: Boolean, buf: ByteBuffer) {
buf.put(lower(value))
}
}

/**
* @suppress
*/
Expand Down Expand Up @@ -1123,3 +1146,67 @@ public object FfiConverterTypeRoomPinnedEventsChange: FfiConverterRustBuffer<Roo





sealed class SpaceRoomListPaginationState {

data class Idle(
val `endReached`: kotlin.Boolean) : SpaceRoomListPaginationState() {
companion object
}

object Loading : SpaceRoomListPaginationState()




companion object
}

/**
* @suppress
*/
public object FfiConverterTypeSpaceRoomListPaginationState : FfiConverterRustBuffer<SpaceRoomListPaginationState>{
override fun read(buf: ByteBuffer): SpaceRoomListPaginationState {
return when(buf.getInt()) {
1 -> SpaceRoomListPaginationState.Idle(
FfiConverterBoolean.read(buf),
)
2 -> SpaceRoomListPaginationState.Loading
else -> throw RuntimeException("invalid enum value, something is very wrong!!")
}
}

override fun allocationSize(value: SpaceRoomListPaginationState) = when(value) {
is SpaceRoomListPaginationState.Idle -> {
// Add the size for the Int that specifies the variant plus the size needed for all fields
(
4UL
+ FfiConverterBoolean.allocationSize(value.`endReached`)
)
}
is SpaceRoomListPaginationState.Loading -> {
// Add the size for the Int that specifies the variant plus the size needed for all fields
(
4UL
)
}
}

override fun write(value: SpaceRoomListPaginationState, buf: ByteBuffer) {
when(value) {
is SpaceRoomListPaginationState.Idle -> {
buf.putInt(1)
FfiConverterBoolean.write(value.`endReached`, buf)
Unit
}
is SpaceRoomListPaginationState.Loading -> {
buf.putInt(2)
Unit
}
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
}
}



Loading
Loading