Files
telepathy-padfoot/src/padfoot/connection/requests.rs
Nick Thomas 169249b716 Don't build a new connection if it already exists
There was also a lot of unneeded overhead in Connection::new() to get
the path to compare against, so split that out into a settings struct
2020-05-16 18:44:02 +01:00

50 lines
1.6 KiB
Rust

use crate::telepathy;
use dbus::arg::{RefArg, Variant};
use dbus::tree::MethodErr;
use std::collections::HashMap;
use super::Connection;
// TODO: extract a utility module for this?
type VarArg = Variant<Box<dyn RefArg + 'static>>;
impl AsRef<dyn telepathy::ConnectionInterfaceRequests + 'static> for std::rc::Rc<Connection> {
fn as_ref(&self) -> &(dyn telepathy::ConnectionInterfaceRequests + 'static) {
&**self
}
}
type ChannelSpec = (dbus::Path<'static>, HashMap<String, VarArg>);
type RequestableChannelSpec = (HashMap<String, VarArg>, Vec<String>);
impl telepathy::ConnectionInterfaceRequests for Connection {
fn create_channel(
&self,
request: HashMap<&str, VarArg>,
) -> Result<(dbus::Path<'static>, HashMap<String, VarArg>), MethodErr> {
println!("Connection<{}>::create_channel({:?})", self.id(), request);
Err(MethodErr::no_arg()) // FIXME: should be NotImplemented?
}
fn ensure_channel(
&self,
request: HashMap<&str, VarArg>,
) -> Result<(bool, dbus::Path<'static>, HashMap<String, VarArg>), MethodErr> {
println!("Connection<{}>::ensure_channel({:?})", self.id(), request);
Err(MethodErr::no_arg()) // FIXME: should be NotImplemented?
}
fn channels(&self) -> Result<Vec<ChannelSpec>, MethodErr> {
println!("Connection<{}>::channels()", self.id());
Ok(vec![])
}
fn requestable_channel_classes(&self) -> Result<Vec<RequestableChannelSpec>, MethodErr> {
println!("Connection<{}>::requestable_channel_classes()", self.id());
Ok(crate::padfoot::requestables())
}
}