aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/merging
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-08-27 02:52:10 +0800
committerChris Toshok <toshok@src.gnome.org>2004-08-27 02:52:10 +0800
commit2fe7d9c79a7a38df4cea878cf5a4d85c442f5af8 (patch)
treecf4730b00fa66f16538cce00d9116fe614a3b66b /addressbook/gui/merging
parentb472b77d6c5147bebd631df616d030ea79255759 (diff)
downloadgsoc2013-evolution-2fe7d9c79a7a38df4cea878cf5a4d85c442f5af8.tar.gz
gsoc2013-evolution-2fe7d9c79a7a38df4cea878cf5a4d85c442f5af8.tar.zst
gsoc2013-evolution-2fe7d9c79a7a38df4cea878cf5a4d85c442f5af8.zip
[ patch for the rest of 60889 ] new function, either start up the query or
2004-08-26 Chris Toshok <toshok@ximian.com> [ 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
Diffstat (limited to 'addressbook/gui/merging')
-rw-r--r--addressbook/gui/merging/eab-contact-merging.c57
1 files changed, 50 insertions, 7 deletions
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;
}