Cargo.toml: Update to zbus 5

This commit is contained in:
Vicki Pfau 2024-11-07 17:20:57 -08:00
parent bdb2d26e2f
commit a2af4d1bc5
29 changed files with 100 additions and 385 deletions

View file

@ -194,11 +194,7 @@ async fn get_all_properties(conn: &Connection) -> Result<()> {
}
_ => continue,
};
properties.extend(
properties_proxy
.get_all(zvariant::Optional::from(Some(name)))
.await?,
);
properties.extend(properties_proxy.get_all(name).await?);
}
for key in properties.keys().sorted() {
let value = &properties[key];

View file

@ -14,8 +14,7 @@ use tokio_util::sync::CancellationToken;
use tracing::error;
use tracing_subscriber::prelude::*;
use tracing_subscriber::{fmt, Registry};
use zbus::connection::Connection;
use zbus::ConnectionBuilder;
use zbus::connection::{Builder, Connection};
use crate::daemon::{channel, Daemon, DaemonCommand, DaemonContext};
use crate::ds_inhibit::Inhibitor;
@ -160,7 +159,7 @@ impl DaemonContext for RootContext {
pub(crate) type Command = DaemonCommand<RootCommand>;
async fn create_connection(channel: Sender<Command>) -> Result<Connection> {
let connection = ConnectionBuilder::system()?
let connection = Builder::system()?
.name("com.steampowered.SteamOSManager1")?
.build()
.await?;

View file

@ -14,8 +14,7 @@ use tracing_subscriber::prelude::*;
use tracing_subscriber::{fmt, Registry};
#[cfg(not(test))]
use xdg::BaseDirectories;
use zbus::connection::Connection;
use zbus::ConnectionBuilder;
use zbus::connection::{Builder, Connection};
use crate::daemon::{channel, Daemon, DaemonCommand, DaemonContext};
use crate::job::{JobManager, JobManagerService};
@ -107,7 +106,7 @@ async fn create_connections(
channel: Sender<Command>,
) -> Result<(Connection, Connection, impl Service)> {
let system = Connection::system().await?;
let connection = ConnectionBuilder::session()?
let connection = Builder::session()?
.name("com.steampowered.SteamOSManager1")?
.build()
.await?;

View file

@ -21,7 +21,8 @@ use tokio::sync::oneshot;
use tokio_stream::StreamExt;
use tracing::error;
use zbus::fdo::{self, IntrospectableProxy};
use zbus::{interface, zvariant, Connection, Interface, InterfaceRef, SignalContext};
use zbus::object_server::{Interface, InterfaceRef, SignalEmitter};
use zbus::{interface, zvariant, Connection};
use zbus_xml::Node;
use crate::error::{to_zbus_fdo_error, zbus_to_zbus_fdo};
@ -100,7 +101,7 @@ impl JobManager {
.await?;
let object_path = zvariant::OwnedObjectPath::try_from(path).map_err(to_zbus_fdo_error)?;
JobManagerInterface::job_started(self.jm_iface.signal_context(), object_path.as_ref())
JobManagerInterface::job_started(self.jm_iface.signal_emitter(), object_path.as_ref())
.await?;
Ok(object_path)
}
@ -170,7 +171,7 @@ impl JobManager {
impl JobManagerInterface {
#[zbus(signal)]
async fn job_started(
signal_ctxt: &SignalContext<'_>,
signal_ctxt: &SignalEmitter<'_>,
job: zvariant::ObjectPath<'_>,
) -> zbus::Result<()>;
}
@ -387,14 +388,14 @@ pub(crate) mod test {
use tokio::sync::{mpsc, oneshot};
use tokio::task::JoinHandle;
use tokio::time::sleep;
use zbus::connection::Builder;
use zbus::names::BusName;
use zbus::ConnectionBuilder;
#[tokio::test]
async fn test_job_emitted() {
let _h = testing::start();
let connection = ConnectionBuilder::session()
let connection = Builder::session()
.expect("session")
.build()
.await
@ -405,7 +406,7 @@ pub(crate) mod test {
let (tx, rx) = oneshot::channel::<()>();
let job = tokio::spawn(async move {
let connection = ConnectionBuilder::session()?.build().await?;
let connection = Builder::session()?.build().await?;
let jm = JobManager1Proxy::builder(&connection)
.destination(sender)?
.build()
@ -535,7 +536,7 @@ pub(crate) mod test {
let (fin_tx, fin_rx) = oneshot::channel();
let job: JoinHandle<Result<()>> = tokio::spawn(async move {
let connection = ConnectionBuilder::address(address)
let connection = Builder::address(address)
.expect("address")
.build()
.await

View file

@ -13,8 +13,9 @@ use tokio::fs::File;
use tokio::sync::mpsc::Sender;
use tokio::sync::oneshot;
use tracing::{error, info};
use zbus::object_server::SignalEmitter;
use zbus::zvariant::{self, Fd};
use zbus::{fdo, interface, Connection, SignalContext};
use zbus::{fdo, interface, Connection};
use crate::daemon::root::{Command, RootCommand};
use crate::daemon::DaemonCommand;
@ -310,7 +311,7 @@ impl SteamOSManager {
&mut self,
mode: u32,
options: HashMap<&str, zvariant::Value<'_>>,
#[zbus(signal_context)] ctx: SignalContext<'_>,
#[zbus(signal_emitter)] ctx: SignalEmitter<'_>,
) -> fdo::Result<()> {
// Set the wifi debug mode to mode, using an int for flexibility going forward but only
// doing things on 0 or 1 for now

View file

@ -11,8 +11,9 @@ use std::collections::HashMap;
use tokio::sync::mpsc::{Sender, UnboundedSender};
use tokio::sync::oneshot;
use tracing::error;
use zbus::proxy::Builder;
use zbus::{fdo, interface, zvariant, CacheProperties, Connection, Proxy, SignalContext};
use zbus::object_server::SignalEmitter;
use zbus::proxy::{Builder, CacheProperties};
use zbus::{fdo, interface, zvariant, Connection, Proxy};
use crate::cec::{HdmiCecControl, HdmiCecState};
use crate::daemon::user::Command;
@ -190,7 +191,7 @@ impl SteamOSManager {
&self,
mode: u32,
buffer_size: u32,
#[zbus(signal_context)] ctx: SignalContext<'_>,
#[zbus(signal_emitter)] ctx: SignalEmitter<'_>,
) -> fdo::Result<()> {
let _: () = method!(self, "SetWifiDebugMode", mode, buffer_size)?;
self.wifi_debug_mode_state_changed(&ctx)
@ -464,7 +465,7 @@ impl WifiDebug1 {
&self,
mode: u32,
options: HashMap<&str, zvariant::Value<'_>>,
#[zbus(signal_context)] ctx: SignalContext<'_>,
#[zbus(signal_emitter)] ctx: SignalEmitter<'_>,
) -> fdo::Result<()> {
let _: () = method!(self, "SetWifiDebugMode", mode, options)?;
self.wifi_debug_mode_state_changed(&ctx)
@ -669,7 +670,8 @@ mod test {
use std::time::Duration;
use tokio::sync::mpsc::unbounded_channel;
use tokio::time::sleep;
use zbus::{Connection, Interface};
use zbus::object_server::Interface;
use zbus::Connection;
struct TestHandle {
_handle: testing::TestHandle,

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.AmbientLightSensor1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait AmbientLightSensor1 {
pub trait AmbientLightSensor1 {
/// AlsCalibrationGain property
#[zbus(property)]
fn als_calibration_gain(&self) -> zbus::Result<Vec<f64>>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.CpuScaling1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait CpuScaling1 {
pub trait CpuScaling1 {
/// AvailableCpuScalingGovernors property
#[zbus(property)]
fn available_cpu_scaling_governors(&self) -> zbus::Result<Vec<String>>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.FactoryReset1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait FactoryReset1 {
pub trait FactoryReset1 {
/// PrepareFactoryReset method
fn prepare_factory_reset(&self, kind: u32) -> zbus::Result<u32>;
}

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.FanControl1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait FanControl1 {
pub trait FanControl1 {
/// FanControlState property
#[zbus(property)]
fn fan_control_state(&self) -> zbus::Result<u32>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.GpuPerformanceLevel1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait GpuPerformanceLevel1 {
pub trait GpuPerformanceLevel1 {
/// AvailableGpuPerformanceLevels property
#[zbus(property)]
fn available_gpu_performance_levels(&self) -> zbus::Result<Vec<String>>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.GpuPowerProfile1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait GpuPowerProfile1 {
pub trait GpuPowerProfile1 {
/// AvailableGpuPowerProfiles property
#[zbus(property)]
fn available_gpu_power_profiles(&self) -> zbus::Result<Vec<String>>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.HdmiCec1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait HdmiCec1 {
pub trait HdmiCec1 {
/// HdmiCecState property
#[zbus(property)]
fn hdmi_cec_state(&self) -> zbus::Result<u32>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.Job1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -17,7 +17,7 @@ use zbus::proxy;
default_service = "com.steampowered.SteamOSManager1",
assume_defaults = true
)]
trait Job1 {
pub trait Job1 {
/// Cancel method
fn cancel(&self, force: bool) -> zbus::Result<()>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.JobManager1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1/Jobs",
assume_defaults = true
)]
trait JobManager1 {
pub trait JobManager1 {
/// JobStarted signal
#[zbus(signal)]
fn job_started(&self, job: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.Manager`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.Manager.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait Manager {
pub trait Manager {
/// SetWifiDebugMode method
fn set_wifi_debug_mode(&self, mode: u32, buffer_size: u32) -> zbus::Result<()>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.Manager2`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait Manager2 {
pub trait Manager2 {
/// ReloadConfig method
fn reload_config(&self) -> zbus::Result<()>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.Storage1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait Storage1 {
pub trait Storage1 {
/// FormatDevice method
fn format_device(
&self,

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.TdpLimit1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait TdpLimit1 {
pub trait TdpLimit1 {
/// TdpLimit property
#[zbus(property)]
fn tdp_limit(&self) -> zbus::Result<u32>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.UdevEvents1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait UdevEvents1 {
pub trait UdevEvents1 {
/// UsbOverCurrent signal
#[zbus(signal)]
fn usb_over_current(&self, devpath: &str, port: &str, count: u64) -> zbus::Result<()>;

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.UpdateBios1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait UpdateBios1 {
pub trait UpdateBios1 {
/// UpdateBios method
fn update_bios(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
}

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.UpdateDock1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait UpdateDock1 {
pub trait UpdateDock1 {
/// UpdateDock method
fn update_dock(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
}

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.WifiDebug1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait WifiDebug1 {
pub trait WifiDebug1 {
/// SetWifiDebugMode method
fn set_wifi_debug_mode(
&self,

View file

@ -1,6 +1,6 @@
//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.WifiPowerManagement1`
//!
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data.
//! Source: `com.steampowered.SteamOSManager1.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
@ -18,7 +18,7 @@ use zbus::proxy;
default_path = "/com/steampowered/SteamOSManager1",
assume_defaults = true
)]
trait WifiPowerManagement1 {
pub trait WifiPowerManagement1 {
/// WifiPowerManagementState property
#[zbus(property)]
fn wifi_power_management_state(&self) -> zbus::Result<u32>;

View file

@ -9,8 +9,9 @@ use anyhow::{anyhow, Result};
use std::path::PathBuf;
use std::str::FromStr;
use strum::{Display, EnumString};
use zbus::proxy::CacheProperties;
use zbus::zvariant::OwnedObjectPath;
use zbus::{CacheProperties, Connection};
use zbus::Connection;
#[zbus::proxy(
interface = "org.freedesktop.systemd1.Unit",

View file

@ -17,8 +17,10 @@ use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::{Child, Command};
use tokio::sync::Mutex;
use tracing::error;
use zbus::connection::{Builder, Connection};
use zbus::object_server::Interface;
use zbus::zvariant::ObjectPath;
use zbus::{Address, Connection, ConnectionBuilder, Interface};
use zbus::Address;
use zbus_xml::{Method, Node, Property, Signal};
use crate::platform::PlatformConfig;
@ -128,7 +130,7 @@ impl MockDBus {
.ok_or(anyhow!("Failed to read address"))?;
let address = Address::from_str(address.trim_end())?;
let connection = ConnectionBuilder::address(address.clone())?.build().await?;
let connection = Builder::address(address.clone())?.build().await?;
Ok(MockDBus {
connection,

View file

@ -13,7 +13,8 @@ use tokio::net::unix::pipe::Sender;
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tracing::debug;
use udev::{Event, EventType, MonitorBuilder};
use zbus::{self, interface, Connection, InterfaceRef, SignalContext};
use zbus::object_server::{InterfaceRef, SignalEmitter};
use zbus::{self, interface, Connection};
use crate::thread::spawn;
use crate::Service;
@ -66,7 +67,7 @@ impl Service for UdevMonitor {
count,
} => {
UdevDbusObject::usb_over_current(
self.udev_object.signal_context(),
self.udev_object.signal_emitter(),
devpath.as_str(),
port.as_str(),
count,
@ -104,7 +105,7 @@ impl UdevMonitor {
impl UdevDbusObject {
#[zbus(signal)]
async fn usb_over_current(
signal_ctxt: &SignalContext<'_>,
signal_ctxt: &SignalEmitter<'_>,
devpath: &str,
port: &str,
count: u64,
@ -176,7 +177,7 @@ mod test {
use super::*;
use std::time::Duration;
use tokio::time::sleep;
use zbus::Interface;
use zbus::object_server::Interface;
use crate::testing;