diff --git a/docs/USAGE.md b/docs/USAGE.md index d4038fa..7877569 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -80,7 +80,5 @@ of desktop-entry-daemon refreshing the database whenever a new icon or entry is removed. along with this, if you'd like to watch changes, subscribe to `icon_changed` and `entry_changed` --> - - - + ``` \ No newline at end of file diff --git a/docs/net.ryanabx.DesktopEntry.xml b/docs/net.ryanabx.DesktopEntry.xml index e347c4c..3f0c949 100644 --- a/docs/net.ryanabx.DesktopEntry.xml +++ b/docs/net.ryanabx.DesktopEntry.xml @@ -80,9 +80,7 @@ removed. along with this, if you'd like to watch changes, subscribe to `icon_changed` and `entry_changed` --> - - - + diff --git a/src/daemon.rs b/src/daemon.rs index 30acfba..e49e0b4 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -10,7 +10,7 @@ use zbus::message::Header; use zbus::names::BusName; use zbus::object_server::SignalContext; use zbus::proxy::CacheProperties; -use zbus::{interface, proxy::Builder, Connection}; +use zbus::{interface, Connection}; use crate::desktop_entry::validate_desktop_entry; use crate::types::{DesktopEntry, EntryCatalog, IconEntry}; @@ -29,8 +29,8 @@ impl Daemon { async fn register_entry( &mut self, #[zbus(header)] hdr: Header<'_>, - #[zbus(signal_context)] ctxt: SignalContext<'_>, #[zbus(connection)] conn: &Connection, + #[zbus(signal_context)] ctxt: SignalContext<'_>, appid: String, entry: String, ) -> zbus::fdo::Result<()> { @@ -88,8 +88,8 @@ impl Daemon { async fn register_icon( &mut self, #[zbus(header)] hdr: Header<'_>, - #[zbus(signal_context)] ctxt: SignalContext<'_>, #[zbus(connection)] conn: &Connection, + #[zbus(signal_context)] ctxt: SignalContext<'_>, name: String, data: &[u8], ) -> zbus::fdo::Result<()> { @@ -230,8 +230,23 @@ impl Daemon { /// of desktop-entry-daemon refreshing the database whenever a new icon or entry is added or /// removed. along with this, if you'd like to watch changes, subscribe to `icon_changed` and /// `entry_changed` - async fn register_change_handler(&mut self, pid: u32) -> zbus::fdo::Result<()> { - self.catalog.lock().await.change_handlers.insert(pid); + async fn register_change_handler( + &mut self, + #[zbus(header)] hdr: Header<'_>, + #[zbus(connection)] conn: &Connection, + ) -> zbus::fdo::Result<()> { + let dbus_proxy = DBusProxy::builder(conn) + .cache_properties(CacheProperties::No) + .build() + .await + .unwrap(); + let pid = dbus_proxy + .get_connection_credentials(BusName::Unique(hdr.sender().unwrap().to_owned())) + .await + .unwrap() + .process_id() + .unwrap(); + log::debug!("PID of client: {:?}", pid); Ok(()) } }