unlock keyring etc

This commit is contained in:
Erica Z 2024-11-10 14:46:50 +01:00
parent a810842e68
commit f4ba44fcb7
2 changed files with 14 additions and 4 deletions

View file

@ -125,6 +125,7 @@ mod imp {
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use gtk::glib; use gtk::glib;
use tracing::{event, Level};
glib::wrapper! { glib::wrapper! {
pub struct Setup(ObjectSubclass<imp::Setup>) pub struct Setup(ObjectSubclass<imp::Setup>)
@ -148,6 +149,8 @@ impl Setup {
// TODO remove unwraps, make sure authn_can_edit is set back to true // TODO remove unwraps, make sure authn_can_edit is set back to true
let keyring = oo7::Keyring::new().await.unwrap(); let keyring = oo7::Keyring::new().await.unwrap();
// make sure the keyring is unlocked
keyring.unlock().await.unwrap();
let attributes = vec![("xdg:schema", crate::APP_ID)]; let attributes = vec![("xdg:schema", crate::APP_ID)];
let items = keyring.search_items(&attributes).await.unwrap(); let items = keyring.search_items(&attributes).await.unwrap();
@ -156,12 +159,19 @@ impl Setup {
// TODO: onboarding // TODO: onboarding
self.set_authn_can_edit(true); self.set_authn_can_edit(true);
self.set_authn_can_validate(true); self.set_authn_can_validate(true);
event!(Level::DEBUG, "TODO: setup onboarding");
} else { } else {
let item = &items[0]; let item = &items[0];
let attributes = item.attributes().await.unwrap(); let attributes = item.attributes().await.unwrap();
self.set_server_url(attributes["server-url"].clone()); let server_url = &attributes["server-url"];
self.set_username(attributes["username"].clone()); let username = &attributes["username"];
event!(Level::DEBUG, "logging in as {} at {}", username, server_url);
self.set_server_url(server_url.clone());
self.set_username(username.clone());
// strip non-utf8 elements from the pw, i guess // strip non-utf8 elements from the pw, i guess
self.set_password(String::from_utf8_lossy(&item.secret().await.unwrap())); self.set_password(String::from_utf8_lossy(&item.secret().await.unwrap()));

View file

@ -613,7 +613,7 @@ mod imp {
}; };
match perform.await { match perform.await {
Ok(()) => {}, Ok(()) => {}
Err(err) => event!(Level::ERROR, "could not refresh album list: {err}"), Err(err) => event!(Level::ERROR, "could not refresh album list: {err}"),
} }
@ -702,7 +702,7 @@ impl Window {
self.set_can_click_shuffle_all(true); self.set_can_click_shuffle_all(true);
let window = self.clone(); let window = self.clone();
glib::spawn_future_local(async move {window.imp().on_refresh_albums_clicked().await}); glib::spawn_future_local(async move { window.imp().on_refresh_albums_clicked().await });
} }
pub fn playlist_next(&self) { pub fn playlist_next(&self) {