From 50f54e757ca63df54eba9ca7125d1f4244239f2c Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 28 Sep 2001 21:17:30 +0000 Subject: g_strdup (pas_backend_file_changes): ditto, make sure to free all data and 2001-09-28 JP Rosevear * backend/pas/pas-backend-file.c (pas_backend_file_changes_foreach_key): g_strdup (pas_backend_file_changes): ditto, make sure to free all data and do a hash write after each add/remove * conduit/address-conduit.c (local_record_to_pilot_record): use the local record category (local_record_from_ecard): ndle the fields and category we don't sync by making sure we don't overwrite them svn path=/trunk/; revision=13232 --- addressbook/ChangeLog | 29 ++++++++++++-- addressbook/backend/pas/pas-backend-file.c | 63 ++++++++++++++++++------------ addressbook/conduit/address-conduit.c | 13 ++++-- 3 files changed, 73 insertions(+), 32 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 536112ebbd..04730b135e 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,8 +1,29 @@ -2001-09-27 Ettore Perazzoli +2001-09-28 JP Rosevear - * gui/component/addressbook.c: Update the paths, - /menu/ComponentToolsPlaceholder/Tools/ -> - /menu/Tools/ComponentPlaceholder/. + * backend/pas/pas-backend-file.c + (pas_backend_file_changes_foreach_key): g_strdup + (pas_backend_file_changes): ditto, make sure to free all data and + do a hash write after each add/remove + + * conduit/address-conduit.c (local_record_to_pilot_record): use + the local record category + (local_record_from_ecard): ndle the fields and category we don't + sync by making sure we don't overwrite them + +2001-09-27 Chris Toshok + + * backend/ebook/e-book.c (e_book_construct): do an oaf query to + get a list of all objects implementing our BookFactory interface, + instead of just activating the one IID. this should really be a + global list, not a per EBook. + (e_book_load_uri): start the iteration over our list of + BookFactory's. + (e_book_load_uri_from_factory): try and load the uri. + (e_book_load_uri_open_cb): callback function for the + BookFactory_openBook call - if it succeeds, call the user's + callback. otherwise step to the next factory. + (e_book_load_uri_step): go to the next factory in our list, and + error out if there are no more. 2001-09-27 JP Rosevear diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index 990d53e704..b8ef4931fb 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -349,7 +349,7 @@ pas_backend_file_changes_foreach_key (const char *key, gpointer user_data) if (db_error == DB_NOTFOUND) { char *id = id_dbt.data; - ctx->del_ids = g_list_append (ctx->del_ids, strdup (id)); + ctx->del_ids = g_list_append (ctx->del_ids, g_strdup (id)); } } @@ -409,12 +409,14 @@ pas_backend_file_changes (PASBackendFile *bf, case E_DBHASH_STATUS_SAME: break; case E_DBHASH_STATUS_NOT_FOUND: - ctx->add_cards = g_list_append (ctx->add_cards, strdup(vcard_string)); - ctx->add_ids = g_list_append (ctx->add_ids, strdup(id)); + ctx->add_cards = g_list_append (ctx->add_cards, + g_strdup(vcard_string)); + ctx->add_ids = g_list_append (ctx->add_ids, g_strdup(id)); break; case E_DBHASH_STATUS_DIFFERENT: - ctx->mod_cards = g_list_append (ctx->mod_cards, strdup(vcard_string)); - ctx->mod_ids = g_list_append (ctx->mod_ids, strdup(id)); + ctx->mod_cards = g_list_append (ctx->mod_cards, + g_strdup(vcard_string)); + ctx->mod_ids = g_list_append (ctx->mod_ids, g_strdup(id)); break; } } @@ -426,25 +428,6 @@ pas_backend_file_changes (PASBackendFile *bf, e_dbhash_foreach_key (ehash, (EDbHashFunc)pas_backend_file_changes_foreach_key, view->change_context); - /* Update the hash */ - for (i = ctx->add_ids, v = ctx->add_cards; i != NULL; i = i->next, v = v->next){ - char *id = i->data; - char *vcard = v->data; - e_dbhash_add (ehash, id, vcard); - } - for (i = ctx->mod_ids, v = ctx->mod_cards; i != NULL; i = i->next, v = v->next){ - char *id = i->data; - char *vcard = v->data; - e_dbhash_add (ehash, id, vcard); - } - for (i = ctx->del_ids; i != NULL; i = i->next){ - char *id = i->data; - e_dbhash_remove (ehash, id); - } - - e_dbhash_write (ehash); - e_dbhash_destroy (ehash); - /* Send the changes */ if (db_error != DB_NOTFOUND) { g_warning ("pas_backend_file_changes: error building list\n"); @@ -462,6 +445,38 @@ pas_backend_file_changes (PASBackendFile *bf, pas_book_view_notify_complete (view->book_view); } + + /* Update the hash */ + for (i = ctx->add_ids, v = ctx->add_cards; i != NULL; i = i->next, v = v->next){ + char *id = i->data; + char *vcard = v->data; + + e_dbhash_add (ehash, id, vcard); + e_dbhash_write (ehash); + + g_free (i->data); + g_free (v->data); + } + for (i = ctx->mod_ids, v = ctx->mod_cards; i != NULL; i = i->next, v = v->next){ + char *id = i->data; + char *vcard = v->data; + + e_dbhash_add (ehash, id, vcard); + e_dbhash_write (ehash); + + g_free (i->data); + g_free (v->data); + } + for (i = ctx->del_ids; i != NULL; i = i->next){ + char *id = i->data; + + e_dbhash_remove (ehash, id); + e_dbhash_write (ehash); + + g_free (i->data); + } + + e_dbhash_destroy (ehash); } static char * diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index ef78fc88d0..42c56cd707 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -322,7 +322,7 @@ local_record_to_pilot_record (EAddrLocalRecord *local, LOG ("local_record_to_pilot_record\n"); p.ID = local->local.ID; - p.category = 0; + p.category = local->local.category; p.attr = local->local.attr; p.archived = local->local.archived; p.secret = local->local.secret; @@ -355,15 +355,20 @@ local_record_from_ecard (EAddrLocalRecord *local, ECard *ecard, EAddrConduitCont local->addr = g_new0 (struct Address, 1); - /* Handle the fields we don't sync by making sure we don't overwrite them */ + /* Handle the fields and category we don't sync by making sure + * we don't overwrite them + */ if (local->local.ID != 0) { char record[0xffff]; - + int cat = 0; + if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, ctxt->dbi->db_handle, local->local.ID, &record, - NULL, NULL, NULL, NULL) > 0) + NULL, NULL, NULL, &cat) > 0) { + local->local.category = cat; unpack_Address (local->addr, record, 0xffff); + } } if (ecard->name) { -- cgit