mod application; pub use application::Application; mod meson_config; pub mod ui; pub mod mpris; pub use mpris::Mpris; pub mod playbin; pub use playbin::Playbin; pub mod subsonic; pub mod subsonic_vala; use gettextrs::{bind_textdomain_codeset, bindtextdomain, setlocale, textdomain, LocaleCategory}; use gtk::prelude::*; use gtk::{gio, glib}; pub mod mpv; #[link(name = "audrey")] #[link(name = "gcrypt")] #[link(name = "json-glib-1.0")] #[link(name = "secret-1")] #[link(name = "soup-3.0")] extern "C" {} pub fn runtime() -> &'static tokio::runtime::Runtime { static RUNTIME: std::sync::OnceLock = std::sync::OnceLock::new(); RUNTIME.get_or_init(|| { tokio::runtime::Runtime::new().expect("could not initialize the tokio runtime") }) } fn main() -> glib::ExitCode { gio::resources_register_include!("audrey.gresource").expect("could not register resources"); ui::Playbar::ensure_type(); ui::PlayQueue::ensure_type(); gtk::disable_setlocale(); bindtextdomain("audrey", meson_config::LOCALEDIR).expect("failed to bind text domain"); bind_textdomain_codeset("audrey", "UTF-8").expect("failed to bind textdomaincodeset"); textdomain("audrey").expect("unable to switch to text domain"); setlocale(LocaleCategory::LcAll, ""); setlocale(LocaleCategory::LcNumeric, "C.UTF-8"); let app = Application::new(); // smol test for the subsonic client runtime().spawn(async { let keyring = oo7::Keyring::new().await.unwrap(); let attributes = vec![("xdg:schema", "eu.callcc.audrey")]; let items = keyring.search_items(&attributes).await.unwrap(); if !items.is_empty() { let item = &items[0]; let attributes = item.attributes().await.unwrap(); let client = subsonic::Client::with_password( &attributes["server-url"], &attributes["username"], &item.secret().await.unwrap(), ) .unwrap(); client.ping().await.unwrap(); println!("{:#?}", client.get_random_songs(10).await.unwrap()); } }); app.run() }