Skip to content

Commit db9a4c6

Browse files
committed
Bump to v1.1.14 (matrix-rust-sdk 6d8d174a5eec62c1213c49aaf7e9a141d3532bb1)
1 parent 482c8c0 commit db9a4c6

File tree

2 files changed

+218
-13
lines changed

2 files changed

+218
-13
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import PackageDescription
55

6-
let checksum = "a5b40d7e1e59ad84ac007b9e95a4c576c9599a77e76823543acef17d55e8588a"
7-
let version = "v1.1.13"
6+
let checksum = "7fc2dc9cec67240a071c14a5aa0fdfb0e6b44f33602d8fc6ad4efb0ed6c9dcf3"
7+
let version = "v1.1.14"
88
let url = "https://github.com/matrix-org/matrix-rust-components-swift/releases/download/\(version)/MatrixSDKFFI.xcframework.zip"
99

1010
let package = Package(

Sources/MatrixRustSDK/matrix_sdk_ffi.swift

Lines changed: 216 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,16 @@ public class AuthenticationService: AuthenticationServiceProtocol {
474474
required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
475475
self.pointer = pointer
476476
}
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?) {
478478
self.init(unsafeFromRawPointer: try! rustCall() {
479479
uniffi_matrix_sdk_ffi_fn_constructor_authenticationservice_new(
480480
FfiConverterString.lower(basePath),
481481
FfiConverterOptionString.lower(passphrase),
482482
FfiConverterOptionString.lower(userAgent),
483483
FfiConverterOptionTypeOidcConfiguration.lower(oidcConfiguration),
484-
FfiConverterOptionString.lower(customSlidingSyncProxy),$0)
484+
FfiConverterOptionString.lower(customSlidingSyncProxy),
485+
FfiConverterOptionCallbackInterfaceClientSessionDelegate.lower(sessionDelegate),
486+
FfiConverterOptionString.lower(crossProcessRefreshLockId),$0)
485487
})
486488
}
487489

@@ -1037,11 +1039,13 @@ public protocol ClientBuilderProtocol {
10371039
func build() throws -> Client
10381040
func disableAutomaticTokenRefresh() -> ClientBuilder
10391041
func disableSslVerification() -> ClientBuilder
1042+
func enableCrossProcessRefreshLock(processId: String, sessionDelegate: ClientSessionDelegate) -> ClientBuilder
10401043
func homeserverUrl(url: String) -> ClientBuilder
10411044
func passphrase(passphrase: String?) -> ClientBuilder
10421045
func proxy(url: String) -> ClientBuilder
10431046
func serverName(serverName: String) -> ClientBuilder
10441047
func serverVersions(versions: [String]) -> ClientBuilder
1048+
func setSessionDelegate(sessionDelegate: ClientSessionDelegate) -> ClientBuilder
10451049
func slidingSyncProxy(slidingSyncProxy: String?) -> ClientBuilder
10461050
func userAgent(userAgent: String) -> ClientBuilder
10471051
func username(username: String) -> ClientBuilder
@@ -1116,6 +1120,19 @@ public class ClientBuilder: ClientBuilderProtocol {
11161120
)
11171121
}
11181122

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+
11191136
public func homeserverUrl(url: String) -> ClientBuilder {
11201137
return try! FfiConverterTypeClientBuilder.lift(
11211138
try!
@@ -1176,6 +1193,18 @@ public class ClientBuilder: ClientBuilderProtocol {
11761193
)
11771194
}
11781195

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+
11791208
public func slidingSyncProxy(slidingSyncProxy: String?) -> ClientBuilder {
11801209
return try! FfiConverterTypeClientBuilder.lift(
11811210
try!
@@ -7622,11 +7651,11 @@ public struct RoomInfo {
76227651
public var joinedMembersCount: UInt64
76237652
public var highlightCount: UInt64
76247653
public var notificationCount: UInt64
7625-
public var notificationMode: RoomNotificationMode?
7654+
public var userDefinedNotificationMode: RoomNotificationMode?
76267655

76277656
// Default memberwise initializers are never public by default, so we
76287657
// 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?) {
76307659
self.id = id
76317660
self.name = name
76327661
self.topic = topic
@@ -7645,7 +7674,7 @@ public struct RoomInfo {
76457674
self.joinedMembersCount = joinedMembersCount
76467675
self.highlightCount = highlightCount
76477676
self.notificationCount = notificationCount
7648-
self.notificationMode = notificationMode
7677+
self.userDefinedNotificationMode = userDefinedNotificationMode
76497678
}
76507679
}
76517680

@@ -7672,7 +7701,7 @@ public struct FfiConverterTypeRoomInfo: FfiConverterRustBuffer {
76727701
joinedMembersCount: FfiConverterUInt64.read(from: &buf),
76737702
highlightCount: FfiConverterUInt64.read(from: &buf),
76747703
notificationCount: FfiConverterUInt64.read(from: &buf),
7675-
notificationMode: FfiConverterOptionTypeRoomNotificationMode.read(from: &buf)
7704+
userDefinedNotificationMode: FfiConverterOptionTypeRoomNotificationMode.read(from: &buf)
76767705
)
76777706
}
76787707

@@ -7695,7 +7724,7 @@ public struct FfiConverterTypeRoomInfo: FfiConverterRustBuffer {
76957724
FfiConverterUInt64.write(value.joinedMembersCount, into: &buf)
76967725
FfiConverterUInt64.write(value.highlightCount, into: &buf)
76977726
FfiConverterUInt64.write(value.notificationCount, into: &buf)
7698-
FfiConverterOptionTypeRoomNotificationMode.write(value.notificationMode, into: &buf)
7727+
FfiConverterOptionTypeRoomNotificationMode.write(value.userDefinedNotificationMode, into: &buf)
76997728
}
77007729
}
77017730

@@ -9841,7 +9870,7 @@ public enum MessageLikeEventContent {
98419870
case keyVerificationDone
98429871
case reactionContent(relatedEventId: String)
98439872
case roomEncrypted
9844-
case roomMessage(messageType: MessageType)
9873+
case roomMessage(messageType: MessageType, inReplyToEventId: String?)
98459874
case roomRedaction
98469875
case sticker
98479876
}
@@ -9882,7 +9911,8 @@ public struct FfiConverterTypeMessageLikeEventContent: FfiConverterRustBuffer {
98829911
case 13: return .roomEncrypted
98839912

98849913
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)
98869916
)
98879917

98889918
case 15: return .roomRedaction
@@ -9950,9 +9980,10 @@ public struct FfiConverterTypeMessageLikeEventContent: FfiConverterRustBuffer {
99509980
writeInt(&buf, Int32(13))
99519981

99529982

9953-
case let .roomMessage(messageType):
9983+
case let .roomMessage(messageType,inReplyToEventId):
99549984
writeInt(&buf, Int32(14))
99559985
FfiConverterTypeMessageType.write(messageType, into: &buf)
9986+
FfiConverterOptionString.write(inReplyToEventId, into: &buf)
99569987

99579988

99589989
case .roomRedaction:
@@ -13137,6 +13168,147 @@ extension FfiConverterCallbackInterfaceClientDelegate : FfiConverter {
1313713168

1313813169

1313913170

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+
1314013312
// Declaration and FfiConverters for NotificationSettingsDelegate Callback Interface
1314113313

1314213314
public protocol NotificationSettingsDelegate : AnyObject {
@@ -15210,6 +15382,27 @@ fileprivate struct FfiConverterOptionCallbackInterfaceClientDelegate: FfiConvert
1521015382
}
1521115383
}
1521215384

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+
1521315406
fileprivate struct FfiConverterOptionCallbackInterfaceNotificationSettingsDelegate: FfiConverterRustBuffer {
1521415407
typealias SwiftType = NotificationSettingsDelegate?
1521515408

@@ -17472,6 +17665,9 @@ private var initializationResult: InitializationResult {
1747217665
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_disable_ssl_verification() != 1510) {
1747317666
return InitializationResult.apiChecksumMismatch
1747417667
}
17668+
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_enable_cross_process_refresh_lock() != 39606) {
17669+
return InitializationResult.apiChecksumMismatch
17670+
}
1747517671
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_homeserver_url() != 43790) {
1747617672
return InitializationResult.apiChecksumMismatch
1747717673
}
@@ -17487,6 +17683,9 @@ private var initializationResult: InitializationResult {
1748717683
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_server_versions() != 64538) {
1748817684
return InitializationResult.apiChecksumMismatch
1748917685
}
17686+
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_set_session_delegate() != 7269) {
17687+
return InitializationResult.apiChecksumMismatch
17688+
}
1749017689
if (uniffi_matrix_sdk_ffi_checksum_method_clientbuilder_sliding_sync_proxy() != 37450) {
1749117690
return InitializationResult.apiChecksumMismatch
1749217691
}
@@ -18078,7 +18277,7 @@ private var initializationResult: InitializationResult {
1807818277
if (uniffi_matrix_sdk_ffi_checksum_constructor_mediasource_from_json() != 31512) {
1807918278
return InitializationResult.apiChecksumMismatch
1808018279
}
18081-
if (uniffi_matrix_sdk_ffi_checksum_constructor_authenticationservice_new() != 62706) {
18280+
if (uniffi_matrix_sdk_ffi_checksum_constructor_authenticationservice_new() != 41347) {
1808218281
return InitializationResult.apiChecksumMismatch
1808318282
}
1808418283
if (uniffi_matrix_sdk_ffi_checksum_constructor_clientbuilder_new() != 53567) {
@@ -18099,6 +18298,12 @@ private var initializationResult: InitializationResult {
1809918298
if (uniffi_matrix_sdk_ffi_checksum_method_clientdelegate_did_refresh_tokens() != 32841) {
1810018299
return InitializationResult.apiChecksumMismatch
1810118300
}
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+
}
1810218307
if (uniffi_matrix_sdk_ffi_checksum_method_notificationsettingsdelegate_settings_did_change() != 4921) {
1810318308
return InitializationResult.apiChecksumMismatch
1810418309
}

0 commit comments

Comments
 (0)