crypto-ffi: Use proc-macros for VerificationRequest methods

This commit is contained in:
Jonas Platte
2023-04-21 11:27:24 +02:00
committed by Jonas Platte
parent 5202e3e1b9
commit 27cf710009
2 changed files with 5 additions and 30 deletions

View File

@@ -139,35 +139,7 @@ callback interface QrCodeListener {
void on_change(QrCodeState state);
};
interface VerificationRequest {
string other_user_id();
string? other_device_id();
string flow_id();
string? room_id();
boolean we_started();
boolean is_ready();
boolean is_done();
boolean is_passive();
boolean is_cancelled();
CancelInfo? cancel_info();
sequence<string>? their_supported_methods();
sequence<string>? our_supported_methods();
OutgoingVerificationRequest? accept(sequence<string> methods);
[Throws=CryptoStoreError]
StartSasResult? start_sas_verification();
[Throws=CryptoStoreError]
QrCode? start_qr_verification();
ScanResult? scan_qr_code([ByRef] string data);
OutgoingVerificationRequest? cancel();
void set_changes_listener(VerificationRequestListener listener);
VerificationRequestState state();
};
interface VerificationRequest {};
[Enum]
interface VerificationRequestState {

View File

@@ -566,6 +566,7 @@ pub struct VerificationRequest {
pub(crate) runtime: Handle,
}
#[uniffi::export]
impl VerificationRequest {
/// The id of the other user that is participating in this verification
/// request.
@@ -712,7 +713,7 @@ impl VerificationRequest {
///
/// * `data` - The data that was extracted from the scanned QR code as an
/// base64 encoded string, without padding.
pub fn scan_qr_code(&self, data: &str) -> Option<ScanResult> {
pub fn scan_qr_code(&self, data: String) -> Option<ScanResult> {
let data = STANDARD_NO_PAD.decode(data).ok()?;
let data = QrVerificationData::from_bytes(data).ok()?;
@@ -741,7 +742,9 @@ impl VerificationRequest {
pub fn state(&self) -> VerificationRequestState {
self.inner.state().into()
}
}
impl VerificationRequest {
async fn changes_listener(
mut stream: impl Stream<Item = RustVerificationRequestState> + std::marker::Unpin,
listener: Box<dyn VerificationRequestListener>,