From 3cf4faec834e7e71dcfb8ea4e1c3f0542c80f2f2 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Tue, 17 Feb 2026 08:36:00 +0000 Subject: [PATCH] feat(ffi): additional HumanQrGrantLoginError enum values --- bindings/matrix-sdk-ffi/CHANGELOG.md | 10 ++++++ bindings/matrix-sdk-ffi/src/qr_code.rs | 45 +++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/bindings/matrix-sdk-ffi/CHANGELOG.md b/bindings/matrix-sdk-ffi/CHANGELOG.md index afa8fcf02..07e3ae16d 100644 --- a/bindings/matrix-sdk-ffi/CHANGELOG.md +++ b/bindings/matrix-sdk-ffi/CHANGELOG.md @@ -31,6 +31,16 @@ All notable changes to this project will be documented in this file. ### Features +- Add `HumanQrGrantLoginError::ConnectionInsecure` for errors establishing the secure channel + ([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141) +- Add `HumanQrGrantLoginError::Expired` for when a timeout is encountered during the grant + ([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141) +- Add `HumanQrGrantLoginError::Cancelled` for when the grant is cancelled + ([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141) +- Add `HumanQrGrantLoginError::OtherDeviceAlreadySignedIn` for when the other device is already signed in + ([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141) +- Add `HumanQrGrantLoginError::DeviceNotFound` for when the requested device was not returned by the homeserver + ([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141) - Add `RoomInfo::is_low_priority` for getting the room's `m.lowpriority` tag state ([#6183](https://github.com/matrix-org/matrix-rust-sdk/pull/6183)) - Add `Client::subscribe_to_duplicate_key_upload_errors` for listening to duplicate key diff --git a/bindings/matrix-sdk-ffi/src/qr_code.rs b/bindings/matrix-sdk-ffi/src/qr_code.rs index 0158f26ba..c0143ea22 100644 --- a/bindings/matrix-sdk-ffi/src/qr_code.rs +++ b/bindings/matrix-sdk-ffi/src/qr_code.rs @@ -405,14 +405,36 @@ pub enum HumanQrGrantLoginError { /// An unknown error has happened. #[error("An unknown error has happened.")] Unknown(String), + + /// The requested device was not returned by the homeserver. + #[error("The requested device was not returned by the homeserver.")] + DeviceNotFound, + + /// The other device is already signed in and so does not need to sign in. + #[error("The other device is already signed and so does not need to sign in.")] + OtherDeviceAlreadySignedIn, + + /// The sign in was cancelled. + #[error("The sign in was cancelled.")] + Cancelled, + + /// The sign in was not completed in the required time. + #[error("The sign in was not completed in the required time.")] + Expired, + + /// A secure connection could not have been established between the two + /// devices. + #[error("A secure connection could not have been established between the two devices.")] + ConnectionInsecure, } impl From for HumanQrGrantLoginError { fn from(value: qrcode::QRCodeGrantLoginError) -> Self { - use qrcode::QRCodeGrantLoginError; + use qrcode::{QRCodeGrantLoginError, SecureChannelError}; match value { QRCodeGrantLoginError::DeviceIDAlreadyInUse => Self::DeviceIDAlreadyInUse, + QRCodeGrantLoginError::DeviceNotFound => Self::DeviceNotFound, QRCodeGrantLoginError::InvalidCheckCode => Self::InvalidCheckCode, QRCodeGrantLoginError::UnableToCreateDevice => Self::UnableToCreateDevice, QRCodeGrantLoginError::UnsupportedProtocol(protocol) => { @@ -422,7 +444,28 @@ impl From for HumanQrGrantLoginError { Self::MissingSecretsBackup(error.map_or("other".to_owned(), |e| e.to_string())) } QRCodeGrantLoginError::NotFound => Self::NotFound, + QRCodeGrantLoginError::SecureChannel(e) => match e { + SecureChannelError::Utf8(_) + | SecureChannelError::MessageDecode(_) + | SecureChannelError::Json(_) + | SecureChannelError::RendezvousChannel(_) + | SecureChannelError::UnsupportedQrCodeType => Self::Unknown(e.to_string()), + SecureChannelError::SecureChannelMessage { .. } + | SecureChannelError::Ecies(_) + | SecureChannelError::InvalidCheckCode + | SecureChannelError::CannotReceiveCheckCode => Self::ConnectionInsecure, + SecureChannelError::InvalidIntent => Self::OtherDeviceAlreadySignedIn, + }, + QRCodeGrantLoginError::UnexpectedMessage { .. } => Self::Unknown(value.to_string()), QRCodeGrantLoginError::Unknown(string) => Self::Unknown(string), + QRCodeGrantLoginError::LoginFailure { reason, .. } => match reason { + LoginFailureReason::UnsupportedProtocol => Self::UnsupportedProtocol( + "Other device does not support any of our protocols".to_owned(), + ), + LoginFailureReason::AuthorizationExpired => Self::Expired, + LoginFailureReason::UserCancelled => Self::Cancelled, + _ => Self::Unknown(reason.to_string()), + }, } } }