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 /addressbook/backend/pas | |
parent | ae91213c361f16e5f132024dce23718f035a8c27 (diff) | |
download | gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.gz gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.bz2 gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.lz gsoc2013-evolution-b3a536d46bfc6f4ed4524ec6252abfcea2f97423.tar.xz 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
Diffstat (limited to 'addressbook/backend/pas')
-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 |
3 files changed, 224 insertions, 1 deletions
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); |