From c1103e4a29d0f8ec59cefcfff2ff44dbce151262 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Thu, 23 Oct 2003 12:52:46 +0000 Subject: make it work with the new ebook api 003-10-21 JP Rosevear * conduit/address-conduit.c: make it work with the new ebook api * backend/pas/pas-book.c (pas_book_respond_get_changes): put the vcard in for every change * backend/pas/pas-backend.c (pas_backend_change_add_new): just use the vcard field (pas_backend_change_modify_new): ditto (pas_backend_change_delete_new): ditto * backend/pas/pas-backend-file.c (pas_backend_file_changes_foreach_key): create a fake contact with the uid (pas_backend_file_get_changes): add the card to the changes * backend/ebook/tests/ebook/test-changes.c (main): just print the uid * backend/ebook/e-book.c (e_book_free_change_list): unref the contact * backend/ebook/e-book-types.h: the change struct contains an EContact now * backend/ebook/e-book-listener.c (impl_BookListener_respond_get_changes): create the contact from the vcard string * backend/idl/addressbook.idl: Book change item is no longer a union, it always gives back a card svn path=/trunk/; revision=23031 --- addressbook/backend/pas/pas-backend-file.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'addressbook/backend/pas/pas-backend-file.c') diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index 923c7e907d..73f1797320 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -515,6 +515,7 @@ typedef struct { GList *mod_cards; GList *mod_ids; GList *del_ids; + GList *del_cards; } PASBackendFileChangeContext; static void @@ -530,10 +531,21 @@ pas_backend_file_changes_foreach_key (const char *key, gpointer user_data) db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0); if (db_error != 0) { + EContact *contact; char *id = id_dbt.data; + char *vcard_string; + + contact = e_contact_new (); + e_contact_set (contact, E_CONTACT_UID, id); + + vcard_string = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); ctx->del_ids = g_list_append (ctx->del_ids, g_strdup (id)); + ctx->del_cards = g_list_append (ctx->del_cards, + vcard_string); + + g_object_unref (contact); } } @@ -645,14 +657,17 @@ pas_backend_file_get_changes (PASBackendSync *backend, g_free (i->data); g_free (v->data); - } - for (i = ctx.del_ids; i != NULL; i = i->next){ + } + for (i = ctx.del_ids, v = ctx.del_cards; i != NULL; i = i->next, v = v->next){ char *id = i->data; - + char *vcard = v->data; + e_dbhash_remove (ehash, id); + changes = g_list_prepend (changes, - pas_backend_change_delete_new (id)); + pas_backend_change_delete_new (vcard)); g_free (i->data); + g_free (v->data); } e_dbhash_write (ehash); -- cgit v1.2.3