Files
telepathy-padfoot/src/padfoot/channel.rs
Nick Thomas b814a9aab0 Partially on the way to receiving an incoming message
This is getting really ugly, but let's run with it for now.
2020-05-17 03:01:21 +01:00

49 lines
1.3 KiB
Rust

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