Skip to content

Commit

Permalink
WIP Update to zbus 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Nov 2, 2024
1 parent 5b5cd77 commit b42f46e
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 99 deletions.
220 changes: 143 additions & 77 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-c
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [
"client",
], rev = "c8d3a1c" }
cosmic-settings-subscriptions = { git = "https://github.com/pop-os/cosmic-settings-subscriptions" }

cosmic-settings-subscriptions = { git = "https://github.com/pop-os/cosmic-settings-subscriptions", branch = "zbus5" }
# cosmic-settings-subscriptions = { path = "../cosmic-settings-subscriptions" }

cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features = false, features = [
Expand Down Expand Up @@ -58,7 +59,7 @@ once_cell = "1"
rust-embed = "8.3"
rust-embed-utils = "8.3.0"
rustix = { version = "0.38", features = ["fs", "process"] }
zbus = { version = "4.2.1", default-features = false, features = ["tokio"] }
zbus = { version = "5.0.1", default-features = false, features = ["tokio"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-log = "0.2.0"
Expand Down
2 changes: 1 addition & 1 deletion cosmic-app-list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rand = "0.8.5"
rust-embed.workspace = true
rustix.workspace = true
serde = { version = "1.0", features = ["derive"] }
switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings" }
switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
tokio = { version = "1.36.0", features = [
"sync",
"rt",
Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ i18n-embed-fl.workspace = true
i18n-embed.workspace = true
libcosmic.workspace = true
libpulse-binding = "2.28.1"
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
rust-embed.workspace = true
serde = "1.0.197"
tokio = { version = "1.36.0", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-audio/src/mpris_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct State {
players: Vec<MprisPlayer>,
active_player: Option<MprisPlayer>,
active_player_metadata_stream: Option<Box<dyn futures::Stream<Item = ()> + Unpin + Send>>,
any_player_state_stream: futures::stream::SelectAll<zbus::PropertyStream<'static, String>>,
any_player_state_stream: futures::stream::SelectAll<zbus::proxy::PropertyStream<'static, String>>,
}

fn filter_firefox_players(players: &mut Vec<MprisPlayer>) {
Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-battery/src/backend/power_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use zbus::proxy;
default_path = "/com/system76/PowerDaemon",
assume_defaults = true
)]
trait PowerDaemon {
pub trait PowerDaemon {
/// Balanced method
fn balanced(&self) -> zbus::Result<()>;

Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-battery/src/backend/power_profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zbus::proxy;
default_path = "/org/freedesktop/UPower/PowerProfiles",
assume_defaults = true
)]
trait PowerProfiles {
pub trait PowerProfiles {
/// HoldProfile method
fn hold_profile(&self, profile: &str, reason: &str, application_id: &str) -> zbus::Result<u32>;

Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later"
[dependencies]

anyhow.workspace = true
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings" }
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
cosmic-time.workspace = true
futures.workspace = true
futures-util.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use zbus::proxy;
default_service = "org.freedesktop.Notifications",
default_path = "/org/freedesktop/Notifications"
)]
trait Notifications {
pub trait Notifications {
/// CloseNotification method
fn close_notification(&self, id: u32) -> zbus::Result<()>;

Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-power/src/cosmic_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ use zbus::proxy;
default_service = "com.system76.CosmicSession",
default_path = "/com/system76/CosmicSession"
)]
trait CosmicSession {
pub trait CosmicSession {
fn exit(&self) -> zbus::Result<()>;
}
2 changes: 1 addition & 1 deletion cosmic-applet-power/src/session_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use zbus::proxy;

#[proxy(interface = "org.gnome.SessionManager", assume_defaults = true)]
trait SessionManager {
pub trait SessionManager {
/// CanRebootToFirmwareSetup method
fn can_reboot_to_firmware_setup(&self) -> zbus::Result<bool>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub struct Layout(i32, LayoutProps, Vec<Layout>);
impl<'a> serde::Deserialize<'a> for Layout {
fn deserialize<D: serde::Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error> {
let (id, props, children) =
<(i32, LayoutProps, Vec<(zvariant::Signature<'_>, Self)>)>::deserialize(deserializer)?;
<(i32, LayoutProps, Vec<(zvariant::Signature, Self)>)>::deserialize(deserializer)?;
Ok(Self(id, props, children.into_iter().map(|x| x.1).collect()))
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ pub struct LayoutProps {
}

impl zvariant::Type for LayoutProps {
fn signature() -> zvariant::Signature<'static> {
fn signature() -> zvariant::Signature {
zvariant::Signature::try_from("a{sv}").unwrap()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use futures::prelude::*;
use zbus::{
fdo::{DBusProxy, RequestNameFlags, RequestNameReply},
names::{BusName, UniqueName, WellKnownName},
MessageHeader, Result, SignalContext,
object_server::SignalEmitter,
MessageHeader, Result,
};

const NAME: WellKnownName =
Expand All @@ -27,7 +28,7 @@ impl StatusNotifierWatcher {
&mut self,
service: &str,
#[zbus(header)] hdr: MessageHeader<'_>,
#[zbus(signal_context)] ctxt: SignalContext<'_>,
#[zbus(signal_emitter)] ctxt: SignalEmitter<'_>,
) {
let sender = hdr.sender().unwrap();
let service = if service.starts_with('/') {
Expand Down Expand Up @@ -62,20 +63,20 @@ impl StatusNotifierWatcher {
}

#[zbus(signal)]
async fn status_notifier_item_registered(ctxt: &SignalContext<'_>, service: &str)
async fn status_notifier_item_registered(ctxt: &SignalEmitter<'_>, service: &str)
-> Result<()>;

#[zbus(signal)]
async fn status_notifier_item_unregistered(
ctxt: &SignalContext<'_>,
ctxt: &SignalEmitter<'_>,
service: &str,
) -> Result<()>;

#[zbus(signal)]
async fn status_notifier_host_registered(ctxt: &SignalContext<'_>) -> Result<()>;
async fn status_notifier_host_registered(ctxt: &SignalEmitter<'_>) -> Result<()>;

#[zbus(signal)]
async fn status_notifier_host_unregistered(ctxt: &SignalContext<'_>) -> Result<()>;
async fn status_notifier_host_unregistered(ctxt: &SignalEmitter<'_>) -> Result<()>;
}

pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
Expand Down Expand Up @@ -122,7 +123,7 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
.iter()
.position(|(unique_name, _)| unique_name == name)
{
let ctxt = zbus::SignalContext::new(&connection, OBJECT_PATH).unwrap();
let ctxt = SignalEmitter::new(&connection, OBJECT_PATH).unwrap();
let service = interface.items.remove(idx).1;
StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service)
.await
Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ icu = { version = "1.4.0", features = [
"icu_datetime_experimental",
] }
zbus.workspace = true
timedate-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
timedate-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.80.1"
channel = "1.81.0" # XXX

0 comments on commit b42f46e

Please sign in to comment.