@@ -474,14 +474,16 @@ public class AuthenticationService: AuthenticationServiceProtocol {
474
474
required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
475
475
self.pointer = pointer
476
476
}
477
- public convenience init(basePath: String, passphrase: String?, userAgent: String?, oidcConfiguration: OidcConfiguration?, customSlidingSyncProxy: String?) {
477
+ public convenience init(basePath: String, passphrase: String?, userAgent: String?, oidcConfiguration: OidcConfiguration?, customSlidingSyncProxy: String?, sessionDelegate: ClientSessionDelegate?, crossProcessRefreshLockId: String? ) {
478
478
self.init(unsafeFromRawPointer: try! rustCall() {
479
479
uniffi_matrix_sdk_ffi_fn_constructor_authenticationservice_new(
480
480
FfiConverterString.lower(basePath),
481
481
FfiConverterOptionString.lower(passphrase),
482
482
FfiConverterOptionString.lower(userAgent),
483
483
FfiConverterOptionTypeOidcConfiguration.lower(oidcConfiguration),
484
- FfiConverterOptionString.lower(customSlidingSyncProxy),$0)
484
+ FfiConverterOptionString.lower(customSlidingSyncProxy),
485
+ FfiConverterOptionCallbackInterfaceClientSessionDelegate.lower(sessionDelegate),
486
+ FfiConverterOptionString.lower(crossProcessRefreshLockId),$0)
485
487
})
486
488
}
487
489
@@ -1037,11 +1039,13 @@ public protocol ClientBuilderProtocol {
1037
1039
func build() throws -> Client
1038
1040
func disableAutomaticTokenRefresh() -> ClientBuilder
1039
1041
func disableSslVerification() -> ClientBuilder
1042
+ func enableCrossProcessRefreshLock(processId: String, sessionDelegate: ClientSessionDelegate) -> ClientBuilder
1040
1043
func homeserverUrl(url: String) -> ClientBuilder
1041
1044
func passphrase(passphrase: String?) -> ClientBuilder
1042
1045
func proxy(url: String) -> ClientBuilder
1043
1046
func serverName(serverName: String) -> ClientBuilder
1044
1047
func serverVersions(versions: [String]) -> ClientBuilder
1048
+ func setSessionDelegate(sessionDelegate: ClientSessionDelegate) -> ClientBuilder
1045
1049
func slidingSyncProxy(slidingSyncProxy: String?) -> ClientBuilder
1046
1050
func userAgent(userAgent: String) -> ClientBuilder
1047
1051
func username(username: String) -> ClientBuilder
@@ -1116,6 +1120,19 @@ public class ClientBuilder: ClientBuilderProtocol {
1116
1120
)
1117
1121
}
1118
1122
1123
+ public func enableCrossProcessRefreshLock(processId: String, sessionDelegate: ClientSessionDelegate) -> ClientBuilder {
1124
+ return try! FfiConverterTypeClientBuilder.lift(
1125
+ try!
1126
+ rustCall() {
1127
+
1128
+ uniffi_matrix_sdk_ffi_fn_method_clientbuilder_enable_cross_process_refresh_lock(self.pointer,
1129
+ FfiConverterString.lower(processId),
1130
+ FfiConverterCallbackInterfaceClientSessionDelegate.lower(sessionDelegate),$0
1131
+ )
1132
+ }
1133
+ )
1134
+ }
1135
+
1119
1136
public func homeserverUrl(url: String) -> ClientBuilder {
1120
1137
return try! FfiConverterTypeClientBuilder.lift(
1121
1138
try!
@@ -1176,6 +1193,18 @@ public class ClientBuilder: ClientBuilderProtocol {
1176
1193
)
1177
1194
}
1178
1195
1196
+ public func setSessionDelegate(sessionDelegate: ClientSessionDelegate) -> ClientBuilder {
1197
+ return try! FfiConverterTypeClientBuilder.lift(
1198
+ try!
1199
+ rustCall() {
1200
+
1201
+ uniffi_matrix_sdk_ffi_fn_method_clientbuilder_set_session_delegate(self.pointer,
1202
+ FfiConverterCallbackInterfaceClientSessionDelegate.lower(sessionDelegate),$0
1203
+ )
1204
+ }
1205
+ )
1206
+ }
1207
+
1179
1208
public func slidingSyncProxy(slidingSyncProxy: String?) -> ClientBuilder {
1180
1209
return try! FfiConverterTypeClientBuilder.lift(
1181
1210
try!
@@ -7622,11 +7651,11 @@ public struct RoomInfo {
7622
7651
public var joinedMembersCount: UInt64
7623
7652
public var highlightCount: UInt64
7624
7653
public var notificationCount: UInt64
7625
- public var notificationMode : RoomNotificationMode?
7654
+ public var userDefinedNotificationMode : RoomNotificationMode?
7626
7655
7627
7656
// Default memberwise initializers are never public by default, so we
7628
7657
// declare one manually.
7629
- public init(id: String, name: String?, topic: String?, avatarUrl: String?, isDirect: Bool, isPublic: Bool, isSpace: Bool, isTombstoned: Bool, canonicalAlias: String?, alternativeAliases: [String], membership: Membership, latestEvent: EventTimelineItem?, inviter: RoomMember?, activeMembersCount: UInt64, invitedMembersCount: UInt64, joinedMembersCount: UInt64, highlightCount: UInt64, notificationCount: UInt64, notificationMode : RoomNotificationMode?) {
7658
+ public init(id: String, name: String?, topic: String?, avatarUrl: String?, isDirect: Bool, isPublic: Bool, isSpace: Bool, isTombstoned: Bool, canonicalAlias: String?, alternativeAliases: [String], membership: Membership, latestEvent: EventTimelineItem?, inviter: RoomMember?, activeMembersCount: UInt64, invitedMembersCount: UInt64, joinedMembersCount: UInt64, highlightCount: UInt64, notificationCount: UInt64, userDefinedNotificationMode : RoomNotificationMode?) {
7630
7659
self.id = id
7631
7660
self.name = name
7632
7661
self.topic = topic
@@ -7645,7 +7674,7 @@ public struct RoomInfo {
7645
7674
self.joinedMembersCount = joinedMembersCount
7646
7675
self.highlightCount = highlightCount
7647
7676
self.notificationCount = notificationCount
7648
- self.notificationMode = notificationMode
7677
+ self.userDefinedNotificationMode = userDefinedNotificationMode
7649
7678
}
7650
7679
}
7651
7680
@@ -7672,7 +7701,7 @@ public struct FfiConverterTypeRoomInfo: FfiConverterRustBuffer {
7672
7701
joinedMembersCount: FfiConverterUInt64.read(from: &buf),
7673
7702
highlightCount: FfiConverterUInt64.read(from: &buf),
7674
7703
notificationCount: FfiConverterUInt64.read(from: &buf),
7675
- notificationMode : FfiConverterOptionTypeRoomNotificationMode.read(from: &buf)
7704
+ userDefinedNotificationMode : FfiConverterOptionTypeRoomNotificationMode.read(from: &buf)
7676
7705
)
7677
7706
}
7678
7707
@@ -7695,7 +7724,7 @@ public struct FfiConverterTypeRoomInfo: FfiConverterRustBuffer {
7695
7724
FfiConverterUInt64.write(value.joinedMembersCount, into: &buf)
7696
7725
FfiConverterUInt64.write(value.highlightCount, into: &buf)
7697
7726
FfiConverterUInt64.write(value.notificationCount, into: &buf)
7698
- FfiConverterOptionTypeRoomNotificationMode.write(value.notificationMode , into: &buf)
7727
+ FfiConverterOptionTypeRoomNotificationMode.write(value.userDefinedNotificationMode , into: &buf)
7699
7728
}
7700
7729
}
7701
7730
@@ -9841,7 +9870,7 @@ public enum MessageLikeEventContent {
9841
9870
case keyVerificationDone
9842
9871
case reactionContent(relatedEventId: String)
9843
9872
case roomEncrypted
9844
- case roomMessage(messageType: MessageType)
9873
+ case roomMessage(messageType: MessageType, inReplyToEventId: String? )
9845
9874
case roomRedaction
9846
9875
case sticker
9847
9876
}
@@ -9882,7 +9911,8 @@ public struct FfiConverterTypeMessageLikeEventContent: FfiConverterRustBuffer {
9882
9911
case 13: return .roomEncrypted
9883
9912
9884
9913
case 14: return .roomMessage(
9885
- messageType: try FfiConverterTypeMessageType.read(from: &buf)
9914
+ messageType: try FfiConverterTypeMessageType.read(from: &buf),
9915
+ inReplyToEventId: try FfiConverterOptionString.read(from: &buf)
9886
9916
)
9887
9917
9888
9918
case 15: return .roomRedaction
@@ -9950,9 +9980,10 @@ public struct FfiConverterTypeMessageLikeEventContent: FfiConverterRustBuffer {
9950
9980
writeInt(&buf, Int32(13))
9951
9981
9952
9982
9953
- case let .roomMessage(messageType):
9983
+ case let .roomMessage(messageType,inReplyToEventId ):
9954
9984
writeInt(&buf, Int32(14))
9955
9985
FfiConverterTypeMessageType.write(messageType, into: &buf)
9986
+ FfiConverterOptionString.write(inReplyToEventId, into: &buf)
9956
9987
9957
9988
9958
9989
case .roomRedaction:
@@ -13137,6 +13168,147 @@ extension FfiConverterCallbackInterfaceClientDelegate : FfiConverter {
13137
13168
13138
13169
13139
13170
13171
+ // Declaration and FfiConverters for ClientSessionDelegate Callback Interface
13172
+
13173
+ public protocol ClientSessionDelegate : AnyObject {
13174
+ func retrieveSessionFromKeychain(userId: String) throws -> Session
13175
+ func saveSessionInKeychain(session: Session)
13176
+
13177
+ }
13178
+
13179
+ // The ForeignCallback that is passed to Rust.
13180
+ fileprivate let foreignCallbackCallbackInterfaceClientSessionDelegate : ForeignCallback =
13181
+ { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer<UInt8>, argsLen: Int32, out_buf: UnsafeMutablePointer<RustBuffer>) -> Int32 in
13182
+
13183
+
13184
+ func invokeRetrieveSessionFromKeychain(_ swiftCallbackInterface: ClientSessionDelegate, _ argsData: UnsafePointer<UInt8>, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer<RustBuffer>) throws -> Int32 {
13185
+ var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen)))
13186
+ func makeCall() throws -> Int32 {
13187
+ let result = try swiftCallbackInterface.retrieveSessionFromKeychain(
13188
+ userId: try FfiConverterString.read(from: &reader)
13189
+ )
13190
+ var writer = [UInt8]()
13191
+ FfiConverterTypeSession.write(result, into: &writer)
13192
+ out_buf.pointee = RustBuffer(bytes: writer)
13193
+ return UNIFFI_CALLBACK_SUCCESS
13194
+ }
13195
+ do {
13196
+ return try makeCall()
13197
+ } catch let error as ClientError {
13198
+ out_buf.pointee = FfiConverterTypeClientError.lower(error)
13199
+ return UNIFFI_CALLBACK_ERROR
13200
+ }
13201
+ }
13202
+
13203
+ func invokeSaveSessionInKeychain(_ swiftCallbackInterface: ClientSessionDelegate, _ argsData: UnsafePointer<UInt8>, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer<RustBuffer>) throws -> Int32 {
13204
+ var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen)))
13205
+ func makeCall() throws -> Int32 {
13206
+ try swiftCallbackInterface.saveSessionInKeychain(
13207
+ session: try FfiConverterTypeSession.read(from: &reader)
13208
+ )
13209
+ return UNIFFI_CALLBACK_SUCCESS
13210
+ }
13211
+ return try makeCall()
13212
+ }
13213
+
13214
+
13215
+ switch method {
13216
+ case IDX_CALLBACK_FREE:
13217
+ FfiConverterCallbackInterfaceClientSessionDelegate.drop(handle: handle)
13218
+ // Sucessful return
13219
+ // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
13220
+ return UNIFFI_CALLBACK_SUCCESS
13221
+ case 1:
13222
+ let cb: ClientSessionDelegate
13223
+ do {
13224
+ cb = try FfiConverterCallbackInterfaceClientSessionDelegate.lift(handle)
13225
+ } catch {
13226
+ out_buf.pointee = FfiConverterString.lower("ClientSessionDelegate: Invalid handle")
13227
+ return UNIFFI_CALLBACK_UNEXPECTED_ERROR
13228
+ }
13229
+ do {
13230
+ return try invokeRetrieveSessionFromKeychain(cb, argsData, argsLen, out_buf)
13231
+ } catch let error {
13232
+ out_buf.pointee = FfiConverterString.lower(String(describing: error))
13233
+ return UNIFFI_CALLBACK_UNEXPECTED_ERROR
13234
+ }
13235
+ case 2:
13236
+ let cb: ClientSessionDelegate
13237
+ do {
13238
+ cb = try FfiConverterCallbackInterfaceClientSessionDelegate.lift(handle)
13239
+ } catch {
13240
+ out_buf.pointee = FfiConverterString.lower("ClientSessionDelegate: Invalid handle")
13241
+ return UNIFFI_CALLBACK_UNEXPECTED_ERROR
13242
+ }
13243
+ do {
13244
+ return try invokeSaveSessionInKeychain(cb, argsData, argsLen, out_buf)
13245
+ } catch let error {
13246
+ out_buf.pointee = FfiConverterString.lower(String(describing: error))
13247
+ return UNIFFI_CALLBACK_UNEXPECTED_ERROR
13248
+ }
13249
+
13250
+ // This should never happen, because an out of bounds method index won't
13251
+ // ever be used. Once we can catch errors, we should return an InternalError.
13252
+ // https://github.com/mozilla/uniffi-rs/issues/351
13253
+ default:
13254
+ // An unexpected error happened.
13255
+ // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs`
13256
+ return UNIFFI_CALLBACK_UNEXPECTED_ERROR
13257
+ }
13258
+ }
13259
+
13260
+ // FfiConverter protocol for callback interfaces
13261
+ fileprivate struct FfiConverterCallbackInterfaceClientSessionDelegate {
13262
+ private static let initCallbackOnce: () = {
13263
+ // Swift ensures this initializer code will once run once, even when accessed by multiple threads.
13264
+ try! rustCall { (err: UnsafeMutablePointer<RustCallStatus>) in
13265
+ uniffi_matrix_sdk_ffi_fn_init_callback_clientsessiondelegate(foreignCallbackCallbackInterfaceClientSessionDelegate, err)
13266
+ }
13267
+ }()
13268
+
13269
+ private static func ensureCallbackinitialized() {
13270
+ _ = initCallbackOnce
13271
+ }
13272
+
13273
+ static func drop(handle: UniFFICallbackHandle) {
13274
+ handleMap.remove(handle: handle)
13275
+ }
13276
+
13277
+ private static var handleMap = UniFFICallbackHandleMap<ClientSessionDelegate>()
13278
+ }
13279
+
13280
+ extension FfiConverterCallbackInterfaceClientSessionDelegate : FfiConverter {
13281
+ typealias SwiftType = ClientSessionDelegate
13282
+ // We can use Handle as the FfiType because it's a typealias to UInt64
13283
+ typealias FfiType = UniFFICallbackHandle
13284
+
13285
+ public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType {
13286
+ ensureCallbackinitialized();
13287
+ guard let callback = handleMap.get(handle: handle) else {
13288
+ throw UniffiInternalError.unexpectedStaleHandle
13289
+ }
13290
+ return callback
13291
+ }
13292
+
13293
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
13294
+ ensureCallbackinitialized();
13295
+ let handle: UniFFICallbackHandle = try readInt(&buf)
13296
+ return try lift(handle)
13297
+ }
13298
+
13299
+ public static func lower(_ v: SwiftType) -> UniFFICallbackHandle {
13300
+ ensureCallbackinitialized();
13301
+ return handleMap.insert(obj: v)
13302
+ }
13303
+
13304
+ public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
13305
+ ensureCallbackinitialized();
13306
+ writeInt(&buf, lower(v))
13307
+ }
13308
+ }
13309
+
13310
+
13311
+
13140
13312
// Declaration and FfiConverters for NotificationSettingsDelegate Callback Interface
13141
13313
13142
13314
public protocol NotificationSettingsDelegate : AnyObject {
@@ -15210,6 +15382,27 @@ fileprivate struct FfiConverterOptionCallbackInterfaceClientDelegate: FfiConvert
15210
15382
}
15211
15383
}
15212
15384
15385
+ fileprivate struct FfiConverterOptionCallbackInterfaceClientSessionDelegate: FfiConverterRustBuffer {
15386
+ typealias SwiftType = ClientSessionDelegate?
15387
+
15388
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
15389
+ guard let value = value else {
15390
+ writeInt(&buf, Int8(0))
15391
+ return
15392
+ }
15393
+ writeInt(&buf, Int8(1))
15394
+ FfiConverterCallbackInterfaceClientSessionDelegate.write(value, into: &buf)
15395
+ }
15396
+
15397
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
15398
+ switch try readInt(&buf) as Int8 {
15399
+ case 0: return nil
15400
+ case 1: return try FfiConverterCallbackInterfaceClientSessionDelegate.read(from: &buf)
15401
+ default: throw UniffiInternalError.unexpectedOptionalTag
15402
+ }
15403
+ }
15404
+ }
15405
+
15213
15406
fileprivate struct FfiConverterOptionCallbackInterfaceNotificationSettingsDelegate: FfiConverterRustBuffer {
15214
15407
typealias SwiftType = NotificationSettingsDelegate?
15215
15408
@@ -17472,6 +17665,9 @@ private var initializationResult: InitializationResult {
17472
17665
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_disable_ssl_verification() != 1510) {
17473
17666
return InitializationResult.apiChecksumMismatch
17474
17667
}
17668
+ if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_enable_cross_process_refresh_lock() != 39606) {
17669
+ return InitializationResult.apiChecksumMismatch
17670
+ }
17475
17671
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_homeserver_url() != 43790) {
17476
17672
return InitializationResult.apiChecksumMismatch
17477
17673
}
@@ -17487,6 +17683,9 @@ private var initializationResult: InitializationResult {
17487
17683
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_server_versions() != 64538) {
17488
17684
return InitializationResult.apiChecksumMismatch
17489
17685
}
17686
+ if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_set_session_delegate() != 7269) {
17687
+ return InitializationResult.apiChecksumMismatch
17688
+ }
17490
17689
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_sliding_sync_proxy() != 37450) {
17491
17690
return InitializationResult.apiChecksumMismatch
17492
17691
}
@@ -18078,7 +18277,7 @@ private var initializationResult: InitializationResult {
18078
18277
if (uniffi_matrix_sdk_ffi_checksum_constructor_mediasource_from_json() != 31512) {
18079
18278
return InitializationResult.apiChecksumMismatch
18080
18279
}
18081
- if (uniffi_matrix_sdk_ffi_checksum_constructor_authenticationservice_new() != 62706 ) {
18280
+ if (uniffi_matrix_sdk_ffi_checksum_constructor_authenticationservice_new() != 41347 ) {
18082
18281
return InitializationResult.apiChecksumMismatch
18083
18282
}
18084
18283
if (uniffi_matrix_sdk_ffi_checksum_constructor_clientbuilder_new() != 53567) {
@@ -18099,6 +18298,12 @@ private var initializationResult: InitializationResult {
18099
18298
if (uniffi_matrix_sdk_ffi_checksum_method_clientdelegate_did_refresh_tokens() != 32841) {
18100
18299
return InitializationResult.apiChecksumMismatch
18101
18300
}
18301
+ if (uniffi_matrix_sdk_ffi_checksum_method_clientsessiondelegate_retrieve_session_from_keychain() != 8049) {
18302
+ return InitializationResult.apiChecksumMismatch
18303
+ }
18304
+ if (uniffi_matrix_sdk_ffi_checksum_method_clientsessiondelegate_save_session_in_keychain() != 30188) {
18305
+ return InitializationResult.apiChecksumMismatch
18306
+ }
18102
18307
if (uniffi_matrix_sdk_ffi_checksum_method_notificationsettingsdelegate_settings_did_change() != 4921) {
18103
18308
return InitializationResult.apiChecksumMismatch
18104
18309
}
0 commit comments