diff options
author | Milan Crha <mcrha@redhat.com> | 2011-06-14 14:54:20 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2011-06-14 14:54:20 +0800 |
commit | 38790d8478e906a5c59d0c4a5216f297f305bfeb (patch) | |
tree | 0f9a96db2765901f2a27b68c84815a491214ecc1 /modules | |
parent | 08af0d1f81a4e983bb49d8fb8fe74e670adbb8f6 (diff) | |
download | gsoc2013-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')
32 files changed, 724 insertions, 727 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 diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c index c1b03874ff..a2932a0d17 100644 --- a/modules/calendar/e-cal-attachment-handler.c +++ b/modules/calendar/e-cal-attachment-handler.c @@ -27,11 +27,10 @@ #include <glib/gi18n.h> #include <libical/ical.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <camel/camel.h> #include <libedataserverui/e-source-selector.h> - -#include "calendar/common/authentication.h" +#include <libedataserverui/e-client-utils.h> typedef struct _ImportContext ImportContext; @@ -40,9 +39,9 @@ struct _ECalAttachmentHandlerPrivate { }; struct _ImportContext { - ECal *client; + ECalClient *client; icalcomponent *component; - ECalSourceType source_type; + ECalClientSourceType source_type; }; static gpointer parent_class; @@ -110,12 +109,13 @@ attachment_handler_get_component (EAttachment *attachment) } static gboolean -attachment_handler_update_objects (ECal *client, +attachment_handler_update_objects (ECalClient *client, icalcomponent *component) { icalcomponent_kind kind; icalcomponent *vcalendar; gboolean success; + GError *error = NULL; kind = icalcomponent_isa (component); @@ -141,7 +141,10 @@ attachment_handler_update_objects (ECal *client, return FALSE; } - success = e_cal_receive_objects (client, vcalendar, NULL); + success = e_cal_client_receive_objects_sync (client, vcalendar, NULL, &error); + if (error) + g_debug ("%s: Failed to receive objects: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); icalcomponent_free (vcalendar); @@ -149,16 +152,23 @@ attachment_handler_update_objects (ECal *client, } static void -attachment_handler_import_event (ECal *client, - const GError *error, - EAttachment *attachment) +attachment_handler_import_event (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EAttachment *attachment = user_data; + EClient *client = NULL; + GError *error = NULL; icalcomponent *component; icalcomponent *subcomponent; icalcompiter iter; - /* FIXME Notify the user somehow. */ - g_return_if_fail (error == NULL); + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; + + if (!client) { + g_debug ("%s: Failed to open '%s': %s", G_STRFUNC, e_source_peek_name (E_SOURCE (source_object)), error ? error->message : "Unknown error"); + g_object_unref (attachment); + return; + } component = attachment_handler_get_component (attachment); g_return_if_fail (component != NULL); @@ -182,23 +192,30 @@ attachment_handler_import_event (ECal *client, } /* XXX Do something with the return value. */ - attachment_handler_update_objects (client, component); + attachment_handler_update_objects (E_CAL_CLIENT (client), component); g_object_unref (attachment); g_object_unref (client); } static void -attachment_handler_import_todo (ECal *client, - const GError *error, - EAttachment *attachment) +attachment_handler_import_todo (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EAttachment *attachment = user_data; + EClient *client = NULL; + GError *error = NULL; icalcomponent *component; icalcomponent *subcomponent; icalcompiter iter; - /* FIXME Notify the user somehow. */ - g_return_if_fail (error == NULL); + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; + + if (!client) { + g_debug ("%s: Failed to open '%s': %s", G_STRFUNC, e_source_peek_name (E_SOURCE (source_object)), error ? error->message : "Unknown error"); + g_object_unref (attachment); + return; + } component = attachment_handler_get_component (attachment); g_return_if_fail (component != NULL); @@ -222,7 +239,7 @@ attachment_handler_import_todo (ECal *client, } /* XXX Do something with the return value. */ - attachment_handler_update_objects (client, component); + attachment_handler_update_objects (E_CAL_CLIENT (client), component); g_object_unref (attachment); g_object_unref (client); @@ -237,27 +254,25 @@ attachment_handler_row_activated_cb (GtkDialog *dialog) static void attachment_handler_run_dialog (GtkWindow *parent, EAttachment *attachment, - ECalSourceType source_type, + ECalClientSourceType source_type, const gchar *title) { GtkWidget *dialog; GtkWidget *container; GtkWidget *widget; - GCallback callback; ESourceSelector *selector; ESourceList *source_list; ESource *source; - ECal *client; icalcomponent *component; GError *error = NULL; component = attachment_handler_get_component (attachment); g_return_if_fail (component != NULL); - e_cal_get_sources (&source_list, source_type, &error); + e_cal_client_get_sources (&source_list, source_type, &error); if (error != NULL) { - g_warning ("%s", error->message); - g_error_free (error); + g_debug ("%s: Faield to get cal sources: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); return; } @@ -309,22 +324,22 @@ attachment_handler_run_dialog (GtkWindow *parent, if (source == NULL) goto exit; - client = e_auth_new_cal_from_source (source, source_type); - if (client == NULL) - goto exit; - - if (source_type == E_CAL_SOURCE_TYPE_EVENT) - callback = G_CALLBACK (attachment_handler_import_event); - else if (source_type == E_CAL_SOURCE_TYPE_TODO) - callback = G_CALLBACK (attachment_handler_import_todo); - else - goto exit; - - g_object_ref (attachment); - g_signal_connect (client, "cal-opened-ex", callback, attachment); - e_cal_open_async (client, FALSE); + switch (source_type) { + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL, + e_client_utils_authenticate_handler, NULL, + attachment_handler_import_event, g_object_ref (attachment)); + break; + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, NULL, + e_client_utils_authenticate_handler, NULL, + attachment_handler_import_todo, g_object_ref (attachment)); + break; + default: + break; + } -exit: + exit: gtk_widget_destroy (dialog); } @@ -348,7 +363,7 @@ attachment_handler_import_to_calendar (GtkAction *action, attachment_handler_run_dialog ( parent, attachment, - E_CAL_SOURCE_TYPE_EVENT, + E_CAL_CLIENT_SOURCE_TYPE_EVENTS, _("Select a Calendar")); g_object_unref (attachment); @@ -375,7 +390,7 @@ attachment_handler_import_to_tasks (GtkAction *action, attachment_handler_run_dialog ( parent, attachment, - E_CAL_SOURCE_TYPE_TODO, + E_CAL_CLIENT_SOURCE_TYPE_TASKS, _("Select a Task List")); g_object_unref (attachment); diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c index 51ed54b810..8d0c6ef36a 100644 --- a/modules/calendar/e-cal-shell-backend.c +++ b/modules/calendar/e-cal-shell-backend.c @@ -27,11 +27,12 @@ #include <string.h> #include <glib/gi18n.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libecal/e-cal-time-util.h> #include <libedataserver/e-url.h> #include <libedataserver/e-source.h> #include <libedataserver/e-source-group.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-import.h" #include "shell/e-shell.h" @@ -39,7 +40,6 @@ #include "shell/e-shell-window.h" #include "widgets/misc/e-preferences-window.h" -#include "calendar/common/authentication.h" #include "calendar/gui/comp-util.h" #include "calendar/gui/dialogs/calendar-setup.h" #include "calendar/gui/dialogs/event-editor.h" @@ -85,6 +85,7 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) const gchar *name; gchar *property; gboolean save_list = FALSE; + GError *error = NULL; birthdays = NULL; personal = NULL; @@ -94,10 +95,11 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend) shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - if (!e_cal_get_sources ( + if (!e_cal_client_get_sources ( &cal_shell_backend->priv->source_list, - E_CAL_SOURCE_TYPE_EVENT, NULL)) { - g_warning ("Could not get calendar sources from GConf!"); + E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &error)) { + g_debug ("%s: Could not get calendar sources: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); return; } @@ -234,20 +236,31 @@ cal_shell_backend_new_event (ESource *source, CompEditorFlags flags, gboolean all_day) { - ECal *cal; + EClient *client = NULL; + ECalClient *cal_client; ECalComponent *comp; EShellSettings *shell_settings; CompEditor *editor; + GError *error = NULL; /* XXX Handle errors better. */ - cal = e_load_cal_source_finish (source, result, NULL); - g_return_if_fail (E_IS_CAL (cal)); + if (!e_client_utils_open_new_finish (source, result, &client, &error)) + client = NULL; + + if (!client) { + g_debug ("%s: Failed to open '%s': %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error"); + g_clear_error (&error); + return; + } + + g_return_if_fail (E_IS_CAL_CLIENT (client)); + cal_client = E_CAL_CLIENT (client); shell_settings = e_shell_get_shell_settings (shell); - editor = event_editor_new (cal, shell, flags); + editor = event_editor_new (cal_client, shell, flags); comp = cal_comp_event_new_with_current_time ( - cal, all_day, + cal_client, all_day, e_shell_settings_get_pointer ( shell_settings, "cal-timezone"), e_shell_settings_get_boolean ( @@ -262,13 +275,11 @@ cal_shell_backend_new_event (ESource *source, gtk_window_present (GTK_WINDOW (editor)); g_object_unref (comp); - g_object_unref (cal); + g_object_unref (client); } static void -cal_shell_backend_event_new_cb (ESource *source, - GAsyncResult *result, - EShell *shell) +cal_shell_backend_event_new_cb (GObject *source_object, GAsyncResult *result, gpointer shell) { CompEditorFlags flags = 0; gboolean all_day = FALSE; @@ -276,15 +287,13 @@ cal_shell_backend_event_new_cb (ESource *source, flags |= COMP_EDITOR_NEW_ITEM; flags |= COMP_EDITOR_USER_ORG; - cal_shell_backend_new_event (source, result, shell, flags, all_day); + cal_shell_backend_new_event (E_SOURCE (source_object), result, shell, flags, all_day); g_object_unref (shell); } static void -cal_shell_backend_event_all_day_new_cb (ESource *source, - GAsyncResult *result, - EShell *shell) +cal_shell_backend_event_all_day_new_cb (GObject *source_object, GAsyncResult *result, gpointer shell) { CompEditorFlags flags = 0; gboolean all_day = TRUE; @@ -292,15 +301,13 @@ cal_shell_backend_event_all_day_new_cb (ESource *source, flags |= COMP_EDITOR_NEW_ITEM; flags |= COMP_EDITOR_USER_ORG; - cal_shell_backend_new_event (source, result, shell, flags, all_day); + cal_shell_backend_new_event (E_SOURCE (source_object), result, shell, flags, all_day); g_object_unref (shell); } static void -cal_shell_backend_event_meeting_new_cb (ESource *source, - GAsyncResult *result, - EShell *shell) +cal_shell_backend_event_meeting_new_cb (GObject *source_object, GAsyncResult *result, gpointer shell) { CompEditorFlags flags = 0; gboolean all_day = FALSE; @@ -309,7 +316,7 @@ cal_shell_backend_event_meeting_new_cb (ESource *source, flags |= COMP_EDITOR_USER_ORG; flags |= COMP_EDITOR_MEETING; - cal_shell_backend_new_event (source, result, shell, flags, all_day); + cal_shell_backend_new_event (E_SOURCE (source_object), result, shell, flags, all_day); g_object_unref (shell); } @@ -324,7 +331,7 @@ action_event_new_cb (GtkAction *action, EShellSettings *shell_settings; ESource *source = NULL; ESourceList *source_list; - ECalSourceType source_type; + EClientSourceType source_type; const gchar *action_name; gchar *uid; @@ -361,7 +368,7 @@ action_event_new_cb (GtkAction *action, /* This callback is used for both appointments and meetings. */ - source_type = E_CAL_SOURCE_TYPE_EVENT; + source_type = E_CLIENT_SOURCE_TYPE_EVENTS; shell = e_shell_window_get_shell (shell_window); shell_settings = e_shell_get_shell_settings (shell); @@ -387,26 +394,17 @@ action_event_new_cb (GtkAction *action, * FIXME Need to obtain a better default time zone. */ action_name = gtk_action_get_name (action); if (strcmp (action_name, "event-all-day-new") == 0) - e_load_cal_source_async ( - source, source_type, NULL, - GTK_WINDOW (shell_window), - NULL, (GAsyncReadyCallback) - cal_shell_backend_event_all_day_new_cb, - g_object_ref (shell)); + e_client_utils_open_new (source, source_type, FALSE, NULL, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + cal_shell_backend_event_all_day_new_cb, g_object_ref (shell)); else if (strcmp (action_name, "event-meeting-new") == 0) - e_load_cal_source_async ( - source, source_type, NULL, - GTK_WINDOW (shell_window), - NULL, (GAsyncReadyCallback) - cal_shell_backend_event_meeting_new_cb, - g_object_ref (shell)); + e_client_utils_open_new (source, source_type, FALSE, NULL, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + cal_shell_backend_event_meeting_new_cb, g_object_ref (shell)); else - e_load_cal_source_async ( - source, source_type, NULL, - GTK_WINDOW (shell_window), - NULL, (GAsyncReadyCallback) - cal_shell_backend_event_new_cb, - g_object_ref (shell)); + e_client_utils_open_new (source, source_type, FALSE, NULL, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + cal_shell_backend_event_new_cb, g_object_ref (shell)); g_object_unref (source_list); } @@ -489,11 +487,11 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, EShellSettings *shell_settings; CompEditor *editor; CompEditorFlags flags = 0; - ECal *client; + ECalClient *client; ECalComponent *comp; ESource *source; ESourceList *source_list; - ECalSourceType source_type; + ECalClientSourceType source_type; EUri *euri; icalcomponent *icalcomp; icalproperty *icalprop; @@ -507,7 +505,7 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, gboolean handled = FALSE; GError *error = NULL; - source_type = E_CAL_SOURCE_TYPE_EVENT; + source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); @@ -589,24 +587,23 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, * we successfully open it is another matter... */ handled = TRUE; - if (!e_cal_get_sources (&source_list, source_type, NULL)) { - g_printerr ("Could not get calendar sources from GConf!\n"); + if (!e_cal_client_get_sources (&source_list, source_type, &error)) { + g_debug ("%s: Could not get calendar sources: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); goto exit; } source = e_source_list_peek_source_by_uid (source_list, source_uid); if (source == NULL) { - g_printerr ("No source for UID '%s'\n", source_uid); + g_debug ("%s: No source for UID '%s'", G_STRFUNC, source_uid); g_object_unref (source_list); goto exit; } - client = e_auth_new_cal_from_source (source, source_type); - if (client == NULL || !e_cal_open (client, TRUE, &error)) { - if (error != NULL) { - g_printerr ("%s\n", error->message); - g_error_free (error); - } + client = e_cal_client_new (source, source_type, &error); + if (client == NULL || !e_client_open_sync (E_CLIENT (client), TRUE, NULL, &error)) { + g_debug ("%s: Failed to create/open client '%s': %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error"); + g_clear_error (&error); g_object_unref (source_list); goto exit; } @@ -619,10 +616,10 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, if (editor != NULL) goto present; - if (!e_cal_get_object (client, comp_uid, comp_rid, &icalcomp, &error)) { - g_printerr ("%s\n", error->message); + if (!e_cal_client_get_object_sync (client, comp_uid, comp_rid, &icalcomp, NULL, &error)) { + g_debug ("%s: Failed to get object from client: %s", G_STRFUNC, error ? error->message : "Unknown error"); g_object_unref (source_list); - g_error_free (error); + g_clear_error (&error); goto exit; } diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index d49b143eef..8e3010ddb7 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -27,12 +27,12 @@ #include <string.h> #include <glib/gi18n.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-alert-dialog.h" #include "e-util/gconf-bridge.h" #include "widgets/misc/e-paned.h" -#include "calendar/common/authentication.h" #include "calendar/gui/e-calendar-selector.h" #include "calendar/gui/misc.h" #include "calendar/gui/dialogs/calendar-setup.h" @@ -56,7 +56,7 @@ struct _ECalShellSidebarPrivate { * opened. So the user first highlights a source, then * sometime later we update our default-client property * which is bound by an EBinding to ECalModel. */ - ECal *default_client; + ECalClient *default_client; GCancellable *loading_default_client; }; @@ -81,7 +81,7 @@ static GType cal_shell_sidebar_type; static void cal_shell_sidebar_emit_client_added (ECalShellSidebar *cal_shell_sidebar, - ECal *client) + ECalClient *client) { guint signal_id = signals[CLIENT_ADDED]; @@ -90,7 +90,7 @@ cal_shell_sidebar_emit_client_added (ECalShellSidebar *cal_shell_sidebar, static void cal_shell_sidebar_emit_client_removed (ECalShellSidebar *cal_shell_sidebar, - ECal *client) + ECalClient *client) { guint signal_id = signals[CLIENT_REMOVED]; @@ -108,7 +108,7 @@ cal_shell_sidebar_emit_status_message (ECalShellSidebar *cal_shell_sidebar, static void cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, - ECal *client) + ECalClient *client) { EShellView *shell_view; EShellContent *shell_content; @@ -123,7 +123,7 @@ cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); uid = e_source_peek_uid (source); g_object_ref (source); @@ -141,7 +141,7 @@ cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, static void cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar, const gchar *message, - ECal *client) + ECalClient *client) { EShellView *shell_view; EShellContent *shell_content; @@ -153,7 +153,7 @@ cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar, shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); source_group = e_source_peek_group (source); e_alert_submit ( @@ -164,38 +164,43 @@ cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar, } static void -cal_shell_sidebar_client_opened_cb (ECalShellSidebar *cal_shell_sidebar, - const GError *error, - ECal *client) +cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + ECalClient *client = E_CAL_CLIENT (source_object); + ECalShellSidebar *cal_shell_sidebar = user_data; EShellView *shell_view; EShellContent *shell_content; EShellSidebar *shell_sidebar; const gchar *message; + GError *error = NULL; shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - if (g_error_matches (error, E_CALENDAR_ERROR, - E_CALENDAR_STATUS_AUTHENTICATION_FAILED) || - g_error_matches (error, E_CALENDAR_ERROR, - E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)) - e_auth_cal_forget_password (client); + e_client_open_finish (E_CLIENT (client), result, &error); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED) || + g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED)) + e_client_utils_forget_password (E_CLIENT (client)); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) { + e_client_open (E_CLIENT (client), FALSE, NULL, cal_shell_sidebar_client_opened_cb, user_data); + g_clear_error (&error); + return; + } /* Handle errors. */ - switch (error ? error->code : E_CALENDAR_STATUS_OK) { - case E_CALENDAR_STATUS_OK: + switch ((error && error->domain == E_CLIENT_ERROR) ? error->code : -1) { + case -1: break; - case E_CALENDAR_STATUS_AUTHENTICATION_FAILED: - e_cal_open_async (client, FALSE); - return; - - case E_CALENDAR_STATUS_BUSY: + case E_CLIENT_ERROR_BUSY: + g_debug ("%s: Cannot open '%s', it's busy (%s)", G_STRFUNC, e_source_peek_name (e_client_get_source (E_CLIENT (client))), error->message); + g_clear_error (&error); return; - case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: + case E_CLIENT_ERROR_REPOSITORY_OFFLINE: e_alert_submit ( E_ALERT_SINK (shell_content), "calendar:prompt-no-contents-offline-calendar", @@ -203,7 +208,7 @@ cal_shell_sidebar_client_opened_cb (ECalShellSidebar *cal_shell_sidebar, /* fall through */ default: - if (error->code != E_CALENDAR_STATUS_REPOSITORY_OFFLINE) { + if (error->code != E_CLIENT_ERROR_REPOSITORY_OFFLINE) { e_alert_submit ( E_ALERT_SINK (shell_content), "calendar:failed-open-calendar", @@ -212,15 +217,12 @@ cal_shell_sidebar_client_opened_cb (ECalShellSidebar *cal_shell_sidebar, e_cal_shell_sidebar_remove_source ( cal_shell_sidebar, - e_cal_get_source (client)); + e_client_get_source (E_CLIENT (client))); + g_clear_error (&error); return; } - g_assert (error == NULL); - - g_signal_handlers_disconnect_matched ( - client, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, - cal_shell_sidebar_client_opened_cb, NULL); + g_clear_error (&error); message = _("Loading calendars"); cal_shell_sidebar_emit_status_message (cal_shell_sidebar, message); @@ -229,27 +231,31 @@ cal_shell_sidebar_client_opened_cb (ECalShellSidebar *cal_shell_sidebar, } static void -cal_shell_sidebar_default_loaded_cb (ESource *source, - GAsyncResult *result, - EShellSidebar *shell_sidebar) +cal_shell_sidebar_default_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EShellSidebar *shell_sidebar = user_data; ECalShellSidebarPrivate *priv; EShellContent *shell_content; EShellView *shell_view; - ECal *client; + ECalShellContent *cal_shell_content; + ECalModel *model; + EClient *client = NULL; GError *error = NULL; priv = E_CAL_SHELL_SIDEBAR (shell_sidebar)->priv; shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); + cal_shell_content = E_CAL_SHELL_CONTENT (shell_content); + model = e_cal_shell_content_get_model (cal_shell_content); - client = e_load_cal_source_finish (source, result, &error); + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || + g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { g_error_free (error); goto exit; - } else if (error != NULL) { e_alert_submit ( E_ALERT_SINK (shell_content), @@ -259,16 +265,18 @@ cal_shell_sidebar_default_loaded_cb (ESource *source, goto exit; } - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); if (priv->default_client != NULL) g_object_unref (priv->default_client); - priv->default_client = client; + priv->default_client = E_CAL_CLIENT (client); + + e_cal_client_set_default_timezone (priv->default_client, e_cal_model_get_timezone (model)); g_object_notify (G_OBJECT (shell_sidebar), "default-client"); -exit: + exit: g_object_unref (shell_sidebar); } @@ -279,29 +287,18 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar, ECalShellSidebarPrivate *priv; EShellView *shell_view; EShellWindow *shell_window; - EShellContent *shell_content; EShellSidebar *shell_sidebar; - ECalShellContent *cal_shell_content; - ECalSourceType source_type; - ECalModel *model; - ECal *client; - icaltimezone *timezone; + ECalClient *client; const gchar *uid; priv = cal_shell_sidebar->priv; - source_type = E_CAL_SOURCE_TYPE_EVENT; /* FIXME Sidebar should not be accessing the EShellContent. * This probably needs to be moved to ECalShellView. */ shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_content = e_shell_view_get_shell_content (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - cal_shell_content = E_CAL_SHELL_CONTENT (shell_content); - model = e_cal_shell_content_get_model (cal_shell_content); - timezone = e_cal_model_get_timezone (model); - /* Cancel any unfinished previous request. */ if (priv->loading_default_client != NULL) { g_cancellable_cancel (priv->loading_default_client); @@ -324,11 +321,9 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar, priv->loading_default_client = g_cancellable_new (); - e_load_cal_source_async ( - source, source_type, timezone, - GTK_WINDOW (shell_window), priv->loading_default_client, - (GAsyncReadyCallback) cal_shell_sidebar_default_loaded_cb, - g_object_ref (shell_sidebar)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, priv->loading_default_client, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + cal_shell_sidebar_default_loaded_cb, g_object_ref (shell_sidebar)); } static void @@ -702,7 +697,7 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) source = e_source_selector_get_primary_selection (selector); if (source != NULL) { - ECal *client; + ECalClient *client; const gchar *uri; const gchar *delete; @@ -717,7 +712,7 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) cal_shell_sidebar->priv->client_table, e_source_peek_uid (source)); refresh_supported = - client && e_cal_get_refresh_supported (client); + client && e_client_check_refresh_supported (E_CLIENT (client)); } if (source != NULL) @@ -734,7 +729,7 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) static void cal_shell_sidebar_client_removed (ECalShellSidebar *cal_shell_sidebar, - ECal *client) + ECalClient *client) { ESourceSelector *selector; GHashTable *client_table; @@ -748,7 +743,7 @@ cal_shell_sidebar_client_removed (ECalShellSidebar *cal_shell_sidebar, client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, cal_shell_sidebar); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); uid = e_source_peek_uid (source); g_return_if_fail (uid != NULL); @@ -793,9 +788,9 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class) PROP_DEFAULT_CLIENT, g_param_spec_object ( "default-client", - "Default Calendar Client", + "Default Calendar ECalClient", "Default client for calendar operations", - E_TYPE_CAL, + E_TYPE_CAL_CLIENT, G_PARAM_READABLE)); g_object_class_install_property ( @@ -816,7 +811,7 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_TYPE_CAL); + E_TYPE_CAL_CLIENT); signals[CLIENT_REMOVED] = g_signal_new ( "client-removed", @@ -826,7 +821,7 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_TYPE_CAL); + E_TYPE_CAL_CLIENT); signals[STATUS_MESSAGE] = g_signal_new ( "status-message", @@ -917,7 +912,7 @@ e_cal_shell_sidebar_get_date_navigator (ECalShellSidebar *cal_shell_sidebar) return E_CALENDAR (cal_shell_sidebar->priv->date_navigator); } -ECal * +ECalClient * e_cal_shell_sidebar_get_default_client (ECalShellSidebar *cal_shell_sidebar) { g_return_val_if_fail ( @@ -943,12 +938,12 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, EShellContent *shell_content; EShellSidebar *shell_sidebar; ECalShellContent *cal_shell_content; - ECalSourceType source_type; + ECalClientSourceType source_type; ESourceSelector *selector; GHashTable *client_table; ECalModel *model; - ECal *default_client; - ECal *client; + ECalClient *default_client; + ECalClient *client; icaltimezone *timezone; const gchar *uid; const gchar *uri; @@ -957,7 +952,7 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, g_return_if_fail (E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - source_type = E_CAL_SOURCE_TYPE_EVENT; + source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; client_table = cal_shell_sidebar->priv->client_table; default_client = cal_shell_sidebar->priv->default_client; selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); @@ -972,15 +967,18 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, ESource *default_source; const gchar *default_uid; - default_source = e_cal_get_source (default_client); + default_source = e_client_get_source (E_CLIENT (default_client)); default_uid = e_source_peek_uid (default_source); if (g_strcmp0 (uid, default_uid) == 0) client = g_object_ref (default_client); } - if (client == NULL) - client = e_auth_new_cal_from_source (source, source_type); + if (client == NULL) { + client = e_cal_client_new (source, source_type, NULL); + if (client) + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + } g_return_if_fail (client != NULL); @@ -997,17 +995,12 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, g_hash_table_insert (client_table, g_strdup (uid), client); e_source_selector_select_source (selector, source); - uri = e_cal_get_uri (client); + uri = e_client_get_uri (E_CLIENT (client)); /* Translators: The string field is a URI. */ message = g_strdup_printf (_("Opening calendar at %s"), uri); cal_shell_sidebar_emit_status_message (cal_shell_sidebar, message); g_free (message); - g_signal_connect_swapped ( - client, "cal-opened-ex", - G_CALLBACK (cal_shell_sidebar_client_opened_cb), - cal_shell_sidebar); - /* FIXME Sidebar should not be accessing the EShellContent. * This probably needs to be moved to ECalShellView. */ shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar); @@ -1018,8 +1011,8 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, model = e_cal_shell_content_get_model (cal_shell_content); timezone = e_cal_model_get_timezone (model); - e_cal_set_default_timezone (client, timezone, NULL); - e_cal_open_async (client, FALSE); + e_cal_client_set_default_timezone (client, timezone); + e_client_open (E_CLIENT (client), FALSE, NULL, cal_shell_sidebar_client_opened_cb, cal_shell_sidebar); } void @@ -1027,7 +1020,7 @@ e_cal_shell_sidebar_remove_source (ECalShellSidebar *cal_shell_sidebar, ESource *source) { GHashTable *client_table; - ECal *client; + ECalClient *client; const gchar *uid; g_return_if_fail (E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar)); diff --git a/modules/calendar/e-cal-shell-sidebar.h b/modules/calendar/e-cal-shell-sidebar.h index 6919d7ab52..3e4d00a87f 100644 --- a/modules/calendar/e-cal-shell-sidebar.h +++ b/modules/calendar/e-cal-shell-sidebar.h @@ -22,7 +22,7 @@ #ifndef E_CAL_SHELL_SIDEBAR_H #define E_CAL_SHELL_SIDEBAR_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libedataserverui/e-source-selector.h> #include <shell/e-shell-sidebar.h> @@ -71,9 +71,9 @@ struct _ECalShellSidebarClass { /* Signals */ void (*client_added) (ECalShellSidebar *cal_shell_sidebar, - ECal *client); + ECalClient *client); void (*client_removed) (ECalShellSidebar *cal_shell_sidebar, - ECal *client); + ECalClient *client); void (*status_message) (ECalShellSidebar *cal_shell_sidebar, const gchar *status_message); }; @@ -86,7 +86,7 @@ GList * e_cal_shell_sidebar_get_clients (ECalShellSidebar *cal_shell_sidebar); ECalendar * e_cal_shell_sidebar_get_date_navigator (ECalShellSidebar *cal_shell_sidebar); -ECal * e_cal_shell_sidebar_get_default_client +ECalClient * e_cal_shell_sidebar_get_default_client (ECalShellSidebar *cal_shell_sidebar); ESourceSelector * e_cal_shell_sidebar_get_selector diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c index c82f0036f5..6537cde8b4 100644 --- a/modules/calendar/e-cal-shell-view-actions.c +++ b/modules/calendar/e-cal-shell-view-actions.c @@ -51,7 +51,7 @@ action_calendar_copy_cb (GtkAction *action, copy_source_dialog ( GTK_WINDOW (shell_window), - source, E_CAL_SOURCE_TYPE_EVENT); + source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS); } static void @@ -67,7 +67,7 @@ action_calendar_delete_cb (GtkAction *action, GnomeCalendarViewType view_type; GnomeCalendar *calendar; ECalModel *model; - ECal *client; + ECalClient *client; ESourceSelector *selector; ESourceGroup *source_group; ESourceList *source_list; @@ -102,14 +102,14 @@ action_calendar_delete_cb (GtkAction *action, uri = e_source_get_uri (source); client = e_cal_model_get_client_for_uri (model, uri); if (client == NULL) - client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_EVENT); + client = e_cal_client_new_from_uri (uri, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL); g_free (uri); g_return_if_fail (client != NULL); - if (!e_cal_remove (client, &error)) { - g_warning ("%s", error->message); - g_error_free (error); + if (!e_client_remove_sync (E_CLIENT (client), NULL, &error)) { + g_debug ("%s: Failed to remove client: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); return; } @@ -125,8 +125,8 @@ action_calendar_delete_cb (GtkAction *action, source_list = e_cal_shell_backend_get_source_list ( E_CAL_SHELL_BACKEND (shell_backend)); if (!e_source_list_sync (source_list, &error)) { - g_warning ("%s", error->message); - g_error_free (error); + g_debug ("%s: Failed to sync source list: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); } } @@ -362,7 +362,7 @@ action_calendar_refresh_cb (GtkAction *action, ECalShellContent *cal_shell_content; ECalShellSidebar *cal_shell_sidebar; ESourceSelector *selector; - ECal *client; + ECalClient *client; ECalModel *model; ESource *source; gchar *uri; @@ -384,14 +384,11 @@ action_calendar_refresh_cb (GtkAction *action, if (client == NULL) return; - g_return_if_fail (e_cal_get_refresh_supported (client)); + g_return_if_fail (e_client_check_refresh_supported (E_CLIENT (client))); - if (!e_cal_refresh (client, &error) && error) { - g_warning ( - "%s: Failed to refresh '%s', %s\n", - G_STRFUNC, e_source_peek_name (source), - error->message); - g_error_free (error); + if (!e_client_refresh_sync (E_CLIENT (client), NULL, &error)) { + g_debug ("%s: Failed to refresh '%s', %s\n", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error"); + g_clear_error (&error); } } @@ -499,8 +496,9 @@ action_event_copy_cb (GtkAction *action, GnomeCalendar *calendar; ECalendarView *calendar_view; ESource *source_source = NULL, *destination_source = NULL; - ECal *destination_client = NULL; + ECalClient *destination_client = NULL; GList *selected, *iter; + GError *error = NULL; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); @@ -517,22 +515,27 @@ action_event_copy_cb (GtkAction *action, ECalendarViewEvent *event = selected->data; if (is_comp_data_valid (event) && event->comp_data->client) - source_source = e_cal_get_source (event->comp_data->client); + source_source = e_client_get_source (E_CLIENT (event->comp_data->client)); } /* Get a destination source from the user. */ destination_source = select_source_dialog ( - GTK_WINDOW (shell_window), E_CAL_SOURCE_TYPE_EVENT, source_source); + GTK_WINDOW (shell_window), E_CAL_CLIENT_SOURCE_TYPE_EVENTS, source_source); if (destination_source == NULL) return; /* Open the destination calendar. */ - destination_client = e_auth_new_cal_from_source ( - destination_source, E_CAL_SOURCE_TYPE_EVENT); + destination_client = e_cal_client_new ( + destination_source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL); if (destination_client == NULL) goto exit; - if (!e_cal_open (destination_client, FALSE, NULL)) + g_signal_connect (destination_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + + if (!e_client_open_sync (E_CLIENT (destination_client), FALSE, NULL, &error)) { + g_debug ("%s: Failed to open destination client: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); goto exit; + } e_cal_shell_view_set_status_message ( cal_shell_view, _("Copying Items"), -1.0); @@ -565,7 +568,7 @@ action_event_delegate_cb (GtkAction *action, ECalendarView *calendar_view; ECalendarViewEvent *event; ECalComponent *component; - ECal *client; + ECalClient *client; GList *selected; icalcomponent *clone; icalproperty *property; @@ -702,7 +705,7 @@ action_event_forward_cb (GtkAction *action, GnomeCalendar *calendar; ECalendarViewEvent *event; ECalComponent *component; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; GList *selected; @@ -769,8 +772,9 @@ action_event_move_cb (GtkAction *action, GnomeCalendar *calendar; ECalendarView *calendar_view; ESource *source_source = NULL, *destination_source = NULL; - ECal *destination_client = NULL; + ECalClient *destination_client = NULL; GList *selected, *iter; + GError *error = NULL; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); @@ -787,22 +791,26 @@ action_event_move_cb (GtkAction *action, ECalendarViewEvent *event = selected->data; if (is_comp_data_valid (event) && event->comp_data->client) - source_source = e_cal_get_source (event->comp_data->client); + source_source = e_client_get_source (E_CLIENT (event->comp_data->client)); } /* Get a destination source from the user. */ destination_source = select_source_dialog ( - GTK_WINDOW (shell_window), E_CAL_SOURCE_TYPE_EVENT, source_source); + GTK_WINDOW (shell_window), E_CAL_CLIENT_SOURCE_TYPE_EVENTS, source_source); if (destination_source == NULL) return; /* Open the destination calendar. */ - destination_client = e_auth_new_cal_from_source ( - destination_source, E_CAL_SOURCE_TYPE_EVENT); + destination_client = e_cal_client_new (destination_source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL); if (destination_client == NULL) goto exit; - if (!e_cal_open (destination_client, FALSE, NULL)) + g_signal_connect (destination_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + + if (!e_client_open_sync (E_CLIENT (destination_client), FALSE, NULL, &error)) { + g_debug ("%s: Failed to open destination client: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); goto exit; + } e_cal_shell_view_set_status_message ( cal_shell_view, _("Moving Items"), -1.0); @@ -856,7 +864,7 @@ action_event_occurrence_movable_cb (GtkAction *action, ECalComponent *recurring_component; ECalComponentDateTime date; ECalComponentId *id; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; icaltimetype itt; icaltimezone *timezone; @@ -922,14 +930,14 @@ action_event_occurrence_movable_cb (GtkAction *action, * since at present the updates happend synchronously so our * event may disappear. */ - e_cal_remove_object_with_mod ( - client, id->uid, id->rid, CALOBJ_MOD_THIS, NULL); + e_cal_client_remove_object_sync ( + client, id->uid, id->rid, CALOBJ_MOD_THIS, NULL, NULL); e_cal_component_free_id (id); g_object_unref (recurring_component); icalcomp = e_cal_component_get_icalcomponent (exception_component); - if (e_cal_create_object (client, icalcomp, &uid, NULL)) + if (e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) g_free (uid); g_object_unref (exception_component); @@ -965,7 +973,7 @@ action_event_print_cb (GtkAction *action, ECalendarViewEvent *event; ECalComponent *component; ECalModel *model; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; GList *selected; @@ -1011,7 +1019,7 @@ action_event_reply_cb (GtkAction *action, GnomeCalendar *calendar; ECalendarViewEvent *event; ECalComponent *component; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; GList *selected; gboolean reply_all = FALSE; @@ -1055,7 +1063,7 @@ action_event_reply_all_cb (GtkAction *action, GnomeCalendar *calendar; ECalendarViewEvent *event; ECalComponent *component; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; GList *selected; gboolean reply_all = TRUE; @@ -1102,7 +1110,7 @@ action_event_save_as_cb (GtkAction *action, GnomeCalendar *calendar; ECalendarView *calendar_view; ECalendarViewEvent *event; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; EActivity *activity; GList *selected; @@ -1140,7 +1148,7 @@ action_event_save_as_cb (GtkAction *action, if (file == NULL) return; - string = e_cal_get_component_as_string (client, icalcomp); + string = e_cal_client_get_component_as_string (client, icalcomp); if (string == NULL) { g_warning ("Could not convert item to a string"); goto exit; @@ -1172,7 +1180,7 @@ edit_event_as (ECalShellView *cal_shell_view, gboolean as_meeting) GnomeCalendar *calendar; ECalendarView *calendar_view; ECalendarViewEvent *event; - ECal *client; + ECalClient *client; icalcomponent *icalcomp; GList *selected; diff --git a/modules/calendar/e-cal-shell-view-memopad.c b/modules/calendar/e-cal-shell-view-memopad.c index 84d14cf09b..e154667826 100644 --- a/modules/calendar/e-cal-shell-view-memopad.c +++ b/modules/calendar/e-cal-shell-view-memopad.c @@ -66,7 +66,7 @@ action_calendar_memopad_new_cb (GtkAction *action, ECalShellContent *cal_shell_content; EMemoTable *memo_table; ECalModelComponent *comp_data; - ECal *client; + ECalClient *client; ECalComponent *comp; CompEditor *editor; GSList *list; @@ -224,7 +224,7 @@ action_calendar_memopad_save_as_cb (GtkAction *action, return; /* XXX We only save the first selected memo. */ - string = e_cal_get_component_as_string ( + string = e_cal_client_get_component_as_string ( comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert memo to a string."); @@ -355,7 +355,7 @@ e_cal_shell_view_memopad_actions_update (ECalShellView *cal_shell_view) icalproperty *prop; gboolean read_only; - e_cal_is_read_only (comp_data->client, &read_only, NULL); + read_only = e_client_is_readonly (E_CLIENT (comp_data->client)); editable &= !read_only; prop = icalcomponent_get_first_property ( diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index c6c9fa5673..d4cee1a627 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -283,7 +283,7 @@ cal_shell_view_selector_popup_event_cb (EShellView *shell_view, static void cal_shell_view_selector_client_added_cb (ECalShellView *cal_shell_view, - ECal *client) + ECalClient *client) { ECalShellContent *cal_shell_content; GnomeCalendar *calendar; @@ -300,7 +300,7 @@ cal_shell_view_selector_client_added_cb (ECalShellView *cal_shell_view, static void cal_shell_view_selector_client_removed_cb (ECalShellView *cal_shell_view, - ECal *client) + ECalClient *client) { ECalShellContent *cal_shell_content; GnomeCalendar *calendar; @@ -341,12 +341,12 @@ cal_shell_view_user_created_cb (ECalShellView *cal_shell_view, { ECalShellSidebar *cal_shell_sidebar; ECalModel *model; - ECal *client; + ECalClient *client; ESource *source; model = e_calendar_view_get_model (calendar_view); client = e_cal_model_get_default_client (model); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar; e_cal_shell_sidebar_add_source (cal_shell_sidebar, source); @@ -824,7 +824,7 @@ e_cal_shell_view_set_status_message (ECalShellView *cal_shell_view, void e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, ECalendarViewEvent *event, - ECal *destination_client, + ECalClient *destination_client, gboolean remove) { icalcomponent *icalcomp; @@ -838,7 +838,7 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view)); g_return_if_fail (event != NULL); - g_return_if_fail (E_IS_CAL (destination_client)); + g_return_if_fail (E_IS_CAL_CLIENT (destination_client)); if (!is_comp_data_valid (event)) return; @@ -848,25 +848,26 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, /* Put the new object into the destination calendar. */ - success = e_cal_get_object ( - destination_client, uid, NULL, &icalcomp, NULL); + success = e_cal_client_get_object_sync ( + destination_client, uid, NULL, &icalcomp, NULL, NULL); if (success) { icalcomponent_free (icalcomp); - success = e_cal_modify_object ( + success = e_cal_client_modify_object_sync ( destination_client, icalcomp_event, - CALOBJ_MOD_ALL, NULL); + CALOBJ_MOD_ALL, NULL, NULL); /* do not delete the event when it was found in the calendar */ return; } else { icalproperty *icalprop; gchar *new_uid; + GError *error = NULL; if (e_cal_util_component_is_instance (icalcomp_event)) { - success = e_cal_get_object ( + success = e_cal_client_get_object_sync ( event->comp_data->client, - uid, NULL, &icalcomp, NULL); + uid, NULL, &icalcomp, NULL, NULL); if (success) { /* Use master object when working * with a recurring event ... */ @@ -904,10 +905,11 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, } new_uid = NULL; - success = e_cal_create_object ( - destination_client, icalcomp_clone, &new_uid, NULL); + success = e_cal_client_create_object_sync ( + destination_client, icalcomp_clone, &new_uid, NULL, &error); if (!success) { icalcomponent_free (icalcomp_clone); + g_debug ("%s: Failed to create object: %s", G_STRFUNC, error ? error->message : "Unknown error"); return; } @@ -916,7 +918,7 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, } if (remove) { - ECal *source_client = event->comp_data->client; + ECalClient *source_client = event->comp_data->client; /* Remove the item from the source calendar. */ if (e_cal_util_component_is_instance (icalcomp_event) || @@ -930,11 +932,11 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, rid = icaltime_as_ical_string_r (icaltime); else rid = NULL; - e_cal_remove_object_with_mod ( - source_client, uid, rid, CALOBJ_MOD_ALL, NULL); + e_cal_client_remove_object_sync ( + source_client, uid, rid, CALOBJ_MOD_ALL, NULL, NULL); g_free (rid); } else - e_cal_remove_object (source_client, uid, NULL); + e_cal_client_remove_object_sync (source_client, uid, NULL, CALOBJ_MOD_THIS, NULL, NULL); } } @@ -1091,10 +1093,10 @@ e_cal_shell_view_update_timezone (ECalShellView *cal_shell_view) clients = e_cal_shell_sidebar_get_clients (cal_shell_sidebar); for (iter = clients; iter != NULL; iter = iter->next) { - ECal *client = iter->data; + ECalClient *client = iter->data; - if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) - e_cal_set_default_timezone (client, timezone, NULL); + if (e_client_is_opened (E_CLIENT (client))) + e_cal_client_set_default_timezone (client, timezone); } g_list_free (clients); diff --git a/modules/calendar/e-cal-shell-view-private.h b/modules/calendar/e-cal-shell-view-private.h index 52ec374295..7c78130fc3 100644 --- a/modules/calendar/e-cal-shell-view-private.h +++ b/modules/calendar/e-cal-shell-view-private.h @@ -31,6 +31,7 @@ #include <libedataserver/e-categories.h> #include <libedataserver/e-data-server-util.h> #include <libedataserver/e-sexp.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-account-utils.h" #include "e-util/e-selection.h" @@ -41,7 +42,6 @@ #include "misc/e-popup-action.h" #include "misc/e-selectable.h" -#include "calendar/common/authentication.h" #include "calendar/gui/calendar-config.h" #include "calendar/gui/comp-util.h" #include "calendar/gui/e-cal-list-view.h" @@ -142,7 +142,7 @@ void e_cal_shell_view_set_status_message void e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, ECalendarViewEvent *event, - ECal *destination_client, + ECalClient *destination_client, gboolean remove); void e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view); diff --git a/modules/calendar/e-cal-shell-view-taskpad.c b/modules/calendar/e-cal-shell-view-taskpad.c index 48fd850790..48c81ac085 100644 --- a/modules/calendar/e-cal-shell-view-taskpad.c +++ b/modules/calendar/e-cal-shell-view-taskpad.c @@ -135,7 +135,7 @@ action_calendar_taskpad_new_cb (GtkAction *action, ECalShellContent *cal_shell_content; ECalModelComponent *comp_data; ETaskTable *task_table; - ECal *client; + ECalClient *client; ECalComponent *comp; CompEditor *editor; GSList *list; @@ -290,7 +290,7 @@ action_calendar_taskpad_save_as_cb (GtkAction *action, if (file == NULL) return; - string = e_cal_get_component_as_string ( + string = e_cal_client_get_component_as_string ( comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert task to a string"); @@ -446,15 +446,15 @@ e_cal_shell_view_taskpad_actions_update (ECalShellView *cal_shell_view) const gchar *cap; gboolean read_only; - e_cal_is_read_only (comp_data->client, &read_only, NULL); + read_only = e_client_is_readonly (E_CLIENT (comp_data->client)); editable &= !read_only; cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT; - if (e_cal_get_static_capability (comp_data->client, cap)) + if (e_client_check_capability (E_CLIENT (comp_data->client), cap)) assignable = FALSE; cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK; - if (e_cal_get_static_capability (comp_data->client, cap)) + if (e_client_check_capability (E_CLIENT (comp_data->client), cap)) assignable = FALSE; prop = icalcomponent_get_first_property ( diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c index 1d7269cd55..2249bf96e4 100644 --- a/modules/calendar/e-cal-shell-view.c +++ b/modules/calendar/e-cal-shell-view.c @@ -353,7 +353,7 @@ cal_shell_view_update_actions (EShellView *shell_view) for (iter = list; iter != NULL; iter = iter->next) { ECalendarViewEvent *event = iter->data; - ECal *client; + ECalClient *client; ECalComponent *comp; icalcomponent *icalcomp; gchar *user_email = NULL; @@ -366,7 +366,7 @@ cal_shell_view_update_actions (EShellView *shell_view) client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; - e_cal_is_read_only (client, &read_only, NULL); + read_only = e_client_is_readonly (E_CLIENT (client)); editable = editable && !read_only; is_instance |= e_cal_util_component_is_instance (icalcomp); @@ -391,11 +391,9 @@ cal_shell_view_update_actions (EShellView *shell_view) itip_organizer_is_user (comp, client); is_delegatable = - e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED) && - ((e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) || - (!user_org && !is_delegated (icalcomp, user_email))); + e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED) && + (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY) || + (!user_org && !is_delegated (icalcomp, user_email))); g_free (user_email); g_object_unref (comp); diff --git a/modules/calendar/e-calendar-preferences.c b/modules/calendar/e-calendar-preferences.c index ec15e3c2d1..f35c88a6ed 100644 --- a/modules/calendar/e-calendar-preferences.c +++ b/modules/calendar/e-calendar-preferences.c @@ -435,7 +435,7 @@ show_alarms_config (ECalendarPreferences *prefs) { GConfClient *gconf; - if (e_cal_get_sources (&prefs->alarms_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) { + if (e_cal_client_get_sources (&prefs->alarms_list, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL)) { prefs->alarm_list_widget = e_source_selector_new (prefs->alarms_list); atk_object_set_name (gtk_widget_get_accessible (prefs->alarm_list_widget), _("Selected Calendars for Alarms")); gtk_container_add (GTK_CONTAINER (prefs->scrolled_window), prefs->alarm_list_widget); diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c index e99e3e2931..8d39843054 100644 --- a/modules/calendar/e-memo-shell-backend.c +++ b/modules/calendar/e-memo-shell-backend.c @@ -27,17 +27,17 @@ #include <string.h> #include <glib/gi18n.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libedataserver/e-url.h> #include <libedataserver/e-source.h> #include <libedataserver/e-source-list.h> #include <libedataserver/e-source-group.h> +#include <libedataserverui/e-client-utils.h> #include "shell/e-shell.h" #include "shell/e-shell-backend.h" #include "shell/e-shell-window.h" -#include "calendar/common/authentication.h" #include "calendar/gui/comp-util.h" #include "calendar/gui/dialogs/calendar-setup.h" #include "calendar/gui/dialogs/memo-editor.h" @@ -75,6 +75,7 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend) GSList *sources, *iter; const gchar *name; gboolean save_list = FALSE; + GError *error = NULL; personal = NULL; @@ -83,10 +84,11 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend) shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - if (!e_cal_get_sources ( + if (!e_cal_client_get_sources ( &memo_shell_backend->priv->source_list, - E_CAL_SOURCE_TYPE_JOURNAL, NULL)) { - g_warning ("Could not get memo sources from GConf!"); + E_CAL_CLIENT_SOURCE_TYPE_MEMOS, &error)) { + g_debug ("%s: Could not get memo sources: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); return; } @@ -164,43 +166,50 @@ memo_shell_backend_new_memo (ESource *source, EShell *shell, CompEditorFlags flags) { - ECal *cal; + EClient *client = NULL; + ECalClient *cal_client; ECalComponent *comp; CompEditor *editor; + GError *error = NULL; + + if (!e_client_utils_open_new_finish (source, result, &client, &error)) + client = NULL; /* XXX Handle errors better. */ - cal = e_load_cal_source_finish (source, result, NULL); - g_return_if_fail (E_IS_CAL (cal)); + if (!client) { + g_debug ("%s: Failed to open '%s': %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error"); + g_clear_error (&error); + return; + } - comp = cal_comp_memo_new_with_defaults (cal); + g_return_if_fail (E_IS_CAL_CLIENT (client)); + + cal_client = E_CAL_CLIENT (client); + comp = cal_comp_memo_new_with_defaults (cal_client); cal_comp_update_time_by_active_window (comp, shell); - editor = memo_editor_new (cal, shell, flags); + editor = memo_editor_new (cal_client, shell, flags); comp_editor_edit_comp (editor, comp); gtk_window_present (GTK_WINDOW (editor)); g_object_unref (comp); - g_object_unref (cal); + g_object_unref (client); } static void -memo_shell_backend_memo_new_cb (ESource *source, - GAsyncResult *result, - EShell *shell) +memo_shell_backend_memo_new_cb (GObject *source_object, GAsyncResult *result, gpointer shell) { CompEditorFlags flags = 0; flags |= COMP_EDITOR_NEW_ITEM; - memo_shell_backend_new_memo (source, result, shell, flags); + memo_shell_backend_new_memo (E_SOURCE (source_object), result, shell, flags); g_object_unref (shell); } static void -memo_shell_backend_memo_shared_new_cb (ESource *source, - GAsyncResult *result, - EShell *shell) +memo_shell_backend_memo_shared_new_cb (GObject *source_object, GAsyncResult *result, gpointer shell) { CompEditorFlags flags = 0; @@ -208,7 +217,7 @@ memo_shell_backend_memo_shared_new_cb (ESource *source, flags |= COMP_EDITOR_IS_SHARED; flags |= COMP_EDITOR_USER_ORG; - memo_shell_backend_new_memo (source, result, shell, flags); + memo_shell_backend_new_memo (E_SOURCE (source_object), result, shell, flags); g_object_unref (shell); } @@ -222,14 +231,11 @@ action_memo_new_cb (GtkAction *action, EShellSettings *shell_settings; ESource *source = NULL; ESourceList *source_list; - ECalSourceType source_type; const gchar *action_name; gchar *uid; /* This callback is used for both memos and shared memos. */ - source_type = E_CAL_SOURCE_TYPE_JOURNAL; - shell = e_shell_window_get_shell (shell_window); shell_settings = e_shell_get_shell_settings (shell); shell_backend = e_shell_get_backend_by_name (shell, "memos"); @@ -254,19 +260,13 @@ action_memo_new_cb (GtkAction *action, * FIXME Need to obtain a better default time zone. */ action_name = gtk_action_get_name (action); if (g_strcmp0 (action_name, "memo-shared-new") == 0) - e_load_cal_source_async ( - source, source_type, NULL, - GTK_WINDOW (shell_window), - NULL, (GAsyncReadyCallback) - memo_shell_backend_memo_shared_new_cb, - g_object_ref (shell)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, FALSE, NULL, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + memo_shell_backend_memo_shared_new_cb, g_object_ref (shell)); else - e_load_cal_source_async ( - source, source_type, NULL, - GTK_WINDOW (shell_window), - NULL, (GAsyncReadyCallback) - memo_shell_backend_memo_new_cb, - g_object_ref (shell)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, FALSE, NULL, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + memo_shell_backend_memo_new_cb, g_object_ref (shell)); g_object_unref (source_list); } @@ -312,11 +312,11 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend, EShell *shell; CompEditor *editor; CompEditorFlags flags = 0; - ECal *client; + ECalClient *client; ECalComponent *comp; ESource *source; ESourceList *source_list; - ECalSourceType source_type; + ECalClientSourceType source_type; EUri *euri; icalcomponent *icalcomp; const gchar *cp; @@ -326,7 +326,7 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend, gboolean handled = FALSE; GError *error = NULL; - source_type = E_CAL_SOURCE_TYPE_JOURNAL; + source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; shell = e_shell_backend_get_shell (shell_backend); if (strncmp (uri, "memo:", 5) != 0) @@ -379,8 +379,9 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend, * we successfully open it is another matter... */ handled = TRUE; - if (!e_cal_get_sources (&source_list, source_type, NULL)) { - g_printerr ("Could not get memo sources from GConf!\n"); + if (!e_cal_client_get_sources (&source_list, source_type, &error)) { + g_debug ("%s: Could not get memo sources: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); goto exit; } @@ -391,12 +392,13 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend, goto exit; } - client = e_auth_new_cal_from_source (source, source_type); - if (client == NULL || !e_cal_open (client, TRUE, &error)) { - if (error != NULL) { - g_printerr ("%s\n", error->message); - g_error_free (error); - } + client = e_cal_client_new (source, source_type, &error); + if (client) + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + + if (client == NULL || !e_client_open_sync (E_CLIENT (client), TRUE, NULL, &error)) { + g_debug ("%s: Failed to create/open client: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); g_object_unref (source_list); goto exit; } @@ -409,10 +411,10 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend, if (editor != NULL) goto present; - if (!e_cal_get_object (client, comp_uid, comp_rid, &icalcomp, &error)) { - g_printerr ("%s\n", error->message); + if (!e_cal_client_get_object_sync (client, comp_uid, comp_rid, &icalcomp, NULL, &error)) { + g_debug ("%s: Failed to get object: %s", G_STRFUNC, error ? error->message : "Unknown error"); g_object_unref (source_list); - g_error_free (error); + g_clear_error (&error); goto exit; } diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c index 9f7d0768b9..f0f4fe958f 100644 --- a/modules/calendar/e-memo-shell-content.c +++ b/modules/calendar/e-memo-shell-content.c @@ -115,7 +115,7 @@ memo_shell_content_table_foreach_cb (gint model_row, ESource *source; const gchar *source_uid; - source = e_cal_get_source (comp_data->client); + source = e_client_get_source (E_CLIENT (comp_data->client)); source_uid = e_source_peek_uid (source); foreach_data->list = g_slist_prepend ( @@ -575,7 +575,7 @@ memo_shell_content_check_state (EShellContent *shell_content) icalproperty *prop; gboolean read_only; - e_cal_is_read_only (comp_data->client, &read_only, NULL); + read_only = e_client_is_readonly (E_CLIENT (comp_data->client)); editable &= !read_only; prop = icalcomponent_get_first_property ( diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index befe60cbc1..5a28611652 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -27,11 +27,11 @@ #include <string.h> #include <glib/gi18n.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-alert-dialog.h" #include "e-util/e-util.h" -#include "calendar/common/authentication.h" #include "calendar/gui/e-memo-list-selector.h" #include "calendar/gui/misc.h" @@ -52,7 +52,7 @@ struct _EMemoShellSidebarPrivate { * opened. So the user first highlights a source, then * sometime later we update our default-client property * which is bound by an EBinding to ECalModel. */ - ECal *default_client; + ECalClient *default_client; GCancellable *loading_default_client; }; @@ -76,7 +76,7 @@ static GType memo_shell_sidebar_type; static void memo_shell_sidebar_emit_client_added (EMemoShellSidebar *memo_shell_sidebar, - ECal *client) + ECalClient *client) { guint signal_id = signals[CLIENT_ADDED]; @@ -85,7 +85,7 @@ memo_shell_sidebar_emit_client_added (EMemoShellSidebar *memo_shell_sidebar, static void memo_shell_sidebar_emit_client_removed (EMemoShellSidebar *memo_shell_sidebar, - ECal *client) + ECalClient *client) { guint signal_id = signals[CLIENT_REMOVED]; @@ -103,7 +103,7 @@ memo_shell_sidebar_emit_status_message (EMemoShellSidebar *memo_shell_sidebar, static void memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, - ECal *client) + ECalClient *client) { EShellView *shell_view; EShellContent *shell_content; @@ -118,7 +118,7 @@ memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); uid = e_source_peek_uid (source); g_object_ref (source); @@ -136,7 +136,7 @@ memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar, static void memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar, const gchar *message, - ECal *client) + ECalClient *client) { EShellView *shell_view; EShellContent *shell_content; @@ -148,7 +148,7 @@ memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar, shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); source_group = e_source_peek_group (source); e_alert_submit ( @@ -159,38 +159,43 @@ memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar, } static void -memo_shell_sidebar_client_opened_cb (EMemoShellSidebar *memo_shell_sidebar, - const GError *error, - ECal *client) +memo_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + ECalClient *client = E_CAL_CLIENT (source_object); + EMemoShellSidebar *memo_shell_sidebar = user_data; EShellView *shell_view; EShellContent *shell_content; EShellSidebar *shell_sidebar; const gchar *message; + GError *error = NULL; shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - if (g_error_matches (error, E_CALENDAR_ERROR, - E_CALENDAR_STATUS_AUTHENTICATION_FAILED) || - g_error_matches (error, E_CALENDAR_ERROR, - E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)) - e_auth_cal_forget_password (client); + e_client_open_finish (E_CLIENT (client), result, &error); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED) || + g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED)) + e_client_utils_forget_password (E_CLIENT (client)); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) { + e_client_open (E_CLIENT (client), FALSE, NULL, memo_shell_sidebar_client_opened_cb, user_data); + g_clear_error (&error); + return; + } /* Handle errors. */ - switch (error ? error->code : E_CALENDAR_STATUS_OK) { - case E_CALENDAR_STATUS_OK: + switch ((error && error->domain == E_CLIENT_ERROR) ? error->code : -1) { + case -1: break; - case E_CALENDAR_STATUS_AUTHENTICATION_FAILED: - e_cal_open_async (client, FALSE); - return; - - case E_CALENDAR_STATUS_BUSY: + case E_CLIENT_ERROR_BUSY: + g_debug ("%s: Cannot open '%s', it's busy (%s)", G_STRFUNC, e_source_peek_name (e_client_get_source (E_CLIENT (client))), error->message); + g_clear_error (&error); return; - case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: + case E_CLIENT_ERROR_REPOSITORY_OFFLINE: e_alert_submit ( E_ALERT_SINK (shell_content), "calendar:prompt-no-contents-offline-memos", @@ -198,7 +203,7 @@ memo_shell_sidebar_client_opened_cb (EMemoShellSidebar *memo_shell_sidebar, /* fall through */ default: - if (error->code != E_CALENDAR_STATUS_REPOSITORY_OFFLINE) { + if (error->code != E_CLIENT_ERROR_REPOSITORY_OFFLINE) { e_alert_submit ( E_ALERT_SINK (shell_content), "calendar:failed-open-memos", @@ -207,15 +212,12 @@ memo_shell_sidebar_client_opened_cb (EMemoShellSidebar *memo_shell_sidebar, e_memo_shell_sidebar_remove_source ( memo_shell_sidebar, - e_cal_get_source (client)); + e_client_get_source (E_CLIENT (client))); + g_clear_error (&error); return; } - g_assert (error == NULL); - - g_signal_handlers_disconnect_matched ( - client, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, - memo_shell_sidebar_client_opened_cb, NULL); + g_clear_error (&error); message = _("Loading memos"); memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message); @@ -224,27 +226,31 @@ memo_shell_sidebar_client_opened_cb (EMemoShellSidebar *memo_shell_sidebar, } static void -memo_shell_sidebar_default_loaded_cb (ESource *source, - GAsyncResult *result, - EShellSidebar *shell_sidebar) +memo_shell_sidebar_default_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EShellSidebar *shell_sidebar = user_data; EMemoShellSidebarPrivate *priv; EShellContent *shell_content; EShellView *shell_view; - ECal *client; + EMemoShellContent *memo_shell_content; + ECalModel *model; + EClient *client = NULL; GError *error = NULL; priv = E_MEMO_SHELL_SIDEBAR (shell_sidebar)->priv; shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); + memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); + model = e_memo_shell_content_get_memo_model (memo_shell_content); - client = e_load_cal_source_finish (source, result, &error); + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || + g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { g_error_free (error); goto exit; - } else if (error != NULL) { e_alert_submit ( E_ALERT_SINK (shell_content), @@ -254,16 +260,18 @@ memo_shell_sidebar_default_loaded_cb (ESource *source, goto exit; } - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); if (priv->default_client != NULL) g_object_unref (priv->default_client); - priv->default_client = client; + priv->default_client = E_CAL_CLIENT (client); + + e_cal_client_set_default_timezone (priv->default_client, e_cal_model_get_timezone (model)); g_object_notify (G_OBJECT (shell_sidebar), "default-client"); -exit: + exit: g_object_unref (shell_sidebar); } @@ -274,29 +282,18 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar, EMemoShellSidebarPrivate *priv; EShellView *shell_view; EShellWindow *shell_window; - EShellContent *shell_content; EShellSidebar *shell_sidebar; - EMemoShellContent *memo_shell_content; - ECalSourceType source_type; - ECalModel *model; - ECal *client; - icaltimezone *timezone; + ECalClient *client; const gchar *uid; priv = memo_shell_sidebar->priv; - source_type = E_CAL_SOURCE_TYPE_JOURNAL; /* FIXME Sidebar should not be accessing the EShellContent. * This probably needs to be moved to EMemoShellView. */ shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_content = e_shell_view_get_shell_content (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); - model = e_memo_shell_content_get_memo_model (memo_shell_content); - timezone = e_cal_model_get_timezone (model); - /* Cancel any unfinished previous request. */ if (priv->loading_default_client != NULL) { g_cancellable_cancel (priv->loading_default_client); @@ -319,11 +316,9 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar, priv->loading_default_client = g_cancellable_new (); - e_load_cal_source_async ( - source, source_type, timezone, - GTK_WINDOW (shell_window), priv->loading_default_client, - (GAsyncReadyCallback) memo_shell_sidebar_default_loaded_cb, - g_object_ref (shell_sidebar)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, FALSE, priv->loading_default_client, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + memo_shell_sidebar_default_loaded_cb, g_object_ref (shell_sidebar)); } static void @@ -607,7 +602,7 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar) source = e_source_selector_get_primary_selection (selector); if (source != NULL) { - ECal *client; + ECalClient *client; const gchar *uri; const gchar *delete; @@ -622,7 +617,7 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar) memo_shell_sidebar->priv->client_table, e_source_peek_uid (source)); refresh_supported = - client && e_cal_get_refresh_supported (client); + client && e_client_check_refresh_supported (E_CLIENT (client)); } if (source != NULL) @@ -639,7 +634,7 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar) static void memo_shell_sidebar_client_removed (EMemoShellSidebar *memo_shell_sidebar, - ECal *client) + ECalClient *client) { ESourceSelector *selector; GHashTable *client_table; @@ -653,7 +648,7 @@ memo_shell_sidebar_client_removed (EMemoShellSidebar *memo_shell_sidebar, client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, memo_shell_sidebar); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); uid = e_source_peek_uid (source); g_return_if_fail (uid != NULL); @@ -688,9 +683,9 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) PROP_DEFAULT_CLIENT, g_param_spec_object ( "default-client", - "Default Memo Client", + "Default Memo ECalClient", "Default client for memo operations", - E_TYPE_CAL, + E_TYPE_CAL_CLIENT, G_PARAM_READABLE)); g_object_class_install_property ( @@ -711,7 +706,7 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_TYPE_CAL); + E_TYPE_CAL_CLIENT); signals[CLIENT_REMOVED] = g_signal_new ( "client-removed", @@ -721,7 +716,7 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_TYPE_CAL); + E_TYPE_CAL_CLIENT); signals[STATUS_MESSAGE] = g_signal_new ( "status-message", @@ -804,7 +799,7 @@ e_memo_shell_sidebar_get_clients (EMemoShellSidebar *memo_shell_sidebar) return g_hash_table_get_values (client_table); } -ECal * +ECalClient * e_memo_shell_sidebar_get_default_client (EMemoShellSidebar *memo_shell_sidebar) { g_return_val_if_fail ( @@ -830,12 +825,12 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, EShellContent *shell_content; EShellSidebar *shell_sidebar; EMemoShellContent *memo_shell_content; - ECalSourceType source_type; + ECalClientSourceType source_type; ESourceSelector *selector; GHashTable *client_table; ECalModel *model; - ECal *default_client; - ECal *client; + ECalClient *default_client; + ECalClient *client; icaltimezone *timezone; const gchar *uid; const gchar *uri; @@ -844,7 +839,7 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - source_type = E_CAL_SOURCE_TYPE_JOURNAL; + source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; client_table = memo_shell_sidebar->priv->client_table; default_client = memo_shell_sidebar->priv->default_client; selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); @@ -859,15 +854,18 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, ESource *default_source; const gchar *default_uid; - default_source = e_cal_get_source (default_client); + default_source = e_client_get_source (E_CLIENT (default_client)); default_uid = e_source_peek_uid (default_source); if (g_strcmp0 (uid, default_uid) == 0) client = g_object_ref (default_client); } - if (client == NULL) - client = e_auth_new_cal_from_source (source, source_type); + if (client == NULL) { + client = e_cal_client_new (source, source_type, NULL); + if (client) + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + } g_return_if_fail (client != NULL); @@ -884,17 +882,12 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, g_hash_table_insert (client_table, g_strdup (uid), client); e_source_selector_select_source (selector, source); - uri = e_cal_get_uri (client); + uri = e_client_get_uri (E_CLIENT (client)); /* Translators: The string field is a URI. */ message = g_strdup_printf (_("Opening memos at %s"), uri); memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message); g_free (message); - g_signal_connect_swapped ( - client, "cal-opened-ex", - G_CALLBACK (memo_shell_sidebar_client_opened_cb), - memo_shell_sidebar); - /* FIXME Sidebar should not be accessing the EShellContent. * This probably needs to be moved to EMemoShellView. */ shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar); @@ -905,8 +898,8 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, model = e_memo_shell_content_get_memo_model (memo_shell_content); timezone = e_cal_model_get_timezone (model); - e_cal_set_default_timezone (client, timezone, NULL); - e_cal_open_async (client, FALSE); + e_cal_client_set_default_timezone (client, timezone); + e_client_open (E_CLIENT (client), FALSE, NULL, memo_shell_sidebar_client_opened_cb, memo_shell_sidebar); } void @@ -914,7 +907,7 @@ e_memo_shell_sidebar_remove_source (EMemoShellSidebar *memo_shell_sidebar, ESource *source) { GHashTable *client_table; - ECal *client; + ECalClient *client; const gchar *uid; g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar)); diff --git a/modules/calendar/e-memo-shell-sidebar.h b/modules/calendar/e-memo-shell-sidebar.h index 91e0ccc618..24e73f11d1 100644 --- a/modules/calendar/e-memo-shell-sidebar.h +++ b/modules/calendar/e-memo-shell-sidebar.h @@ -22,7 +22,7 @@ #ifndef E_MEMO_SHELL_SIDEBAR_H #define E_MEMO_SHELL_SIDEBAR_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libedataserverui/e-source-selector.h> #include <shell/e-shell-sidebar.h> @@ -70,9 +70,9 @@ struct _EMemoShellSidebarClass { /* Signals */ void (*client_added) (EMemoShellSidebar *memo_shell_sidebar, - ECal *client); + ECalClient *client); void (*client_removed) (EMemoShellSidebar *memo_shell_sidebar, - ECal *client); + ECalClient *client); void (*status_message) (EMemoShellSidebar *memo_shell_sidebar, const gchar *status_message, gdouble percent); @@ -85,7 +85,7 @@ GtkWidget * e_memo_shell_sidebar_new (EShellView *shell_view); GList * e_memo_shell_sidebar_get_clients (EMemoShellSidebar *memo_shell_sidebar); -ECal * e_memo_shell_sidebar_get_default_client +ECalClient * e_memo_shell_sidebar_get_default_client (EMemoShellSidebar *memo_shell_sidebar); ESourceSelector * e_memo_shell_sidebar_get_selector diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c index 593031235d..75d957c684 100644 --- a/modules/calendar/e-memo-shell-view-actions.c +++ b/modules/calendar/e-memo-shell-view-actions.c @@ -121,7 +121,7 @@ action_memo_list_copy_cb (GtkAction *action, copy_source_dialog ( GTK_WINDOW (shell_window), - source, E_CAL_SOURCE_TYPE_JOURNAL); + source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS); } static void @@ -134,7 +134,7 @@ action_memo_list_delete_cb (GtkAction *action, EShellWindow *shell_window; EShellView *shell_view; EMemoTable *memo_table; - ECal *client; + ECalClient *client; ECalModel *model; ESourceSelector *selector; ESourceGroup *source_group; @@ -170,14 +170,14 @@ action_memo_list_delete_cb (GtkAction *action, uri = e_source_get_uri (source); client = e_cal_model_get_client_for_uri (model, uri); if (client == NULL) - client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL); + client = e_cal_client_new_from_uri (uri, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL); g_free (uri); g_return_if_fail (client != NULL); - if (!e_cal_remove (client, &error)) { - g_warning ("%s", error->message); - g_error_free (error); + if (!e_client_remove_sync (E_CLIENT (client), NULL, &error)) { + g_debug ("%s: Failed to remove client: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); return; } @@ -191,8 +191,8 @@ action_memo_list_delete_cb (GtkAction *action, e_source_group_remove_source (source_group, source); if (!e_source_list_sync (source_list, &error)) { - g_warning ("%s", error->message); - g_error_free (error); + g_debug ("%s: Failed to sync source list: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); } } @@ -266,7 +266,7 @@ action_memo_list_refresh_cb (GtkAction *action, EMemoShellContent *memo_shell_content; EMemoShellSidebar *memo_shell_sidebar; ESourceSelector *selector; - ECal *client; + ECalClient *client; ECalModel *model; ESource *source; gchar *uri; @@ -288,14 +288,11 @@ action_memo_list_refresh_cb (GtkAction *action, if (client == NULL) return; - g_return_if_fail (e_cal_get_refresh_supported (client)); + g_return_if_fail (e_client_check_refresh_supported (E_CLIENT (client))); - if (!e_cal_refresh (client, &error) && error) { - g_warning ( - "%s: Failed to refresh '%s', %s\n", - G_STRFUNC, e_source_peek_name (source), - error->message); - g_error_free (error); + if (!e_client_refresh_sync (E_CLIENT (client), NULL, &error)) { + g_debug ("%s: Failed to refresh '%s', %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error"); + g_clear_error (&error); } } @@ -338,7 +335,7 @@ action_memo_new_cb (GtkAction *action, EShellWindow *shell_window; EMemoShellContent *memo_shell_content; EMemoTable *memo_table; - ECal *client; + ECalClient *client; ECalComponent *comp; CompEditor *editor; GSList *list; @@ -518,7 +515,7 @@ action_memo_save_as_cb (GtkAction *action, return; /* XXX We only save the first selected memo. */ - string = e_cal_get_component_as_string ( + string = e_cal_client_get_component_as_string ( comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert memo to a string"); diff --git a/modules/calendar/e-memo-shell-view-private.c b/modules/calendar/e-memo-shell-view-private.c index 36f09fd954..c1278cb46e 100644 --- a/modules/calendar/e-memo-shell-view-private.c +++ b/modules/calendar/e-memo-shell-view-private.c @@ -34,13 +34,13 @@ memo_shell_view_model_row_appended_cb (EMemoShellView *memo_shell_view, ECalModel *model) { EMemoShellSidebar *memo_shell_sidebar; - ECal *client; + ECalClient *client; ESource *source; /* This is the "Click to Add" handler. */ client = e_cal_model_get_default_client (model); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar; e_memo_shell_sidebar_add_source (memo_shell_sidebar, source); @@ -58,7 +58,7 @@ memo_shell_view_table_popup_event_cb (EShellView *shell_view, static void memo_shell_view_selector_client_added_cb (EMemoShellView *memo_shell_view, - ECal *client) + ECalClient *client) { EMemoShellContent *memo_shell_content; EMemoTable *memo_table; @@ -74,7 +74,7 @@ memo_shell_view_selector_client_added_cb (EMemoShellView *memo_shell_view, static void memo_shell_view_selector_client_removed_cb (EMemoShellView *memo_shell_view, - ECal *client) + ECalClient *client) { EMemoShellContent *memo_shell_content; EMemoTable *memo_table; @@ -452,10 +452,10 @@ e_memo_shell_view_update_timezone (EMemoShellView *memo_shell_view) clients = e_memo_shell_sidebar_get_clients (memo_shell_sidebar); for (iter = clients; iter != NULL; iter = iter->next) { - ECal *client = iter->data; + ECalClient *client = iter->data; - if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) - e_cal_set_default_timezone (client, timezone, NULL); + if (e_client_is_opened (E_CLIENT (client))) + e_cal_client_set_default_timezone (client, timezone); } g_list_free (clients); diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c index b9f95b3a72..768f46fd28 100644 --- a/modules/calendar/e-task-shell-backend.c +++ b/modules/calendar/e-task-shell-backend.c @@ -27,17 +27,17 @@ #include <string.h> #include <glib/gi18n.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libedataserver/e-url.h> #include <libedataserver/e-source.h> #include <libedataserver/e-source-list.h> #include <libedataserver/e-source-group.h> +#include <libedataserverui/e-client-utils.h> #include "shell/e-shell.h" #include "shell/e-shell-backend.h" #include "shell/e-shell-window.h" -#include "calendar/common/authentication.h" #include "calendar/gui/comp-util.h" #include "calendar/gui/dialogs/calendar-setup.h" #include "calendar/gui/dialogs/task-editor.h" @@ -74,6 +74,7 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend) GSList *sources, *iter; const gchar *name; gboolean save_list = FALSE; + GError *error = NULL; on_this_computer = NULL; personal = NULL; @@ -83,10 +84,11 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend) shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - if (!e_cal_get_sources ( + if (!e_cal_client_get_sources ( &task_shell_backend->priv->source_list, - E_CAL_SOURCE_TYPE_TODO, NULL)) { - g_warning ("Could not get task sources from GConf!"); + E_CAL_CLIENT_SOURCE_TYPE_TASKS, &error)) { + g_debug ("%s: Could not get task sources: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); return; } @@ -164,42 +166,49 @@ task_shell_backend_new_task (ESource *source, EShell *shell, CompEditorFlags flags) { - ECal *cal; + EClient *client = NULL; + ECalClient *cal_client; ECalComponent *comp; CompEditor *editor; + GError *error = NULL; + + if (!e_client_utils_open_new_finish (source, result, &client, &error)) + client = NULL; /* XXX Handle errors better. */ - cal = e_load_cal_source_finish (source, result, NULL); - g_return_if_fail (E_IS_CAL (cal)); + if (!client) { + g_debug ("%s: Failed to open '%s': %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error"); + g_clear_error (&error); + return; + } - editor = task_editor_new (cal, shell, flags); - comp = cal_comp_task_new_with_defaults (cal); + g_return_if_fail (E_IS_CAL_CLIENT (client)); + + cal_client = E_CAL_CLIENT (client); + editor = task_editor_new (cal_client, shell, flags); + comp = cal_comp_task_new_with_defaults (cal_client); comp_editor_edit_comp (editor, comp); gtk_window_present (GTK_WINDOW (editor)); g_object_unref (comp); - g_object_unref (cal); + g_object_unref (client); } static void -task_shell_backend_task_new_cb (ESource *source, - GAsyncResult *result, - EShell *shell) +task_shell_backend_task_new_cb (GObject *source_object, GAsyncResult *result, gpointer shell) { CompEditorFlags flags = 0; flags |= COMP_EDITOR_NEW_ITEM; - task_shell_backend_new_task (source, result, shell, flags); + task_shell_backend_new_task (E_SOURCE (source_object), result, shell, flags); g_object_unref (shell); } static void -task_shell_backend_task_assigned_new_cb (ESource *source, - GAsyncResult *result, - EShell *shell) +task_shell_backend_task_assigned_new_cb (GObject *source_object, GAsyncResult *result, gpointer shell) { CompEditorFlags flags = 0; @@ -207,7 +216,7 @@ task_shell_backend_task_assigned_new_cb (ESource *source, flags |= COMP_EDITOR_IS_ASSIGNED; flags |= COMP_EDITOR_USER_ORG; - task_shell_backend_new_task (source, result, shell, flags); + task_shell_backend_new_task (E_SOURCE (source_object), result, shell, flags); g_object_unref (shell); } @@ -221,14 +230,11 @@ action_task_new_cb (GtkAction *action, EShellSettings *shell_settings; ESource *source = NULL; ESourceList *source_list; - ECalSourceType source_type; const gchar *action_name; gchar *uid; /* This callback is used for both tasks and assigned tasks. */ - source_type = E_CAL_SOURCE_TYPE_TODO; - shell = e_shell_window_get_shell (shell_window); shell_settings = e_shell_get_shell_settings (shell); shell_backend = e_shell_get_backend_by_name (shell, "tasks"); @@ -253,19 +259,13 @@ action_task_new_cb (GtkAction *action, * FIXME Need to obtain a better default time zone. */ action_name = gtk_action_get_name (action); if (strcmp (action_name, "task-assigned-new") == 0) - e_load_cal_source_async ( - source, source_type, NULL, - GTK_WINDOW (shell_window), - NULL, (GAsyncReadyCallback) - task_shell_backend_task_assigned_new_cb, - g_object_ref (shell)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, NULL, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + task_shell_backend_task_assigned_new_cb, g_object_ref (shell)); else - e_load_cal_source_async ( - source, source_type, NULL, - GTK_WINDOW (shell_window), - NULL, (GAsyncReadyCallback) - task_shell_backend_task_new_cb, - g_object_ref (shell)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, NULL, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + task_shell_backend_task_new_cb, g_object_ref (shell)); g_object_unref (source_list); } @@ -311,11 +311,11 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend, EShell *shell; CompEditor *editor; CompEditorFlags flags = 0; - ECal *client; + ECalClient *client; ECalComponent *comp; ESource *source; ESourceList *source_list; - ECalSourceType source_type; + ECalClientSourceType source_type; EUri *euri; icalcomponent *icalcomp; icalproperty *icalprop; @@ -326,7 +326,7 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend, gboolean handled = FALSE; GError *error = NULL; - source_type = E_CAL_SOURCE_TYPE_TODO; + source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; shell = e_shell_backend_get_shell (shell_backend); if (strncmp (uri, "task:", 5) != 0) @@ -379,8 +379,9 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend, * we successfully open it is another matter... */ handled = TRUE; - if (!e_cal_get_sources (&source_list, source_type, NULL)) { - g_printerr ("Could not get task sources from GConf!\n"); + if (!e_cal_client_get_sources (&source_list, source_type, &error)) { + g_debug ("%s: Could not get task sources: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); goto exit; } @@ -391,12 +392,13 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend, goto exit; } - client = e_auth_new_cal_from_source (source, source_type); - if (client == NULL || !e_cal_open (client, TRUE, &error)) { - if (error != NULL) { - g_printerr ("%s\n", error->message); - g_error_free (error); - } + client = e_cal_client_new (source, source_type, &error); + if (client) + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + + if (client == NULL || !e_client_open_sync (E_CLIENT (client), TRUE, NULL, &error)) { + g_debug ("%s: Failed to create/open client: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); g_object_unref (source_list); goto exit; } @@ -409,8 +411,8 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend, if (editor != NULL) goto present; - if (!e_cal_get_object (client, comp_uid, comp_rid, &icalcomp, &error)) { - g_printerr ("%s\n", error->message); + if (!e_cal_client_get_object_sync (client, comp_uid, comp_rid, &icalcomp, NULL, &error)) { + g_debug ("%s: Failed to get object: %s", G_STRFUNC, error ? error->message : "Unknown error"); g_object_unref (source_list); g_error_free (error); goto exit; diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c index 0ffa6fb5a3..743bb937e7 100644 --- a/modules/calendar/e-task-shell-content.c +++ b/modules/calendar/e-task-shell-content.c @@ -115,7 +115,7 @@ task_shell_content_table_foreach_cb (gint model_row, ESource *source; const gchar *source_uid; - source = e_cal_get_source (comp_data->client); + source = e_client_get_source (E_CLIENT (comp_data->client)); source_uid = e_source_peek_uid (source); foreach_data->list = g_slist_prepend ( @@ -577,15 +577,15 @@ task_shell_content_check_state (EShellContent *shell_content) const gchar *cap; gboolean read_only; - e_cal_is_read_only (comp_data->client, &read_only, NULL); + read_only = e_client_is_readonly (E_CLIENT (comp_data->client)); editable &= !read_only; cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT; - if (e_cal_get_static_capability (comp_data->client, cap)) + if (e_client_check_capability (E_CLIENT (comp_data->client), cap)) assignable = FALSE; cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK; - if (e_cal_get_static_capability (comp_data->client, cap)) + if (e_client_check_capability (E_CLIENT (comp_data->client), cap)) assignable = FALSE; prop = icalcomponent_get_first_property ( diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c index 098726af22..b37ab6dec6 100644 --- a/modules/calendar/e-task-shell-sidebar.c +++ b/modules/calendar/e-task-shell-sidebar.c @@ -27,11 +27,11 @@ #include <string.h> #include <glib/gi18n.h> -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-alert-dialog.h" #include "e-util/e-util.h" -#include "calendar/common/authentication.h" #include "calendar/gui/e-task-list-selector.h" #include "calendar/gui/misc.h" @@ -52,7 +52,7 @@ struct _ETaskShellSidebarPrivate { * opened. So the user first highlights a source, then * sometime later we update our default-client property * which is bound by an EBinding to ECalModel. */ - ECal *default_client; + ECalClient *default_client; GCancellable *loading_default_client; }; @@ -76,7 +76,7 @@ static GType task_shell_sidebar_type; static void task_shell_sidebar_emit_client_added (ETaskShellSidebar *task_shell_sidebar, - ECal *client) + ECalClient *client) { guint signal_id = signals[CLIENT_ADDED]; @@ -85,7 +85,7 @@ task_shell_sidebar_emit_client_added (ETaskShellSidebar *task_shell_sidebar, static void task_shell_sidebar_emit_client_removed (ETaskShellSidebar *task_shell_sidebar, - ECal *client) + ECalClient *client) { guint signal_id = signals[CLIENT_REMOVED]; @@ -103,7 +103,7 @@ task_shell_sidebar_emit_status_message (ETaskShellSidebar *task_shell_sidebar, static void task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar, - ECal *client) + ECalClient *client) { EShellView *shell_view; EShellContent *shell_content; @@ -118,7 +118,7 @@ task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar, shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); uid = e_source_peek_uid (source); g_object_ref (source); @@ -136,7 +136,7 @@ task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar, static void task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar, const gchar *message, - ECal *client) + ECalClient *client) { EShellView *shell_view; EShellContent *shell_content; @@ -148,7 +148,7 @@ task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar, shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); source_group = e_source_peek_group (source); e_alert_submit ( @@ -159,38 +159,43 @@ task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar, } static void -task_shell_sidebar_client_opened_cb (ETaskShellSidebar *task_shell_sidebar, - const GError *error, - ECal *client) +task_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + ECalClient *client = E_CAL_CLIENT (source_object); + ETaskShellSidebar *task_shell_sidebar = user_data; EShellView *shell_view; EShellContent *shell_content; EShellSidebar *shell_sidebar; const gchar *message; + GError *error = NULL; shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); - if (g_error_matches (error, E_CALENDAR_ERROR, - E_CALENDAR_STATUS_AUTHENTICATION_FAILED) || - g_error_matches (error, E_CALENDAR_ERROR, - E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED)) - e_auth_cal_forget_password (client); + e_client_open_finish (E_CLIENT (client), result, &error); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED) || + g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED)) + e_client_utils_forget_password (E_CLIENT (client)); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) { + e_client_open (E_CLIENT (client), FALSE, NULL, task_shell_sidebar_client_opened_cb, user_data); + g_clear_error (&error); + return; + } /* Handle errors. */ - switch (error ? error->code : E_CALENDAR_STATUS_OK) { - case E_CALENDAR_STATUS_OK: + switch ((error && error->domain == E_CLIENT_ERROR) ? error->code : -1) { + case -1: break; - case E_CALENDAR_STATUS_AUTHENTICATION_FAILED: - e_cal_open_async (client, FALSE); - return; - - case E_CALENDAR_STATUS_BUSY: + case E_CLIENT_ERROR_BUSY: + g_debug ("%s: Cannot open '%s', it's busy (%s)", G_STRFUNC, e_source_peek_name (e_client_get_source (E_CLIENT (client))), error->message); + g_clear_error (&error); return; - case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: + case E_CLIENT_ERROR_REPOSITORY_OFFLINE: e_alert_submit ( E_ALERT_SINK (shell_content), "calendar:prompt-no-contents-offline-tasks", @@ -198,7 +203,7 @@ task_shell_sidebar_client_opened_cb (ETaskShellSidebar *task_shell_sidebar, /* fall through */ default: - if (error->code != E_CALENDAR_STATUS_REPOSITORY_OFFLINE) { + if (error->code != E_CLIENT_ERROR_REPOSITORY_OFFLINE) { e_alert_submit ( E_ALERT_SINK (shell_content), "calendar:failed-open-tasks", @@ -207,15 +212,12 @@ task_shell_sidebar_client_opened_cb (ETaskShellSidebar *task_shell_sidebar, e_task_shell_sidebar_remove_source ( task_shell_sidebar, - e_cal_get_source (client)); + e_client_get_source (E_CLIENT (client))); + g_clear_error (&error); return; } - g_assert (error == NULL); - - g_signal_handlers_disconnect_matched ( - client, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, - task_shell_sidebar_client_opened_cb, NULL); + g_clear_error (&error); message = _("Loading tasks"); task_shell_sidebar_emit_status_message (task_shell_sidebar, message); @@ -224,27 +226,31 @@ task_shell_sidebar_client_opened_cb (ETaskShellSidebar *task_shell_sidebar, } static void -task_shell_sidebar_default_loaded_cb (ESource *source, - GAsyncResult *result, - EShellSidebar *shell_sidebar) +task_shell_sidebar_default_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { + EShellSidebar *shell_sidebar = user_data; ETaskShellSidebarPrivate *priv; EShellContent *shell_content; EShellView *shell_view; - ECal *client; + ETaskShellContent *task_shell_content; + ECalModel *model; + EClient *client = NULL; GError *error = NULL; priv = E_TASK_SHELL_SIDEBAR (shell_sidebar)->priv; shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_content = e_shell_view_get_shell_content (shell_view); + task_shell_content = E_TASK_SHELL_CONTENT (shell_content); + model = e_task_shell_content_get_task_model (task_shell_content); - client = e_load_cal_source_finish (source, result, &error); + if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) + client = NULL; - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || + g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { g_error_free (error); goto exit; - } else if (error != NULL) { e_alert_submit ( E_ALERT_SINK (shell_content), @@ -254,16 +260,18 @@ task_shell_sidebar_default_loaded_cb (ESource *source, goto exit; } - g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (E_IS_CAL_CLIENT (client)); if (priv->default_client != NULL) g_object_unref (priv->default_client); - priv->default_client = client; + priv->default_client = E_CAL_CLIENT (client); + + e_cal_client_set_default_timezone (priv->default_client, e_cal_model_get_timezone (model)); g_object_notify (G_OBJECT (shell_sidebar), "default-client"); -exit: + exit: g_object_unref (shell_sidebar); } @@ -274,29 +282,18 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar, ETaskShellSidebarPrivate *priv; EShellView *shell_view; EShellWindow *shell_window; - EShellContent *shell_content; EShellSidebar *shell_sidebar; - ETaskShellContent *task_shell_content; - ECalSourceType source_type; - ECalModel *model; - ECal *client; - icaltimezone *timezone; + ECalClient *client; const gchar *uid; priv = task_shell_sidebar->priv; - source_type = E_CAL_SOURCE_TYPE_TODO; /* FIXME Sidebar should not be accessing the EShellContent. * This probably needs to be moved to ETaskShellView. */ shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); - shell_content = e_shell_view_get_shell_content (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - task_shell_content = E_TASK_SHELL_CONTENT (shell_content); - model = e_task_shell_content_get_task_model (task_shell_content); - timezone = e_cal_model_get_timezone (model); - /* Cancel any unfinished previous request. */ if (priv->loading_default_client != NULL) { g_cancellable_cancel (priv->loading_default_client); @@ -319,11 +316,9 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar, priv->loading_default_client = g_cancellable_new (); - e_load_cal_source_async ( - source, source_type, timezone, - GTK_WINDOW (shell_window), priv->loading_default_client, - (GAsyncReadyCallback) task_shell_sidebar_default_loaded_cb, - g_object_ref (shell_sidebar)); + e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, priv->loading_default_client, + e_client_utils_authenticate_handler, GTK_WINDOW (shell_window), + task_shell_sidebar_default_loaded_cb, g_object_ref (shell_sidebar)); } static void @@ -607,22 +602,22 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar) source = e_source_selector_get_primary_selection (selector); if (source != NULL) { - ECal *client; + ECalClient *client; const gchar *uri; - const gchar *delete; + const gchar *delete_prop; uri = e_source_peek_relative_uri (source); is_system = (uri == NULL || strcmp (uri, "system") == 0); can_delete = !is_system; - delete = e_source_get_property (source, "delete"); - can_delete &= (delete == NULL || strcmp (delete, "no") != 0); + delete_prop = e_source_get_property (source, "delete"); + can_delete = can_delete && (delete_prop == NULL || strcmp (delete_prop, "no") != 0); client = g_hash_table_lookup ( task_shell_sidebar->priv->client_table, e_source_peek_uid (source)); refresh_supported = - client && e_cal_get_refresh_supported (client); + client && e_client_check_refresh_supported (E_CLIENT (client)); } if (source != NULL) @@ -639,7 +634,7 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar) static void task_shell_sidebar_client_removed (ETaskShellSidebar *task_shell_sidebar, - ECal *client) + ECalClient *client) { ESourceSelector *selector; GHashTable *client_table; @@ -653,7 +648,7 @@ task_shell_sidebar_client_removed (ETaskShellSidebar *task_shell_sidebar, client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, task_shell_sidebar); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); uid = e_source_peek_uid (source); g_return_if_fail (uid != NULL); @@ -688,9 +683,9 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class) PROP_DEFAULT_CLIENT, g_param_spec_object ( "default-client", - "Default Task Client", + "Default Task ECalClient", "Default client for task operations", - E_TYPE_CAL, + E_TYPE_CAL_CLIENT, G_PARAM_READABLE)); g_object_class_install_property ( @@ -711,7 +706,7 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_TYPE_CAL); + E_TYPE_CAL_CLIENT); signals[CLIENT_REMOVED] = g_signal_new ( "client-removed", @@ -721,7 +716,7 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_TYPE_CAL); + E_TYPE_CAL_CLIENT); signals[STATUS_MESSAGE] = g_signal_new ( "status-message", @@ -804,7 +799,7 @@ e_task_shell_sidebar_get_clients (ETaskShellSidebar *task_shell_sidebar) return g_hash_table_get_values (client_table); } -ECal * +ECalClient * e_task_shell_sidebar_get_default_client (ETaskShellSidebar *task_shell_sidebar) { g_return_val_if_fail ( @@ -830,12 +825,12 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, EShellContent *shell_content; EShellSidebar *shell_sidebar; ETaskShellContent *task_shell_content; - ECalSourceType source_type; + ECalClientSourceType source_type; ESourceSelector *selector; GHashTable *client_table; ECalModel *model; - ECal *default_client; - ECal *client; + ECalClient *default_client; + ECalClient *client; icaltimezone *timezone; const gchar *uid; const gchar *uri; @@ -844,7 +839,7 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, g_return_if_fail (E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar)); g_return_if_fail (E_IS_SOURCE (source)); - source_type = E_CAL_SOURCE_TYPE_TODO; + source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; client_table = task_shell_sidebar->priv->client_table; default_client = task_shell_sidebar->priv->default_client; selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); @@ -859,15 +854,18 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, ESource *default_source; const gchar *default_uid; - default_source = e_cal_get_source (default_client); + default_source = e_client_get_source (E_CLIENT (default_client)); default_uid = e_source_peek_uid (default_source); if (g_strcmp0 (uid, default_uid) == 0) client = g_object_ref (default_client); } - if (client == NULL) - client = e_auth_new_cal_from_source (source, source_type); + if (client == NULL) { + client = e_cal_client_new (source, source_type, NULL); + if (client) + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + } g_return_if_fail (client != NULL); @@ -884,17 +882,12 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, g_hash_table_insert (client_table, g_strdup (uid), client); e_source_selector_select_source (selector, source); - uri = e_cal_get_uri (client); + uri = e_client_get_uri (E_CLIENT (client)); /* Translators: The string field is a URI. */ message = g_strdup_printf (_("Opening tasks at %s"), uri); task_shell_sidebar_emit_status_message (task_shell_sidebar, message); g_free (message); - g_signal_connect_swapped ( - client, "cal-opened-ex", - G_CALLBACK (task_shell_sidebar_client_opened_cb), - task_shell_sidebar); - /* FIXME Sidebar should not be accessing the EShellContent. * This probably needs to be moved to ETaskShellView. */ shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); @@ -905,8 +898,8 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, model = e_task_shell_content_get_task_model (task_shell_content); timezone = e_cal_model_get_timezone (model); - e_cal_set_default_timezone (client, timezone, NULL); - e_cal_open_async (client, FALSE); + e_cal_client_set_default_timezone (client, timezone); + e_client_open (E_CLIENT (client), FALSE, NULL, task_shell_sidebar_client_opened_cb, task_shell_sidebar); } void @@ -914,7 +907,7 @@ e_task_shell_sidebar_remove_source (ETaskShellSidebar *task_shell_sidebar, ESource *source) { GHashTable *client_table; - ECal *client; + ECalClient *client; const gchar *uid; g_return_if_fail (E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar)); diff --git a/modules/calendar/e-task-shell-sidebar.h b/modules/calendar/e-task-shell-sidebar.h index 17e50f8239..24c64cf2af 100644 --- a/modules/calendar/e-task-shell-sidebar.h +++ b/modules/calendar/e-task-shell-sidebar.h @@ -22,7 +22,7 @@ #ifndef E_TASK_SHELL_SIDEBAR_H #define E_TASK_SHELL_SIDEBAR_H -#include <libecal/e-cal.h> +#include <libecal/e-cal-client.h> #include <libedataserverui/e-source-selector.h> #include <shell/e-shell-sidebar.h> @@ -70,9 +70,9 @@ struct _ETaskShellSidebarClass { /* Signals */ void (*client_added) (ETaskShellSidebar *task_shell_sidebar, - ECal *client); + ECalClient *client); void (*client_removed) (ETaskShellSidebar *task_shell_sidebar, - ECal *client); + ECalClient *client); void (*status_message) (ETaskShellSidebar *task_shell_sidebar, const gchar *status_message, gdouble percent); @@ -85,7 +85,7 @@ GtkWidget * e_task_shell_sidebar_new (EShellView *shell_view); GList * e_task_shell_sidebar_get_clients (ETaskShellSidebar *task_shell_sidebar); -ECal * e_task_shell_sidebar_get_default_client +ECalClient * e_task_shell_sidebar_get_default_client (ETaskShellSidebar *task_shell_sidebar); ESourceSelector * e_task_shell_sidebar_get_selector diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c index 297120e29c..4938452309 100644 --- a/modules/calendar/e-task-shell-view-actions.c +++ b/modules/calendar/e-task-shell-view-actions.c @@ -144,7 +144,7 @@ action_task_list_copy_cb (GtkAction *action, copy_source_dialog ( GTK_WINDOW (shell_window), - source, E_CAL_SOURCE_TYPE_TODO); + source, E_CAL_CLIENT_SOURCE_TYPE_TASKS); } static void @@ -157,7 +157,7 @@ action_task_list_delete_cb (GtkAction *action, EShellWindow *shell_window; EShellView *shell_view; ETaskTable *task_table; - ECal *client; + ECalClient *client; ECalModel *model; ESourceSelector *selector; ESourceGroup *source_group; @@ -193,14 +193,14 @@ action_task_list_delete_cb (GtkAction *action, uri = e_source_get_uri (source); client = e_cal_model_get_client_for_uri (model, uri); if (client == NULL) - client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL); + client = e_cal_client_new_from_uri (uri, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL); g_free (uri); g_return_if_fail (client != NULL); - if (!e_cal_remove (client, &error)) { - g_warning ("%s", error->message); - g_error_free (error); + if (!e_client_remove_sync (E_CLIENT (client), NULL, &error)) { + g_debug ("%s: Failed to remove client: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); return; } @@ -214,8 +214,8 @@ action_task_list_delete_cb (GtkAction *action, e_source_group_remove_source (source_group, source); if (!e_source_list_sync (source_list, &error)) { - g_warning ("%s", error->message); - g_error_free (error); + g_debug ("%s: Failed to sync srouce list: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); } } @@ -289,7 +289,7 @@ action_task_list_refresh_cb (GtkAction *action, ETaskShellContent *task_shell_content; ETaskShellSidebar *task_shell_sidebar; ESourceSelector *selector; - ECal *client; + ECalClient *client; ECalModel *model; ESource *source; gchar *uri; @@ -311,14 +311,11 @@ action_task_list_refresh_cb (GtkAction *action, if (client == NULL) return; - g_return_if_fail (e_cal_get_refresh_supported (client)); + g_return_if_fail (e_client_check_refresh_supported (E_CLIENT (client))); - if (!e_cal_refresh (client, &error) && error) { - g_warning ( - "%s: Failed to refresh '%s', %s\n", - G_STRFUNC, e_source_peek_name (source), - error->message); - g_error_free (error); + if (!e_client_refresh_sync (E_CLIENT (client), NULL, &error)) { + g_debug ("%s: Failed to refresh '%s', %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error"); + g_clear_error (&error); } } @@ -407,7 +404,7 @@ action_task_new_cb (GtkAction *action, EShellWindow *shell_window; ETaskShellContent *task_shell_content; ETaskTable *task_table; - ECal *client; + ECalClient *client; ECalComponent *comp; CompEditor *editor; GSList *list; @@ -635,7 +632,7 @@ action_task_save_as_cb (GtkAction *action, return; /* XXX We only save the first selected task. */ - string = e_cal_get_component_as_string ( + string = e_cal_client_get_component_as_string ( comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert task to a string"); diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c index 0ce8339849..77e4beae1e 100644 --- a/modules/calendar/e-task-shell-view-private.c +++ b/modules/calendar/e-task-shell-view-private.c @@ -34,13 +34,13 @@ task_shell_view_model_row_appended_cb (ETaskShellView *task_shell_view, ECalModel *model) { ETaskShellSidebar *task_shell_sidebar; - ECal *client; + ECalClient *client; ESource *source; /* This is the "Click to Add" handler. */ client = e_cal_model_get_default_client (model); - source = e_cal_get_source (client); + source = e_client_get_source (E_CLIENT (client)); task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; e_task_shell_sidebar_add_source (task_shell_sidebar, source); @@ -81,7 +81,7 @@ task_shell_view_table_popup_event_cb (EShellView *shell_view, static void task_shell_view_selector_client_added_cb (ETaskShellView *task_shell_view, - ECal *client) + ECalClient *client) { ETaskShellContent *task_shell_content; ETaskTable *task_table; @@ -97,7 +97,7 @@ task_shell_view_selector_client_added_cb (ETaskShellView *task_shell_view, static void task_shell_view_selector_client_removed_cb (ETaskShellView *task_shell_view, - ECal *client) + ECalClient *client) { ETaskShellContent *task_shell_content; ETaskTable *task_table; @@ -472,39 +472,33 @@ e_task_shell_view_delete_completed (ETaskShellView *task_shell_view) task_shell_view, _("Expunging"), -1.0); for (iter = list; iter != NULL; iter = iter->next) { - ECal *client = E_CAL (iter->data); - GList *objects; - gboolean read_only = TRUE; + ECalClient *client = E_CAL_CLIENT (iter->data); + GSList *objects, *obj; GError *error = NULL; - if (!e_cal_is_read_only (client, &read_only, &error)) { - g_warning ("%s", error->message); - g_error_free (error); - continue; - } - - if (read_only) + if (e_client_is_readonly (E_CLIENT (client))) continue; - if (!e_cal_get_object_list (client, sexp, &objects, &error)) { - g_warning ("%s", error->message); - g_error_free (error); + if (!e_cal_client_get_object_list_sync (client, sexp, &objects, NULL, &error)) { + g_debug ("%s: Failed to get object list: %s", G_STRFUNC, error ? error->message : "Unknown error"); + g_clear_error (&error); continue; } - while (objects != NULL) { - icalcomponent *component = objects->data; + for (obj = objects; obj != NULL; obj = obj->next) { + icalcomponent *component = obj->data; const gchar *uid; uid = icalcomponent_get_uid (component); - if (!e_cal_remove_object (client, uid, &error)) { - g_warning ("%s", error->message); + if (!e_cal_client_remove_object_sync (client, uid, NULL, CALOBJ_MOD_THIS, NULL, &error)) { + g_debug ("%s: Failed to remove object: %s", G_STRFUNC, error ? error->message : "Unknown error"); g_clear_error (&error); } icalcomponent_free (component); - objects = g_list_delete_link (objects, objects); } + + e_cal_client_free_icalcomp_slist (objects); } e_task_shell_view_set_status_message (task_shell_view, NULL, -1.0); @@ -603,10 +597,10 @@ e_task_shell_view_update_timezone (ETaskShellView *task_shell_view) clients = e_task_shell_sidebar_get_clients (task_shell_sidebar); for (iter = clients; iter != NULL; iter = iter->next) { - ECal *client = iter->data; + ECalClient *client = iter->data; - if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) - e_cal_set_default_timezone (client, timezone, NULL); + if (e_client_is_opened (E_CLIENT (client))) + e_cal_client_set_default_timezone (client, timezone); } g_list_free (clients); diff --git a/modules/calendar/e-task-shell-view-private.h b/modules/calendar/e-task-shell-view-private.h index b7dace83b7..ec2173f201 100644 --- a/modules/calendar/e-task-shell-view-private.h +++ b/modules/calendar/e-task-shell-view-private.h @@ -29,6 +29,7 @@ #include <libecal/e-cal-time-util.h> #include <libedataserver/e-categories.h> #include <libedataserver/e-sexp.h> +#include <libedataserverui/e-client-utils.h> #include "e-util/e-dialog-utils.h" #include "e-util/e-file-utils.h" @@ -38,7 +39,6 @@ #include "misc/e-popup-action.h" #include "misc/e-selectable.h" -#include "calendar/common/authentication.h" #include "calendar/gui/calendar-config.h" #include "calendar/gui/comp-util.h" #include "calendar/gui/e-cal-component-preview.h" |