Reorder Channel::new args

This commit is contained in:
2020-05-17 22:37:25 +01:00
parent 576fec63cd
commit e5e06c55f9
3 changed files with 14 additions and 5 deletions

View File

@@ -31,9 +31,10 @@ pub const HANDLE_TYPE_GROUP: HandleType = 4; // Deprecated
// FIXME: I'm assuming that all channels will be of type text and 1-1 for now. // FIXME: I'm assuming that all channels will be of type text and 1-1 for now.
#[derive(Debug)] #[derive(Debug)]
pub struct Channel { pub struct Channel {
ctx: Arc<RwLock<dc::context::Context>>,
actq: mpsc::Sender<DbusAction>, actq: mpsc::Sender<DbusAction>,
ctx: Arc<RwLock<dc::context::Context>>,
path: dbus::Path<'static>, path: dbus::Path<'static>,
requested: bool,
target_handle: u32, // Who we're talking to target_handle: u32, // Who we're talking to
} }
@@ -44,16 +45,18 @@ pub fn channel_interfaces() -> Vec<String> {
impl Channel { impl Channel {
pub fn new( pub fn new(
actq: mpsc::Sender<DbusAction>,
ctx: Arc<RwLock<dc::context::Context>>, ctx: Arc<RwLock<dc::context::Context>>,
path: dbus::Path<'static>, path: dbus::Path<'static>,
requested: bool,
target_handle: u32, target_handle: u32,
actq: mpsc::Sender<DbusAction>,
) -> Self { ) -> Self {
Channel { Channel {
actq,
ctx, ctx,
path, path,
requested,
target_handle, target_handle,
actq,
} }
} }

View File

@@ -77,7 +77,7 @@ impl telepathy::Channel for Channel {
fn requested(&self) -> Result<bool> { fn requested(&self) -> Result<bool> {
println!("Channel::requested()"); println!("Channel::requested()");
Ok(false) // FIXME: channels initiated by ourselves *will* be requested Ok(true) // FIXME: channels initiated by ourselves *will* be requested
} }
fn initiator_handle(&self) -> Result<u32> { fn initiator_handle(&self) -> Result<u32> {

View File

@@ -403,7 +403,13 @@ impl Connection {
} }
let handle = contacts.first().unwrap(); let handle = contacts.first().unwrap();
let chan = Channel::new(ctx.clone(), chan_path, *handle, actq.clone()); let chan = Channel::new(
actq.clone(),
ctx.clone(),
chan_path,
false, // FIXME: this needs to handle requested channels
*handle,
);
actq.send(DbusAction::NewChannel(chan)).unwrap(); actq.send(DbusAction::NewChannel(chan)).unwrap();
actq.send(act).unwrap(); actq.send(act).unwrap();