We now emit appropriate signals and return a non-error status code when a channel is closed.
99 lines
2.3 KiB
Rust
99 lines
2.3 KiB
Rust
use crate::padfoot::DbusAction;
|
|
use crate::telepathy;
|
|
|
|
use dbus::tree::MethodErr;
|
|
|
|
use super::{Channel, Result};
|
|
|
|
impl AsRef<dyn telepathy::Channel + 'static> for std::sync::Arc<Channel> {
|
|
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<String> {
|
|
self.channel_type()
|
|
}
|
|
|
|
fn channel_type(&self) -> Result<String> {
|
|
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<Vec<String>> {
|
|
println!("Channel::get_interfaces()");
|
|
|
|
self.interfaces()
|
|
}
|
|
|
|
fn interfaces(&self) -> Result<Vec<String>> {
|
|
println!("Channel::interfaces()");
|
|
Ok(super::channel_interfaces())
|
|
}
|
|
|
|
fn target_handle(&self) -> Result<u32> {
|
|
println!("Channel::target_handle()");
|
|
|
|
Ok(self.handle())
|
|
}
|
|
|
|
fn target_id(&self) -> Result<String> {
|
|
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<u32> {
|
|
println!("Channel::target_handle_type()");
|
|
|
|
Ok(self.handle_type())
|
|
}
|
|
|
|
fn requested(&self) -> Result<bool> {
|
|
println!("Channel::requested()");
|
|
|
|
Ok(false) // FIXME: channels initiated by ourselves *will* be requested
|
|
}
|
|
|
|
fn initiator_handle(&self) -> Result<u32> {
|
|
println!("Channel::initiator_handle()");
|
|
|
|
self.target_handle() // FIXME: Not the case for channels initiated by ourselves
|
|
}
|
|
|
|
fn initiator_id(&self) -> Result<String> {
|
|
println!("Channel::initiator_id()");
|
|
|
|
if let Some(contact) = self.initiator_contact() {
|
|
Ok(contact.get_addr().to_string())
|
|
} else {
|
|
Err(MethodErr::no_arg())
|
|
}
|
|
}
|
|
}
|