Finish implementing the Contacts interface

This commit is contained in:
2020-05-16 20:54:05 +01:00
parent 9564a16aa2
commit 9473a13b65
3 changed files with 31 additions and 16 deletions

View File

@@ -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;
@@ -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> {