make it work with the new ebook api
003-10-21 JP Rosevear <jpr@ximian.com> * 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
This commit is contained in:
@ -34,6 +34,39 @@
|
|||||||
"evolution:button_label" property on the component for use in the
|
"evolution:button_label" property on the component for use in the
|
||||||
shell.
|
shell.
|
||||||
|
|
||||||
|
2003-10-21 JP Rosevear <jpr@ximian.com>
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
2003-10-21 Chris Toshok <toshok@ximian.com>
|
2003-10-21 Chris Toshok <toshok@ximian.com>
|
||||||
|
|
||||||
* tools/evolution-addressbook-abuse.c: use the synchronous api for
|
* tools/evolution-addressbook-abuse.c: use the synchronous api for
|
||||||
|
@ -187,20 +187,18 @@ impl_BookListener_respond_get_changes (PortableServer_Servant servant,
|
|||||||
EBookChange *change = g_new (EBookChange, 1);
|
EBookChange *change = g_new (EBookChange, 1);
|
||||||
GNOME_Evolution_Addressbook_BookChangeItem corba_change = changes->_buffer[i];
|
GNOME_Evolution_Addressbook_BookChangeItem corba_change = changes->_buffer[i];
|
||||||
|
|
||||||
switch (corba_change._d) {
|
switch (corba_change.changeType) {
|
||||||
case GNOME_Evolution_Addressbook_ContactAdded:
|
case GNOME_Evolution_Addressbook_ContactAdded:
|
||||||
change->change_type = E_BOOK_CHANGE_CARD_ADDED;
|
change->change_type = E_BOOK_CHANGE_CARD_ADDED;
|
||||||
change->vcard = g_strdup (corba_change._u.add_vcard);
|
|
||||||
break;
|
break;
|
||||||
case GNOME_Evolution_Addressbook_ContactDeleted:
|
case GNOME_Evolution_Addressbook_ContactDeleted:
|
||||||
change->change_type = E_BOOK_CHANGE_CARD_DELETED;
|
change->change_type = E_BOOK_CHANGE_CARD_DELETED;
|
||||||
change->id = g_strdup (corba_change._u.del_id);
|
|
||||||
break;
|
break;
|
||||||
case GNOME_Evolution_Addressbook_ContactModified:
|
case GNOME_Evolution_Addressbook_ContactModified:
|
||||||
change->change_type = E_BOOK_CHANGE_CARD_MODIFIED;
|
change->change_type = E_BOOK_CHANGE_CARD_MODIFIED;
|
||||||
change->vcard = g_strdup (corba_change._u.mod_vcard);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
change->contact = e_contact_new_from_vcard (corba_change.vcard);
|
||||||
|
|
||||||
response.list = g_list_prepend (response.list, change);
|
response.list = g_list_prepend (response.list, change);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define __E_BOOK_TYPES_H__
|
#define __E_BOOK_TYPES_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <ebook/e-contact.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -59,8 +60,7 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
EBookChangeType change_type;
|
EBookChangeType change_type;
|
||||||
char *vcard; /* used in the ADDED/MODIFIED case */
|
EContact *contact;
|
||||||
char *id; /* used in the DELETED case */
|
|
||||||
} EBookChange;
|
} EBookChange;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -1244,7 +1244,7 @@ e_book_free_change_list (GList *change_list)
|
|||||||
for (l = change_list; l; l = l->next) {
|
for (l = change_list; l; l = l->next) {
|
||||||
EBookChange *change = l->data;
|
EBookChange *change = l->data;
|
||||||
|
|
||||||
g_free (change->vcard);
|
g_object_unref (change->contact);
|
||||||
g_free (change);
|
g_free (change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ main (int argc, char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("got changed vcard back: %s\n", change->vcard);
|
printf ("got changed vcard back: %s\n", e_contact_get_const (change->contact, E_CONTACT_UID));
|
||||||
|
|
||||||
e_book_free_change_list (changes);
|
e_book_free_change_list (changes);
|
||||||
|
|
||||||
|
@ -24,13 +24,9 @@ module Addressbook {
|
|||||||
ContactDeleted
|
ContactDeleted
|
||||||
};
|
};
|
||||||
|
|
||||||
union BookChangeItem switch (BookChangeType) {
|
struct BookChangeItem {
|
||||||
case ContactAdded:
|
BookChangeType changeType;
|
||||||
VCard add_vcard;
|
VCard vcard;
|
||||||
case ContactModified:
|
|
||||||
VCard mod_vcard;
|
|
||||||
case ContactDeleted:
|
|
||||||
ContactId del_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef sequence<BookChangeItem> BookChangeList;
|
typedef sequence<BookChangeItem> BookChangeList;
|
||||||
|
@ -515,6 +515,7 @@ typedef struct {
|
|||||||
GList *mod_cards;
|
GList *mod_cards;
|
||||||
GList *mod_ids;
|
GList *mod_ids;
|
||||||
GList *del_ids;
|
GList *del_ids;
|
||||||
|
GList *del_cards;
|
||||||
} PASBackendFileChangeContext;
|
} PASBackendFileChangeContext;
|
||||||
|
|
||||||
static void
|
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);
|
db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0);
|
||||||
|
|
||||||
if (db_error != 0) {
|
if (db_error != 0) {
|
||||||
|
EContact *contact;
|
||||||
char *id = id_dbt.data;
|
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,
|
ctx->del_ids = g_list_append (ctx->del_ids,
|
||||||
g_strdup (id));
|
g_strdup (id));
|
||||||
|
ctx->del_cards = g_list_append (ctx->del_cards,
|
||||||
|
vcard_string);
|
||||||
|
|
||||||
|
g_object_unref (contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,13 +658,16 @@ pas_backend_file_get_changes (PASBackendSync *backend,
|
|||||||
g_free (i->data);
|
g_free (i->data);
|
||||||
g_free (v->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 *id = i->data;
|
||||||
|
char *vcard = v->data;
|
||||||
|
|
||||||
e_dbhash_remove (ehash, id);
|
e_dbhash_remove (ehash, id);
|
||||||
|
|
||||||
changes = g_list_prepend (changes,
|
changes = g_list_prepend (changes,
|
||||||
pas_backend_change_delete_new (id));
|
pas_backend_change_delete_new (vcard));
|
||||||
g_free (i->data);
|
g_free (i->data);
|
||||||
|
g_free (v->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_dbhash_write (ehash);
|
e_dbhash_write (ehash);
|
||||||
|
@ -448,8 +448,8 @@ pas_backend_change_add_new (const char *vcard)
|
|||||||
{
|
{
|
||||||
GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc();
|
GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc();
|
||||||
|
|
||||||
new_change->_d = GNOME_Evolution_Addressbook_ContactAdded;
|
new_change->changeType= GNOME_Evolution_Addressbook_ContactAdded;
|
||||||
new_change->_u.add_vcard = CORBA_string_dup (vcard);
|
new_change->vcard = CORBA_string_dup (vcard);
|
||||||
|
|
||||||
return new_change;
|
return new_change;
|
||||||
}
|
}
|
||||||
@ -459,19 +459,19 @@ pas_backend_change_modify_new (const char *vcard)
|
|||||||
{
|
{
|
||||||
GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc();
|
GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc();
|
||||||
|
|
||||||
new_change->_d = GNOME_Evolution_Addressbook_ContactModified;
|
new_change->changeType= GNOME_Evolution_Addressbook_ContactModified;
|
||||||
new_change->_u.mod_vcard = CORBA_string_dup (vcard);
|
new_change->vcard = CORBA_string_dup (vcard);
|
||||||
|
|
||||||
return new_change;
|
return new_change;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNOME_Evolution_Addressbook_BookChangeItem*
|
GNOME_Evolution_Addressbook_BookChangeItem*
|
||||||
pas_backend_change_delete_new (const char *id)
|
pas_backend_change_delete_new (const char *vcard)
|
||||||
{
|
{
|
||||||
GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc();
|
GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc();
|
||||||
|
|
||||||
new_change->_d = GNOME_Evolution_Addressbook_ContactDeleted;
|
new_change->changeType= GNOME_Evolution_Addressbook_ContactDeleted;
|
||||||
new_change->_u.del_id = CORBA_string_dup (id);
|
new_change->vcard = CORBA_string_dup (vcard);
|
||||||
|
|
||||||
return new_change;
|
return new_change;
|
||||||
}
|
}
|
||||||
|
@ -612,17 +612,7 @@ pas_book_respond_get_changes (PASBook *book,
|
|||||||
for (i = 0, l = changes; l; l = l->next, i ++) {
|
for (i = 0, l = changes; l; l = l->next, i ++) {
|
||||||
GNOME_Evolution_Addressbook_BookChangeItem *change = (GNOME_Evolution_Addressbook_BookChangeItem*)l->data;
|
GNOME_Evolution_Addressbook_BookChangeItem *change = (GNOME_Evolution_Addressbook_BookChangeItem*)l->data;
|
||||||
changelist._buffer[i] = *change;
|
changelist._buffer[i] = *change;
|
||||||
switch (change->_d) {
|
changelist._buffer[i].vcard = CORBA_string_dup (change->vcard);
|
||||||
case GNOME_Evolution_Addressbook_ContactAdded:
|
|
||||||
changelist._buffer[i]._u.add_vcard = CORBA_string_dup (change->_u.add_vcard);
|
|
||||||
break;
|
|
||||||
case GNOME_Evolution_Addressbook_ContactModified:
|
|
||||||
changelist._buffer[i]._u.mod_vcard = CORBA_string_dup (change->_u.mod_vcard);
|
|
||||||
break;
|
|
||||||
case GNOME_Evolution_Addressbook_ContactDeleted:
|
|
||||||
changelist._buffer[i]._u.del_id = CORBA_string_dup (change->_u.del_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_foreach (changes, (GFunc)CORBA_free, NULL);
|
g_list_foreach (changes, (GFunc)CORBA_free, NULL);
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user