Flesh out channels some more. They can now be closed.
As part of this, move Connection's queue to mpsc and have all channels for a connection share that connection's main loop.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::padfoot::DbusAction;
|
||||
use crate::telepathy;
|
||||
|
||||
use dbus::tree::MethodErr;
|
||||
@@ -13,27 +14,37 @@ impl AsRef<dyn telepathy::Channel + 'static> for std::sync::Arc<Channel> {
|
||||
impl telepathy::Channel for Channel {
|
||||
fn close(&self) -> Result<()> {
|
||||
println!("Channel::close()");
|
||||
|
||||
self.actq
|
||||
.send(DbusAction::CloseChannel(self.path()))
|
||||
.unwrap();
|
||||
|
||||
Err(MethodErr::no_arg())
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
fn get_channel_type(&self) -> Result<String> {
|
||||
self.channel_type()
|
||||
}
|
||||
|
||||
fn get_handle(&self) -> Result<(u32, u32)> {
|
||||
println!("Channel::get_handle()");
|
||||
Err(MethodErr::no_arg())
|
||||
}
|
||||
|
||||
fn get_interfaces(&self) -> Result<Vec<String>> {
|
||||
println!("Channel::get_interfaces()");
|
||||
Err(MethodErr::no_arg())
|
||||
}
|
||||
|
||||
fn channel_type(&self) -> Result<String> {
|
||||
println!("Channel::channel_type()");
|
||||
|
||||
Ok("org.freedesktop.Telepathy.Channel.Text".to_string())
|
||||
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>> {
|
||||
@@ -43,31 +54,45 @@ impl telepathy::Channel for Channel {
|
||||
|
||||
fn target_handle(&self) -> Result<u32> {
|
||||
println!("Channel::target_handle()");
|
||||
Err(MethodErr::no_arg())
|
||||
|
||||
Ok(self.handle())
|
||||
}
|
||||
|
||||
fn target_id(&self) -> Result<String> {
|
||||
println!("Channel::target_id()");
|
||||
Err(MethodErr::no_arg())
|
||||
|
||||
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()");
|
||||
Err(MethodErr::no_arg())
|
||||
|
||||
Ok(self.handle_type())
|
||||
}
|
||||
|
||||
fn requested(&self) -> Result<bool> {
|
||||
println!("Channel::requested()");
|
||||
Err(MethodErr::no_arg())
|
||||
|
||||
Ok(false) // FIXME: channels initiated by ourselves *will* be requested
|
||||
}
|
||||
|
||||
fn initiator_handle(&self) -> Result<u32> {
|
||||
println!("Channel::initiator_handle()");
|
||||
Err(MethodErr::no_arg())
|
||||
|
||||
self.target_handle() // FIXME: Not the case for channels initiated by ourselves
|
||||
}
|
||||
|
||||
fn initiator_id(&self) -> Result<String> {
|
||||
println!("Channel::initiator_id()");
|
||||
Err(MethodErr::no_arg())
|
||||
|
||||
if let Some(contact) = self.initiator_contact() {
|
||||
Ok(contact.get_addr().to_string())
|
||||
} else {
|
||||
Err(MethodErr::no_arg())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user