use crate::padfoot::DbusAction; use crate::telepathy; use dbus::tree::MethodErr; use super::{Channel, Result}; impl AsRef for std::sync::Arc { fn as_ref(&self) -> &(dyn telepathy::Channel + 'static) { &**self } } impl telepathy::Channel for Channel { fn close(&self) -> Result<()> { println!("Channel::close()"); self.actq .send(DbusAction::CloseChannel(self.path())) .unwrap(); Ok(()) } // Deprecated fn get_channel_type(&self) -> Result { self.channel_type() } fn channel_type(&self) -> Result { println!("Channel::channel_type()"); Ok(self.chan_type()) } // Deprecated fn get_handle(&self) -> Result<(u32, u32)> { println!("Channel::get_handle()"); Ok((self.handle_type(), self.handle())) } // Deprecated fn get_interfaces(&self) -> Result> { println!("Channel::get_interfaces()"); self.interfaces() } fn interfaces(&self) -> Result> { println!("Channel::interfaces()"); Ok(super::channel_interfaces()) } fn target_handle(&self) -> Result { println!("Channel::target_handle()"); Ok(self.handle()) } fn target_id(&self) -> Result { println!("Channel::target_id()"); if let Some(contact) = self.target_contact() { Ok(contact.get_addr().to_string()) } else { Err(MethodErr::no_arg()) } } fn target_handle_type(&self) -> Result { println!("Channel::target_handle_type()"); Ok(self.handle_type()) } fn requested(&self) -> Result { println!("Channel::requested()"); Ok(false) // FIXME: channels initiated by ourselves *will* be requested } fn initiator_handle(&self) -> Result { println!("Channel::initiator_handle()"); self.target_handle() // FIXME: Not the case for channels initiated by ourselves } fn initiator_id(&self) -> Result { println!("Channel::initiator_id()"); if let Some(contact) = self.initiator_contact() { Ok(contact.get_addr().to_string()) } else { Err(MethodErr::no_arg()) } } }