From 38790d8478e906a5c59d0c4a5216f297f305bfeb Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 14 Jun 2011 08:54:20 +0200 Subject: Do not use deprecated EBook/ECal API --- modules/calendar/e-memo-shell-backend.c | 98 +++++++++++++++++---------------- 1 file changed, 50 insertions(+), 48 deletions(-) (limited to 'modules/calendar/e-memo-shell-backend.c') 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 #include -#include +#include #include #include #include #include +#include #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; } -- cgit v1.2.3