[fractal/fractal-next] verification: Drop screenshot support
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] verification: Drop screenshot support
- Date: Wed, 2 Feb 2022 17:19:30 +0000 (UTC)
commit b73b5043905d677c47e37e7286227f53dab2b0a6
Author: Julian Sparber <julian sparber net>
Date: Wed Feb 2 15:52:28 2022 +0100
verification: Drop screenshot support
data/resources/ui/identity-verification-widget.ui | 63 +-----------
src/contrib/mod.rs | 2 +-
src/contrib/qr_code_scanner/mod.rs | 1 -
src/contrib/qr_code_scanner/screenshot.rs | 13 ---
.../verification/identity_verification_widget.rs | 109 +++++++--------------
src/session/verification/mod.rs | 1 +
6 files changed, 36 insertions(+), 153 deletions(-)
---
diff --git a/data/resources/ui/identity-verification-widget.ui
b/data/resources/ui/identity-verification-widget.ui
index 685965be0..9c0fa913b 100644
--- a/data/resources/ui/identity-verification-widget.ui
+++ b/data/resources/ui/identity-verification-widget.ui
@@ -127,15 +127,6 @@
</style>
</object>
</child>
- <child>
- <object class="SpinnerButton" id="take_screenshot_btn2">
- <property name="label" translatable="yes">Take a Screenshot of a Qr Code</property>
- <property name="halign">center</property>
- <style>
- <class name="pill"/>
- </style>
- </object>
- </child>
</object>
</property>
</object>
@@ -183,59 +174,6 @@
</property>
</object>
</child>
- <child>
- <object class="GtkStackPage">
- <property name="name">no-camera</property>
- <property name="child">
- <object class="AdwClamp">
- <property name="maximum-size">400</property>
- <property name="tightening-threshold">300</property>
- <property name="child">
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="spacing">18</property>
- <property name="valign">center</property>
- <child>
- <object class="GtkLabel" id="label6">
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="justify">center</property>
- <style>
- <class name="title-1"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="label7">
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="justify">center</property>
- </object>
- </child>
- <child>
- <object class="SpinnerButton" id="start_emoji_btn3">
- <property name="label" translatable="yes">Compare Emoji</property>
- <property name="halign">center</property>
- <style>
- <class name="pill"/>
- </style>
- </object>
- </child>
- <child>
- <object class="SpinnerButton" id="take_screenshot_btn3">
- <property name="label" translatable="yes">Take a Screenshot of a Qr Code</property>
- <property name="halign">center</property>
- <style>
- <class name="pill"/>
- </style>
- </object>
- </child>
- </object>
- </property>
- </object>
- </property>
- </object>
- </child>
<child>
<object class="GtkStackPage">
<property name="name">qrcode</property>
@@ -284,6 +222,7 @@
<child>
<object class="SpinnerButton" id="scan_qr_code_btn">
<property name="halign">center</property>
+ <property name="label" translatable="yes">Scan QR code with this session</property>
<style>
<class name="pill"/>
</style>
diff --git a/src/contrib/mod.rs b/src/contrib/mod.rs
index a4548336d..26ba29a78 100644
--- a/src/contrib/mod.rs
+++ b/src/contrib/mod.rs
@@ -3,5 +3,5 @@ mod qr_code_scanner;
pub use self::{
qr_code::{QRCode, QRCodeExt},
- qr_code_scanner::{Camera, screenshot, QrCodeScanner},
+ qr_code_scanner::{Camera, QrCodeScanner},
};
diff --git a/src/contrib/qr_code_scanner/mod.rs b/src/contrib/qr_code_scanner/mod.rs
index 75978b1d9..f961bf8d9 100644
--- a/src/contrib/qr_code_scanner/mod.rs
+++ b/src/contrib/qr_code_scanner/mod.rs
@@ -5,7 +5,6 @@ use matrix_sdk::encryption::verification::QrVerificationData;
mod camera;
mod camera_paintable;
mod qr_code_detector;
-pub mod screenshot;
pub use camera::Camera;
diff --git a/src/session/content/verification/identity_verification_widget.rs
b/src/session/content/verification/identity_verification_widget.rs
index 5c62ca2f4..d11f3a833 100644
--- a/src/session/content/verification/identity_verification_widget.rs
+++ b/src/session/content/verification/identity_verification_widget.rs
@@ -7,10 +7,13 @@ use matrix_sdk::encryption::verification::QrVerificationData;
use super::Emoji;
use crate::{
components::SpinnerButton,
- contrib::{screenshot, QRCode, QRCodeExt, QrCodeScanner},
+ contrib::{QRCode, QRCodeExt, QrCodeScanner},
session::{
user::UserExt,
- verification::{IdentityVerification, SasData, VerificationMode, VerificationState},
+ verification::{
+ IdentityVerification, SasData, VerificationMode, VerificationState,
+ VerificationSupportedMethods,
+ },
},
spawn,
};
@@ -41,18 +44,12 @@ mod imp {
#[template_child]
pub start_emoji_btn2: TemplateChild<SpinnerButton>,
#[template_child]
- pub start_emoji_btn3: TemplateChild<SpinnerButton>,
- #[template_child]
pub scan_qr_code_btn: TemplateChild<SpinnerButton>,
#[template_child]
pub accept_btn: TemplateChild<SpinnerButton>,
#[template_child]
pub decline_btn: TemplateChild<gtk::Button>,
#[template_child]
- pub take_screenshot_btn2: TemplateChild<SpinnerButton>,
- #[template_child]
- pub take_screenshot_btn3: TemplateChild<SpinnerButton>,
- #[template_child]
pub main_stack: TemplateChild<gtk::Stack>,
#[template_child]
pub qr_code_scanner: TemplateChild<QrCodeScanner>,
@@ -60,6 +57,7 @@ mod imp {
pub done_btn: TemplateChild<gtk::Button>,
pub state_handler: RefCell<Option<SignalHandlerId>>,
pub name_handler: RefCell<Option<SignalHandlerId>>,
+ pub supported_methods_handler: RefCell<Option<SignalHandlerId>>,
#[template_child]
pub label1: TemplateChild<gtk::Label>,
#[template_child]
@@ -71,10 +69,6 @@ mod imp {
#[template_child]
pub label5: TemplateChild<gtk::Label>,
#[template_child]
- pub label6: TemplateChild<gtk::Label>,
- #[template_child]
- pub label7: TemplateChild<gtk::Label>,
- #[template_child]
pub label8: TemplateChild<gtk::Label>,
#[template_child]
pub label9: TemplateChild<gtk::Label>,
@@ -190,15 +184,6 @@ mod imp {
self.start_emoji_btn2
.connect_clicked(clone!(@weak obj => move |button| {
button.set_loading(true);
- obj.imp().take_screenshot_btn2.set_sensitive(false);
- if let Some(request) = obj.request() {
- request.start_sas();
- }
- }));
- self.start_emoji_btn3
- .connect_clicked(clone!(@weak obj => move |button| {
- button.set_loading(true);
- obj.imp().take_screenshot_btn3.set_sensitive(false);
if let Some(request) = obj.request() {
request.start_sas();
}
@@ -212,20 +197,6 @@ mod imp {
obj.start_scanning();
}));
- self.take_screenshot_btn2
- .connect_clicked(clone!(@weak obj => move |button| {
- button.set_loading(true);
- obj.imp().start_emoji_btn2.set_sensitive(false);
- obj.take_screenshot();
- }));
-
- self.take_screenshot_btn3
- .connect_clicked(clone!(@weak obj => move |button| {
- button.set_loading(true);
- obj.imp().start_emoji_btn3.set_sensitive(false);
- obj.take_screenshot();
- }));
-
self.done_btn.connect_clicked(clone!(@weak obj => move |_| {
if let Some(request) = obj.request() {
if request.mode() == VerificationMode::CurrentSession {
@@ -238,14 +209,6 @@ mod imp {
.connect_code_detected(clone!(@weak obj => move |_, data| {
obj.finish_scanning(data);
}));
-
- self.qr_code_scanner.connect_notify_local(
- Some("has-camera"),
- clone!(@weak obj => move |_, _| {
- obj.update_camera_state();
- }),
- );
- obj.update_camera_state();
}
fn dispose(&self, obj: &Self::Type) {
@@ -257,6 +220,10 @@ mod imp {
if let Some(handler) = self.name_handler.take() {
request.user().disconnect(handler);
}
+
+ if let Some(handler) = self.supported_methods_handler.take() {
+ request.disconnect(handler);
+ }
}
}
}
@@ -303,6 +270,10 @@ impl IdentityVerificationWidget {
if let Some(handler) = priv_.name_handler.take() {
previous_request.user().disconnect(handler);
}
+
+ if let Some(handler) = priv_.supported_methods_handler.take() {
+ previous_request.disconnect(handler);
+ }
}
if let Some(ref request) = request {
@@ -323,11 +294,21 @@ impl IdentityVerificationWidget {
);
priv_.name_handler.replace(Some(handler));
+
+ let handler = request.connect_notify_local(
+ Some("supported-methods"),
+ clone!(@weak self as obj => move |_, _| {
+ obj.update_supported_methods();
+ }),
+ );
+
+ priv_.supported_methods_handler.replace(Some(handler));
}
priv_.request.replace(request);
self.init_mode();
self.update_view();
+ self.update_supported_methods();
self.notify("request");
}
@@ -346,12 +327,6 @@ impl IdentityVerificationWidget {
priv_.start_emoji_btn.set_sensitive(true);
priv_.start_emoji_btn2.set_loading(false);
priv_.start_emoji_btn2.set_sensitive(true);
- priv_.start_emoji_btn3.set_loading(false);
- priv_.start_emoji_btn3.set_sensitive(true);
- priv_.take_screenshot_btn2.set_loading(false);
- priv_.take_screenshot_btn2.set_sensitive(true);
- priv_.take_screenshot_btn3.set_loading(false);
- priv_.take_screenshot_btn3.set_sensitive(true);
self.clean_emoji();
}
@@ -448,17 +423,6 @@ impl IdentityVerificationWidget {
}));
}
- fn take_screenshot(&self) {
- spawn!(clone!(@weak self as obj => async move {
- let root = obj.root().unwrap();
- if let Some(code) = screenshot::capture(&root).await {
- obj.finish_scanning(code);
- } else {
- obj.reset();
- }
- }));
- }
-
fn finish_scanning(&self, data: QrVerificationData) {
let priv_ = self.imp();
priv_.qr_code_scanner.stop();
@@ -468,10 +432,15 @@ impl IdentityVerificationWidget {
priv_.main_stack.set_visible_child_name("qr-code-scanned");
}
- fn update_camera_state(&self) {
- self.imp()
- .scan_qr_code_btn
- .set_label(&gettext("Scan QR code with this session"))
+ fn update_supported_methods(&self) {
+ let priv_ = self.imp();
+ if let Some(request) = self.request() {
+ priv_.scan_qr_code_btn.set_visible(
+ request
+ .supported_methods()
+ .contains(VerificationSupportedMethods::QR_SCAN),
+ );
+ }
}
fn init_mode(&self) {
@@ -491,10 +460,6 @@ impl IdentityVerificationWidget {
priv_.label3.set_label(&gettext("Verify Session"));
priv_.label4.set_label(&gettext("Scan the QR code with this session from another session
logged into this account."));
priv_.label5.set_label(&gettext("You scanned to qr code successfully. You may need to
confirm the verification in the other session."));
- priv_.label6.set_label(&gettext("Verify Session"));
- priv_
- .label7
- .set_label(&gettext("Select an option to verify the new session."));
priv_.label8.set_label(&gettext("Verify Session"));
priv_.label9.set_label(&gettext(
"Scan this qr code with the newly logged in session.",
@@ -519,10 +484,6 @@ impl IdentityVerificationWidget {
priv_.label3.set_label(&gettext("Verify Session"));
priv_.label4.set_label(&gettext("Scan the QR code with this session from another session
logged into this account."));
priv_.label5.set_label(&gettext("You scanned to qr code successfully. You may need to
confirm the verification in the other session."));
- priv_.label6.set_label(&gettext("Verify Session"));
- priv_
- .label7
- .set_label(&gettext("Select an option to verify the new session."));
priv_.label8.set_label(&gettext("Verify Session"));
priv_.label9.set_label(&gettext(
"Scan this qr code with the newly logged in session.",
@@ -552,10 +513,6 @@ impl IdentityVerificationWidget {
name
));
priv_.label5.set_markup(&gettext!("You scanned the QR code successfully. <b>{}</b> may need
to confirm the verification.", name));
- priv_.label6.set_markup(&gettext("Verification Request"));
- priv_
- .label7
- .set_markup(&gettext!("Select an option to verify <b>{}</b>", name));
priv_.label8.set_markup(&gettext("Verification Request"));
priv_.label9.set_markup(&gettext(
"Ask <b>{}</b> to scan this QR code with their device.",
diff --git a/src/session/verification/mod.rs b/src/session/verification/mod.rs
index 35d320b12..bb67f3e7c 100644
--- a/src/session/verification/mod.rs
+++ b/src/session/verification/mod.rs
@@ -6,6 +6,7 @@ use std::time::Duration;
pub use self::{
identity_verification::{
IdentityVerification, Mode as VerificationMode, SasData, State as VerificationState,
+ SupportedMethods as VerificationSupportedMethods,
},
verification_list::VerificationList,
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]