diff --git a/src/padfoot/connection.rs b/src/padfoot/connection.rs index 195b5ed..c1a7434 100644 --- a/src/padfoot/connection.rs +++ b/src/padfoot/connection.rs @@ -303,7 +303,7 @@ impl Connection { .add(conn_iface) .add(avatars_iface) .add(contacts_iface) -// .add(contact_list_iface) + // .add(contact_list_iface) .add(requests_iface) .add(simple_presence_iface), ); diff --git a/src/padfoot/connection/connection.rs b/src/padfoot/connection/connection.rs index 5b96268..416d66b 100644 --- a/src/padfoot/connection/connection.rs +++ b/src/padfoot/connection/connection.rs @@ -19,7 +19,7 @@ pub fn connection_interfaces() -> Vec { "org.freedesktop.Telepathy.Connection".to_string(), "org.freedesktop.Telepathy.Connection.Interface.Avatars".to_string(), "org.freedesktop.Telepathy.Connection.Interface.Contacts".to_string(), -// "org.freedesktop.Telepathy.Connection.Interface.ContactList".to_string(), + // "org.freedesktop.Telepathy.Connection.Interface.ContactList".to_string(), "org.freedesktop.Telepathy.Connection.Interface.Requests".to_string(), "org.freedesktop.Telepathy.Connection.Interface.SimplePresence".to_string(), ] diff --git a/src/padfoot/connection/contacts.rs b/src/padfoot/connection/contacts.rs index 15fb973..881614c 100644 --- a/src/padfoot/connection/contacts.rs +++ b/src/padfoot/connection/contacts.rs @@ -2,7 +2,7 @@ use crate::telepathy; use dbus::arg::{RefArg, Variant}; use dbus::tree::MethodErr; -use deltachat::contact::Contact; +use deltachat::contact::{Contact, Origin}; use std::collections::HashMap; use super::Connection; @@ -51,18 +51,18 @@ impl telepathy::ConnectionInterfaceContacts for Connection { "org.freedesktop.Telepathy.Connection.Interface.Avatars/token".to_string(), Variant(Box::new("".to_string())), ); -/* - // TODO: we need to publish DBUS services on these endpoints - props.insert( - "org.freedesktop.Telepathy.Connection.Interface.ContactList/publish".to_string(), - Variant(Box::new(4)), - ); + /* + // TODO: we need to publish DBUS services on these endpoints + props.insert( + "org.freedesktop.Telepathy.Connection.Interface.ContactList/publish".to_string(), + Variant(Box::new(4)), + ); - props.insert( - "org.freedesktop.Telepathy.Connection.Interface.ContactList/subscribe".to_string(), - Variant(Box::new(4)), - ); -*/ + props.insert( + "org.freedesktop.Telepathy.Connection.Interface.ContactList/subscribe".to_string(), + Variant(Box::new(4)), + ); + */ out.insert(*id, props); } @@ -80,7 +80,22 @@ impl telepathy::ConnectionInterfaceContacts for Connection { identifier, interfaces ); - Err(MethodErr::no_arg()) // FIXME: should be NotImplemented? + + let id = { + let ctx = &self.ctx.read().unwrap(); + Contact::lookup_id_by_addr(ctx, identifier, Origin::Unknown) + }; + + if id == 0 { + return Err(MethodErr::no_arg()); // FIXME: should be InvalidHandle + }; + + let mut contacts = self.get_contact_attributes(vec![id], interfaces, true)?; + if let Some(contact) = contacts.remove(&id) { + Ok((id, contact)) + } else { + Err(MethodErr::no_arg()) // FIXME: should be InvalidHandle + } } fn contact_attribute_interfaces(&self) -> Result, MethodErr> { @@ -89,7 +104,7 @@ impl telepathy::ConnectionInterfaceContacts for Connection { Ok(vec![ "org.freedesktop.Telepathy.Connection".to_string(), "org.freedesktop.Telepathy.Connection.Interface.Avatars".to_string(), -// "org.freedesktop.Telepathy.Connection.Interface.ContactList".to_string(), + // "org.freedesktop.Telepathy.Connection.Interface.ContactList".to_string(), ]) } }