aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c27
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c33
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c25
-rw-r--r--addressbook/gui/merging/eab-contact-compare.c15
-rw-r--r--addressbook/gui/widgets/e-addressbook-selector.c34
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c24
-rw-r--r--addressbook/importers/evolution-csv-importer.c15
-rw-r--r--addressbook/importers/evolution-ldif-importer.c15
-rw-r--r--addressbook/importers/evolution-vcard-importer.c15
-rw-r--r--addressbook/tools/evolution-addressbook-export-list-cards.c13
-rw-r--r--addressbook/tools/evolution-addressbook-export-list-folders.c14
-rw-r--r--addressbook/util/eab-book-util.c32
-rw-r--r--addressbook/util/eab-book-util.h6
-rw-r--r--e-util/e-name-selector-dialog.c27
-rw-r--r--e-util/e-name-selector-entry.c26
-rw-r--r--e-util/e-name-selector.c23
-rw-r--r--libemail-engine/e-mail-utils.c82
-rw-r--r--mail/importers/pine-importer.c11
-rw-r--r--modules/addressbook/e-book-shell-backend.c34
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c41
-rw-r--r--modules/addressbook/e-book-shell-view-private.c37
-rw-r--r--modules/vcard-inline/e-mail-parser-vcard-inline.c25
-rw-r--r--plugins/bbdb/bbdb.c30
-rw-r--r--plugins/bbdb/bbdb.h4
-rw-r--r--plugins/bbdb/gaimbuddies.c12
-rw-r--r--plugins/pst-import/pst-importer.c20
26 files changed, 274 insertions, 366 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index b168b79985..a0bd221f94 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -3084,16 +3084,21 @@ init_all (EContactEditor *editor)
}
static void
-contact_editor_book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+contact_editor_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ESource *source = E_SOURCE (source_object);
EContactEditor *editor = user_data;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
@@ -3105,8 +3110,6 @@ contact_editor_book_loaded_cb (GObject *source_object,
GtkWidget *source_combo_box;
GtkWindow *parent;
- g_warn_if_fail (client == NULL);
-
parent = eab_editor_get_window (EAB_EDITOR (editor));
eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error);
@@ -3119,8 +3122,6 @@ contact_editor_book_loaded_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
/* FIXME Write a private contact_editor_set_target_client(). */
g_object_set (editor, "target_client", client, NULL);
@@ -3162,10 +3163,10 @@ source_changed (ESourceComboBox *source_combo_box,
editor->cancellable = g_cancellable_new ();
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, editor->cancellable,
- contact_editor_book_loaded_cb, g_object_ref (editor));
+ e_book_client_connect (
+ source, editor->cancellable,
+ contact_editor_client_connect_cb,
+ g_object_ref (editor));
exit:
g_object_unref (source);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 6dcb7dc628..afbd817ac7 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -126,10 +126,15 @@ merge_cb (GObject *source_object,
{
ESource *source = E_SOURCE (source_object);
QuickAdd *qa = user_data;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* Ignore cancellations. */
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
@@ -140,7 +145,6 @@ merge_cb (GObject *source_object,
}
if (error != NULL) {
- g_warn_if_fail (client == NULL);
if (qa->cb)
qa->cb (NULL, qa->closure);
g_error_free (error);
@@ -148,8 +152,6 @@ merge_cb (GObject *source_object,
return;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
if (!e_client_is_readonly (client))
eab_merging_book_add_contact (
qa->registry, E_BOOK_CLIENT (client),
@@ -179,9 +181,7 @@ quick_add_merge_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
- e_client_utils_open_new (
- qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, qa->cancellable, merge_cb, qa);
+ e_book_client_connect (qa->source, qa->cancellable, merge_cb, qa);
}
/* Raise a contact editor with all fields editable,
@@ -279,12 +279,16 @@ ce_have_book (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
QuickAdd *qa = user_data;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* Ignore cancellations. */
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
@@ -295,7 +299,6 @@ ce_have_book (GObject *source_object,
}
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"Couldn't open local address book (%s).",
error->message);
@@ -304,8 +307,6 @@ ce_have_book (GObject *source_object,
return;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
eab_merging_book_find_contact (
qa->registry, E_BOOK_CLIENT (client),
qa->contact, ce_have_contact, qa);
@@ -321,9 +322,7 @@ edit_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
- e_client_utils_open_new (
- qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, qa->cancellable, ce_have_book, qa);
+ e_book_client_connect (qa->source, qa->cancellable, ce_have_book, qa);
}
#define QUICK_ADD_RESPONSE_EDIT_FULL 2
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 58ea7046dc..6f92e511de 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -301,26 +301,29 @@ contact_list_editor_add_email (EContactListEditor *editor,
}
static void
-contact_list_editor_book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+contact_list_editor_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ESource *source = E_SOURCE (source_object);
EContactListEditor *editor = user_data;
EContactListEditorPrivate *priv = editor->priv;
EContactStore *contact_store;
ENameSelectorEntry *entry;
- EClient *client = NULL;
+ EClient *client;
EBookClient *book_client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
GtkWindow *parent;
- g_warn_if_fail (client == NULL);
-
parent = eab_editor_get_window (EAB_EDITOR (editor));
eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error);
@@ -332,8 +335,6 @@ contact_list_editor_book_loaded_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
book_client = E_BOOK_CLIENT (client);
entry = E_NAME_SELECTOR_ENTRY (WIDGET (EMAIL_ENTRY));
@@ -977,9 +978,9 @@ contact_list_editor_source_menu_changed_cb (GtkWidget *widget)
client_source = e_client_get_source (client);
if (!e_source_equal (client_source, active_source))
- e_client_utils_open_new (
- active_source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, NULL, contact_list_editor_book_loaded_cb,
+ e_book_client_connect (
+ active_source, NULL,
+ contact_list_editor_client_connect_cb,
g_object_ref (editor));
g_object_unref (active_source);
diff --git a/addressbook/gui/merging/eab-contact-compare.c b/addressbook/gui/merging/eab-contact-compare.c
index 1cd5228873..bfca37cbff 100644
--- a/addressbook/gui/merging/eab-contact-compare.c
+++ b/addressbook/gui/merging/eab-contact-compare.c
@@ -768,15 +768,14 @@ use_common_book_client (EBookClient *book_client,
}
static void
-book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
MatchSearchInfo *info = user_data;
- EClient *client = NULL;
+ EClient *client;
- e_client_utils_open_new_finish (source, result, &client, NULL);
+ client = e_book_client_connect_finish (result, NULL);
/* Client may be NULL; don't use a type cast macro. */
use_common_book_client ((EBookClient *) client, info);
@@ -833,9 +832,7 @@ eab_contact_locate_match_full (ESourceRegistry *registry,
source = e_source_registry_ref_default_address_book (registry);
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- book_loaded_cb, info);
+ e_book_client_connect (source, NULL, book_client_connect_cb, info);
g_object_unref (source);
}
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index 2441a0bc89..eedc776a6c 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.c
+++ b/addressbook/gui/widgets/e-addressbook-selector.c
@@ -247,29 +247,30 @@ addressbook_selector_constructed (GObject *object)
}
static void
-target_client_open_ready_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+target_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
MergeContext *merge_context = user_data;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
g_return_if_fail (merge_context != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open targer client: %s",
G_STRFUNC, error->message);
g_error_free (error);
}
- g_return_if_fail (E_IS_CLIENT (client));
-
merge_context->target_client = client ? E_BOOK_CLIENT (client) : NULL;
if (!merge_context->target_client) {
@@ -299,7 +300,7 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
EAddressbookSelectorPrivate *priv;
MergeContext *merge_context;
EAddressbookModel *model;
- EBookClient *source_client = NULL;
+ EBookClient *source_client;
ESourceRegistry *registry;
GSList *list;
const gchar *string;
@@ -314,12 +315,8 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
model = e_addressbook_view_get_model (priv->current_view);
registry = e_addressbook_model_get_registry (model);
- /* XXX Function assumes both out arguments are provided. All we
- * care about is the contact list; source_client will be NULL. */
- eab_book_and_contact_list_from_string (
- registry, string, &source_client, &list);
- if (source_client)
- g_object_unref (source_client);
+ eab_source_and_contact_list_from_string (
+ registry, string, NULL, &list);
if (list == NULL)
return FALSE;
@@ -332,9 +329,8 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
merge_context->remove_from_source = remove_from_source;
merge_context->pending_adds = TRUE;
- e_client_utils_open_new (
- destination, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- target_client_open_ready_cb, merge_context);
+ e_book_client_connect (
+ destination, NULL, target_client_connect_cb, merge_context);
return TRUE;
}
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 089c12b573..2f0f29ea23 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -524,19 +524,22 @@ do_copy (gpointer data,
}
static void
-book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *destination = E_SOURCE (source_object);
ContactCopyProcess *process = user_data;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
- e_client_utils_open_new_finish (destination, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open destination client: %s",
G_STRFUNC, error->message);
@@ -544,8 +547,6 @@ book_loaded_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
process->destination = E_BOOK_CLIENT (client);
process->book_status = TRUE;
g_slist_foreach (process->contacts, do_copy, process);
@@ -612,9 +613,8 @@ eab_transfer_contacts (ESourceRegistry *registry,
process->alert_sink = alert_sink;
process->delete_from_source = delete_from_source;
- e_client_utils_open_new (
- destination, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- book_loaded_cb, process);
+ e_book_client_connect (
+ destination, NULL, book_client_connect_cb, process);
}
/*
diff --git a/addressbook/importers/evolution-csv-importer.c b/addressbook/importers/evolution-csv-importer.c
index 38ba5cacbf..6d5423e064 100644
--- a/addressbook/importers/evolution-csv-importer.c
+++ b/addressbook/importers/evolution-csv-importer.c
@@ -871,15 +871,14 @@ csv_import_done (CSVImporter *gci)
}
static void
-book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
CSVImporter *gci = user_data;
- EClient *client = NULL;
+ EClient *client;
- e_client_utils_open_new_finish (source, result, &client, NULL);
+ client = e_book_client_connect_finish (result, NULL);
if (client == NULL) {
csv_import_done (gci);
@@ -928,9 +927,7 @@ csv_import (EImport *ei,
source = g_datalist_get_data (&target->data, "csv-source");
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- book_loaded_cb, gci);
+ e_book_client_connect (source, NULL, book_client_connect_cb, gci);
}
static void
diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c
index 3ecde6f6f3..ae8fb5ac95 100644
--- a/addressbook/importers/evolution-ldif-importer.c
+++ b/addressbook/importers/evolution-ldif-importer.c
@@ -663,15 +663,14 @@ ldif_import_done (LDIFImporter *gci)
}
static void
-book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
LDIFImporter *gci = user_data;
- EClient *client = NULL;
+ EClient *client;
- e_client_utils_open_new_finish (source, result, &client, NULL);
+ client = e_book_client_connect_finish (result, NULL);
if (client == NULL) {
ldif_import_done (gci);
@@ -719,9 +718,7 @@ ldif_import (EImport *ei,
source = g_datalist_get_data (&target->data, "ldif-source");
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- book_loaded_cb, gci);
+ e_book_client_connect (source, NULL, book_client_connect_cb, gci);
}
static void
diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c
index b7ee8660ca..09778b5f21 100644
--- a/addressbook/importers/evolution-vcard-importer.c
+++ b/addressbook/importers/evolution-vcard-importer.c
@@ -491,15 +491,14 @@ vcard_import_done (VCardImporter *gci)
}
static void
-book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
VCardImporter *gci = user_data;
- EClient *client = NULL;
+ EClient *client;
- e_client_utils_open_new_finish (source, result, &client, NULL);
+ client = e_book_client_connect_finish (result, NULL);
if (client == NULL) {
vcard_import_done (gci);
@@ -579,9 +578,7 @@ vcard_import (EImport *ei,
source = g_datalist_get_data (&target->data, "vcard-source");
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- book_loaded_cb, gci);
+ e_book_client_connect (source, NULL, book_client_connect_cb, gci);
}
static void
diff --git a/addressbook/tools/evolution-addressbook-export-list-cards.c b/addressbook/tools/evolution-addressbook-export-list-cards.c
index 977fd9cac4..eee2fe92b7 100644
--- a/addressbook/tools/evolution-addressbook-export-list-cards.c
+++ b/addressbook/tools/evolution-addressbook-export-list-cards.c
@@ -771,6 +771,7 @@ guint
action_list_cards_init (ESourceRegistry *registry,
ActionContext *p_actctx)
{
+ EClient *client;
EBookClient *book_client;
EBookQuery *query;
ESource *source;
@@ -788,12 +789,14 @@ action_list_cards_init (ESourceRegistry *registry,
else
source = e_source_registry_ref_default_address_book (registry);
- book_client = e_book_client_new (source, &error);
+ client = e_book_client_connect_sync (source, NULL, &error);
g_object_unref (source);
- if (book_client != NULL)
- e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error);
+ /* Sanity check. */
+ g_return_val_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)), FAILED);
if (error != NULL) {
g_warning (
@@ -801,13 +804,11 @@ action_list_cards_init (ESourceRegistry *registry,
p_actctx->action_list_cards.addressbook_source_uid ?
p_actctx->action_list_cards.addressbook_source_uid :
"'default'", error->message);
- if (book_client != NULL)
- g_object_unref (book_client);
g_error_free (error);
exit (-1);
}
- g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), FAILED);
+ book_client = E_BOOK_CLIENT (client);
query = e_book_query_any_field_contains ("");
query_str = e_book_query_to_string (query);
diff --git a/addressbook/tools/evolution-addressbook-export-list-folders.c b/addressbook/tools/evolution-addressbook-export-list-folders.c
index bfaf110cb9..29c44dbeba 100644
--- a/addressbook/tools/evolution-addressbook-export-list-folders.c
+++ b/addressbook/tools/evolution-addressbook-export-list-folders.c
@@ -52,6 +52,7 @@ action_list_folders_init (ESourceRegistry *registry,
list = e_source_registry_list_sources (registry, extension_name);
for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ EClient *client;
EBookClient *book_client;
EBookQuery *query;
ESource *source;
@@ -63,23 +64,24 @@ action_list_folders_init (ESourceRegistry *registry,
source = E_SOURCE (iter->data);
- book_client = e_book_client_new (source, &error);
+ client = e_book_client_connect_sync (source, NULL, &error);
- if (book_client != NULL)
- e_client_open_sync (
- E_CLIENT (book_client), TRUE, NULL, &error);
+ /* Sanity check. */
+ g_return_val_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)), FAILED);
if (error != NULL) {
g_warning (
_("Failed to open client '%s': %s"),
e_source_get_display_name (source),
error->message);
- if (book_client != NULL)
- g_object_unref (book_client);
g_error_free (error);
continue;
}
+ book_client = E_BOOK_CLIENT (client);
+
query = e_book_query_any_field_contains ("");
query_str = e_book_query_to_string (query);
e_book_query_unref (query);
diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c
index 161d848ce6..d7c0941c69 100644
--- a/addressbook/util/eab-book-util.c
+++ b/addressbook/util/eab-book-util.c
@@ -150,21 +150,24 @@ eab_contact_list_to_string (const GSList *contacts)
}
gboolean
-eab_book_and_contact_list_from_string (ESourceRegistry *registry,
- const gchar *str,
- EBookClient **book_client,
- GSList **contacts)
+eab_source_and_contact_list_from_string (ESourceRegistry *registry,
+ const gchar *str,
+ ESource **out_source,
+ GSList **out_contacts)
{
ESource *source;
const gchar *s0, *s1;
gchar *uid;
+ gboolean success = FALSE;
g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
g_return_val_if_fail (str != NULL, FALSE);
- g_return_val_if_fail (book_client != NULL, FALSE);
- g_return_val_if_fail (contacts != NULL, FALSE);
- *contacts = eab_contact_list_from_string (str);
+ if (out_source != NULL)
+ *out_source = NULL; /* in case we fail */
+
+ if (out_contacts != NULL)
+ *out_contacts = NULL; /* in case we fail */
if (!strncmp (str, "Book: ", 6)) {
s0 = str + 6;
@@ -177,22 +180,23 @@ eab_book_and_contact_list_from_string (ESourceRegistry *registry,
s1 = NULL;
}
- if (!s0 || !s1) {
- *book_client = NULL;
+ if (!s0 || !s1)
return FALSE;
- }
uid = g_strndup (s0, s1 - s0);
source = e_source_registry_ref_source (registry, uid);
if (source != NULL) {
- *book_client = e_book_client_new (source, NULL);
+ if (out_source != NULL)
+ *out_source = g_object_ref (source);
g_object_unref (source);
- } else {
- *book_client = NULL;
+ success = TRUE;
}
g_free (uid);
- return (*book_client != NULL);
+ if (success && out_contacts != NULL)
+ *out_contacts = eab_contact_list_from_string (str);
+
+ return success;
}
gchar *
diff --git a/addressbook/util/eab-book-util.h b/addressbook/util/eab-book-util.h
index 45602c2547..559aa79714 100644
--- a/addressbook/util/eab-book-util.h
+++ b/addressbook/util/eab-book-util.h
@@ -31,11 +31,11 @@ G_BEGIN_DECLS
GSList * eab_contact_list_from_string (const gchar *str);
gchar * eab_contact_list_to_string (const GSList *contacts);
-gboolean eab_book_and_contact_list_from_string
+gboolean eab_source_and_contact_list_from_string
(ESourceRegistry *registry,
const gchar *str,
- EBookClient **book_client,
- GSList **contacts);
+ ESource **out_source,
+ GSList **out_contacts);
gchar * eab_book_and_contact_list_to_string
(EBookClient *book_client,
const GSList *contacts);
diff --git a/e-util/e-name-selector-dialog.c b/e-util/e-name-selector-dialog.c
index 0a647637a8..36b426b0f5 100644
--- a/e-util/e-name-selector-dialog.c
+++ b/e-util/e-name-selector-dialog.c
@@ -36,7 +36,6 @@
#include "e-source-combo-box.h"
#include "e-destination-store.h"
#include "e-contact-store.h"
-#include "e-client-utils.h"
#include "e-name-selector-dialog.h"
#include "e-name-selector-entry.h"
@@ -1134,21 +1133,25 @@ stop_client_view_cb (EContactStore *store,
}
static void
-book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ENameSelectorDialog *name_selector_dialog = user_data;
- EClient *client = NULL;
+ EClient *client;
EBookClient *book_client;
EContactStore *store;
ENameSelectorModel *model;
GError *error = NULL;
- e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
@@ -1162,7 +1165,6 @@ book_loaded_cb (GObject *source_object,
name_selector_dialog->priv->status_label, message);
g_free (message);
- g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
@@ -1204,10 +1206,11 @@ source_changed (ENameSelectorDialog *name_selector_dialog,
cancellable = g_cancellable_new ();
name_selector_dialog->priv->cancellable = cancellable;
- /* Start loading selected book */
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, cancellable,
- book_loaded_cb, g_object_ref (name_selector_dialog));
+ /* Connect to the selected book. */
+ e_book_client_connect (
+ source, cancellable,
+ book_client_connect_cb,
+ g_object_ref (name_selector_dialog));
g_object_unref (source);
}
diff --git a/e-util/e-name-selector-entry.c b/e-util/e-name-selector-entry.c
index 45038c0fee..58c7b391fd 100644
--- a/e-util/e-name-selector-entry.c
+++ b/e-util/e-name-selector-entry.c
@@ -28,7 +28,6 @@
#include <camel/camel.h>
#include <libebackend/libebackend.h>
-#include "e-client-utils.h"
#include "e-name-selector-entry.h"
#define E_NAME_SELECTOR_ENTRY_GET_PRIVATE(obj) \
@@ -2206,27 +2205,29 @@ setup_contact_store (ENameSelectorEntry *name_selector_entry)
}
static void
-book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
EContactStore *contact_store = user_data;
- ESource *source = E_SOURCE (source_object);
EBookClient *book_client;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
if (error != NULL) {
g_warning ("%s", error->message);
- g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
@@ -2287,9 +2288,10 @@ setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
&name_selector_entry->priv->cancellables,
cancellable);
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, cancellable,
- book_loaded_cb, g_object_ref (contact_store));
+ e_book_client_connect (
+ source, cancellable,
+ book_client_connect_cb,
+ g_object_ref (contact_store));
}
g_list_free_full (list, (GDestroyNotify) g_object_unref);
diff --git a/e-util/e-name-selector.c b/e-util/e-name-selector.c
index a94b6ff5f3..66d93512d0 100644
--- a/e-util/e-name-selector.c
+++ b/e-util/e-name-selector.c
@@ -32,7 +32,6 @@
#include "e-name-selector.h"
-#include "e-client-utils.h"
#include "e-contact-store.h"
#include "e-destination-store.h"
@@ -91,20 +90,25 @@ reset_pointer_cb (gpointer data,
}
static void
-name_selector_book_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+name_selector_book_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ENameSelector *name_selector = user_data;
ESource *source = E_SOURCE (source_object);
EBookClient *book_client;
- EClient *client = NULL;
+ EClient *client;
GArray *sections;
SourceBook source_book;
guint ii;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE)
@@ -186,10 +190,9 @@ e_name_selector_load_books (ENameSelector *name_selector)
if (!e_source_autocomplete_get_include_me (extension))
continue;
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- TRUE, name_selector->priv->cancellable,
- name_selector_book_loaded_cb,
+ e_book_client_connect (
+ source, name_selector->priv->cancellable,
+ name_selector_book_client_connect_cb,
g_object_ref (name_selector));
}
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index 750e8cce51..5e9a6db853 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -285,80 +285,6 @@ struct TryOpenEBookStruct {
gboolean result;
};
-static void
-try_open_book_client_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer closure)
-{
- EBookClient *book_client = E_BOOK_CLIENT (source_object);
- struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *) closure;
- GError *error = NULL;
-
- if (!data)
- return;
-
- e_client_open_finish (E_CLIENT (book_client), result, &error);
-
- data->result = error == NULL;
-
- if (!data->result) {
- g_clear_error (data->error);
- g_propagate_error (data->error, error);
- }
-
- e_flag_set (data->flag);
-}
-
-/*
- * try_open_book_client:
- * Tries to open address book asynchronously, but acts as synchronous.
- * The advantage is it checks periodically whether the camel_operation
- * has been canceled or not, and if so, then stops immediately, with
- * result FALSE. Otherwise returns same as e_client_open()
- */
-static gboolean
-try_open_book_client (EBookClient *book_client,
- gboolean only_if_exists,
- GCancellable *cancellable,
- GError **error)
-{
- struct TryOpenEBookStruct data;
- gboolean canceled = FALSE;
- EFlag *flag = e_flag_new ();
-
- data.error = error;
- data.flag = flag;
- data.result = FALSE;
-
- e_client_open (
- E_CLIENT (book_client), only_if_exists,
- cancellable, try_open_book_client_cb, &data);
-
- while (canceled = g_cancellable_is_cancelled (cancellable),
- !canceled && !e_flag_is_set (flag)) {
- gint64 end_time;
-
- /* waits 250ms */
- end_time = g_get_monotonic_time () + (G_TIME_SPAN_SECOND / 4);
-
- e_flag_wait_until (flag, end_time);
- }
-
- if (canceled) {
- g_cancellable_cancel (cancellable);
-
- g_clear_error (error);
- g_propagate_error (
- error, e_client_error_create (
- E_CLIENT_ERROR_CANCELLED, NULL));
- }
-
- e_flag_wait (flag);
- e_flag_free (flag);
-
- return data.result && (!error || !*error);
-}
-
extern gint camel_application_is_exiting;
#define NOT_FOUND_BOOK (GINT_TO_POINTER (1))
@@ -517,7 +443,11 @@ search_address_in_addressbooks (ESourceRegistry *registry,
book_client = g_hash_table_lookup (emu_books_hash, uid);
if (!book_client) {
- book_client = e_book_client_new (source, &err);
+ /* FIXME This blocks, but this entire function is
+ * in desperate need of a rewrite. This is
+ * horribly convoluted, even for Evolution! */
+ book_client = (EBookClient *)
+ e_book_client_connect_sync (source, NULL, &err);
if (book_client == NULL) {
if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
@@ -539,7 +469,7 @@ search_address_in_addressbooks (ESourceRegistry *registry,
err->message);
}
g_clear_error (&err);
- } else if (!stop && !try_open_book_client (book_client, TRUE, cancellable, &err)) {
+ } else if (!stop) {
g_object_unref (book_client);
book_client = NULL;
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index f0e33eae06..c37d3bd809 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -174,7 +174,7 @@ import_contacts (void)
{
EShell *shell;
ESourceRegistry *registry;
- EBookClient *book_client = NULL;
+ EClient *client = NULL;
GList *list;
gchar *name;
GString *line;
@@ -201,14 +201,11 @@ import_contacts (void)
ESource *source;
source = E_SOURCE (list->data);
- book_client = e_book_client_new (source, &error);
+ client = e_book_client_connect_sync (source, NULL, &error);
}
g_list_free_full (list, (GDestroyNotify) g_object_unref);
- if (book_client != NULL)
- e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error);
-
if (error != NULL) {
g_warning (
"%s: Failed to open book client: %s",
@@ -235,13 +232,13 @@ import_contacts (void)
g_string_truncate (line, len);
}
- import_contact (book_client, line->str);
+ import_contact (E_BOOK_CLIENT (client), line->str);
offset = 0;
}
g_string_free (line, TRUE);
fclose (fp);
- g_object_unref (book_client);
+ g_object_unref (client);
}
static gchar *
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index 3886c7f400..3cc5c9d722 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -93,18 +93,21 @@ book_shell_backend_new_contact_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
EShell *shell = user_data;
- EClient *client = NULL;
+ EClient *client;
EContact *contact;
EABEditor *editor;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* XXX Handle errors better. */
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open book: %s",
G_STRFUNC, error->message);
@@ -112,8 +115,6 @@ book_shell_backend_new_contact_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
contact = e_contact_new ();
editor = e_contact_editor_new (
@@ -133,18 +134,21 @@ book_shell_backend_new_contact_list_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
EShell *shell = user_data;
- EClient *client = NULL;
+ EClient *client;
EContact *contact;
EABEditor *editor;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* XXX Handle errors better. */
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open book: %s",
G_STRFUNC, error->message);
@@ -152,8 +156,6 @@ book_shell_backend_new_contact_list_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
contact = e_contact_new ();
editor = e_contact_list_editor_new (
@@ -215,13 +217,13 @@ action_contact_new_cb (GtkAction *action,
/* Use a callback function appropriate for the action. */
action_name = gtk_action_get_name (action);
if (strcmp (action_name, "contact-new") == 0)
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_book_client_connect (
+ source, NULL,
book_shell_backend_new_contact_cb,
g_object_ref (shell));
if (strcmp (action_name, "contact-new-list") == 0)
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_book_client_connect (
+ source, NULL,
book_shell_backend_new_contact_list_cb,
g_object_ref (shell));
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index cbe2ef4e32..e4e31039da 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -234,7 +234,7 @@ map_window_show_contact_editor_cb (EContactMapWindow *window,
EBookShellSidebar *book_shell_sidebar;
ESource *source;
ESourceSelector *selector;
- EBookClient *book_client;
+ EClient *client;
EContact *contact;
EABEditor *editor;
GError *error = NULL;
@@ -244,26 +244,32 @@ map_window_show_contact_editor_cb (EContactMapWindow *window,
source = e_source_selector_ref_primary_selection (selector);
g_return_if_fail (source != NULL);
- book_client = e_book_client_new (source, &error);
+ client = e_book_client_connect_sync (source, NULL, &error);
+
g_object_unref (source);
- if (error) {
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
+ if (error != NULL) {
g_warning ("Error loading addressbook: %s", error->message);
g_error_free (error);
- if (book_client)
- g_object_unref (book_client);
return;
}
- e_book_client_get_contact_sync (book_client, contact_uid, &contact, NULL, &error);
- if (error) {
+ e_book_client_get_contact_sync (
+ E_BOOK_CLIENT (client), contact_uid, &contact, NULL, &error);
+ if (error != NULL) {
g_warning ("Error getting contact from addressbook: %s", error->message);
g_error_free (error);
- g_object_unref (book_client);
+ g_object_unref (client);
return;
}
- editor = e_contact_editor_new (shell, book_client, contact, FALSE, TRUE);
+ editor = e_contact_editor_new (
+ shell, E_BOOK_CLIENT (client), contact, FALSE, TRUE);
g_signal_connect (
editor, "contact-modified",
@@ -273,7 +279,7 @@ map_window_show_contact_editor_cb (EContactMapWindow *window,
G_CALLBACK (g_object_unref), editor);
eab_editor_show (editor);
- g_object_unref (book_client);
+ g_object_unref (client);
}
#endif
@@ -287,7 +293,7 @@ action_address_book_map_cb (GtkAction *action,
EBookShellSidebar *book_shell_sidebar;
ESource *source;
ESourceSelector *selector;
- EBookClient *book_client;
+ EClient *client;
GError *error = NULL;
book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
@@ -295,9 +301,15 @@ action_address_book_map_cb (GtkAction *action,
source = e_source_selector_ref_primary_selection (selector);
g_return_if_fail (source != NULL);
- book_client = e_book_client_new (source, &error);
+ client = e_book_client_connect_sync (source, NULL, &error);
+
g_object_unref (source);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
if (error != NULL) {
g_warning ("Error loading addressbook: %s", error->message);
g_error_free (error);
@@ -305,7 +317,8 @@ action_address_book_map_cb (GtkAction *action,
}
map_window = e_contact_map_window_new ();
- e_contact_map_window_load_addressbook (map_window, book_client);
+ e_contact_map_window_load_addressbook (
+ map_window, E_BOOK_CLIENT (client));
/* Free the map_window automatically when it is closed */
g_signal_connect_swapped (
@@ -317,7 +330,7 @@ action_address_book_map_cb (GtkAction *action,
gtk_widget_show_all (GTK_WIDGET (map_window));
- g_object_unref (book_client);
+ g_object_unref (client);
#endif
}
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index 884477f451..d33054e36f 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -205,21 +205,24 @@ model_query_changed_cb (EBookShellView *book_shell_view,
}
static void
-book_shell_view_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+book_shell_view_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
EAddressbookView *view = user_data;
- EClient *client = NULL;
+ EClient *client;
EAddressbookModel *model;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* Ignore cancellations. */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
@@ -227,9 +230,9 @@ book_shell_view_loaded_cb (GObject *source_object,
EShellView *shell_view;
EShellContent *shell_content;
EAlertSink *alert_sink;
+ ESource *source;
- g_warn_if_fail (client == NULL);
-
+ source = e_addressbook_view_get_source (view);
shell_view = e_addressbook_view_get_shell_view (view);
shell_content = e_shell_view_get_shell_content (shell_view);
alert_sink = E_ALERT_SINK (shell_content);
@@ -240,8 +243,6 @@ book_shell_view_loaded_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
model = e_addressbook_view_get_model (view);
e_addressbook_model_set_client (model, E_BOOK_CLIENT (client));
e_addressbook_model_force_folder_bar_message (model);
@@ -287,10 +288,9 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
if (e_addressbook_model_get_client (model) == NULL)
/* XXX No way to cancel this? */
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, NULL,
- book_shell_view_loaded_cb,
+ e_book_client_connect (
+ source, NULL,
+ book_shell_view_client_connect_cb,
g_object_ref (view));
} else {
@@ -334,9 +334,10 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
model = e_addressbook_view_get_model (view);
/* XXX No way to cancel this? */
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- book_shell_view_loaded_cb, g_object_ref (view));
+ e_book_client_connect (
+ source, NULL,
+ book_shell_view_client_connect_cb,
+ g_object_ref (view));
g_signal_connect_object (
model, "contact-changed",
diff --git a/modules/vcard-inline/e-mail-parser-vcard-inline.c b/modules/vcard-inline/e-mail-parser-vcard-inline.c
index c1064dd28f..2580059b94 100644
--- a/modules/vcard-inline/e-mail-parser-vcard-inline.c
+++ b/modules/vcard-inline/e-mail-parser-vcard-inline.c
@@ -93,21 +93,26 @@ mail_part_vcard_inline_free (EMailPart *mail_part)
}
static void
-client_loaded_cb (ESource *source,
- GAsyncResult *result,
- GSList *contact_list)
+client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ GSList *contact_list = user_data;
EShell *shell;
- EClient *client = NULL;
+ EClient *client;
EBookClient *book_client;
ESourceRegistry *registry;
GSList *iter;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open book client: %s",
G_STRFUNC, error->message);
@@ -115,8 +120,6 @@ client_loaded_cb (ESource *source,
goto exit;
}
- g_return_if_fail (E_IS_BOOK_CLIENT (client));
-
book_client = E_BOOK_CLIENT (client);
shell = e_shell_get_default ();
@@ -178,10 +181,8 @@ save_vcard_cb (WebKitDOMEventTarget *button,
vcard_part->contact_list,
(GCopyFunc) g_object_ref, NULL);
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, NULL, (GAsyncReadyCallback) client_loaded_cb,
- contact_list);
+ e_book_client_connect (
+ source, NULL, client_connect_cb, contact_list);
}
static void
diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c
index 7187f6e376..568bd90733 100644
--- a/plugins/bbdb/bbdb.c
+++ b/plugins/bbdb/bbdb.c
@@ -137,7 +137,7 @@ bbdb_do_in_thread (gpointer data)
EBookClient *client = data;
/* Open the addressbook */
- if (!client || !bbdb_open_book_client (client)) {
+ if (client == NULL) {
G_LOCK (todo);
g_slist_foreach (todo, (GFunc) free_todo_struct, NULL);
@@ -370,7 +370,7 @@ bbdb_create_book_client (gint type)
EShell *shell;
ESource *source = NULL;
ESourceRegistry *registry;
- EBookClient *client = NULL;
+ EClient *client = NULL;
GSettings *settings;
gboolean enable = TRUE;
gchar *uid;
@@ -406,7 +406,7 @@ bbdb_create_book_client (gint type)
if (source == NULL)
source = e_source_registry_ref_builtin_address_book (registry);
- client = e_book_client_new (source, &error);
+ client = e_book_client_connect_sync (source, NULL, &error);
if (client == NULL) {
g_warning (
"bbdb: Failed to get addressbook: %s\n",
@@ -416,29 +416,7 @@ bbdb_create_book_client (gint type)
g_object_unref (source);
- return client;
-}
-
-gboolean
-bbdb_open_book_client (EBookClient *client)
-{
- GError *error = NULL;
-
- if (!client)
- return FALSE;
-
- e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error);
-
- if (error != NULL) {
- g_warning (
- "bbdb: failed to open addressbook: %s",
- error->message);
- g_object_unref (client);
- g_error_free (error);
- return FALSE;
- }
-
- return TRUE;
+ return (EBookClient *) client;
}
gboolean
diff --git a/plugins/bbdb/bbdb.h b/plugins/bbdb/bbdb.h
index 8681592921..6759921192 100644
--- a/plugins/bbdb/bbdb.h
+++ b/plugins/bbdb/bbdb.h
@@ -44,10 +44,6 @@
* this function should be called in a main thread. */
EBookClient *bbdb_create_book_client (gint type);
-/* opens an EBookClient. Returns false if it fails, and unrefs the book too;
- * this function can be called in any thread */
-gboolean bbdb_open_book_client (EBookClient *client);
-
gboolean bbdb_check_gaim_enabled (void);
/* gaimbuddies.c */
diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c
index 228eae2613..9ef3db263b 100644
--- a/plugins/bbdb/gaimbuddies.c
+++ b/plugins/bbdb/gaimbuddies.c
@@ -199,18 +199,6 @@ bbdb_sync_buddy_list_in_thread (gpointer data)
g_return_val_if_fail (std != NULL, NULL);
- if (!bbdb_open_book_client (std->client)) {
- /* client got freed in bbdb_open_book_client on a failure */
- free_buddy_list (std->blist);
- g_free (std);
-
- G_LOCK (syncing);
- syncing = FALSE;
- G_UNLOCK (syncing);
-
- return NULL;
- }
-
printf ("bbdb: Synchronizing buddy list to contacts...\n");
/* Walk the buddy list */
for (l = std->blist; l != NULL; l = l->next) {
diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c
index e20d09a958..0389d25bb6 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -616,20 +616,24 @@ org_credativ_evolution_readpst_getwidget (EImport *ei,
}
static void
-client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
PstImporter *m = user_data;
+ EClient *client;
GError *error = NULL;
- EClient *client = NULL;
g_return_if_fail (result != NULL);
g_return_if_fail (m != NULL);
g_return_if_fail (m->waiting_open > 0);
- if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
- client = NULL;
+ client = e_book_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error)
g_debug ("%s: Failed to open client: %s", G_STRFUNC, error->message);
@@ -681,9 +685,7 @@ open_client (PstImporter *m,
m->waiting_open++;
- e_client_utils_open_new (
- source, source_type, FALSE, m->cancellable,
- client_opened_cb, m);
+ e_book_client_connect (source, m->cancellable, client_connect_cb, m);
g_object_unref (source);
}