Return protocol parameters

This commit is contained in:
2020-05-09 11:19:40 +01:00
parent 5328ae9bd6
commit 40ea57a0cc
5 changed files with 62 additions and 30 deletions

View File

@@ -4,7 +4,7 @@ mod telepathy;
//use dbus::tree::{Interface, MTFn, MethodErr};
use dbus::{
blocking::{stdintf::org_freedesktop_dbus::RequestNameReply, LocalConnection},
tree::{Factory, Interface, MTFn, Tree},
tree::{Factory, MTFn, Tree},
};
use padfoot::{CMData, ConnectionManager};
@@ -14,8 +14,8 @@ use std::time::Duration;
use anyhow::{anyhow, Result};
const BUS_NAME: &'static str = "org.freedesktop.Telepathy.ConnectionManager.padfoot";
const OBJECT_PATH: &'static str = "/org/freedesktop/Telepathy/ConnectionManager/padfoot";
const CM_BUS_NAME: &'static str = "org.freedesktop.Telepathy.ConnectionManager.padfoot";
const CM_OBJECT_PATH: &'static str = "/org/freedesktop/Telepathy/ConnectionManager/padfoot";
fn create_tree(cm: &Arc<ConnectionManager>) -> Tree<MTFn<CMData>, CMData> {
let f = Factory::new_fn();
@@ -29,7 +29,7 @@ fn create_tree(cm: &Arc<ConnectionManager>) -> Tree<MTFn<CMData>, CMData> {
});
tree = tree.add(
f.object_path(OBJECT_PATH, cm.clone())
f.object_path(CM_OBJECT_PATH, cm.clone())
.introspectable()
.add(iface),
);
@@ -45,18 +45,18 @@ fn run() -> Result<()> {
// Setup DBus connection
let mut c = LocalConnection::new_session()?;
let result = c.request_name(BUS_NAME, false, false, true)?;
let result = c.request_name(CM_BUS_NAME, false, false, true)?;
match result {
RequestNameReply::Exists => {
return Err(anyhow!(
"Another process is already registered on {}",
BUS_NAME
CM_BUS_NAME
))
}
_ => {} // All other responses we can get are a success
};
println!("Bus registered: {}", BUS_NAME);
println!("Bus registered: {}", CM_BUS_NAME);
tree.start_receive(&c);
loop {