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.
This commit is contained in:
Elias Schriefer 2020-09-13 14:48:35 +02:00
parent 5aaf57c9bb
commit a4bf221c92
2 changed files with 0 additions and 13 deletions

View File

@ -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"

View File

@ -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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
// 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
}));