From d573a839894f6c73e69232e3d7e8b8aa2037e633 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Tue, 20 Feb 2024 09:09:20 -0300 Subject: [PATCH] chore: update to zbus v4 --- Cargo.toml | 2 +- src/notification.rs | 2 +- src/xdg/zbus_rs.rs | 43 ++++++++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f6df4f18c..de59b374c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ include = [ dbus = { version = "0.9", optional = true } lazy_static = { version = "1", optional = true } image = { version = "0.24", optional = true } -zbus = { version = "3.10", optional = true } +zbus = { version = "4", optional = true } serde = { version = "1", optional = true } log = "0.4" env_logger ={ version ="0.10", optional = true } diff --git a/src/notification.rs b/src/notification.rs index 20bb2e110..4e1c6e132 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -452,7 +452,7 @@ impl Notification { windows::show_notification(self) } - /// Wraps show() but prints notification to stdout. + /// Wraps `show()` but prints notification to stdout. #[cfg(all(unix, not(target_os = "macos")))] #[deprecated = "this was never meant to be public API"] pub fn show_debug(&mut self) -> Result { diff --git a/src/xdg/zbus_rs.rs b/src/xdg/zbus_rs.rs index ab6985e80..4e244f85e 100644 --- a/src/xdg/zbus_rs.rs +++ b/src/xdg/zbus_rs.rs @@ -155,7 +155,7 @@ async fn send_notification_via_connection_at_bus( ) .await? .body() - .unwrap(); + .deserialize()?; Ok(reply) } @@ -193,7 +193,8 @@ pub async fn get_capabilities_at_bus(bus: NotificationBus) -> Result &(), ) .await? - .body()?; + .body() + .deserialize()?; Ok(info) } @@ -212,7 +213,8 @@ pub async fn get_server_information_at_bus(bus: NotificationBus) -> Result { - match msg.body::<(u32, String)>() { - Ok((nid, action)) if nid == id => { - handler.call(&ActionResponse::Custom(&action)); - break; - } - _ => {} + let header = msg.header(); + if let zbus::MessageType::Signal = header.message_type() { + match header.member() { + Some(name) if name == "ActionInvoked" => { + match msg.body().deserialize::<(u32, String)>() { + Ok((nid, action)) if nid == id => { + handler.call(&ActionResponse::Custom(&action)); + break; } + _ => {} } - Ok(Some(name)) if name == "NotificationClosed" => { - match msg.body::<(u32, u32)>() { - Ok((nid, reason)) if nid == id => { - handler.call(&ActionResponse::Closed(reason.into())); - break; - } - _ => {} + } + Some(name) if name == "NotificationClosed" => { + match msg.body().deserialize::<(u32, u32)>() { + Ok((nid, reason)) if nid == id => { + handler.call(&ActionResponse::Closed(reason.into())); + break; } + _ => {} } - Ok(_) | Err(_) => {} } + _ => {} } } }