From 2fe7d9c79a7a38df4cea878cf5a4d85c442f5af8 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Thu, 26 Aug 2004 18:52:10 +0000 Subject: [ patch for the rest of 60889 ] new function, either start up the query or 2004-08-26 Chris Toshok [ patch for the rest of 60889 ] * gui/merging/eab-contact-merging.c (add_lookup): new function, either start up the query or add it to the queue if we're over the number of simultaneous queries. (finished_lookup): start up enough pending queries to get us to our limit again. (free_lookup): free lookup->avoid. (final_id_cb): call finished_lookup. (eab_merging_book_add_contact): set lookup->avoid to NULL and replace call to eab_contact_locate_match_full with add_lookup. (eab_merging_book_commit_contact): set lookup->avoid to the contact, and make the same s/eab_contact_locate_match_full/add_lookup/ replacement. svn path=/trunk/; revision=27038 --- addressbook/ChangeLog | 16 ++++++++ addressbook/gui/merging/eab-contact-merging.c | 57 +++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index bcdb60510c..880f902252 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,19 @@ +2004-08-26 Chris Toshok + + [ patch for the rest of 60889 ] + * gui/merging/eab-contact-merging.c (add_lookup): new function, + either start up the query or add it to the queue if we're over the + number of simultaneous queries. + (finished_lookup): start up enough pending queries to get us to + our limit again. + (free_lookup): free lookup->avoid. + (final_id_cb): call finished_lookup. + (eab_merging_book_add_contact): set lookup->avoid to NULL and + replace call to eab_contact_locate_match_full with add_lookup. + (eab_merging_book_commit_contact): set lookup->avoid to the + contact, and make the same + s/eab_contact_locate_match_full/add_lookup/ replacement. + 2004-08-26 Christian Neumair * gui/component/GNOME_Evolution_Addressbook.server.in.in: diff --git a/addressbook/gui/merging/eab-contact-merging.c b/addressbook/gui/merging/eab-contact-merging.c index 8cabe1cd4e..685739ed89 100644 --- a/addressbook/gui/merging/eab-contact-merging.c +++ b/addressbook/gui/merging/eab-contact-merging.c @@ -26,16 +26,58 @@ typedef struct { EContactMergingOpType op; EBook *book; EContact *contact; + GList *avoid; EBookIdCallback id_cb; EBookCallback cb; gpointer closure; } EContactMergingLookup; +static void match_query_callback (EContact *contact, EContact *match, EABContactMatchType type, gpointer closure); + +#define SIMULTANEOUS_MERGING_REQUESTS 20 + +static GList *merging_queue = NULL; +static int running_merge_requests = 0; + + +static void +add_lookup (EContactMergingLookup *lookup) +{ + if (running_merge_requests < SIMULTANEOUS_MERGING_REQUESTS) { + running_merge_requests++; + eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup); + } + else { + merging_queue = g_list_append (merging_queue, lookup); + } +} + +static void +finished_lookup (void) +{ + running_merge_requests--; + + while (running_merge_requests < SIMULTANEOUS_MERGING_REQUESTS) { + EContactMergingLookup *lookup; + + if (!merging_queue) + break; + + lookup = merging_queue->data; + + merging_queue = g_list_remove_link (merging_queue, merging_queue); + + running_merge_requests++; + eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup); + } +} + static void free_lookup (EContactMergingLookup *lookup) { g_object_unref (lookup->book); g_object_unref (lookup->contact); + g_list_free (lookup->avoid); g_free (lookup); } @@ -49,6 +91,8 @@ final_id_cb (EBook *book, EBookStatus status, const char *id, gpointer closure) lookup->id_cb (lookup->book, status, id, lookup->closure); free_lookup (lookup); + + finished_lookup (); } static void @@ -60,6 +104,8 @@ final_cb (EBook *book, EBookStatus status, gpointer closure) lookup->cb (lookup->book, status, lookup->closure); free_lookup (lookup); + + finished_lookup (); } static void @@ -151,8 +197,9 @@ eab_merging_book_add_contact (EBook *book, lookup->contact = g_object_ref (contact); lookup->id_cb = cb; lookup->closure = closure; + lookup->avoid = NULL; - eab_contact_locate_match_full (book, contact, NULL, match_query_callback, lookup); + add_lookup (lookup); return TRUE; } @@ -164,7 +211,6 @@ eab_merging_book_commit_contact (EBook *book, gpointer closure) { EContactMergingLookup *lookup; - GList *avoid; lookup = g_new (EContactMergingLookup, 1); @@ -173,12 +219,9 @@ eab_merging_book_commit_contact (EBook *book, lookup->contact = g_object_ref (contact); lookup->cb = cb; lookup->closure = closure; + lookup->avoid = g_list_append (NULL, contact); - avoid = g_list_append (NULL, contact); - - eab_contact_locate_match_full (book, contact, avoid, match_query_callback, lookup); - - g_list_free (avoid); + add_lookup (lookup); return TRUE; } -- cgit v1.2.3