Skip to content

Commit

Permalink
Update to zbus 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Nov 5, 2024
1 parent 22198fd commit 25e9354
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 146 deletions.
292 changes: 181 additions & 111 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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 All @@ -45,7 +45,7 @@ i18n-embed = { version = "0.14.1", features = [
"desktop-requester",
] }
i18n-embed-fl = "0.8"
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [
libcosmic = { git = "https://github.com/pop-os/libcosmic", branch = "zbus5", default-features = false, features = [
"applet",
"applet-token",
"multi-window",
Expand All @@ -59,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 All @@ -83,3 +83,11 @@ ignored = ["libcosmic"]
# winit = { path = "../winit" }
[patch."https://github.com/smithay/client-toolkit.git"]
sctk = { package = "smithay-client-toolkit", version = "=0.19.2" }

[patch."https://github.com/pop-os/dbus-settings-bindings"]
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings//", branch = "zbus5" }

[patch."https://github.com/pop-os/libcosmic"]
cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus5" }
libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus5" }
iced_futures = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus5" }
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-a11y/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
cosmic-dbus-a11y = { git = "https://github.com/pop-os/dbus-settings-bindings" }
cosmic-dbus-a11y = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
cosmic-time.workspace = true
i18n-embed-fl.workspace = true
i18n-embed.workspace = true
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
4 changes: 2 additions & 2 deletions cosmic-applet-notifications/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ tokio = { version = "1.36.0", features = [
"io-util",
"io-std",
] }
cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notifications" }
cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications" }
cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notifications", branch = "zbus5" }
cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications", branch = "zbus5" }
# cosmic-notifications-util = { path = "../../cosmic-notifications-daemon/cosmic-notifications-util" }
# cosmic-notifications-config = { path = "../../cosmic-notifications-daemon/cosmic-notifications-config" }
tracing = "0.1"
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"
)]

Check warning on line 28 in cosmic-applet-notifications/src/subscriptions/freedesktop_proxy.rs

View workflow job for this annotation

GitHub Actions / linting

this function has too many arguments (9/7)

warning: this function has too many arguments (9/7) --> cosmic-applet-notifications/src/subscriptions/freedesktop_proxy.rs:24:1 | 24 | / #[proxy( 25 | | interface = "org.freedesktop.Notifications", 26 | | default_service = "org.freedesktop.Notifications", 27 | | default_path = "/org/freedesktop/Notifications" 28 | | )] | |__^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments = note: this warning originates in the attribute macro `proxy` (in Nightly builds, run with -Z macro-backtrace for more info)
trait Notifications {
pub trait Notifications {
/// CloseNotification method
fn close_notification(&self, id: u32) -> zbus::Result<()>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn notifications(proxy: NotificationsAppletProxy<'static>) -> Subscription<N
interface = "com.system76.NotificationsApplet",
default_path = "/com/system76/NotificationsApplet"
)]
trait NotificationsApplet {
pub trait NotificationsApplet {
#[zbus(signal)]
fn notify(
&self,
Expand Down
3 changes: 2 additions & 1 deletion cosmic-applet-power/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ license = "GPL-3.0-only"
i18n-embed-fl.workspace = true
i18n-embed.workspace = true
libcosmic.workspace = true
logind-zbus = "4.0.3"
# logind-zbus = "4.0.3"
logind-zbus = { git = "https://gitlab.com/ids1024/logind-zbus", branch = "zbus5" }
once_cell = "1.19.0"
rust-embed.workspace = true
rustix.workspace = true
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 @@ -6,6 +6,7 @@ use cosmic::{
widget::icon,
};
use futures::{FutureExt, StreamExt};
use std::collections::HashMap;
use zbus::zvariant::{self, OwnedValue};

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -110,7 +111,7 @@ async fn get_layout(menu_proxy: DBusMenuProxy<'static>) -> Result<Layout, String
}

#[zbus::proxy(interface = "org.kde.StatusNotifierItem")]
trait StatusNotifierItem {
pub trait StatusNotifierItem {
#[zbus(property)]
fn icon_name(&self) -> zbus::Result<String>;

Expand All @@ -128,15 +129,14 @@ 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()))
}
}

impl zvariant::Type for Layout {
fn signature() -> zvariant::Signature<'static> {
zvariant::Signature::try_from("(ia{sv}av)").unwrap()
}
const SIGNATURE: &'static zvariant::Signature =
<(i32, HashMap<String, zvariant::Value>, Vec<zvariant::Value>)>::SIGNATURE;
}

#[derive(Clone, Debug, zvariant::DeserializeDict)]
Expand Down Expand Up @@ -166,9 +166,7 @@ pub struct LayoutProps {
}

impl zvariant::Type for LayoutProps {
fn signature() -> zvariant::Signature<'static> {
zvariant::Signature::try_from("a{sv}").unwrap()
}
const SIGNATURE: &'static zvariant::Signature = <HashMap<String, zvariant::Value>>::SIGNATURE;
}

#[allow(dead_code)]
Expand Down Expand Up @@ -227,7 +225,7 @@ impl Layout {
}

#[zbus::proxy(interface = "com.canonical.dbusmenu")]
trait DBusMenu {
pub trait DBusMenu {
fn get_layout(
&self,
parent_id: i32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
use futures::prelude::*;
use zbus::{
fdo::{DBusProxy, RequestNameFlags, RequestNameReply},
message::Header,
names::{BusName, UniqueName, WellKnownName},
MessageHeader, Result, SignalContext,
object_server::SignalEmitter,
Result,
};

const NAME: WellKnownName =
Expand All @@ -26,8 +28,8 @@ impl StatusNotifierWatcher {
async fn register_status_notifier_item(
&mut self,
service: &str,
#[zbus(header)] hdr: MessageHeader<'_>,
#[zbus(signal_context)] ctxt: SignalContext<'_>,
#[zbus(header)] hdr: Header<'_>,
#[zbus(signal_emitter)] ctxt: SignalEmitter<'_>,
) {
let sender = hdr.sender().unwrap();
let service = if service.starts_with('/') {
Expand Down Expand Up @@ -62,20 +64,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 +124,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" }

0 comments on commit 25e9354

Please sign in to comment.