Skip to content

Commit

Permalink
feat: update to zbus v4
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored and hoodie committed Apr 4, 2024
1 parent c0ffee4 commit 9683d01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<xdg::NotificationHandle> {
Expand Down
43 changes: 22 additions & 21 deletions src/xdg/zbus_rs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async fn send_notification_via_connection_at_bus(
)
.await?
.body()
.unwrap();
.deserialize()?;
Ok(reply)
}

Expand Down Expand Up @@ -193,7 +193,8 @@ pub async fn get_capabilities_at_bus(bus: NotificationBus) -> Result<Vec<String>
&(),
)
.await?
.body()?;
.body()
.deserialize()?;
Ok(info)
}

Expand All @@ -212,7 +213,8 @@ pub async fn get_server_information_at_bus(bus: NotificationBus) -> Result<xdg::
&(),
)
.await?
.body()?;
.body()
.deserialize()?;

Ok(info)
}
Expand Down Expand Up @@ -255,29 +257,28 @@ async fn wait_for_action_signal(
proxy.add_match_rule(close_signal_rule).await.unwrap();

while let Ok(Some(msg)) = zbus::MessageStream::from(connection).try_next().await {
if let Ok(header) = msg.header() {
if let Ok(zbus::MessageType::Signal) = header.message_type() {
match header.member() {
Ok(Some(name)) if name == "ActionInvoked" => {
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(_) => {}
}
_ => {}
}
}
}
Expand Down

0 comments on commit 9683d01

Please sign in to comment.