Return protocol parameters
This commit is contained in:
14
src/main.rs
14
src/main.rs
@@ -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 {
|
||||
|
Reference in New Issue
Block a user