aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/merging/eab-contact-compare.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-01-22 05:31:09 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-01-22 05:34:39 +0800
commitb1565f53d797fe4dbbf7256eca060eb4d8ee9ee4 (patch)
tree9af4d94e34145cf56984cf313dd237470c3f15ce /addressbook/gui/merging/eab-contact-compare.c
parentd05d0b0338eebc3ca68f69b69c9932f884effed0 (diff)
downloadgsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar
gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.gz
gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.bz2
gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.lz
gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.xz
gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.tar.zst
gsoc2013-evolution-b1565f53d797fe4dbbf7256eca060eb4d8ee9ee4.zip
Use e_load_book_source_async() for all EBook loading.
Diffstat (limited to 'addressbook/gui/merging/eab-contact-compare.c')
-rw-r--r--addressbook/gui/merging/eab-contact-compare.c66
1 files changed, 42 insertions, 24 deletions
diff --git a/addressbook/gui/merging/eab-contact-compare.c b/addressbook/gui/merging/eab-contact-compare.c
index d5ba1a5f84..db92649f6d 100644
--- a/addressbook/gui/merging/eab-contact-compare.c
+++ b/addressbook/gui/merging/eab-contact-compare.c
@@ -24,7 +24,7 @@
#include <config.h>
#include <ctype.h>
#include <string.h>
-#include "addressbook/util/addressbook.h"
+#include <libedataserverui/e-book-auth-util.h>
#include "addressbook/util/eab-book-util.h"
#include "eab-contact-compare.h"
@@ -541,6 +541,7 @@ eab_contact_compare (EContact *contact1, EContact *contact2)
typedef struct _MatchSearchInfo MatchSearchInfo;
struct _MatchSearchInfo {
+ ESourceList *source_list;
EContact *contact;
GList *avoid;
EABContactMatchQueryCallback cb;
@@ -551,6 +552,9 @@ static void
match_search_info_free (MatchSearchInfo *info)
{
if (info) {
+ if (info->source_list != NULL)
+ g_object_unref (info->source_list);
+
g_object_unref (info->contact);
/* This should already have been deallocated, but just in case... */
@@ -626,9 +630,9 @@ query_cb (EBook *book, const GError *error, GList *contacts, gpointer closure)
#define MAX_QUERY_PARTS 10
static void
-use_common_book_cb (EBook *book, const GError *error, gpointer closure)
+use_common_book (EBook *book,
+ MatchSearchInfo *info)
{
- MatchSearchInfo *info = (MatchSearchInfo *) closure;
EContact *contact = info->contact;
EContactName *contact_name;
GList *contact_email;
@@ -716,22 +720,23 @@ use_common_book_cb (EBook *book, const GError *error, gpointer closure)
e_book_query_unref (query);
}
-void
-eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gpointer closure)
+static void
+book_loaded_cb (ESource *source,
+ GAsyncResult *result,
+ MatchSearchInfo *info)
{
- MatchSearchInfo *info;
+ EBook *book;
- g_return_if_fail (contact && E_IS_CONTACT (contact));
- g_return_if_fail (cb != NULL);
-
- info = g_new (MatchSearchInfo, 1);
- info->contact = contact;
- g_object_ref (contact);
- info->cb = cb;
- info->closure = closure;
- info->avoid = NULL;
+ book = e_load_book_source_finish (source, result, NULL);
+ use_common_book (book, info);
+}
- addressbook_load_default_book ((EBookAsyncCallback) use_common_book_cb, info);
+void
+eab_contact_locate_match (EContact *contact,
+ EABContactMatchQueryCallback cb,
+ gpointer closure)
+{
+ eab_contact_locate_match_full (NULL, contact, NULL, cb, closure);
}
/**
@@ -746,24 +751,37 @@ eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gp
* Look for the best match and return it using the EABContactMatchQueryCallback.
**/
void
-eab_contact_locate_match_full (EBook *book, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure)
+eab_contact_locate_match_full (EBook *book,
+ EContact *contact,
+ GList *avoid,
+ EABContactMatchQueryCallback cb,
+ gpointer closure)
{
MatchSearchInfo *info;
+ ESource *source;
- g_return_if_fail (contact && E_IS_CONTACT (contact));
+ g_return_if_fail (E_IS_CONTACT (contact));
g_return_if_fail (cb != NULL);
info = g_new (MatchSearchInfo, 1);
- info->contact = contact;
- g_object_ref (contact);
+ info->contact = g_object_ref (contact);
info->cb = cb;
info->closure = closure;
info->avoid = g_list_copy (avoid);
g_list_foreach (info->avoid, (GFunc) g_object_ref, NULL);
- if (book)
- use_common_book_cb (book, NULL, info);
- else
- addressbook_load_default_book ((EBookAsyncCallback) use_common_book_cb, info);
+ if (book) {
+ use_common_book (book, info);
+ return;
+ }
+
+ if (!e_book_get_addressbooks (&info->source_list, NULL))
+ return;
+
+ source = e_source_list_peek_default_source (info->source_list);
+
+ e_load_book_source_async (
+ source, NULL, NULL, (GAsyncReadyCallback)
+ book_loaded_cb, info);
}