Finish implementing the Contacts interface
This commit is contained in:
@@ -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),
|
||||
);
|
||||
|
@@ -19,7 +19,7 @@ pub fn connection_interfaces() -> Vec<String> {
|
||||
"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(),
|
||||
]
|
||||
|
@@ -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<Vec<String>, 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(),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user