By hook or by crook, amke empathy open a window
This commit is contained in:
@@ -15,11 +15,12 @@ AuthenticationTypes=org.freedesktop.Telepathy.Channel.Type.ServerTLSConnection;
|
||||
ConnectionInterfaces=org.freedesktop.Telepathy.Connection.Interface.Avatars;org.freedesktop.Telepathy.Connection.Interface.Contacts;org.freedesktop.Telepathy.Connection.Interface.Requests;org.freedesktop.Telepathy.Connection.Interface.SimplePresence;
|
||||
EnglishName=Delta Chat
|
||||
Icon=im-delta
|
||||
Interfaces=
|
||||
Interfaces=org.freedesktop.Telepathy.Protocol;org.freedesktop.Telepathy.Protocol.Interface.Presence;
|
||||
RequestableChannelClasses=text;
|
||||
VCardField=email
|
||||
|
||||
[text]
|
||||
Interfaces=org.freedesktop.Telepathy.Channel.Interface.Messages;
|
||||
org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text
|
||||
org.freedesktop.Telepathy.Channel.TargetHandleType u=1
|
||||
allowed=org.freedesktop.Telepathy.Channel.TargetHandle;org.freedesktop.Telepathy.Channel.TargetID;
|
||||
allowed=org.freedesktop.Telepathy.Channel.TargetHandle;org.freedesktop.Telepathy.Channel.TargetID;org.freedesktop.Telepathy.Channel.Interface.Messages;
|
||||
|
@@ -32,6 +32,7 @@ pub const HANDLE_TYPE_GROUP: HandleType = 4; // Deprecated
|
||||
#[derive(Debug)]
|
||||
pub struct Channel {
|
||||
actq: mpsc::Sender<DbusAction>,
|
||||
chat_id: dc::chat::ChatId,
|
||||
ctx: Arc<RwLock<dc::context::Context>>,
|
||||
path: dbus::Path<'static>,
|
||||
requested: bool,
|
||||
@@ -46,6 +47,7 @@ pub fn channel_interfaces() -> Vec<String> {
|
||||
impl Channel {
|
||||
pub fn new(
|
||||
actq: mpsc::Sender<DbusAction>,
|
||||
chat_id: dc::chat::ChatId,
|
||||
ctx: Arc<RwLock<dc::context::Context>>,
|
||||
path: dbus::Path<'static>,
|
||||
requested: bool,
|
||||
@@ -53,6 +55,7 @@ impl Channel {
|
||||
) -> Self {
|
||||
Channel {
|
||||
actq,
|
||||
chat_id,
|
||||
ctx,
|
||||
path,
|
||||
requested,
|
||||
@@ -76,18 +79,22 @@ impl Channel {
|
||||
self.target_handle
|
||||
}
|
||||
|
||||
fn target_contact(&self) -> Option<dc::contact::Contact> {
|
||||
pub fn target_contact(&self) -> Option<dc::contact::Contact> {
|
||||
let ctx = self.ctx.read().unwrap();
|
||||
|
||||
dc::contact::Contact::get_by_id(&ctx, self.handle()).ok()
|
||||
}
|
||||
|
||||
fn initiator_contact(&self) -> Option<dc::contact::Contact> {
|
||||
pub fn initiator_contact(&self) -> Option<dc::contact::Contact> {
|
||||
let ctx = self.ctx.read().unwrap();
|
||||
|
||||
dc::contact::Contact::get_by_id(&ctx, self.handle()).ok() // FIXME: this will be wrong for outbound channels
|
||||
}
|
||||
|
||||
pub fn requested(&self) -> bool {
|
||||
self.requested
|
||||
}
|
||||
|
||||
pub fn build_object_path(
|
||||
channel: Arc<Channel>,
|
||||
) -> dbus::tree::ObjectPath<dbus::tree::MTFn, ()> {
|
||||
|
@@ -77,7 +77,7 @@ impl telepathy::Channel for Channel {
|
||||
fn requested(&self) -> Result<bool> {
|
||||
println!("Channel::requested()");
|
||||
|
||||
Ok(true) // FIXME: channels initiated by ourselves *will* be requested
|
||||
Ok(self.requested) // FIXME: channels initiated by ourselves *will* be requested
|
||||
}
|
||||
|
||||
fn initiator_handle(&self) -> Result<u32> {
|
||||
|
@@ -49,9 +49,20 @@ impl telepathy::ChannelInterfaceMessages for Channel {
|
||||
}
|
||||
|
||||
fn pending_messages(&self) -> Result<Vec<Vec<HashMap<String, VarArg>>>> {
|
||||
println!("Channel::pending_messages()");
|
||||
let out = Vec::new();
|
||||
/*
|
||||
let ctx = self.ctx.read().unwrap();
|
||||
for msg_id in dc::chat::get_chat_msgs(&ctx, self.chat_id, 0, None) {
|
||||
if let Ok(msg) = dc::msg::Message::load_from_db(&ctx, msg_id) {
|
||||
let lot = msg.get_summary(&ctx, None);
|
||||
|
||||
Ok(vec![]) // FIXME: check for pending messages
|
||||
if lot
|
||||
}
|
||||
}
|
||||
|
||||
println!("Channel::pending_messages()");
|
||||
*/
|
||||
Ok(out) // FIXME: check for pending messages
|
||||
}
|
||||
|
||||
fn delivery_reporting_support(&self) -> Result<u32> {
|
||||
|
@@ -20,7 +20,7 @@ pub use self::requests::*;
|
||||
mod simple_presence;
|
||||
pub use self::simple_presence::*;
|
||||
|
||||
use crate::padfoot::{Channel, VarArg};
|
||||
use crate::padfoot::{var_bool, var_str, var_str_vec, var_u32, Channel, VarArg};
|
||||
use crate::telepathy;
|
||||
|
||||
use dbus::blocking::{stdintf::org_freedesktop_dbus::RequestNameReply, LocalConnection};
|
||||
@@ -309,7 +309,7 @@ impl Connection {
|
||||
while let Some(act) = queue_receiver.try_recv().ok() {
|
||||
match act {
|
||||
DbusAction::Signal(msg) => {
|
||||
print!("*** Connection<{}>: Sending message...", id);
|
||||
print!("*** Connection<{}>: Sending signal: {:?}...", id, msg);
|
||||
|
||||
match c.send(msg) {
|
||||
Err(e) => println!("error! {:?}", e), // FIXME: handle error better?
|
||||
@@ -317,9 +317,11 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
DbusAction::NewChannel(channel) => {
|
||||
let requested = channel.requested();
|
||||
let chan_type = channel.chan_type();
|
||||
let handle_type = channel.handle_type();
|
||||
let handle = channel.handle();
|
||||
let target_id = channel.target_contact().unwrap().get_addr().to_string();
|
||||
let chan_path = channel.path().clone();
|
||||
let rc_channel = Arc::new(channel);
|
||||
|
||||
@@ -335,8 +337,36 @@ impl Connection {
|
||||
|
||||
t2.lock().unwrap().insert(op);
|
||||
|
||||
let mut chan_props = HashMap::<String, VarArg>::new();
|
||||
chan_props.insert(
|
||||
"org.freedesktop.Telepathy.Channel.ChannelType".to_string(),
|
||||
var_str(chan_type.clone()),
|
||||
);
|
||||
chan_props.insert(
|
||||
"org.freedesktop.Telepathy.Channel.TargetHandleType".to_string(),
|
||||
var_u32(handle_type),
|
||||
);
|
||||
chan_props.insert(
|
||||
"org.freedesktop.Telepathy.Channel.TargetHandle".to_string(),
|
||||
var_u32(handle),
|
||||
);
|
||||
chan_props.insert(
|
||||
"org.freedesktop.Telepathy.Channel.TargetID".to_string(),
|
||||
var_str(target_id),
|
||||
);
|
||||
chan_props.insert(
|
||||
"org.freedesktop.Telepathy.Channel.Requested".to_string(),
|
||||
var_bool(requested),
|
||||
);
|
||||
chan_props.insert(
|
||||
"org.freedesktop.Telepathy.Channel.Interfaces".to_string(),
|
||||
var_str_vec(vec![
|
||||
"org.freedesktop.Telepathy.Channel.Interface.Messages".to_string(),
|
||||
]),
|
||||
);
|
||||
|
||||
let requests_sig = telepathy::ConnectionInterfaceRequestsNewChannels {
|
||||
channels: vec![(chan_path.clone(), HashMap::new())],
|
||||
channels: vec![(chan_path.clone(), chan_props)],
|
||||
};
|
||||
|
||||
let legacy_sig = telepathy::ConnectionNewChannel {
|
||||
@@ -405,6 +435,7 @@ impl Connection {
|
||||
let handle = contacts.first().unwrap();
|
||||
let chan = Channel::new(
|
||||
actq.clone(),
|
||||
chat_id,
|
||||
ctx.clone(),
|
||||
chan_path,
|
||||
false, // FIXME: this needs to handle requested channels
|
||||
|
@@ -14,6 +14,10 @@ pub fn var_str_vec(item: Vec<String>) -> VarArg {
|
||||
var_arg(Box::new(item))
|
||||
}
|
||||
|
||||
pub fn var_bool(item: bool) -> VarArg {
|
||||
var_arg(Box::new(item))
|
||||
}
|
||||
|
||||
pub fn var_u32(item: u32) -> VarArg {
|
||||
var_arg(Box::new(item))
|
||||
}
|
||||
|
Reference in New Issue
Block a user