[fractal/fractal-next] verification: Use same widget for session and user verification
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] verification: Use same widget for session and user verification
- Date: Thu, 13 Jan 2022 14:34:41 +0000 (UTC)
commit 3fe920c34289bd80b738dc1a04f0a401d5420810
Author: Julian Sparber <julian sparber net>
Date: Wed Jan 12 18:56:26 2022 +0100
verification: Use same widget for session and user verification
This makes the session verification widget use the idenity verification
widget as a base. This reduces code dupplication and hopfully
differences between the two implementations.
data/resources/ui/identity-verification-widget.ui | 91 +++--
data/resources/ui/session-verification.ui | 371 +-------------------
src/session/content/mod.rs | 12 +-
.../verification/identity_verification_widget.rs | 183 +++++++++-
.../content/verification/session_verification.rs | 372 ++++++++-------------
src/session/mod.rs | 35 +-
6 files changed, 385 insertions(+), 679 deletions(-)
---
diff --git a/data/resources/ui/identity-verification-widget.ui
b/data/resources/ui/identity-verification-widget.ui
index 32e690c2..f69af5b0 100644
--- a/data/resources/ui/identity-verification-widget.ui
+++ b/data/resources/ui/identity-verification-widget.ui
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="IdentityVerificationWidget" parent="AdwBin">
- <style>
- <class name="incoming-verification"/>
- </style>
<child>
<object class="GtkStack" id="main_stack">
<property name="transition-type">crossfade</property>
@@ -23,8 +20,7 @@
<property name="spacing">18</property>
<property name="valign">center</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Login Request From Another
Session</property>
+ <object class="GtkLabel" id="label1">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -34,8 +30,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify the new session with the current
session.</property>
+ <object class="GtkLabel" id="label2">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -51,10 +46,10 @@
<property name="halign">center</property>
<property name="spacing">24</property>
<child>
- <object class="GtkButton" id="dismiss_btn">
- <property name="label" translatable="yes">Dismiss</property>
+ <object class="GtkButton" id="decline_btn">
+ <property name="label" translatable="yes">Decline</property>
<property name="halign">center</property>
- <property name="action-name">verification.dismiss</property>
+ <property name="action-name">verification.decline</property>
<style>
<class name="pill"/>
</style>
@@ -62,7 +57,7 @@
</child>
<child>
<object class="SpinnerButton" id="accept_btn">
- <property name="label" translatable="yes">Accept</property>
+ <property name="label" translatable="yes">Verify</property>
<property name="halign">center</property>
<style>
<class name="suggested-action"/>
@@ -91,8 +86,7 @@
<property name="spacing">18</property>
<property name="valign">center</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
+ <object class="GtkLabel" id="label3">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -102,8 +96,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Scan the Qr code with this session from
another session logged into this account</property>
+ <object class="GtkLabel" id="label4">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -178,8 +171,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">You scanned to qr code successfully. You
may need to confirm the verification in the other session.</property>
+ <object class="GtkLabel" id="label5">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -204,8 +196,7 @@
<property name="spacing">18</property>
<property name="valign">center</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
+ <object class="GtkLabel" id="label6">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -215,8 +206,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Select an option to verify the new
session.</property>
+ <object class="GtkLabel" id="label7">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -259,8 +249,7 @@
<property name="spacing">18</property>
<property name="valign">center</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
+ <object class="GtkLabel" id="label8">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -270,8 +259,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Scan this qr code with the newly logged in
session.</property>
+ <object class="GtkLabel" id="label9">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -329,8 +317,7 @@
<property name="spacing">18</property>
<property name="valign">center</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
+ <object class="GtkLabel" id="label10">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -340,8 +327,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Check if the same emoji appear in the same
order on the other device</property>
+ <object class="GtkLabel" id="label11">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -402,8 +388,7 @@
<property name="spacing">18</property>
<property name="valign">center</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Request Complete</property>
+ <object class="GtkLabel" id="label12">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -418,8 +403,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">The new session is now ready to send and
receive secure messages.</property>
+ <object class="GtkLabel" id="label13">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -441,6 +425,47 @@
</property>
</object>
</child>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">wait-for-other-party</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>
+ <property name="halign">center</property>
+ <child>
+ <object class="GtkLabel" id="label14">
+ <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="label15">
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <property name="justify">center</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPicture">
+ <property
name="file">resource:///org/gnome/FractalNext/icons/scalable/status/other-device.svg</property>
+ </object>
+ </child>
+ </object>
+ </property>
+ </object>
+ </property>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/data/resources/ui/session-verification.ui b/data/resources/ui/session-verification.ui
index e4af1e08..1a44c733 100644
--- a/data/resources/ui/session-verification.ui
+++ b/data/resources/ui/session-verification.ui
@@ -17,7 +17,7 @@
<object class="GtkButton">
<property name="visible">True</property>
<property name="icon-name">go-previous-symbolic</property>
- <property name="action-name">verification.previous</property>
+ <property name="action-name">session-verification.previous</property>
<style>
<class name="circular"/>
</style>
@@ -86,220 +86,11 @@
</style>
</object>
</child>
- </object>
- </property>
- </object>
- </property>
- </object>
- </child>
- <child>
- <object class="GtkStackPage">
- <property name="name">bootstrap</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>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Setup Encryption Identity</property>
- <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">
- <property name="label" translatable="yes">You need to setup an encryption
identity, since this is the first time you logged into your account.</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="justify">center</property>
- </object>
- </child>
- <child>
- <object class="SpinnerButton" id="bootstrap_button">
- <property name="label" translatable="yes">Setup</property>
- <property name="halign">center</property>
- <style>
- <class name="suggested-action"/>
- <class name="pill"/>
- </style>
- </object>
- </child>
- </object>
- </property>
- </object>
- </property>
- </object>
- </child>
- <child>
- <object class="GtkStackPage">
- <property name="name">scan-qr-code</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>
- <property name="halign">center</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
- <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">
- <property name="label" translatable="yes">Scan the Qr code with this session
from another session logged into this account</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="justify">center</property>
- </object>
- </child>
- <child>
- <object class="QrCodeScanner" id="qr_code_scanner">
- <property name="margin-top">24</property>
- <property name="margin-bottom">24</property>
- <property name="vexpand">True</property>
- <property name="hexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Can't scan QR code?</property>
- <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_btn2">
- <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_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>
- </property>
- </object>
- </child>
- <child>
- <object class="GtkStackPage">
- <property name="name">qr-code-scanned</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>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Scan Complete</property>
- <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="GtkPicture">
- <property
name="file">resource:///org/gnome/FractalNext/icons/scalable/status/setup-complete.svg</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">You scanned to qr code successfully.
You may need to confirm the verification in the other session.</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="justify">center</property>
- </object>
- </child>
- </object>
- </property>
- </object>
- </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>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
- <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">
- <property name="label" translatable="yes">Select an option to verify the new
session.</property>
- <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>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Reset</property>
<property name="halign">center</property>
+ <property name="action-name">session-verification.show-bootstrap</property>
<style>
<class name="pill"/>
</style>
@@ -312,71 +103,11 @@
</object>
</child>
<child>
- <object class="GtkStackPage">
- <property name="name">qrcode</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>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
- <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">
- <property name="label" translatable="yes">Scan this code from another session
logged into this account</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="justify">center</property>
- </object>
- </child>
- <child>
- <object class="TriQRCode" id="qrcode">
- <property name="valign">center</property>
- <property name="halign">center</property>
- <property name="margin-top">24</property>
- <property name="margin-bottom">24</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Can't scan QR code?</property>
- <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_btn">
- <property name="label" translatable="yes">Compare Emoji</property>
- <property name="halign">center</property>
- <style>
- <class name="pill"/>
- </style>
- </object>
- </child>
- </object>
- </property>
- </object>
- </property>
- </object>
+ <object class="IdentityVerificationWidget" id="verification_widget"/>
</child>
<child>
<object class="GtkStackPage">
- <property name="name">emoji</property>
+ <property name="name">bootstrap</property>
<property name="child">
<object class="AdwClamp">
<property name="maximum-size">400</property>
@@ -389,7 +120,7 @@
<property name="halign">center</property>
<child>
<object class="GtkLabel">
- <property name="label" translatable="yes">Verify Session</property>
+ <property name="label" translatable="yes">Setup Encryption Identity</property>
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
@@ -399,42 +130,16 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Check if the same emoji appear in the
same order on the other device</property>
+ <object class="GtkLabel" id="bootstrap_label">
+ <property name="label" translatable="yes">You need to setup an encryption
identity, since this is the first time you logged into your account.</property>
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
</object>
</child>
<child>
- <object class="GtkBox" id="emoji_row_1">
- <property name="valign">center</property>
- <property name="halign">center</property>
- <property name="spacing">30</property>
- <property name="margin-top">24</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="emoji_row_2">
- <property name="valign">center</property>
- <property name="halign">center</property>
- <property name="spacing">30</property>
- <property name="margin-bottom">24</property>
- </object>
- </child>
- <child>
- <object class="SpinnerButton" id="emoji_not_match_btn">
- <property name="label" translatable="yes">Do Not Match</property>
- <property name="halign">center</property>
- <style>
- <class name="destructive-action"/>
- <class name="pill"/>
- </style>
- </object>
- </child>
- <child>
- <object class="SpinnerButton" id="emoji_match_btn">
- <property name="label" translatable="yes">Match</property>
+ <object class="SpinnerButton" id="bootstrap_button">
+ <property name="label" translatable="yes">Setup</property>
<property name="halign">center</property>
<style>
<class name="suggested-action"/>
@@ -647,60 +352,6 @@
</property>
</object>
</child>
- <child>
- <object class="GtkStackPage">
- <property name="name">completed</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>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Setup Complete</property>
- <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="GtkPicture">
- <property
name="file">resource:///org/gnome/FractalNext/icons/scalable/status/setup-complete.svg</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">This session is ready to send and
receive secure messages</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="justify">center</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="get_started_button">
- <property name="label" translatable="yes">Get Started</property>
- <property name="action-name">session.show-content</property>
- <property name="halign">center</property>
- <style>
- <class name="suggested-action"/>
- <class name="pill"/>
- </style>
- </object>
- </child>
- </object>
- </property>
- </object>
- </property>
- </object>
- </child>
</object>
</child>
</object>
diff --git a/src/session/content/mod.rs b/src/session/content/mod.rs
index 2f57005a..1b47b395 100644
--- a/src/session/content/mod.rs
+++ b/src/session/content/mod.rs
@@ -14,7 +14,7 @@ use self::verification::IdentityVerificationWidget;
use crate::session::sidebar::{Entry, EntryType};
-use crate::session::verification::IdentityVerification;
+use crate::session::verification::{IdentityVerification, VerificationMode};
use adw::subclass::prelude::*;
use gtk::{gio, glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
@@ -279,10 +279,12 @@ impl Content {
.as_ref()
.and_then(|item| item.downcast_ref::<IdentityVerification>())
{
- priv_
- .identity_verification_widget
- .set_request(Some(item.clone()));
- priv_.stack.set_visible_child(&*priv_.verification_page);
+ if item.mode() != VerificationMode::CurrentSession {
+ priv_
+ .identity_verification_widget
+ .set_request(Some(item.clone()));
+ priv_.stack.set_visible_child(&*priv_.verification_page);
+ }
}
}
_ => {}
diff --git a/src/session/content/verification/identity_verification_widget.rs
b/src/session/content/verification/identity_verification_widget.rs
index 01d9b134..04c5294f 100644
--- a/src/session/content/verification/identity_verification_widget.rs
+++ b/src/session/content/verification/identity_verification_widget.rs
@@ -8,7 +8,10 @@ use crate::contrib::screenshot;
use crate::contrib::QRCode;
use crate::contrib::QRCodeExt;
use crate::contrib::QrCodeScanner;
-use crate::session::verification::{IdentityVerification, SasData, VerificationState};
+use crate::session::user::UserExt;
+use crate::session::verification::{
+ IdentityVerification, SasData, VerificationMode, VerificationState,
+};
use crate::spawn;
use gettextrs::gettext;
use matrix_sdk::encryption::verification::QrVerificationData;
@@ -44,7 +47,7 @@ mod imp {
#[template_child]
pub accept_btn: TemplateChild<SpinnerButton>,
#[template_child]
- pub dismiss_btn: TemplateChild<gtk::Button>,
+ pub decline_btn: TemplateChild<gtk::Button>,
#[template_child]
pub take_screenshot_btn2: TemplateChild<SpinnerButton>,
#[template_child]
@@ -56,6 +59,37 @@ mod imp {
#[template_child]
pub done_btn: TemplateChild<gtk::Button>,
pub state_handler: RefCell<Option<SignalHandlerId>>,
+ pub name_handler: RefCell<Option<SignalHandlerId>>,
+ #[template_child]
+ pub label1: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label2: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label3: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label4: TemplateChild<gtk::Label>,
+ #[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>,
+ #[template_child]
+ pub label10: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label11: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label12: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label13: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label14: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub label15: TemplateChild<gtk::Label>,
}
#[glib::object_subclass]
@@ -70,8 +104,8 @@ mod imp {
Emoji::static_type();
QrCodeScanner::static_type();
- klass.install_action("verification.dismiss", None, move |obj, _, _| {
- obj.dismiss();
+ klass.install_action("verification.decline", None, move |obj, _, _| {
+ obj.decline();
});
Self::bind_template(klass);
@@ -124,7 +158,7 @@ mod imp {
.connect_clicked(clone!(@weak obj => move |button| {
let priv_ = imp::IdentityVerificationWidget::from_instance(&obj);
button.set_loading(true);
- priv_.dismiss_btn.set_sensitive(false);
+ priv_.decline_btn.set_sensitive(false);
obj.accept();
}));
@@ -205,7 +239,11 @@ mod imp {
}));
self.done_btn.connect_clicked(clone!(@weak obj => move |_| {
- obj.dismiss();
+ if let Some(request) = obj.request() {
+ if request.mode() == VerificationMode::CurrentSession {
+ obj.activate_action("session.show-content", None);
+ }
+ }
}));
self.qr_code_scanner
@@ -227,6 +265,10 @@ mod imp {
if let Some(handler) = self.state_handler.take() {
request.disconnect(handler);
}
+
+ if let Some(handler) = self.name_handler.take() {
+ request.user().disconnect(handler);
+ }
}
}
}
@@ -270,6 +312,10 @@ impl IdentityVerificationWidget {
if let Some(handler) = priv_.state_handler.take() {
previous_request.disconnect(handler);
}
+
+ if let Some(handler) = priv_.name_handler.take() {
+ previous_request.user().disconnect(handler);
+ }
}
if let Some(ref request) = request {
@@ -279,12 +325,22 @@ impl IdentityVerificationWidget {
obj.update_view();
}),
);
- self.update_view();
priv_.state_handler.replace(Some(handler));
+
+ let handler = request.user().connect_notify_local(
+ Some("display-name"),
+ clone!(@weak self as obj => move |_, _| {
+ obj.init_mode();
+ }),
+ );
+
+ priv_.name_handler.replace(Some(handler));
}
priv_.request.replace(request);
+ self.init_mode();
+ self.update_view();
self.notify("request");
}
@@ -292,7 +348,7 @@ impl IdentityVerificationWidget {
let priv_ = imp::IdentityVerificationWidget::from_instance(self);
priv_.accept_btn.set_loading(false);
priv_.accept_btn.set_sensitive(true);
- priv_.dismiss_btn.set_sensitive(true);
+ priv_.decline_btn.set_sensitive(true);
priv_.scan_qr_code_btn.set_loading(false);
priv_.scan_qr_code_btn.set_sensitive(true);
priv_.emoji_not_match_btn.set_loading(false);
@@ -331,9 +387,9 @@ impl IdentityVerificationWidget {
}
}
- pub fn dismiss(&self) {
+ pub fn decline(&self) {
if let Some(request) = self.request() {
- request.dismiss();
+ request.cancel();
}
}
@@ -344,6 +400,11 @@ impl IdentityVerificationWidget {
VerificationState::Requested => {
priv_.main_stack.set_visible_child_name("accept-request");
}
+ VerificationState::RequestSend => {
+ priv_
+ .main_stack
+ .set_visible_child_name("wait-for-other-party");
+ }
VerificationState::QrV1Show => {
if let Some(qrcode) = request.qr_code() {
priv_.qrcode.set_qrcode(qrcode.clone());
@@ -384,7 +445,10 @@ impl IdentityVerificationWidget {
VerificationState::Completed => {
priv_.main_stack.set_visible_child_name("completed");
}
- _ => {}
+ VerificationState::Cancelled
+ | VerificationState::Dismissed
+ | VerificationState::Error
+ | VerificationState::Passive => {}
}
}
}
@@ -432,4 +496,101 @@ impl IdentityVerificationWidget {
.set_label(&gettext("Take a Screenshot of a Qr Code"))
}
}
+
+ fn init_mode(&self) {
+ let priv_ = imp::IdentityVerificationWidget::from_instance(self);
+ let request = if let Some(request) = self.request() {
+ request
+ } else {
+ return;
+ };
+
+ match request.mode() {
+ VerificationMode::CurrentSession => {
+ // label1 and label2 won't be shown
+ priv_
+ .label2
+ .set_label(&gettext("Verify the new session with the current session."));
+ 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.",
+ ));
+ priv_.label10.set_label(&gettext("Verify Session"));
+ priv_.label11.set_label(&gettext(
+ "Check if the same emoji appear in the same order on the other device.",
+ ));
+ priv_.label12.set_label(&gettext("Request Complete"));
+ priv_.label13.set_label(&gettext(
+ "This session is ready to send and receive secure messages.",
+ ));
+ priv_.done_btn.set_label(&gettext("Get Started"));
+ }
+ VerificationMode::OtherSession => {
+ priv_
+ .label1
+ .set_label(&gettext("Login Request From Another Session"));
+ priv_
+ .label2
+ .set_label(&gettext("Verify the new session with the current session."));
+ 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.",
+ ));
+ priv_.label10.set_label(&gettext("Verify Session"));
+ priv_.label11.set_label(&gettext(
+ "Check if the same emoji appear in the same order on the other device.",
+ ));
+ priv_.label12.set_label(&gettext("Request Complete"));
+ priv_.label13.set_label(&gettext(
+ "The new session is now ready to send and receive secure messages.",
+ ));
+ priv_.label14.set_label(&gettext("Get Another Device"));
+ priv_.label15.set_label(&gettext(
+ "Accept the verification request from another session or device.",
+ ));
+ }
+ VerificationMode::User => {
+ let name = request.user().display_name();
+ priv_.label1.set_markup(&gettext("Verification Request"));
+ priv_
+ .label2
+ .set_markup(&gettext!("<b>{}</b> asked do be verified. Verifying an user increases the
security of the conversation.", name));
+ priv_.label3.set_markup(&gettext("Verification Request"));
+ priv_.label4.set_markup(&gettext!(
+ "Scan the Qr code shown on the device of <b>{}</b>.",
+ 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 there device.",
+ ));
+ priv_.label10.set_markup(&gettext("Verification Request"));
+ priv_.label11.set_markup(&gettext!(
+ "Ask <b>{}</b> if they see the following emoji appear in the same order on there
screen.",
+ name
+ ));
+ priv_.label12.set_markup(&gettext("Verification Complete"));
+ priv_.label13.set_markup(&gettext!("<b>{}</b>is now verified and you can now be sure that
your comunication will be private.", name));
+ }
+ }
+ }
}
diff --git a/src/session/content/verification/session_verification.rs
b/src/session/content/verification/session_verification.rs
index 254f184b..d0e6105a 100644
--- a/src/session/content/verification/session_verification.rs
+++ b/src/session/content/verification/session_verification.rs
@@ -1,56 +1,37 @@
use adw::subclass::prelude::*;
use gettextrs::gettext;
use gtk::{glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
-use log::{debug, error, warn};
+use log::error;
-use super::Emoji;
+use super::IdentityVerificationWidget;
use crate::components::{AuthDialog, SpinnerButton};
-use crate::contrib::screenshot;
-use crate::contrib::QRCode;
-use crate::contrib::QRCodeExt;
-use crate::contrib::QrCodeScanner;
-use crate::session::verification::{IdentityVerification, SasData, VerificationState};
+use crate::session::verification::{IdentityVerification, VerificationState};
use crate::spawn;
use crate::Error;
+use crate::Session;
use crate::Window;
-use matrix_sdk::encryption::verification::QrVerificationData;
mod imp {
use super::*;
use glib::subclass::InitializingObject;
use glib::SignalHandlerId;
+ use glib::WeakRef;
+ use once_cell::unsync::OnceCell;
use std::cell::RefCell;
#[derive(Debug, Default, CompositeTemplate)]
#[template(resource = "/org/gnome/FractalNext/session-verification.ui")]
pub struct SessionVerification {
pub request: RefCell<Option<IdentityVerification>>,
+ pub session: OnceCell<WeakRef<Session>>,
#[template_child]
pub bootstrap_button: TemplateChild<SpinnerButton>,
#[template_child]
- pub qrcode: TemplateChild<QRCode>,
- #[template_child]
- pub emoji_row_1: TemplateChild<gtk::Box>,
- #[template_child]
- pub emoji_row_2: TemplateChild<gtk::Box>,
- #[template_child]
- pub emoji_match_btn: TemplateChild<SpinnerButton>,
- #[template_child]
- pub emoji_not_match_btn: TemplateChild<SpinnerButton>,
- #[template_child]
- pub start_emoji_btn: TemplateChild<SpinnerButton>,
- #[template_child]
- pub start_emoji_btn2: TemplateChild<SpinnerButton>,
- #[template_child]
- pub start_emoji_btn3: TemplateChild<SpinnerButton>,
- #[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>,
+ pub bootstrap_label: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub verification_widget: TemplateChild<IdentityVerificationWidget>,
pub state_handler: RefCell<Option<SignalHandlerId>>,
}
@@ -62,17 +43,27 @@ mod imp {
fn class_init(klass: &mut Self::Class) {
SpinnerButton::static_type();
- QRCode::static_type();
- Emoji::static_type();
Self::bind_template(klass);
- klass.install_action("verification.show-recovery", None, move |obj, _, _| {
- obj.show_recovery();
- });
-
- klass.install_action("verification.previous", None, move |obj, _, _| {
+ klass.install_action("session-verification.previous", None, move |obj, _, _| {
obj.previous();
});
+
+ klass.install_action(
+ "session-verification.show-recovery",
+ None,
+ move |obj, _, _| {
+ obj.show_recovery();
+ },
+ );
+
+ klass.install_action(
+ "session-verification.show-bootstrap",
+ None,
+ move |obj, _, _| {
+ obj.show_bootstrap();
+ },
+ );
}
fn instance_init(obj: &InitializingObject<Self>) {
@@ -85,13 +76,11 @@ mod imp {
use once_cell::sync::Lazy;
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
vec![glib::ParamSpec::new_object(
- "request",
- "Request",
- "The Object holding the data for the verification",
- IdentityVerification::static_type(),
- glib::ParamFlags::READWRITE
- | glib::ParamFlags::CONSTRUCT
- | glib::ParamFlags::EXPLICIT_NOTIFY,
+ "session",
+ "Session",
+ "The session",
+ Session::static_type(),
+ glib::ParamFlags::READWRITE | glib::ParamFlags::CONSTRUCT_ONLY,
)]
});
@@ -106,14 +95,14 @@ mod imp {
pspec: &glib::ParamSpec,
) {
match pspec.name() {
- "request" => obj.set_request(value.get().unwrap()),
+ "session" => obj.set_session(value.get().unwrap()),
_ => unimplemented!(),
}
}
fn property(&self, obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
- "request" => obj.request().to_value(),
+ "session" => obj.session().to_value(),
_ => unimplemented!(),
}
}
@@ -121,70 +110,21 @@ mod imp {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
- obj.action_set_enabled("verification.show-recovery", false);
-
- self.emoji_match_btn
- .connect_clicked(clone!(@weak obj => move |button| {
- let priv_ = imp::SessionVerification::from_instance(&obj);
- button.set_loading(true);
- priv_.emoji_not_match_btn.set_sensitive(false);
- obj.request().emoji_match();
- }));
-
- self.emoji_not_match_btn
- .connect_clicked(clone!(@weak obj => move |button| {
- let priv_ = imp::SessionVerification::from_instance(&obj);
- button.set_loading(true);
- priv_.emoji_match_btn.set_sensitive(false);
- obj.request().emoji_not_match();
- }));
-
- self.start_emoji_btn
- .connect_clicked(clone!(@weak obj => move |button| {
- button.set_loading(true);
- obj.request().start_sas();
- }));
-
- self.start_emoji_btn2
- .connect_clicked(clone!(@weak obj => move |button| {
- let priv_ = imp::SessionVerification::from_instance(&obj);
- button.set_loading(true);
- priv_.take_screenshot_btn2.set_sensitive(false);
- obj.request().start_sas();
- }));
- self.start_emoji_btn3
- .connect_clicked(clone!(@weak obj => move |button| {
- let priv_ = imp::SessionVerification::from_instance(&obj);
- button.set_loading(true);
- priv_.take_screenshot_btn3.set_sensitive(false);
- obj.request().start_sas();
- }));
+ obj.action_set_enabled("session-verification.show-recovery", false);
self.bootstrap_button
.connect_clicked(clone!(@weak obj => move |button| {
- button.set_loading(true);
- obj.bootstrap_cross_signing();
- }));
-
- self.take_screenshot_btn2
- .connect_clicked(clone!(@weak obj => move |button| {
- let priv_ = imp::SessionVerification::from_instance(&obj);
button.set_loading(true);
- priv_.start_emoji_btn2.set_sensitive(false);
- obj.take_screenshot();
+ obj.bootstrap_cross_signing();
}));
- self.take_screenshot_btn3
- .connect_clicked(clone!(@weak obj => move |button| {
- let priv_ = imp::SessionVerification::from_instance(&obj);
- button.set_loading(true);
- priv_.start_emoji_btn3.set_sensitive(false);
- obj.take_screenshot();
- }));
+ obj.start_request();
}
fn dispose(&self, obj: &Self::Type) {
- obj.silent_cancel();
+ if let Some(request) = obj.request() {
+ request.cancel();
+ }
}
}
@@ -198,40 +138,58 @@ glib::wrapper! {
}
impl SessionVerification {
- pub fn new(request: &IdentityVerification) -> Self {
- glib::Object::new(&[("request", request)]).expect("Failed to create SessionVerification")
+ pub fn new(session: &Session) -> Self {
+ glib::Object::new(&[("session", session)]).expect("Failed to create SessionVerification")
}
- pub fn request(&self) -> IdentityVerification {
+ /// The current `Session`.
+ pub fn session(&self) -> Session {
let priv_ = imp::SessionVerification::from_instance(self);
- priv_.request.borrow().clone().unwrap()
+ priv_.session.get().unwrap().upgrade().unwrap()
}
- pub fn set_request(&self, request: IdentityVerification) {
+ fn set_session(&self, session: Session) {
let priv_ = imp::SessionVerification::from_instance(self);
+ priv_.session.set(session.downgrade()).unwrap()
+ }
- if let Some(old_request) = &*priv_.request.borrow() {
- if old_request == &request {
- return;
- }
+ fn request(&self) -> Option<IdentityVerification> {
+ let priv_ = imp::SessionVerification::from_instance(self);
+ priv_.request.borrow().clone()
+ }
+
+ fn set_request(&self, request: Option<IdentityVerification>) {
+ let priv_ = imp::SessionVerification::from_instance(self);
+ let previous_request = self.request();
- self.reset();
+ if previous_request == request {
+ return;
+ }
+
+ self.reset();
+ if let Some(previous_request) = previous_request {
if let Some(handler) = priv_.state_handler.take() {
- old_request.disconnect(handler);
+ previous_request.disconnect(handler);
}
+
+ previous_request.cancel();
}
- let handler = request.connect_notify_local(
- Some("state"),
- clone!(@weak self as obj => move |_, _| {
- obj.update_view();
- }),
- );
+ if let Some(ref request) = request {
+ let handler = request.connect_notify_local(
+ Some("state"),
+ clone!(@weak self as obj => move |request, _| {
+ obj.update_view(request);
+ }),
+ );
- priv_.state_handler.replace(Some(handler));
+ priv_.state_handler.replace(Some(handler));
+ self.update_view(request);
+ }
- priv_.request.replace(Some(request));
+ priv_.verification_widget.set_request(request.clone());
+ priv_.request.replace(request);
}
/// Returns the parent GtkWindow containing this widget.
@@ -242,161 +200,100 @@ impl SessionVerification {
fn reset(&self) {
let priv_ = imp::SessionVerification::from_instance(self);
- priv_.emoji_not_match_btn.set_loading(false);
- priv_.emoji_not_match_btn.set_sensitive(true);
- priv_.emoji_match_btn.set_loading(false);
- priv_.emoji_match_btn.set_sensitive(true);
- priv_.start_emoji_btn.set_loading(false);
- priv_.start_emoji_btn.set_sensitive(true);
+ priv_.bootstrap_button.set_sensitive(true);
priv_.bootstrap_button.set_loading(false);
- priv_.start_emoji_btn2.set_loading(false);
- priv_.start_emoji_btn2.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);
-
- while let Some(child) = priv_.emoji_row_1.first_child() {
- priv_.emoji_row_1.remove(&child);
- }
-
- while let Some(child) = priv_.emoji_row_2.first_child() {
- priv_.emoji_row_2.remove(&child);
- }
}
- /// Cancel the verification request without telling the user about it
- fn silent_cancel(&self) {
+ fn update_view(&self, request: &IdentityVerification) {
let priv_ = imp::SessionVerification::from_instance(self);
- if let Some(handler) = priv_.state_handler.take() {
- self.request().disconnect(handler);
+ if request.is_finished() && request.state() != VerificationState::Completed {
+ self.start_request();
+ return;
}
- debug!("Verification request was silently canceled");
-
- self.request().cancel();
- }
-
- fn update_view(&self) {
- let priv_ = imp::SessionVerification::from_instance(self);
- let request = self.request();
match request.state() {
// FIXME: we bootstrap on all errors
VerificationState::Error => {
priv_.main_stack.set_visible_child_name("bootstrap");
}
- VerificationState::Requested | VerificationState::RequestSend => {
+ VerificationState::RequestSend => {
priv_.main_stack.set_visible_child_name("wait-for-device");
}
- VerificationState::QrV1Show => {
- if let Some(qrcode) = request.qr_code() {
- priv_.qrcode.set_qrcode(qrcode.clone());
- priv_.main_stack.set_visible_child_name("qrcode");
- } else {
- warn!("Failed to get qrcode for QrVerification");
- request.start_sas();
- }
- }
- VerificationState::QrV1Scan => {
- self.start_scanning();
- }
- VerificationState::SasV1 => {
- match request.sas_data().unwrap() {
- SasData::Emoji(emoji) => {
- for (index, emoji) in emoji.iter().enumerate() {
- if index < 4 {
- priv_.emoji_row_1.append(&Emoji::new(emoji));
- } else {
- priv_.emoji_row_2.append(&Emoji::new(emoji));
- }
- }
- }
- SasData::Decimal((a, b, c)) => {
- let container = gtk::Box::builder()
- .spacing(24)
- .css_classes(vec!["emoji".to_string()])
- .build();
- container.append(>k::Label::builder().label(&a.to_string()).build());
- container.append(>k::Label::builder().label(&b.to_string()).build());
- container.append(>k::Label::builder().label(&c.to_string()).build());
- priv_.emoji_row_1.append(&container);
- }
- }
-
- priv_.main_stack.set_visible_child_name("emoji");
- }
- VerificationState::Completed => {
- priv_.main_stack.set_visible_child_name("completed");
- }
_ => {
- warn!("Try to show a dismissed verification");
+ priv_
+ .main_stack
+ .set_visible_child(&*priv_.verification_widget);
}
}
}
- fn start_scanning(&self) {
- spawn!(clone!(@weak self as obj => async move {
- let priv_ = imp::SessionVerification::from_instance(&obj);
- if priv_.qr_code_scanner.start().await {
- priv_.main_stack.set_visible_child_name("scan-qr-code");
- } else {
- priv_.main_stack.set_visible_child_name("no-camera");
- }
- }));
- }
+ fn show_recovery(&self) {
+ let priv_ = imp::SessionVerification::from_instance(self);
- 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();
- }
- }));
+ // TODO: stop the request
+
+ priv_.main_stack.set_visible_child_name("recovery");
}
- fn finish_scanning(&self, data: QrVerificationData) {
+ fn show_bootstrap(&self) {
let priv_ = imp::SessionVerification::from_instance(self);
- priv_.qr_code_scanner.stop();
- self.request().scanned_qr_code(data);
- priv_.main_stack.set_visible_child_name("qr-code-scanned");
+
+ self.set_request(None);
+ priv_.bootstrap_label.set_label(&gettext("If you lost access to all other session you can create a
new crypto identity. Be care full because this will reset all verified users and make previously encrypted
conversations unreadable."));
+ priv_.bootstrap_button.remove_css_class("suggested-action");
+ priv_.bootstrap_button.add_css_class("destructive-action");
+ priv_.bootstrap_button.set_label(&gettext("Reset"));
+ priv_.main_stack.set_visible_child_name("bootstrap");
}
- fn show_recovery(&self) {
+ fn start_request(&self) {
let priv_ = imp::SessionVerification::from_instance(self);
+ priv_.main_stack.set_visible_child_name("wait-for-device");
- self.silent_cancel();
-
- priv_.main_stack.set_visible_child_name("recovery");
+ spawn!(clone!(@weak self as obj => async move {
+ let request = IdentityVerification::create(&obj.session(), None).await;
+ obj.session().verification_list().add(request.clone());
+ obj.set_request(Some(request));
+ }));
}
fn previous(&self) {
let priv_ = imp::SessionVerification::from_instance(self);
- match priv_.main_stack.visible_child_name().unwrap().as_str() {
- "recovery" => {
- self.silent_cancel();
- }
- "recovery-passphrase" | "recovery-key" => {
- priv_.main_stack.set_visible_child_name("recovery");
+ if let Some(child_name) = priv_.main_stack.visible_child_name() {
+ match child_name.as_str() {
+ "recovery" => {
+ self.start_request();
+ return;
+ }
+ "recovery-passphrase" | "recovery-key" => {
+ priv_.main_stack.set_visible_child_name("recovery");
+ return;
+ }
+ "bootstrap" => {
+ self.start_request();
+ return;
+ }
+ _ => {}
}
- "wait-for-device" | "complete" => {
- self.silent_cancel();
+ }
+
+ if let Some(request) = self.request() {
+ if request.state() == VerificationState::RequestSend {
+ self.set_request(None);
self.activate_action("session.logout", None);
+ } else {
+ self.start_request();
}
- "emoji" | "qrcode" | "scan-qr-code" | "no-camera" => {
- self.silent_cancel();
- }
- _ => {}
+ } else {
+ self.activate_action("session.logout", None);
}
}
fn bootstrap_cross_signing(&self) {
spawn!(clone!(@weak self as obj => async move {
- let priv_ = imp::SessionVerification::from_instance(&obj);
- let dialog = AuthDialog::new(obj.parent_window().as_ref(), &obj.request().session());
+ let dialog = AuthDialog::new(obj.parent_window().as_ref(), &obj.session());
let result = dialog
.authenticate(move |client, auth_data| async move {
@@ -434,12 +331,9 @@ impl SessionVerification {
if let Some(window) = obj.parent_window() {
window.append_error(&error);
}
-
- obj.silent_cancel();
} else {
- priv_
- .main_stack
- .set_visible_child_name("completed");
+ // TODO tell user that the a crypto identity was created
+ obj.activate_action("session.show-content", None);
}
}));
}
diff --git a/src/session/mod.rs b/src/session/mod.rs
index 63ca36e6..c1267a13 100644
--- a/src/session/mod.rs
+++ b/src/session/mod.rs
@@ -20,7 +20,7 @@ pub use self::room_creation::RoomCreation;
use self::room_list::RoomList;
use self::sidebar::Sidebar;
pub use self::user::{User, UserExt};
-use self::verification::{IdentityVerification, VerificationList, VerificationState};
+use self::verification::VerificationList;
use crate::session::sidebar::ItemList;
use crate::secret;
@@ -492,31 +492,9 @@ impl Session {
async fn create_session_verification(&self) {
let priv_ = imp::Session::from_instance(self);
- let request = IdentityVerification::create(&self, None).await;
-
- if let Some(widget) = priv_.stack.child_by_name("session-verification") {
- widget
- .downcast::<SessionVerification>()
- .unwrap()
- .set_request(request.clone());
- } else {
- let widget = SessionVerification::new(&request);
- priv_.stack.add_named(&widget, Some("session-verification"));
- priv_.stack.set_visible_child(&widget);
- }
-
- request.connect_notify_local(
- Some("state"),
- clone!(@weak self as obj => move |request, _| {
- if request.is_finished() && request.state() != VerificationState::Completed {
- spawn!(async move {
- obj.create_session_verification().await;
- });
- }
- }),
- );
-
- self.verification_list().add(request);
+ let widget = SessionVerification::new(self);
+ priv_.stack.add_named(&widget, Some("session-verification"));
+ priv_.stack.set_visible_child(&widget);
}
fn mark_ready(&self) {
@@ -722,11 +700,6 @@ impl Session {
// First stop the verification in progress
if let Some(session_verificiation) = priv_.stack.child_by_name("session-verification") {
priv_.stack.remove(&session_verificiation);
- session_verificiation
- .downcast_ref::<SessionVerification>()
- .unwrap()
- .request()
- .cancel();
}
let client = self.client();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]