aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-01-24 03:59:41 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-01-30 21:37:15 +0800
commite583928e0401a4baea4432c5b7e12a1b1eff8c2e (patch)
tree786d3c1b3ed24456d88f3b8c6987755a08f310db /addressbook/gui
parent5125cdac38ced3898bdd59ed29259e4c747374f7 (diff)
downloadgsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar
gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.gz
gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.bz2
gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.lz
gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.xz
gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.tar.zst
gsoc2013-evolution-e583928e0401a4baea4432c5b7e12a1b1eff8c2e.zip
Use e_book_client_connect().
Instead of e_client_utils_open_new() and e_book_client_new().
Diffstat (limited to 'addressbook/gui')
-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
6 files changed, 76 insertions, 82 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);
}
/*