diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index f17cefb29..66e83e8ea 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -9436,7 +9436,7 @@ repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = 25.10.21; + version = 25.10.27; }; }; 701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7f08c5c26..9ac6ba3aa 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -149,8 +149,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/element-hq/matrix-rust-components-swift", "state" : { - "revision" : "bb0db6dabeceb59daade5d84ca56c7e7db0c10c5", - "version" : "25.10.21" + "revision" : "496a5e7846f81180cb6a0b5c5b74dc88e096fc0c", + "version" : "25.10.27" } }, { diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 399968a7a..a50a97e62 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -6,6 +6,63 @@ import Foundation +open class CheckCodeSenderSDKMock: MatrixRustSDK.CheckCodeSender, @unchecked Sendable { + init() { + super.init(noPointer: .init()) + } + + public required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + fatalError("init(unsafeFromRawPointer:) has not been implemented") + } + + fileprivate var pointer: UnsafeMutableRawPointer! + + //MARK: - send + + open var sendCodeThrowableError: Error? + var sendCodeUnderlyingCallsCount = 0 + open var sendCodeCallsCount: Int { + get { + if Thread.isMainThread { + return sendCodeUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = sendCodeUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + sendCodeUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + sendCodeUnderlyingCallsCount = newValue + } + } + } + } + open var sendCodeCalled: Bool { + return sendCodeCallsCount > 0 + } + open var sendCodeReceivedCode: UInt8? + open var sendCodeReceivedInvocations: [UInt8] = [] + open var sendCodeClosure: ((UInt8) async throws -> Void)? + + open override func send(code: UInt8) async throws { + if let error = sendCodeThrowableError { + throw error + } + sendCodeCallsCount += 1 + sendCodeReceivedCode = code + DispatchQueue.main.async { + self.sendCodeReceivedInvocations.append(code) + } + try await sendCodeClosure?(code) + } +} open class ClientSDKMock: MatrixRustSDK.Client, @unchecked Sendable { init() { super.init(noPointer: .init()) @@ -3190,16 +3247,15 @@ open class ClientSDKMock: MatrixRustSDK.Client, @unchecked Sendable { //MARK: - loginWithQrCode - open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerThrowableError: Error? - var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = 0 - open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount: Int { + var loginWithQrCodeOidcConfigurationUnderlyingCallsCount = 0 + open var loginWithQrCodeOidcConfigurationCallsCount: Int { get { if Thread.isMainThread { - return loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount + return loginWithQrCodeOidcConfigurationUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount + returnValue = loginWithQrCodeOidcConfigurationUnderlyingCallsCount } return returnValue! @@ -3207,31 +3263,57 @@ open class ClientSDKMock: MatrixRustSDK.Client, @unchecked Sendable { } set { if Thread.isMainThread { - loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue + loginWithQrCodeOidcConfigurationUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerUnderlyingCallsCount = newValue + loginWithQrCodeOidcConfigurationUnderlyingCallsCount = newValue } } } } - open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCalled: Bool { - return loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount > 0 + open var loginWithQrCodeOidcConfigurationCalled: Bool { + return loginWithQrCodeOidcConfigurationCallsCount > 0 } - open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments: (qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener)? - open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations: [(qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener)] = [] - open var loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure: ((QrCodeData, OidcConfiguration, QrLoginProgressListener) async throws -> Void)? + open var loginWithQrCodeOidcConfigurationReceivedOidcConfiguration: OidcConfiguration? + open var loginWithQrCodeOidcConfigurationReceivedInvocations: [OidcConfiguration] = [] - open override func loginWithQrCode(qrCodeData: QrCodeData, oidcConfiguration: OidcConfiguration, progressListener: QrLoginProgressListener) async throws { - if let error = loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerThrowableError { - throw error + var loginWithQrCodeOidcConfigurationUnderlyingReturnValue: LoginWithQrCodeHandler! + open var loginWithQrCodeOidcConfigurationReturnValue: LoginWithQrCodeHandler! { + get { + if Thread.isMainThread { + return loginWithQrCodeOidcConfigurationUnderlyingReturnValue + } else { + var returnValue: LoginWithQrCodeHandler? = nil + DispatchQueue.main.sync { + returnValue = loginWithQrCodeOidcConfigurationUnderlyingReturnValue + } + + return returnValue! + } } - loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerCallsCount += 1 - loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedArguments = (qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener) + set { + if Thread.isMainThread { + loginWithQrCodeOidcConfigurationUnderlyingReturnValue = newValue + } else { + DispatchQueue.main.sync { + loginWithQrCodeOidcConfigurationUnderlyingReturnValue = newValue + } + } + } + } + open var loginWithQrCodeOidcConfigurationClosure: ((OidcConfiguration) -> LoginWithQrCodeHandler)? + + open override func loginWithQrCode(oidcConfiguration: OidcConfiguration) -> LoginWithQrCodeHandler { + loginWithQrCodeOidcConfigurationCallsCount += 1 + loginWithQrCodeOidcConfigurationReceivedOidcConfiguration = oidcConfiguration DispatchQueue.main.async { - self.loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerReceivedInvocations.append((qrCodeData: qrCodeData, oidcConfiguration: oidcConfiguration, progressListener: progressListener)) + self.loginWithQrCodeOidcConfigurationReceivedInvocations.append(oidcConfiguration) + } + if let loginWithQrCodeOidcConfigurationClosure = loginWithQrCodeOidcConfigurationClosure { + return loginWithQrCodeOidcConfigurationClosure(oidcConfiguration) + } else { + return loginWithQrCodeOidcConfigurationReturnValue } - try await loginWithQrCodeQrCodeDataOidcConfigurationProgressListenerClosure?(qrCodeData, oidcConfiguration, progressListener) } //MARK: - logout @@ -5119,6 +5201,81 @@ open class ClientSDKMock: MatrixRustSDK.Client, @unchecked Sendable { } } + //MARK: - subscribeToSendQueueUpdates + + open var subscribeToSendQueueUpdatesListenerThrowableError: Error? + var subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = 0 + open var subscribeToSendQueueUpdatesListenerCallsCount: Int { + get { + if Thread.isMainThread { + return subscribeToSendQueueUpdatesListenerUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = subscribeToSendQueueUpdatesListenerUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = newValue + } + } + } + } + open var subscribeToSendQueueUpdatesListenerCalled: Bool { + return subscribeToSendQueueUpdatesListenerCallsCount > 0 + } + open var subscribeToSendQueueUpdatesListenerReceivedListener: SendQueueRoomUpdateListener? + open var subscribeToSendQueueUpdatesListenerReceivedInvocations: [SendQueueRoomUpdateListener] = [] + + var subscribeToSendQueueUpdatesListenerUnderlyingReturnValue: TaskHandle! + open var subscribeToSendQueueUpdatesListenerReturnValue: TaskHandle! { + get { + if Thread.isMainThread { + return subscribeToSendQueueUpdatesListenerUnderlyingReturnValue + } else { + var returnValue: TaskHandle? = nil + DispatchQueue.main.sync { + returnValue = subscribeToSendQueueUpdatesListenerUnderlyingReturnValue + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + subscribeToSendQueueUpdatesListenerUnderlyingReturnValue = newValue + } else { + DispatchQueue.main.sync { + subscribeToSendQueueUpdatesListenerUnderlyingReturnValue = newValue + } + } + } + } + open var subscribeToSendQueueUpdatesListenerClosure: ((SendQueueRoomUpdateListener) async throws -> TaskHandle)? + + open override func subscribeToSendQueueUpdates(listener: SendQueueRoomUpdateListener) async throws -> TaskHandle { + if let error = subscribeToSendQueueUpdatesListenerThrowableError { + throw error + } + subscribeToSendQueueUpdatesListenerCallsCount += 1 + subscribeToSendQueueUpdatesListenerReceivedListener = listener + DispatchQueue.main.async { + self.subscribeToSendQueueUpdatesListenerReceivedInvocations.append(listener) + } + if let subscribeToSendQueueUpdatesListenerClosure = subscribeToSendQueueUpdatesListenerClosure { + return try await subscribeToSendQueueUpdatesListenerClosure(listener) + } else { + return subscribeToSendQueueUpdatesListenerReturnValue + } + } + //MARK: - syncService var syncServiceUnderlyingCallsCount = 0 @@ -10257,6 +10414,109 @@ open class LeaveSpaceHandleSDKMock: MatrixRustSDK.LeaveSpaceHandle, @unchecked S } } } +open class LoginWithQrCodeHandlerSDKMock: MatrixRustSDK.LoginWithQrCodeHandler, @unchecked Sendable { + init() { + super.init(noPointer: .init()) + } + + public required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + fatalError("init(unsafeFromRawPointer:) has not been implemented") + } + + fileprivate var pointer: UnsafeMutableRawPointer! + + //MARK: - generate + + open var generateProgressListenerThrowableError: Error? + var generateProgressListenerUnderlyingCallsCount = 0 + open var generateProgressListenerCallsCount: Int { + get { + if Thread.isMainThread { + return generateProgressListenerUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = generateProgressListenerUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + generateProgressListenerUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + generateProgressListenerUnderlyingCallsCount = newValue + } + } + } + } + open var generateProgressListenerCalled: Bool { + return generateProgressListenerCallsCount > 0 + } + open var generateProgressListenerReceivedProgressListener: GeneratedQrLoginProgressListener? + open var generateProgressListenerReceivedInvocations: [GeneratedQrLoginProgressListener] = [] + open var generateProgressListenerClosure: ((GeneratedQrLoginProgressListener) async throws -> Void)? + + open override func generate(progressListener: GeneratedQrLoginProgressListener) async throws { + if let error = generateProgressListenerThrowableError { + throw error + } + generateProgressListenerCallsCount += 1 + generateProgressListenerReceivedProgressListener = progressListener + DispatchQueue.main.async { + self.generateProgressListenerReceivedInvocations.append(progressListener) + } + try await generateProgressListenerClosure?(progressListener) + } + + //MARK: - scan + + open var scanQrCodeDataProgressListenerThrowableError: Error? + var scanQrCodeDataProgressListenerUnderlyingCallsCount = 0 + open var scanQrCodeDataProgressListenerCallsCount: Int { + get { + if Thread.isMainThread { + return scanQrCodeDataProgressListenerUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = scanQrCodeDataProgressListenerUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + scanQrCodeDataProgressListenerUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + scanQrCodeDataProgressListenerUnderlyingCallsCount = newValue + } + } + } + } + open var scanQrCodeDataProgressListenerCalled: Bool { + return scanQrCodeDataProgressListenerCallsCount > 0 + } + open var scanQrCodeDataProgressListenerReceivedArguments: (qrCodeData: QrCodeData, progressListener: QrLoginProgressListener)? + open var scanQrCodeDataProgressListenerReceivedInvocations: [(qrCodeData: QrCodeData, progressListener: QrLoginProgressListener)] = [] + open var scanQrCodeDataProgressListenerClosure: ((QrCodeData, QrLoginProgressListener) async throws -> Void)? + + open override func scan(qrCodeData: QrCodeData, progressListener: QrLoginProgressListener) async throws { + if let error = scanQrCodeDataProgressListenerThrowableError { + throw error + } + scanQrCodeDataProgressListenerCallsCount += 1 + scanQrCodeDataProgressListenerReceivedArguments = (qrCodeData: qrCodeData, progressListener: progressListener) + DispatchQueue.main.async { + self.scanQrCodeDataProgressListenerReceivedInvocations.append((qrCodeData: qrCodeData, progressListener: progressListener)) + } + try await scanQrCodeDataProgressListenerClosure?(qrCodeData, progressListener) + } +} open class MediaFileHandleSDKMock: MatrixRustSDK.MediaFileHandle, @unchecked Sendable { init() { super.init(noPointer: .init()) diff --git a/ElementX/Sources/Services/Authentication/AuthenticationService.swift b/ElementX/Sources/Services/Authentication/AuthenticationService.swift index a680ee660..bdaa02d84 100644 --- a/ElementX/Sources/Services/Authentication/AuthenticationService.swift +++ b/ElementX/Sources/Services/Authentication/AuthenticationService.swift @@ -178,9 +178,8 @@ class AuthenticationService: AuthenticationServiceProtocol { do { let client = try await makeClient(homeserverAddress: scannedServerName) - try await client.loginWithQrCode(qrCodeData: qrData, - oidcConfiguration: appSettings.oidcConfiguration.rustValue, - progressListener: listener) + let qrCodeHandler = client.loginWithQrCode(oidcConfiguration: appSettings.oidcConfiguration.rustValue) + try await qrCodeHandler.scan(qrCodeData: qrData, progressListener: listener) return await userSession(for: client) } catch let error as HumanQrLoginError { MXLog.error("QRCode login error: \(error)") @@ -249,7 +248,7 @@ private extension HumanQrLoginError { .qrCodeError(.deviceNotSupported) case .OtherDeviceNotSignedIn: .qrCodeError(.deviceNotSignedIn) - case .Unknown, .OidcMetadataInvalid: + case .Unknown, .OidcMetadataInvalid, .CheckCodeAlreadySent, .CheckCodeCannotBeSent: .qrCodeError(.unknown) } } diff --git a/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift b/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift index 29b48ae54..9b1986a7c 100644 --- a/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift +++ b/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift @@ -44,7 +44,7 @@ struct ComposerDraftProxy: Equatable { let draftType: ComposerDraftType var toRust: ComposerDraft { - ComposerDraft(plainText: plainText, htmlText: htmlText, draftType: draftType.toRust) + ComposerDraft(plainText: plainText, htmlText: htmlText, draftType: draftType.toRust, attachments: []) } } diff --git a/project.yml b/project.yml index e0d711fc6..9ea2fe2e7 100644 --- a/project.yml +++ b/project.yml @@ -71,7 +71,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/element-hq/matrix-rust-components-swift - exactVersion: 25.10.21 + exactVersion: 25.10.27 # path: ../matrix-rust-sdk Compound: path: compound-ios