Partial implementation of contact removal

Empathy needs you to cycle the connection before it notices.
This commit is contained in:
2020-05-24 00:24:15 +01:00
parent 370f5076a1
commit b9faad742b

View File

@@ -2,8 +2,9 @@ use crate::padfoot::VarArg;
use crate::telepathy;
use dbus::tree::MethodErr;
use deltachat::constants::DC_GCL_ADD_SELF;
use deltachat::contact::Contact;
use dc::constants::DC_GCL_ADD_SELF;
use dc::contact::Contact;
use deltachat as dc;
use std::collections::HashMap;
use std::convert::TryInto;
use telepathy::ConnectionInterfaceContacts; // for get_contact_attributes
@@ -63,6 +64,19 @@ impl telepathy::ConnectionInterfaceContactList for Connection {
}
fn remove_contacts(&self, contacts: Vec<u32>) -> Result<(), MethodErr> {
println!("Connection<{}>::remove_contacts({:?})", self.id(), contacts);
let ctx = self.ctx.read().unwrap();
for contact_id in contacts {
// FIXME: don't ignore errors
if let Err(e) = Contact::delete(&ctx, contact_id) {
println!(" Deleting contact {} failed: {}", contact_id, e);
}
}
// FIXME: signals MUST be emitted before this method returns
// FIXME: emitting signals at all would be great
Ok(())
}
fn unsubscribe(&self, contacts: Vec<u32>) -> Result<(), MethodErr> {