Update to zbus 5.x
This commit is contained in:
parent
b61e0bc94d
commit
417f43a0f5
14 changed files with 756 additions and 514 deletions
1206
Cargo.lock
generated
1206
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -60,7 +60,7 @@ once_cell = "1"
|
||||||
rust-embed = "8.5"
|
rust-embed = "8.5"
|
||||||
rust-embed-utils = "8.5.0"
|
rust-embed-utils = "8.5.0"
|
||||||
rustix = { version = "0.38", features = ["fs", "process"] }
|
rustix = { version = "0.38", features = ["fs", "process"] }
|
||||||
zbus = { version = "4", default-features = false, features = ["tokio"] }
|
zbus = { version = "5.7.1", default-features = false, features = ["tokio"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
||||||
tracing-log = "0.2.0"
|
tracing-log = "0.2.0"
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,8 @@ struct State {
|
||||||
players: Vec<MprisPlayer>,
|
players: Vec<MprisPlayer>,
|
||||||
active_player: Option<MprisPlayer>,
|
active_player: Option<MprisPlayer>,
|
||||||
active_player_metadata_stream: Option<Box<dyn futures::Stream<Item = ()> + Unpin + Send>>,
|
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>) {
|
fn filter_firefox_players(players: &mut Vec<MprisPlayer>) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use zbus::proxy;
|
||||||
default_path = "/com/system76/PowerDaemon",
|
default_path = "/com/system76/PowerDaemon",
|
||||||
assume_defaults = true
|
assume_defaults = true
|
||||||
)]
|
)]
|
||||||
trait PowerDaemon {
|
pub trait PowerDaemon {
|
||||||
/// Balanced method
|
/// Balanced method
|
||||||
fn balanced(&self) -> zbus::Result<()>;
|
fn balanced(&self) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use zbus::proxy;
|
||||||
default_path = "/org/freedesktop/UPower/PowerProfiles",
|
default_path = "/org/freedesktop/UPower/PowerProfiles",
|
||||||
assume_defaults = true
|
assume_defaults = true
|
||||||
)]
|
)]
|
||||||
trait PowerProfiles {
|
pub trait PowerProfiles {
|
||||||
/// HoldProfile method
|
/// HoldProfile method
|
||||||
fn hold_profile(&self, profile: &str, reason: &str, application_id: &str) -> zbus::Result<u32>;
|
fn hold_profile(&self, profile: &str, reason: &str, application_id: &str) -> zbus::Result<u32>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notificati
|
||||||
cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications" }
|
cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications" }
|
||||||
# cosmic-notifications-util = { path = "../../cosmic-notifications-daemon/cosmic-notifications-util" }
|
# cosmic-notifications-util = { path = "../../cosmic-notifications-daemon/cosmic-notifications-util" }
|
||||||
# cosmic-notifications-config = { path = "../../cosmic-notifications-daemon/cosmic-notifications-config" }
|
# cosmic-notifications-config = { path = "../../cosmic-notifications-daemon/cosmic-notifications-config" }
|
||||||
|
futures-util = { version = "0.3", feature = ["sink", "stream"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
ron = "0.8"
|
ron = "0.8"
|
||||||
sendfd = { version = "0.4", features = ["tokio"] }
|
sendfd = { version = "0.4", features = ["tokio"] }
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,10 @@ use cosmic::{
|
||||||
iced::futures::{self, SinkExt},
|
iced::futures::{self, SinkExt},
|
||||||
iced_futures::{stream, Subscription},
|
iced_futures::{stream, Subscription},
|
||||||
};
|
};
|
||||||
|
use futures_util::StreamExt;
|
||||||
use tokio::sync::mpsc::{channel, Receiver, Sender};
|
use tokio::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
use zbus::{export::futures_util::StreamExt, Connection};
|
use zbus::Connection;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum State {
|
pub enum State {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use zbus::proxy;
|
||||||
default_service = "org.freedesktop.Notifications",
|
default_service = "org.freedesktop.Notifications",
|
||||||
default_path = "/org/freedesktop/Notifications"
|
default_path = "/org/freedesktop/Notifications"
|
||||||
)]
|
)]
|
||||||
trait Notifications {
|
pub trait Notifications {
|
||||||
/// CloseNotification method
|
/// CloseNotification method
|
||||||
fn close_notification(&self, id: u32) -> zbus::Result<()>;
|
fn close_notification(&self, id: u32) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use cosmic::{
|
||||||
iced_futures::Subscription,
|
iced_futures::Subscription,
|
||||||
};
|
};
|
||||||
use cosmic_notifications_util::Notification;
|
use cosmic_notifications_util::Notification;
|
||||||
|
use futures_util::{SinkExt, StreamExt};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
future::pending,
|
future::pending,
|
||||||
|
|
@ -17,11 +18,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tracing::{error, trace};
|
use tracing::{error, trace};
|
||||||
use zbus::{
|
use zbus::{connection::Builder, proxy};
|
||||||
connection::Builder,
|
|
||||||
export::futures_util::{SinkExt, StreamExt},
|
|
||||||
proxy,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum State {
|
pub enum State {
|
||||||
|
|
@ -130,7 +127,7 @@ pub fn notifications(proxy: NotificationsAppletProxy<'static>) -> Subscription<O
|
||||||
interface = "com.system76.NotificationsApplet",
|
interface = "com.system76.NotificationsApplet",
|
||||||
default_path = "/com/system76/NotificationsApplet"
|
default_path = "/com/system76/NotificationsApplet"
|
||||||
)]
|
)]
|
||||||
trait NotificationsApplet {
|
pub trait NotificationsApplet {
|
||||||
#[zbus(signal)]
|
#[zbus(signal)]
|
||||||
fn notify(
|
fn notify(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ license = "GPL-3.0-only"
|
||||||
i18n-embed-fl.workspace = true
|
i18n-embed-fl.workspace = true
|
||||||
i18n-embed.workspace = true
|
i18n-embed.workspace = true
|
||||||
libcosmic.workspace = true
|
libcosmic.workspace = true
|
||||||
logind-zbus = "4.0"
|
logind-zbus = "5.3.2"
|
||||||
once_cell = "1.20.3"
|
once_cell = "1.20.3"
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
rustix.workspace = true
|
rustix.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@ use zbus::proxy;
|
||||||
default_service = "com.system76.CosmicSession",
|
default_service = "com.system76.CosmicSession",
|
||||||
default_path = "/com/system76/CosmicSession"
|
default_path = "/com/system76/CosmicSession"
|
||||||
)]
|
)]
|
||||||
trait CosmicSession {
|
pub trait CosmicSession {
|
||||||
fn exit(&self) -> zbus::Result<()>;
|
fn exit(&self) -> zbus::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
use zbus::proxy;
|
use zbus::proxy;
|
||||||
|
|
||||||
#[proxy(interface = "org.gnome.SessionManager", assume_defaults = true)]
|
#[proxy(interface = "org.gnome.SessionManager", assume_defaults = true)]
|
||||||
trait SessionManager {
|
pub trait SessionManager {
|
||||||
/// CanRebootToFirmwareSetup method
|
/// CanRebootToFirmwareSetup method
|
||||||
fn can_reboot_to_firmware_setup(&self) -> zbus::Result<bool>;
|
fn can_reboot_to_firmware_setup(&self) -> zbus::Result<bool>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use cosmic::{
|
||||||
widget::icon,
|
widget::icon,
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
|
use std::collections::HashMap;
|
||||||
use zbus::zvariant::{self, OwnedValue};
|
use zbus::zvariant::{self, OwnedValue};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -122,7 +123,7 @@ async fn get_layout(menu_proxy: DBusMenuProxy<'static>) -> Result<Layout, String
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus::proxy(interface = "org.kde.StatusNotifierItem")]
|
#[zbus::proxy(interface = "org.kde.StatusNotifierItem")]
|
||||||
trait StatusNotifierItem {
|
pub trait StatusNotifierItem {
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn icon_name(&self) -> zbus::Result<String>;
|
fn icon_name(&self) -> zbus::Result<String>;
|
||||||
|
|
||||||
|
|
@ -143,15 +144,14 @@ pub struct Layout(i32, LayoutProps, Vec<Layout>);
|
||||||
impl<'a> serde::Deserialize<'a> for Layout {
|
impl<'a> serde::Deserialize<'a> for Layout {
|
||||||
fn deserialize<D: serde::Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error> {
|
fn deserialize<D: serde::Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error> {
|
||||||
let (id, props, children) =
|
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()))
|
Ok(Self(id, props, children.into_iter().map(|x| x.1).collect()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl zvariant::Type for Layout {
|
impl zvariant::Type for Layout {
|
||||||
fn signature() -> zvariant::Signature<'static> {
|
const SIGNATURE: &'static zvariant::Signature =
|
||||||
zvariant::Signature::try_from("(ia{sv}av)").unwrap()
|
<(i32, HashMap<String, zvariant::Value>, Vec<zvariant::Value>)>::SIGNATURE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, zvariant::DeserializeDict)]
|
#[derive(Clone, Debug, zvariant::DeserializeDict)]
|
||||||
|
|
@ -181,9 +181,7 @@ pub struct LayoutProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl zvariant::Type for LayoutProps {
|
impl zvariant::Type for LayoutProps {
|
||||||
fn signature() -> zvariant::Signature<'static> {
|
const SIGNATURE: &'static zvariant::Signature = <HashMap<String, zvariant::Value>>::SIGNATURE;
|
||||||
zvariant::Signature::try_from("a{sv}").unwrap()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -242,7 +240,7 @@ impl Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus::proxy(interface = "com.canonical.dbusmenu")]
|
#[zbus::proxy(interface = "com.canonical.dbusmenu")]
|
||||||
trait DBusMenu {
|
pub trait DBusMenu {
|
||||||
fn get_layout(
|
fn get_layout(
|
||||||
&self,
|
&self,
|
||||||
parent_id: i32,
|
parent_id: i32,
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use zbus::{
|
use zbus::{
|
||||||
fdo::{DBusProxy, RequestNameFlags, RequestNameReply},
|
fdo::{DBusProxy, RequestNameFlags, RequestNameReply},
|
||||||
|
message::Header,
|
||||||
names::{BusName, UniqueName, WellKnownName},
|
names::{BusName, UniqueName, WellKnownName},
|
||||||
MessageHeader, Result, SignalContext,
|
object_server::SignalEmitter,
|
||||||
|
Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
const NAME: WellKnownName =
|
const NAME: WellKnownName =
|
||||||
|
|
@ -26,8 +28,8 @@ impl StatusNotifierWatcher {
|
||||||
async fn register_status_notifier_item(
|
async fn register_status_notifier_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
service: &str,
|
service: &str,
|
||||||
#[zbus(header)] hdr: MessageHeader<'_>,
|
#[zbus(header)] hdr: Header<'_>,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_emitter)] ctxt: SignalEmitter<'_>,
|
||||||
) {
|
) {
|
||||||
let sender = hdr.sender().unwrap();
|
let sender = hdr.sender().unwrap();
|
||||||
let service = if service.starts_with('/') {
|
let service = if service.starts_with('/') {
|
||||||
|
|
@ -62,20 +64,20 @@ impl StatusNotifierWatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(signal)]
|
#[zbus(signal)]
|
||||||
async fn status_notifier_item_registered(ctxt: &SignalContext<'_>, service: &str)
|
async fn status_notifier_item_registered(ctxt: &SignalEmitter<'_>, service: &str)
|
||||||
-> Result<()>;
|
-> Result<()>;
|
||||||
|
|
||||||
#[zbus(signal)]
|
#[zbus(signal)]
|
||||||
async fn status_notifier_item_unregistered(
|
async fn status_notifier_item_unregistered(
|
||||||
ctxt: &SignalContext<'_>,
|
ctxt: &SignalEmitter<'_>,
|
||||||
service: &str,
|
service: &str,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
#[zbus(signal)]
|
#[zbus(signal)]
|
||||||
async fn status_notifier_host_registered(ctxt: &SignalContext<'_>) -> Result<()>;
|
async fn status_notifier_host_registered(ctxt: &SignalEmitter<'_>) -> Result<()>;
|
||||||
|
|
||||||
#[zbus(signal)]
|
#[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<()> {
|
pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
|
||||||
|
|
@ -122,7 +124,7 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
|
||||||
.iter()
|
.iter()
|
||||||
.position(|(unique_name, _)| unique_name == name)
|
.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;
|
let service = interface.items.remove(idx).1;
|
||||||
StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service)
|
StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service)
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue