From 57de6972c845dbae49717a4520aeed75f88f0078 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Fri, 16 Mar 2001 08:16:29 +0000 Subject: Added addressbook querying and "cardification" functions, which are turned 2001-03-15 Jon Trowbridge * gui/component/e-address-widget.c: Added addressbook querying and "cardification" functions, which are turned off by default for now because of addressbook bugs. Added a popup menu option to turn queries on, so that others can enjoy the thrill of massive flaming death. * gui/component/addressbook-factory.c (main): Made warnings always be fatal. * backend/pas/pas-book-view.c: Added some debugging spew. * backend/pas/pas-backend-file.c (pas_backend_file_search): Added a little experimental code to try to make file searches scale better. #if 0/#endif-ed out for now. * contact-editor/e-contact-quick-add.c: #included e-book-util.h. * backend/ebook/e-card.c (e_card_name_match_string): Added. Looser name-matching function. (e_card_email_match_string): Added. Loose e-mail matching. * backend/ebook/e-book-view-listener.c (e_book_view_listener_check_queue): Added code to cause us to abort rather than get trapped in a 100%-CPU-consuming loop in certain situations. Now we just need to figure out how to avoid these situations altogether. * backend/ebook/e-book-util.c: Added. Now contains the simple query stuff and the open local addressbook functions. * backend/ebook/e-book.c: Moved simple query stuff and open local addressbook functions into e-book-util.c. 2001-03-15 Jon Trowbridge * wombat.c (main): If we can't initialize a service on startup, tell us which one before terminating. svn path=/trunk/; revision=8754 --- addressbook/backend/ebook/e-book.c | 174 ------------------------------------- 1 file changed, 174 deletions(-) (limited to 'addressbook/backend/ebook/e-book.c') diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c index e0b62c48d1..2a02b78fbf 100644 --- a/addressbook/backend/ebook/e-book.c +++ b/addressbook/backend/ebook/e-book.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "addressbook.h" @@ -517,28 +516,6 @@ e_book_unload_uri (EBook *book) book->priv->load_state = URINotLoaded; } -gboolean -e_book_load_local_address_book (EBook *book, EBookCallback open_response, gpointer closure) -{ - gchar *filename; - gchar *uri; - gboolean rv; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (open_response != NULL, FALSE); - - filename = gnome_util_prepend_user_home ("evolution/local/Contacts/addressbook.db"); - uri = g_strdup_printf ("file://%s", filename); - - rv = e_book_load_uri (book, uri, open_response, closure); - - g_free (filename); - g_free (uri); - - return rv; -} - char * e_book_get_static_capabilities (EBook *book) { @@ -1119,157 +1096,6 @@ e_book_get_changes (EBook *book, return TRUE; } -/* - * - * Simple Query Stuff - * - */ - -typedef struct _SimpleQueryInfo SimpleQueryInfo; -struct _SimpleQueryInfo { - guint tag; - EBook *book; - gchar *query; - EBookSimpleQueryCallback cb; - gpointer closure; - EBookView *view; - guint add_tag; - guint seq_complete_tag; - GList *cards; -}; - -static SimpleQueryInfo * -simple_query_new (EBook *book, char *query, EBookSimpleQueryCallback cb, gpointer closure) -{ - SimpleQueryInfo *sq = g_new0 (SimpleQueryInfo, 1); - - sq->tag = ++book->priv->sq_tag; - sq->book = book; - gtk_object_ref (GTK_OBJECT (book)); - sq->query = g_strdup_printf (query); - sq->cb = cb; - sq->closure = closure; - - /* Automatically add ourselves to the EBook's pending list. */ - book->priv->sq_pending = g_list_prepend (book->priv->sq_pending, sq); - - return sq; -} - -static void -simple_query_free (SimpleQueryInfo *sq) -{ - GList *i; - gboolean found = FALSE; - - /* Find & remove ourselves from the EBook's pending list. */ - for (i = sq->book->priv->sq_pending; i != NULL; i = g_list_next (i)) { - if (i->data == sq) { - sq->book->priv->sq_pending = g_list_remove_link (sq->book->priv->sq_pending, i); - g_list_free_1 (i); - i = NULL; - found = TRUE; - } else - i = g_list_next (i); - } - - g_assert (found); - - g_free (sq->query); - - if (sq->add_tag) - gtk_signal_disconnect (GTK_OBJECT (sq->view), sq->add_tag); - if (sq->seq_complete_tag) - gtk_signal_disconnect (GTK_OBJECT (sq->view), sq->seq_complete_tag); - - if (sq->view) - gtk_object_unref (GTK_OBJECT (sq->view)); - - if (sq->book) - gtk_object_unref (GTK_OBJECT (sq->book)); - - g_list_foreach (sq->cards, (GFunc) gtk_object_unref, NULL); - g_list_free (sq->cards); - - g_free (sq); -} - -static void -simple_query_card_added_cb (EBookView *view, const GList *cards, gpointer closure) -{ - SimpleQueryInfo *sq = closure; - - sq->cards = g_list_concat (sq->cards, g_list_copy ((GList *) cards)); - g_list_foreach ((GList *) cards, (GFunc) gtk_object_ref, NULL); -} - -static void -simple_query_sequence_complete_cb (EBookView *view, gpointer closure) -{ - SimpleQueryInfo *sq = closure; - - sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS, sq->cards, sq->closure); - simple_query_free (sq); -} - -static void -simple_query_book_view_cb (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - SimpleQueryInfo *sq = closure; - - if (status != E_BOOK_STATUS_SUCCESS) { - sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_OTHER_ERROR, NULL, sq->closure); - simple_query_free (sq); - return; - } - - sq->view = book_view; - gtk_object_ref (GTK_OBJECT (book_view)); - - sq->add_tag = gtk_signal_connect (GTK_OBJECT (sq->view), - "card_added", - GTK_SIGNAL_FUNC (simple_query_card_added_cb), - sq); - sq->seq_complete_tag = gtk_signal_connect (GTK_OBJECT (sq->view), - "sequence_complete", - GTK_SIGNAL_FUNC (simple_query_sequence_complete_cb), - sq); -} - -guint -e_book_simple_query (EBook *book, char *query, EBookSimpleQueryCallback cb, gpointer closure) -{ - SimpleQueryInfo *sq; - - g_return_val_if_fail (book && E_IS_BOOK (book), 0); - g_return_val_if_fail (query, 0); - g_return_val_if_fail (cb, 0); - - sq = simple_query_new (book, query, cb, closure); - e_book_get_book_view (book, query, simple_query_book_view_cb, sq); - - return sq->tag; -} - -void -e_book_simple_query_cancel (EBook *book, guint tag) -{ - GList *i; - - g_return_if_fail (book && E_IS_BOOK (book)); - - for (i=book->priv->sq_pending; i != NULL; i=g_list_next (i)) { - SimpleQueryInfo *sq = i->data; - - if (sq->tag == tag) { - sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_CANCELLED, NULL, sq->closure); - simple_query_free (sq); - return; - } - } - g_warning ("Simple query tag %d is unknown", tag); -} - /** * e_book_get_name: */ -- cgit v1.2.3