Skip to content

Commit

Permalink
0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanabx committed Apr 19, 2024
1 parent d675fb7 commit 1b27b13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
4 changes: 1 addition & 3 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
-->
<method name="RegisterChangeHandler">
<arg name="pid" type="u" direction="in"/>
</method>
<method name="RegisterChangeHandler"></method>
```
4 changes: 1 addition & 3 deletions docs/net.ryanabx.DesktopEntry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@
removed. along with this, if you'd like to watch changes, subscribe to `icon_changed` and
`entry_changed`
-->
<method name="RegisterChangeHandler">
<arg name="pid" type="u" direction="in"/>
</method>
<method name="RegisterChangeHandler"></method>
</interface>
</node>

25 changes: 20 additions & 5 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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<()> {
Expand Down Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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(())
}
}
Expand Down

0 comments on commit 1b27b13

Please sign in to comment.