diff options
author | JP Rosevear <jpr@helixcode.com> | 2000-11-01 03:20:31 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2000-11-01 03:20:31 +0800 |
commit | b3a536d46bfc6f4ed4524ec6252abfcea2f97423 (patch) | |
tree | f327398c9f76da31d1248890f5781af95aa34fef | |
parent | ae91213c361f16e5f132024dce23718f035a8c27 (diff) | |
download | gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.gz gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.zst gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.zip |
Let the warning make sense (compute_pid): remove
2000-10-31 JP Rosevear <jpr@helixcode.com>
* conduit/address-conduit.c (cursor_cb): Let the warning make sense
(compute_pid): remove
(local_record_from_ecard): Create local record from ecard - not finished
(local_record_from_uid): Obtain local_record from uid with the proper
e-book way
(set_status_cleared): Add empty callback
(add_archive_record): kill
(delete_archive_record): kill
(archive_record): Add empty callback
(conduit_get_gpilot_conduit): Update signal connects
* backend/pas/pas-backend-file.c (vcard_change_type): Function to determine
the type of change - not finished
(pas_backend_file_search_changes): Create a view and callback based on
how the cards have changed
(pas_backend_file_process_get_changes): Implement the get changes operation
for files
(pas_backend_file_process_client_requests): Add GetChanges method for
processing
* backend/pas/pas-book.c (pas_book_queue_get_changes): Add changes to
the list
(impl_Evolution_Book_get_changes): implement object method
(pas_book_get_epv): Add get changes to epv
(pas_book_respond_get_changes): Respond to the get changes operation
* backend/pas/pas-book.h: Add GetChanges PASOperation
* backend/idl/addressbook.idl: add get_changes and respond_get_changes
methods
* backend/ebook/e-book.c (e_book_get_changes): Client function
to a view of the changed objects
* backend/ebook/e-book.h: New prototype
2000-10-31 JP Rosevear <jpr@helixcode.com>
* conduits/todo/todo-conduit.h: Remove add/del/mod hashes and
add changed_hash.
* conduits/calendar/calendar-conduit.h: ditto
* conduits/todo/todo-conduit.c (next_changed_item): Utility function
to get the next "really" changed item (changed status can be cleared now)
(compute_status): Compute status based on changed_hash
(pre_sync): Fill changed_hash and counts adds/mods/dels
(set_status_cleared): New callback handler - avoid double syncing
(for_each_modified): Use next_changed_item to iterate
(add_archive_record): kill
(delete_archive_record): kill
(archive_record): New callback handler - mark/unmark archive status
(conduit_get_gpilot_conduit): Adjust signal connects
* conduits/calendar/calendar-conduit.c: ditto
svn path=/trunk/; revision=6297
-rw-r--r-- | addressbook/ChangeLog | 38 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book.c | 36 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book.h | 5 | ||||
-rw-r--r-- | addressbook/backend/idl/addressbook.idl | 4 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-file.c | 157 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.c | 64 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.h | 4 | ||||
-rw-r--r-- | addressbook/conduit/address-conduit.c | 272 | ||||
-rw-r--r-- | calendar/ChangeLog | 20 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 179 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.h | 7 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.c | 181 | ||||
-rw-r--r-- | calendar/conduits/todo/todo-conduit.h | 7 |
13 files changed, 600 insertions, 374 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 7a54abd23f..c091dee850 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,41 @@ +2000-10-31 JP Rosevear <jpr@helixcode.com> + + * conduit/address-conduit.c (cursor_cb): Let the warning make sense + (compute_pid): remove + (local_record_from_ecard): Create local record from ecard - not finished + (local_record_from_uid): Obtain local_record from uid with the proper + e-book way + (set_status_cleared): Add empty callback + (add_archive_record): kill + (delete_archive_record): kill + (archive_record): Add empty callback + (conduit_get_gpilot_conduit): Update signal connects + + * backend/pas/pas-backend-file.c (vcard_change_type): Function to determine + the type of change - not finished + (pas_backend_file_search_changes): Create a view and callback based on + how the cards have changed + (pas_backend_file_process_get_changes): Implement the get changes operation + for files + (pas_backend_file_process_client_requests): Add GetChanges method for + processing + + * backend/pas/pas-book.c (pas_book_queue_get_changes): Add changes to + the list + (impl_Evolution_Book_get_changes): implement object method + (pas_book_get_epv): Add get changes to epv + (pas_book_respond_get_changes): Respond to the get changes operation + + * backend/pas/pas-book.h: Add GetChanges PASOperation + + * backend/idl/addressbook.idl: add get_changes and respond_get_changes + methods + + * backend/ebook/e-book.c (e_book_get_changes): Client function + to a view of the changed objects + + * backend/ebook/e-book.h: New prototype + 2000-10-30 Kjartan Maraas <kmaraas@gnome.org> * backend/e-book/e-card.c: Fixed marking of strings diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c index bb0226eb5a..32103fc9df 100644 --- a/addressbook/backend/ebook/e-book.c +++ b/addressbook/backend/ebook/e-book.c @@ -909,6 +909,42 @@ gboolean e_book_get_book_view (EBook *book, return TRUE; } +gboolean e_book_get_changes (EBook *book, + gchar *changeid, + EBookBookViewCallback cb, + gpointer closure) +{ + CORBA_Environment ev; + EBookViewListener *listener; + + g_return_val_if_fail (book != NULL, FALSE); + g_return_val_if_fail (E_IS_BOOK (book), FALSE); + + if (book->priv->load_state != URILoaded) { + g_warning ("e_book_get_changes: No URI loaded!\n"); + return FALSE; + } + + listener = e_book_view_listener_new(); + + CORBA_exception_init (&ev); + + Evolution_Book_get_changes (book->priv->corba_book, bonobo_object_corba_objref(BONOBO_OBJECT(listener)), changeid, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("e_book_changes: Exception " + "getting changes!\n"); + CORBA_exception_free (&ev); + return FALSE; + } + + CORBA_exception_free (&ev); + + e_book_queue_op (book, cb, closure, listener); + + return TRUE; +} + /** * e_book_get_name: */ diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h index 29f3787f66..3c3f2bc65b 100644 --- a/addressbook/backend/ebook/e-book.h +++ b/addressbook/backend/ebook/e-book.h @@ -107,6 +107,11 @@ gboolean e_book_get_book_view (EBook *book, EBookBookViewCallback cb, gpointer closure); +gboolean e_book_get_changes (EBook *book, + char *changeid, + EBookBookViewCallback cb, + gpointer closure); + /* Getting the name of the repository. */ char *e_book_get_name (EBook *book); diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl index e520621858..2c5a54487e 100644 --- a/addressbook/backend/idl/addressbook.idl +++ b/addressbook/backend/idl/addressbook.idl @@ -83,6 +83,8 @@ module Evolution { */ void get_book_view(in BookViewListener listener, in string query); + void get_changes(in BookViewListener listener, in string changeid); + void check_connection (); string get_static_capabilities (); @@ -115,6 +117,8 @@ module Evolution { void respond_get_view (in CallStatus status, in BookView view); + void respond_get_changes (in CallStatus status, in BookView view); + /** * report_connection_status: * diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index a54d32d424..84a21d4c6f 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -485,6 +485,104 @@ pas_backend_file_search (PASBackendFile *bf, g_list_free (cards); } +typedef enum { + VCardChangeNone, + VCardChangeAdded, + VCardChangeModified, + VCardChangeDeleted +} VCardChangeType; + +static VCardChangeType +vcard_change_type (const PASBackendFileBookView *view, char *vcard_string) +{ + ECard *card; + + card = e_card_new (vcard_string); + view->search_context->card = e_card_simple_new (card); + gtk_object_unref(GTK_OBJECT(card)); + + /* if it's not a valid vcard why is it in our db? :) */ + if (!view->search_context->card) + return VCardChangeNone; + + /* FIX ME, actually need to implement this */ + + gtk_object_unref(GTK_OBJECT(view->search_context->card)); + + return VCardChangeNone; +} + +static void +pas_backend_file_search_changes (PASBackendFile *bf, + PASBook *book, + const PASBackendFileBookView *cnstview) +{ + int db_error = 0; + GList *add_cards = NULL; + GList *mod_cards = NULL; + GList *del_cards = NULL; + DB *db = bf->priv->file_db; + DBT id_dbt, vcard_dbt; + PASBackendFileBookView *view = (PASBackendFileBookView *)cnstview; + + if (!bf->priv->loaded) + return; + + db_error = db->seq(db, &id_dbt, &vcard_dbt, R_FIRST); + + while (db_error == 0) { + + /* don't include the version in the list of cards */ + if (id_dbt.size != strlen(PAS_BACKEND_FILE_VERSION_NAME) + 1 + || strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { + char *vcard_string = vcard_dbt.data; + + /* check what type of change has occurred, if any */ + switch (vcard_change_type (view, vcard_string)) { + case VCardChangeNone: + break; + case VCardChangeAdded: + add_cards = g_list_append (add_cards, strdup(vcard_string)); + break; + case VCardChangeModified: + mod_cards = g_list_append (mod_cards, strdup(vcard_string)); + break; + case VCardChangeDeleted: + del_cards = g_list_append (del_cards, strdup(vcard_string)); + break; + } + } + + db_error = db->seq(db, &id_dbt, &vcard_dbt, R_NEXT); + } + + if (db_error == -1) { + g_warning ("pas_backend_file_search_changes: error building list\n"); + } else { + GList *l; + + pas_book_view_notify_add (view->book_view, add_cards); + pas_book_view_notify_change (view->book_view, mod_cards); + + for (l = del_cards; l != NULL; l = l->next){ + char *card = l->data; + pas_book_view_notify_remove (view->book_view, card); + } + + pas_book_view_notify_complete (view->book_view); + } + + /* + ** It's fine to do this now since the data has been handed off. + */ + g_list_foreach (add_cards, (GFunc)g_free, NULL); + g_list_foreach (mod_cards, (GFunc)g_free, NULL); + g_list_foreach (del_cards, (GFunc)g_free, NULL); + g_list_free (add_cards); + g_list_free (mod_cards); + g_list_free (del_cards); +} + static char * do_create(PASBackend *backend, char *vcard_req, @@ -848,6 +946,61 @@ pas_backend_file_process_get_book_view (PASBackend *backend, } static void +pas_backend_file_process_get_changes (PASBackend *backend, + PASBook *book, + PASRequest *req) +{ + PASBackendFile *bf = PAS_BACKEND_FILE (backend); + CORBA_Environment ev; + PASBookView *book_view; + Evolution_Book corba_book; + PASBackendFileBookView view; + PASBackendFileSearchContext ctx; + EIterator *iterator; + + g_return_if_fail (req->listener != NULL); + + corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); + + CORBA_exception_init(&ev); + + Evolution_Book_ref(corba_book, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning("pas_backend_file_process_get_book_view: Exception reffing " + "corba book.\n"); + } + + CORBA_exception_free(&ev); + + book_view = pas_book_view_new (req->listener); + + gtk_signal_connect(GTK_OBJECT(book_view), "destroy", + GTK_SIGNAL_FUNC(view_destroy), book); + + pas_book_respond_get_changes (book, + (book_view != NULL + ? Evolution_BookListener_Success + : Evolution_BookListener_CardNotFound /* XXX */), + book_view); + + view.book_view = book_view; + view.search = req->search; + view.search_sexp = NULL; + view.search_context = &ctx; + ctx.card = NULL; + + e_list_append(bf->priv->book_views, &view); + + iterator = e_list_get_iterator(bf->priv->book_views); + e_iterator_last(iterator); + pas_backend_file_search_changes (bf, book, e_iterator_get(iterator)); + gtk_object_unref(GTK_OBJECT(iterator)); + + g_free(req->search); +} + +static void pas_backend_file_process_check_connection (PASBackend *backend, PASBook *book, PASRequest *req) @@ -932,6 +1085,10 @@ pas_backend_file_process_client_requests (PASBook *book) case GetBookView: pas_backend_file_process_get_book_view (backend, book, req); break; + + case GetChanges: + pas_backend_file_process_get_changes (backend, book, req); + break; } g_free (req); diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c index 4cd51237a1..6a8c17a584 100644 --- a/addressbook/backend/pas/pas-book.c +++ b/addressbook/backend/pas/pas-book.c @@ -130,6 +130,30 @@ pas_book_queue_get_book_view (PASBook *book, const Evolution_BookViewListener li } static void +pas_book_queue_get_changes (PASBook *book, const Evolution_BookViewListener listener, const char *search) +{ + PASRequest *req; + CORBA_Environment ev; + + req = g_new0 (PASRequest, 1); + req->op = GetChanges; + req->search = g_strdup(search); + + CORBA_exception_init (&ev); + + req->listener = CORBA_Object_duplicate(listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("pas_book_queue_get_changes: Exception " + "duplicating BookViewListener!\n"); + } + + CORBA_exception_free (&ev); + + pas_book_queue_request (book, req); +} + +static void pas_book_queue_check_connection (PASBook *book) { PASRequest *req; @@ -233,6 +257,17 @@ impl_Evolution_Book_get_book_view (PortableServer_Servant servant, } static void +impl_Evolution_Book_get_changes (PortableServer_Servant servant, + const Evolution_BookViewListener listener, + const CORBA_char *search, + CORBA_Environment *ev) +{ + PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); + + pas_book_queue_get_changes (book, listener, search); +} + +static void impl_Evolution_Book_check_connection (PortableServer_Servant servant, CORBA_Environment *ev) { @@ -442,7 +477,7 @@ pas_book_respond_get_cursor (PASBook *book, } /** - * pas_book_respond_get_cursor: + * pas_book_respond_get_book_view: */ void pas_book_respond_get_book_view (PASBook *book, @@ -468,6 +503,32 @@ pas_book_respond_get_book_view (PASBook *book, } /** + * pas_book_respond_get_changes: + */ +void +pas_book_respond_get_changes (PASBook *book, + Evolution_BookListener_CallStatus status, + PASBookView *book_view) +{ + CORBA_Environment ev; + CORBA_Object object; + + CORBA_exception_init (&ev); + + object = bonobo_object_corba_objref(BONOBO_OBJECT(book_view)); + + Evolution_BookListener_respond_get_changes ( + book->priv->listener, status, object, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("pas_book_respond_get_changes: Exception " + "responding to BookListener!\n"); + } + + CORBA_exception_free (&ev); +} + +/** * pas_book_report_connection: */ void @@ -622,6 +683,7 @@ pas_book_get_epv (void) epv->get_static_capabilities = impl_Evolution_Book_get_static_capabilities; epv->get_cursor = impl_Evolution_Book_get_cursor; epv->get_book_view = impl_Evolution_Book_get_book_view; + epv->get_changes = impl_Evolution_Book_get_changes; return epv; diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h index 9ca81eb25d..ab59d7bb3e 100644 --- a/addressbook/backend/pas/pas-book.h +++ b/addressbook/backend/pas/pas-book.h @@ -29,6 +29,7 @@ typedef enum { ModifyCard, GetCursor, GetBookView, + GetChanges, CheckConnection } PASOperation; @@ -80,6 +81,9 @@ void pas_book_respond_get_cursor (PASBook void pas_book_respond_get_book_view (PASBook *book, Evolution_BookListener_CallStatus status, PASBookView *book_view); +void pas_book_respond_get_changes (PASBook *book, + Evolution_BookListener_CallStatus status, + PASBookView *book_view); void pas_book_report_connection (PASBook *book, gboolean connected); diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index 94d48179a6..048422cb7b 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -180,7 +180,6 @@ cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closur long length; int i; - // ctxt->cursor = cursor; ctxt->address_load_success = TRUE; length = e_card_cursor_get_length (cursor); @@ -191,7 +190,7 @@ cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closur gtk_main_quit(); /* end the sub event loop */ } else { - WARN (_("BLARG\n")); + WARN (_("Cursor could not be loaded\n")); gtk_main_quit(); /* end the sub event loop */ } } @@ -203,9 +202,8 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure) if (status == E_BOOK_STATUS_SUCCESS) { e_book_get_cursor (book, "(contains \"full_name\" \"\")", cursor_cb, ctxt); - } - else { - WARN (_("BLARG\n")); + } else { + WARN (_("EBook not loaded\n")); gtk_main_quit(); /* end the sub event loop */ } } @@ -250,32 +248,11 @@ map_name (EAddrConduitContext *ctxt) } static void -compute_pid (EAddrConduitContext *ctxt, EAddrLocalRecord *local, const char *uid) -{ -/* guint32 *pid; */ - -/* pid = g_hash_table_lookup (ctxt->map->uid_map, uid); */ - -/* if (pid) */ -/* local->local.ID = *pid; */ -/* else */ -/* local->local.ID = 0; */ -} - -static void compute_status (EAddrConduitContext *ctxt, EAddrLocalRecord *local, const char *uid) { local->local.archived = FALSE; local->local.secret = FALSE; - -/* if (g_hash_table_lookup (ctxt->added, uid)) */ -/* local->local.attr = GnomePilotRecordNew; */ -/* else if (g_hash_table_lookup (ctxt->modified, uid)) */ -/* local->local.attr = GnomePilotRecordModified; */ -/* else if (g_hash_table_lookup (ctxt->deleted, uid)) */ -/* local->local.attr = GnomePilotRecordDeleted; */ -/* else */ -/* local->local.attr = GnomePilotRecordNothing; */ + local->local.attr = GnomePilotRecordNothing; } static GnomePilotRecord * @@ -304,108 +281,58 @@ local_record_to_pilot_record (EAddrLocalRecord *local, return p; } -#if 0 -/* - * converts a CalComponent object to a EAddrLocalRecord - */ static void -local_record_from_comp (EAddrLocalRecord *local, CalComponent *comp, EAddrConduitContext *ctxt) +local_record_from_ecard (EAddrLocalRecord *local, ECard *ecard, EAddrConduitContext *ctxt) { - const char *uid; - int *priority; - struct icaltimetype *completed; - CalComponentText summary; - GSList *d_list = NULL; - CalComponentText *description; - CalComponentDateTime due; - time_t due_time; - CalComponentClassification classif; - - LOG ("local_record_from_comp\n"); + ECardSimple *simple; + const ECardDeliveryAddress *delivery; g_return_if_fail (local != NULL); - g_return_if_fail (comp != NULL); - - local->comp = comp; + g_return_if_fail (ecard != NULL); - cal_component_get_uid (local->comp, &uid); - compute_pid (ctxt, local, uid); - compute_status (ctxt, local, uid); + local->ecard = ecard; + simple = e_card_simple_new (ecard); + + local->local.ID = e_pilot_map_lookup_pid (ctxt->map, ecard->id); - local->todo = g_new0 (struct ToDo,1); + compute_status (ctxt, local, ecard->id); - /* STOP: don't replace these with g_strdup, since free_ToDo - uses free to deallocate */ - cal_component_get_summary (comp, &summary); - if (summary.value) - local->todo->description = strdup ((char *) summary.value); + local->addr = g_new0 (struct Address, 1); - cal_component_get_description_list (comp, &d_list); - if (d_list) { - description = (CalComponentText *) d_list->data; - if (description && description->value) - local->todo->note = strdup (description->value); - else - local->todo->note = NULL; - } else { - local->todo->note = NULL; - } + local->addr->entry[entryFirstname] = strdup (ecard->name->given); + local->addr->entry[entryLastname] = strdup (ecard->name->family); + local->addr->entry[entryCompany] = strdup (ecard->org); + local->addr->entry[entryTitle] = strdup (ecard->title); - cal_component_get_due (comp, &due); - if (due.value) { - due_time = icaltime_as_timet (*due.value); - - local->todo->due = *localtime (&due_time); - local->todo->indefinite = 0; - } else { - local->todo->indefinite = 1; - } + delivery = e_card_simple_get_delivery_address (simple, E_CARD_SIMPLE_ADDRESS_ID_HOME); + local->addr->entry[entryAddress] = strdup (delivery->street); + local->addr->entry[entryCity] = strdup (delivery->city); + local->addr->entry[entryState] = strdup (delivery->region); + local->addr->entry[entryZip] = strdup (delivery->code); + local->addr->entry[entryCountry] = strdup (delivery->country); - cal_component_get_completed (comp, &completed); - if (completed) { - local->todo->complete = 1; - cal_component_free_icaltimetype (completed); - } + /* FIX ME Phone numbers */ - cal_component_get_priority (comp, &priority); - if (priority) { - local->todo->priority = *priority; - cal_component_free_priority (priority); - } - - cal_component_get_classification (comp, &classif); - - if (classif == CAL_COMPONENT_CLASS_PRIVATE) - local->local.secret = 1; - else - local->local.secret = 0; - - local->local.archived = 0; + gtk_object_unref (GTK_OBJECT (simple)); } -#endif static void local_record_from_uid (EAddrLocalRecord *local, char *uid, EAddrConduitContext *ctxt) { -/* CalComponent *comp; */ -/* CalClientGetStatus status; */ + ECard *ecard; -/* g_assert(local!=NULL); */ + g_assert(local!=NULL); -/* status = cal_client_get_object (ctxt->client, uid, &comp); */ + ecard = e_book_get_card (ctxt->ebook, uid); -/* if (status == CAL_CLIENT_GET_SUCCESS) { */ -/* local_record_from_comp (local, comp, ctxt); */ -/* } else if (status == CAL_CLIENT_GET_NOT_FOUND) { */ -/* comp = cal_component_new (); */ -/* cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); */ -/* cal_component_set_uid (comp, uid); */ -/* local_record_from_comp (local, comp, ctxt); */ -/* } else { */ -/* INFO ("Object did not exist"); */ -/* } */ + if (ecard != NULL) { + local_record_from_ecard (local, ecard, ctxt); + } else { + ecard = e_card_new (NULL); + local_record_from_ecard (local, ecard, ctxt); + } } static ECard * @@ -429,11 +356,10 @@ ecard_from_remote_record(EAddrConduitContext *ctxt, if (in_card == NULL) { ecard = e_card_new(""); - simple = e_card_simple_new(ecard); } else { - ecard = in_card; - simple = E_CARD_SIMPLE (ecard); + ecard = e_card_duplicate (in_card); } + simple = e_card_simple_new (ecard); #define get(pilotprop) \ (address.entry [(pilotprop)]) @@ -518,86 +444,12 @@ ecard_from_remote_record(EAddrConduitContext *ctxt, return ecard; } -#if 0 -static CalComponent * -comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - CalComponent *in_comp) -{ - CalComponent *comp; - struct ToDo todo; - struct icaltimetype now = icaltime_from_timet (time (NULL), FALSE, FALSE); - CalComponentText summary = {NULL, NULL}; - CalComponentText description = {NULL, NULL}; - CalComponentDateTime dt = {NULL, NULL}; - struct icaltimetype due; - GSList *d_list; - - g_return_val_if_fail (remote != NULL, NULL); - - memset (&todo, 0, sizeof (struct ToDo)); - unpack_ToDo (&todo, remote->record, remote->length); - - if (in_comp == NULL) { - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - cal_component_set_created (comp, &now); - } else { - comp = cal_component_clone (in_comp); - } - - LOG (" comp_from_remote_record: " - "creating from remote %s and comp %s\n", - print_remote (remote), cal_component_get_as_string (comp)); - - cal_component_set_last_modified (comp, &now); - - summary.value = todo.description; - cal_component_set_summary (comp, &summary); - - description.value = todo.note; - d_list = g_slist_append (NULL, &description); - cal_component_set_comment_list (comp, d_list); - g_slist_free (d_list); - - if (todo.complete) { - int percent = 100; - cal_component_set_completed (comp, &now); - cal_component_set_percent (comp, &percent); - } - - /* FIX ME This is a bit hackish, how else can we tell if there is - * no due date set? - */ - if (todo.due.tm_sec || todo.due.tm_min || todo.due.tm_hour - || todo.due.tm_mday || todo.due.tm_mon || todo.due.tm_year) { - due = icaltime_from_timet (mktime (&todo.due), FALSE, FALSE); - dt.value = &due; - cal_component_set_due (comp, &dt); - } - - cal_component_set_priority (comp, &todo.priority); - cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE); - - if (remote->attr & dlpRecAttrSecret) - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE); - else - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC); - - cal_component_commit_sequence (comp); - - free_ToDo(&todo); - - return comp; -} -#endif - static void check_for_slow_setting (GnomePilotConduit *c, EAddrConduitContext *ctxt) { int count, map_count; -/* count = g_list_length (ctxt->uids); */ + count = g_list_length (ctxt->cards); count = 0; map_count = g_hash_table_size (ctxt->map->pid_map); @@ -671,7 +523,7 @@ pre_sync (GnomePilotConduit *conduit, unpack_AddressAppInfo (&(ctxt->ai), buf, len); g_free (buf); -/* check_for_slow_setting (conduit, ctxt); */ + check_for_slow_setting (conduit, ctxt); return 0; } @@ -707,6 +559,16 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit, } static gint +set_status_cleared (GnomePilotConduitSyncAbs *conduit, + EAddrLocalRecord *local, + EAddrConduitContext *ctxt) +{ + LOG ("set_status_cleared: clearing status\n"); + + return 0; +} + +static gint for_each (GnomePilotConduitSyncAbs *conduit, EAddrLocalRecord **local, EAddrConduitContext *ctxt) @@ -877,23 +739,6 @@ add_record (GnomePilotConduitSyncAbs *conduit, } static gint -add_archive_record (GnomePilotConduitSyncAbs *conduit, - EAddrLocalRecord *local, - GnomePilotRecord *remote, - EAddrConduitContext *ctxt) -{ - int retval = 0; - - g_return_val_if_fail (remote != NULL, -1); - g_return_val_if_fail (local != NULL, -1); - - LOG ("add_archive_record: doing nothing with %s\n", - print_local (local)); - - return retval; -} - -static gint replace_record (GnomePilotConduitSyncAbs *conduit, EAddrLocalRecord *local, GnomePilotRecord *remote, @@ -944,16 +789,17 @@ delete_record (GnomePilotConduitSyncAbs *conduit, } static gint -delete_archive_record (GnomePilotConduitSyncAbs *conduit, - EAddrLocalRecord *local, - EAddrConduitContext *ctxt) +archive_record (GnomePilotConduitSyncAbs *conduit, + EAddrLocalRecord *local, + gboolean archive, + EAddrConduitContext *ctxt) { int retval = 0; - g_return_val_if_fail(local!=NULL,-1); - - LOG ("delete_archive_record: doing nothing\n"); + g_return_val_if_fail (local != NULL, -1); + LOG ("archive_record: %s\n", archive ? "yes" : "no"); + return retval; } @@ -1079,18 +925,16 @@ conduit_get_gpilot_conduit (guint32 pilot_id) gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, ctxt); gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt); + gtk_signal_connect (retval, "set_status_cleared", (GtkSignalFunc) set_status_cleared, ctxt); gtk_signal_connect (retval, "for_each", (GtkSignalFunc) for_each, ctxt); gtk_signal_connect (retval, "for_each_modified", (GtkSignalFunc) for_each_modified, ctxt); gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt); gtk_signal_connect (retval, "add_record", (GtkSignalFunc) add_record, ctxt); - gtk_signal_connect (retval, "add_archive_record", (GtkSignalFunc) add_archive_record, ctxt); - gtk_signal_connect (retval, "replace_record", (GtkSignalFunc) replace_record, ctxt); - gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt); - gtk_signal_connect (retval, "delete_archive_record", (GtkSignalFunc) delete_archive_record, ctxt); + gtk_signal_connect (retval, "archive_record", (GtkSignalFunc) archive_record, ctxt); gtk_signal_connect (retval, "match", (GtkSignalFunc) match, ctxt); gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 834afcdc2f..c8b2859dad 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,23 @@ +2000-10-31 JP Rosevear <jpr@helixcode.com> + + * conduits/todo/todo-conduit.h: Remove add/del/mod hashes and + add changed_hash. + + * conduits/calendar/calendar-conduit.h: ditto + + * conduits/todo/todo-conduit.c (next_changed_item): Utility function + to get the next "really" changed item (changed status can be cleared now) + (compute_status): Compute status based on changed_hash + (pre_sync): Fill changed_hash and counts adds/mods/dels + (set_status_cleared): New callback handler - avoid double syncing + (for_each_modified): Use next_changed_item to iterate + (add_archive_record): kill + (delete_archive_record): kill + (archive_record): New callback handler - mark/unmark archive status + (conduit_get_gpilot_conduit): Adjust signal connects + + * conduits/calendar/calendar-conduit.c: ditto + 2000-10-30 Federico Mena Quintero <federico@helixcode.com> * gui/event-editor.c (sensitize_recur_widgets): New function. We diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 2429e317d7..90bcb5e685 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -235,20 +235,49 @@ get_ical_day (int day) return ICAL_NO_WEEKDAY; } +static GList * +next_changed_item (ECalConduitContext *ctxt, GList *changes) +{ + CalObjChange *coc; + GList *l; + + for (l = changes; l != NULL; l = l->next) { + coc = l->data; + + if (g_hash_table_lookup (ctxt->changed_hash, coc->uid)) + return l; + } + + return NULL; +} + static void compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *uid) { + CalObjChange *coc; + local->local.archived = FALSE; local->local.secret = FALSE; + + coc = g_hash_table_lookup (ctxt->changed_hash, uid); - if (g_hash_table_lookup (ctxt->added, uid)) - local->local.attr = GnomePilotRecordNew; - else if (g_hash_table_lookup (ctxt->modified, uid)) - local->local.attr = GnomePilotRecordModified; - else if (g_hash_table_lookup (ctxt->deleted, uid)) - local->local.attr = GnomePilotRecordDeleted; - else + if (coc == NULL) { local->local.attr = GnomePilotRecordNothing; + return; + } + + switch (coc->type) { + case CALOBJ_UPDATED: + if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0) + local->local.attr = GnomePilotRecordModified; + else + local->local.attr = GnomePilotRecordNew; + break; + + case CALOBJ_REMOVED: + local->local.attr = GnomePilotRecordDeleted; + break; + } } static GnomePilotRecord * @@ -608,7 +637,7 @@ pre_sync (GnomePilotConduit *conduit, int len; unsigned char *buf; char *filename; - gint num_records; + gint num_records, add_records = 0, mod_records = 0, del_records = 0; abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit); @@ -633,38 +662,39 @@ pre_sync (GnomePilotConduit *conduit, g_free (filename); /* Find the added, modified and deleted items */ - ctxt->added = g_hash_table_new (g_str_hash, g_str_equal); - ctxt->modified = g_hash_table_new (g_str_hash, g_str_equal); - ctxt->deleted = g_hash_table_new (g_str_hash, g_str_equal); - + ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal); ctxt->changed = cal_client_get_changed_uids (ctxt->client, CALOBJ_TYPE_EVENT, ctxt->map->since + 1); + for (l = ctxt->changed; l != NULL; l = l->next) { CalObjChange *coc = l->data; - - switch (coc->type) { - case CALOBJ_UPDATED: - if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0) - g_hash_table_insert (ctxt->modified, coc->uid, coc); - else - g_hash_table_insert (ctxt->added, coc->uid, coc); - break; - case CALOBJ_REMOVED: - g_hash_table_insert (ctxt->deleted, coc->uid, coc); - break; + + if (!e_pilot_map_uid_is_archived (ctxt->map, coc->uid)) { + + g_hash_table_insert (ctxt->changed_hash, coc->uid, coc); + + switch (coc->type) { + case CALOBJ_UPDATED: + if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0) + mod_records++; + else + add_records++; + break; + + case CALOBJ_REMOVED: + del_records++; + break; + } } } /* Set the count information */ - num_records = cal_client_get_n_objects (ctxt->client, CALOBJ_TYPE_EVENT); + num_records = cal_client_get_n_objects (ctxt->client, CALOBJ_TYPE_TODO); gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records); - num_records = g_hash_table_size (ctxt->added); - gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, num_records); - num_records = g_hash_table_size (ctxt->modified); - gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, num_records); - num_records = g_hash_table_size (ctxt->deleted); - gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, num_records); + gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records); + gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records); + gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records); gtk_object_set_data (GTK_OBJECT (conduit), "dbinfo", dbi); @@ -721,6 +751,21 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit, } static gint +set_status_cleared (GnomePilotConduitSyncAbs *conduit, + ECalLocalRecord *local, + ECalConduitContext *ctxt) +{ + const char *uid; + + LOG ("set_status_cleared: clearing status\n"); + + cal_component_get_uid (local->comp, &uid); + g_hash_table_remove (ctxt->changed_hash, uid); + + return 0; +} + +static gint for_each (GnomePilotConduitSyncAbs *conduit, ECalLocalRecord **local, ECalConduitContext *ctxt) @@ -773,7 +818,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, ECalLocalRecord **local, ECalConduitContext *ctxt) { - static GList *changes, *iterator; + static GList *iterator; static int count; g_return_val_if_fail (local != NULL, 0); @@ -781,41 +826,41 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, if (*local == NULL) { LOG ("beginning for_each_modified: beginning\n"); - changes = ctxt->changed; + iterator = ctxt->changed; count = 0; + + LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); - if (changes != NULL) { - CalObjChange *coc = changes->data; + iterator = next_changed_item (ctxt, iterator); + if (iterator != NULL) { + CalObjChange *coc = NULL; - LOG ("iterating over %d records", g_list_length (changes)); - + coc = iterator->data; + + LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); + *local = g_new0 (ECalLocalRecord, 1); local_record_from_uid (*local, coc->uid, ctxt); - - iterator = changes; } else { LOG ("no events"); - (*local) = NULL; - return 0; + + *local = NULL; } } else { count++; - if (g_list_next (iterator)) { - CalObjChange *coc; + if ((iterator = next_changed_item (ctxt, iterator))) { + CalObjChange *coc = NULL; - iterator = g_list_next (iterator); coc = iterator->data; - + *local = g_new0 (ECalLocalRecord, 1); local_record_from_uid (*local, coc->uid, ctxt); } else { LOG ("for_each_modified ending"); - /* Tell the pilot the iteration is over */ - (*local) = NULL; - - return 0; + /* Signal the iteration is over */ + *local = NULL; } } @@ -880,21 +925,6 @@ add_record (GnomePilotConduitSyncAbs *conduit, } static gint -add_archive_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - ECalConduitContext *ctxt) -{ - int retval = 0; - - g_return_val_if_fail (remote != NULL, -1); - - LOG ("add_archive_record: doing nothing with %s\n", - print_remote (remote)); - - return retval; -} - -static gint replace_record (GnomePilotConduitSyncAbs *conduit, ECalLocalRecord *local, GnomePilotRecord *remote, @@ -913,8 +943,6 @@ replace_record (GnomePilotConduitSyncAbs *conduit, local->comp = new_comp; update_comp (conduit, local->comp, ctxt); - gtk_object_unref (GTK_OBJECT (new_comp)); - return retval; } @@ -938,16 +966,21 @@ delete_record (GnomePilotConduitSyncAbs *conduit, } static gint -delete_archive_record (GnomePilotConduitSyncAbs *conduit, - ECalLocalRecord *local, - ECalConduitContext *ctxt) +archive_record (GnomePilotConduitSyncAbs *conduit, + ECalLocalRecord *local, + gboolean archive, + ECalConduitContext *ctxt) { + const char *uid; int retval = 0; - g_return_val_if_fail(local!=NULL,-1); + g_return_val_if_fail (local != NULL, -1); - LOG ("delete_archive_record: doing nothing\n"); + LOG ("archive_record: %s\n", archive ? "yes" : "no"); + cal_component_get_uid (local->comp, &uid); + e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive); + return retval; } @@ -1073,18 +1106,16 @@ conduit_get_gpilot_conduit (guint32 pilot_id) gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, ctxt); gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt); + gtk_signal_connect (retval, "set_status_cleared", (GtkSignalFunc) set_status_cleared, ctxt); gtk_signal_connect (retval, "for_each", (GtkSignalFunc) for_each, ctxt); gtk_signal_connect (retval, "for_each_modified", (GtkSignalFunc) for_each_modified, ctxt); gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt); gtk_signal_connect (retval, "add_record", (GtkSignalFunc) add_record, ctxt); - gtk_signal_connect (retval, "add_archive_record", (GtkSignalFunc) add_archive_record, ctxt); - gtk_signal_connect (retval, "replace_record", (GtkSignalFunc) replace_record, ctxt); - gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt); - gtk_signal_connect (retval, "delete_archive_record", (GtkSignalFunc) delete_archive_record, ctxt); + gtk_signal_connect (retval, "archive_record", (GtkSignalFunc) archive_record, ctxt); gtk_signal_connect (retval, "match", (GtkSignalFunc) match, ctxt); gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h index 91900fcb90..d78fae3553 100644 --- a/calendar/conduits/calendar/calendar-conduit.h +++ b/calendar/conduits/calendar/calendar-conduit.h @@ -66,12 +66,9 @@ struct _ECalConduitContext { time_t since; GList *uids; GList *changed; - + GHashTable *changed_hash; + EPilotMap *map; - - GHashTable *added; - GHashTable *modified; - GHashTable *deleted; }; #endif __CALENDAR_CONDUIT_H__ diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index 2c4e5e8ff3..12b04ad78c 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -214,20 +214,49 @@ map_name (EToDoConduitContext *ctxt) return filename; } +static GList * +next_changed_item (EToDoConduitContext *ctxt, GList *changes) +{ + CalObjChange *coc; + GList *l; + + for (l = changes; l != NULL; l = l->next) { + coc = l->data; + + if (g_hash_table_lookup (ctxt->changed_hash, coc->uid)) + return l; + } + + return NULL; +} + static void compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char *uid) { + CalObjChange *coc; + local->local.archived = FALSE; local->local.secret = FALSE; + + coc = g_hash_table_lookup (ctxt->changed_hash, uid); - if (g_hash_table_lookup (ctxt->added, uid)) - local->local.attr = GnomePilotRecordNew; - else if (g_hash_table_lookup (ctxt->modified, uid)) - local->local.attr = GnomePilotRecordModified; - else if (g_hash_table_lookup (ctxt->deleted, uid)) - local->local.attr = GnomePilotRecordDeleted; - else + if (coc == NULL) { local->local.attr = GnomePilotRecordNothing; + return; + } + + switch (coc->type) { + case CALOBJ_UPDATED: + if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0) + local->local.attr = GnomePilotRecordModified; + else + local->local.attr = GnomePilotRecordNew; + break; + + case CALOBJ_REMOVED: + local->local.attr = GnomePilotRecordDeleted; + break; + } } static GnomePilotRecord * @@ -481,7 +510,7 @@ pre_sync (GnomePilotConduit *conduit, int len; unsigned char *buf; char *filename; - gint num_records; + gint num_records, add_records = 0, mod_records = 0, del_records = 0; abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit); @@ -505,39 +534,40 @@ pre_sync (GnomePilotConduit *conduit, e_pilot_map_read (filename, &ctxt->map); g_free (filename); - /* Find the added, modified and deleted items */ - ctxt->added = g_hash_table_new (g_str_hash, g_str_equal); - ctxt->modified = g_hash_table_new (g_str_hash, g_str_equal); - ctxt->deleted = g_hash_table_new (g_str_hash, g_str_equal); - + /* Count and hash the changes */ + ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal); ctxt->changed = cal_client_get_changed_uids (ctxt->client, CALOBJ_TYPE_TODO, ctxt->map->since + 1); + for (l = ctxt->changed; l != NULL; l = l->next) { CalObjChange *coc = l->data; - - switch (coc->type) { - case CALOBJ_UPDATED: - if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0) - g_hash_table_insert (ctxt->modified, coc->uid, coc); - else - g_hash_table_insert (ctxt->added, coc->uid, coc); - break; - case CALOBJ_REMOVED: - g_hash_table_insert (ctxt->deleted, coc->uid, coc); - break; + + if (!e_pilot_map_uid_is_archived (ctxt->map, coc->uid)) { + + g_hash_table_insert (ctxt->changed_hash, coc->uid, coc); + + switch (coc->type) { + case CALOBJ_UPDATED: + if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0) + mod_records++; + else + add_records++; + break; + + case CALOBJ_REMOVED: + del_records++; + break; + } } } /* Set the count information */ num_records = cal_client_get_n_objects (ctxt->client, CALOBJ_TYPE_TODO); gnome_pilot_conduit_sync_abs_set_num_local_records(abs_conduit, num_records); - num_records = g_hash_table_size (ctxt->added); - gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, num_records); - num_records = g_hash_table_size (ctxt->modified); - gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, num_records); - num_records = g_hash_table_size (ctxt->deleted); - gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, num_records); + gnome_pilot_conduit_sync_abs_set_num_new_local_records (abs_conduit, add_records); + gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records); + gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records); gtk_object_set_data (GTK_OBJECT (conduit), "dbinfo", dbi); @@ -595,6 +625,21 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit, } static gint +set_status_cleared (GnomePilotConduitSyncAbs *conduit, + EToDoLocalRecord *local, + EToDoConduitContext *ctxt) +{ + const char *uid; + + LOG ("set_status_cleared: clearing status\n"); + + cal_component_get_uid (local->comp, &uid); + g_hash_table_remove (ctxt->changed_hash, uid); + + return 0; +} + +static gint for_each (GnomePilotConduitSyncAbs *conduit, EToDoLocalRecord **local, EToDoConduitContext *ctxt) @@ -647,7 +692,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, EToDoLocalRecord **local, EToDoConduitContext *ctxt) { - static GList *changes, *iterator; + static GList *iterator; static int count; g_return_val_if_fail (local != NULL, 0); @@ -655,41 +700,41 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, if (*local == NULL) { LOG ("beginning for_each_modified: beginning\n"); - changes = ctxt->changed; + iterator = ctxt->changed; count = 0; + + LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); - if (changes != NULL) { - CalObjChange *coc = changes->data; + iterator = next_changed_item (ctxt, iterator); + if (iterator != NULL) { + CalObjChange *coc = NULL; - LOG ("iterating over %d records", g_list_length (changes)); - + coc = iterator->data; + + LOG ("iterating over %d records", g_hash_table_size (ctxt->changed_hash)); + *local = g_new0 (EToDoLocalRecord, 1); local_record_from_uid (*local, coc->uid, ctxt); - - iterator = changes; } else { LOG ("no events"); - (*local) = NULL; - return 0; + + *local = NULL; } } else { count++; - if (g_list_next (iterator)) { - CalObjChange *coc; + if ((iterator = next_changed_item (ctxt, iterator))) { + CalObjChange *coc = NULL; - iterator = g_list_next (iterator); coc = iterator->data; - + *local = g_new0 (EToDoLocalRecord, 1); local_record_from_uid (*local, coc->uid, ctxt); } else { LOG ("for_each_modified ending"); - /* Tell the pilot the iteration is over */ - (*local) = NULL; - - return 0; + /* Signal the iteration is over */ + *local = NULL; } } @@ -754,21 +799,6 @@ add_record (GnomePilotConduitSyncAbs *conduit, } static gint -add_archive_record (GnomePilotConduitSyncAbs *conduit, - GnomePilotRecord *remote, - EToDoConduitContext *ctxt) -{ - int retval = 0; - - g_return_val_if_fail (remote != NULL, -1); - - LOG ("add_archive_record: doing nothing with %s\n", - print_remote (remote)); - - return retval; -} - -static gint replace_record (GnomePilotConduitSyncAbs *conduit, EToDoLocalRecord *local, GnomePilotRecord *remote, @@ -787,8 +817,6 @@ replace_record (GnomePilotConduitSyncAbs *conduit, local->comp = new_comp; update_comp (conduit, local->comp, ctxt); - gtk_object_unref (GTK_OBJECT (new_comp)); - return retval; } @@ -800,7 +828,7 @@ delete_record (GnomePilotConduitSyncAbs *conduit, const char *uid; g_return_val_if_fail (local != NULL, -1); - g_assert (local->comp != NULL); + g_return_val_if_fail (local->comp != NULL, -1); cal_component_get_uid (local->comp, &uid); @@ -812,16 +840,21 @@ delete_record (GnomePilotConduitSyncAbs *conduit, } static gint -delete_archive_record (GnomePilotConduitSyncAbs *conduit, - EToDoLocalRecord *local, - EToDoConduitContext *ctxt) +archive_record (GnomePilotConduitSyncAbs *conduit, + EToDoLocalRecord *local, + gboolean archive, + EToDoConduitContext *ctxt) { + const char *uid; int retval = 0; - g_return_val_if_fail(local!=NULL,-1); + g_return_val_if_fail (local != NULL, -1); - LOG ("delete_archive_record: doing nothing\n"); + LOG ("archive_record: %s\n", archive ? "yes" : "no"); + cal_component_get_uid (local->comp, &uid); + e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive); + return retval; } @@ -947,18 +980,16 @@ conduit_get_gpilot_conduit (guint32 pilot_id) gtk_signal_connect (retval, "post_sync", (GtkSignalFunc) post_sync, ctxt); gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt); + gtk_signal_connect (retval, "set_status_cleared", (GtkSignalFunc) set_status_cleared, ctxt); gtk_signal_connect (retval, "for_each", (GtkSignalFunc) for_each, ctxt); gtk_signal_connect (retval, "for_each_modified", (GtkSignalFunc) for_each_modified, ctxt); gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt); gtk_signal_connect (retval, "add_record", (GtkSignalFunc) add_record, ctxt); - gtk_signal_connect (retval, "add_archive_record", (GtkSignalFunc) add_archive_record, ctxt); - gtk_signal_connect (retval, "replace_record", (GtkSignalFunc) replace_record, ctxt); - gtk_signal_connect (retval, "delete_record", (GtkSignalFunc) delete_record, ctxt); - gtk_signal_connect (retval, "delete_archive_record", (GtkSignalFunc) delete_archive_record, ctxt); + gtk_signal_connect (retval, "archive_record", (GtkSignalFunc) archive_record, ctxt); gtk_signal_connect (retval, "match", (GtkSignalFunc) match, ctxt); gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt); diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h index 6e1f109a87..624c6271e7 100644 --- a/calendar/conduits/todo/todo-conduit.h +++ b/calendar/conduits/todo/todo-conduit.h @@ -65,12 +65,9 @@ struct _EToDoConduitContext { GList *uids; GList *changed; - - EPilotMap *map; + GHashTable *changed_hash; - GHashTable *added; - GHashTable *modified; - GHashTable *deleted; + EPilotMap *map; }; #endif __TODO_CONDUIT_H__ |