manager/user: Create mirrored jobs for methods that create jobs on the root manager

This commit is contained in:
Vicki Pfau 2024-06-28 17:17:56 -07:00
parent 35eb5631ff
commit 0626012748

View file

@ -19,6 +19,7 @@ use crate::daemon::user::Command;
use crate::daemon::DaemonCommand; use crate::daemon::DaemonCommand;
use crate::error::{to_zbus_error, to_zbus_fdo_error, zbus_to_zbus_fdo}; use crate::error::{to_zbus_error, to_zbus_fdo_error, zbus_to_zbus_fdo};
use crate::hardware::check_support; use crate::hardware::check_support;
use crate::job::JobManager;
use crate::power::{ use crate::power::{
get_available_cpu_scaling_governors, get_cpu_scaling_governor, get_gpu_clocks, get_available_cpu_scaling_governors, get_cpu_scaling_governor, get_gpu_clocks,
get_gpu_performance_level, get_gpu_power_profile, get_gpu_power_profiles, get_tdp_limit, get_gpu_performance_level, get_gpu_power_profile, get_gpu_power_profiles, get_tdp_limit,
@ -41,6 +42,21 @@ macro_rules! method {
}; };
} }
macro_rules! job_method {
($self:expr, $method:expr, $($args:expr),+) => {
$self.job_manager.mirror_job::<zvariant::OwnedObjectPath>(
$self.proxy.connection(),
method!($self, $method, $($args),+)?
).await
};
($self:expr, $method:expr) => {
$self.job_manager.mirror_job::<zvariant::OwnedObjectPath>(
$self.proxy.connection(),
method!($self, $method)?
).await
};
}
macro_rules! getter { macro_rules! getter {
($self:expr, $prop:expr) => { ($self:expr, $prop:expr) => {
$self $self
@ -65,6 +81,7 @@ pub struct SteamOSManager {
proxy: Proxy<'static>, proxy: Proxy<'static>,
hdmi_cec: HdmiCecControl<'static>, hdmi_cec: HdmiCecControl<'static>,
channel: Sender<Command>, channel: Sender<Command>,
job_manager: JobManager,
} }
impl SteamOSManager { impl SteamOSManager {
@ -82,6 +99,7 @@ impl SteamOSManager {
.cache_properties(CacheProperties::No) .cache_properties(CacheProperties::No)
.build() .build()
.await?, .await?,
job_manager: JobManager::new(connection).await?,
channel, channel,
}) })
} }
@ -170,25 +188,25 @@ impl SteamOSManager {
} }
} }
async fn update_bios(&self) -> fdo::Result<zvariant::OwnedObjectPath> { async fn update_bios(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "UpdateBios") job_method!(self, "UpdateBios")
} }
async fn update_dock(&self) -> fdo::Result<zvariant::OwnedObjectPath> { async fn update_dock(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "UpdateDock") job_method!(self, "UpdateDock")
} }
async fn trim_devices(&self) -> fdo::Result<zvariant::OwnedObjectPath> { async fn trim_devices(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "TrimDevices") job_method!(self, "TrimDevices")
} }
async fn format_device( async fn format_device(
&self, &mut self,
device: &str, device: &str,
label: &str, label: &str,
validate: bool, validate: bool,
) -> fdo::Result<zvariant::OwnedObjectPath> { ) -> fdo::Result<zvariant::OwnedObjectPath> {
method!(self, "FormatDevice", device, label, validate) job_method!(self, "FormatDevice", device, label, validate)
} }
#[zbus(property(emits_changed_signal = "false"))] #[zbus(property(emits_changed_signal = "false"))]