account-settings: Show availability of cross-signing keys
This commit is contained in:
parent
462d2ff99e
commit
beac89dc79
3 changed files with 96 additions and 2 deletions
|
@ -23,6 +23,41 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<property name="title" translatable="yes">Cross-Signing</property>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Master key</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="master_key_status">
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Self-signing key</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="self_signing_key_status">
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">User-signing key</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="user_signing_key_status">
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<object class="ImportExportKeysSubpage" id="import_export_keys_subpage">
|
||||
<property name="session" bind-source="SecurityPage" bind-property="session" bind-flags="sync-create"/>
|
||||
|
|
|
@ -64,6 +64,7 @@ src/session/account_settings/devices_page/device_list.rs
|
|||
src/session/account_settings/devices_page/device_row.rs
|
||||
src/session/account_settings/notifications_page.rs
|
||||
src/session/account_settings/security_page/import_export_keys_subpage.rs
|
||||
src/session/account_settings/security_page/mod.rs
|
||||
src/session/account_settings/user_page/change_password_subpage.rs
|
||||
src/session/account_settings/user_page/deactivate_account_subpage.rs
|
||||
src/session/account_settings/user_page/mod.rs
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use adw::{prelude::*, subclass::prelude::*};
|
||||
use gtk::{glib, CompositeTemplate};
|
||||
use gettextrs::gettext;
|
||||
use gtk::{glib, glib::clone, CompositeTemplate};
|
||||
|
||||
use crate::{components::ButtonRow, session::Session};
|
||||
use crate::{components::ButtonRow, session::Session, spawn, spawn_tokio};
|
||||
|
||||
mod import_export_keys_subpage;
|
||||
use import_export_keys_subpage::{ImportExportKeysSubpage, KeysSubpageMode};
|
||||
|
@ -17,6 +18,12 @@ mod imp {
|
|||
pub session: WeakRef<Session>,
|
||||
#[template_child]
|
||||
pub import_export_keys_subpage: TemplateChild<ImportExportKeysSubpage>,
|
||||
#[template_child]
|
||||
pub master_key_status: TemplateChild<gtk::Label>,
|
||||
#[template_child]
|
||||
pub self_signing_key_status: TemplateChild<gtk::Label>,
|
||||
#[template_child]
|
||||
pub user_signing_key_status: TemplateChild<gtk::Label>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
@ -95,6 +102,10 @@ impl SecurityPage {
|
|||
|
||||
self.imp().session.set(session.as_ref());
|
||||
self.notify("session");
|
||||
|
||||
spawn!(clone!(@weak self as obj => async move {
|
||||
obj.load_cross_signing_status().await;
|
||||
}));
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
|
@ -118,4 +129,51 @@ impl SecurityPage {
|
|||
.unwrap()
|
||||
.present_subpage(subpage);
|
||||
}
|
||||
|
||||
async fn load_cross_signing_status(&self) {
|
||||
let Some(session) = self.session() else {
|
||||
return;
|
||||
};
|
||||
let client = session.client();
|
||||
|
||||
let cross_signing_status =
|
||||
spawn_tokio!(async move { client.encryption().cross_signing_status().await })
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let imp = self.imp();
|
||||
update_cross_signing_key_status(
|
||||
&imp.master_key_status,
|
||||
cross_signing_status
|
||||
.as_ref()
|
||||
.map(|s| s.has_master)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
update_cross_signing_key_status(
|
||||
&imp.self_signing_key_status,
|
||||
cross_signing_status
|
||||
.as_ref()
|
||||
.map(|s| s.has_self_signing)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
update_cross_signing_key_status(
|
||||
&imp.user_signing_key_status,
|
||||
cross_signing_status
|
||||
.as_ref()
|
||||
.map(|s| s.has_user_signing)
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn update_cross_signing_key_status(label: >k::Label, available: bool) {
|
||||
if available {
|
||||
label.add_css_class("success");
|
||||
label.remove_css_class("error");
|
||||
label.set_text(&gettext("Available"));
|
||||
} else {
|
||||
label.add_css_class("error");
|
||||
label.remove_css_class("success");
|
||||
label.set_text(&gettext("Not available"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue