2020-05-16 23:05:14 +01:00
|
|
|
#[allow(clippy::module_inception)]
|
|
|
|
mod channel;
|
|
|
|
pub use channel::*;
|
|
|
|
|
|
|
|
mod messages;
|
|
|
|
pub use messages::*;
|
|
|
|
|
|
|
|
mod type_text;
|
|
|
|
pub use type_text::*;
|
|
|
|
|
|
|
|
use crate::telepathy;
|
|
|
|
|
|
|
|
// FIXME: I'm assuming that all channels will be of type text and 1-1 for now.
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Channel {
|
2020-05-17 00:49:46 +01:00
|
|
|
pub path: dbus::Path<'static>,
|
2020-05-16 23:05:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// "This SHOULD NOT include the channel type and channel interface itself"
|
|
|
|
pub fn channel_interfaces() -> Vec<String> {
|
2020-05-17 00:49:46 +01:00
|
|
|
vec!["org.freedesktop.Telepathy.Channel.Interface.Messages".to_string()]
|
2020-05-16 23:05:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Result<T> = std::result::Result<T, dbus::tree::MethodErr>;
|
|
|
|
|
|
|
|
impl Channel {
|
|
|
|
fn build_tree(self) -> dbus::tree::Tree<dbus::tree::MTFn, ()> {
|
|
|
|
let c_rc = std::rc::Rc::new(self);
|
|
|
|
let f = dbus::tree::Factory::new_fn::<()>();
|
|
|
|
let mut tree = f.tree(());
|
|
|
|
|
|
|
|
let c_rc1 = c_rc.clone();
|
|
|
|
let chan_iface = telepathy::channel_server(&f, (), move |_| c_rc1.clone());
|
|
|
|
|
|
|
|
let c_rc2 = c_rc.clone();
|
|
|
|
let messages_iface =
|
|
|
|
telepathy::channel_interface_messages_server(&f, (), move |_| c_rc2.clone());
|
|
|
|
|
2020-05-17 00:49:46 +01:00
|
|
|
let type_text_iface = telepathy::channel_type_text_server(&f, (), move |_| c_rc.clone());
|
2020-05-16 23:05:14 +01:00
|
|
|
|
|
|
|
tree = tree.add(
|
|
|
|
f.object_path("", ())
|
|
|
|
.introspectable()
|
|
|
|
.add(chan_iface)
|
|
|
|
.add(messages_iface)
|
|
|
|
.add(type_text_iface),
|
|
|
|
);
|
|
|
|
tree = tree.add(f.object_path("/", ()).introspectable());
|
|
|
|
|
|
|
|
tree
|
|
|
|
}
|
|
|
|
}
|