mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-06 06:30:27 -04:00
Import a few more zbus things to reduce namespace line length
This commit is contained in:
parent
7213ea5179
commit
450541b2bd
5 changed files with 20 additions and 21 deletions
|
@ -12,7 +12,7 @@ use tokio::fs::File;
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use zbus::zvariant::Fd;
|
use zbus::zvariant::{self, Fd};
|
||||||
use zbus::{fdo, interface, Connection, SignalContext};
|
use zbus::{fdo, interface, Connection, SignalContext};
|
||||||
|
|
||||||
use crate::daemon::root::{Command, RootCommand};
|
use crate::daemon::root::{Command, RootCommand};
|
||||||
|
@ -135,14 +135,14 @@ impl SteamOSManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_bios(&mut self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
async fn update_bios(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
// Update the bios as needed
|
// Update the bios as needed
|
||||||
self.process_manager
|
self.process_manager
|
||||||
.get_command_object_path("/usr/bin/jupiter-biosupdate", &["--auto"], "updating BIOS")
|
.get_command_object_path("/usr/bin/jupiter-biosupdate", &["--auto"], "updating BIOS")
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_dock(&mut self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
async fn update_dock(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
// Update the dock firmware as needed
|
// Update the dock firmware as needed
|
||||||
self.process_manager
|
self.process_manager
|
||||||
.get_command_object_path(
|
.get_command_object_path(
|
||||||
|
@ -153,7 +153,7 @@ impl SteamOSManager {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn trim_devices(&mut self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
async fn trim_devices(&mut self) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
// Run steamos-trim-devices script
|
// Run steamos-trim-devices script
|
||||||
self.process_manager
|
self.process_manager
|
||||||
.get_command_object_path(
|
.get_command_object_path(
|
||||||
|
@ -169,7 +169,7 @@ impl SteamOSManager {
|
||||||
device: &str,
|
device: &str,
|
||||||
label: &str,
|
label: &str,
|
||||||
validate: bool,
|
validate: bool,
|
||||||
) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
let mut args = vec!["--label", label, "--device", device];
|
let mut args = vec!["--label", label, "--device", device];
|
||||||
if !validate {
|
if !validate {
|
||||||
args.push("--skip-validation");
|
args.push("--skip-validation");
|
||||||
|
|
|
@ -11,8 +11,8 @@ use std::collections::HashMap;
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use zbus::proxy::Builder;
|
use zbus::proxy::Builder;
|
||||||
use zbus::zvariant::Fd;
|
use zbus::zvariant::{self, Fd};
|
||||||
use zbus::{fdo, interface, Connection, Proxy, SignalContext};
|
use zbus::{fdo, interface, CacheProperties, Connection, Proxy, SignalContext};
|
||||||
|
|
||||||
use crate::cec::{HdmiCecControl, HdmiCecState};
|
use crate::cec::{HdmiCecControl, HdmiCecState};
|
||||||
use crate::daemon::user::Command;
|
use crate::daemon::user::Command;
|
||||||
|
@ -79,7 +79,7 @@ impl SteamOSManager {
|
||||||
.destination("com.steampowered.SteamOSManager1")?
|
.destination("com.steampowered.SteamOSManager1")?
|
||||||
.path("/com/steampowered/SteamOSManager1")?
|
.path("/com/steampowered/SteamOSManager1")?
|
||||||
.interface("com.steampowered.SteamOSManager1.RootManager")?
|
.interface("com.steampowered.SteamOSManager1.RootManager")?
|
||||||
.cache_properties(zbus::CacheProperties::No)
|
.cache_properties(CacheProperties::No)
|
||||||
.build()
|
.build()
|
||||||
.await?,
|
.await?,
|
||||||
channel,
|
channel,
|
||||||
|
@ -170,15 +170,15 @@ impl SteamOSManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_bios(&self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
async fn update_bios(&self) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
method!(self, "UpdateBios")
|
method!(self, "UpdateBios")
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_dock(&self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
async fn update_dock(&self) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
method!(self, "UpdateDock")
|
method!(self, "UpdateDock")
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn trim_devices(&self) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
async fn trim_devices(&self) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
method!(self, "TrimDevices")
|
method!(self, "TrimDevices")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ impl SteamOSManager {
|
||||||
device: &str,
|
device: &str,
|
||||||
label: &str,
|
label: &str,
|
||||||
validate: bool,
|
validate: bool,
|
||||||
) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
method!(self, "FormatDevice", device, label, validate)
|
method!(self, "FormatDevice", device, label, validate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::os::unix::process::ExitStatusExt;
|
||||||
use std::process::ExitStatus;
|
use std::process::ExitStatus;
|
||||||
use tokio::process::{Child, Command};
|
use tokio::process::{Child, Command};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use zbus::{fdo, interface};
|
use zbus::{fdo, interface, zvariant, Connection};
|
||||||
|
|
||||||
use crate::error::to_zbus_fdo_error;
|
use crate::error::to_zbus_fdo_error;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ pub struct ProcessManager {
|
||||||
// The thing that manages subprocesses.
|
// The thing that manages subprocesses.
|
||||||
// Keeps a handle to the zbus connection and
|
// Keeps a handle to the zbus connection and
|
||||||
// what the next process id on the bus should be
|
// what the next process id on the bus should be
|
||||||
connection: zbus::Connection,
|
connection: Connection,
|
||||||
next_process: u32,
|
next_process: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ pub struct Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProcessManager {
|
impl ProcessManager {
|
||||||
pub fn new(conn: zbus::Connection) -> ProcessManager {
|
pub fn new(conn: Connection) -> ProcessManager {
|
||||||
ProcessManager {
|
ProcessManager {
|
||||||
connection: conn,
|
connection: conn,
|
||||||
next_process: 0,
|
next_process: 0,
|
||||||
|
@ -48,7 +48,7 @@ impl ProcessManager {
|
||||||
executable: &str,
|
executable: &str,
|
||||||
args: &[impl AsRef<OsStr>],
|
args: &[impl AsRef<OsStr>],
|
||||||
operation_name: &str,
|
operation_name: &str,
|
||||||
) -> fdo::Result<zbus::zvariant::OwnedObjectPath> {
|
) -> fdo::Result<zvariant::OwnedObjectPath> {
|
||||||
// Run the given executable and give back an object path
|
// Run the given executable and give back an object path
|
||||||
let path = format!("{}{}", PROCESS_PREFIX, self.next_process);
|
let path = format!("{}{}", PROCESS_PREFIX, self.next_process);
|
||||||
self.next_process += 1;
|
self.next_process += 1;
|
||||||
|
@ -60,7 +60,7 @@ impl ProcessManager {
|
||||||
.object_server()
|
.object_server()
|
||||||
.at(path.as_str(), pm)
|
.at(path.as_str(), pm)
|
||||||
.await?;
|
.await?;
|
||||||
zbus::zvariant::OwnedObjectPath::try_from(path).map_err(to_zbus_fdo_error)
|
zvariant::OwnedObjectPath::try_from(path).map_err(to_zbus_fdo_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_long_command(executable: &str, args: &[impl AsRef<OsStr>]) -> Result<Job> {
|
pub async fn run_long_command(executable: &str, args: &[impl AsRef<OsStr>]) -> Result<Job> {
|
||||||
|
|
|
@ -7,8 +7,7 @@ use tokio::fs;
|
||||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||||
use tokio::net::unix::pipe;
|
use tokio::net::unix::pipe;
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
use zbus::connection::Connection;
|
use zbus::{zvariant, Connection};
|
||||||
use zbus::zvariant;
|
|
||||||
|
|
||||||
use crate::{get_appid, path, read_comm, Service};
|
use crate::{get_appid, path, read_comm, Service};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::{anyhow, bail, Result};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use zbus::zvariant::OwnedObjectPath;
|
use zbus::zvariant::OwnedObjectPath;
|
||||||
use zbus::Connection;
|
use zbus::{CacheProperties, Connection};
|
||||||
|
|
||||||
#[zbus::proxy(
|
#[zbus::proxy(
|
||||||
interface = "org.freedesktop.systemd1.Unit",
|
interface = "org.freedesktop.systemd1.Unit",
|
||||||
|
@ -88,7 +88,7 @@ impl<'dbus> SystemdUnit<'dbus> {
|
||||||
let path = String::from(path.to_str().ok_or(anyhow!("Unit name {name} invalid"))?);
|
let path = String::from(path.to_str().ok_or(anyhow!("Unit name {name} invalid"))?);
|
||||||
Ok(SystemdUnit {
|
Ok(SystemdUnit {
|
||||||
proxy: SystemdUnitProxy::builder(&connection)
|
proxy: SystemdUnitProxy::builder(&connection)
|
||||||
.cache_properties(zbus::CacheProperties::No)
|
.cache_properties(CacheProperties::No)
|
||||||
.path(path)?
|
.path(path)?
|
||||||
.build()
|
.build()
|
||||||
.await?,
|
.await?,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue