From a4bf221c928fdc7667670b1e76095ce3427ae27c Mon Sep 17 00:00:00 2001 From: EliasSchriefer Date: Sun, 13 Sep 2020 14:48:35 +0200 Subject: [PATCH] Remove `dbus-crossroads` and code using it That library didn't do it for me. Adding async methods was a pain in the a** with lifetime and type bounds confusing the heck out of me. So I tried it with `dbus::tree` (in the next commits). It still was a bit of work to get it working, but at least it **is** working. --- sfsmcd/Cargo.toml | 1 - sfsmcd/src/main.rs | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/sfsmcd/Cargo.toml b/sfsmcd/Cargo.toml index 3cf6c86..4770f0b 100644 --- a/sfsmcd/Cargo.toml +++ b/sfsmcd/Cargo.toml @@ -12,6 +12,5 @@ tokio = { version = "0.2", features = ["full"] } async-minecraft-ping = "0.2" dbus = { version = "0.8", features = ["futures"] } dbus-tokio = "0.5" -dbus-crossroads = "0.2" log = "0.4" env_logger = "0.7" \ No newline at end of file diff --git a/sfsmcd/src/main.rs b/sfsmcd/src/main.rs index 744e1f6..1f73c6c 100644 --- a/sfsmcd/src/main.rs +++ b/sfsmcd/src/main.rs @@ -1,5 +1,4 @@ use log::{ debug, info, warn, error }; -use dbus_crossroads::Crossroads; use dbus::{ message::MatchRule, channel::MatchingReceiver @@ -18,12 +17,6 @@ async fn main() -> Result<(), Box> { debug!("PID: {}, User: {}", std::process::id(), std::env::var("USER").unwrap_or("N/A".into())); - // New Crossroads instance - let mut cr = Crossroads::new(); - - // Insert object paths - cr.insert("/", &[], ()); - // Connect with D-Bus let (resource, c) = dbus_tokio::connection::new_system_sync()?; debug!("D-Bus unique name: {}", c.unique_name()); @@ -34,9 +27,6 @@ async fn main() -> Result<(), Box> { panic!("Lost connection to D-Bus: {}", err); }); - // Allow methods to be async - cr.set_async_support(Some((c.clone(), Box::new(|x| { tokio::spawn(x); })))); - // Aquire name on D-Bus match c.request_name(DBUS_NAME, false, true, false).await { Ok(_) => info!("Listening (D-Bus) on {}", DBUS_NAME), @@ -48,8 +38,6 @@ async fn main() -> Result<(), Box> { // Receive method calls c.start_receive(MatchRule::new_method_call(), Box::new(move |msg, conn| { - cr.handle_message(msg, conn).unwrap_or_else(|_| warn!("Incoming message wasn't a method call")); - // Return bool whether message should be handled only once (false) or another time (true) true }));