Add cancel methods and rename callback method

This commit is contained in:
Andy Uhnak
2022-11-17 11:24:39 +00:00
committed by Damir Jelić
parent c604e59dcc
commit 457c5f4fa3
2 changed files with 24 additions and 3 deletions

View File

@@ -162,7 +162,7 @@ interface Sas {
sequence<i32>? get_emoji_indices();
sequence<i32>? get_decimals();
void changes(SasListener callback);
void set_changes_listener(SasListener callback);
SasState state();
};
@@ -192,6 +192,7 @@ interface QrCode {
string? room_id();
boolean we_started();
boolean is_done();
boolean is_cancelled();
CancelInfo? cancel_info();
boolean reciprocated();
@@ -211,6 +212,8 @@ interface VerificationRequest {
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();
@@ -223,6 +226,8 @@ interface VerificationRequest {
[Throws=CryptoStoreError]
QrCode? start_qr_verification();
ScanResult? scan_qr_code([ByRef] string data);
OutgoingVerificationRequest? cancel();
};
dictionary RequestVerificationResult {

View File

@@ -194,7 +194,7 @@ impl Sas {
self.inner.decimals().map(|v| [v.0.into(), v.1.into(), v.2.into()].to_vec())
}
/// Listen for changes in the SAS verification process.
/// Set a listener for changes in the SAS verification process.
///
/// The given callback will be called whenever the state changes.
///
@@ -239,7 +239,7 @@ impl Sas {
/// │ Done │
/// └───────┘
/// ```
pub fn changes(&self, callback: Box<dyn SasListener>) {
pub fn set_changes_listener(&self, callback: Box<dyn SasListener>) {
let stream = self.inner.changes();
self.runtime.spawn(Self::changes_callback(stream, callback));
@@ -302,6 +302,11 @@ impl QrCode {
self.inner.is_done()
}
/// Has the verification flow been cancelled.
pub fn is_cancelled(&self) -> bool {
self.inner.is_cancelled()
}
/// Did we initiate the verification flow.
pub fn we_started(&self) -> bool {
self.inner.we_started()
@@ -469,6 +474,17 @@ impl VerificationRequest {
self.inner.is_passive()
}
/// Has the verification flow that been cancelled.
pub fn is_cancelled(&self) -> bool {
self.inner.is_cancelled()
}
/// Get info about the cancellation if the verification request has been
/// cancelled.
pub fn cancel_info(&self) -> Option<CancelInfo> {
self.inner.cancel_info().map(|v| v.into())
}
/// Get the supported verification methods of the other side.
///
/// Will be present only if the other side requested the verification or if