aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-06-14 14:54:20 +0800
committerMilan Crha <mcrha@redhat.com>2011-06-14 14:54:20 +0800
commit38790d8478e906a5c59d0c4a5216f297f305bfeb (patch)
tree0f9a96db2765901f2a27b68c84815a491214ecc1 /modules/addressbook
parent08af0d1f81a4e983bb49d8fb8fe74e670adbb8f6 (diff)
downloadgsoc2013-evolution-38790d8478e906a5c59d0c4a5216f297f305bfeb.tar
gsoc2013-evolution-38790d8478e906a5c59d0c4a5216f297f305bfeb.tar.gz
gsoc2013-evolution-38790d8478e906a5c59d0c4a5216f297f305bfeb.tar.bz2
gsoc2013-evolution-38790d8478e906a5c59d0c4a5216f297f305bfeb.tar.lz
gsoc2013-evolution-38790d8478e906a5c59d0c4a5216f297f305bfeb.tar.xz
gsoc2013-evolution-38790d8478e906a5c59d0c4a5216f297f305bfeb.tar.zst
gsoc2013-evolution-38790d8478e906a5c59d0c4a5216f297f305bfeb.zip
Do not use deprecated EBook/ECal API
Diffstat (limited to 'modules/addressbook')
-rw-r--r--modules/addressbook/e-book-shell-backend.c98
-rw-r--r--modules/addressbook/e-book-shell-content.c2
-rw-r--r--modules/addressbook/e-book-shell-migrate.c4
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c68
-rw-r--r--modules/addressbook/e-book-shell-view-private.c38
-rw-r--r--modules/addressbook/e-book-shell-view-private.h4
-rw-r--r--modules/addressbook/eab-composer-util.c12
-rw-r--r--modules/addressbook/eab-composer-util.h4
8 files changed, 118 insertions, 112 deletions
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index f9dba4cfee..e697e89990 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -27,11 +27,11 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-group.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
#include "e-util/e-import.h"
#include "shell/e-shell.h"
@@ -79,14 +79,16 @@ book_shell_backend_ensure_sources (EShellBackend *shell_backend)
ESource *personal;
GSList *sources, *iter;
const gchar *name;
+ GError *error = NULL;
on_this_computer = NULL;
personal = NULL;
priv = E_BOOK_SHELL_BACKEND (shell_backend)->priv;
- if (!e_book_get_addressbooks (&priv->source_list, NULL)) {
- g_warning ("Could not get addressbook sources from GConf!");
+ if (!e_book_client_get_sources (&priv->source_list, &error)) {
+ g_warning ("Could not get addressbook sources: %s", error ? error->message : "Unknown error");
+ g_clear_error (&error);
return;
}
@@ -154,60 +156,68 @@ book_shell_backend_init_importers (void)
}
static void
-book_shell_backend_new_contact_cb (ESource *source,
- GAsyncResult *result,
- EShell *shell)
+book_shell_backend_new_contact_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
- EContact *contact;
- EABEditor *editor;
+ EShell *shell = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
- book = e_load_book_source_finish (source, result, NULL);
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
/* XXX Handle errors better. */
- if (book == NULL)
- goto exit;
+ if (client == NULL) {
+ g_debug ("%s: Failed to open book: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ g_clear_error (&error);
+ } else {
+ EBookClient *book_client = E_BOOK_CLIENT (client);
+ EContact *contact;
+ EABEditor *editor;
- contact = e_contact_new ();
+ contact = e_contact_new ();
- editor = e_contact_editor_new (
- shell, book, contact, TRUE, TRUE);
+ editor = e_contact_editor_new (
+ shell, book_client, contact, TRUE, TRUE);
- eab_editor_show (editor);
+ eab_editor_show (editor);
- g_object_unref (contact);
- g_object_unref (book);
+ g_object_unref (contact);
+ g_object_unref (book_client);
+ }
-exit:
g_object_unref (shell);
}
static void
-book_shell_backend_new_contact_list_cb (ESource *source,
- GAsyncResult *result,
- EShell *shell)
+book_shell_backend_new_contact_list_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
- EContact *contact;
- EABEditor *editor;
+ EShell *shell = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
- book = e_load_book_source_finish (source, result, NULL);
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
/* XXX Handle errors better. */
- if (book == NULL)
- goto exit;
+ if (client == NULL) {
+ g_debug ("%s: Failed to open book: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ g_clear_error (&error);
+ } else {
+ EBookClient *book_client = E_BOOK_CLIENT (client);
+ EContact *contact;
+ EABEditor *editor;
- contact = e_contact_new ();
+ contact = e_contact_new ();
- editor = e_contact_list_editor_new (
- shell, book, contact, TRUE, TRUE);
+ editor = e_contact_list_editor_new (
+ shell, book_client, contact, TRUE, TRUE);
- eab_editor_show (editor);
+ eab_editor_show (editor);
- g_object_unref (contact);
- g_object_unref (book);
+ g_object_unref (contact);
+ g_object_unref (book_client);
+ }
-exit:
g_object_unref (shell);
}
@@ -249,17 +259,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_load_book_source_async (
- source, GTK_WINDOW (shell_window),
- NULL, (GAsyncReadyCallback)
- book_shell_backend_new_contact_cb,
- g_object_ref (shell));
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
+ book_shell_backend_new_contact_cb, g_object_ref (shell));
if (strcmp (action_name, "contact-new-list") == 0)
- e_load_book_source_async (
- source, GTK_WINDOW (shell_window),
- NULL, (GAsyncReadyCallback)
- book_shell_backend_new_contact_list_cb,
- g_object_ref (shell));
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
+ book_shell_backend_new_contact_list_cb, g_object_ref (shell));
g_object_unref (source_list);
}
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index 82e1f297d9..e8f2afd83b 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -66,7 +66,7 @@ book_shell_content_send_message_cb (EBookShellContent *book_shell_content,
EShellContent *shell_content;
EShellWindow *shell_window;
EShellView *shell_view;
- GList node = { destination, NULL, NULL };
+ GSList node = { destination, NULL };
shell_content = E_SHELL_CONTENT (book_shell_content);
shell_view = e_shell_content_get_shell_view (shell_content);
diff --git a/modules/addressbook/e-book-shell-migrate.c b/modules/addressbook/e-book-shell-migrate.c
index df27f39e47..a88219348a 100644
--- a/modules/addressbook/e-book-shell-migrate.c
+++ b/modules/addressbook/e-book-shell-migrate.c
@@ -38,7 +38,7 @@
#include <gtk/gtk.h>
#include <libebook/e-destination.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <glib/gi18n.h>
#include <libedataserver/e-xml-utils.h>
@@ -169,7 +169,7 @@ migration_context_new (const gchar *data_dir)
(GDestroyNotify) g_free,
(GDestroyNotify) g_free);
- e_book_get_addressbooks (&context->source_list, NULL);
+ e_book_client_get_sources (&context->source_list, NULL);
context->data_dir = data_dir;
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 029bdd783d..52d8243ead 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -61,7 +61,7 @@ action_address_book_delete_cb (GtkAction *action,
ESourceSelector *selector;
ESourceGroup *source_group;
ESourceList *source_list;
- EBook *book;
+ EBookClient *book;
gint response;
GError *error = NULL;
@@ -84,14 +84,14 @@ action_address_book_delete_cb (GtkAction *action,
if (response != GTK_RESPONSE_YES)
return;
- book = e_book_new (source, &error);
+ book = e_book_client_new (source, &error);
if (error != NULL) {
g_warning ("Error removing addressbook: %s", error->message);
g_error_free (error);
return;
}
- if (!e_book_remove (book, NULL)) {
+ if (!e_client_remove_sync (E_CLIENT (book), NULL, NULL)) {
e_alert_run_dialog_for_args (
GTK_WINDOW (shell_window),
"addressbook:remove-addressbook", NULL);
@@ -249,7 +249,7 @@ map_window_show_contact_editor_cb (EContactMapWindow *window,
EBookShellSidebar *book_shell_sidebar;
ESource *source;
ESourceSelector *selector;
- EBook *book;
+ EBookClient *book_client;
EContact *contact;
EABEditor *editor;
GError *error = NULL;
@@ -259,23 +259,24 @@ map_window_show_contact_editor_cb (EContactMapWindow *window,
source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (source != NULL);
- book = e_book_new (source, &error);
+ book_client = e_book_client_new (source, &error);
if (error) {
g_warning ("Error loading addressbook: %s", error->message);
g_error_free (error);
- g_object_unref (book);
+ if (book_client)
+ g_object_unref (book_client);
return;
}
- e_book_get_contact (book, contact_uid, &contact, &error);
+ e_book_client_get_contact_sync (book_client, contact_uid, &contact, NULL, &error);
if (error) {
g_warning ("Error getting contact from addressbook: %s", error->message);
g_error_free (error);
- g_object_unref (book);
+ g_object_unref (book_client);
return;
}
- editor = e_contact_editor_new (shell, book, contact, FALSE, TRUE);
+ editor = e_contact_editor_new (shell, book_client, contact, FALSE, TRUE);
g_signal_connect (editor, "contact-modified",
G_CALLBACK (contact_editor_contact_modified_cb), window);
@@ -283,7 +284,7 @@ map_window_show_contact_editor_cb (EContactMapWindow *window,
G_CALLBACK (g_object_unref), editor);
eab_editor_show (editor);
- g_object_unref (book);
+ g_object_unref (book_client);
}
#endif
@@ -297,7 +298,7 @@ action_address_book_map_cb (GtkAction *action,
EBookShellSidebar *book_shell_sidebar;
ESource *source;
ESourceSelector *selector;
- EBook *book;
+ EBookClient *book_client;
GError *error = NULL;
book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
@@ -305,7 +306,7 @@ action_address_book_map_cb (GtkAction *action,
source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (source != NULL);
- book = e_book_new (source, &error);
+ book_client = e_book_client_new (source, &error);
if (error != NULL) {
g_warning ("Error loading addressbook: %s", error->message);
g_error_free (error);
@@ -313,7 +314,7 @@ action_address_book_map_cb (GtkAction *action,
}
map_window = e_contact_map_window_new ();
- e_contact_map_window_load_addressbook (map_window, book);
+ e_contact_map_window_load_addressbook (map_window, book_client);
/* Free the map_window automatically when it is closed */
g_signal_connect_swapped (GTK_WIDGET (map_window), "hide",
@@ -323,7 +324,7 @@ action_address_book_map_cb (GtkAction *action,
gtk_widget_show_all (GTK_WIDGET (map_window));
- g_object_unref (book);
+ g_object_unref (book_client);
#endif
}
@@ -353,8 +354,8 @@ action_address_book_save_as_cb (GtkAction *action,
EAddressbookView *view;
EActivity *activity;
EBookQuery *query;
- EBook *book;
- GList *list = NULL;
+ EBookClient *book;
+ GSList *list = NULL;
GFile *file;
gchar *string;
@@ -368,12 +369,15 @@ action_address_book_save_as_cb (GtkAction *action,
g_return_if_fail (view != NULL);
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book = e_addressbook_model_get_client (model);
query = e_book_query_any_field_contains ("");
- e_book_get_contacts (book, query, &list, NULL);
+ string = e_book_query_to_string (query);
e_book_query_unref (query);
+ e_book_client_get_contacts_sync (book, string, &list, NULL, NULL);
+ g_free (string);
+
if (list == NULL)
goto exit;
@@ -415,8 +419,7 @@ action_address_book_save_as_cb (GtkAction *action,
g_object_unref (file);
exit:
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ e_client_util_free_object_slist (list);
}
static void
@@ -483,7 +486,7 @@ action_contact_forward_cb (GtkAction *action,
EShellWindow *shell_window;
EBookShellContent *book_shell_content;
EAddressbookView *view;
- GList *list, *iter;
+ GSList *list, *iter;
shell_view = E_SHELL_VIEW (book_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -510,8 +513,7 @@ action_contact_forward_cb (GtkAction *action,
eab_send_as_attachment (shell, list);
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ e_client_util_free_object_slist (list);
}
static void
@@ -540,7 +542,7 @@ action_contact_new_cb (GtkAction *action,
EAddressbookModel *model;
EContact *contact;
EABEditor *editor;
- EBook *book;
+ EBookClient *book;
shell_view = E_SHELL_VIEW (book_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -551,7 +553,7 @@ action_contact_new_cb (GtkAction *action,
g_return_if_fail (view != NULL);
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book = e_addressbook_model_get_client (model);
g_return_if_fail (book != NULL);
contact = e_contact_new ();
@@ -572,7 +574,7 @@ action_contact_new_list_cb (GtkAction *action,
EAddressbookModel *model;
EContact *contact;
EABEditor *editor;
- EBook *book;
+ EBookClient *book;
shell_view = E_SHELL_VIEW (book_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -583,7 +585,7 @@ action_contact_new_list_cb (GtkAction *action,
g_return_if_fail (view != NULL);
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book = e_addressbook_model_get_client (model);
g_return_if_fail (book != NULL);
contact = e_contact_new ();
@@ -657,7 +659,7 @@ action_contact_save_as_cb (GtkAction *action,
EBookShellContent *book_shell_content;
EAddressbookView *view;
EActivity *activity;
- GList *list;
+ GSList *list;
GFile *file;
gchar *string;
@@ -712,9 +714,8 @@ action_contact_save_as_cb (GtkAction *action,
g_object_unref (file);
-exit:
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ exit:
+ e_client_util_free_object_slist (list);
}
static void
@@ -726,7 +727,7 @@ action_contact_send_message_cb (GtkAction *action,
EShellWindow *shell_window;
EBookShellContent *book_shell_content;
EAddressbookView *view;
- GList *list, *iter;
+ GSList *list, *iter;
shell_view = E_SHELL_VIEW (book_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -753,8 +754,7 @@ action_contact_send_message_cb (GtkAction *action,
eab_send_as_to (shell, list);
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ e_client_util_free_object_slist (list);
}
static void
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index 8a05d26282..c9a233df9f 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -41,7 +41,7 @@ open_contact (EBookShellView *book_shell_view,
EShellWindow *shell_window;
EAddressbookModel *model;
EABEditor *editor;
- EBook *book;
+ EBookClient *book;
gboolean editable;
shell_view = E_SHELL_VIEW (book_shell_view);
@@ -49,7 +49,7 @@ open_contact (EBookShellView *book_shell_view,
shell = e_shell_window_get_shell (shell_window);
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book = e_addressbook_model_get_client (model);
editable = e_addressbook_model_get_editable (model);
if (e_contact_get (contact, E_CONTACT_IS_LIST))
@@ -184,21 +184,25 @@ contacts_removed (EBookShellView *book_shell_view,
}
static void
-book_shell_view_loaded_cb (ESource *source,
- GAsyncResult *result,
- EAddressbookView *view)
+book_shell_view_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
+ ESource *source = E_SOURCE (source_object);
+ EAddressbookView *view = user_data;
+ EClient *client = NULL;
+ EBookClient *book;
GError *error = NULL;
- book = e_load_book_source_finish (source, result, &error);
+ if (!e_client_utils_open_new_finish (source, result, &client, &error))
+ client = NULL;
+
+ book = client ? E_BOOK_CLIENT (client) : NULL;
if (book != NULL) {
EAddressbookModel *model;
g_warn_if_fail (error == NULL);
model = e_addressbook_view_get_model (view);
- e_addressbook_model_set_book (model, book);
+ e_addressbook_model_set_client (model, book);
e_addressbook_model_force_folder_bar_message (model);
} else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
@@ -254,14 +258,11 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
model = e_addressbook_view_get_model (view);
source = e_addressbook_view_get_source (view);
- if (e_addressbook_model_get_book (model) == NULL)
+ if (e_addressbook_model_get_client (model) == NULL)
/* XXX No way to cancel this? */
- e_load_book_source_async (
- source,
- GTK_WINDOW (shell_window),
- NULL, (GAsyncReadyCallback)
- book_shell_view_loaded_cb,
- g_object_ref (view));
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
+ book_shell_view_loaded_cb, g_object_ref (view));
} else {
/* Create a view for this UID. */
@@ -304,10 +305,9 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
model = e_addressbook_view_get_model (view);
/* XXX No way to cancel this? */
- e_load_book_source_async (
- source, GTK_WINDOW (shell_window), NULL,
- (GAsyncReadyCallback) book_shell_view_loaded_cb,
- g_object_ref (view));
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
+ book_shell_view_loaded_cb, g_object_ref (view));
g_signal_connect_object (
model, "contact-changed",
diff --git a/modules/addressbook/e-book-shell-view-private.h b/modules/addressbook/e-book-shell-view-private.h
index 528a34d282..a715d5acdf 100644
--- a/modules/addressbook/e-book-shell-view-private.h
+++ b/modules/addressbook/e-book-shell-view-private.h
@@ -27,10 +27,10 @@
#include <string.h>
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libedataserver/e-categories.h>
#include <libedataserver/e-sexp.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
#include "e-util/e-util.h"
diff --git a/modules/addressbook/eab-composer-util.c b/modules/addressbook/eab-composer-util.c
index 629f5a651a..215dacea05 100644
--- a/modules/addressbook/eab-composer-util.c
+++ b/modules/addressbook/eab-composer-util.c
@@ -33,7 +33,7 @@
void
eab_send_as_to (EShell *shell,
- GList *destinations)
+ GSList *destinations)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
@@ -68,7 +68,7 @@ eab_send_as_to (EShell *shell,
} else
g_ptr_array_add (to_array, destination);
- destinations = g_list_next (destinations);
+ destinations = g_slist_next (destinations);
}
/* Add sentinels to each array. */
@@ -115,12 +115,12 @@ get_email (EContact *contact, EContactField field_id, gchar **to_free)
void
eab_send_as_attachment (EShell *shell,
- GList *destinations)
+ GSList *destinations)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
CamelMimePart *attachment;
- GList *contacts, *iter;
+ GSList *contacts, *iter;
gchar *data;
g_return_if_fail (E_IS_SHELL (shell));
@@ -133,11 +133,11 @@ eab_send_as_attachment (EShell *shell,
attachment = camel_mime_part_new ();
- contacts = g_list_copy (destinations);
+ contacts = g_slist_copy (destinations);
for (iter = contacts; iter != NULL; iter = iter->next)
iter->data = e_destination_get_contact (iter->data);
data = eab_contact_list_to_string (contacts);
- g_list_free (contacts);
+ g_slist_free (contacts);
camel_mime_part_set_content (
attachment, data, strlen (data), "text/x-vcard");
diff --git a/modules/addressbook/eab-composer-util.h b/modules/addressbook/eab-composer-util.h
index a2feb2f999..b8644ab187 100644
--- a/modules/addressbook/eab-composer-util.h
+++ b/modules/addressbook/eab-composer-util.h
@@ -24,9 +24,9 @@
G_BEGIN_DECLS
void eab_send_as_to (EShell *shell,
- GList *destinations);
+ GSList *destinations);
void eab_send_as_attachment (EShell *shell,
- GList *destinations);
+ GSList *destinations);
G_END_DECLS