From f0e5bb4ad1c04daaf560512dd930c4517c043364 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 26 May 2021 21:17:45 +1200 Subject: [PATCH] dbus: send/recv notifications for bios options --- Cargo.lock | 2 +- rog-dbus/Cargo.toml | 2 +- rog-dbus/src/lib.rs | 16 ++++++++++++++++ rog-dbus/src/zbus_rogbios.rs | 19 +++++++------------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fdbcea1..0320c0a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -887,7 +887,7 @@ dependencies = [ [[package]] name = "rog_dbus" -version = "3.4.0" +version = "3.5.0" dependencies = [ "rog_anime", "rog_aura", diff --git a/rog-dbus/Cargo.toml b/rog-dbus/Cargo.toml index a6bdb907..68966290 100644 --- a/rog-dbus/Cargo.toml +++ b/rog-dbus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rog_dbus" -version = "3.4.0" +version = "3.5.0" license = "MPL-2.0" readme = "README.md" authors = ["Luke "] diff --git a/rog-dbus/src/lib.rs b/rog-dbus/src/lib.rs index c72fb62c..ae692cfb 100644 --- a/rog-dbus/src/lib.rs +++ b/rog-dbus/src/lib.rs @@ -54,6 +54,8 @@ impl<'a> DbusProxies<'a> { recv.receive_for(self.charge.proxy()); recv.receive_for(self.gfx.proxy()); recv.receive_for(self.profile.proxy()); + recv.receive_for(self.rog_bios.proxy()); + recv.receive_for(self.supported.proxy()); recv } @@ -95,6 +97,8 @@ pub struct Signals { pub led_power_state: Receiver, pub anime_power_state: Receiver, pub charge: Receiver, + pub bios_gsync: Receiver, + pub bios_sound: Receiver, } impl Signals { @@ -136,6 +140,16 @@ impl Signals { proxies.anime.connect_notify_power_states(tx)?; rx }, + bios_gsync: { + let (tx, rx) = channel(); + proxies.rog_bios.connect_notify_dedicated_graphic_mode(tx)?; + rx + }, + bios_sound: { + let (tx, rx) = channel(); + proxies.rog_bios.connect_notify_post_boot_sound(tx)?; + rx + }, }) } } @@ -170,6 +184,8 @@ impl<'a> RogDbusClient<'a> { recv.receive_for(self.proxies.charge.proxy()); recv.receive_for(self.proxies.gfx.proxy()); recv.receive_for(self.proxies.profile.proxy()); + recv.receive_for(self.proxies.rog_bios.proxy()); + recv.receive_for(self.proxies.supported.proxy()); recv } diff --git a/rog-dbus/src/zbus_rogbios.rs b/rog-dbus/src/zbus_rogbios.rs index 065c3495..00e45099 100644 --- a/rog-dbus/src/zbus_rogbios.rs +++ b/rog-dbus/src/zbus_rogbios.rs @@ -19,7 +19,7 @@ //! //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. -use std::sync::{Arc, Mutex}; +use std::sync::{mpsc::Sender}; use zbus::{dbus_proxy, Connection, Result}; @@ -84,25 +84,20 @@ impl<'a> RogBiosProxy<'a> { #[inline] pub fn connect_notify_dedicated_graphic_mode( &self, - dedicated: Arc>>, + send: Sender, ) -> zbus::fdo::Result<()> { self.0.connect_notify_dedicated_graphic_mode(move |data| { - if let Ok(mut lock) = dedicated.lock() { - *lock = Some(data); - } + send.send(data) + .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; Ok(()) }) } #[inline] - pub fn connect_notify_post_boot_sound( - &self, - sound: Arc>>, - ) -> zbus::fdo::Result<()> { + pub fn connect_notify_post_boot_sound(&self, send: Sender) -> zbus::fdo::Result<()> { self.0.connect_notify_post_boot_sound(move |data| { - if let Ok(mut lock) = sound.lock() { - *lock = Some(data); - } + send.send(data) + .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; Ok(()) }) }