Skip to content

Commit 70281e7

Browse files
committed
Update to zbus 5.x
1 parent 22198fd commit 70281e7

File tree

18 files changed

+226
-146
lines changed

18 files changed

+226
-146
lines changed

Cargo.lock

Lines changed: 181 additions & 111 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-c
2828
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [
2929
"client",
3030
], rev = "c8d3a1c" }
31-
cosmic-settings-subscriptions = { git = "https://github.com/pop-os/cosmic-settings-subscriptions" }
31+
cosmic-settings-subscriptions = { git = "https://github.com/pop-os/cosmic-settings-subscriptions", branch = "zbus5" }
3232
# cosmic-settings-subscriptions = { path = "../cosmic-settings-subscriptions" }
3333

3434
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features = false, features = [
@@ -45,7 +45,7 @@ i18n-embed = { version = "0.14.1", features = [
4545
"desktop-requester",
4646
] }
4747
i18n-embed-fl = "0.8"
48-
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [
48+
libcosmic = { git = "https://github.com/pop-os/libcosmic", branch = "zbus5", default-features = false, features = [
4949
"applet",
5050
"applet-token",
5151
"multi-window",
@@ -59,7 +59,7 @@ once_cell = "1"
5959
rust-embed = "8.3"
6060
rust-embed-utils = "8.3.0"
6161
rustix = { version = "0.38", features = ["fs", "process"] }
62-
zbus = { version = "4.2.1", default-features = false, features = ["tokio"] }
62+
zbus = { version = "5.0.1", default-features = false, features = ["tokio"] }
6363
tracing = "0.1"
6464
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
6565
tracing-log = "0.2.0"
@@ -83,3 +83,11 @@ ignored = ["libcosmic"]
8383
# winit = { path = "../winit" }
8484
[patch."https://github.com/smithay/client-toolkit.git"]
8585
sctk = { package = "smithay-client-toolkit", version = "=0.19.2" }
86+
87+
[patch."https://github.com/pop-os/dbus-settings-bindings"]
88+
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings//", branch = "zbus5" }
89+
90+
[patch."https://github.com/pop-os/libcosmic"]
91+
cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus5" }
92+
libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus5" }
93+
iced_futures = { git = "https://github.com/pop-os/libcosmic//", branch = "zbus5" }

cosmic-app-list/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rand = "0.8.5"
2121
rust-embed.workspace = true
2222
rustix.workspace = true
2323
serde = { version = "1.0", features = ["derive"] }
24-
switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings" }
24+
switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
2525
tokio = { version = "1.36.0", features = [
2626
"sync",
2727
"rt",

cosmic-applet-a11y/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
cosmic-dbus-a11y = { git = "https://github.com/pop-os/dbus-settings-bindings" }
7+
cosmic-dbus-a11y = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
88
cosmic-time.workspace = true
99
i18n-embed-fl.workspace = true
1010
i18n-embed.workspace = true

cosmic-applet-audio/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ i18n-embed-fl.workspace = true
1111
i18n-embed.workspace = true
1212
libcosmic.workspace = true
1313
libpulse-binding = "2.28.1"
14-
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
14+
mpris2-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
1515
rust-embed.workspace = true
1616
serde = "1.0.197"
1717
tokio = { version = "1.36.0", features = ["full"] }

cosmic-applet-audio/src/mpris_subscription.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ struct State {
135135
players: Vec<MprisPlayer>,
136136
active_player: Option<MprisPlayer>,
137137
active_player_metadata_stream: Option<Box<dyn futures::Stream<Item = ()> + Unpin + Send>>,
138-
any_player_state_stream: futures::stream::SelectAll<zbus::PropertyStream<'static, String>>,
138+
any_player_state_stream:
139+
futures::stream::SelectAll<zbus::proxy::PropertyStream<'static, String>>,
139140
}
140141

141142
fn filter_firefox_players(players: &mut Vec<MprisPlayer>) {

cosmic-applet-battery/src/backend/power_daemon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use zbus::proxy;
2525
default_path = "/com/system76/PowerDaemon",
2626
assume_defaults = true
2727
)]
28-
trait PowerDaemon {
28+
pub trait PowerDaemon {
2929
/// Balanced method
3030
fn balanced(&self) -> zbus::Result<()>;
3131

cosmic-applet-battery/src/backend/power_profiles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use zbus::proxy;
1717
default_path = "/org/freedesktop/UPower/PowerProfiles",
1818
assume_defaults = true
1919
)]
20-
trait PowerProfiles {
20+
pub trait PowerProfiles {
2121
/// HoldProfile method
2222
fn hold_profile(&self, profile: &str, reason: &str, application_id: &str) -> zbus::Result<u32>;
2323

cosmic-applet-network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "GPL-3.0-or-later"
77
[dependencies]
88

99
anyhow.workspace = true
10-
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings" }
10+
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
1111
cosmic-time.workspace = true
1212
futures.workspace = true
1313
futures-util.workspace = true

cosmic-applet-notifications/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ tokio = { version = "1.36.0", features = [
1717
"io-util",
1818
"io-std",
1919
] }
20-
cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notifications" }
21-
cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications" }
20+
cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notifications", branch = "zbus5" }
21+
cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications", branch = "zbus5" }
2222
# cosmic-notifications-util = { path = "../../cosmic-notifications-daemon/cosmic-notifications-util" }
2323
# cosmic-notifications-config = { path = "../../cosmic-notifications-daemon/cosmic-notifications-config" }
2424
tracing = "0.1"

cosmic-applet-notifications/src/subscriptions/freedesktop_proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use zbus::proxy;
2626
default_service = "org.freedesktop.Notifications",
2727
default_path = "/org/freedesktop/Notifications"
2828
)]
29-
trait Notifications {
29+
pub trait Notifications {
3030
/// CloseNotification method
3131
fn close_notification(&self, id: u32) -> zbus::Result<()>;
3232

cosmic-applet-notifications/src/subscriptions/notifications.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn notifications(proxy: NotificationsAppletProxy<'static>) -> Subscription<N
8484
interface = "com.system76.NotificationsApplet",
8585
default_path = "/com/system76/NotificationsApplet"
8686
)]
87-
trait NotificationsApplet {
87+
pub trait NotificationsApplet {
8888
#[zbus(signal)]
8989
fn notify(
9090
&self,

cosmic-applet-power/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ license = "GPL-3.0-only"
88
i18n-embed-fl.workspace = true
99
i18n-embed.workspace = true
1010
libcosmic.workspace = true
11-
logind-zbus = "4.0.3"
11+
# logind-zbus = "4.0.3"
12+
logind-zbus = { git = "https://gitlab.com/ids1024/logind-zbus", branch = "zbus5" }
1213
once_cell = "1.19.0"
1314
rust-embed.workspace = true
1415
rustix.workspace = true

cosmic-applet-power/src/cosmic_session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ use zbus::proxy;
88
default_service = "com.system76.CosmicSession",
99
default_path = "/com/system76/CosmicSession"
1010
)]
11-
trait CosmicSession {
11+
pub trait CosmicSession {
1212
fn exit(&self) -> zbus::Result<()>;
1313
}

cosmic-applet-power/src/session_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use zbus::proxy;
2525

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

cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use cosmic::{
66
widget::icon,
77
};
88
use futures::{FutureExt, StreamExt};
9+
use std::collections::HashMap;
910
use zbus::zvariant::{self, OwnedValue};
1011

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

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

@@ -128,15 +129,14 @@ pub struct Layout(i32, LayoutProps, Vec<Layout>);
128129
impl<'a> serde::Deserialize<'a> for Layout {
129130
fn deserialize<D: serde::Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error> {
130131
let (id, props, children) =
131-
<(i32, LayoutProps, Vec<(zvariant::Signature<'_>, Self)>)>::deserialize(deserializer)?;
132+
<(i32, LayoutProps, Vec<(zvariant::Signature, Self)>)>::deserialize(deserializer)?;
132133
Ok(Self(id, props, children.into_iter().map(|x| x.1).collect()))
133134
}
134135
}
135136

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

142142
#[derive(Clone, Debug, zvariant::DeserializeDict)]
@@ -166,9 +166,7 @@ pub struct LayoutProps {
166166
}
167167

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

174172
#[allow(dead_code)]
@@ -227,7 +225,7 @@ impl Layout {
227225
}
228226

229227
#[zbus::proxy(interface = "com.canonical.dbusmenu")]
230-
trait DBusMenu {
228+
pub trait DBusMenu {
231229
fn get_layout(
232230
&self,
233231
parent_id: i32,

cosmic-applet-status-area/src/subscriptions/status_notifier_watcher/server.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
use futures::prelude::*;
99
use zbus::{
1010
fdo::{DBusProxy, RequestNameFlags, RequestNameReply},
11+
message::Header,
1112
names::{BusName, UniqueName, WellKnownName},
12-
MessageHeader, Result, SignalContext,
13+
object_server::SignalEmitter,
14+
Result,
1315
};
1416

1517
const NAME: WellKnownName =
@@ -26,8 +28,8 @@ impl StatusNotifierWatcher {
2628
async fn register_status_notifier_item(
2729
&mut self,
2830
service: &str,
29-
#[zbus(header)] hdr: MessageHeader<'_>,
30-
#[zbus(signal_context)] ctxt: SignalContext<'_>,
31+
#[zbus(header)] hdr: Header<'_>,
32+
#[zbus(signal_emitter)] ctxt: SignalEmitter<'_>,
3133
) {
3234
let sender = hdr.sender().unwrap();
3335
let service = if service.starts_with('/') {
@@ -62,20 +64,20 @@ impl StatusNotifierWatcher {
6264
}
6365

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

6870
#[zbus(signal)]
6971
async fn status_notifier_item_unregistered(
70-
ctxt: &SignalContext<'_>,
72+
ctxt: &SignalEmitter<'_>,
7173
service: &str,
7274
) -> Result<()>;
7375

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

7779
#[zbus(signal)]
78-
async fn status_notifier_host_unregistered(ctxt: &SignalContext<'_>) -> Result<()>;
80+
async fn status_notifier_host_unregistered(ctxt: &SignalEmitter<'_>) -> Result<()>;
7981
}
8082

8183
pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
@@ -122,7 +124,7 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
122124
.iter()
123125
.position(|(unique_name, _)| unique_name == name)
124126
{
125-
let ctxt = zbus::SignalContext::new(&connection, OBJECT_PATH).unwrap();
127+
let ctxt = SignalEmitter::new(&connection, OBJECT_PATH).unwrap();
126128
let service = interface.items.remove(idx).1;
127129
StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service)
128130
.await

cosmic-applet-time/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ icu = { version = "1.4.0", features = [
2222
"icu_datetime_experimental",
2323
] }
2424
zbus.workspace = true
25-
timedate-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
25+
timedate-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }

0 commit comments

Comments
 (0)