aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c382
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h12
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c80
-rw-r--r--addressbook/gui/contact-editor/eab-editor.h1
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c141
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.h10
-rw-r--r--addressbook/gui/merging/eab-contact-compare.c88
-rw-r--r--addressbook/gui/merging/eab-contact-compare.h4
-rw-r--r--addressbook/gui/merging/eab-contact-merging.c141
-rw-r--r--addressbook/gui/merging/eab-contact-merging.h32
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c296
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h16
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.c21
-rw-r--r--addressbook/gui/widgets/e-addressbook-selector.c127
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.c15
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.h2
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c260
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h6
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c38
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.h4
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c95
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h8
-rw-r--r--addressbook/gui/widgets/e-minicard.c1
-rw-r--r--addressbook/gui/widgets/ea-minicard-view.c10
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c204
-rw-r--r--addressbook/gui/widgets/eab-gui-util.h11
-rw-r--r--addressbook/importers/evolution-addressbook-importers.h2
-rw-r--r--addressbook/importers/evolution-csv-importer.c44
-rw-r--r--addressbook/importers/evolution-ldif-importer.c52
-rw-r--r--addressbook/importers/evolution-vcard-importer.c55
-rw-r--r--addressbook/printing/e-contact-print.c171
-rw-r--r--addressbook/printing/e-contact-print.h7
-rw-r--r--addressbook/tools/evolution-addressbook-export-list-cards.c55
-rw-r--r--addressbook/tools/evolution-addressbook-export-list-folders.c51
-rw-r--r--addressbook/tools/evolution-addressbook-export.c2
-rw-r--r--addressbook/util/eab-book-util.c228
-rw-r--r--addressbook/util/eab-book-util.h40
-rw-r--r--calendar/Makefile.am2
-rw-r--r--calendar/common/Makefile.am21
-rw-r--r--calendar/common/authentication.c455
-rw-r--r--calendar/common/authentication.h46
-rw-r--r--calendar/gui/Makefile.am1
-rw-r--r--calendar/gui/alarm-notify/Makefile.am1
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c85
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.h7
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c318
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.h6
-rw-r--r--calendar/gui/alarm-notify/config-data.c8
-rw-r--r--calendar/gui/alarm-notify/config-data.h6
-rw-r--r--calendar/gui/cal-editor-utils.c11
-rw-r--r--calendar/gui/cal-editor-utils.h4
-rw-r--r--calendar/gui/calendar-config.h2
-rw-r--r--calendar/gui/comp-util.c73
-rw-r--r--calendar/gui/comp-util.h22
-rw-r--r--calendar/gui/dialogs/alarm-dialog.c37
-rw-r--r--calendar/gui/dialogs/alarm-dialog.h4
-rw-r--r--calendar/gui/dialogs/alarm-list-dialog.c27
-rw-r--r--calendar/gui/dialogs/alarm-list-dialog.h8
-rw-r--r--calendar/gui/dialogs/calendar-setup.c22
-rw-r--r--calendar/gui/dialogs/cancel-comp.c4
-rw-r--r--calendar/gui/dialogs/cancel-comp.h4
-rw-r--r--calendar/gui/dialogs/comp-editor-page.h2
-rw-r--r--calendar/gui/dialogs/comp-editor.c230
-rw-r--r--calendar/gui/dialogs/comp-editor.h6
-rw-r--r--calendar/gui/dialogs/copy-source-dialog.c178
-rw-r--r--calendar/gui/dialogs/copy-source-dialog.h4
-rw-r--r--calendar/gui/dialogs/delete-error.c10
-rw-r--r--calendar/gui/dialogs/delete-error.h2
-rw-r--r--calendar/gui/dialogs/event-editor.c21
-rw-r--r--calendar/gui/dialogs/event-editor.h2
-rw-r--r--calendar/gui/dialogs/event-page.c103
-rw-r--r--calendar/gui/dialogs/goto-dialog.c2
-rw-r--r--calendar/gui/dialogs/memo-editor.c6
-rw-r--r--calendar/gui/dialogs/memo-editor.h2
-rw-r--r--calendar/gui/dialogs/memo-page.c85
-rw-r--r--calendar/gui/dialogs/recur-comp.c6
-rw-r--r--calendar/gui/dialogs/recur-comp.h4
-rw-r--r--calendar/gui/dialogs/recurrence-page.c41
-rw-r--r--calendar/gui/dialogs/schedule-page.c53
-rw-r--r--calendar/gui/dialogs/select-source-dialog.c14
-rw-r--r--calendar/gui/dialogs/select-source-dialog.h4
-rw-r--r--calendar/gui/dialogs/send-comp.c6
-rw-r--r--calendar/gui/dialogs/send-comp.h6
-rw-r--r--calendar/gui/dialogs/task-details-page.c5
-rw-r--r--calendar/gui/dialogs/task-editor.c17
-rw-r--r--calendar/gui/dialogs/task-editor.h2
-rw-r--r--calendar/gui/dialogs/task-page.c88
-rw-r--r--calendar/gui/dialogs/task-page.h2
-rw-r--r--calendar/gui/e-cal-component-preview.c24
-rw-r--r--calendar/gui/e-cal-component-preview.h4
-rw-r--r--calendar/gui/e-cal-config.h4
-rw-r--r--calendar/gui/e-cal-list-view.c8
-rw-r--r--calendar/gui/e-cal-list-view.h3
-rw-r--r--calendar/gui/e-cal-model-calendar.c11
-rw-r--r--calendar/gui/e-cal-model-memos.c7
-rw-r--r--calendar/gui/e-cal-model-tasks.c14
-rw-r--r--calendar/gui/e-cal-model.c323
-rw-r--r--calendar/gui/e-cal-model.h26
-rw-r--r--calendar/gui/e-calendar-selector.c73
-rw-r--r--calendar/gui/e-calendar-view.c114
-rw-r--r--calendar/gui/e-calendar-view.h14
-rw-r--r--calendar/gui/e-day-view.c64
-rw-r--r--calendar/gui/e-day-view.h3
-rw-r--r--calendar/gui/e-meeting-list-view.c65
-rw-r--r--calendar/gui/e-meeting-store.c50
-rw-r--r--calendar/gui/e-meeting-store.h6
-rw-r--r--calendar/gui/e-memo-list-selector.c189
-rw-r--r--calendar/gui/e-memo-table.c54
-rw-r--r--calendar/gui/e-task-list-selector.c190
-rw-r--r--calendar/gui/e-task-table.c105
-rw-r--r--calendar/gui/e-timezone-entry.h2
-rw-r--r--calendar/gui/e-week-view.c53
-rw-r--r--calendar/gui/e-week-view.h3
-rw-r--r--calendar/gui/gnome-cal.c113
-rw-r--r--calendar/gui/gnome-cal.h2
-rw-r--r--calendar/gui/itip-utils.c129
-rw-r--r--calendar/gui/itip-utils.h20
-rw-r--r--calendar/gui/print.c26
-rw-r--r--calendar/gui/print.h2
-rw-r--r--calendar/gui/tag-calendar.c28
-rw-r--r--calendar/gui/tag-calendar.h6
-rw-r--r--calendar/importers/Makefile.am1
-rw-r--r--calendar/importers/icalendar-importer.c385
-rw-r--r--capplet/settings/mail-capplet-shell.c7
-rw-r--r--composer/e-composer-name-header.c8
-rw-r--r--configure.ac3
-rw-r--r--e-util/e-marshal.list3
-rw-r--r--mail/em-utils.c138
-rw-r--r--mail/importers/pine-importer.c49
-rw-r--r--modules/addressbook/e-book-shell-backend.c98
-rw-r--r--modules/addressbook/e-book-shell-content.c2
-rw-r--r--modules/addressbook/e-book-shell-migrate.c4
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c68
-rw-r--r--modules/addressbook/e-book-shell-view-private.c38
-rw-r--r--modules/addressbook/e-book-shell-view-private.h4
-rw-r--r--modules/addressbook/eab-composer-util.c12
-rw-r--r--modules/addressbook/eab-composer-util.h4
-rw-r--r--modules/calendar/e-cal-attachment-handler.c99
-rw-r--r--modules/calendar/e-cal-shell-backend.c113
-rw-r--r--modules/calendar/e-cal-shell-sidebar.c159
-rw-r--r--modules/calendar/e-cal-shell-sidebar.h8
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c88
-rw-r--r--modules/calendar/e-cal-shell-view-memopad.c6
-rw-r--r--modules/calendar/e-cal-shell-view-private.c44
-rw-r--r--modules/calendar/e-cal-shell-view-private.h4
-rw-r--r--modules/calendar/e-cal-shell-view-taskpad.c10
-rw-r--r--modules/calendar/e-cal-shell-view.c12
-rw-r--r--modules/calendar/e-calendar-preferences.c2
-rw-r--r--modules/calendar/e-memo-shell-backend.c98
-rw-r--r--modules/calendar/e-memo-shell-content.c4
-rw-r--r--modules/calendar/e-memo-shell-sidebar.c161
-rw-r--r--modules/calendar/e-memo-shell-sidebar.h8
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c33
-rw-r--r--modules/calendar/e-memo-shell-view-private.c14
-rw-r--r--modules/calendar/e-task-shell-backend.c96
-rw-r--r--modules/calendar/e-task-shell-content.c8
-rw-r--r--modules/calendar/e-task-shell-sidebar.c167
-rw-r--r--modules/calendar/e-task-shell-sidebar.h8
-rw-r--r--modules/calendar/e-task-shell-view-actions.c33
-rw-r--r--modules/calendar/e-task-shell-view-private.c44
-rw-r--r--modules/calendar/e-task-shell-view-private.h2
-rw-r--r--plugins/bbdb/bbdb.c98
-rw-r--r--plugins/bbdb/bbdb.h11
-rw-r--r--plugins/bbdb/gaimbuddies.c63
-rw-r--r--plugins/caldav/caldav-browse-server.c8
-rw-r--r--plugins/caldav/caldav-source.c19
-rw-r--r--plugins/calendar-file/calendar-file.c8
-rw-r--r--plugins/dbx-import/dbx-importer.c3
-rw-r--r--plugins/default-source/default-source.c16
-rw-r--r--plugins/google-account-setup/google-source.c9
-rw-r--r--plugins/itip-formatter/itip-formatter.c244
-rw-r--r--plugins/itip-formatter/itip-view.c22
-rw-r--r--plugins/itip-formatter/itip-view.h6
-rw-r--r--plugins/mail-to-task/Makefile.am1
-rw-r--r--plugins/mail-to-task/mail-to-task.c98
-rw-r--r--plugins/pst-import/pst-importer.c86
-rw-r--r--plugins/publish-calendar/publish-format-fb.c61
-rw-r--r--plugins/publish-calendar/publish-format-ical.c44
-rw-r--r--plugins/save-calendar/csv-format.c30
-rw-r--r--plugins/save-calendar/format-handler.h4
-rw-r--r--plugins/save-calendar/ical-format.c36
-rw-r--r--plugins/save-calendar/rdf-format.c30
-rw-r--r--plugins/save-calendar/save-calendar.c12
-rw-r--r--plugins/vcard-inline/vcard-inline.c62
-rw-r--r--po/POTFILES.in1
-rw-r--r--widgets/misc/e-contact-map-window.c48
-rw-r--r--widgets/misc/e-contact-map-window.h4
187 files changed, 4828 insertions, 4763 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index b636190777..4088837f90 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -35,7 +35,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libebook/e-address-western.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-categories-dialog.h>
#include <libedataserverui/e-category-completion.h>
#include <libedataserverui/e-source-combo-box.h>
@@ -107,8 +107,8 @@ static EABEditorClass *parent_class = NULL;
/* The arguments we take */
enum {
PROP_0,
- PROP_SOURCE_BOOK,
- PROP_TARGET_BOOK,
+ PROP_SOURCE_CLIENT,
+ PROP_TARGET_CLIENT,
PROP_CONTACT,
PROP_IS_NEW_CONTACT,
PROP_EDITABLE,
@@ -213,7 +213,7 @@ e_contact_editor_contact_added (EABEditor *editor,
if (!error)
return;
- if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
return;
eab_error_dialog (NULL, _("Error adding contact"), error);
@@ -227,7 +227,7 @@ e_contact_editor_contact_modified (EABEditor *editor,
if (!error)
return;
- if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
return;
eab_error_dialog (NULL, _("Error modifying contact"), error);
@@ -241,7 +241,7 @@ e_contact_editor_contact_deleted (EABEditor *editor,
if (!error)
return;
- if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
return;
eab_error_dialog (NULL, _("Error removing contact"), error);
@@ -305,22 +305,22 @@ e_contact_editor_class_init (EContactEditorClass *klass)
g_object_class_install_property (
object_class,
- PROP_SOURCE_BOOK,
+ PROP_SOURCE_CLIENT,
g_param_spec_object (
- "source_book",
- "Source Book",
+ "source_client",
+ "Source EBookClient",
NULL,
- E_TYPE_BOOK,
+ E_TYPE_BOOK_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
- PROP_TARGET_BOOK,
+ PROP_TARGET_CLIENT,
g_param_spec_object (
- "target_book",
- "Target Book",
+ "target_client",
+ "Target EBookClient",
NULL,
- E_TYPE_BOOK,
+ E_TYPE_BOOK_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (
@@ -346,21 +346,19 @@ e_contact_editor_class_init (EContactEditorClass *klass)
g_object_class_install_property (
object_class,
PROP_WRITABLE_FIELDS,
- g_param_spec_object (
+ g_param_spec_pointer (
"writable_fields",
"Writable Fields",
NULL,
- E_TYPE_LIST,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_REQUIRED_FIELDS,
- g_param_spec_object (
+ g_param_spec_pointer (
"required_fields",
"Required Fields",
NULL,
- E_TYPE_LIST,
G_PARAM_READWRITE));
g_object_class_install_property (
@@ -394,9 +392,8 @@ entry_activated (EContactEditor *editor)
static gboolean
is_field_supported (EContactEditor *editor, EContactField field_id)
{
- EList *fields;
+ GSList *fields, *iter;
const gchar *field;
- EIterator *iter;
fields = editor->writable_fields;
if (!fields)
@@ -406,10 +403,8 @@ is_field_supported (EContactEditor *editor, EContactField field_id)
if (!field)
return FALSE;
- for (iter = e_list_get_iterator (fields);
- e_iterator_is_valid (iter);
- e_iterator_next (iter)) {
- const gchar *this_field = e_iterator_get (iter);
+ for (iter = fields; iter; iter = iter->next) {
+ const gchar *this_field = iter->data;
if (!this_field)
continue;
@@ -692,7 +687,7 @@ fill_in_source_field (EContactEditor *editor)
{
GtkWidget *source_menu;
- if (!editor->target_book)
+ if (!editor->target_client)
return;
source_menu = e_builder_get_widget (
@@ -700,7 +695,7 @@ fill_in_source_field (EContactEditor *editor)
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (source_menu),
- e_book_get_source (editor->target_book));
+ e_client_get_source (E_CLIENT (editor->target_client)));
}
static void
@@ -2976,25 +2971,27 @@ init_all (EContactEditor *editor)
}
static void
-contact_editor_book_loaded_cb (ESource *source,
+contact_editor_book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- EContactEditor *editor)
+ gpointer user_data)
{
- EBook *book;
+ ESource *source = E_SOURCE (source_object);
+ EContactEditor *editor = user_data;
+ EClient *client = NULL;
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;
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (book == NULL);
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
+ g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) {
+ g_warn_if_fail (client == NULL);
g_error_free (error);
- goto exit;
-
} else if (error != NULL) {
GtkWidget *source_combo_box;
GtkWindow *parent;
- g_warn_if_fail (book == NULL);
+ g_warn_if_fail (client == NULL);
parent = eab_editor_get_window (EAB_EDITOR (editor));
eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error);
@@ -3005,17 +3002,18 @@ contact_editor_book_loaded_cb (ESource *source,
E_SOURCE_COMBO_BOX (source_combo_box), source);
g_error_free (error);
- goto exit;
- }
+ } else {
+ EBookClient *book_client;
- g_return_if_fail (E_IS_BOOK (book));
+ book_client = E_BOOK_CLIENT (client);
+ g_return_if_fail (book_client != NULL);
- /* FIXME Write a private contact_editor_set_target_book(). */
- g_object_set (editor, "target_book", book, NULL);
+ /* FIXME Write a private contact_editor_set_target_client(). */
+ g_object_set (editor, "target_client", book_client, NULL);
- g_object_unref (book);
+ g_object_unref (book_client);
+ }
-exit:
g_object_unref (editor);
}
@@ -3034,20 +3032,19 @@ source_changed (ESourceComboBox *source_combo_box, EContactEditor *editor)
editor->cancellable = NULL;
}
- if (e_source_equal (e_book_get_source (editor->target_book), source))
+ if (e_source_equal (e_client_get_source (E_CLIENT (editor->target_client)), source))
return;
- if (e_source_equal (e_book_get_source (editor->source_book), source)) {
- g_object_set (editor, "target_book", editor->source_book, NULL);
+ if (e_source_equal (e_client_get_source (E_CLIENT (editor->source_client)), source)) {
+ g_object_set (editor, "target_client", editor->source_client, NULL);
return;
}
editor->cancellable = g_cancellable_new ();
- e_load_book_source_async (
- source, parent, editor->cancellable,
- (GAsyncReadyCallback) contact_editor_book_loaded_cb,
- g_object_ref (editor));
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, editor->cancellable,
+ e_client_utils_authenticate_handler, parent,
+ contact_editor_book_loaded_cb, g_object_ref (editor));
}
static void
@@ -3348,10 +3345,15 @@ typedef struct {
} EditorCloseStruct;
static void
-contact_moved_cb (EBook *book, const GError *error, EditorCloseStruct *ecs)
+contact_removed_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EditorCloseStruct *ecs = user_data;
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
+ GError *error = NULL;
+
+ e_book_client_remove_contact_finish (book_client, result, &error);
gtk_widget_set_sensitive (ce->app, TRUE);
ce->in_async_call = FALSE;
@@ -3364,44 +3366,43 @@ contact_moved_cb (EBook *book, const GError *error, EditorCloseStruct *ecs)
if (should_close) {
eab_editor_close (EAB_EDITOR (ce));
- }
- else {
+ } else {
ce->changed = FALSE;
- g_object_ref (ce->target_book);
- g_object_unref (ce->source_book);
- ce->source_book = ce->target_book;
+ g_object_ref (ce->target_client);
+ g_object_unref (ce->source_client);
+ ce->source_client = ce->target_client;
sensitize_all (ce);
}
+ if (error)
+ g_error_free (error);
+
g_object_unref (ce);
g_free (ecs->new_id);
g_free (ecs);
}
static void
-contact_added_cb (EBook *book,
- const GError *error,
- const gchar *id,
- EditorCloseStruct *ecs)
+contact_added_cb (EBookClient *book_client, const GError *error, const gchar *id, gpointer closure)
{
+ EditorCloseStruct *ecs = closure;
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
- if (ce->source_book != ce->target_book && e_book_is_writable (ce->source_book) &&
+ if (ce->source_client != ce->target_client && !e_client_is_readonly (E_CLIENT (ce->source_client)) &&
!error && ce->is_new_contact == FALSE) {
ecs->new_id = g_strdup (id);
- e_book_remove_contact_async (
- ce->source_book, ce->contact,
- (EBookAsyncCallback) contact_moved_cb, ecs);
+ e_book_client_remove_contact (
+ ce->source_client, ce->contact, NULL, contact_removed_cb, ecs);
return;
}
gtk_widget_set_sensitive (ce->app, TRUE);
ce->in_async_call = FALSE;
- e_contact_set (ce->contact, E_CONTACT_UID, (gchar *) id);
+ e_contact_set (ce->contact, E_CONTACT_UID, id);
eab_editor_contact_added (EAB_EDITOR (ce), error, ce->contact);
@@ -3410,8 +3411,7 @@ contact_added_cb (EBook *book,
if (should_close) {
eab_editor_close (EAB_EDITOR (ce));
- }
- else {
+ } else {
ce->changed = FALSE;
sensitize_all (ce);
}
@@ -3422,8 +3422,9 @@ contact_added_cb (EBook *book,
}
static void
-contact_modified_cb (EBook *book, const GError *error, EditorCloseStruct *ecs)
+contact_modified_cb (EBookClient *book_client, const GError *error, gpointer closure)
{
+ EditorCloseStruct *ecs = closure;
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
@@ -3446,6 +3447,20 @@ contact_modified_cb (EBook *book, const GError *error, EditorCloseStruct *ecs)
g_free (ecs);
}
+static void
+contact_modified_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ GError *error = NULL;
+
+ e_book_client_modify_contact_finish (book_client, result, &error);
+
+ contact_modified_cb (book_client, error, user_data);
+
+ if (error)
+ g_error_free (error);
+}
+
/* Emits the signal to request saving a contact */
static void
real_save_contact (EContactEditor *ce, gboolean should_close)
@@ -3461,23 +3476,24 @@ real_save_contact (EContactEditor *ce, gboolean should_close)
gtk_widget_set_sensitive (ce->app, FALSE);
ce->in_async_call = TRUE;
- if (ce->source_book != ce->target_book) {
+ if (ce->source_client != ce->target_client) {
/* Two-step move; add to target, then remove from source */
eab_merging_book_add_contact (
- ce->target_book, ce->contact,
- (EBookIdAsyncCallback) contact_added_cb, ecs);
+ ce->target_client, ce->contact,
+ contact_added_cb, ecs);
} else {
if (ce->is_new_contact)
eab_merging_book_add_contact (
- ce->target_book, ce->contact,
- (EBookIdAsyncCallback) contact_added_cb, ecs);
+ ce->target_client, ce->contact,
+ contact_added_cb, ecs);
else if (ce->check_merge)
- eab_merging_book_commit_contact (
- ce->target_book, ce->contact,
- (EBookAsyncCallback) contact_modified_cb, ecs);
+ eab_merging_book_modify_contact (
+ ce->target_client, ce->contact,
+ contact_modified_cb, ecs);
else
- e_book_commit_contact_async (ce->target_book, ce->contact,
- (EBookAsyncCallback) contact_modified_cb, ecs);
+ e_book_client_modify_contact (
+ ce->target_client, ce->contact, NULL,
+ contact_modified_ready_cb, ecs);
}
}
@@ -3488,10 +3504,10 @@ save_contact (EContactEditor *ce, gboolean should_close)
const gchar *name_entry_string, *file_as_entry_string, *company_name_string;
GtkWidget *entry_fullname, *entry_file_as, *company_name;
- if (!ce->target_book)
+ if (!ce->target_client)
return;
- if (ce->target_editable && !e_book_is_writable (ce->source_book)) {
+ if (ce->target_editable && e_client_is_readonly (E_CLIENT (ce->source_client))) {
if (e_alert_run_dialog_for_args (
GTK_WINDOW (ce->app),
"addressbook:prompt-move",
@@ -3592,7 +3608,7 @@ e_contact_editor_is_valid (EABEditor *editor)
EContactEditor *ce = E_CONTACT_EDITOR (editor);
GtkWidget *widget;
gboolean validation_error = FALSE;
- EIterator *iter;
+ GSList *iter;
GString *errmsg = g_string_new (_("The contact data is invalid:\n\n"));
widget = e_builder_get_widget (ce->builder, "dateedit-birthday");
@@ -3610,11 +3626,8 @@ e_contact_editor_is_valid (EABEditor *editor)
validation_error = TRUE;
}
- iter = e_list_get_iterator (ce->required_fields);
- for (e_iterator_last (iter);
- e_iterator_is_valid (iter);
- e_iterator_prev (iter)) {
- const gchar *field_name = e_iterator_get (iter);
+ for (iter = ce->required_fields; iter; iter = iter->next) {
+ const gchar *field_name = iter->data;
EContactField field_id = e_contact_field_id (field_name);
if (is_non_string_field (field_id)) {
@@ -3967,11 +3980,11 @@ e_contact_editor_dispose (GObject *object)
}
if (e_contact_editor->writable_fields) {
- g_object_unref (e_contact_editor->writable_fields);
+ e_client_util_free_string_slist (e_contact_editor->writable_fields);
e_contact_editor->writable_fields = NULL;
}
if (e_contact_editor->required_fields) {
- g_object_unref (e_contact_editor->required_fields);
+ e_client_util_free_string_slist (e_contact_editor->required_fields);
e_contact_editor->required_fields = NULL;
}
if (e_contact_editor->contact) {
@@ -3979,17 +3992,17 @@ e_contact_editor_dispose (GObject *object)
e_contact_editor->contact = NULL;
}
- if (e_contact_editor->source_book) {
- g_object_unref (e_contact_editor->source_book);
- e_contact_editor->source_book = NULL;
+ if (e_contact_editor->source_client) {
+ g_object_unref (e_contact_editor->source_client);
+ e_contact_editor->source_client = NULL;
}
- if (e_contact_editor->target_book) {
+ if (e_contact_editor->target_client) {
g_signal_handler_disconnect (
- e_contact_editor->target_book,
+ e_contact_editor->target_client,
e_contact_editor->target_editable_id);
- g_object_unref (e_contact_editor->target_book);
- e_contact_editor->target_book = NULL;
+ g_object_unref (e_contact_editor->target_client);
+ e_contact_editor->target_client = NULL;
}
if (e_contact_editor->name) {
@@ -4012,46 +4025,78 @@ e_contact_editor_dispose (GObject *object)
}
static void
-supported_fields_cb (EBook *book,
- const GError *error,
- EList *fields,
- EContactEditor *ce)
+supported_fields_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EContactEditor *ce = user_data;
+ gchar *prop_value = NULL;
+ GSList *fields;
+ GError *error = NULL;
+
+ if (!e_client_get_backend_property_finish (E_CLIENT (book_client), result, &prop_value, &error))
+ prop_value = NULL;
+
+ if (error) {
+ g_debug ("%s: Failed to get supported fields: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
if (!g_slist_find (eab_editor_get_all_editors (), ce)) {
g_warning (
"supported_fields_cb called for book that's still "
"around, but contact editor that's been destroyed.");
+ g_free (prop_value);
return;
}
+ fields = e_client_util_parse_comma_strings (prop_value);
+
g_object_set (ce, "writable_fields", fields, NULL);
+ e_client_util_free_string_slist (fields);
+ g_free (prop_value);
+
eab_editor_show (EAB_EDITOR (ce));
sensitize_all (ce);
}
static void
-required_fields_cb (EBook *book,
- const GError *error,
- EList *fields,
- EContactEditor *ce)
+required_fields_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EContactEditor *ce = user_data;
+ gchar *prop_value = NULL;
+ GSList *fields;
+ GError *error = NULL;
+
+ if (!e_client_get_backend_property_finish (E_CLIENT (book_client), result, &prop_value, &error))
+ prop_value = NULL;
+
+ if (error) {
+ g_debug ("%s: Failed to get supported fields: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
if (!g_slist_find (eab_editor_get_all_editors (), ce)) {
g_warning (
"supported_fields_cb called for book that's still "
"around, but contact editor that's been destroyed.");
+ g_free (prop_value);
return;
}
+ fields = e_client_util_parse_comma_strings (prop_value);
+
g_object_set (ce, "required_fields", fields, NULL);
+ e_client_util_free_string_slist (fields);
+ g_free (prop_value);
}
EABEditor *
e_contact_editor_new (EShell *shell,
- EBook *book,
+ EBookClient *book_client,
EContact *contact,
gboolean is_new_contact,
gboolean editable)
@@ -4059,34 +4104,29 @@ e_contact_editor_new (EShell *shell,
EABEditor *editor;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- g_return_val_if_fail (E_IS_BOOK (book), NULL);
+ g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), NULL);
g_return_val_if_fail (E_IS_CONTACT (contact), NULL);
editor = g_object_new (E_TYPE_CONTACT_EDITOR, "shell", shell, NULL);
g_object_set (
editor,
- "source_book", book,
+ "source_client", book_client,
"contact", contact,
"is_new_contact", is_new_contact,
"editable", editable,
NULL);
- if (book)
- e_book_get_supported_fields_async (
- book, (EBookEListAsyncCallback)
- supported_fields_cb, editor);
-
return editor;
}
static void
-writable_changed (EBook *book, gboolean writable, EContactEditor *ce)
+notify_readonly_cb (EBookClient *book_client, EContactEditor *ce)
{
gint new_target_editable;
gboolean changed = FALSE;
- new_target_editable = e_book_is_writable (ce->target_book);
+ new_target_editable = !e_client_is_readonly (E_CLIENT (ce->target_client));
if (ce->target_editable != new_target_editable)
changed = TRUE;
@@ -4108,41 +4148,35 @@ e_contact_editor_set_property (GObject *object,
editor = E_CONTACT_EDITOR (object);
switch (prop_id) {
- case PROP_SOURCE_BOOK: {
+ case PROP_SOURCE_CLIENT: {
gboolean writable;
gboolean changed = FALSE;
- EBook *source_book;
+ EBookClient *source_client;
- source_book = E_BOOK (g_value_get_object (value));
+ source_client = E_BOOK_CLIENT (g_value_get_object (value));
- if (source_book == editor->source_book)
+ if (source_client == editor->source_client)
break;
- if (editor->source_book)
- g_object_unref (editor->source_book);
+ if (editor->source_client)
+ g_object_unref (editor->source_client);
- editor->source_book = source_book;
- g_object_ref (editor->source_book);
+ editor->source_client = source_client;
+ g_object_ref (editor->source_client);
- if (!editor->target_book) {
- editor->target_book = editor->source_book;
- g_object_ref (editor->target_book);
+ if (!editor->target_client) {
+ editor->target_client = editor->source_client;
+ g_object_ref (editor->target_client);
editor->target_editable_id = g_signal_connect (
- editor->target_book, "writable_status",
- G_CALLBACK (writable_changed), editor);
-
- e_book_get_supported_fields_async (
- editor->target_book,
- (EBookEListAsyncCallback)
- supported_fields_cb, editor);
- e_book_get_required_fields_async (
- editor->target_book,
- (EBookEListAsyncCallback)
- required_fields_cb, editor);
+ editor->target_client, "notify::readonly",
+ G_CALLBACK (notify_readonly_cb), editor);
+
+ e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, NULL, supported_fields_cb, editor);
+ e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, NULL, required_fields_cb, editor);
}
- writable = e_book_is_writable (editor->target_book);
+ writable = !e_client_is_readonly (E_CLIENT (editor->target_client));
if (writable != editor->target_editable) {
editor->target_editable = writable;
changed = TRUE;
@@ -4154,43 +4188,35 @@ e_contact_editor_set_property (GObject *object,
break;
}
- case PROP_TARGET_BOOK: {
+ case PROP_TARGET_CLIENT: {
gboolean writable;
gboolean changed = FALSE;
- EBook *target_book;
+ EBookClient *target_client;
- target_book = E_BOOK (g_value_get_object (value));
+ target_client = E_BOOK_CLIENT (g_value_get_object (value));
- if (target_book == editor->target_book)
+ if (target_client == editor->target_client)
break;
- if (editor->target_book) {
- g_signal_handler_disconnect (
- editor->target_book,
- editor->target_editable_id);
- g_object_unref (editor->target_book);
+ if (editor->target_client) {
+ g_signal_handler_disconnect (editor->target_client, editor->target_editable_id);
+ g_object_unref (editor->target_client);
}
- editor->target_book = target_book;
- g_object_ref (editor->target_book);
+ editor->target_client = target_client;
+ g_object_ref (editor->target_client);
editor->target_editable_id = g_signal_connect (
- editor->target_book, "writable_status",
- G_CALLBACK (writable_changed), editor);
-
- e_book_get_supported_fields_async (
- editor->target_book,
- (EBookEListAsyncCallback)
- supported_fields_cb, editor);
-
- e_book_get_required_fields_async (
- editor->target_book,
- (EBookEListAsyncCallback)
- required_fields_cb, editor);
+ editor->target_client, "notify::readonly",
+ G_CALLBACK (notify_readonly_cb), editor);
+
+ e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS, NULL, supported_fields_cb, editor);
+ e_client_get_backend_property (E_CLIENT (editor->target_client), BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS, NULL, required_fields_cb, editor);
+
if (!editor->is_new_contact)
editor->changed = TRUE;
- writable = e_book_is_writable (editor->target_book);
+ writable = !e_client_is_readonly (E_CLIENT (editor->target_client));
if (writable != editor->target_editable) {
editor->target_editable = writable;
@@ -4238,24 +4264,16 @@ e_contact_editor_set_property (GObject *object,
}
case PROP_WRITABLE_FIELDS:
if (editor->writable_fields)
- g_object_unref (editor->writable_fields);
+ e_client_util_free_string_slist (editor->writable_fields);
- editor->writable_fields = g_value_get_object (value);
- if (editor->writable_fields)
- g_object_ref (editor->writable_fields);
- else
- editor->writable_fields = e_list_new (NULL, NULL, NULL);
+ editor->writable_fields = e_client_util_copy_string_slist (NULL, g_value_get_pointer (value));
sensitize_all (editor);
break;
case PROP_REQUIRED_FIELDS:
if (editor->required_fields)
- g_object_unref (editor->required_fields);
- editor->required_fields = g_value_get_object (value);
- if (editor->required_fields)
- g_object_ref (editor->required_fields);
- else
- editor->required_fields = e_list_new (NULL, NULL, NULL);
+ e_client_util_free_string_slist (editor->required_fields);
+ editor->required_fields = e_client_util_copy_string_slist (NULL, g_value_get_pointer (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -4274,12 +4292,12 @@ e_contact_editor_get_property (GObject *object,
e_contact_editor = E_CONTACT_EDITOR (object);
switch (prop_id) {
- case PROP_SOURCE_BOOK:
- g_value_set_object (value, e_contact_editor->source_book);
+ case PROP_SOURCE_CLIENT:
+ g_value_set_object (value, e_contact_editor->source_client);
break;
- case PROP_TARGET_BOOK:
- g_value_set_object (value, e_contact_editor->target_book);
+ case PROP_TARGET_CLIENT:
+ g_value_set_object (value, e_contact_editor->target_client);
break;
case PROP_CONTACT:
@@ -4303,20 +4321,10 @@ e_contact_editor_get_property (GObject *object,
break;
case PROP_WRITABLE_FIELDS:
- if (e_contact_editor->writable_fields)
- g_value_set_object (
- value, e_list_duplicate (
- e_contact_editor->writable_fields));
- else
- g_value_set_object (value, NULL);
+ g_value_set_pointer (value, e_contact_editor->writable_fields);
break;
case PROP_REQUIRED_FIELDS:
- if (e_contact_editor->required_fields)
- g_value_set_object (
- value, e_list_duplicate (
- e_contact_editor->required_fields));
- else
- g_value_set_object (value, NULL);
+ g_value_set_pointer (value, e_contact_editor->required_fields);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index 2f00a12f67..7f39fe421e 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -25,7 +25,7 @@
#include "addressbook/gui/contact-editor/eab-editor.h"
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
#include <gtk/gtk.h>
@@ -55,8 +55,8 @@ struct _EContactEditor
EABEditor object;
/* item specific fields */
- EBook *source_book;
- EBook *target_book;
+ EBookClient *source_client;
+ EBookClient *target_client;
EContact *contact;
GtkBuilder *builder;
@@ -90,9 +90,9 @@ struct _EContactEditor
/* Whether to try to reduce space used */
guint compress_ui : 1;
- EList *writable_fields;
+ GSList *writable_fields;
- EList *required_fields;
+ GSList *required_fields;
GCancellable *cancellable;
@@ -110,7 +110,7 @@ struct _EContactEditorClass
GType e_contact_editor_get_type (void);
EABEditor *e_contact_editor_new (EShell *shell,
- EBook *book,
+ EBookClient *book_client,
EContact *contact,
gboolean is_new_contact,
gboolean editable);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index c7a42233c2..ac46c0ecfc 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -28,9 +28,9 @@
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-combo-box.h>
#include <addressbook/util/eab-book-util.h>
#include "e-contact-editor.h"
@@ -121,37 +121,42 @@ quick_add_set_vcard (QuickAdd *qa, const gchar *vcard)
}
static void
-merge_cb (ESource *source,
- GAsyncResult *result,
- QuickAdd *qa)
+merge_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
+ ESource *source = E_SOURCE (source_object);
+ QuickAdd *qa = user_data;
+ EClient *client = NULL;
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;
/* Ignore cancellations. */
- 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);
return;
+ }
if (!error) {
- if (e_book_is_writable (book))
- eab_merging_book_add_contact (book, qa->contact, NULL, NULL);
+ if (!e_client_is_readonly (client))
+ eab_merging_book_add_contact (E_BOOK_CLIENT (client), qa->contact, NULL, NULL);
else
e_alert_run_dialog_for_args (e_shell_get_active_window (NULL),
"addressbook:error-read-only",
- e_source_peek_name (e_book_get_source (book)),
+ e_source_peek_name (e_client_get_source (client)),
NULL);
if (qa->cb)
qa->cb (qa->contact, qa->closure);
- g_object_unref (book);
+ g_object_unref (client);
} else {
/* Something went wrong. */
- if (book)
- g_object_unref (book);
+ if (client)
+ g_object_unref (client);
if (qa->cb)
qa->cb (NULL, qa->closure);
+ g_error_free (error);
}
quick_add_unref (qa);
@@ -167,9 +172,9 @@ quick_add_merge_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
- e_load_book_source_async (
- qa->source, NULL, qa->cancellable,
- (GAsyncReadyCallback) merge_cb, qa);
+ e_client_utils_open_new (qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, qa->cancellable,
+ e_client_utils_authenticate_handler, NULL,
+ merge_cb, qa);
}
/* Raise a contact editor with all fields editable,
@@ -177,7 +182,7 @@ quick_add_merge_contact (QuickAdd *qa)
static void
contact_added_cb (EContactEditor *ce,
- EBookStatus status,
+ const GError *error,
EContact *contact,
gpointer closure)
{
@@ -204,7 +209,7 @@ editor_closed_cb (GtkWidget *w, gpointer closure)
}
static void
-ce_have_contact (EBook *book,
+ce_have_contact (EBookClient *book_client,
const GError *error,
EContact *contact,
gpointer closure)
@@ -212,8 +217,8 @@ ce_have_contact (EBook *book,
QuickAdd *qa = (QuickAdd *) closure;
if (error) {
- if (book)
- g_object_unref (book);
+ if (book_client)
+ g_object_unref (book_client);
g_warning (
"Failed to find contact, status %d (%s).",
error->code, error->message);
@@ -231,7 +236,7 @@ ce_have_contact (EBook *book,
shell = e_shell_get_default ();
contact_editor = e_contact_editor_new (
- shell, book, qa->contact, TRUE, TRUE /* XXX */);
+ shell, book_client, qa->contact, TRUE, TRUE /* XXX */);
/* Mark it as changed so the Save buttons are
* enabled when we bring up the dialog. */
@@ -256,31 +261,36 @@ ce_have_contact (EBook *book,
G_CALLBACK (editor_closed_cb),
NULL);
- g_object_unref (book);
+ g_object_unref (book_client);
}
}
static void
-ce_have_book (ESource *source,
- GAsyncResult *result,
- QuickAdd *qa)
+ce_have_book (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
+ ESource *source = E_SOURCE (source_object);
+ QuickAdd *qa = user_data;
+ EClient *client = NULL;
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;
/* Ignore cancellations. */
- 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);
return;
+ }
if (error) {
- if (book)
- g_object_unref (book);
+ if (client)
+ g_object_unref (client);
g_warning ("Couldn't open local address book (%s).", error->message);
quick_add_unref (qa);
+ g_error_free (error);
} else {
- eab_merging_book_find_contact (book, qa->contact, ce_have_contact, qa);
+ eab_merging_book_find_contact (E_BOOK_CLIENT (client), qa->contact, ce_have_contact, qa);
}
}
@@ -294,9 +304,9 @@ edit_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
- e_load_book_source_async (
- qa->source, NULL, qa->cancellable,
- (GAsyncReadyCallback) ce_have_book, qa);
+ e_client_utils_open_new (qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, qa->cancellable,
+ e_client_utils_authenticate_handler, NULL,
+ ce_have_book, qa);
}
#define QUICK_ADD_RESPONSE_EDIT_FULL 2
diff --git a/addressbook/gui/contact-editor/eab-editor.h b/addressbook/gui/contact-editor/eab-editor.h
index 5623aa5bd4..43e36e53a3 100644
--- a/addressbook/gui/contact-editor/eab-editor.h
+++ b/addressbook/gui/contact-editor/eab-editor.h
@@ -25,7 +25,6 @@
#define __EAB_EDITOR_H__
#include <gtk/gtk.h>
-#include <libebook/e-book.h>
#include <libebook/e-contact.h>
#include <shell/e-shell.h>
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 3fae1a2013..a4f30ca573 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -37,7 +37,7 @@
#include <gdk/gdkkeysyms.h>
#include <camel/camel.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-combo-box.h>
#include "e-util/e-util.h"
@@ -90,7 +90,7 @@
enum {
PROP_0,
- PROP_BOOK,
+ PROP_CLIENT,
PROP_CONTACT,
PROP_IS_NEW_LIST,
PROP_EDITABLE
@@ -103,7 +103,7 @@ typedef struct {
struct _EContactListEditorPrivate {
- EBook *book;
+ EBookClient *book_client;
EContact *contact;
GtkBuilder *builder;
@@ -208,17 +208,20 @@ contact_list_editor_add_email (EContactListEditor *editor)
}
static void
-contact_list_editor_book_loaded_cb (ESource *source,
+contact_list_editor_book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- EContactListEditor *editor)
+ gpointer user_data)
{
+ ESource *source = E_SOURCE (source_object);
+ EContactListEditor *editor = user_data;
EContactListEditorPrivate *priv = editor->priv;
EContactStore *contact_store;
ENameSelectorEntry *entry;
- EBook *book;
+ EClient *client = NULL;
+ EBookClient *book_client;
GError *error = NULL;
- book = e_load_book_source_finish (source, result, &error);
+ e_client_utils_open_new_finish (source, result, &client, &error);
if (error != NULL) {
GtkWindow *parent;
@@ -228,20 +231,21 @@ contact_list_editor_book_loaded_cb (ESource *source,
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (WIDGET (SOURCE_MENU)),
- e_book_get_source (priv->book));
+ e_client_get_source (E_CLIENT (priv->book_client)));
g_error_free (error);
goto exit;
}
- g_return_if_fail (E_IS_BOOK (book));
+ book_client = E_BOOK_CLIENT (client);
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
entry = E_NAME_SELECTOR_ENTRY (WIDGET (EMAIL_ENTRY));
contact_store = e_name_selector_entry_peek_contact_store (entry);
- e_contact_store_add_book (contact_store, book);
- e_contact_list_editor_set_book (editor, book);
+ e_contact_store_add_client (contact_store, book_client);
+ e_contact_list_editor_set_client (editor, book_client);
- g_object_unref (book);
+ g_object_unref (book_client);
exit:
g_object_unref (editor);
@@ -261,11 +265,12 @@ contact_list_editor_contact_exists (EContactListModel *model,
}
static void
-contact_list_editor_list_added_cb (EBook *book,
+contact_list_editor_list_added_cb (EBookClient *book_client,
const GError *error,
const gchar *id,
- EditorCloseStruct *ecs)
+ gpointer closure)
{
+ EditorCloseStruct *ecs = closure;
EContactListEditor *editor = ecs->editor;
EContactListEditorPrivate *priv = editor->priv;
gboolean should_close = ecs->should_close;
@@ -292,10 +297,11 @@ contact_list_editor_list_added_cb (EBook *book,
}
static void
-contact_list_editor_list_modified_cb (EBook *book,
+contact_list_editor_list_modified_cb (EBookClient *book_client,
const GError *error,
- EditorCloseStruct *ecs)
+ gpointer closure)
{
+ EditorCloseStruct *ecs = closure;
EContactListEditor *editor = ecs->editor;
EContactListEditorPrivate *priv = editor->priv;
gboolean should_close = ecs->should_close;
@@ -500,7 +506,7 @@ contact_list_editor_drag_data_received_cb (GtkWidget *widget,
gboolean changed = FALSE;
gboolean handled = FALSE;
const guchar *data;
- GList *list, *iter;
+ GSList *list, *iter;
GdkAtom target;
gint n_addresses = 0;
gchar *text;
@@ -546,8 +552,7 @@ contact_list_editor_drag_data_received_cb (GtkWidget *widget,
}
}
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ e_client_util_free_object_slist (list);
contact_list_editor_scroll_to_end (editor);
@@ -894,21 +899,17 @@ void
contact_list_editor_source_menu_changed_cb (GtkWidget *widget)
{
EContactListEditor *editor;
- GtkWindow *parent;
ESource *source;
editor = contact_list_editor_extract (widget);
source = e_source_combo_box_get_active (E_SOURCE_COMBO_BOX (widget));
- if (e_source_equal (e_book_get_source (editor->priv->book), source))
+ if (e_source_equal (e_client_get_source (E_CLIENT (editor->priv->book_client)), source))
return;
- parent = eab_editor_get_window (EAB_EDITOR (editor));
-
- e_load_book_source_async (
- source, parent, NULL, (GAsyncReadyCallback)
- contact_list_editor_book_loaded_cb,
- g_object_ref (editor));
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, eab_editor_get_window (EAB_EDITOR (editor)),
+ contact_list_editor_book_loaded_cb, g_object_ref (editor));
}
gboolean
@@ -1097,7 +1098,7 @@ contact_list_editor_bottom_button_clicked_cb (GtkButton *button)
/******************** GtkBuilder Custom Widgets Functions ********************/
static gpointer
-contact_editor_fudge_new (EBook *book,
+contact_editor_fudge_new (EBookClient *book_client,
EContact *contact,
gboolean is_new,
gboolean editable)
@@ -1108,11 +1109,11 @@ contact_editor_fudge_new (EBook *book,
* was a terrible idea. Now we're stuck with it. */
return e_contact_editor_new (
- shell, book, contact, is_new, editable);
+ shell, book_client, contact, is_new, editable);
}
static gpointer
-contact_list_editor_fudge_new (EBook *book,
+contact_list_editor_fudge_new (EBookClient *book_client,
EContact *contact,
gboolean is_new,
gboolean editable)
@@ -1123,20 +1124,19 @@ contact_list_editor_fudge_new (EBook *book,
* was a terrible idea. Now we're stuck with it. */
return e_contact_list_editor_new (
- shell, book, contact, is_new, editable);
+ shell, book_client, contact, is_new, editable);
}
static void
setup_custom_widgets (EContactListEditor *editor)
{
- const gchar *key = "/apps/evolution/addressbook/sources";
GtkWidget *combo_box;
- GConfClient *client;
ESourceList *source_list;
ENameSelectorEntry *name_selector_entry;
ENameSelector *name_selector;
GtkWidget *old, *parent;
EContactListEditorPrivate *priv;
+ GError *error = NULL;
guint ba = 0, la = 0, ra = 0, ta = 0, xo = 0, xp = 0, yo = 0, yp = 0;
g_return_if_fail (editor != NULL);
@@ -1144,11 +1144,16 @@ setup_custom_widgets (EContactListEditor *editor)
priv = editor->priv;
combo_box = WIDGET (SOURCE_MENU);
- client = gconf_client_get_default ();
- source_list = e_source_list_new_for_gconf (client, key);
+ if (!e_book_client_get_sources (&source_list, &error))
+ source_list = NULL;
g_object_set (G_OBJECT (combo_box), "source-list", source_list, NULL);
- g_object_unref (source_list);
- g_object_unref (client);
+ if (source_list)
+ g_object_unref (source_list);
+
+ if (error) {
+ g_debug ("%s: Failed to get sources: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
g_signal_connect (
combo_box, "changed", G_CALLBACK (
@@ -1237,8 +1242,8 @@ contact_list_editor_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BOOK:
- e_contact_list_editor_set_book (
+ case PROP_CLIENT:
+ e_contact_list_editor_set_client (
E_CONTACT_LIST_EDITOR (object),
g_value_get_object (value));
return;
@@ -1272,10 +1277,10 @@ contact_list_editor_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BOOK:
+ case PROP_CLIENT:
g_value_set_object (
value,
- e_contact_list_editor_get_book (
+ e_contact_list_editor_get_client (
E_CONTACT_LIST_EDITOR (object)));
return;
@@ -1354,7 +1359,7 @@ contact_list_editor_save_contact (EABEditor *eab_editor,
contact = e_contact_list_editor_get_contact (editor);
- if (priv->book == NULL)
+ if (priv->book_client == NULL)
return;
ecs = g_new (EditorCloseStruct, 1);
@@ -1366,11 +1371,11 @@ contact_list_editor_save_contact (EABEditor *eab_editor,
if (priv->is_new_list)
eab_merging_book_add_contact (
- priv->book, contact, (EBookIdAsyncCallback)
+ priv->book_client, contact,
contact_list_editor_list_added_cb, ecs);
else
- eab_merging_book_commit_contact (
- priv->book, contact, (EBookAsyncCallback)
+ eab_merging_book_modify_contact (
+ priv->book_client, contact,
contact_list_editor_list_modified_cb, ecs);
priv->changed = FALSE;
@@ -1411,7 +1416,7 @@ contact_list_editor_contact_added (EABEditor *editor,
if (!error)
return;
- if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
return;
eab_error_dialog (NULL, _("Error adding list"), error);
@@ -1425,7 +1430,7 @@ contact_list_editor_contact_modified (EABEditor *editor,
if (!error)
return;
- if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
return;
eab_error_dialog (NULL, _("Error modifying list"), error);
@@ -1439,7 +1444,7 @@ contact_list_editor_contact_deleted (EABEditor *editor,
if (!error)
return;
- if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
return;
eab_error_dialog (NULL, _("Error removing list"), error);
@@ -1483,12 +1488,12 @@ contact_list_editor_class_init (EContactListEditorClass *class)
g_object_class_install_property (
object_class,
- PROP_BOOK,
+ PROP_CLIENT,
g_param_spec_object (
- "book",
- "Book",
+ "client",
+ "EBookClient",
NULL,
- E_TYPE_BOOK,
+ E_TYPE_BOOK_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (
@@ -1615,7 +1620,7 @@ e_contact_list_editor_get_type (void)
EABEditor *
e_contact_list_editor_new (EShell *shell,
- EBook *book,
+ EBookClient *book_client,
EContact *list_contact,
gboolean is_new_list,
gboolean editable)
@@ -1629,7 +1634,7 @@ e_contact_list_editor_new (EShell *shell,
"shell", shell, NULL);
g_object_set (editor,
- "book", book,
+ "client", book_client,
"contact", list_contact,
"is_new_list", is_new_list,
"editable", editable,
@@ -1638,32 +1643,30 @@ e_contact_list_editor_new (EShell *shell,
return editor;
}
-EBook *
-e_contact_list_editor_get_book (EContactListEditor *editor)
+EBookClient *
+e_contact_list_editor_get_client (EContactListEditor *editor)
{
g_return_val_if_fail (E_IS_CONTACT_LIST_EDITOR (editor), NULL);
- return editor->priv->book;
+ return editor->priv->book_client;
}
void
-e_contact_list_editor_set_book (EContactListEditor *editor,
- EBook *book)
+e_contact_list_editor_set_client (EContactListEditor *editor,
+ EBookClient *book_client)
{
g_return_if_fail (E_IS_CONTACT_LIST_EDITOR (editor));
- g_return_if_fail (E_IS_BOOK (book));
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
- if (editor->priv->book != NULL)
- g_object_unref (editor->priv->book);
- editor->priv->book = g_object_ref (book);
+ if (editor->priv->book_client != NULL)
+ g_object_unref (editor->priv->book_client);
+ editor->priv->book_client = g_object_ref (book_client);
- editor->priv->allows_contact_lists =
- e_book_check_static_capability (
- editor->priv->book, "contact-lists");
+ editor->priv->allows_contact_lists = e_client_check_capability (E_CLIENT (editor->priv->book_client), "contact-lists");
contact_list_editor_update (editor);
- g_object_notify (G_OBJECT (editor), "book");
+ g_object_notify (G_OBJECT (editor), "client");
}
EContact *
@@ -1823,10 +1826,10 @@ e_contact_list_editor_set_contact (EContactListEditor *editor,
g_list_free (email_list);
}
- if (priv->book != NULL) {
+ if (priv->book_client != NULL) {
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (WIDGET (SOURCE_MENU)),
- e_book_get_source (priv->book));
+ e_client_get_source (E_CLIENT (priv->book_client)));
gtk_widget_set_sensitive (
WIDGET (SOURCE_MENU), priv->is_new_list);
}
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
index 11242b3dee..38713ba7ab 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
@@ -27,7 +27,7 @@
#include "addressbook/gui/contact-editor/eab-editor.h"
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
#include <libebook/e-destination.h>
@@ -68,13 +68,13 @@ struct _EContactListEditorClass
GType e_contact_list_editor_get_type (void);
EABEditor * e_contact_list_editor_new (EShell *shell,
- EBook *book,
+ EBookClient *book_client,
EContact *list_contact,
gboolean is_new_list,
gboolean editable);
-EBook * e_contact_list_editor_get_book (EContactListEditor *editor);
-void e_contact_list_editor_set_book (EContactListEditor *editor,
- EBook *book);
+EBookClient * e_contact_list_editor_get_client(EContactListEditor *editor);
+void e_contact_list_editor_set_client(EContactListEditor *editor,
+ EBookClient *book_client);
EContact * e_contact_list_editor_get_contact
(EContactListEditor *editor);
void e_contact_list_editor_set_contact
diff --git a/addressbook/gui/merging/eab-contact-compare.c b/addressbook/gui/merging/eab-contact-compare.c
index 4e226e798c..1ba9b3811f 100644
--- a/addressbook/gui/merging/eab-contact-compare.c
+++ b/addressbook/gui/merging/eab-contact-compare.c
@@ -27,7 +27,8 @@
#include <ctype.h>
#include <string.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libebook/e-book-query.h>
+#include <libedataserverui/e-client-utils.h>
#include "addressbook/util/eab-book-util.h"
#include "eab-contact-compare.h"
@@ -572,24 +573,31 @@ match_search_info_free (MatchSearchInfo *info)
}
static void
-query_cb (EBook *book, const GError *error, GList *contacts, gpointer closure)
+query_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- /* XXX we need to free contacts */
- MatchSearchInfo *info = (MatchSearchInfo *) closure;
+ MatchSearchInfo *info = (MatchSearchInfo *) user_data;
EABContactMatchType best_match = EAB_CONTACT_MATCH_NONE;
EContact *best_contact = NULL;
- GList *remaining_contacts = NULL;
- const GList *i;
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ GSList *remaining_contacts = NULL;
+ GSList *contacts = NULL;
+ GError *error = NULL;
+ const GSList *ii;
+
+ if (result && !e_book_client_get_contacts_finish (book_client, result, &contacts, &error)) {
+ g_debug ("%s: Failed to get contacts: %s\n", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
- if (error) {
info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure);
match_search_info_free (info);
+ g_object_unref (book_client);
return;
}
/* remove the contacts we're to avoid from the list, if they're present */
- for (i = contacts; i != NULL; i = g_list_next (i)) {
- EContact *this_contact = E_CONTACT (i->data);
+ for (ii = contacts; ii != NULL; ii = g_slist_next (ii)) {
+ EContact *this_contact = E_CONTACT (ii->data);
const gchar *this_uid;
GList *iterator;
gboolean avoid = FALSE;
@@ -611,30 +619,36 @@ query_cb (EBook *book, const GError *error, GList *contacts, gpointer closure)
}
}
if (!avoid)
- remaining_contacts = g_list_prepend (remaining_contacts, this_contact);
+ remaining_contacts = g_slist_prepend (remaining_contacts, g_object_ref (this_contact));
}
- remaining_contacts = g_list_reverse (remaining_contacts);
+ remaining_contacts = g_slist_reverse (remaining_contacts);
- for (i = remaining_contacts; i != NULL; i = g_list_next (i)) {
- EContact *this_contact = E_CONTACT (i->data);
+ for (ii = remaining_contacts; ii != NULL; ii = g_slist_next (ii)) {
+ EContact *this_contact = E_CONTACT (ii->data);
EABContactMatchType this_match = eab_contact_compare (info->contact, this_contact);
if ((gint) this_match > (gint) best_match) {
best_match = this_match;
- best_contact = this_contact;
+ best_contact = this_contact;
}
}
- g_list_free (remaining_contacts);
+ if (best_contact)
+ best_contact = g_object_ref (best_contact);
+
+ e_client_util_free_object_slist (contacts);
+ e_client_util_free_object_slist (remaining_contacts);
info->cb (info->contact, best_contact, best_match, info->closure);
match_search_info_free (info);
+ g_object_unref (book_client);
+ g_object_unref (best_contact);
}
#define MAX_QUERY_PARTS 10
static void
-use_common_book (EBook *book,
- MatchSearchInfo *info)
+use_common_book_client (EBookClient *book_client,
+ MatchSearchInfo *info)
{
EContact *contact = info->contact;
EContactName *contact_name;
@@ -645,7 +659,7 @@ use_common_book (EBook *book,
EBookQuery *query = NULL;
gint i;
- if (book == NULL) {
+ if (book_client == NULL) {
info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure);
match_search_info_free (info);
return;
@@ -713,10 +727,14 @@ use_common_book (EBook *book,
query = NULL;
}
- if (query)
- e_book_get_contacts_async (book, query, query_cb, info);
- else
- query_cb (book, NULL, NULL, info);
+ if (query) {
+ gchar *query_str = e_book_query_to_string (query);
+
+ e_book_client_get_contacts (book_client, query_str, NULL, query_cb, info);
+
+ g_free (query_str);
+ } else
+ query_cb (G_OBJECT (book_client), NULL, info);
g_free (qj);
if (query)
@@ -724,14 +742,18 @@ use_common_book (EBook *book,
}
static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- MatchSearchInfo *info)
+ gpointer user_data)
{
- EBook *book;
+ ESource *source = E_SOURCE (source_object);
+ MatchSearchInfo *info = user_data;
+ EClient *client = NULL;
+
+ if (!e_client_utils_open_new_finish (source, result, &client, NULL))
+ client = NULL;
- book = e_load_book_source_finish (source, result, NULL);
- use_common_book (book, info);
+ use_common_book_client (client ? E_BOOK_CLIENT (client): NULL, info);
}
void
@@ -754,7 +776,7 @@ eab_contact_locate_match (EContact *contact,
* Look for the best match and return it using the EABContactMatchQueryCallback.
**/
void
-eab_contact_locate_match_full (EBook *book,
+eab_contact_locate_match_full (EBookClient *book_client,
EContact *contact,
GList *avoid,
EABContactMatchQueryCallback cb,
@@ -773,18 +795,18 @@ eab_contact_locate_match_full (EBook *book,
info->avoid = g_list_copy (avoid);
g_list_foreach (info->avoid, (GFunc) g_object_ref, NULL);
- if (book) {
- use_common_book (book, info);
+ if (book_client) {
+ use_common_book_client (g_object_ref (book_client), info);
return;
}
- if (!e_book_get_addressbooks (&info->source_list, NULL))
+ if (!e_book_client_get_sources (&info->source_list, NULL))
return;
source = e_source_list_peek_default_source (info->source_list);
- e_load_book_source_async (
- source, NULL, NULL, (GAsyncReadyCallback)
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
book_loaded_cb, info);
}
diff --git a/addressbook/gui/merging/eab-contact-compare.h b/addressbook/gui/merging/eab-contact-compare.h
index 4fc8ed1569..df67c5d752 100644
--- a/addressbook/gui/merging/eab-contact-compare.h
+++ b/addressbook/gui/merging/eab-contact-compare.h
@@ -26,7 +26,7 @@
#ifndef __EAB_CONTACT_COMPARE_H__
#define __EAB_CONTACT_COMPARE_H__
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
typedef enum {
@@ -64,7 +64,7 @@ EABContactMatchType eab_contact_compare_telephone (EContact *contact1, EContact
EABContactMatchType eab_contact_compare (EContact *contact1, EContact *contact2);
void eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gpointer closure);
-void eab_contact_locate_match_full (EBook *book, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure);
+void eab_contact_locate_match_full (EBookClient *book_client, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure);
#endif /* __E_CONTACT_COMPARE_H__ */
diff --git a/addressbook/gui/merging/eab-contact-merging.c b/addressbook/gui/merging/eab-contact-merging.c
index 49e9968074..99bb2d39fb 100644
--- a/addressbook/gui/merging/eab-contact-merging.c
+++ b/addressbook/gui/merging/eab-contact-merging.c
@@ -45,15 +45,15 @@ typedef enum {
typedef struct {
EContactMergingOpType op;
- EBook *book;
+ EBookClient *book_client;
/*contact is the new contact which the user has tried to add to the addressbook*/
EContact *contact;
/*match is the duplicate contact already existing in the addressbook*/
EContact *match;
GList *avoid;
- EBookIdAsyncCallback id_cb;
- EBookAsyncCallback cb;
- EBookContactAsyncCallback c_cb;
+ EABMergingAsyncCallback cb;
+ EABMergingIdAsyncCallback id_cb;
+ EABMergingContactAsyncCallback c_cb;
gpointer closure;
} EContactMergingLookup;
@@ -73,7 +73,7 @@ add_lookup (EContactMergingLookup *lookup)
{
if (running_merge_requests < SIMULTANEOUS_MERGING_REQUESTS) {
running_merge_requests++;
- eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup);
+ eab_contact_locate_match_full (lookup->book_client, lookup->contact, lookup->avoid, match_query_callback, lookup);
}
else {
merging_queue = g_list_append (merging_queue, lookup);
@@ -96,14 +96,14 @@ finished_lookup (void)
merging_queue = g_list_remove_link (merging_queue, merging_queue);
running_merge_requests++;
- eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup);
+ eab_contact_locate_match_full (lookup->book_client, lookup->contact, lookup->avoid, match_query_callback, lookup);
}
}
static void
free_lookup (EContactMergingLookup *lookup)
{
- g_object_unref (lookup->book);
+ g_object_unref (lookup->book_client);
g_object_unref (lookup->contact);
g_list_free (lookup->avoid);
if (lookup->match)
@@ -112,12 +112,12 @@ free_lookup (EContactMergingLookup *lookup)
}
static void
-final_id_cb (EBook *book, const GError *error, const gchar *id, gpointer closure)
+final_id_cb (EBookClient *book_client, const GError *error, const gchar *id, gpointer closure)
{
EContactMergingLookup *lookup = closure;
if (lookup->id_cb)
- lookup->id_cb (lookup->book, error, id, lookup->closure);
+ lookup->id_cb (lookup->book_client, error, id, lookup->closure);
free_lookup (lookup);
@@ -125,12 +125,12 @@ final_id_cb (EBook *book, const GError *error, const gchar *id, gpointer closure
}
static void
-final_cb_as_id (EBook *book, const GError *error, gpointer closure)
+final_cb_as_id (EBookClient *book_client, const GError *error, gpointer closure)
{
EContactMergingLookup *lookup = closure;
if (lookup->id_cb)
- lookup->id_cb (lookup->book, error, lookup->contact ? e_contact_get_const (lookup->contact, E_CONTACT_UID) : NULL, lookup->closure);
+ lookup->id_cb (lookup->book_client, error, lookup->contact ? e_contact_get_const (lookup->contact, E_CONTACT_UID) : NULL, lookup->closure);
free_lookup (lookup);
@@ -138,12 +138,12 @@ final_cb_as_id (EBook *book, const GError *error, gpointer closure)
}
static void
-final_cb (EBook *book, const GError *error, gpointer closure)
+final_cb (EBookClient *book_client, const GError *error, gpointer closure)
{
EContactMergingLookup *lookup = closure;
if (lookup->cb)
- lookup->cb (lookup->book, error, lookup->closure);
+ lookup->cb (lookup->book_client, error, lookup->closure);
free_lookup (lookup);
@@ -151,26 +151,67 @@ final_cb (EBook *book, const GError *error, gpointer closure)
}
static void
-doit (EContactMergingLookup *lookup, gboolean force_commit)
+modify_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EContactMergingLookup *lookup = user_data;
+ GError *error = NULL;
+
+ g_return_if_fail (book_client != NULL);
+ g_return_if_fail (lookup != NULL);
+
+ e_book_client_modify_contact_finish (book_client, result, &error);
+
+ if (lookup->op == E_CONTACT_MERGING_ADD)
+ final_cb_as_id (book_client, error, lookup);
+ else
+ final_cb (book_client, error, lookup);
+
+ if (error)
+ g_error_free (error);
+}
+
+static void
+add_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EContactMergingLookup *lookup = user_data;
+ gchar *uid = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (book_client != NULL);
+ g_return_if_fail (lookup != NULL);
+
+ if (!e_book_client_add_contact_finish (book_client, result, &uid, &error))
+ uid = NULL;
+
+ final_id_cb (book_client, error, uid, lookup);
+
+ if (error)
+ g_error_free (error);
+}
+
+static void
+doit (EContactMergingLookup *lookup, gboolean force_modify)
{
if (lookup->op == E_CONTACT_MERGING_ADD) {
- if (force_commit)
- e_book_commit_contact_async (lookup->book, lookup->contact, final_cb_as_id, lookup);
+ if (force_modify)
+ e_book_client_modify_contact (lookup->book_client, lookup->contact, NULL, modify_contact_ready_cb, lookup);
else
- e_book_add_contact_async (lookup->book, lookup->contact, final_id_cb, lookup);
+ e_book_client_add_contact (lookup->book_client, lookup->contact, NULL, add_contact_ready_cb, lookup);
} else if (lookup->op == E_CONTACT_MERGING_COMMIT)
- e_book_commit_contact_async (lookup->book, lookup->contact, final_cb, lookup);
+ e_book_client_modify_contact (lookup->book_client, lookup->contact, NULL, modify_contact_ready_cb, lookup);
}
static void
cancelit (EContactMergingLookup *lookup)
{
- GError *error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED, _("Cancelled"));
+ GError *error = e_client_error_create (E_CLIENT_ERROR_CANCELLED, NULL);
if (lookup->op == E_CONTACT_MERGING_ADD) {
- final_id_cb (lookup->book, error, NULL, lookup);
+ final_id_cb (lookup->book_client, error, NULL, lookup);
} else if (lookup->op == E_CONTACT_MERGING_COMMIT) {
- final_cb (lookup->book, error, lookup);
+ final_cb (lookup->book_client, error, lookup);
}
g_error_free (error);
@@ -209,6 +250,26 @@ dropdown_changed (GtkWidget *dropdown, dropdown_data *data)
return;
}
+static void
+remove_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EContactMergingLookup *lookup = user_data;
+ GError *error = NULL;
+
+ g_return_if_fail (book_client != NULL);
+ g_return_if_fail (lookup != NULL);
+
+ e_book_client_remove_contact_finish (book_client, result, &error);
+
+ if (error) {
+ g_debug ("%s: Failed to remove contact: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ e_book_client_add_contact (book_client, lookup->contact, NULL, add_contact_ready_cb, lookup);
+}
+
static gint
mergeit (EContactMergingLookup *lookup)
{
@@ -373,12 +434,10 @@ mergeit (EContactMergingLookup *lookup)
gtk_widget_show_all ((GtkWidget *) table);
result = gtk_dialog_run (dialog);
- switch (result)
- {
+ switch (result) {
case GTK_RESPONSE_OK:
lookup->contact = lookup->match;
- e_book_remove_contact_async (lookup->book, lookup->match, NULL, lookup);
- e_book_add_contact_async (lookup->book, lookup->contact, final_id_cb, lookup);
+ e_book_client_remove_contact (lookup->book_client, lookup->match, NULL, remove_contact_ready_cb, lookup);
value = 1;
break;
case GTK_RESPONSE_CANCEL:
@@ -472,7 +531,7 @@ match_query_callback (EContact *contact, EContact *match, EABContactMatchType ty
if (lookup->op == E_CONTACT_MERGING_FIND) {
if (lookup->c_cb)
- lookup->c_cb (lookup->book, NULL, (gint) type <= (gint) EAB_CONTACT_MATCH_VAGUE ? NULL : match, lookup->closure);
+ lookup->c_cb (lookup->book_client, NULL, (gint) type <= (gint) EAB_CONTACT_MATCH_VAGUE ? NULL : match, lookup->closure);
free_lookup (lookup);
finished_lookup ();
@@ -547,17 +606,17 @@ match_query_callback (EContact *contact, EContact *match, EABContactMatchType ty
}
gboolean
-eab_merging_book_add_contact (EBook *book,
- EContact *contact,
- EBookIdAsyncCallback cb,
- gpointer closure)
+eab_merging_book_add_contact (EBookClient *book_client,
+ EContact *contact,
+ EABMergingIdAsyncCallback cb,
+ gpointer closure)
{
EContactMergingLookup *lookup;
lookup = g_new (EContactMergingLookup, 1);
lookup->op = E_CONTACT_MERGING_ADD;
- lookup->book = g_object_ref (book);
+ lookup->book_client = g_object_ref (book_client);
lookup->contact = g_object_ref (contact);
lookup->id_cb = cb;
lookup->closure = closure;
@@ -570,17 +629,17 @@ eab_merging_book_add_contact (EBook *book,
}
gboolean
-eab_merging_book_commit_contact (EBook *book,
- EContact *contact,
- EBookAsyncCallback cb,
- gpointer closure)
+eab_merging_book_modify_contact (EBookClient *book_client,
+ EContact *contact,
+ EABMergingAsyncCallback cb,
+ gpointer closure)
{
EContactMergingLookup *lookup;
lookup = g_new (EContactMergingLookup, 1);
lookup->op = E_CONTACT_MERGING_COMMIT;
- lookup->book = g_object_ref (book);
+ lookup->book_client = g_object_ref (book_client);
lookup->contact = g_object_ref (contact);
lookup->cb = cb;
lookup->closure = closure;
@@ -593,17 +652,17 @@ eab_merging_book_commit_contact (EBook *book,
}
gboolean
-eab_merging_book_find_contact (EBook *book,
- EContact *contact,
- EBookContactAsyncCallback cb,
- gpointer closure)
+eab_merging_book_find_contact (EBookClient *book_client,
+ EContact *contact,
+ EABMergingContactAsyncCallback cb,
+ gpointer closure)
{
EContactMergingLookup *lookup;
lookup = g_new (EContactMergingLookup, 1);
lookup->op = E_CONTACT_MERGING_FIND;
- lookup->book = g_object_ref (book);
+ lookup->book_client = g_object_ref (book_client);
lookup->contact = g_object_ref (contact);
lookup->c_cb = cb;
lookup->closure = closure;
diff --git a/addressbook/gui/merging/eab-contact-merging.h b/addressbook/gui/merging/eab-contact-merging.h
index 40d12a5a29..c8e2ddb3ef 100644
--- a/addressbook/gui/merging/eab-contact-merging.h
+++ b/addressbook/gui/merging/eab-contact-merging.h
@@ -26,22 +26,28 @@
#ifndef __E_CONTACT_MERGING_H__
#define __E_CONTACT_MERGING_H__
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
G_BEGIN_DECLS
-gboolean eab_merging_book_add_contact (EBook *book,
- EContact *contact,
- EBookIdAsyncCallback cb,
- gpointer closure);
-gboolean eab_merging_book_commit_contact (EBook *book,
- EContact *contact,
- EBookAsyncCallback cb,
- gpointer closure);
-gboolean eab_merging_book_find_contact (EBook *book,
- EContact *contact,
- EBookContactAsyncCallback cb,
- gpointer closure);
+typedef void (*EABMergingAsyncCallback) (EBookClient *book_client, const GError *error, gpointer closure);
+typedef void (*EABMergingIdAsyncCallback) (EBookClient *book_client, const GError *error, const gchar *id, gpointer closure);
+typedef void (*EABMergingContactAsyncCallback) (EBookClient *book_client, const GError *error, EContact *contact, gpointer closure);
+
+gboolean eab_merging_book_add_contact (EBookClient *book_client,
+ EContact *contact,
+ EABMergingIdAsyncCallback cb,
+ gpointer closure);
+
+gboolean eab_merging_book_modify_contact (EBookClient *book_client,
+ EContact *contact,
+ EABMergingAsyncCallback cb,
+ gpointer closure);
+
+gboolean eab_merging_book_find_contact (EBookClient *book_client,
+ EContact *contact,
+ EABMergingContactAsyncCallback cb,
+ gpointer closure);
G_END_DECLS
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index 30720513d0..497b8fe353 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -32,10 +32,10 @@
#include "eab-gui-util.h"
struct _EAddressbookModelPrivate {
- EBook *book;
- EBookQuery *query;
- EBookView *book_view;
- guint book_view_idle_id;
+ EBookClient *book_client;
+ gchar *query_str;
+ EBookClientView *client_view;
+ guint client_view_idle_id;
/* Query Results */
GPtrArray *contacts;
@@ -58,7 +58,7 @@ struct _EAddressbookModelPrivate {
enum {
PROP_0,
- PROP_BOOK,
+ PROP_CLIENT,
PROP_EDITABLE,
PROP_QUERY
};
@@ -94,25 +94,25 @@ free_data (EAddressbookModel *model)
static void
remove_book_view (EAddressbookModel *model)
{
- if (model->priv->book_view && model->priv->create_contact_id)
+ if (model->priv->client_view && model->priv->create_contact_id)
g_signal_handler_disconnect (
- model->priv->book_view,
+ model->priv->client_view,
model->priv->create_contact_id);
- if (model->priv->book_view && model->priv->remove_contact_id)
+ if (model->priv->client_view && model->priv->remove_contact_id)
g_signal_handler_disconnect (
- model->priv->book_view,
+ model->priv->client_view,
model->priv->remove_contact_id);
- if (model->priv->book_view && model->priv->modify_contact_id)
+ if (model->priv->client_view && model->priv->modify_contact_id)
g_signal_handler_disconnect (
- model->priv->book_view,
+ model->priv->client_view,
model->priv->modify_contact_id);
- if (model->priv->book_view && model->priv->status_message_id)
+ if (model->priv->client_view && model->priv->status_message_id)
g_signal_handler_disconnect (
- model->priv->book_view,
+ model->priv->client_view,
model->priv->status_message_id);
- if (model->priv->book_view && model->priv->view_complete_id)
+ if (model->priv->client_view && model->priv->view_complete_id)
g_signal_handler_disconnect (
- model->priv->book_view,
+ model->priv->client_view,
model->priv->view_complete_id);
if (model->priv->remove_status_id)
g_source_remove (model->priv->remove_status_id);
@@ -126,12 +126,19 @@ remove_book_view (EAddressbookModel *model)
model->priv->search_in_progress = FALSE;
- if (model->priv->book_view) {
- e_book_view_stop (model->priv->book_view);
- g_object_unref (model->priv->book_view);
- model->priv->book_view = NULL;
+ if (model->priv->client_view) {
+ GError *error = NULL;
- g_signal_emit (model, signals[STATUS_MESSAGE], 0, NULL);
+ e_book_client_view_stop (model->priv->client_view, &error);
+ if (error) {
+ g_debug ("%s: Failed to stop client view: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (model->priv->client_view);
+ model->priv->client_view = NULL;
+
+ g_signal_emit (model, signals[STATUS_MESSAGE], 0, NULL, -1);
}
}
@@ -159,9 +166,7 @@ update_folder_bar_message (EAddressbookModel *model)
}
static void
-create_contact (EBookView *book_view,
- const GList *contact_list,
- EAddressbookModel *model)
+view_create_contact_cb (EBookClientView *client_view, const GSList *contact_list, EAddressbookModel *model)
{
GPtrArray *array;
guint count;
@@ -193,12 +198,10 @@ sort_descending (gconstpointer ca,
}
static void
-remove_contact (EBookView *book_view,
- GList *ids,
- EAddressbookModel *model)
+view_remove_contact_cb (EBookClientView *client_view, const GSList *ids, EAddressbookModel *model)
{
/* XXX we should keep a hash around instead of this O(n*m) loop */
- GList *iter;
+ const GSList *iter;
GArray *indices;
GPtrArray *array;
gint ii;
@@ -249,9 +252,7 @@ remove_contact (EBookView *book_view,
}
static void
-modify_contact (EBookView *book_view,
- const GList *contact_list,
- EAddressbookModel *model)
+view_modify_contact_cb (EBookClientView *client_view, const GSList *contact_list, EAddressbookModel *model)
{
GPtrArray *array;
@@ -290,122 +291,109 @@ modify_contact (EBookView *book_view,
}
static void
-status_message (EBookView *book_view,
- gchar * status,
- EAddressbookModel *model)
+view_progress_cb (EBookClientView *client_view, guint percent, const gchar *message, EAddressbookModel *model)
{
if (model->priv->remove_status_id)
g_source_remove (model->priv->remove_status_id);
model->priv->remove_status_id = 0;
- g_signal_emit (model, signals[STATUS_MESSAGE], 0, status);
+ g_signal_emit (model, signals[STATUS_MESSAGE], 0, message, percent);
}
static void
-view_complete (EBookView *book_view,
- EBookViewStatus status,
- const gchar *error_msg,
- EAddressbookModel *model)
+view_complete_cb (EBookClientView *client_view, const GError *error, EAddressbookModel *model)
{
model->priv->search_in_progress = FALSE;
- status_message (book_view, NULL, model);
- g_signal_emit (model, signals[SEARCH_RESULT], 0, status, error_msg);
+ view_progress_cb (client_view, -1, NULL, model);
+ g_signal_emit (model, signals[SEARCH_RESULT], 0, error);
g_signal_emit (model, signals[STOP_STATE_CHANGED], 0);
}
static void
-writable_status (EBook *book,
- gboolean writable,
- EAddressbookModel *model)
+readonly_cb (EBookClient *book_client, EAddressbookModel *model)
{
if (!model->priv->editable_set) {
- model->priv->editable = writable;
+ model->priv->editable = !e_client_is_readonly (E_CLIENT (book_client));
- g_signal_emit (model, signals[WRITABLE_STATUS], 0, writable);
+ g_signal_emit (model, signals[WRITABLE_STATUS], 0, model->priv->editable);
}
}
static void
-backend_died (EBook *book,
- EAddressbookModel *model)
+backend_died_cb (EBookClient *book_client, EAddressbookModel *model)
{
g_signal_emit (model, signals[BACKEND_DIED], 0);
}
static void
-book_view_loaded (EBook *book,
- const GError *error,
- EBookView *book_view,
- gpointer closure)
+client_view_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EAddressbookModel *model = closure;
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EBookClientView *client_view = NULL;
+ EAddressbookModel *model = user_data;
+ GError *error = NULL;
+
+ if (!e_book_client_get_view_finish (book_client, result, &client_view, &error))
+ client_view = NULL;
if (error) {
eab_error_dialog (NULL, _("Error getting book view"), error);
+ g_error_free (error);
return;
}
remove_book_view (model);
free_data (model);
- model->priv->book_view = book_view;
- if (model->priv->book_view)
- g_object_ref (model->priv->book_view);
-
- model->priv->create_contact_id = g_signal_connect (
- model->priv->book_view, "contacts-added",
- G_CALLBACK (create_contact), model);
- model->priv->remove_contact_id = g_signal_connect (
- model->priv->book_view, "contacts-removed",
- G_CALLBACK (remove_contact), model);
- model->priv->modify_contact_id = g_signal_connect (
- model->priv->book_view, "contacts-changed",
- G_CALLBACK (modify_contact), model);
- model->priv->status_message_id = g_signal_connect (
- model->priv->book_view, "status-message",
- G_CALLBACK (status_message), model);
- model->priv->view_complete_id = g_signal_connect (
- model->priv->book_view, "view-complete",
- G_CALLBACK (view_complete), model);
-
- model->priv->search_in_progress = TRUE;
+ model->priv->client_view = client_view;
+ if (model->priv->client_view) {
+ model->priv->create_contact_id = g_signal_connect (
+ model->priv->client_view, "objects-added",
+ G_CALLBACK (view_create_contact_cb), model);
+ model->priv->remove_contact_id = g_signal_connect (
+ model->priv->client_view, "objects-removed",
+ G_CALLBACK (view_remove_contact_cb), model);
+ model->priv->modify_contact_id = g_signal_connect (
+ model->priv->client_view, "objects-modified",
+ G_CALLBACK (view_modify_contact_cb), model);
+ model->priv->status_message_id = g_signal_connect (
+ model->priv->client_view, "progress",
+ G_CALLBACK (view_progress_cb), model);
+ model->priv->view_complete_id = g_signal_connect (
+ model->priv->client_view, "complete",
+ G_CALLBACK (view_complete_cb), model);
+
+ model->priv->search_in_progress = TRUE;
+ }
+
g_signal_emit (model, signals[MODEL_CHANGED], 0);
g_signal_emit (model, signals[SEARCH_STARTED], 0);
g_signal_emit (model, signals[STOP_STATE_CHANGED], 0);
- e_book_view_start (model->priv->book_view);
+ if (model->priv->client_view) {
+ e_book_client_view_start (model->priv->client_view, &error);
+ if (error) {
+ g_debug ("%s: Failed to start client view: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+ }
}
static gboolean
addressbook_model_idle_cb (EAddressbookModel *model)
{
- model->priv->book_view_idle_id = 0;
-
- if (model->priv->book && model->priv->query) {
- ESource *source;
- const gchar *limit_str;
- gint limit = -1;
-
- source = e_book_get_source (model->priv->book);
-
- limit_str = e_source_get_property (source, "limit");
- if (limit_str && *limit_str)
- limit = atoi (limit_str);
-
+ model->priv->client_view_idle_id = 0;
+
+ if (model->priv->book_client && model->priv->query_str) {
remove_book_view (model);
if (model->priv->first_get_view) {
- gboolean do_initial_query;
-
model->priv->first_get_view = FALSE;
- do_initial_query = e_book_check_static_capability (
- model->priv->book, "do-initial-query");
-
- if (do_initial_query) {
- e_book_get_book_view_async (
- model->priv->book, model->priv->query,
- NULL, limit, book_view_loaded, model);
+ if (e_client_check_capability (E_CLIENT (model->priv->book_client), "do-initial-query")) {
+ e_book_client_get_view (
+ model->priv->book_client, model->priv->query_str,
+ NULL, client_view_ready_cb, model);
} else {
free_data (model);
@@ -415,9 +403,9 @@ addressbook_model_idle_cb (EAddressbookModel *model)
model, signals[STOP_STATE_CHANGED], 0);
}
} else
- e_book_get_book_view_async (
- model->priv->book, model->priv->query,
- NULL, limit, book_view_loaded, model);
+ e_book_client_get_view (
+ model->priv->book_client, model->priv->query_str,
+ NULL, client_view_ready_cb, model);
}
@@ -434,7 +422,7 @@ remove_status_cb (gpointer data)
g_return_val_if_fail (model != NULL, FALSE);
g_return_val_if_fail (E_IS_ADDRESSBOOK_MODEL (model), FALSE);
- g_signal_emit (model, signals[STATUS_MESSAGE], 0, NULL);
+ g_signal_emit (model, signals[STATUS_MESSAGE], 0, NULL, -1);
model->priv->remove_status_id = 0;
return FALSE;
@@ -447,8 +435,8 @@ addressbook_model_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BOOK:
- e_addressbook_model_set_book (
+ case PROP_CLIENT:
+ e_addressbook_model_set_client (
E_ADDRESSBOOK_MODEL (object),
g_value_get_object (value));
return;
@@ -477,9 +465,9 @@ addressbook_model_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BOOK:
+ case PROP_CLIENT:
g_value_set_object (
- value, e_addressbook_model_get_book (
+ value, e_addressbook_model_get_client (
E_ADDRESSBOOK_MODEL (object)));
return;
@@ -490,7 +478,7 @@ addressbook_model_get_property (GObject *object,
return;
case PROP_QUERY:
- g_value_take_string (
+ g_value_set_string (
value, e_addressbook_model_get_query (
E_ADDRESSBOOK_MODEL (object)));
return;
@@ -507,26 +495,26 @@ addressbook_model_dispose (GObject *object)
remove_book_view (model);
free_data (model);
- if (model->priv->book) {
+ if (model->priv->book_client) {
if (model->priv->writable_status_id)
g_signal_handler_disconnect (
- model->priv->book,
+ model->priv->book_client,
model->priv->writable_status_id);
model->priv->writable_status_id = 0;
if (model->priv->backend_died_id)
g_signal_handler_disconnect (
- model->priv->book,
+ model->priv->book_client,
model->priv->backend_died_id);
model->priv->backend_died_id = 0;
- g_object_unref (model->priv->book);
- model->priv->book = NULL;
+ g_object_unref (model->priv->book_client);
+ model->priv->book_client = NULL;
}
- if (model->priv->query) {
- e_book_query_unref (model->priv->query);
- model->priv->query = NULL;
+ if (model->priv->query_str) {
+ g_free (model->priv->query_str);
+ model->priv->query_str = NULL;
}
/* Chain up to parent's dispose() method. */
@@ -562,12 +550,12 @@ addressbook_model_class_init (EAddressbookModelClass *class)
g_object_class_install_property (
object_class,
- PROP_BOOK,
+ PROP_CLIENT,
g_param_spec_object (
- "book",
- "Book",
+ "client",
+ "EBookClient",
NULL,
- E_TYPE_BOOK,
+ E_TYPE_BOOK_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (
@@ -607,9 +595,9 @@ addressbook_model_class_init (EAddressbookModelClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EAddressbookModelClass, status_message),
NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ e_marshal_VOID__STRING_INT,
G_TYPE_NONE,
- 1, G_TYPE_POINTER);
+ 2, G_TYPE_STRING, G_TYPE_INT);
signals[SEARCH_STARTED] =
g_signal_new ("search_started",
@@ -626,8 +614,8 @@ addressbook_model_class_init (EAddressbookModelClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EAddressbookModelClass, search_result),
NULL, NULL,
- e_marshal_VOID__UINT_STRING,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, G_TYPE_ERROR);
signals[FOLDER_BAR_MESSAGE] =
g_signal_new ("folder_bar_message",
@@ -762,7 +750,7 @@ e_addressbook_model_stop (EAddressbookModel *model)
message = _("Search Interrupted");
g_signal_emit (model, signals[STOP_STATE_CHANGED], 0);
- g_signal_emit (model, signals[STATUS_MESSAGE], 0, message);
+ g_signal_emit (model, signals[STATUS_MESSAGE], 0, message, -1);
if (!model->priv->remove_status_id)
model->priv->remove_status_id =
@@ -828,64 +816,64 @@ e_addressbook_model_find (EAddressbookModel *model,
return -1;
}
-EBook *
-e_addressbook_model_get_book (EAddressbookModel *model)
+EBookClient *
+e_addressbook_model_get_client (EAddressbookModel *model)
{
g_return_val_if_fail (E_IS_ADDRESSBOOK_MODEL (model), NULL);
- return model->priv->book;
+ return model->priv->book_client;
}
void
-e_addressbook_model_set_book (EAddressbookModel *model,
- EBook *book)
+e_addressbook_model_set_client (EAddressbookModel *model,
+ EBookClient *book_client)
{
g_return_if_fail (E_IS_ADDRESSBOOK_MODEL (model));
- g_return_if_fail (E_IS_BOOK (book));
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
- if (model->priv->book != NULL) {
- if (model->priv->book == book)
+ if (model->priv->book_client != NULL) {
+ if (model->priv->book_client == book_client)
return;
if (model->priv->writable_status_id != 0)
g_signal_handler_disconnect (
- model->priv->book,
+ model->priv->book_client,
model->priv->writable_status_id);
model->priv->writable_status_id = 0;
if (model->priv->backend_died_id != 0)
g_signal_handler_disconnect (
- model->priv->book,
+ model->priv->book_client,
model->priv->backend_died_id);
model->priv->backend_died_id = 0;
- g_object_unref (model->priv->book);
+ g_object_unref (model->priv->book_client);
}
- model->priv->book = g_object_ref (book);
+ model->priv->book_client = g_object_ref (book_client);
model->priv->first_get_view = TRUE;
model->priv->writable_status_id = g_signal_connect (
- book, "writable-status",
- G_CALLBACK (writable_status), model);
+ book_client, "notify::readonly",
+ G_CALLBACK (readonly_cb), model);
model->priv->backend_died_id = g_signal_connect (
- book, "backend-died",
- G_CALLBACK (backend_died), model);
+ book_client, "backend-died",
+ G_CALLBACK (backend_died_cb), model);
if (!model->priv->editable_set) {
- model->priv->editable = e_book_is_writable (book);
+ model->priv->editable = !e_client_is_readonly (E_CLIENT (book_client));
g_signal_emit (
model, signals[WRITABLE_STATUS], 0,
model->priv->editable);
}
- if (model->priv->book_view_idle_id == 0)
- model->priv->book_view_idle_id = g_idle_add (
+ if (model->priv->client_view_idle_id == 0)
+ model->priv->client_view_idle_id = g_idle_add (
(GSourceFunc) addressbook_model_idle_cb,
g_object_ref (model));
- g_object_notify (G_OBJECT (model), "book");
+ g_object_notify (G_OBJECT (model), "client");
}
gboolean
@@ -913,10 +901,7 @@ e_addressbook_model_get_query (EAddressbookModel *model)
{
g_return_val_if_fail (E_IS_ADDRESSBOOK_MODEL (model), NULL);
- if (!model->priv->query)
- return NULL;
-
- return e_book_query_to_string (model->priv->query);
+ return model->priv->query_str;
}
void
@@ -932,31 +917,30 @@ e_addressbook_model_set_query (EAddressbookModel *model,
else
book_query = e_book_query_from_string (query);
+ /* also checks whether the query is a valid query string */
if (!book_query)
return;
- if (model->priv->query != NULL) {
- gchar *old_query, *new_query;
+ if (model->priv->query_str != NULL) {
+ gchar *new_query;
- old_query = e_book_query_to_string (model->priv->query);
new_query = e_book_query_to_string (book_query);
- if (old_query && new_query && g_str_equal (old_query, new_query)) {
- g_free (old_query);
+ if (new_query && g_str_equal (model->priv->query_str, new_query)) {
g_free (new_query);
e_book_query_unref (book_query);
return;
}
- g_free (old_query);
g_free (new_query);
- e_book_query_unref (model->priv->query);
}
- model->priv->query = book_query;
+ g_free (model->priv->query_str);
+ model->priv->query_str = e_book_query_to_string (book_query);
+ e_book_query_unref (book_query);
- if (model->priv->book_view_idle_id == 0)
- model->priv->book_view_idle_id = g_idle_add (
+ if (model->priv->client_view_idle_id == 0)
+ model->priv->client_view_idle_id = g_idle_add (
(GSourceFunc) addressbook_model_idle_cb,
g_object_ref (model));
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 44b22df4cd..13d23e92b0 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -21,9 +21,9 @@
#ifndef E_ADDRESSBOOK_MODEL_H
#define E_ADDRESSBOOK_MODEL_H
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-client-view.h>
#include <libebook/e-book-query.h>
-#include <libebook/e-book-view.h>
/* Standard GObject macros */
#define E_TYPE_ADDRESSBOOK_MODEL \
@@ -63,10 +63,10 @@ struct _EAddressbookModelClass {
gboolean writable);
void (*search_started) (EAddressbookModel *model);
void (*search_result) (EAddressbookModel *model,
- EBookViewStatus status,
- const gchar *error_msg);
+ const GError *error);
void (*status_message) (EAddressbookModel *model,
- const gchar *message);
+ const gchar *message,
+ gint percent);
void (*folder_bar_message) (EAddressbookModel *model,
const gchar *message);
void (*contact_added) (EAddressbookModel *model,
@@ -101,9 +101,9 @@ EContact * e_addressbook_model_contact_at (EAddressbookModel *model,
gint index);
gint e_addressbook_model_find (EAddressbookModel *model,
EContact *contact);
-EBook * e_addressbook_model_get_book (EAddressbookModel *model);
-void e_addressbook_model_set_book (EAddressbookModel *model,
- EBook *book);
+EBookClient * e_addressbook_model_get_client (EAddressbookModel *model);
+void e_addressbook_model_set_client (EAddressbookModel *model,
+ EBookClient *book_client);
gboolean e_addressbook_model_get_editable (EAddressbookModel *model);
void e_addressbook_model_set_editable (EAddressbookModel *model,
gboolean editable);
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index 0561b766b6..680a511d05 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -47,7 +47,7 @@ static EReflowModel *parent_class;
enum {
PROP_0,
- PROP_BOOK,
+ PROP_CLIENT,
PROP_QUERY,
PROP_EDITABLE,
PROP_MODEL
@@ -382,8 +382,7 @@ search_started (EAddressbookModel *model,
static void
search_result (EAddressbookModel *model,
- EBookViewStatus status,
- const gchar *error_msg,
+ const GError *error,
EAddressbookReflowAdapter *adapter)
{
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
@@ -403,9 +402,9 @@ addressbook_set_property (GObject *object,
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
switch (prop_id) {
- case PROP_BOOK:
+ case PROP_CLIENT:
g_object_set (priv->model,
- "book", g_value_get_object (value),
+ "client", g_value_get_object (value),
NULL);
break;
case PROP_QUERY:
@@ -434,9 +433,9 @@ addressbook_get_property (GObject *object,
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
switch (prop_id) {
- case PROP_BOOK: {
+ case PROP_CLIENT: {
g_object_get_property (G_OBJECT (priv->model),
- "book", value);
+ "client", value);
break;
}
case PROP_QUERY: {
@@ -469,11 +468,11 @@ e_addressbook_reflow_adapter_class_init (GObjectClass *object_class)
object_class->get_property = addressbook_get_property;
object_class->dispose = addressbook_dispose;
- g_object_class_install_property (object_class, PROP_BOOK,
- g_param_spec_object ("book",
- "Book",
+ g_object_class_install_property (object_class, PROP_CLIENT,
+ g_param_spec_object ("client",
+ "EBookClient",
NULL,
- E_TYPE_BOOK,
+ E_TYPE_BOOK_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_QUERY,
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index 76b0e98f74..954b1e19b9 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.c
+++ b/addressbook/gui/widgets/e-addressbook-selector.c
@@ -25,6 +25,7 @@
#include "e-addressbook-selector.h"
#include <e-util/e-selection.h>
+#include <libedataserverui/e-client-utils.h>
#include <eab-book-util.h>
#include <eab-contact-merging.h>
@@ -36,11 +37,11 @@ struct _EAddressbookSelectorPrivate {
};
struct _MergeContext {
- EBook *source_book;
- EBook *target_book;
+ EBookClient *source_client;
+ EBookClient *target_client;
EContact *current_contact;
- GList *remaining_contacts;
+ GSList *remaining_contacts;
guint pending_removals;
gboolean pending_adds;
@@ -62,7 +63,7 @@ static gpointer parent_class;
static void
merge_context_next (MergeContext *merge_context)
{
- GList *list;
+ GSList *list;
merge_context->current_contact = NULL;
if (!merge_context->remaining_contacts)
@@ -70,20 +71,20 @@ merge_context_next (MergeContext *merge_context)
list = merge_context->remaining_contacts;
merge_context->current_contact = list->data;
- list = g_list_delete_link (list, list);
+ list = g_slist_delete_link (list, list);
merge_context->remaining_contacts = list;
}
static MergeContext *
-merge_context_new (EBook *source_book,
- EBook *target_book,
- GList *contact_list)
+merge_context_new (EBookClient *source_client,
+ EBookClient *target_client,
+ GSList *contact_list)
{
MergeContext *merge_context;
merge_context = g_slice_new0 (MergeContext);
- merge_context->source_book = source_book;
- merge_context->target_book = target_book;
+ merge_context->source_client = source_client;
+ merge_context->target_client = target_client;
merge_context->remaining_contacts = contact_list;
merge_context_next (merge_context);
@@ -93,20 +94,28 @@ merge_context_new (EBook *source_book,
static void
merge_context_free (MergeContext *merge_context)
{
- if (merge_context->source_book != NULL)
- g_object_unref (merge_context->source_book);
+ if (merge_context->source_client != NULL)
+ g_object_unref (merge_context->source_client);
- if (merge_context->target_book != NULL)
- g_object_unref (merge_context->target_book);
+ if (merge_context->target_client != NULL)
+ g_object_unref (merge_context->target_client);
g_slice_free (MergeContext, merge_context);
}
static void
-addressbook_selector_removed_cb (EBook *book,
- const GError *error,
- MergeContext *merge_context)
+addressbook_selector_removed_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ MergeContext *merge_context = user_data;
+ GError *error = NULL;
+
+ e_book_client_remove_contact_finish (book_client, result, &error);
+ if (error) {
+ g_debug ("%s: Failed to remove contact: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
merge_context->pending_removals--;
if (merge_context->pending_adds)
@@ -119,18 +128,19 @@ addressbook_selector_removed_cb (EBook *book,
}
static void
-addressbook_selector_merge_next_cb (EBook *book,
+addressbook_selector_merge_next_cb (EBookClient *book_client,
const GError *error,
const gchar *id,
- MergeContext *merge_context)
+ gpointer closure)
{
+ MergeContext *merge_context = closure;
+
if (merge_context->remove_from_source && !error) {
/* Remove previous contact from source. */
- e_book_remove_contact_async (
- merge_context->source_book,
- merge_context->current_contact,
- (EBookAsyncCallback) addressbook_selector_removed_cb,
- merge_context);
+ e_book_client_remove_contact (
+ merge_context->source_client,
+ merge_context->current_contact, NULL,
+ addressbook_selector_removed_cb, merge_context);
merge_context->pending_removals++;
}
@@ -139,10 +149,9 @@ addressbook_selector_merge_next_cb (EBook *book,
if (merge_context->remaining_contacts != NULL) {
merge_context_next (merge_context);
eab_merging_book_add_contact (
- merge_context->target_book,
+ merge_context->target_client,
merge_context->current_contact,
- (EBookIdAsyncCallback) addressbook_selector_merge_next_cb,
- merge_context);
+ addressbook_selector_merge_next_cb, merge_context);
} else if (merge_context->pending_removals == 0) {
merge_context_free (merge_context);
@@ -242,6 +251,39 @@ addressbook_selector_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object);
}
+static void
+target_client_open_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ ESource *source = E_SOURCE (source_object);
+ MergeContext *merge_context = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (merge_context != NULL);
+
+ if (!e_client_utils_open_new_finish (source, result, &client, &error))
+ client = NULL;
+
+ if (error) {
+ g_debug ("%s: Failed to open targer client: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ merge_context->target_client = client ? E_BOOK_CLIENT (client) : NULL;
+
+ if (!merge_context->target_client) {
+ g_slist_foreach (merge_context->remaining_contacts, (GFunc) g_object_unref, NULL);
+ g_slist_free (merge_context->remaining_contacts);
+
+ merge_context_free (merge_context);
+ return;
+ }
+
+ eab_merging_book_add_contact (
+ merge_context->target_client, merge_context->current_contact,
+ addressbook_selector_merge_next_cb, merge_context);
+}
+
static gboolean
addressbook_selector_data_dropped (ESourceSelector *selector,
GtkSelectionData *selection_data,
@@ -252,9 +294,8 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
EAddressbookSelectorPrivate *priv;
MergeContext *merge_context;
EAddressbookModel *model;
- EBook *source_book;
- EBook *target_book;
- GList *list;
+ EBookClient *source_client = NULL;
+ GSList *list;
const gchar *string;
gboolean remove_from_source;
@@ -264,30 +305,26 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
string = (const gchar *) gtk_selection_data_get_data (selection_data);
remove_from_source = (action == GDK_ACTION_MOVE);
- target_book = e_book_new (destination, NULL);
- if (target_book == NULL)
- return FALSE;
-
- e_book_open (target_book, FALSE, NULL);
-
/* XXX Function assumes both out arguments are provided. All we
- * care about is the contact list; source_book will be NULL. */
- eab_book_and_contact_list_from_string (string, &source_book, &list);
+ * care about is the contact list; source_client will be NULL. */
+ eab_book_and_contact_list_from_string (string, &source_client, &list);
+ if (source_client)
+ g_object_unref (source_client);
+
if (list == NULL)
return FALSE;
model = e_addressbook_view_get_model (priv->current_view);
- source_book = e_addressbook_model_get_book (model);
- g_return_val_if_fail (E_IS_BOOK (source_book), FALSE);
+ source_client = e_addressbook_model_get_client (model);
+ g_return_val_if_fail (E_IS_BOOK_CLIENT (source_client), FALSE);
- merge_context = merge_context_new (source_book, target_book, list);
+ merge_context = merge_context_new (g_object_ref (source_client), NULL, list);
merge_context->remove_from_source = remove_from_source;
merge_context->pending_adds = TRUE;
- eab_merging_book_add_contact (
- target_book, merge_context->current_contact,
- (EBookIdAsyncCallback) addressbook_selector_merge_next_cb,
- merge_context);
+ e_client_utils_open_new (destination, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ target_client_open_ready_cb, merge_context);
return TRUE;
}
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c
index e246118d3a..e47b5bb186 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c
@@ -25,6 +25,9 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+
+#include <libebook/e-book-client.h>
+
#include "e-addressbook-model.h"
#include "e-addressbook-table-adapter.h"
#include "eab-contact-merging.h"
@@ -145,7 +148,7 @@ addressbook_value_at (ETableModel *etc, gint col, gint row)
/* This function sets the value at a particular point in our ETableModel. */
static void
-contact_modified_cb (EBook* book,
+contact_modified_cb (EBookClient *book_client,
const GError *error,
gpointer user_data)
{
@@ -182,8 +185,8 @@ addressbook_set_value_at (ETableModel *etc, gint col, gint row, gconstpointer va
}
e_contact_set (contact, col, (gpointer) val);
- eab_merging_book_commit_contact (
- e_addressbook_model_get_book (priv->model),
+ eab_merging_book_modify_contact (
+ e_addressbook_model_get_client (priv->model),
contact, contact_modified_cb, etc);
g_object_unref (contact);
@@ -227,7 +230,7 @@ addressbook_append_row (ETableModel *etm, ETableModel *source, gint row)
EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER (etm);
EAddressbookTableAdapterPrivate *priv = adapter->priv;
EContact *contact;
- EBook *book;
+ EBookClient *book_client;
gint col;
contact = e_contact_new ();
@@ -237,8 +240,8 @@ addressbook_append_row (ETableModel *etm, ETableModel *source, gint row)
e_contact_set (contact, col, (gpointer) val);
}
- book = e_addressbook_model_get_book (priv->model);
- eab_merging_book_add_contact (book, contact, NULL, NULL);
+ book_client = e_addressbook_model_get_client (priv->model);
+ eab_merging_book_add_contact (book_client, contact, NULL, NULL);
g_object_unref (contact);
}
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.h b/addressbook/gui/widgets/e-addressbook-table-adapter.h
index 71999bd4d1..17cf4cfadb 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.h
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.h
@@ -22,8 +22,6 @@
#define _EAB_TABLE_ADAPTER_H_
#include <table/e-table-model.h>
-#include <libebook/e-book.h>
-#include <libebook/e-book-view.h>
#define E_TYPE_AB_TABLE_ADAPTER (eab_table_adapter_get_type ())
#define EAB_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_AB_TABLE_ADAPTER, EAddressbookTableAdapter))
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 321a9fd949..00f106ea40 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -64,10 +64,9 @@
#define d(x)
static void status_message (EAddressbookView *view,
- const gchar *status);
+ const gchar *status, gint percent);
static void search_result (EAddressbookView *view,
- EBookViewStatus status,
- const gchar *error_msg);
+ const GError *error);
static void folder_bar_message (EAddressbookView *view,
const gchar *status);
static void stop_state_changed (GObject *object,
@@ -240,8 +239,8 @@ table_drag_data_get (ETable *table,
{
EAddressbookView *view = user_data;
EAddressbookModel *model;
- EBook *book;
- GList *contact_list;
+ EBookClient *book_client;
+ GSList *contact_list;
GdkAtom target;
gchar *value;
@@ -249,7 +248,7 @@ table_drag_data_get (ETable *table,
return;
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book_client = e_addressbook_model_get_client (model);
contact_list = e_addressbook_view_get_selected (view);
target = gtk_selection_data_get_target (selection_data);
@@ -267,7 +266,7 @@ table_drag_data_get (ETable *table,
case DND_TARGET_TYPE_SOURCE_VCARD:
value = eab_book_and_contact_list_to_string (
- book, contact_list);
+ book_client, contact_list);
gtk_selection_data_set (
selection_data, target, 8,
@@ -277,8 +276,7 @@ table_drag_data_get (ETable *table,
break;
}
- g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (contact_list);
+ e_client_util_free_object_slist (contact_list);
}
static void
@@ -668,7 +666,7 @@ addressbook_view_copy_clipboard (ESelectable *selectable)
{
EAddressbookView *view;
GtkClipboard *clipboard;
- GList *contact_list;
+ GSList *contact_list;
gchar *string;
view = E_ADDRESSBOOK_VIEW (selectable);
@@ -680,18 +678,17 @@ addressbook_view_copy_clipboard (ESelectable *selectable)
e_clipboard_set_directory (clipboard, string, -1);
g_free (string);
- g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (contact_list);
+ e_client_util_free_object_slist (contact_list);
}
static void
addressbook_view_paste_clipboard (ESelectable *selectable)
{
- EBook *book;
+ EBookClient *book_client;
EAddressbookView *view;
EAddressbookModel *model;
GtkClipboard *clipboard;
- GList *contact_list, *iter;
+ GSList *contact_list, *iter;
gchar *string;
view = E_ADDRESSBOOK_VIEW (selectable);
@@ -701,7 +698,7 @@ addressbook_view_paste_clipboard (ESelectable *selectable)
return;
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book_client = e_addressbook_model_get_client (model);
string = e_clipboard_wait_for_directory (clipboard);
contact_list = eab_contact_list_from_string (string);
@@ -710,11 +707,10 @@ addressbook_view_paste_clipboard (ESelectable *selectable)
for (iter = contact_list; iter != NULL; iter = iter->next) {
EContact *contact = iter->data;
- eab_merging_book_add_contact (book, contact, NULL, NULL);
+ eab_merging_book_add_contact (book_client, contact, NULL, NULL);
}
- g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (contact_list);
+ e_client_util_free_object_slist (contact_list);
}
static void
@@ -979,14 +975,14 @@ e_addressbook_view_get_view_object (EAddressbookView *view)
static void
add_to_list (gint model_row, gpointer closure)
{
- GList **list = closure;
- *list = g_list_prepend (*list, GINT_TO_POINTER (model_row));
+ GSList **list = closure;
+ *list = g_slist_prepend (*list, GINT_TO_POINTER (model_row));
}
-GList *
+GSList *
e_addressbook_view_get_selected (EAddressbookView *view)
{
- GList *list, *iter;
+ GSList *list, *iter;
ESelectionModel *selection;
g_return_val_if_fail (E_IS_ADDRESSBOOK_VIEW (view), NULL);
@@ -998,9 +994,7 @@ e_addressbook_view_get_selected (EAddressbookView *view)
for (iter = list; iter != NULL; iter = iter->next)
iter->data = e_addressbook_model_get_contact (
view->priv->model, GPOINTER_TO_INT (iter->data));
- list = g_list_reverse (list);
-
- return list;
+ return g_slist_reverse (list);
}
ESelectionModel *
@@ -1064,8 +1058,7 @@ e_addressbook_view_get_paste_target_list (EAddressbookView *view)
}
static void
-status_message (EAddressbookView *view,
- const gchar *status)
+status_message (EAddressbookView *view, const gchar *status, gint percent)
{
EActivity *activity;
EShellView *shell_view;
@@ -1086,16 +1079,19 @@ status_message (EAddressbookView *view,
activity = e_activity_new ();
view->priv->activity = activity;
e_activity_set_text (activity, status);
+ if (percent >= 0)
+ e_activity_set_percent (activity, percent);
e_shell_backend_add_activity (shell_backend, activity);
-
- } else
+ } else {
e_activity_set_text (activity, status);
+ if (percent >= 0)
+ e_activity_set_percent (activity, percent);
+ }
}
static void
search_result (EAddressbookView *view,
- EBookViewStatus status,
- const gchar *error_msg)
+ const GError *error)
{
EShellView *shell_view;
EAlertSink *alert_sink;
@@ -1103,7 +1099,7 @@ search_result (EAddressbookView *view,
shell_view = e_addressbook_view_get_shell_view (view);
alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view));
- eab_search_result_dialog (alert_sink, status, error_msg);
+ eab_search_result_dialog (alert_sink, error);
}
static void
@@ -1143,17 +1139,17 @@ backend_died (EAddressbookView *view)
EShellView *shell_view;
EAlertSink *alert_sink;
EAddressbookModel *model;
- EBook *book;
+ EBookClient *book_client;
shell_view = e_addressbook_view_get_shell_view (view);
alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view));
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book_client = e_addressbook_model_get_client (model);
e_alert_submit (alert_sink,
"addressbook:backend-died",
- e_book_get_uri (book), NULL);
+ e_client_get_uri (E_CLIENT (book_client)), NULL);
}
static void
@@ -1215,31 +1211,29 @@ e_addressbook_view_print (EAddressbookView *view,
/* Print the selected contacts. */
if (GAL_IS_VIEW_MINICARD (gal_view) && selection_only) {
- GList *contact_list;
+ GSList *contact_list;
contact_list = e_addressbook_view_get_selected (view);
e_contact_print (NULL, NULL, contact_list, action);
- g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (contact_list);
+ e_client_util_free_object_slist (contact_list);
/* Print the latest query results. */
} else if (GAL_IS_VIEW_MINICARD (gal_view)) {
EAddressbookModel *model;
- EBook *book;
+ EBookClient *book_client;
EBookQuery *query;
- gchar *query_string;
+ const gchar *query_string;
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book_client = e_addressbook_model_get_client (model);
query_string = e_addressbook_model_get_query (model);
if (query_string != NULL)
query = e_book_query_from_string (query_string);
else
query = NULL;
- g_free (query_string);
- e_contact_print (book, query, NULL, action);
+ e_contact_print (book_client, query, NULL, action);
if (query != NULL)
e_book_query_unref (query);
@@ -1259,26 +1253,51 @@ e_addressbook_view_print (EAddressbookView *view,
}
}
+static void
+report_and_free_error_if_any (GError *error)
+{
+ if (!error)
+ return;
+
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) {
+ g_error_free (error);
+ return;
+ }
+
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_PERMISSION_DENIED)) {
+ e_alert_run_dialog_for_args (e_shell_get_active_window (NULL),
+ "addressbook:contact-delete-error-perm",
+ NULL);
+ } else {
+ eab_error_dialog (NULL, _("Failed to delete contact"), error);
+ }
+
+ g_error_free (error);
+}
+
/* callback function to handle removal of contacts for
* which a user doesnt have write permission
*/
static void
-delete_contacts_cb (EBook *book, const GError *error, gpointer closure)
+remove_contacts_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- switch (error ? error->code : E_BOOK_ERROR_OK) {
- case E_BOOK_ERROR_OK :
- case E_BOOK_ERROR_CANCELLED :
- break;
- case E_BOOK_ERROR_PERMISSION_DENIED :
- e_alert_run_dialog_for_args (e_shell_get_active_window (NULL),
- "addressbook:contact-delete-error-perm",
- NULL);
- break;
- default :
- /* Unknown error */
- eab_error_dialog (NULL, _("Failed to delete contact"), error);
- break;
- }
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ GError *error = NULL;
+
+ e_book_client_remove_contacts_finish (book_client, result, &error);
+
+ report_and_free_error_if_any (error);
+}
+
+static void
+remove_contact_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ GError *error = NULL;
+
+ e_book_client_remove_contact_finish (book_client, result, &error);
+
+ report_and_free_error_if_any (error);
}
static gboolean
@@ -1340,12 +1359,12 @@ addressbook_view_confirm_delete (GtkWindow *parent,
void
e_addressbook_view_delete_selection (EAddressbookView *view, gboolean is_delete)
{
- GList *list, *l;
+ GSList *list, *l;
gboolean plural = FALSE, is_list = FALSE;
EContact *contact;
ETable *etable = NULL;
EAddressbookModel *model;
- EBook *book;
+ EBookClient *book_client;
ESelectionModel *selection_model = NULL;
GalViewInstance *view_instance;
GalView *gal_view;
@@ -1354,7 +1373,7 @@ e_addressbook_view_delete_selection (EAddressbookView *view, gboolean is_delete)
gint row = 0, select;
model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
+ book_client = e_addressbook_model_get_client (model);
view_instance = e_addressbook_view_get_view_instance (view);
gal_view = gal_view_instance_get_current_view (view_instance);
@@ -1362,7 +1381,7 @@ e_addressbook_view_delete_selection (EAddressbookView *view, gboolean is_delete)
list = e_addressbook_view_get_selected (view);
contact = list->data;
- if (g_list_next (list))
+ if (g_slist_next (list))
plural = TRUE;
else
name = e_contact_get (contact, E_CONTACT_FILE_AS);
@@ -1387,38 +1406,29 @@ e_addressbook_view_delete_selection (EAddressbookView *view, gboolean is_delete)
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
plural, is_list, name)) {
g_free (name);
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ e_client_util_free_object_slist (list);
return;
}
- if (e_book_check_static_capability (book, "bulk-remove")) {
- GList *ids = NULL;
+ if (e_client_check_capability (E_CLIENT (book_client), "bulk-remove")) {
+ GSList *ids = NULL;
- for (l=list;l;l=g_list_next (l)) {
+ for (l = list; l; l = g_slist_next (l)) {
contact = l->data;
- ids = g_list_prepend (
- ids, (gchar *) e_contact_get_const (
- contact, E_CONTACT_UID));
+ ids = g_slist_prepend (ids, (gpointer) e_contact_get_const (contact, E_CONTACT_UID));
}
/* Remove the cards all at once. */
- e_book_remove_contacts_async (book,
- ids,
- delete_contacts_cb,
- NULL);
+ e_book_client_remove_contacts (book_client, ids, NULL, remove_contacts_cb, NULL);
- g_list_free (ids);
- }
- else {
- for (l=list;l;l=g_list_next (l)) {
+ g_slist_free (ids);
+ } else {
+ for (l = list; l; l = g_slist_next (l)) {
contact = l->data;
+
/* Remove the card. */
- e_book_remove_contact_async (book,
- contact,
- delete_contacts_cb,
- NULL);
+ e_book_client_remove_contact (book_client, contact, NULL, remove_contact_cb, NULL);
}
}
@@ -1449,21 +1459,20 @@ e_addressbook_view_delete_selection (EAddressbookView *view, gboolean is_delete)
row = e_table_view_to_model_row (E_TABLE (etable), select);
e_table_set_cursor_row (E_TABLE (etable), row);
}
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ e_client_util_free_object_slist (list);
}
void
e_addressbook_view_view (EAddressbookView *view)
{
- GList *list, *iter;
+ GSList *list, *iter;
gint response;
guint length;
g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
list = e_addressbook_view_get_selected (view);
- length = g_list_length (list);
+ length = g_slist_length (list);
response = GTK_RESPONSE_YES;
if (length > 5) {
@@ -1495,8 +1504,7 @@ e_addressbook_view_view (EAddressbookView *view)
addressbook_view_emit_open_contact (
view, iter->data, FALSE);
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ e_client_util_free_object_slist (list);
}
void
@@ -1515,42 +1523,78 @@ e_addressbook_view_stop (EAddressbookView *view)
e_addressbook_model_stop (view->priv->model);
}
+struct TransferContactsData
+{
+ gboolean delete_from_source;
+ EAddressbookView *view;
+};
+
static void
-view_transfer_contacts (EAddressbookView *view,
- gboolean delete_from_source,
- gboolean all)
+all_contacts_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
- GList *contacts = NULL;
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ struct TransferContactsData *tcd = user_data;
EShellView *shell_view;
EAlertSink *alert_sink;
+ GSList *contacts = NULL;
+ GError *error = NULL;
- book = e_addressbook_model_get_book (view->priv->model);
- shell_view = e_addressbook_view_get_shell_view (view);
+ g_return_if_fail (book_client != NULL);
+ g_return_if_fail (tcd != NULL);
+
+ if (!e_book_client_get_contacts_finish (book_client, result, &contacts, &error))
+ contacts = NULL;
+
+ shell_view = e_addressbook_view_get_shell_view (tcd->view);
alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view));
+ if (error) {
+ e_alert_submit (
+ alert_sink, "addressbook:search-error",
+ error->message, NULL);
+ g_error_free (error);
+ } else if (contacts) {
+ eab_transfer_contacts (book_client, contacts, tcd->delete_from_source, alert_sink);
+ }
+
+ g_object_unref (tcd->view);
+ g_free (tcd);
+}
+
+static void
+view_transfer_contacts (EAddressbookView *view,
+ gboolean delete_from_source,
+ gboolean all)
+{
+ EBookClient *book_client;
+
+ book_client = e_addressbook_model_get_client (view->priv->model);
+
if (all) {
EBookQuery *query;
- GError *error = NULL;
+ gchar *query_str;
+ struct TransferContactsData *tcd;
query = e_book_query_any_field_contains ("");
- e_book_get_contacts (book, query, &contacts, &error);
+ query_str = e_book_query_to_string (query);
e_book_query_unref (query);
- if (error) {
- e_alert_submit (
- alert_sink, "addressbook:search-error",
- error->message, NULL);
- g_error_free (error);
- return;
- }
+ tcd = g_new0 (struct TransferContactsData, 1);
+ tcd->delete_from_source = delete_from_source;
+ tcd->view = g_object_ref (view);
+
+ e_book_client_get_contacts (book_client, query_str, NULL, all_contacts_ready_cb, tcd);
} else {
- contacts = e_addressbook_view_get_selected (view);
- }
+ GSList *contacts = NULL;
+ EShellView *shell_view;
+ EAlertSink *alert_sink;
- eab_transfer_contacts (book, contacts, delete_from_source, alert_sink);
+ shell_view = e_addressbook_view_get_shell_view (view);
+ alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view));
+ contacts = e_addressbook_view_get_selected (view);
- g_object_unref (book);
+ eab_transfer_contacts (book_client, contacts, delete_from_source, alert_sink);
+ }
}
void
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index 4b85293cd5..1ccfba99b3 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -23,7 +23,7 @@
#ifndef E_ADDRESSBOOK_VIEW_H
#define E_ADDRESSBOOK_VIEW_H
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
#include <menus/gal-view-instance.h>
@@ -73,8 +73,6 @@ struct _EAddressbookViewClass {
gboolean is_new_contact);
void (*popup_event) (EAddressbookView *view,
GdkEvent *event);
- void (*status_message) (EAddressbookView *view,
- const gchar *message);
void (*command_state_change) (EAddressbookView *view);
void (*selection_change) (EAddressbookView *view);
};
@@ -89,7 +87,7 @@ GalViewInstance *
(EAddressbookView *view);
GObject * e_addressbook_view_get_view_object
(EAddressbookView *view);
-GList * e_addressbook_view_get_selected (EAddressbookView *view);
+GSList * e_addressbook_view_get_selected (EAddressbookView *view);
ESelectionModel *
e_addressbook_view_get_selection_model
(EAddressbookView *view);
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index 4421b1a739..65fa12d9f1 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -63,7 +63,7 @@ static gpointer parent_class;
/* The arguments we take */
enum {
PROP_0,
- PROP_BOOK,
+ PROP_CLIENT,
PROP_QUERY,
PROP_EDITABLE,
PROP_COLUMN_WIDTH
@@ -132,11 +132,11 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *class)
class->column_width_changed = NULL;
class->right_click = NULL;
- g_object_class_install_property (object_class, PROP_BOOK,
- g_param_spec_object ("book",
- "Book",
+ g_object_class_install_property (object_class, PROP_CLIENT,
+ g_param_spec_object ("client",
+ "EBookClient",
NULL,
- E_TYPE_BOOK,
+ E_TYPE_BOOK_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_QUERY,
@@ -211,7 +211,7 @@ e_minicard_view_widget_init (EMinicardViewWidget *view)
{
view->emv = NULL;
- view->book = NULL;
+ view->book_client = NULL;
view->query = NULL;
view->editable = FALSE;
view->column_width = 225;
@@ -240,18 +240,18 @@ e_minicard_view_widget_set_property (GObject *object,
emvw = E_MINICARD_VIEW_WIDGET (object);
switch (prop_id) {
- case PROP_BOOK:
- if (emvw->book)
- g_object_unref (emvw->book);
+ case PROP_CLIENT:
+ if (emvw->book_client)
+ g_object_unref (emvw->book_client);
if (g_value_get_object (value)) {
- emvw->book = E_BOOK (g_value_get_object (value));
- if (emvw->book)
- g_object_ref (emvw->book);
+ emvw->book_client = E_BOOK_CLIENT (g_value_get_object (value));
+ if (emvw->book_client)
+ g_object_ref (emvw->book_client);
} else
- emvw->book = NULL;
+ emvw->book_client = NULL;
if (emvw->emv)
g_object_set (emvw->emv,
- "book", emvw->book,
+ "client", emvw->book_client,
NULL);
break;
case PROP_QUERY:
@@ -293,8 +293,8 @@ e_minicard_view_widget_get_property (GObject *object,
emvw = E_MINICARD_VIEW_WIDGET (object);
switch (prop_id) {
- case PROP_BOOK:
- g_value_set_object (value, emvw->book);
+ case PROP_CLIENT:
+ g_value_set_object (value, emvw->book_client);
break;
case PROP_QUERY:
g_value_set_string (value, emvw->query);
@@ -316,9 +316,9 @@ e_minicard_view_widget_dispose (GObject *object)
{
EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET (object);
- if (view->book) {
- g_object_unref (view->book);
- view->book = NULL;
+ if (view->book_client) {
+ g_object_unref (view->book_client);
+ view->book_client = NULL;
}
if (view->query) {
g_free (view->query);
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h
index ab5bda2881..aea68bd5db 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.h
+++ b/addressbook/gui/widgets/e-minicard-view-widget.h
@@ -24,7 +24,7 @@
#define __E_MINICARD_VIEW_WIDGET_H__
#include <misc/e-canvas.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include "e-minicard-view.h"
G_BEGIN_DECLS
@@ -47,7 +47,7 @@ struct _EMinicardViewWidget
EAddressbookReflowAdapter *adapter;
- EBook *book;
+ EBookClient *book_client;
gchar *query;
guint editable : 1;
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index a00b03816c..91a4a12991 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -24,6 +24,8 @@
#include <config.h>
#endif
+#include <libebook/e-book-client.h>
+
#include "e-minicard-view.h"
#include "eab-gui-util.h"
@@ -52,7 +54,7 @@ static EReflowClass *parent_class = NULL;
enum {
PROP_0,
PROP_ADAPTER,
- PROP_BOOK,
+ PROP_CLIENT,
PROP_QUERY,
PROP_EDITABLE
};
@@ -105,15 +107,17 @@ e_minicard_view_drag_data_get (GtkWidget *widget,
break;
}
case DND_TARGET_TYPE_SOURCE_VCARD_LIST: {
- EBook *book;
+ EBookClient *book_client = NULL;
gchar *value;
- g_object_get (view->adapter, "book", &book, NULL);
- value = eab_book_and_contact_list_to_string (book, view->drag_list);
+ g_object_get (view->adapter, "book_client", &book_client, NULL);
+ value = eab_book_and_contact_list_to_string (book_client, view->drag_list);
gtk_selection_data_set (
selection_data, target, 8,
(guchar *) value, strlen (value));
+
+ g_object_unref (book_client);
g_free (value);
break;
}
@@ -123,8 +127,7 @@ e_minicard_view_drag_data_get (GtkWidget *widget,
static void
clear_drag_data (EMinicardView *view)
{
- g_list_foreach (view->drag_list, (GFunc) g_object_unref, NULL);
- g_list_free (view->drag_list);
+ e_client_util_free_object_slist (view->drag_list);
view->drag_list = NULL;
}
@@ -141,7 +144,7 @@ e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter,
view->drag_list = e_minicard_view_get_card_list (view);
- g_print ("dragging %d card(s)\n", g_list_length (view->drag_list));
+ g_print ("dragging %d card(s)\n", g_slist_length (view->drag_list));
target_list = gtk_target_list_new (drag_types, G_N_ELEMENTS (drag_types));
@@ -163,21 +166,26 @@ set_empty_message (EMinicardView *view)
{
gchar *empty_message;
gboolean editable = FALSE, perform_initial_query = FALSE, searching = FALSE;
- EBook *book;
if (view->adapter) {
EAddressbookModel *model = NULL;
+ EBookClient *book_client = NULL;
g_object_get (view->adapter,
"editable", &editable,
"model", &model,
- "book", &book,
+ "client", &book_client,
NULL);
- if (book && !e_book_check_static_capability (book, "do-initial-query"))
+ if (book_client && !e_client_check_capability (E_CLIENT (book_client), "do-initial-query"))
perform_initial_query = TRUE;
searching = model && e_addressbook_model_can_stop (model);
+
+ if (book_client)
+ g_object_unref (book_client);
+ if (model)
+ g_object_unref (model);
}
if (searching) {
@@ -277,9 +285,9 @@ e_minicard_view_set_property (GObject *object,
}
break;
- case PROP_BOOK:
+ case PROP_CLIENT:
g_object_set (view->adapter,
- "book", g_value_get_object (value),
+ "client", g_value_get_object (value),
NULL);
set_empty_message (view);
break;
@@ -314,9 +322,9 @@ e_minicard_view_get_property (GObject *object,
case PROP_ADAPTER:
g_value_set_object (value, view->adapter);
break;
- case PROP_BOOK:
+ case PROP_CLIENT:
g_object_get_property (G_OBJECT (view->adapter),
- "book", value);
+ "client", value);
break;
case PROP_QUERY:
g_object_get_property (G_OBJECT (view->adapter),
@@ -455,33 +463,6 @@ e_minicard_view_selection_event (EReflow *reflow,
return return_val;
}
-typedef struct {
- EMinicardView *view;
- EBookAsyncCallback cb;
- gpointer closure;
-} ViewCbClosure;
-
-static void
-do_remove (gint i, gpointer user_data)
-{
- EBook *book;
- EContact *contact;
- ViewCbClosure *viewcbclosure = user_data;
- EMinicardView *view = viewcbclosure->view;
- EBookAsyncCallback cb = viewcbclosure->cb;
- gpointer closure = viewcbclosure->closure;
-
- g_object_get (view->adapter,
- "book", &book,
- NULL);
-
- contact = e_addressbook_reflow_adapter_get_contact (view->adapter, i);
-
- e_book_remove_contact_async (book, contact, cb, closure);
-
- g_object_unref (contact);
-}
-
#if 0
static gint
compare_to_utf_str (EMinicard *card, const gchar *utf_str)
@@ -532,11 +513,11 @@ e_minicard_view_class_init (EMinicardViewClass *klass)
E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_BOOK,
- g_param_spec_object ("book",
- "Book",
+ g_object_class_install_property (object_class, PROP_CLIENT,
+ g_param_spec_object ("client",
+ "EBookClient",
NULL,
- E_TYPE_BOOK,
+ E_TYPE_BOOK_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_QUERY,
@@ -625,21 +606,6 @@ e_minicard_view_get_type (void)
}
void
-e_minicard_view_remove_selection (EMinicardView *view,
- EBookAsyncCallback cb,
- gpointer closure)
-{
- ViewCbClosure viewcbclosure;
- viewcbclosure.view = view;
- viewcbclosure.cb = cb;
- viewcbclosure.closure = closure;
-
- e_selection_model_foreach (E_REFLOW (view)->selection,
- do_remove,
- &viewcbclosure);
-}
-
-void
e_minicard_view_jump_to_letter (EMinicardView *view,
gunichar letter)
{
@@ -654,7 +620,7 @@ e_minicard_view_jump_to_letter (EMinicardView *view,
}
typedef struct {
- GList *list;
+ GSList *list;
EAddressbookReflowAdapter *adapter;
} ModelAndList;
@@ -662,12 +628,12 @@ static void
add_to_list (gint index, gpointer closure)
{
ModelAndList *mal = closure;
- mal->list = g_list_prepend (
+ mal->list = g_slist_prepend (
mal->list, e_addressbook_reflow_adapter_get_contact (
mal->adapter, index));
}
-GList *
+GSList *
e_minicard_view_get_card_list (EMinicardView *view)
{
ModelAndList mal;
@@ -677,8 +643,7 @@ e_minicard_view_get_card_list (EMinicardView *view)
e_selection_model_foreach (E_REFLOW (view)->selection, add_to_list, &mal);
- mal.list = g_list_reverse (mal.list);
- return mal.list;
+ return g_slist_reverse (mal.list);
}
void
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index 8b37ba6df5..1024a85088 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -28,7 +28,6 @@
#include <text/e-reflow.h>
#include <misc/e-selection-model-simple.h>
-#include <libebook/e-book.h>
#include "e-addressbook-reflow-adapter.h"
G_BEGIN_DECLS
@@ -69,7 +68,7 @@ struct _EMinicardView
/* item specific fields */
- GList *drag_list;
+ GSList *drag_list;
guint canvas_drag_data_get_id;
guint writable_status_id;
@@ -84,12 +83,9 @@ struct _EMinicardViewClass
};
GType e_minicard_view_get_type (void);
-void e_minicard_view_remove_selection (EMinicardView *view,
- EBookAsyncCallback cb,
- gpointer closure);
void e_minicard_view_jump_to_letter (EMinicardView *view,
gunichar letter);
-GList *e_minicard_view_get_card_list (EMinicardView *view);
+GSList *e_minicard_view_get_card_list (EMinicardView *view);
void e_minicard_view_create_contact (EMinicardView *view);
void e_minicard_view_create_contact_list (EMinicardView *view);
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 98cf1c2f98..352604984c 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -32,7 +32,6 @@
#include <e-util/e-util.h>
#include <misc/e-canvas-utils.h>
#include <misc/e-canvas.h>
-#include <libebook/e-book.h>
#include "eab-gui-util.h"
#include "e-minicard.h"
#include "e-minicard-label.h"
diff --git a/addressbook/gui/widgets/ea-minicard-view.c b/addressbook/gui/widgets/ea-minicard-view.c
index 6850813ca7..a61c6074a0 100644
--- a/addressbook/gui/widgets/ea-minicard-view.c
+++ b/addressbook/gui/widgets/ea-minicard-view.c
@@ -148,7 +148,7 @@ ea_minicard_view_get_name (AtkObject *accessible)
EReflow *reflow;
gchar *string;
EMinicardView *card_view;
- EBook *book = NULL;
+ EBookClient *book_client = NULL;
const gchar *source_name;
g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), NULL);
@@ -161,9 +161,9 @@ ea_minicard_view_get_name (AtkObject *accessible)
/* Get the current name of minicard view*/
card_view = E_MINICARD_VIEW (reflow);
- g_object_get (card_view->adapter, "book", &book, NULL);
- g_return_val_if_fail (E_IS_BOOK (book), NULL);
- source_name = e_source_peek_name (e_book_get_source (book));
+ g_object_get (card_view->adapter, "client", &book_client, NULL);
+ g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), NULL);
+ source_name = e_source_peek_name (e_client_get_source (E_CLIENT (book_client)));
if (!source_name)
source_name="";
@@ -173,7 +173,7 @@ ea_minicard_view_get_name (AtkObject *accessible)
ATK_OBJECT_CLASS (parent_class)->set_name (accessible, string);
g_free (string);
- g_object_unref (book);
+ g_object_unref (book_client);
return accessible->name;
}
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 1ade6b143a..359c104c89 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -35,7 +35,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libedataserver/e-data-server-util.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>
#include "eab-gui-util.h"
@@ -108,7 +108,7 @@ eab_load_error_dialog (GtkWidget *parent, EAlertSink *alert_sink, ESource *sourc
uri = e_source_get_uri (source);
- if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_OFFLINE_UNAVAILABLE)) {
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OFFLINE_UNAVAILABLE)) {
can_detail_error = FALSE;
label_string = _("This address book cannot be opened. This either means this "
"book is not marked for offline usage or not yet downloaded "
@@ -166,7 +166,7 @@ eab_load_error_dialog (GtkWidget *parent, EAlertSink *alert_sink, ESource *sourc
if (can_detail_error) {
/* do not show repository offline message, it's kind of generic error */
- if (error && !g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_REPOSITORY_OFFLINE)) {
+ if (error && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE)) {
label = g_strconcat (label_string, "\n\n", _("Detailed error message:"), " ", error->message, NULL);
label_string = label;
}
@@ -187,46 +187,50 @@ eab_load_error_dialog (GtkWidget *parent, EAlertSink *alert_sink, ESource *sourc
}
void
-eab_search_result_dialog (EAlertSink *alert_sink,
- EBookViewStatus status,
- const gchar *error_msg)
+eab_search_result_dialog (EAlertSink *alert_sink, const GError *error)
{
gchar *str = NULL;
- switch (status) {
- case E_BOOK_VIEW_STATUS_OK:
+ if (!error)
return;
- case E_BOOK_VIEW_STATUS_SIZE_LIMIT_EXCEEDED:
- str = _("More cards matched this query than either the server is \n"
- "configured to return or Evolution is configured to display.\n"
- "Please make your search more specific or raise the result limit in\n"
- "the directory server preferences for this address book.");
- str = g_strdup (str);
- break;
- case E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED:
- str = _("The time to execute this query exceeded the server limit or the limit\n"
- "configured for this address book. Please make your search\n"
- "more specific or raise the time limit in the directory server\n"
- "preferences for this address book.");
- str = g_strdup (str);
- break;
- case E_BOOK_VIEW_ERROR_INVALID_QUERY:
- /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
- str = _("The backend for this address book was unable to parse this query. %s");
- str = g_strdup_printf (str, error_msg ? error_msg : "");
- break;
- case E_BOOK_VIEW_ERROR_QUERY_REFUSED:
- /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
- str = _("The backend for this address book refused to perform this query. %s");
- str = g_strdup_printf (str, error_msg ? error_msg : "");
- break;
- case E_BOOK_VIEW_ERROR_OTHER_ERROR:
+
+ if (error->domain == E_CLIENT_ERROR) {
+ switch (error->code) {
+ case E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED:
+ str = _("More cards matched this query than either the server is \n"
+ "configured to return or Evolution is configured to display.\n"
+ "Please make your search more specific or raise the result limit in\n"
+ "the directory server preferences for this address book.");
+ str = g_strdup (str);
+ break;
+ case E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED:
+ str = _("The time to execute this query exceeded the server limit or the limit\n"
+ "configured for this address book. Please make your search\n"
+ "more specific or raise the time limit in the directory server\n"
+ "preferences for this address book.");
+ str = g_strdup (str);
+ break;
+ case E_CLIENT_ERROR_INVALID_QUERY:
+ /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
+ str = _("The backend for this address book was unable to parse this query. %s");
+ str = g_strdup_printf (str, error->message);
+ break;
+ case E_CLIENT_ERROR_QUERY_REFUSED:
+ /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
+ str = _("The backend for this address book refused to perform this query. %s");
+ str = g_strdup_printf (str, error->message);
+ break;
+ case E_CLIENT_ERROR_OTHER_ERROR:
+ default:
+ /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
+ str = _("This query did not complete successfully. %s");
+ str = g_strdup_printf (str, error->message);
+ break;
+ }
+ } else {
/* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
str = _("This query did not complete successfully. %s");
- str = g_strdup_printf (str, error_msg ? error_msg : "");
- break;
- default:
- g_return_if_reached ();
+ str = g_strdup_printf (str, error->message);
}
e_alert_submit (alert_sink, "addressbook:search-error", str, NULL);
@@ -284,7 +288,7 @@ eab_select_source (ESource *except_source, const gchar *title, const gchar *mess
GtkWidget *scrolled_window;
gint response;
- if (!e_book_get_addressbooks (&source_list, NULL))
+ if (!e_book_client_get_sources (&source_list, NULL))
return NULL;
dialog = gtk_dialog_new_with_buttons (_("Select Address Book"), parent,
@@ -331,13 +335,13 @@ eab_select_source (ESource *except_source, const gchar *title, const gchar *mess
}
gchar *
-eab_suggest_filename (GList *contact_list)
+eab_suggest_filename (const GSList *contact_list)
{
gchar *res = NULL;
g_return_val_if_fail (contact_list != NULL, NULL);
- if (g_list_length (contact_list) == 1) {
+ if (!contact_list->next) {
EContact *contact = E_CONTACT (contact_list->data);
gchar *string;
@@ -357,36 +361,58 @@ eab_suggest_filename (GList *contact_list)
typedef struct ContactCopyProcess_ ContactCopyProcess;
-typedef void (*ContactCopyDone) (ContactCopyProcess *process);
-
struct ContactCopyProcess_ {
gint count;
gboolean book_status;
- GList *contacts;
- EBook *source;
- EBook *destination;
- ContactCopyDone done_cb;
+ GSList *contacts;
+ EBookClient *source;
+ EBookClient *destination;
+ gboolean delete_from_source;
EAlertSink *alert_sink;
};
+static void process_unref (ContactCopyProcess *process);
+
static void
-do_delete (gpointer data, gpointer user_data)
+remove_contact_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book = user_data;
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ ContactCopyProcess *process = user_data;
+ GError *error = NULL;
+
+ e_book_client_remove_contact_by_uid_finish (book_client, result, &error);
+
+ if (error) {
+ g_debug ("%s: Remove contact by uid failed: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ process_unref (process);
+}
+
+static void
+do_delete_from_source (gpointer data, gpointer user_data)
+{
+ ContactCopyProcess *process = user_data;
EContact *contact = data;
const gchar *id;
+ EBookClient *book_client = process->source;
id = e_contact_get_const (contact, E_CONTACT_UID);
- e_book_remove_contact (book, id, NULL);
+ g_return_if_fail (id != NULL);
+ g_return_if_fail (book_client != NULL);
+
+ process->count++;
+ e_book_client_remove_contact_by_uid (book_client, id, NULL, remove_contact_ready_cb, process);
}
static void
delete_contacts (ContactCopyProcess *process)
{
if (process->book_status == TRUE) {
- g_list_foreach (process->contacts,
- do_delete,
- process->source);
+ g_slist_foreach (process->contacts,
+ do_delete_from_source,
+ process);
}
}
@@ -395,12 +421,15 @@ process_unref (ContactCopyProcess *process)
{
process->count--;
if (process->count == 0) {
- if (process->done_cb)
- process->done_cb (process);
- g_list_foreach (
- process->contacts,
- (GFunc) g_object_unref, NULL);
- g_list_free (process->contacts);
+ if (process->delete_from_source) {
+ delete_contacts (process);
+ /* to not repeate this again */
+ process->delete_from_source = FALSE;
+
+ if (process->count > 0)
+ return;
+ }
+ e_client_util_free_object_slist (process->contacts);
g_object_unref (process->source);
g_object_unref (process->destination);
g_free (process);
@@ -408,58 +437,62 @@ process_unref (ContactCopyProcess *process)
}
static void
-contact_added_cb (EBook* book, const GError *error, const gchar *id, gpointer user_data)
+contact_added_cb (EBookClient *book_client, const GError *error, const gchar *id, gpointer user_data)
{
ContactCopyProcess *process = user_data;
- if (error && !g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) {
+ if (error && !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) {
process->book_status = FALSE;
eab_error_dialog (process->alert_sink, _("Error adding contact"), error);
}
- else if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) {
+ else if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) {
process->book_status = FALSE;
}
else {
/* success */
process->book_status = TRUE;
}
+
process_unref (process);
}
static void
do_copy (gpointer data, gpointer user_data)
{
- EBook *book;
+ EBookClient *book_client;
EContact *contact;
ContactCopyProcess *process;
process = user_data;
contact = data;
- book = process->destination;
+ book_client = process->destination;
process->count++;
- eab_merging_book_add_contact (book, contact, contact_added_cb, process);
+ eab_merging_book_add_contact (book_client, contact, contact_added_cb, process);
}
static void
-book_loaded_cb (ESource *destination,
- GAsyncResult *result,
- ContactCopyProcess *process)
+book_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
+ ESource *destination = E_SOURCE (source_object);
+ ContactCopyProcess *process = user_data;
+ EClient *client = NULL;
+ EBookClient *book_client;
GError *error = NULL;
- book = e_load_book_source_finish (destination, result, &error);
+ if (!e_client_utils_open_new_finish (destination, result, &client, &error))
+ client = NULL;
+
+ book_client = client ? E_BOOK_CLIENT (client) : NULL;
- if (book != NULL) {
+ if (book_client != NULL) {
g_warn_if_fail (error == NULL);
- process->destination = book;
+ process->destination = book_client;
process->book_status = TRUE;
- g_list_foreach (process->contacts, do_copy, process);
-
+ g_slist_foreach (process->contacts, do_copy, process);
} else if (error != NULL) {
- g_warning ("%s", error->message);
+ g_debug ("%s: Failed to open destination client: %s", G_STRFUNC, error->message);
g_error_free (error);
}
@@ -467,8 +500,8 @@ book_loaded_cb (ESource *destination,
}
void
-eab_transfer_contacts (EBook *source_book,
- GList *contacts /* adopted */,
+eab_transfer_contacts (EBookClient *source_client,
+ GSList *contacts /* adopted */,
gboolean delete_from_source,
EAlertSink *alert_sink)
{
@@ -478,7 +511,7 @@ eab_transfer_contacts (EBook *source_book,
gchar *desc;
GtkWindow *window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (alert_sink)));
- g_return_if_fail (E_IS_BOOK (source_book));
+ g_return_if_fail (E_IS_BOOK_CLIENT (source_client));
if (contacts == NULL)
return;
@@ -499,7 +532,7 @@ eab_transfer_contacts (EBook *source_book,
}
destination = eab_select_source (
- e_book_get_source (source_book),
+ e_client_get_source (E_CLIENT (source_client)),
desc, NULL, last_uid, window);
if (!destination)
@@ -513,19 +546,16 @@ eab_transfer_contacts (EBook *source_book,
process = g_new (ContactCopyProcess, 1);
process->count = 1;
process->book_status = FALSE;
- process->source = g_object_ref (source_book);
+ process->source = g_object_ref (source_client);
process->contacts = contacts;
process->destination = NULL;
process->alert_sink = alert_sink;
+ process->delete_from_source = delete_from_source;
- if (delete_from_source)
- process->done_cb = delete_contacts;
- else
- process->done_cb = NULL;
-
- e_load_book_source_async (
- destination, window, NULL,
- (GAsyncReadyCallback) book_loaded_cb, process);
+ e_client_utils_open_new (
+ destination, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, window,
+ book_loaded_cb, process);
}
/* To parse something like...
diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h
index b50df6de95..88a759b75b 100644
--- a/addressbook/gui/widgets/eab-gui-util.h
+++ b/addressbook/gui/widgets/eab-gui-util.h
@@ -25,7 +25,7 @@
#define __E_ADDRESSBOOK_UTIL_H__
#include <gtk/gtk.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include "e-util/e-alert-sink.h"
G_BEGIN_DECLS
@@ -38,14 +38,13 @@ void eab_load_error_dialog (GtkWidget *parent,
ESource *source,
const GError *error);
void eab_search_result_dialog (EAlertSink *alert_sink,
- EBookViewStatus status,
- const gchar *error_msg);
+ const GError *error);
gint eab_prompt_save_dialog (GtkWindow *parent);
-void eab_transfer_contacts (EBook *source_book,
- GList *contacts, /* adopted */
+void eab_transfer_contacts (EBookClient *source_client,
+ GSList *contacts, /* adopted */
gboolean delete_from_source,
EAlertSink *alert_sink);
-gchar * eab_suggest_filename (GList *contact_list);
+gchar * eab_suggest_filename (const GSList *contact_list);
ESource * eab_select_source (ESource *except_source,
const gchar *title,
const gchar *message,
diff --git a/addressbook/importers/evolution-addressbook-importers.h b/addressbook/importers/evolution-addressbook-importers.h
index 8278e67b12..e4579cbc4e 100644
--- a/addressbook/importers/evolution-addressbook-importers.h
+++ b/addressbook/importers/evolution-addressbook-importers.h
@@ -25,4 +25,4 @@ struct _EImportImporter *evolution_csv_mozilla_importer_peek (void);
struct _EImportImporter *evolution_csv_evolution_importer_peek (void);
/* private utility function for importers only */
-struct _GtkWidget *evolution_contact_importer_get_preview_widget (const GList *contacts);
+struct _GtkWidget *evolution_contact_importer_get_preview_widget (const GSList *contacts);
diff --git a/addressbook/importers/evolution-csv-importer.c b/addressbook/importers/evolution-csv-importer.c
index 358b8198ab..76607f342e 100644
--- a/addressbook/importers/evolution-csv-importer.c
+++ b/addressbook/importers/evolution-csv-importer.c
@@ -34,8 +34,8 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libebook/e-book.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libebook/e-book-client.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
#include <libebook/e-destination.h>
@@ -66,7 +66,7 @@ typedef struct {
* file to an index in the known fields array. */
GHashTable *fields_map;
- EBook *book;
+ EBookClient *book_client;
GSList *contacts;
} CSVImporter;
@@ -721,7 +721,11 @@ csv_import_contacts (gpointer d) {
EContact *contact = NULL;
while ((contact = getNextCSVEntry (gci, gci->file))) {
- e_book_add_contact (gci->book, contact, NULL);
+ gchar *uid = NULL;
+ if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) {
+ e_contact_set (contact, E_CONTACT_UID, uid);
+ g_free (uid);
+ }
gci->contacts = g_slist_prepend (gci->contacts, contact);
}
if (contact == NULL) {
@@ -755,7 +759,7 @@ csv_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im)
ESourceList *source_list;
/* FIXME Better error handling */
- if (!e_book_get_addressbooks (&source_list, NULL))
+ if (!e_book_client_get_sources (&source_list, NULL))
return NULL;
vbox = gtk_vbox_new (FALSE, FALSE);
@@ -829,7 +833,7 @@ csv_import_done (CSVImporter *gci)
g_source_remove (gci->idle_id);
fclose (gci->file);
- g_object_unref (gci->book);
+ g_object_unref (gci->book_client);
g_slist_foreach (gci->contacts, (GFunc) g_object_unref, NULL);
g_slist_free (gci->contacts);
@@ -843,13 +847,20 @@ csv_import_done (CSVImporter *gci)
}
static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- CSVImporter *gci)
+ gpointer user_data)
{
- gci->book = e_load_book_source_finish (source, result, NULL);
+ ESource *source = E_SOURCE (source_object);
+ CSVImporter *gci = user_data;
+ EClient *client = NULL;
+
+ if (!e_client_utils_open_new_finish (source, result, &client, NULL))
+ client = NULL;
+
+ gci->book_client = client ? E_BOOK_CLIENT (client) : NULL;
- if (gci->book == NULL) {
+ if (gci->book_client == NULL) {
csv_import_done (gci);
return;
}
@@ -893,8 +904,8 @@ csv_import (EImport *ei, EImportTarget *target, EImportImporter *im)
source = g_datalist_get_data (&target->data, "csv-source");
- e_load_book_source_async (
- source, NULL, NULL, (GAsyncReadyCallback)
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
book_loaded_cb, gci);
}
@@ -931,7 +942,7 @@ static GtkWidget *
csv_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
{
GtkWidget *preview;
- GList *contacts = NULL;
+ GSList *contacts = NULL;
EContact *contact;
EImportTargetURI *s = (EImportTargetURI *) target;
gchar *filename;
@@ -960,14 +971,13 @@ csv_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
fseek (file, 0, SEEK_SET);
while (contact = getNextCSVEntry (gci, gci->file), contact != NULL) {
- contacts = g_list_prepend (contacts, contact);
+ contacts = g_slist_prepend (contacts, contact);
}
- contacts = g_list_reverse (contacts);
+ contacts = g_slist_reverse (contacts);
preview = evolution_contact_importer_get_preview_widget (contacts);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ e_client_util_free_object_slist (contacts);
fclose (file);
g_free (gci);
diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c
index 85e46923d1..79d446cdaa 100644
--- a/addressbook/importers/evolution-ldif-importer.c
+++ b/addressbook/importers/evolution-ldif-importer.c
@@ -41,8 +41,8 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libebook/e-book.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libebook/e-book-client.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
#include <libebook/e-destination.h>
@@ -63,7 +63,7 @@ typedef struct {
FILE *file;
gulong size;
- EBook *book;
+ EBookClient *book_client;
GSList *contacts;
GSList *list_contacts;
@@ -497,10 +497,15 @@ ldif_import_contacts (gpointer d)
gci->list_contacts = g_slist_prepend (
gci->list_contacts, contact);
} else {
+ gchar *uid = NULL;
+
add_to_notes (contact, E_CONTACT_OFFICE);
add_to_notes (contact, E_CONTACT_SPOUSE);
add_to_notes (contact, E_CONTACT_BLOG_URL);
- e_book_add_contact (gci->book, contact, NULL);
+ if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) {
+ e_contact_set (contact, E_CONTACT_UID, uid);
+ g_free (uid);
+ }
gci->contacts = g_slist_prepend (gci->contacts, contact);
}
count++;
@@ -512,9 +517,14 @@ ldif_import_contacts (gpointer d)
}
if (gci->state == 1) {
for (iter = gci->list_iterator;count < 50 && iter;iter=iter->next) {
+ gchar *uid = NULL;
+
contact = iter->data;
resolve_list_card (gci, contact);
- e_book_add_contact (gci->book, contact, NULL);
+ if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) {
+ e_contact_set (contact, E_CONTACT_UID, uid);
+ g_free (uid);
+ }
count++;
}
gci->list_iterator = iter;
@@ -548,7 +558,7 @@ ldif_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im)
ESourceList *source_list;
/* FIXME Better error handling */
- if (!e_book_get_addressbooks (&source_list, NULL))
+ if (!e_book_client_get_sources (&source_list, NULL))
return NULL;
vbox = gtk_vbox_new (FALSE, FALSE);
@@ -618,7 +628,7 @@ ldif_import_done (LDIFImporter *gci)
g_source_remove (gci->idle_id);
fclose (gci->file);
- g_object_unref (gci->book);
+ g_object_unref (gci->book_client);
g_slist_foreach (gci->contacts, (GFunc) g_object_unref, NULL);
g_slist_foreach (gci->list_contacts, (GFunc) g_object_unref, NULL);
g_slist_free (gci->contacts);
@@ -632,13 +642,20 @@ ldif_import_done (LDIFImporter *gci)
}
static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- LDIFImporter *gci)
+ gpointer user_data)
{
- gci->book = e_load_book_source_finish (source, result, NULL);
+ ESource *source = E_SOURCE (source_object);
+ LDIFImporter *gci = user_data;
+ EClient *client = NULL;
+
+ if (!e_client_utils_open_new_finish (source, result, &client, NULL))
+ client = NULL;
+
+ gci->book_client = client ? E_BOOK_CLIENT (client) : NULL;
- if (gci->book == NULL) {
+ if (gci->book_client == NULL) {
ldif_import_done (gci);
return;
}
@@ -681,8 +698,8 @@ ldif_import (EImport *ei, EImportTarget *target, EImportImporter *im)
source = g_datalist_get_data (&target->data, "ldif-source");
- e_load_book_source_async (
- source, NULL, NULL, (GAsyncReadyCallback)
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
book_loaded_cb, gci);
}
@@ -699,7 +716,7 @@ static GtkWidget *
ldif_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
{
GtkWidget *preview;
- GList *contacts = NULL;
+ GSList *contacts = NULL;
EContact *contact;
EImportTargetURI *s = (EImportTargetURI *) target;
gchar *filename;
@@ -732,16 +749,15 @@ ldif_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
add_to_notes (contact, E_CONTACT_BLOG_URL);
}
- contacts = g_list_prepend (contacts, contact);
+ contacts = g_slist_prepend (contacts, contact);
}
g_hash_table_destroy (dn_contact_hash);
- contacts = g_list_reverse (contacts);
+ contacts = g_slist_reverse (contacts);
preview = evolution_contact_importer_get_preview_widget (contacts);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ e_client_util_free_object_slist (contacts);
fclose (file);
return preview;
diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c
index 04f81b222c..09ad3d1f7f 100644
--- a/addressbook/importers/evolution-vcard-importer.c
+++ b/addressbook/importers/evolution-vcard-importer.c
@@ -35,8 +35,8 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libebook/e-book.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libebook/e-book-client.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
#include <util/eab-book-util.h>
@@ -69,9 +69,9 @@ typedef struct {
ESource *primary;
- GList *contactlist;
- GList *iterator;
- EBook *book;
+ GSList *contactlist;
+ GSList *iterator;
+ EBookClient *book_client;
/* when opening book */
gchar *contents;
@@ -109,6 +109,7 @@ vcard_import_contact (VCardImporter *gci, EContact *contact)
{
EContactPhoto *photo;
GList *attrs, *attr;
+ gchar *uid = NULL;
/* Apple's addressbook.app exports PHOTO's without a TYPE
param, so let's figure out the format here if there's a
@@ -249,7 +250,10 @@ vcard_import_contact (VCardImporter *gci, EContact *contact)
add_to_notes (contact, E_CONTACT_BLOG_URL);
/* FIXME Error checking */
- e_book_add_contact (gci->book, contact, NULL);
+ if (e_book_client_add_contact_sync (gci->book_client, contact, &uid, NULL, NULL) && uid) {
+ e_contact_set (contact, E_CONTACT_UID, uid);
+ g_free (uid);
+ }
}
static gboolean
@@ -257,7 +261,7 @@ vcard_import_contacts (gpointer data)
{
VCardImporter *gci = data;
gint count = 0;
- GList *iterator = gci->iterator;
+ GSList *iterator = gci->iterator;
if (gci->state == 0) {
while (count < 50 && iterator) {
@@ -402,7 +406,7 @@ vcard_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im)
ESourceList *source_list;
/* FIXME Better error handling */
- if (!e_book_get_addressbooks (&source_list, NULL))
+ if (!e_book_client_get_sources (&source_list, NULL))
return NULL;
vbox = gtk_vbox_new (FALSE, FALSE);
@@ -465,9 +469,8 @@ vcard_import_done (VCardImporter *gci)
g_source_remove (gci->idle_id);
g_free (gci->contents);
- g_object_unref (gci->book);
- g_list_foreach (gci->contactlist, (GFunc) g_object_unref, NULL);
- g_list_free (gci->contactlist);
+ g_object_unref (gci->book_client);
+ e_client_util_free_object_slist (gci->contactlist);
e_import_complete (gci->import, gci->target);
g_object_unref (gci->import);
@@ -475,13 +478,20 @@ vcard_import_done (VCardImporter *gci)
}
static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- VCardImporter *gci)
+ gpointer user_data)
{
- gci->book = e_load_book_source_finish (source, result, NULL);
+ ESource *source = E_SOURCE (source_object);
+ VCardImporter *gci = user_data;
+ EClient *client = NULL;
+
+ if (!e_client_utils_open_new_finish (source, result, &client, NULL))
+ client = NULL;
+
+ gci->book_client = client ? E_BOOK_CLIENT (client) : NULL;
- if (gci->book == NULL) {
+ if (gci->book_client == NULL) {
vcard_import_done (gci);
return;
}
@@ -504,7 +514,7 @@ book_loaded_cb (ESource *source,
g_free (gci->contents);
gci->contents = NULL;
gci->iterator = gci->contactlist;
- gci->total = g_list_length (gci->contactlist);
+ gci->total = g_slist_length (gci->contactlist);
if (gci->iterator)
gci->idle_id = g_idle_add (vcard_import_contacts, gci);
@@ -554,8 +564,8 @@ vcard_import (EImport *ei, EImportTarget *target, EImportImporter *im)
source = g_datalist_get_data (&target->data, "vcard-source");
- e_load_book_source_async (
- source, NULL, NULL, (GAsyncReadyCallback)
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
book_loaded_cb, gci);
}
@@ -572,7 +582,7 @@ static GtkWidget *
vcard_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
{
GtkWidget *preview;
- GList *contacts;
+ GSList *contacts;
gchar *contents;
VCardEncoding encoding;
EImportTargetURI *s = (EImportTargetURI *) target;
@@ -617,8 +627,7 @@ vcard_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im)
preview = evolution_contact_importer_get_preview_widget (contacts);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ e_client_util_free_object_slist (contacts);
return preview;
}
@@ -904,14 +913,14 @@ preview_selection_changed_cb (GtkTreeSelection *selection, EWebViewPreview *prev
}
GtkWidget *
-evolution_contact_importer_get_preview_widget (const GList *contacts)
+evolution_contact_importer_get_preview_widget (const GSList *contacts)
{
GtkWidget *preview;
GtkTreeView *tree_view;
GtkTreeSelection *selection;
GtkListStore *store;
GtkTreeIter iter;
- const GList *c;
+ const GSList *c;
if (!contacts)
return NULL;
diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c
index 05f1101467..8057192f77 100644
--- a/addressbook/printing/e-contact-print.c
+++ b/addressbook/printing/e-contact-print.c
@@ -32,7 +32,8 @@
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include <glib/gi18n.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-client-view.h>
#include <libebook/e-contact.h>
#include <libedataserver/e-flag.h>
@@ -49,6 +50,7 @@ typedef struct _ContactPrintItem ContactPrintItem;
struct _EContactPrintContext
{
+ GtkPrintOperationAction action;
GtkPrintContext *context;
gdouble x;
gdouble y;
@@ -64,10 +66,7 @@ struct _EContactPrintContext
gchar *section;
gboolean first_contact;
- EBook *book;
- EBookQuery *query;
-
- GList *contact_list;
+ GSList *contact_list;
};
static gdouble
@@ -385,12 +384,12 @@ contact_compare (EContact *contact1,
}
static void
-contacts_added (EBookView *book_view,
- const GList *contact_list,
+contacts_added (EBookClientView *book_view,
+ const GSList *contact_list,
EContactPrintContext *ctxt)
{
while (contact_list != NULL) {
- ctxt->contact_list = g_list_insert_sorted (
+ ctxt->contact_list = g_slist_insert_sorted (
ctxt->contact_list,
g_object_ref (contact_list->data),
(GCompareFunc) contact_compare);
@@ -399,12 +398,25 @@ contacts_added (EBookView *book_view,
}
static void
-view_complete (EBookView *book_view,
- EBookViewStatus status,
- const gchar *error_msg,
- EFlag *book_view_started)
+view_complete (EBookClientView *client_view,
+ const GError *error,
+ GtkPrintOperation *operation)
{
- e_flag_set (book_view_started);
+ EContactPrintContext *ctxt;
+
+ g_return_if_fail (operation != NULL);
+
+ ctxt = g_object_get_data (G_OBJECT (operation), "contact-print-ctx");
+ g_return_if_fail (ctxt != NULL);
+
+ e_book_client_view_stop (client_view, NULL);
+ g_signal_handlers_disconnect_by_func (client_view, G_CALLBACK (contacts_added), ctxt);
+ g_signal_handlers_disconnect_by_func (client_view, G_CALLBACK (view_complete), operation);
+
+ g_object_unref (client_view);
+
+ gtk_print_operation_run (operation, ctxt->action, NULL, NULL);
+ g_object_unref (operation);
}
static gboolean
@@ -584,40 +596,6 @@ e_contact_build_style (EContactPrintStyle *style)
}
static void
-load_contacts (EContactPrintContext *ctxt)
-{
- /* Load contacts from the EBook. This is an asynchronous operation
- * but we force it to be synchronous here. */
-
- EBookView *book_view;
- EFlag *book_view_started;
-
- book_view_started = e_flag_new ();
-
- e_book_get_book_view (
- ctxt->book, ctxt->query, NULL, -1, &book_view, NULL);
-
- g_signal_connect (
- book_view, "contacts_added",
- G_CALLBACK (contacts_added), ctxt);
- g_signal_connect (
- book_view, "view_complete",
- G_CALLBACK (view_complete), book_view_started);
-
- e_book_view_start (book_view);
-
- while (!e_flag_is_set (book_view_started))
- g_main_context_iteration (NULL, TRUE);
-
- e_flag_free (book_view_started);
-
- g_signal_handlers_disconnect_by_func (
- book_view, G_CALLBACK (contacts_added), ctxt);
- g_signal_handlers_disconnect_by_func (
- book_view, G_CALLBACK (view_complete), book_view_started);
-}
-
-static void
contact_draw (EContact *contact,
EContactPrintContext *ctxt)
{
@@ -674,13 +652,6 @@ contact_draw (EContact *contact,
}
static void
-free_contacts (EContactPrintContext *ctxt)
-{
- g_list_foreach (ctxt->contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (ctxt->contact_list);
-}
-
-static void
contact_begin_print (GtkPrintOperation *operation,
GtkPrintContext *context,
EContactPrintContext *ctxt)
@@ -714,11 +685,10 @@ contact_begin_print (GtkPrintOperation *operation,
pango_font_description_get_size (
ctxt->style->headings_font) * 1.5);
- if (ctxt->book != NULL) {
- load_contacts (ctxt);
+ if (ctxt->contact_list != NULL) {
ctxt->page_nr = -1;
ctxt->pages = 1;
- g_list_foreach (ctxt->contact_list, (GFunc) contact_draw, ctxt);
+ g_slist_foreach (ctxt->contact_list, (GFunc) contact_draw, ctxt);
gtk_print_operation_set_n_pages (operation, ctxt->pages);
}
}
@@ -788,7 +758,7 @@ contact_draw_page (GtkPrintOperation *operation,
ctxt->first_section = TRUE;
ctxt->section = NULL;
- g_list_foreach (ctxt->contact_list, (GFunc) contact_draw, ctxt);
+ g_slist_foreach (ctxt->contact_list, (GFunc) contact_draw, ctxt);
contact_page_draw_footer (operation, context, page_nr);
}
@@ -803,49 +773,88 @@ contact_end_print (GtkPrintOperation *operation,
pango_font_description_free (ctxt->style->footer_font);
pango_font_description_free (ctxt->letter_heading_font);
+ e_client_util_free_object_slist (ctxt->contact_list);
+
+ g_free (ctxt->style);
g_free (ctxt->section);
+}
+
+static void
+get_view_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ GtkPrintOperation *operation = user_data;
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
+ EBookClientView *client_view = NULL;
+ EContactPrintContext *ctxt;
+ GError *error = NULL;
+
+ e_book_client_get_view_finish (book_client, result, &client_view, &error);
+
+ ctxt = g_object_get_data (G_OBJECT (operation), "contact-print-ctx");
+ g_return_if_fail (ctxt != NULL);
+
+ if (error) {
+ g_debug ("%s: Failed to get view: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+
+ gtk_print_operation_run (operation, ctxt->action, NULL, NULL);
+ g_object_unref (operation);
+ } else {
+ g_signal_connect (client_view, "objects-added", G_CALLBACK (contacts_added), ctxt);
+ g_signal_connect (client_view, "complete", G_CALLBACK (view_complete), operation);
+
+ e_book_client_view_start (client_view, &error);
- if (ctxt->book != NULL)
- free_contacts (ctxt);
+ if (error) {
+ g_debug ("%s: Failed to start view: %s\n", G_STRFUNC, error->message);
+ g_error_free (error);
+
+ gtk_print_operation_run (operation, ctxt->action, NULL, NULL);
+ g_object_unref (operation);
+ }
+ }
}
void
-e_contact_print (EBook *book,
+e_contact_print (EBookClient *book_client,
EBookQuery *query,
- GList *contact_list,
+ const GSList *contact_list,
GtkPrintOperationAction action)
{
GtkPrintOperation *operation;
- EContactPrintContext ctxt;
- EContactPrintStyle style;
+ EContactPrintContext *ctxt;
- if (book != NULL) {
- ctxt.book = book;
- ctxt.query = query;
- ctxt.contact_list = NULL;
- } else {
- ctxt.book = NULL;
- ctxt.query = NULL;
- ctxt.contact_list = contact_list;
- }
- ctxt.style = &style;
- ctxt.page_nr = 0;
- ctxt.pages = 0;
+ ctxt = g_new0 (EContactPrintContext, 1);
+ ctxt->action = action;
+ ctxt->contact_list = e_client_util_copy_object_slist (NULL, contact_list);
+ ctxt->style = g_new0 (EContactPrintStyle, 1);
+ ctxt->page_nr = 0;
+ ctxt->pages = 0;
operation = e_print_operation_new ();
gtk_print_operation_set_n_pages (operation, 1);
+ g_object_set_data_full (G_OBJECT (operation), "contact-print-ctx", ctxt, g_free);
+
g_signal_connect (
operation, "begin-print",
- G_CALLBACK (contact_begin_print), &ctxt);
+ G_CALLBACK (contact_begin_print), ctxt);
g_signal_connect (
operation, "draw_page",
- G_CALLBACK (contact_draw_page), &ctxt);
+ G_CALLBACK (contact_draw_page), ctxt);
g_signal_connect (
operation, "end-print",
- G_CALLBACK (contact_end_print), &ctxt);
+ G_CALLBACK (contact_end_print), ctxt);
- gtk_print_operation_run (operation, action, NULL, NULL);
+ if (book_client) {
+ gchar *query_str = e_book_query_to_string (query);
- g_object_unref (operation);
+ e_book_client_get_view (book_client, query_str, NULL, get_view_ready_cb, operation);
+
+ g_free (query_str);
+ } else {
+ gtk_print_operation_run (operation, action, NULL, NULL);
+
+ g_object_unref (operation);
+ }
}
diff --git a/addressbook/printing/e-contact-print.h b/addressbook/printing/e-contact-print.h
index d87a3e6fcb..94a61b080c 100644
--- a/addressbook/printing/e-contact-print.h
+++ b/addressbook/printing/e-contact-print.h
@@ -24,12 +24,13 @@
#define E_CONTACT_PRINT_H
#include <gtk/gtk.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
#include "e-contact-print-types.h"
-void e_contact_print (EBook *book,
+void e_contact_print (EBookClient *book_client,
EBookQuery *query,
- GList *contact_list,
+ const GSList *contact_list,
GtkPrintOperationAction action);
void contact_page_draw_footer (GtkPrintOperation *operation,
GtkPrintContext *context,
diff --git a/addressbook/tools/evolution-addressbook-export-list-cards.c b/addressbook/tools/evolution-addressbook-export-list-cards.c
index eed6dbc183..b886b2cc32 100644
--- a/addressbook/tools/evolution-addressbook-export-list-cards.c
+++ b/addressbook/tools/evolution-addressbook-export-list-cards.c
@@ -31,7 +31,8 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
#include <libebook/e-contact.h>
#include "evolution-addressbook-export.h"
@@ -243,7 +244,7 @@ gchar *e_contact_get_csv (EContact * contact, GSList * csv_all_fields);
gchar *delivery_address_get_sub_field (const EContactAddress * delivery_address, DeliveryAddressField sub_field);
gchar *check_null_pointer (gchar * orig);
gchar *escape_string (gchar * orig);
-gint output_n_cards_file (FILE * outputfile, GList *contacts, gint size, gint begin_no, CARD_FORMAT format);
+gint output_n_cards_file (FILE * outputfile, GSList *contacts, gint size, gint begin_no, CARD_FORMAT format);
static void fork_to_background (void);
void set_pre_defined_field (GSList ** pre_defined_fields);
@@ -562,12 +563,12 @@ escape_string (gchar *orig)
}
gint
-output_n_cards_file (FILE * outputfile, GList *contacts, gint size, gint begin_no, CARD_FORMAT format)
+output_n_cards_file (FILE * outputfile, GSList *contacts, gint size, gint begin_no, CARD_FORMAT format)
{
gint i;
if (format == CARD_FORMAT_VCARD) {
for (i = begin_no; i < size + begin_no; i++) {
- EContact *contact = g_list_nth_data (contacts, i);
+ EContact *contact = g_slist_nth_data (contacts, i);
gchar *vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
fprintf (outputfile, "%s\n", vcard);
g_free (vcard);
@@ -583,7 +584,7 @@ output_n_cards_file (FILE * outputfile, GList *contacts, gint size, gint begin_n
g_free (csv_fields_name);
for (i = begin_no; i < size + begin_no; i++) {
- EContact *contact = g_list_nth_data (contacts, i);
+ EContact *contact = g_slist_nth_data (contacts, i);
gchar *csv = e_contact_get_csv (contact, pre_defined_fields);
fprintf (outputfile, "%s\n", csv);
g_free (csv);
@@ -616,7 +617,7 @@ fork_to_background (void)
}
static void
-action_list_cards (GList *contacts, ActionContext * p_actctx)
+action_list_cards (GSList *contacts, ActionContext * p_actctx)
{
FILE *outputfile;
long length;
@@ -626,7 +627,7 @@ action_list_cards (GList *contacts, ActionContext * p_actctx)
CARD_FORMAT format;
gint size;
- length = g_list_length (contacts);
+ length = g_slist_length (contacts);
if (length <= 0) {
g_warning ("Couldn't load addressbook correctly!!!! %s####", p_actctx->action_list_cards.addressbook_folder_uri ?
@@ -761,31 +762,47 @@ set_pre_defined_field (GSList ** pre_defined_fields)
guint
action_list_cards_init (ActionContext * p_actctx)
{
- EBook *book;
+ EBookClient *book_client;
EBookQuery *query;
- GList *contacts;
+ gchar *query_str;
+ GSList *contacts;
+ GError *error = NULL;
if (p_actctx->action_list_cards.addressbook_folder_uri != NULL) {
- book = e_book_new_from_uri (p_actctx->action_list_cards.addressbook_folder_uri, NULL);
+ book_client = e_book_client_new_from_uri (p_actctx->action_list_cards.addressbook_folder_uri, &error);
} else {
- book = e_book_new_default_addressbook (NULL);
+ book_client = e_book_client_new_default (&error);
}
- if (!book
- || !e_book_open (book, TRUE, NULL)) {
- g_warning ("Couldn't load addressbook %s", p_actctx->action_list_cards.addressbook_folder_uri ?
- p_actctx->action_list_cards.addressbook_folder_uri : "NULL");
+ if (!book_client
+ || !e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error)) {
+ g_warning ("Couldn't load addressbook %s: %s", p_actctx->action_list_cards.addressbook_folder_uri ?
+ p_actctx->action_list_cards.addressbook_folder_uri : "'default'",
+ error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ if (book_client)
+ g_object_unref (book_client);
exit (-1);
}
query = e_book_query_any_field_contains ("");
- e_book_get_contacts (book, query, &contacts, NULL);
+ query_str = e_book_query_to_string (query);
e_book_query_unref (query);
+ if (!e_book_client_get_contacts_sync (book_client, query_str, &contacts, NULL, &error))
+ contacts = NULL;
+
action_list_cards (contacts, p_actctx);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
+ g_slist_free (contacts);
+ g_object_unref (book_client);
- return SUCCESS;
+ if (error) {
+ g_warning ("Failed to get contacts: %s", error->message);
+ g_error_free (error);
+ }
+
+ return error ? FAILED : SUCCESS;
}
diff --git a/addressbook/tools/evolution-addressbook-export-list-folders.c b/addressbook/tools/evolution-addressbook-export-list-folders.c
index 440b757097..82241f8f67 100644
--- a/addressbook/tools/evolution-addressbook-export-list-folders.c
+++ b/addressbook/tools/evolution-addressbook-export-list-folders.c
@@ -26,7 +26,8 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
#include "evolution-addressbook-export.h"
@@ -36,9 +37,14 @@ action_list_folders_init (ActionContext * p_actctx)
ESourceList *addressbooks = NULL;
GSList *groups, *group;
FILE *outputfile = NULL;
-
- if (!e_book_get_addressbooks (&addressbooks, NULL)) {
- g_warning (_("Couldn't get list of address books"));
+ GError *error = NULL;
+ EBookQuery *query;
+ gchar *query_str;
+
+ if (!e_book_client_get_sources (&addressbooks, &error)) {
+ g_warning (_("Couldn't get list of address books: %s"), error ? error->message : _("Unknown error"));
+ if (error)
+ g_error_free (error);
exit (-1);
}
@@ -49,6 +55,10 @@ action_list_folders_init (ActionContext * p_actctx)
}
}
+ query = e_book_query_any_field_contains ("");
+ query_str = e_book_query_to_string (query);
+ e_book_query_unref (query);
+
groups = e_source_list_peek_groups (addressbooks);
for (group = groups; group; group = group->next) {
ESourceGroup *g = group->data;
@@ -57,22 +67,23 @@ action_list_folders_init (ActionContext * p_actctx)
sources = e_source_group_peek_sources (g);
for (source = sources; source; source = source->next) {
ESource *s = source->data;
- EBook *book;
- EBookQuery *query;
- GList *contacts;
+ EBookClient *book_client;
+ GSList *contacts;
gchar *uri;
const gchar *name;
- book = e_book_new (s, NULL);
- if (!book
- || !e_book_open (book, TRUE, NULL)) {
- g_warning (_("failed to open book"));
+ error = NULL;
+ book_client = e_book_client_new (s, &error);
+ if (!book_client
+ || !e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error)) {
+ g_warning (_("Failed to open client '%s': %s"), e_source_peek_name (s), error ? error->message : _("Unknown error"));
+ if (error)
+ g_error_free (error);
continue;
}
- query = e_book_query_any_field_contains ("");
- e_book_get_contacts (book, query, &contacts, NULL);
- e_book_query_unref (query);
+ if (!e_book_client_get_contacts_sync (book_client, query_str, &contacts, NULL, &error))
+ contacts = NULL;
uri = e_source_get_uri (s);
name = e_source_peek_name (s);
@@ -80,18 +91,20 @@ action_list_folders_init (ActionContext * p_actctx)
if (outputfile)
fprintf (
outputfile, "\"%s\",\"%s\",%d\n",
- uri, name, g_list_length (contacts));
+ uri, name, g_slist_length (contacts));
else
- printf ("\"%s\",\"%s\",%d\n", uri, name, g_list_length (contacts));
+ printf ("\"%s\",\"%s\",%d\n", uri, name, g_slist_length (contacts));
g_free (uri);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
+ g_slist_free (contacts);
- g_object_unref (book);
+ g_object_unref (book_client);
}
}
+ g_free (query_str);
+
if (outputfile)
fclose (outputfile);
diff --git a/addressbook/tools/evolution-addressbook-export.c b/addressbook/tools/evolution-addressbook-export.c
index e780cfbfda..56a2b14a54 100644
--- a/addressbook/tools/evolution-addressbook-export.c
+++ b/addressbook/tools/evolution-addressbook-export.c
@@ -27,7 +27,7 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include "evolution-addressbook-export.h"
diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c
index 638f536c37..de6900d1d0 100644
--- a/addressbook/util/eab-book-util.c
+++ b/addressbook/util/eab-book-util.c
@@ -25,143 +25,9 @@
#include <config.h>
#endif
-#include "eab-book-util.h"
-
#include <string.h>
-/*
- *
- * Specialized Queries
- *
- */
-
-static gchar *
-escape (const gchar *str)
-{
- GString *s = g_string_new (NULL);
- const gchar *p = str;
-
- while (*p) {
- if (*p == '\\')
- g_string_append_len (s, "\\\\", 2);
- else if (*p == '"')
- g_string_append_len (s, "\\\"", 2);
- else
- g_string_append_c (s, *p);
-
- p++;
- }
-
- return g_string_free (s, FALSE);
-}
-
-guint
-eab_name_and_email_query (EBook *book,
- const gchar *name,
- const gchar *email,
- EBookListAsyncCallback cb,
- gpointer closure)
-{
- gchar *email_query=NULL, *name_query=NULL;
- EBookQuery *query;
- guint tag;
- gchar *escaped_name, *escaped_email;
-
- g_return_val_if_fail (book && E_IS_BOOK (book), 0);
- g_return_val_if_fail (cb != NULL, 0);
-
- if (name && !*name)
- name = NULL;
- if (email && !*email)
- email = NULL;
-
- if (name == NULL && email == NULL)
- return 0;
-
- escaped_name = name ? escape (name) : NULL;
- escaped_email = email ? escape (email) : NULL;
-
- /* Build our e-mail query.
- * We only query against the username part of the address, to avoid not matching
- * fred@foo.com and fred@mail.foo.com. While their may be namespace collisions
- * in the usernames of everyone out there, it shouldn't be that bad. (Famous last words.)
- * But if name is missing we query against complete email id to avoid matching emails like
- * users@foo.org with users@bar.org
- */
- if (escaped_email) {
- const gchar *t = escaped_email;
- while (*t && *t != '@')
- ++t;
- if (*t == '@' && escaped_name) {
- email_query = g_strdup_printf ("(beginswith \"email\" \"%.*s@\")", (gint)(t-escaped_email), escaped_email);
-
- } else {
- email_query = g_strdup_printf ("(beginswith \"email\" \"%s\")", escaped_email);
- }
- }
-
- /* Build our name query.*/
-
- if (escaped_name)
- name_query = g_strdup_printf ("(or (beginswith \"file_as\" \"%s\") (beginswith \"full_name\" \"%s\"))", escaped_name, escaped_name);
-
- /* Assemble our e-mail & name queries */
- if (email_query && name_query) {
- gchar *full_query = g_strdup_printf ("(and %s %s)", email_query, name_query);
- query = e_book_query_from_string (full_query);
- g_free (full_query);
- }
- else if (email_query) {
- query = e_book_query_from_string (email_query);
- }
- else if (name_query) {
- query = e_book_query_from_string (name_query);
- }
- else
- return 0;
-
- tag = e_book_get_contacts_async (book, query, cb, closure);
-
- g_free (email_query);
- g_free (name_query);
- g_free (escaped_email);
- g_free (escaped_name);
- e_book_query_unref (query);
-
- return tag;
-}
-
-/*
- * Simple nickname query
- */
-guint
-eab_nickname_query (EBook *book,
- const gchar *nickname,
- EBookListAsyncCallback cb,
- gpointer closure)
-{
- EBookQuery *query;
- gchar *query_string;
- guint retval;
-
- g_return_val_if_fail (E_IS_BOOK (book), 0);
- g_return_val_if_fail (nickname != NULL, 0);
-
- /* The empty-string case shouldn't generate a warning. */
- if (!*nickname)
- return 0;
-
- query_string = g_strdup_printf ("(is \"nickname\" \"%s\")", nickname);
-
- query = e_book_query_from_string (query_string);
-
- retval = e_book_get_contacts_async (book, query, cb, closure);
-
- g_free (query_string);
- e_book_query_unref (query);
-
- return retval;
-}
+#include "eab-book-util.h"
/* Copied from camel_strstrcase */
static gchar *
@@ -188,10 +54,10 @@ eab_strstrcase (const gchar *haystack, const gchar *needle)
return NULL;
}
-GList*
+GSList *
eab_contact_list_from_string (const gchar *str)
{
- GList *contacts = NULL;
+ GSList *contacts = NULL;
GString *gstr = g_string_new (NULL);
gchar *str_stripped;
gchar *p = (gchar *) str;
@@ -249,20 +115,20 @@ eab_contact_list_from_string (const gchar *str)
break;
card_str = g_strndup (p, q - p);
- contacts = g_list_append (contacts, e_contact_new_from_vcard (card_str));
+ contacts = g_slist_prepend (contacts, e_contact_new_from_vcard (card_str));
g_free (card_str);
}
g_free (str_stripped);
- return contacts;
+ return g_slist_reverse (contacts);
}
gchar *
-eab_contact_list_to_string (GList *contacts)
+eab_contact_list_to_string (const GSList *contacts)
{
GString *str = g_string_new ("");
- GList *l;
+ const GSList *l;
for (l = contacts; l; l = l->next) {
EContact *contact = l->data;
@@ -277,13 +143,13 @@ eab_contact_list_to_string (GList *contacts)
}
gboolean
-eab_book_and_contact_list_from_string (const gchar *str, EBook **book, GList **contacts)
+eab_book_and_contact_list_from_string (const gchar *str, EBookClient **book_client, GSList **contacts)
{
const gchar *s0, *s1;
gchar *uri;
g_return_val_if_fail (str != NULL, FALSE);
- g_return_val_if_fail (book != NULL, FALSE);
+ g_return_val_if_fail (book_client != NULL, FALSE);
g_return_val_if_fail (contacts != NULL, FALSE);
*contacts = eab_contact_list_from_string (str);
@@ -300,19 +166,19 @@ eab_book_and_contact_list_from_string (const gchar *str, EBook **book, GList **c
}
if (!s0 || !s1) {
- *book = NULL;
+ *book_client = NULL;
return FALSE;
}
uri = g_strndup (s0, s1 - s0);
- *book = e_book_new_from_uri (uri, NULL);
+ *book_client = e_book_client_new_from_uri (uri, NULL);
g_free (uri);
- return *book ? TRUE : FALSE;
+ return *book_client ? TRUE : FALSE;
}
gchar *
-eab_book_and_contact_list_to_string (EBook *book, GList *contacts)
+eab_book_and_contact_list_to_string (EBookClient *book_client, const GSList *contacts)
{
gchar *s0, *s1;
@@ -320,8 +186,8 @@ eab_book_and_contact_list_to_string (EBook *book, GList *contacts)
if (!s0)
s0 = g_strdup ("");
- if (book)
- s1 = g_strconcat ("Book: ", e_book_get_uri (book), "\r\n", s0, NULL);
+ if (book_client)
+ s1 = g_strconcat ("Book: ", e_client_get_uri (E_CLIENT (book_client)), "\r\n", s0, NULL);
else
s1 = g_strdup (s0);
@@ -329,70 +195,6 @@ eab_book_and_contact_list_to_string (EBook *book, GList *contacts)
return s1;
}
-#ifdef notyet
-/*
- * Convenience routine to check for addresses in the local address book.
- */
-
-typedef struct _HaveAddressInfo HaveAddressInfo;
-struct _HaveAddressInfo {
- gchar *email;
- EBookHaveAddressCallback cb;
- gpointer closure;
-};
-
-static void
-have_address_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *contacts, gpointer closure)
-{
- HaveAddressInfo *info = (HaveAddressInfo *) closure;
-
- info->cb (book,
- info->email,
- contacts && (status == E_BOOK_ERROR_OK) ? E_CONTACT (contacts->data) : NULL,
- info->closure);
-
- g_free (info->email);
- g_free (info);
-}
-
-static void
-have_address_book_open_cb (EBook *book, gpointer closure)
-{
- HaveAddressInfo *info = (HaveAddressInfo *) closure;
-
- if (book) {
-
- e_book_name_and_email_query (book, NULL, info->email, have_address_query_cb, info);
-
- } else {
-
- info->cb (NULL, info->email, NULL, info->closure);
-
- g_free (info->email);
- g_free (info);
-
- }
-}
-
-void
-eab_query_address_default (const gchar *email,
- EABHaveAddressCallback cb,
- gpointer closure)
-{
- HaveAddressInfo *info;
-
- g_return_if_fail (email != NULL);
- g_return_if_fail (cb != NULL);
-
- info = g_new0 (HaveAddressInfo, 1);
- info->email = g_strdup (email);
- info->cb = cb;
- info->closure = closure;
-
- e_book_use_default_book (have_address_book_open_cb, info);
-}
-#endif
-
/* bad place for this i know. */
gint
e_utf8_casefold_collate_len (const gchar *str1, const gchar *str2, gint len)
diff --git a/addressbook/util/eab-book-util.h b/addressbook/util/eab-book-util.h
index 1cda93c102..602e7bd44b 100644
--- a/addressbook/util/eab-book-util.h
+++ b/addressbook/util/eab-book-util.h
@@ -21,42 +21,22 @@
*
*/
-#ifndef __EAB_UTIL_H__
-#define __EAB_UTIL_H__
+#ifndef EAB_BOOK_UTIL_H
+#define EAB_BOOK_UTIL_H
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
G_BEGIN_DECLS
-typedef void (*EABHaveAddressCallback) (EBook *book, const gchar *addr, EContact *contact, gpointer closure);
+GSList * eab_contact_list_from_string (const gchar *str);
+gchar * eab_contact_list_to_string (const GSList *contacts);
-/* Specialized Name/Email Queries */
-guint eab_name_and_email_query (EBook *book,
- const gchar *name,
- const gchar *email,
- EBookListAsyncCallback cb,
- gpointer closure);
-guint eab_nickname_query (EBook *book,
- const gchar *nickname,
- EBookListAsyncCallback cb,
- gpointer closure);
+gboolean eab_book_and_contact_list_from_string (const gchar *str, EBookClient **book_client, GSList **contacts);
+gchar * eab_book_and_contact_list_to_string (EBookClient *book_client, const GSList *contacts);
-GList *eab_contact_list_from_string (const gchar *str);
-gchar *eab_contact_list_to_string (GList *contacts);
-
-gboolean eab_book_and_contact_list_from_string (const gchar *str, EBook **book, GList **contacts);
-gchar *eab_book_and_contact_list_to_string (EBook *book, GList *contacts);
-
-/* Returns the EContact associated to email in the callback,
- or NULL if no match is found in the default address book. */
-void eab_query_address_default (const gchar *email,
- EABHaveAddressCallback cb,
- gpointer closure);
-
-gint e_utf8_casefold_collate_len (const gchar *str1, const gchar *str2, gint len);
-gint e_utf8_casefold_collate (const gchar *str1, const gchar *str2);
+gint e_utf8_casefold_collate_len (const gchar *str1, const gchar *str2, gint len);
+gint e_utf8_casefold_collate (const gchar *str1, const gchar *str2);
G_END_DECLS
-#endif /* __EAB_UTIL_H__ */
-
+#endif /* EAB_BOOK_UTIL_H */
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
index dfed6e66c7..76bc20338d 100644
--- a/calendar/Makefile.am
+++ b/calendar/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = common importers gui
+SUBDIRS = importers gui
error_DATA = calendar.error
errordir = $(privdatadir)/errors
diff --git a/calendar/common/Makefile.am b/calendar/common/Makefile.am
deleted file mode 100644
index 5a6c18f417..0000000000
--- a/calendar/common/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-noinst_LTLIBRARIES = libevolution-calendarprivate.la
-
-ecalendarcommonincludedir = $(privincludedir)/calendar/common
-ecalendarcommoninclude_HEADERS = \
- authentication.h
-
-libevolution_calendarprivate_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -DG_LOG_DOMAIN=\"calendar-gui\" \
- -I$(top_builddir)/shell \
- -I$(top_srcdir)/shell \
- -I$(top_srcdir) \
- -I$(top_srcdir)/calendar \
- -I$(top_srcdir)/widgets \
- $(EVOLUTION_CALENDAR_CFLAGS)
-
-libevolution_calendarprivate_la_SOURCES = \
- authentication.c \
- authentication.h
-
--include $(top_srcdir)/git.mk
diff --git a/calendar/common/authentication.c b/calendar/common/authentication.c
deleted file mode 100644
index 7989107e64..0000000000
--- a/calendar/common/authentication.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Rodrigo Moya <rodrigo@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <glib/gi18n.h>
-#include <libedataserver/e-source.h>
-#include <libedataserverui/e-passwords.h>
-#include "authentication.h"
-#include <libedataserver/e-url.h>
-
-static gboolean
-get_remember_password (ESource *source)
-{
- const gchar *value;
-
- value = e_source_get_property (source, "remember_password");
- if (value && !g_ascii_strcasecmp (value, "true"))
- return TRUE;
-
- return FALSE;
-}
-
-static void
-set_remember_password (ESource *source, gboolean value)
-{
- e_source_set_property (source, "remember_password",
- value ? "true" : "false");
-}
-
-static gchar *
-auth_func_cb (ECal *ecal,
- const gchar *prompt,
- const gchar *key,
- gpointer user_data)
-{
- gchar *password, *auth_domain;
- ESource *source;
- const gchar *component_name;
-
- source = e_cal_get_source (ecal);
- auth_domain = e_source_get_duped_property (source, "auth-domain");
- component_name = auth_domain ? auth_domain : "Calendar";
- password = e_passwords_get_password (component_name, key);
-
- if (!password) {
- gboolean remember;
-
- remember = get_remember_password (source);
-
- password = e_passwords_ask_password (
- _("Enter password"),
- component_name, key, prompt,
- E_PASSWORDS_REMEMBER_FOREVER |
- E_PASSWORDS_SECRET |
- E_PASSWORDS_ONLINE,
- &remember, NULL);
-
- if (password)
- set_remember_password (source, remember);
- }
-
- g_free (auth_domain);
-
- return password;
-}
-
-static gchar *
-build_pass_key (ECal *ecal)
-{
- gchar *euri_str;
- const gchar *uri;
- EUri *euri;
-
- uri = e_cal_get_uri (ecal);
-
- euri = e_uri_new (uri);
- euri_str = e_uri_to_string (euri, FALSE);
-
- e_uri_free (euri);
- return euri_str;
-}
-
-void
-e_auth_cal_forget_password (ECal *ecal)
-{
- ESource *source = NULL;
- const gchar *auth_domain = NULL, *component_name = NULL, *auth_type = NULL;
-
- source = e_cal_get_source (ecal);
- auth_domain = e_source_get_property (source, "auth-domain");
- component_name = auth_domain ? auth_domain : "Calendar";
-
- auth_type = e_source_get_property (source, "auth-type");
- if (auth_type) {
- gchar *key = NULL;
-
- key = build_pass_key (ecal);
- e_passwords_forget_password (component_name, key);
- g_free (key);
- }
-
- e_passwords_forget_password (component_name, e_source_get_uri (source));
-}
-
-ECal *
-e_auth_new_cal_from_default (ECalSourceType type)
-{
- ECal *ecal = NULL;
-
- if (!e_cal_open_default (&ecal, type, auth_func_cb, NULL, NULL))
- return NULL;
-
- return ecal;
-}
-
-ECal *
-e_auth_new_cal_from_source (ESource *source, ECalSourceType type)
-{
- ECal *cal;
-
- cal = e_cal_new (source, type);
- if (cal)
- e_cal_set_auth_func (cal, (ECalAuthFunc) auth_func_cb, NULL);
-
- return cal;
-}
-
-typedef struct {
- ECal *cal;
- GtkWindow *parent;
- GCancellable *cancellable;
- ECalSourceType source_type;
- icaltimezone *default_zone;
-
- /* Authentication Details */
- gchar *auth_component;
-} LoadContext;
-
-static void
-load_cal_source_context_free (LoadContext *context)
-{
- if (context->cal != NULL)
- g_object_unref (context->cal);
-
- if (context->parent != NULL)
- g_object_unref (context->parent);
-
- if (context->cancellable != NULL)
- g_object_unref (context->cancellable);
-
- g_free (context->auth_component);
-
- g_slice_free (LoadContext, context);
-}
-
-static void
-load_cal_source_get_auth_details (ESource *source,
- LoadContext *context)
-{
- const gchar *property;
-
- /* ECal figures out most of the details before invoking the
- * authentication callback, but we still need a component name
- * for e_passwords_ask_password(). */
-
- /* auth_component */
-
- property = e_source_get_property (source, "auth-domain");
-
- if (property == NULL)
- property = "Calendar";
-
- context->auth_component = g_strdup (property);
-}
-
-static gchar *
-load_cal_source_authenticate (ECal *cal,
- const gchar *prompt,
- const gchar *uri,
- gpointer not_used)
-{
- const gchar *auth_component;
- const gchar *title;
- GtkWindow *parent;
- gchar *password;
-
- /* XXX Dig up authentication info embedded in the ECal instance.
- * (See load_cal_source_thread() for an explanation of why.) */
- auth_component = g_object_get_data (G_OBJECT (cal), "auth-component");
- g_return_val_if_fail (auth_component != NULL, NULL);
-
- parent = g_object_get_data (G_OBJECT (cal), "parent-window");
-
- /* Remember the URI so we don't have to reconstruct it if
- * authentication fails and we have to forget the password. */
- g_object_set_data_full (
- G_OBJECT (cal),
- "auth-uri", g_strdup (uri),
- (GDestroyNotify) g_free);
-
- /* XXX Dialog windows should not have titles. */
- title = "";
-
- password = e_passwords_get_password (auth_component, uri);
-
- if (password == NULL) {
- gboolean remember;
- ESource *source = e_cal_get_source (cal);
-
- remember = get_remember_password (source);
-
- password = e_passwords_ask_password (
- title, auth_component, uri,
- prompt, E_PASSWORDS_REMEMBER_FOREVER |
- E_PASSWORDS_SECRET | E_PASSWORDS_ONLINE,
- &remember, parent);
-
- if (password)
- set_remember_password (source, remember);
- }
-
- return password;
-}
-
-static void
-load_cal_source_thread (GSimpleAsyncResult *simple,
- ESource *source,
- GCancellable *cancellable)
-{
- ECal *cal;
- LoadContext *context;
- GError *error = NULL;
-
- context = g_simple_async_result_get_op_res_gpointer (simple);
-
- /* XXX This doesn't take a GError, it just dumps
- * error messages to the terminal... so broken. */
- cal = e_cal_new (source, context->source_type);
- g_return_if_fail (cal != NULL);
-
- if (g_cancellable_set_error_if_cancelled (cancellable, &error)) {
- g_simple_async_result_set_from_error (simple, error);
- g_object_unref (cal);
- g_error_free (error);
- return;
- }
-
- if (!e_cal_set_default_timezone (cal, context->default_zone, &error)) {
- g_simple_async_result_set_from_error (simple, error);
- g_object_unref (cal);
- g_error_free (error);
- return;
- }
-
- /* XXX e_cal_set_auth_func() does not take a GDestroyNotify callback
- * for the 'user_data' argument, which makes the argument rather
- * useless. So instead, we'll embed the information needed by
- * the authentication callback directly into the ECal instance
- * using g_object_set_data_full(). */
- g_object_set_data_full (
- G_OBJECT (cal), "auth-component",
- g_strdup (context->auth_component),
- (GDestroyNotify) g_free);
- if (context->parent != NULL)
- g_object_set_data_full (
- G_OBJECT (cal), "parent-window",
- g_object_ref (context->parent),
- (GDestroyNotify) g_object_unref);
-
- e_cal_set_auth_func (
- cal, (ECalAuthFunc) load_cal_source_authenticate, NULL);
-
-try_again:
- if (!e_cal_open (cal, FALSE, &error))
- goto fail;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, &error)) {
- g_simple_async_result_set_from_error (simple, error);
- g_object_unref (cal);
- g_error_free (error);
- return;
- }
-
- context->cal = cal;
-
- return;
-
-fail:
- g_return_if_fail (error != NULL);
-
- /* If authentication failed, forget the password and reprompt. */
- if (g_error_matches (
- error, E_CALENDAR_ERROR,
- E_CALENDAR_STATUS_AUTHENTICATION_FAILED)) {
- const gchar *auth_uri;
-
- /* Retrieve the URI set by the authentication function. */
- auth_uri = g_object_get_data (G_OBJECT (cal), "auth-uri");
-
- e_passwords_forget_password (
- context->auth_component, auth_uri);
- g_clear_error (&error);
- goto try_again;
-
- /* XXX Might this cause a busy loop? */
- } else if (g_error_matches (
- error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY)) {
- g_clear_error (&error);
- g_usleep (250000);
- goto try_again;
-
- } else {
- g_simple_async_result_set_from_error (simple, error);
- g_object_unref (cal);
- g_error_free (error);
- }
-}
-
-/**
- * e_load_cal_source_async:
- * @source: an #ESource
- * @source_type: the type of #ECal to load
- * @default_zone: default time zone, or %NULL to use UTC
- * @parent: parent window for password dialogs, or %NULL
- * @cancellable: optional #GCancellable object, %NULL to ignore
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to @callback
- *
- * Creates a new #ECal specified by @source and opens it, prompting the
- * user for authentication if necessary.
- *
- * When the operation is finished, @callback will be called. You can
- * then call e_load_cal_source_finish() to obtain the resulting #ECal.
- **/
-void
-e_load_cal_source_async (ESource *source,
- ECalSourceType source_type,
- icaltimezone *default_zone,
- GtkWindow *parent,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- LoadContext *context;
-
- g_return_if_fail (E_IS_SOURCE (source));
-
- /* Source must have a group so we can obtain its URI. */
- g_return_if_fail (e_source_peek_group (source) != NULL);
-
- if (parent != NULL) {
- g_return_if_fail (GTK_IS_WINDOW (parent));
- g_object_ref (parent);
- }
-
- if (cancellable != NULL) {
- g_return_if_fail (G_IS_CANCELLABLE (cancellable));
- g_object_ref (cancellable);
- } else {
- /* always provide cancellable, because the code depends on it */
- cancellable = g_cancellable_new ();
- }
-
- if (default_zone == NULL)
- default_zone = icaltimezone_get_utc_timezone ();
-
- context = g_slice_new0 (LoadContext);
- context->parent = parent;
- context->cancellable = cancellable;
- context->source_type = source_type;
- context->default_zone = default_zone;
-
- /* Extract authentication details from the ESource before
- * spawning the thread, since ESource is not thread-safe. */
- load_cal_source_get_auth_details (source, context);
-
- simple = g_simple_async_result_new (
- G_OBJECT (source), callback,
- user_data, e_load_cal_source_async);
-
- g_simple_async_result_set_op_res_gpointer (
- simple, context, (GDestroyNotify)
- load_cal_source_context_free);
-
- g_simple_async_result_run_in_thread (
- simple, (GSimpleAsyncThreadFunc) load_cal_source_thread,
- G_PRIORITY_DEFAULT, context->cancellable);
-
- g_object_unref (simple);
-}
-
-/**
- * e_load_cal_source_finish:
- * @source: an #ESource
- * @result: a #GAsyncResult
- * @error: return location for a #GError, or %NULL
- *
- * Finishes an asynchronous #ECal open operation started with
- * e_load_cal_source_async(). If an error occurred, or the user
- * declined to authenticate, the function will return %NULL and
- * set @error.
- *
- * Returns: a ready-to-use #ECal, or %NULL on error
- **/
-ECal *
-e_load_cal_source_finish (ESource *source,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- LoadContext *context;
-
- g_return_val_if_fail (E_IS_SOURCE (source), NULL);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
-
- g_return_val_if_fail (
- g_simple_async_result_is_valid (
- result, G_OBJECT (source),
- e_load_cal_source_async), NULL);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
-
- context = g_simple_async_result_get_op_res_gpointer (simple);
- g_return_val_if_fail (context != NULL, NULL);
-
- return g_object_ref (context->cal);
-}
diff --git a/calendar/common/authentication.h b/calendar/common/authentication.h
deleted file mode 100644
index 11b2dc1dfc..0000000000
--- a/calendar/common/authentication.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Rodrigo Moya <rodrigo@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef AUTHENTICATION_H
-#define AUTHENTICATION_H
-
-#include <gtk/gtk.h>
-#include <libedataserver/e-source.h>
-#include <libecal/e-cal.h>
-
-ECal *e_auth_new_cal_from_default (ECalSourceType type);
-ECal *e_auth_new_cal_from_source (ESource *source, ECalSourceType type);
-void e_auth_cal_forget_password (ECal *ecal);
-
-void e_load_cal_source_async (ESource *source,
- ECalSourceType source_type,
- icaltimezone *default_zone,
- GtkWindow *parent,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-ECal * e_load_cal_source_finish (ESource *source,
- GAsyncResult *result,
- GError **error);
-
-#endif /* AUTHENTICATION_H */
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 0a404d429c..09cc0559b0 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -209,7 +209,6 @@ libevolution_calendar_la_LIBADD = \
$(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \
$(top_builddir)/widgets/menus/libmenus.la \
$(top_builddir)/shell/libeshell.la \
- $(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \
$(top_builddir)/calendar/importers/libevolution-calendar-importers.la \
$(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \
diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am
index 5296f95f19..c15181ad9c 100644
--- a/calendar/gui/alarm-notify/Makefile.am
+++ b/calendar/gui/alarm-notify/Makefile.am
@@ -44,7 +44,6 @@ evolution_alarm_notify_SOURCES = \
evolution_alarm_notify_LDADD = \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(CAMEL_LIBS) \
$(EVOLUTION_CALENDAR_LIBS) \
$(CANBERRA_LIBS) \
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 96e8a177aa..28b10ff602 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -26,16 +26,16 @@
#include <string.h>
#include <camel/camel.h>
+#include <libecal/e-cal-client.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserverui/e-passwords.h>
-#include <libecal/e-cal.h>
+#include <libedataserverui/e-client-utils.h>
#include "alarm.h"
#include "alarm-notify.h"
#include "alarm-queue.h"
#include "config-data.h"
-#include "common/authentication.h"
#define APPLICATION_ID "org.gnome.EvolutionAlarmNotify"
@@ -43,8 +43,8 @@ struct _AlarmNotifyPrivate {
/* Mapping from EUri's to LoadedClient structures */
/* FIXME do we need per source type uri hashes? or perhaps we
just need to hash based on source */
- GHashTable *uri_client_hash[E_CAL_SOURCE_TYPE_LAST];
- ESourceList *source_lists[E_CAL_SOURCE_TYPE_LAST];
+ GHashTable *uri_client_hash[E_CAL_CLIENT_SOURCE_TYPE_LAST];
+ ESourceList *source_lists[E_CAL_CLIENT_SOURCE_TYPE_LAST];
ESourceList *selected_calendars;
GMutex *mutex;
};
@@ -97,7 +97,7 @@ alarm_notify_list_changed_cb (ESourceList *source_list,
AlarmNotify *an)
{
GSList *groups, *sources, *p, *q;
- ECalSourceType source_type = E_CAL_SOURCE_TYPE_LAST;
+ ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST;
ProcessRemovalsData prd;
GList *l;
gint i;
@@ -106,13 +106,13 @@ alarm_notify_list_changed_cb (ESourceList *source_list,
source_list, alarm_notify_list_changed_cb, an);
/* Figure out the source type */
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+ for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) {
if (source_list == an->priv->source_lists[i]) {
source_type = i;
break;
}
}
- if (source_type == E_CAL_SOURCE_TYPE_LAST)
+ if (source_type == E_CAL_CLIENT_SOURCE_TYPE_LAST)
return;
/* process the additions */
@@ -156,12 +156,12 @@ alarm_notify_list_changed_cb (ESourceList *source_list,
static void
alarm_notify_load_calendars (AlarmNotify *an,
- ECalSourceType source_type)
+ ECalClientSourceType source_type)
{
ESourceList *source_list;
GSList *groups, *sources, *p, *q;
- if (!e_cal_get_sources (&source_list, source_type, NULL)) {
+ if (!e_cal_client_get_sources (&source_list, source_type, NULL)) {
debug (("Cannont get sources"));
an->priv->source_lists[source_type] = NULL;
@@ -198,7 +198,7 @@ alarm_notify_load_calendars (AlarmNotify *an,
static void
alarm_notify_dequeue_client (gpointer key,
- ECal *client)
+ ECalClient *client)
{
alarm_queue_remove_client (client, TRUE);
}
@@ -211,7 +211,7 @@ alarm_notify_finalize (GObject *object)
priv = ALARM_NOTIFY (object)->priv;
- for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++) {
+ for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) {
g_hash_table_foreach (
priv->uri_client_hash[ii],
(GHFunc) alarm_notify_dequeue_client, NULL);
@@ -279,7 +279,7 @@ alarm_notify_init (AlarmNotify *an)
an->priv->selected_calendars = config_data_get_calendars (
"/apps/evolution/calendar/sources");
- for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++)
+ for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++)
an->priv->uri_client_hash[ii] = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
@@ -287,7 +287,7 @@ alarm_notify_init (AlarmNotify *an)
alarm_queue_init (an);
- for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++)
+ for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++)
alarm_notify_load_calendars (an, ii);
}
@@ -313,22 +313,30 @@ alarm_notify_new (void)
}
static void
-cal_opened_cb (ECal *client, const GError *error, gpointer user_data)
+client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
AlarmNotifyPrivate *priv;
AlarmNotify *an = ALARM_NOTIFY (user_data);
+ EClient *client = NULL;
+ GError *error = NULL;
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
priv = an->priv;
- debug (("%s - Calendar Status %d%s%s%s", e_cal_get_uri (client), error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : ""));
+ debug (("%s - Calendar Status %d%s%s%s", e_client_get_uri (client), error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : ""));
+
+ if (!error) {
+ ECalClient *cal_client = E_CAL_CLIENT (client);
+
+ g_hash_table_insert (priv->uri_client_hash[e_cal_client_get_source_type (cal_client)], g_strdup (e_client_get_uri (client)), cal_client);
+ /* to resolve floating DATE-TIME properly */
+ e_cal_client_set_default_timezone (cal_client, config_data_get_timezone ());
- if (!error)
- alarm_queue_add_client (client);
- else {
- g_hash_table_remove (priv->uri_client_hash[e_cal_get_source_type (client)],
- e_cal_get_uri (client));
- g_signal_handlers_disconnect_matched (G_OBJECT (client), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, an);
+ alarm_queue_add_client (cal_client);
+ } else {
+ g_error_free (error);
}
}
@@ -344,10 +352,9 @@ cal_opened_cb (ECal *client, const GError *error, gpointer user_data)
* that it can be loaded in the future when the alarm daemon starts up.
**/
void
-alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource *source, gboolean load_afterwards)
+alarm_notify_add_calendar (AlarmNotify *an, ECalClientSourceType source_type, ESource *source, gboolean load_afterwards)
{
AlarmNotifyPrivate *priv;
- ECal *client;
EUri *e_uri;
gchar *str_uri;
gchar *pass_key;
@@ -390,16 +397,16 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource
}
}
- client = e_auth_new_cal_from_source (source, source_type);
+ debug (("%s - Calendar Open Async... %p", str_uri, source));
- if (client) {
- debug (("%s - Calendar Open Async... %p", str_uri, client));
- g_hash_table_insert (priv->uri_client_hash[source_type], g_strdup (str_uri), client);
- g_signal_connect (G_OBJECT (client), "cal_opened_ex", G_CALLBACK (cal_opened_cb), an);
- /* to resolve floating DATE-TIME properly */
- e_cal_set_default_timezone (client, config_data_get_timezone (), NULL);
- e_cal_open_async (client, FALSE);
- }
+ e_client_utils_open_new (source,
+ source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? E_CLIENT_SOURCE_TYPE_EVENTS :
+ source_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS ? E_CLIENT_SOURCE_TYPE_TASKS :
+ source_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS ? E_CLIENT_SOURCE_TYPE_MEMOS :
+ E_CLIENT_SOURCE_TYPE_LAST,
+ TRUE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ client_opened_cb, an);
g_free (str_uri);
g_free (pass_key);
@@ -407,17 +414,17 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource
}
void
-alarm_notify_remove_calendar (AlarmNotify *an, ECalSourceType source_type, const gchar *str_uri)
+alarm_notify_remove_calendar (AlarmNotify *an, ECalClientSourceType source_type, const gchar *str_uri)
{
AlarmNotifyPrivate *priv;
- ECal *client;
+ ECalClient *cal_client;
priv = an->priv;
- client = g_hash_table_lookup (priv->uri_client_hash[source_type], str_uri);
- if (client) {
- debug (("Removing Client %p", client));
- alarm_queue_remove_client (client, FALSE);
+ cal_client = g_hash_table_lookup (priv->uri_client_hash[source_type], str_uri);
+ if (cal_client) {
+ debug (("Removing Client %p", cal_client));
+ alarm_queue_remove_client (cal_client, FALSE);
g_hash_table_remove (priv->uri_client_hash[source_type], str_uri);
}
}
diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h
index de7e0398a6..51837d21d5 100644
--- a/calendar/gui/alarm-notify/alarm-notify.h
+++ b/calendar/gui/alarm-notify/alarm-notify.h
@@ -27,7 +27,8 @@
#define ALARM_NOTIFY_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
+#include <libedataserverui/e-client-utils.h>
/* Standard GObject macros */
#define TYPE_ALARM_NOTIFY \
@@ -66,11 +67,11 @@ struct _AlarmNotifyClass {
GType alarm_notify_get_type (void);
AlarmNotify * alarm_notify_new (void);
void alarm_notify_add_calendar (AlarmNotify *an,
- ECalSourceType source_type,
+ ECalClientSourceType source_type,
ESource *source,
gboolean load_afterwards);
void alarm_notify_remove_calendar (AlarmNotify *an,
- ECalSourceType source_type,
+ ECalClientSourceType source_type,
const gchar *str_uri);
ESourceList * alarm_notify_get_selected_calendars
(AlarmNotify *an);
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index e8e5485e45..fde985f8be 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -34,6 +34,7 @@
#include <canberra-gtk.h>
#endif
+#include <libecal/e-cal-client-view.h>
#include <libecal/e-cal-time-util.h>
#include <libecal/e-cal-component.h>
@@ -69,10 +70,10 @@ static AlarmNotify *an;
/* Structure that stores a client we are monitoring */
typedef struct {
/* Monitored client */
- ECal *client;
+ ECalClient *cal_client;
- /* The live query to the calendar */
- ECalView *query;
+ /* The live view to the calendar */
+ ECalClientView *view;
/* Hash table of component UID -> CompQueuedAlarms. If an element is
* present here, then it means its cqa->queued_alarms contains at least
@@ -142,17 +143,17 @@ static void popup_notification (time_t trigger,
gpointer alarm_id,
gboolean use_description);
#endif
-static void query_objects_changed_cb (ECal *client,
- GList *objects,
+static void query_objects_modified_cb (ECalClientView *view,
+ const GSList *objects,
gpointer data);
-static void query_objects_removed_cb (ECal *client,
- GList *objects,
+static void query_objects_removed_cb (ECalClientView *view,
+ const GSList *uids,
gpointer data);
static void update_cqa (CompQueuedAlarms *cqa, ECalComponent *comp);
static void update_qa (ECalComponentAlarms *alarms, QueuedAlarm *qa);
static void tray_list_remove_cqa (CompQueuedAlarms *cqa);
-static void on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data);
+static void on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data);
/* Alarm queue engine */
@@ -299,9 +300,9 @@ midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data)
/* Looks up a client in the client alarms hash table */
static ClientAlarms *
-lookup_client (ECal *client)
+lookup_client (ECalClient *cal_client)
{
- return g_hash_table_lookup (client_alarms_hash, client);
+ return g_hash_table_lookup (client_alarms_hash, cal_client);
}
/* Looks up a queued alarm based on its alarm ID */
@@ -347,10 +348,21 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id,
cqa->queued_alarms = g_slist_delete_link (cqa->queued_alarms, l);
if (remove_alarm) {
- cqa->expecting_update = TRUE;
- e_cal_discard_alarm (cqa->parent_client->client, cqa->alarms->comp,
- qa->instance->auid, NULL);
- cqa->expecting_update = FALSE;
+ GError *error = NULL;
+ ECalComponentId *id = e_cal_component_get_id (cqa->alarms->comp);
+ if (id) {
+ cqa->expecting_update = TRUE;
+ e_cal_client_discard_alarm_sync (cqa->parent_client->cal_client, id->uid, id->rid,
+ qa->instance->auid, NULL, &error);
+ cqa->expecting_update = FALSE;
+
+ if (error) {
+ if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED))
+ g_debug ("%s: Failed to discard alarm: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+ e_cal_component_free_id (id);
+ }
}
g_free (qa);
@@ -425,7 +437,7 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data)
cqa = data;
comp = cqa->alarms->comp;
- config_data_set_last_notification_time (cqa->parent_client->client, trigger);
+ config_data_set_last_notification_time (cqa->parent_client->cal_client, trigger);
debug (("Setting Last notification time to %s", e_ctime (&trigger)));
qa = lookup_queued_alarm (cqa, alarm_id);
@@ -543,6 +555,7 @@ static void
load_alarms (ClientAlarms *ca, time_t start, time_t end)
{
gchar *str_query, *iso_start, *iso_end;
+ GError *error = NULL;
debug (("..."));
@@ -563,31 +576,36 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end)
g_free (iso_end);
/* create the live query */
- if (ca->query) {
+ if (ca->view) {
debug (("Disconnecting old queries"));
g_signal_handlers_disconnect_matched (
- ca->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca);
- g_object_unref (ca->query);
- ca->query = NULL;
+ ca->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ca);
+ g_object_unref (ca->view);
+ ca->view = NULL;
}
- /* FIXME: handle errors */
- if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) {
- g_warning (G_STRLOC ": Could not get query for client");
+ if (!e_cal_client_get_view_sync (ca->cal_client, str_query, &ca->view, NULL, &error)) {
+ g_debug ("%s: Could not get query for client: %s", error ? error->message : "Unknown error", G_STRFUNC);
+ if (error)
+ g_error_free (error);
} else {
debug (("Setting Call backs"));
g_signal_connect (
- ca->query, "objects_added",
- G_CALLBACK (query_objects_changed_cb), ca);
+ ca->view, "objects-added",
+ G_CALLBACK (query_objects_modified_cb), ca);
g_signal_connect (
- ca->query, "objects_modified",
- G_CALLBACK (query_objects_changed_cb), ca);
+ ca->view, "objects-modified",
+ G_CALLBACK (query_objects_modified_cb), ca);
g_signal_connect (
- ca->query, "objects_removed",
+ ca->view, "objects-removed",
G_CALLBACK (query_objects_removed_cb), ca);
- e_cal_view_start (ca->query);
+ e_cal_client_view_start (ca->view, &error);
+ if (error) {
+ g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
g_free (str_query);
@@ -609,7 +627,7 @@ load_alarms_for_today (ClientAlarms *ca)
* half-open; we do not want to display the "last" displayed alarm
* twice, once when it occurs and once when the alarm daemon restarts.
*/
- from = config_data_get_last_notification_time (ca->client) + 1;
+ from = config_data_get_last_notification_time (ca->cal_client) + 1;
if (from <= 0)
from = MAX (from, day_start);
@@ -618,20 +636,6 @@ load_alarms_for_today (ClientAlarms *ca)
load_alarms (ca, from, day_end);
}
-/* Called when a calendar client finished loading; we load its alarms */
-static void
-cal_opened_cb (ECal *client, const GError *error, gpointer data)
-{
- ClientAlarms *ca;
-
- ca = data;
-
- if (error)
- return;
-
- load_alarms_for_today (ca);
-}
-
/* Looks up a component's queued alarm structure in a client alarms structure */
static CompQueuedAlarms *
lookup_comp_queued_alarms (ClientAlarms *ca, const ECalComponentId *id)
@@ -693,35 +697,71 @@ remove_comp (ClientAlarms *ca, ECalComponentId *id)
*/
struct _query_msg {
Message header;
- GList *objects;
+ GSList *objects;
gpointer data;
};
-static GList *
-duplicate_ical (GList *in_list)
+static GSList *
+duplicate_ical (const GSList *in_list)
{
- GList *l, *out_list = NULL;
+ const GSList *l;
+ GSList *out_list = NULL;
for (l = in_list; l; l = l->next) {
- out_list = g_list_prepend (out_list, icalcomponent_new_clone (l->data));
+ out_list = g_slist_prepend (out_list, icalcomponent_new_clone (l->data));
}
- return g_list_reverse (out_list);
+ return g_slist_reverse (out_list);
}
-static GList *
-duplicate_ecal (GList *in_list)
+static GSList *
+duplicate_ecal (const GSList *in_list)
{
- GList *l, *out_list = NULL;
+ const GSList *l;
+ GSList *out_list = NULL;
for (l = in_list; l; l = l->next) {
ECalComponentId *id, *old;
old = l->data;
id = g_new0 (ECalComponentId, 1);
id->uid = g_strdup (old->uid);
id->rid = g_strdup (old->rid);
- out_list = g_list_prepend (out_list, id);
+ out_list = g_slist_prepend (out_list, id);
+ }
+
+ return g_slist_reverse (out_list);
+}
+
+static gboolean
+get_alarms_for_object (ECalClient *cal_client, const ECalComponentId *id, time_t start, time_t end, ECalComponentAlarms **alarms)
+{
+ icalcomponent *icalcomp;
+ ECalComponent *comp;
+ ECalComponentAlarmAction omit[] = {-1};
+
+ g_return_val_if_fail (cal_client != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
+ g_return_val_if_fail (alarms != NULL, FALSE);
+ g_return_val_if_fail (start >= 0 && end >= 0, FALSE);
+ g_return_val_if_fail (start <= end, FALSE);
+
+ if (!e_cal_client_get_object_sync (cal_client, id->uid, id->rid, &icalcomp, NULL, NULL))
+ return FALSE;
+
+ if (!icalcomp)
+ return FALSE;
+
+ comp = e_cal_component_new ();
+ if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
+ icalcomponent_free (icalcomp);
+ g_object_unref (comp);
+ return FALSE;
}
- return g_list_reverse (out_list);
+ *alarms = e_cal_util_generate_alarms_for_comp (comp, start, end, omit, e_cal_client_resolve_tzid_cb,
+ cal_client, e_cal_client_get_default_timezone (cal_client));
+
+ g_object_unref (comp);
+
+ return TRUE;
}
static void
@@ -733,13 +773,13 @@ query_objects_changed_async (struct _query_msg *msg)
gboolean found;
icaltimezone *zone;
CompQueuedAlarms *cqa;
- GList *l;
- GList *objects;
+ GSList *l;
+ GSList *objects;
ca = msg->data;
objects = msg->objects;
- from = config_data_get_last_notification_time (ca->client);
+ from = config_data_get_last_notification_time (ca->cal_client);
if (from == -1)
from = time (NULL);
else
@@ -757,10 +797,10 @@ query_objects_changed_async (struct _query_msg *msg)
e_cal_component_set_icalcomponent (comp, l->data);
id = e_cal_component_get_id (comp);
- found = e_cal_get_alarms_for_object (ca->client, id, from, day_end, &alarms);
+ found = get_alarms_for_object (ca->cal_client, id, from, day_end, &alarms);
if (!found) {
- debug (("No Alarm found for client %p", ca->client));
+ debug (("No Alarm found for client %p", ca->cal_client));
tray_list_remove_cqa (lookup_comp_queued_alarms (ca, id));
remove_comp (ca, id);
g_hash_table_remove (ca->uid_alarms_hash, id);
@@ -826,13 +866,13 @@ query_objects_changed_async (struct _query_msg *msg)
g_object_unref (comp);
comp = NULL;
}
- g_list_free (objects);
+ g_slist_free (objects);
g_slice_free (struct _query_msg, msg);
}
static void
-query_objects_changed_cb (ECal *client, GList *objects, gpointer data)
+query_objects_modified_cb (ECalClientView *view, const GSList *objects, gpointer data)
{
struct _query_msg *msg;
@@ -851,13 +891,13 @@ static void
query_objects_removed_async (struct _query_msg *msg)
{
ClientAlarms *ca;
- GList *l;
- GList *objects;
+ GSList *l;
+ GSList *objects;
ca = msg->data;
objects = msg->objects;
- debug (("Removing %d objects", g_list_length (objects)));
+ debug (("Removing %d objects", g_slist_length (objects)));
for (l = objects; l != NULL; l = l->next) {
/* If the alarm is already triggered remove it. */
@@ -867,19 +907,19 @@ query_objects_removed_async (struct _query_msg *msg)
e_cal_component_free_id (l->data);
}
- g_list_free (objects);
+ g_slist_free (objects);
g_slice_free (struct _query_msg, msg);
}
static void
-query_objects_removed_cb (ECal *client, GList *objects, gpointer data)
+query_objects_removed_cb (ECalClientView *view, const GSList *uids, gpointer data)
{
struct _query_msg *msg;
msg = g_slice_new0 (struct _query_msg);
msg->header.func = (MessageFunc) query_objects_removed_async;
- msg->objects = duplicate_ecal (objects);
+ msg->objects = duplicate_ecal (uids);
msg->data = data;
message_push ((Message *) msg);
@@ -919,7 +959,7 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins)
/* Launches a component editor for a component */
static void
-edit_component (ECal *client, ECalComponent *comp)
+edit_component (ECalClient *cal_client, ECalComponent *comp)
{
ESource *source;
gchar *command_line;
@@ -931,19 +971,19 @@ edit_component (ECal *client, ECalComponent *comp)
/* XXX Don't we have a function to construct these URIs?
* How are other apps expected to know this stuff? */
- source = e_cal_get_source (client);
+ source = e_client_get_source (E_CLIENT (cal_client));
source_uid = e_source_peek_uid (source);
e_cal_component_get_uid (comp, &comp_uid);
- switch (e_cal_get_source_type (client)) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ switch (e_cal_client_get_source_type (cal_client)) {
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
scheme = "calendar:";
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
scheme = "task:";
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
scheme = "memo:";
break;
default:
@@ -973,8 +1013,8 @@ typedef struct {
CompQueuedAlarms *cqa;
gpointer alarm_id;
ECalComponent *comp;
- ECal *client;
- ECalView *query;
+ ECalClient *cal_client;
+ ECalClientView *view;
GdkPixbuf *image;
GtkTreeIter iter;
} TrayIconData;
@@ -999,13 +1039,13 @@ free_tray_icon_data (TrayIconData *tray_data)
tray_data->location = NULL;
}
- g_object_unref (tray_data->client);
- tray_data->client = NULL;
+ g_object_unref (tray_data->cal_client);
+ tray_data->cal_client = NULL;
- g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC,
+ g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC,
0, 0, NULL, on_dialog_objs_removed_cb, NULL);
- g_object_unref (tray_data->query);
- tray_data->query = NULL;
+ g_object_unref (tray_data->view);
+ tray_data->view = NULL;
g_object_unref (tray_data->comp);
tray_data->comp = NULL;
@@ -1020,44 +1060,47 @@ free_tray_icon_data (TrayIconData *tray_data)
static void
on_dialog_objs_removed_async (struct _query_msg *msg)
{
- const gchar *our_uid;
- GList *l;
TrayIconData *tray_data;
- GList *objects;
+ GSList *l, *objects;
+ ECalComponentId *our_id;
debug (("..."));
tray_data = msg->data;
objects = msg->objects;
- e_cal_component_get_uid (tray_data->comp, &our_uid);
- g_return_if_fail (our_uid && *our_uid);
+ our_id = e_cal_component_get_id (tray_data->comp);
+ g_return_if_fail (our_id);
for (l = objects; l != NULL; l = l->next) {
- const gchar *uid = l->data;
+ ECalComponentId *id = l->data;
- if (!uid)
+ if (!id)
continue;
- if (!strcmp (uid, our_uid)) {
+ if (g_strcmp0 (id->uid, our_id->uid) == 0&& g_strcmp0 (id->rid, our_id->rid) == 0) {
tray_data->cqa = NULL;
tray_data->alarm_id = NULL;
tray_icons_list = g_list_remove (tray_icons_list, tray_data);
tray_data = NULL;
}
+
+ e_cal_component_free_id (id);
}
+ e_cal_component_free_id (our_id);
+ g_slist_free (objects);
g_slice_free (struct _query_msg, msg);
}
static void
-on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data)
+on_dialog_objs_removed_cb (ECalClientView *view, const GSList *uids, gpointer data)
{
struct _query_msg *msg;
msg = g_slice_new0 (struct _query_msg);
msg->header.func = (MessageFunc) on_dialog_objs_removed_async;
- msg->objects = objects;
+ msg->objects = duplicate_ecal (uids);
msg->data = data;
message_push ((Message *) msg);
@@ -1219,7 +1262,7 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data)
debug (("Received from dialog"));
- g_signal_handlers_disconnect_matched (tray_data->query, G_SIGNAL_MATCH_FUNC,
+ g_signal_handlers_disconnect_matched (tray_data->view, G_SIGNAL_MATCH_FUNC,
0, 0, NULL, on_dialog_objs_removed_cb, NULL);
switch (result) {
@@ -1254,7 +1297,7 @@ notify_dialog_cb (AlarmNotifyResult result, gint snooze_mins, gpointer data)
break;
case ALARM_NOTIFY_EDIT:
- edit_component (tray_data->client, tray_data->comp);
+ edit_component (tray_data->cal_client, tray_data->comp);
break;
@@ -1530,11 +1573,11 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
tray_data->cqa = cqa;
tray_data->alarm_id = alarm_id;
tray_data->comp = g_object_ref (e_cal_component_clone (comp));
- tray_data->client = cqa->parent_client->client;
- tray_data->query = g_object_ref (cqa->parent_client->query);
+ tray_data->cal_client = cqa->parent_client->cal_client;
+ tray_data->view = g_object_ref (cqa->parent_client->view);
tray_data->blink_state = FALSE;
tray_data->snooze_set = FALSE;
- g_object_ref (tray_data->client);
+ g_object_ref (tray_data->cal_client);
/* Task to add tray_data to the global tray_icon_list */
tray_list_add_new (tray_data);
@@ -1558,7 +1601,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
g_free (time_str);
g_free (str);
- g_signal_connect (G_OBJECT (tray_data->query), "objects_removed",
+ g_signal_connect (G_OBJECT (tray_data->view), "objects_removed",
G_CALLBACK (on_dialog_objs_removed_cb), tray_data);
/* FIXME: We should remove this check */
@@ -1731,8 +1774,7 @@ mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id)
debug (("..."));
- if (!e_cal_get_static_capability (cqa->parent_client->client,
- CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS))
+ if (!e_client_check_capability (E_CLIENT (cqa->parent_client->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS))
return;
dialog = gtk_dialog_new_with_buttons (_("Warning"),
@@ -1932,20 +1974,20 @@ free_client_alarms_cb (gpointer key, gpointer value, gpointer user_data)
if (ca) {
remove_client_alarms (ca);
- if (ca->client) {
+ if (ca->cal_client) {
debug (("Disconnecting Client"));
- g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_disconnect_matched (ca->cal_client, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, ca);
- g_object_unref (ca->client);
+ g_object_unref (ca->cal_client);
}
- if (ca->query) {
+ if (ca->view) {
debug (("Disconnecting Query"));
- g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_disconnect_matched (ca->view, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, ca);
- g_object_unref (ca->query);
+ g_object_unref (ca->view);
}
g_hash_table_destroy (ca->uid_alarms_hash);
@@ -2016,52 +2058,46 @@ hash_ids (gpointer a)
struct _alarm_client_msg {
Message header;
- ECal *client;
+ ECalClient *cal_client;
};
static void
alarm_queue_add_async (struct _alarm_client_msg *msg)
{
ClientAlarms *ca;
- ECal *client = msg->client;
+ ECalClient *cal_client = msg->cal_client;
g_return_if_fail (alarm_queue_inited);
- g_return_if_fail (client != NULL);
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (cal_client != NULL);
+ g_return_if_fail (E_IS_CAL_CLIENT (cal_client));
- ca = lookup_client (client);
+ ca = lookup_client (cal_client);
if (ca) {
/* We already have it. Unref the passed one*/
- g_object_unref (client);
+ g_object_unref (cal_client);
return;
}
- debug (("client=%p", client));
+ debug (("client=%p", cal_client));
ca = g_new (ClientAlarms, 1);
- ca->client = client;
- ca->query = NULL;
+ ca->cal_client = cal_client;
+ ca->view = NULL;
- g_hash_table_insert (client_alarms_hash, client, ca);
+ g_hash_table_insert (client_alarms_hash, cal_client, ca);
ca->uid_alarms_hash = g_hash_table_new (
(GHashFunc) hash_ids, (GEqualFunc) compare_ids);
- if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) {
- load_alarms_for_today (ca);
- } else {
- g_signal_connect (client, "cal_opened_ex",
- G_CALLBACK (cal_opened_cb),
- ca);
- }
+ load_alarms_for_today (ca);
g_slice_free (struct _alarm_client_msg, msg);
}
/**
* alarm_queue_add_client:
- * @client: A calendar client.
+ * @cal_client: A calendar client.
*
* Adds a calendar client to the alarm queueing system. Alarm trigger
* notifications will be presented at the appropriate times. The client should
@@ -2074,13 +2110,13 @@ alarm_queue_add_async (struct _alarm_client_msg *msg)
* queueing system when it is no longer wanted.
**/
void
-alarm_queue_add_client (ECal *client)
+alarm_queue_add_client (ECalClient *cal_client)
{
struct _alarm_client_msg *msg;
msg = g_slice_new0 (struct _alarm_client_msg);
msg->header.func = (MessageFunc) alarm_queue_add_async;
- msg->client = g_object_ref (client);
+ msg->cal_client = g_object_ref (cal_client);
message_push ((Message *) msg);
}
@@ -2137,35 +2173,35 @@ static void
alarm_queue_remove_async (struct _alarm_client_msg *msg)
{
ClientAlarms *ca;
- ECal *client = msg->client;
+ ECalClient *cal_client = msg->cal_client;
g_return_if_fail (alarm_queue_inited);
- g_return_if_fail (client != NULL);
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (cal_client != NULL);
+ g_return_if_fail (E_IS_CAL_CLIENT (cal_client));
- ca = lookup_client (client);
+ ca = lookup_client (cal_client);
g_return_if_fail (ca != NULL);
debug (("..."));
remove_client_alarms (ca);
/* Clean up */
- if (ca->client) {
+ if (ca->cal_client) {
debug (("Disconnecting Client"));
- g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_disconnect_matched (ca->cal_client, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, ca);
- g_object_unref (ca->client);
- ca->client = NULL;
+ g_object_unref (ca->cal_client);
+ ca->cal_client = NULL;
}
- if (ca->query) {
+ if (ca->view) {
debug (("Disconnecting Query"));
- g_signal_handlers_disconnect_matched (ca->query, G_SIGNAL_MATCH_DATA,
+ g_signal_handlers_disconnect_matched (ca->view, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, ca);
- g_object_unref (ca->query);
- ca->query = NULL;
+ g_object_unref (ca->view);
+ ca->view = NULL;
}
g_hash_table_destroy (ca->uid_alarms_hash);
@@ -2173,7 +2209,7 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg)
g_free (ca);
- g_hash_table_remove (client_alarms_hash, client);
+ g_hash_table_remove (client_alarms_hash, cal_client);
g_slice_free (struct _alarm_client_msg, msg);
}
@@ -2181,18 +2217,18 @@ alarm_queue_remove_async (struct _alarm_client_msg *msg)
/** alarm_queue_remove_client
*
* asynchronously remove client from alarm queue.
- * @client: Client to remove.
+ * @cal_client: Client to remove.
* @immediately: Indicates whether use thread or do it right now.
*/
void
-alarm_queue_remove_client (ECal *client, gboolean immediately)
+alarm_queue_remove_client (ECalClient *cal_client, gboolean immediately)
{
struct _alarm_client_msg *msg;
msg = g_slice_new0 (struct _alarm_client_msg);
msg->header.func = (MessageFunc) alarm_queue_remove_async;
- msg->client = client;
+ msg->cal_client = cal_client;
if (immediately) {
alarm_queue_remove_async (msg);
@@ -2220,7 +2256,7 @@ update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp)
debug (("Generating alarms between %s and %s", e_ctime (&from), e_ctime (&to)));
alarms = e_cal_util_generate_alarms_for_comp (newcomp, from, to, omit,
- e_cal_resolve_tzid_cb, cqa->parent_client->client, zone);
+ e_cal_client_resolve_tzid_cb, cqa->parent_client->cal_client, zone);
/* Update auids in Queued Alarms*/
for (qa_list = cqa->queued_alarms; qa_list; qa_list = qa_list->next) {
diff --git a/calendar/gui/alarm-notify/alarm-queue.h b/calendar/gui/alarm-notify/alarm-queue.h
index c594e12a6b..e43027bd60 100644
--- a/calendar/gui/alarm-notify/alarm-queue.h
+++ b/calendar/gui/alarm-notify/alarm-queue.h
@@ -26,12 +26,12 @@
#ifndef ALARM_QUEUE_H
#define ALARM_QUEUE_H
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
void alarm_queue_init (gpointer);
void alarm_queue_done (void);
-void alarm_queue_add_client (ECal *client);
-void alarm_queue_remove_client (ECal *client, gboolean immediately);
+void alarm_queue_add_client (ECalClient *cal_client);
+void alarm_queue_remove_client (ECalClient *cal_client, gboolean immediately);
#endif
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
index 41207d48fb..b5e6faa923 100644
--- a/calendar/gui/alarm-notify/config-data.c
+++ b/calendar/gui/alarm-notify/config-data.c
@@ -259,7 +259,7 @@ config_data_get_notify_with_tray (void)
* triggered while it was not running.
**/
void
-config_data_set_last_notification_time (ECal *cal, time_t t)
+config_data_set_last_notification_time (ECalClient *cal, time_t t)
{
GConfClient *client;
time_t current_t, now = time (NULL);
@@ -267,7 +267,7 @@ config_data_set_last_notification_time (ECal *cal, time_t t)
g_return_if_fail (t != -1);
if (cal) {
- ESource *source = e_cal_get_source (cal);
+ ESource *source = e_client_get_source (E_CLIENT (cal));
if (source) {
GTimeVal tmval = {0};
gchar *as_text;
@@ -301,13 +301,13 @@ config_data_set_last_notification_time (ECal *cal, time_t t)
* Return value: The last saved value, or -1 if no value had been saved before.
**/
time_t
-config_data_get_last_notification_time (ECal *cal)
+config_data_get_last_notification_time (ECalClient *cal)
{
GConfValue *value;
GConfClient *client;
if (cal) {
- ESource *source = e_cal_get_source (cal);
+ ESource *source = e_client_get_source (E_CLIENT (cal));
if (source) {
const gchar *last_notified;
diff --git a/calendar/gui/alarm-notify/config-data.h b/calendar/gui/alarm-notify/config-data.h
index 85b2593a8b..1023609d6a 100644
--- a/calendar/gui/alarm-notify/config-data.h
+++ b/calendar/gui/alarm-notify/config-data.h
@@ -27,7 +27,7 @@
#define CONFIG_DATA_H
#include <libical/ical.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <gconf/gconf-client.h>
#include <libedataserver/e-source-list.h>
@@ -37,10 +37,10 @@ gboolean config_data_get_24_hour_format (void);
gboolean config_data_get_notify_with_tray
(void);
void config_data_set_last_notification_time
- (ECal *cal,
+ (ECalClient *cal,
time_t t);
time_t config_data_get_last_notification_time
- (ECal *cal);
+ (ECalClient *cal);
void config_data_save_blessed_program
(const gchar *program);
gboolean config_data_is_blessed_program (const gchar *program);
diff --git a/calendar/gui/cal-editor-utils.c b/calendar/gui/cal-editor-utils.c
index c49e648883..4ddc3899b9 100644
--- a/calendar/gui/cal-editor-utils.c
+++ b/calendar/gui/cal-editor-utils.c
@@ -32,7 +32,7 @@
/**
* open_component_editor:
- * @client: Already opened #ECal, where to store the component
+ * @client: Already opened #ECalClient, where to store the component
* @comp: #ECalComponent component to be stored
* @is_new: Whether the @comp is a new component or an existing
* @error: #GError for possible error reporting
@@ -45,7 +45,7 @@
**/
void
open_component_editor (EShell *shell,
- ECal *client,
+ ECalClient *client,
ECalComponent *comp,
gboolean is_new,
GError **error)
@@ -55,7 +55,7 @@ open_component_editor (EShell *shell,
CompEditor *editor = NULL;
g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
id = e_cal_component_get_id (comp);
@@ -99,10 +99,7 @@ open_component_editor (EShell *shell,
break;
default:
if (error)
- *error = g_error_new (
- E_CALENDAR_ERROR,
- E_CALENDAR_STATUS_INVALID_OBJECT,
- "%s", _("Invalid object"));
+ *error = e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL);
break;
}
diff --git a/calendar/gui/cal-editor-utils.h b/calendar/gui/cal-editor-utils.h
index 00f24a5b33..26b2104ea4 100644
--- a/calendar/gui/cal-editor-utils.h
+++ b/calendar/gui/cal-editor-utils.h
@@ -20,14 +20,14 @@
#ifndef CAL_EDITOR_UTILS_H
#define CAL_EDITOR_UTILS_H
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
#include <shell/e-shell.h>
G_BEGIN_DECLS
void open_component_editor (EShell *shell,
- ECal *client,
+ ECalClient *client,
ECalComponent *comp,
gboolean is_new,
GError **error);
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index f905af4d40..61e92efae4 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -29,7 +29,7 @@
#define _CALENDAR_CONFIG_H_
#include <gdk/gdk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <gconf/gconf-client.h>
#include <e-util/e-util-enums.h>
diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c
index fbf9e7dc82..a6095d0bcc 100644
--- a/calendar/gui/comp-util.c
+++ b/calendar/gui/comp-util.c
@@ -32,8 +32,8 @@
#include "comp-util.h"
#include "dialogs/delete-comp.h"
#include <libecal/e-cal-component.h>
+#include <libedataserverui/e-client-utils.h>
#include "e-util/e-categories-config.h"
-#include "common/authentication.h"
#include "gnome-cal.h"
#include "shell/e-shell-window.h"
@@ -90,7 +90,7 @@ e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2)
/**
* cal_comp_util_compare_event_timezones:
* @comp: A calendar component object.
- * @client: A #ECal.
+ * @client: A #ECalClient.
*
* Checks if the component uses the given timezone for both the start and
* the end time, or if the UTC offsets of the start and end times are the same
@@ -101,7 +101,7 @@ e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2)
**/
gboolean
cal_comp_util_compare_event_timezones (ECalComponent *comp,
- ECal *client,
+ ECalClient *client,
icaltimezone *zone)
{
ECalComponentDateTime start_datetime, end_datetime;
@@ -151,8 +151,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp,
/* If the TZIDs differ, we have to compare the UTC offsets
of the start and end times, using their own timezones and
the given timezone. */
- if (!e_cal_get_timezone (client, start_datetime.tzid,
- &start_zone, NULL))
+ if (!e_cal_client_get_timezone_sync (client, start_datetime.tzid,
+ &start_zone, NULL, NULL))
goto out;
if (start_datetime.value) {
@@ -166,8 +166,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp,
goto out;
}
- if (!e_cal_get_timezone (client, end_datetime.tzid,
- &end_zone, NULL))
+ if (!e_cal_client_get_timezone_sync (client, end_datetime.tzid,
+ &end_zone, NULL, NULL))
goto out;
if (end_datetime.value) {
@@ -211,7 +211,7 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp,
* user cancelled the deletion.
**/
gboolean
-cal_comp_is_on_server (ECalComponent *comp, ECal *client)
+cal_comp_is_on_server (ECalComponent *comp, ECalClient *client)
{
const gchar *uid;
gchar *rid = NULL;
@@ -221,7 +221,7 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client)
g_return_val_if_fail (comp != NULL, FALSE);
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE);
g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (E_IS_CAL (client), FALSE);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
/* See if the component is on the server. If it is not, then it likely
* means that the appointment is new, only in the day view, and we
@@ -234,19 +234,18 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client)
/* TODO We should not be checking for this here. But since
* e_cal_util_construct_instance does not create the instances
* of all day events, so we default to old behaviour. */
- if (e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+ if (e_cal_client_check_recurrences_no_master (client)) {
rid = e_cal_component_get_recurid_as_string (comp);
}
- if (e_cal_get_object (client, uid, rid, &icalcomp, &error)) {
+ if (e_cal_client_get_object_sync (client, uid, rid, &icalcomp, NULL, &error)) {
icalcomponent_free (icalcomp);
g_free (rid);
return TRUE;
}
- if (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND)
+ if (!g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND))
g_warning (G_STRLOC ": %s", error->message);
g_clear_error (&error);
@@ -261,7 +260,7 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client)
* icalcomponent, not the ECalComponent.
**/
gboolean
-is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client)
+is_icalcomp_on_the_server (icalcomponent *icalcomp, ECalClient *client)
{
gboolean on_server;
ECalComponent *comp;
@@ -288,7 +287,7 @@ is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client)
* Return value: A newly-created calendar component.
**/
ECalComponent *
-cal_comp_event_new_with_defaults (ECal *client,
+cal_comp_event_new_with_defaults (ECalClient *client,
gboolean all_day,
gboolean use_default_reminder,
gint default_reminder_interval,
@@ -300,7 +299,7 @@ cal_comp_event_new_with_defaults (ECal *client,
icalproperty *icalprop;
ECalComponentAlarmTrigger trigger;
- if (!e_cal_get_default_object (client, &icalcomp, NULL))
+ if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL))
icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
comp = e_cal_component_new ();
@@ -358,7 +357,7 @@ cal_comp_event_new_with_defaults (ECal *client,
}
ECalComponent *
-cal_comp_event_new_with_current_time (ECal *client,
+cal_comp_event_new_with_current_time (ECalClient *client,
gboolean all_day,
icaltimezone *zone,
gboolean use_default_reminder,
@@ -398,12 +397,12 @@ cal_comp_event_new_with_current_time (ECal *client,
}
ECalComponent *
-cal_comp_task_new_with_defaults (ECal *client)
+cal_comp_task_new_with_defaults (ECalClient *client)
{
ECalComponent *comp;
icalcomponent *icalcomp;
- if (!e_cal_get_default_object (client, &icalcomp, NULL))
+ if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL))
icalcomp = icalcomponent_new (ICAL_VTODO_COMPONENT);
comp = e_cal_component_new ();
@@ -417,12 +416,12 @@ cal_comp_task_new_with_defaults (ECal *client)
}
ECalComponent *
-cal_comp_memo_new_with_defaults (ECal *client)
+cal_comp_memo_new_with_defaults (ECalClient *client)
{
ECalComponent *comp;
icalcomponent *icalcomp;
- if (!e_cal_get_default_object (client, &icalcomp, NULL))
+ if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL))
icalcomp = icalcomponent_new (ICAL_VJOURNAL_COMPONENT);
comp = e_cal_component_new ();
@@ -613,7 +612,7 @@ cal_comp_selection_get_string_list (GtkSelectionData *selection_data)
}
static void
-datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid)
+datetime_to_zone (ECalClient *client, ECalComponentDateTime *date, const gchar *tzid)
{
icaltimezone *from, *to;
@@ -625,16 +624,21 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid)
from = icaltimezone_get_builtin_timezone_from_tzid (date->tzid);
if (!from) {
- if (!e_cal_get_timezone (client, date->tzid, &from, NULL))
+ GError *error = NULL;
+
+ if (!e_cal_client_get_timezone_sync (client, date->tzid, &from, NULL, &error))
g_warning (
- "%s: Could not get timezone from server: %s",
- G_STRFUNC, date->tzid ? date->tzid : "");
+ "%s: Could not get timezone '%s' from server: %s",
+ G_STRFUNC, date->tzid ? date->tzid : "", error ? error->message : "Unknown error");
+
+ if (error)
+ g_error_free (error);
}
to = icaltimezone_get_builtin_timezone_from_tzid (tzid);
if (!to) {
/* do not check failure here, maybe the zone is not available there */
- e_cal_get_timezone (client, tzid, &to, NULL);
+ e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL);
}
icaltimezone_convert_time (date->value, from, to);
@@ -643,14 +647,14 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid)
/**
* cal_comp_set_dtstart_with_oldzone:
- * @client: ECal structure, to retrieve timezone from, when required.
+ * @client: ECalClient structure, to retrieve timezone from, when required.
* @comp: Component, where make the change.
* @pdate: Value, to change to.
*
* Changes 'dtstart' of the component, but converts time to the old timezone.
**/
void
-cal_comp_set_dtstart_with_oldzone (ECal *client,
+cal_comp_set_dtstart_with_oldzone (ECalClient *client,
ECalComponent *comp,
const ECalComponentDateTime *pdate)
{
@@ -671,14 +675,14 @@ cal_comp_set_dtstart_with_oldzone (ECal *client,
/**
* cal_comp_set_dtend_with_oldzone:
- * @client: ECal structure, to retrieve timezone from, when required.
+ * @client: ECalClient structure, to retrieve timezone from, when required.
* @comp: Component, where make the change.
* @pdate: Value, to change to.
*
* Changes 'dtend' of the component, but converts time to the old timezone.
**/
void
-cal_comp_set_dtend_with_oldzone (ECal *client,
+cal_comp_set_dtend_with_oldzone (ECalClient *client,
ECalComponent *comp,
const ECalComponentDateTime *pdate)
{
@@ -699,18 +703,21 @@ cal_comp_set_dtend_with_oldzone (ECal *client,
void
comp_util_sanitize_recurrence_master (ECalComponent *comp,
- ECal *client)
+ ECalClient *client)
{
ECalComponent *master = NULL;
icalcomponent *icalcomp = NULL;
ECalComponentRange rid;
ECalComponentDateTime sdt;
const gchar *uid;
+ GError *error = NULL;
/* Get the master component */
e_cal_component_get_uid (comp, &uid);
- if (!e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) {
- g_warning ("Unable to get the master component \n");
+ if (!e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, &error)) {
+ g_warning ("Unable to get the master component: %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return;
}
diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h
index c99e1d0c3f..1f69ddb107 100644
--- a/calendar/gui/comp-util.h
+++ b/calendar/gui/comp-util.h
@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
#include <libecal/e-cal-component.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <e-util/e-util-enums.h>
struct _EShell;
@@ -38,41 +38,41 @@ void cal_comp_util_add_exdate (ECalComponent *comp, time_t t, icaltimezone *zone
and DTEND, or if the UTC offsets of the start and end times are the same
as in the given zone. */
gboolean cal_comp_util_compare_event_timezones (ECalComponent *comp,
- ECal *client,
+ ECalClient *client,
icaltimezone *zone);
/* Returns the number of icons owned by the ECalComponent */
gint cal_comp_util_get_n_icons (ECalComponent *comp, GSList **pixbufs);
gboolean cal_comp_is_on_server (ECalComponent *comp,
- ECal *client);
-gboolean is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client);
+ ECalClient *client);
+gboolean is_icalcomp_on_the_server (icalcomponent *icalcomp, ECalClient *client);
ECalComponent * cal_comp_event_new_with_defaults
- (ECal *client,
+ (ECalClient *client,
gboolean all_day,
gboolean use_default_reminder,
gint default_reminder_interval,
EDurationType default_reminder_units);
ECalComponent * cal_comp_event_new_with_current_time
- (ECal *client,
+ (ECalClient *client,
gboolean all_day,
icaltimezone *zone,
gboolean use_default_reminder,
gint default_reminder_interval,
EDurationType default_reminder_units);
-ECalComponent *cal_comp_task_new_with_defaults (ECal *client);
-ECalComponent *cal_comp_memo_new_with_defaults (ECal *client);
+ECalComponent *cal_comp_task_new_with_defaults (ECalClient *client);
+ECalComponent *cal_comp_memo_new_with_defaults (ECalClient *client);
void cal_comp_update_time_by_active_window (ECalComponent *comp, struct _EShell *shell);
void cal_comp_selection_set_string_list (GtkSelectionData *data, GSList *str_list);
GSList *cal_comp_selection_get_string_list (GtkSelectionData *data);
-void cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate);
-void cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate);
+void cal_comp_set_dtstart_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate);
+void cal_comp_set_dtend_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate);
-void comp_util_sanitize_recurrence_master (ECalComponent *comp, ECal *client);
+void comp_util_sanitize_recurrence_master (ECalComponent *comp, ECalClient *client);
gchar *icalcomp_suggest_filename (icalcomponent *icalcomp, const gchar *default_name);
diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c
index 6b234f6cce..564c4dd1f4 100644
--- a/calendar/gui/dialogs/alarm-dialog.c
+++ b/calendar/gui/dialogs/alarm-dialog.c
@@ -54,7 +54,7 @@ typedef struct {
ECalComponentAlarm *alarm;
/* The client */
- ECal *ecal;
+ ECalClient *cal_client;
/* Toplevel */
GtkWidget *toplevel;
@@ -209,16 +209,16 @@ alarm_to_dialog (Dialog *dialog)
for (i = 0; valid && action_map[i] != -1; i++) {
gtk_list_store_set (
GTK_LIST_STORE (model), &iter,
- 1, !e_cal_get_static_capability (dialog->ecal, action_map_cap[i]),
+ 1, !e_client_check_capability (E_CLIENT (dialog->cal_client), action_map_cap[i]),
-1);
valid = gtk_tree_model_iter_next (model, &iter);
}
/* Set a default address if possible */
- if (!e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)
- && !e_cal_component_alarm_has_attendees (dialog->alarm)
- && e_cal_get_alarm_email_address (dialog->ecal, &email, NULL)) {
+ if (!e_client_check_capability (E_CLIENT (dialog->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)
+ && !e_cal_component_alarm_has_attendees (dialog->alarm)
+ && e_client_get_backend_property_sync (E_CLIENT (dialog->cal_client), CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS, &email, NULL, NULL)) {
ECalComponentAttendee *a;
GSList attendee_list;
@@ -235,7 +235,7 @@ alarm_to_dialog (Dialog *dialog)
}
/* If we can repeat */
- repeat = !e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT);
+ repeat = !e_client_check_capability (E_CLIENT (dialog->cal_client), CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT);
gtk_widget_set_sensitive (dialog->repeat_toggle, repeat);
/* if we are editing a exiting alarm */
@@ -880,27 +880,6 @@ get_widgets (Dialog *dialog)
&& dialog->palarm_args);
}
-#if 0
-/* Callback used when the alarm options button is clicked */
-static void
-show_options (Dialog *dialog)
-{
- gboolean repeat;
- gchar *email;
-
- e_cal_component_alarm_set_action (dialog->alarm,
- e_dialog_combo_box_get (dialog->action_combo, action_map));
-
- repeat = !e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT);
-
- if (e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)
- || e_cal_get_alarm_email_address (dialog->ecal, &email, NULL)) {
- if (!alarm_options_dialog_run (dialog->toplevel, dialog->alarm, email, repeat))
- g_message (G_STRLOC ": not create the alarm options dialog");
- }
-}
-#endif
-
static void
addressbook_clicked_cb (GtkWidget *widget, Dialog *dialog)
{
@@ -1202,7 +1181,7 @@ init_widgets (Dialog *dialog)
}
gboolean
-alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm)
+alarm_dialog_run (GtkWidget *parent, ECalClient *cal_client, ECalComponentAlarm *alarm)
{
Dialog dialog;
GtkWidget *container;
@@ -1211,7 +1190,7 @@ alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm)
g_return_val_if_fail (alarm != NULL, FALSE);
dialog.alarm = alarm;
- dialog.ecal = ecal;
+ dialog.cal_client = cal_client;
dialog.builder = gtk_builder_new ();
e_load_ui_builder_definition (dialog.builder, "alarm-dialog.ui");
diff --git a/calendar/gui/dialogs/alarm-dialog.h b/calendar/gui/dialogs/alarm-dialog.h
index b5560f9ff4..d99d47f15f 100644
--- a/calendar/gui/dialogs/alarm-dialog.h
+++ b/calendar/gui/dialogs/alarm-dialog.h
@@ -30,12 +30,12 @@
#ifndef ALARM_DIALOG_H
#define ALARM_DIALOG_H
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
G_BEGIN_DECLS
-gboolean alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm);
+gboolean alarm_dialog_run (GtkWidget *parent, ECalClient *cal_client, ECalComponentAlarm *alarm);
G_END_DECLS
diff --git a/calendar/gui/dialogs/alarm-list-dialog.c b/calendar/gui/dialogs/alarm-list-dialog.c
index 1990e076df..3e854da751 100644
--- a/calendar/gui/dialogs/alarm-list-dialog.c
+++ b/calendar/gui/dialogs/alarm-list-dialog.c
@@ -48,7 +48,7 @@ typedef struct {
GtkBuilder *builder;
/* The client */
- ECal *ecal;
+ ECalClient *cal_client;
/* The list store */
EAlarmList *list_store;
@@ -94,18 +94,13 @@ sensitize_buttons (Dialog *dialog)
GtkTreeSelection *selection;
GtkTreeIter iter;
gboolean have_selected, read_only = FALSE;
- GError *error = NULL;
- if (!e_cal_is_read_only (dialog->ecal, &read_only, &error)) {
- if (error->code != E_CALENDAR_STATUS_BUSY)
- read_only = TRUE;
- g_error_free (error);
- }
+ read_only = e_client_is_readonly (E_CLIENT (dialog->cal_client));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list));
have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter);
- if ((e_cal_get_one_alarm_only (dialog->ecal) && have_selected) || read_only)
+ if ((e_cal_client_check_one_alarm_only (dialog->cal_client) && have_selected) || read_only)
gtk_widget_set_sensitive (dialog->add, FALSE);
else
gtk_widget_set_sensitive (dialog->add, TRUE);
@@ -133,7 +128,7 @@ add_clicked_cb (GtkButton *button, gpointer data)
icalproperty_set_x_name (icalprop, "X-EVOLUTION-NEEDS-DESCRIPTION");
icalcomponent_add_property (icalcomp, icalprop);
- if (alarm_dialog_run (dialog->toplevel, dialog->ecal, alarm)) {
+ if (alarm_dialog_run (dialog->toplevel, dialog->cal_client, alarm)) {
e_alarm_list_append (dialog->list_store, &iter, alarm);
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter);
} else {
@@ -165,7 +160,7 @@ edit_clicked_cb (GtkButton *button, gpointer data)
alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (dialog->list_store, &iter);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->list_store), &iter);
- if (alarm_dialog_run (dialog->toplevel, dialog->ecal, alarm)) {
+ if (alarm_dialog_run (dialog->toplevel, dialog->cal_client, alarm)) {
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter);
gtk_tree_model_row_changed (GTK_TREE_MODEL (dialog->list_store), path, &iter);
}
@@ -216,7 +211,7 @@ selection_changed_cb (GtkTreeSelection *selection, gpointer data)
}
void
-alarm_list_dialog_set_client (GtkWidget *dlg_box, ECal *client)
+alarm_list_dialog_set_client (GtkWidget *dlg_box, ECalClient *cal_client)
{
Dialog *dialog;
@@ -224,7 +219,7 @@ alarm_list_dialog_set_client (GtkWidget *dlg_box, ECal *client)
dialog = g_object_get_data (G_OBJECT (dlg_box), "dialog");
if (dialog) {
- dialog->ecal = client;
+ dialog->cal_client = cal_client;
sensitize_buttons (dialog);
}
}
@@ -267,13 +262,13 @@ init_widgets (Dialog *dialog)
}
gboolean
-alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store)
+alarm_list_dialog_run (GtkWidget *parent, ECalClient *cal_client, EAlarmList *list_store)
{
Dialog dialog;
GtkWidget *container;
gint response_id;
- dialog.ecal = ecal;
+ dialog.cal_client = cal_client;
dialog.list_store = list_store;
dialog.builder = gtk_builder_new ();
@@ -313,12 +308,12 @@ alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store)
}
GtkWidget *
-alarm_list_dialog_peek (ECal *ecal, EAlarmList *list_store)
+alarm_list_dialog_peek (ECalClient *cal_client, EAlarmList *list_store)
{
Dialog *dialog;
dialog = (Dialog *) g_new (Dialog, 1);
- dialog->ecal = ecal;
+ dialog->cal_client = cal_client;
dialog->list_store = list_store;
dialog->builder = gtk_builder_new ();
diff --git a/calendar/gui/dialogs/alarm-list-dialog.h b/calendar/gui/dialogs/alarm-list-dialog.h
index 7d58fcb0af..163582c556 100644
--- a/calendar/gui/dialogs/alarm-list-dialog.h
+++ b/calendar/gui/dialogs/alarm-list-dialog.h
@@ -30,15 +30,15 @@
#ifndef ALARM_LIST_DIALOG_H
#define ALARM_LIST_DIALOG_H
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
#include "../e-alarm-list.h"
G_BEGIN_DECLS
-gboolean alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store);
-GtkWidget *alarm_list_dialog_peek (ECal *ecal, EAlarmList *list_store);
-void alarm_list_dialog_set_client (GtkWidget *dlg_box, ECal *client);
+gboolean alarm_list_dialog_run (GtkWidget *parent, ECalClient *cal_client, EAlarmList *list_store);
+GtkWidget *alarm_list_dialog_peek (ECalClient *cal_client, EAlarmList *list_store);
+void alarm_list_dialog_set_client (GtkWidget *dlg_box, ECalClient *cal_client);
G_END_DECLS
diff --git a/calendar/gui/dialogs/calendar-setup.c b/calendar/gui/dialogs/calendar-setup.c
index 5981076ee6..231cd0dd34 100644
--- a/calendar/gui/dialogs/calendar-setup.c
+++ b/calendar/gui/dialogs/calendar-setup.c
@@ -32,7 +32,7 @@
#include <libedataserver/e-source-list.h>
#include <shell/e-shell.h>
#include <glib/gi18n.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include "calendar-setup.h"
#include "../e-cal-config.h"
@@ -55,7 +55,7 @@ struct _CalendarSourceDialog {
/* Source group we're creating/editing a source in */
ESourceGroup *source_group;
- ECalSourceType source_type;
+ ECalClientSourceType source_type;
};
static gboolean
@@ -272,11 +272,11 @@ eccp_general_offline (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidg
else {
g_object_get (parent, "n-rows", &row, NULL);
- if (sdialog->source_type == E_CAL_SOURCE_TYPE_EVENT)
+ if (sdialog->source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
offline_setting = gtk_check_button_new_with_mnemonic (_("Cop_y calendar contents locally for offline operation"));
- else if (sdialog->source_type == E_CAL_SOURCE_TYPE_TODO)
+ else if (sdialog->source_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS)
offline_setting = gtk_check_button_new_with_mnemonic (_("Cop_y task list contents locally for offline operation"));
- else if (sdialog->source_type == E_CAL_SOURCE_TYPE_JOURNAL)
+ else if (sdialog->source_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
offline_setting = gtk_check_button_new_with_mnemonic (_("Cop_y memo list contents locally for offline operation"));
gtk_widget_show (offline_setting);
@@ -469,7 +469,7 @@ calendar_setup_edit_calendar (GtkWindow *parent, ESource *source, ESourceGroup *
e_source_set_absolute_uri (sdialog->source, NULL);
e_source_set_group (sdialog->source, sdialog->source_group);
- sdialog->source_type = E_CAL_SOURCE_TYPE_EVENT;
+ sdialog->source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties");
for (i = 0; eccp_items[i].path; i++)
items = g_slist_prepend (items, &eccp_items[i]);
@@ -477,7 +477,7 @@ calendar_setup_edit_calendar (GtkWindow *parent, ESource *source, ESourceGroup *
e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog);
target = e_cal_config_target_new_source (ec, sdialog->source);
- target->source_type = E_CAL_SOURCE_TYPE_EVENT;
+ target->source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
e_config_set_target ((EConfig *) ec, (EConfigTarget *) target);
sdialog->window = e_config_create_window ((EConfig *)ec, NULL, source ? _("Calendar Properties") : _("New Calendar"));
@@ -525,7 +525,7 @@ calendar_setup_edit_task_list (GtkWindow *parent, ESource *source)
e_source_set_absolute_uri (sdialog->source, NULL);
e_source_set_group (sdialog->source, sdialog->source_group);
- sdialog->source_type = E_CAL_SOURCE_TYPE_TODO;
+ sdialog->source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties");
for (i = 0; ectp_items[i].path; i++)
items = g_slist_prepend (items, &ectp_items[i]);
@@ -533,7 +533,7 @@ calendar_setup_edit_task_list (GtkWindow *parent, ESource *source)
e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog);
target = e_cal_config_target_new_source (ec, sdialog->source);
- target->source_type = E_CAL_SOURCE_TYPE_TODO;
+ target->source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
e_config_set_target ((EConfig *) ec, (EConfigTarget *) target);
sdialog->window = e_config_create_window ((EConfig *)ec, NULL, source ? _("Task List Properties") : _("New Task List"));
@@ -581,7 +581,7 @@ calendar_setup_edit_memo_list (GtkWindow *parent, ESource *source)
e_source_set_absolute_uri (sdialog->source, NULL);
e_source_set_group (sdialog->source, sdialog->source_group);
- sdialog->source_type = E_CAL_SOURCE_TYPE_JOURNAL;
+ sdialog->source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties");
for (i = 0; ecmp_items[i].path; i++)
items = g_slist_prepend (items, &ecmp_items[i]);
@@ -589,7 +589,7 @@ calendar_setup_edit_memo_list (GtkWindow *parent, ESource *source)
e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog);
target = e_cal_config_target_new_source (ec, sdialog->source);
- target->source_type = E_CAL_SOURCE_TYPE_JOURNAL;
+ target->source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
e_config_set_target ((EConfig *) ec, (EConfigTarget *) target);
sdialog->window = e_config_create_window ((EConfig *)ec, NULL, source ? _("Memo List Properties") : _("New Memo List"));
diff --git a/calendar/gui/dialogs/cancel-comp.c b/calendar/gui/dialogs/cancel-comp.c
index 4482d4d7ab..86663eda97 100644
--- a/calendar/gui/dialogs/cancel-comp.c
+++ b/calendar/gui/dialogs/cancel-comp.c
@@ -66,14 +66,14 @@ is_past_event (ECalComponent *comp)
**/
gboolean
cancel_component_dialog (GtkWindow *parent,
- ECal *client,
+ ECalClient *cal_client,
ECalComponent *comp,
gboolean deleting)
{
ECalComponentVType vtype;
const gchar *id;
- if (deleting && e_cal_get_save_schedules (client))
+ if (deleting && e_cal_client_check_save_schedules (cal_client))
return TRUE;
vtype = e_cal_component_get_vtype (comp);
diff --git a/calendar/gui/dialogs/cancel-comp.h b/calendar/gui/dialogs/cancel-comp.h
index db455b06d7..3514cf19f5 100644
--- a/calendar/gui/dialogs/cancel-comp.h
+++ b/calendar/gui/dialogs/cancel-comp.h
@@ -26,9 +26,9 @@
#ifndef CANCEL_COMP_H
#define CANCEL_COMP_H
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
-gboolean cancel_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean deleting);
+gboolean cancel_component_dialog (GtkWindow *parent, ECalClient *cal_client, ECalComponent *comp, gboolean deleting);
#endif
diff --git a/calendar/gui/dialogs/comp-editor-page.h b/calendar/gui/dialogs/comp-editor-page.h
index 2b9f7a4467..a33d83810d 100644
--- a/calendar/gui/dialogs/comp-editor-page.h
+++ b/calendar/gui/dialogs/comp-editor-page.h
@@ -28,7 +28,7 @@
#include <time.h>
#include <gtk/gtk.h>
#include <libecal/e-cal-component.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <calendar/gui/e-meeting-attendee.h>
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index cc794ae3f5..21ac86e9c3 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -43,6 +43,9 @@
#include <e-util/gconf-bridge.h>
#include <shell/e-shell.h>
+#include <libecal/e-cal-client.h>
+#include <libecal/e-cal-client-view.h>
+
#include "../print.h"
#include "../comp-util.h"
#include "save-comp.h"
@@ -75,13 +78,14 @@ struct _CompEditorPrivate {
GtkWindowGroup *window_group;
/* Client to use */
- ECal *client;
+ ECalClient *cal_client;
/* Source client (where comp lives currently) */
- ECal *source_client;
+ ECalClient *source_client;
/* View to listen for changes */
- ECalView *view;
+ ECalClientView *view;
+ GCancellable *view_cancellable;
/* Calendar object/uid we are editing; this is an internal copy */
ECalComponent *comp;
@@ -198,8 +202,8 @@ static void page_dates_changed_cb (CompEditor *editor,
CompEditorPageDates *dates,
CompEditorPage *page);
-static void obj_modified_cb (ECal *client, GList *objs, CompEditor *editor);
-static void obj_removed_cb (ECal *client, GList *uids, CompEditor *editor);
+static void obj_modified_cb (ECalClientView *view, const GSList *objs, CompEditor *editor);
+static void obj_removed_cb (ECalClientView *view, const GSList *uids, CompEditor *editor);
G_DEFINE_TYPE_WITH_CODE (
CompEditor, comp_editor, GTK_TYPE_WINDOW,
@@ -303,7 +307,7 @@ get_attachment_list (CompEditor *editor)
view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
- local_store = e_cal_get_local_attachment_store (editor->priv->client);
+ local_store = e_cal_client_get_local_attachment_store (editor->priv->cal_client);
e_cal_component_get_uid (editor->priv->comp, &comp_uid);
path = g_build_path ("/", local_store, comp_uid, NULL);
destination = g_file_new_for_path (path);
@@ -344,6 +348,40 @@ commit_all_fields (CompEditor *editor)
}
static void
+changes_view_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ CompEditor *editor = user_data;
+ ECalClientView *view = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (editor != NULL);
+
+ if (!e_cal_client_get_view_finish (E_CAL_CLIENT (source_object), result, &view, &error))
+ view = NULL;
+
+ if (view) {
+ editor->priv->view = view;
+ g_signal_connect (
+ view, "objects_modified",
+ G_CALLBACK (obj_modified_cb), editor);
+ g_signal_connect (
+ view, "objects_removed",
+ G_CALLBACK (obj_removed_cb), editor);
+
+ e_cal_client_view_start (view, &error);
+
+ if (error) {
+ g_debug ("%s: Failed to stat view: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+ } else if (error) {
+ if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
+ g_debug ("%s: Failed to get view: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+}
+
+static void
listen_for_changes (CompEditor *editor)
{
CompEditorPrivate *priv;
@@ -352,6 +390,12 @@ listen_for_changes (CompEditor *editor)
priv = editor->priv;
/* Discard change listener */
+ if (priv->view_cancellable) {
+ g_cancellable_cancel (priv->view_cancellable);
+ g_object_unref (priv->view_cancellable);
+ priv->view_cancellable = NULL;
+ }
+
if (priv->view) {
g_signal_handlers_disconnect_matched (G_OBJECT (priv->view),
G_SIGNAL_MATCH_DATA,
@@ -369,21 +413,11 @@ listen_for_changes (CompEditor *editor)
if (uid) {
gchar *query;
+ priv->view_cancellable = g_cancellable_new ();
query = g_strdup_printf ("(uid? \"%s\")", uid);
- e_cal_get_query (priv->source_client, query, &priv->view, NULL);
+ e_cal_client_get_view (priv->source_client, query, priv->view_cancellable, changes_view_ready_cb, editor);
g_free (query);
}
-
- if (priv->view) {
- g_signal_connect (
- priv->view, "objects_modified",
- G_CALLBACK (obj_modified_cb), editor);
- g_signal_connect (
- priv->view, "objects_removed",
- G_CALLBACK (obj_removed_cb), editor);
-
- e_cal_view_start (priv->view);
- }
}
static void
@@ -391,8 +425,14 @@ send_timezone (gpointer key, gpointer value, gpointer user_data)
{
icaltimezone *zone = value;
CompEditor *editor = user_data;
+ GError *error = NULL;
+
+ e_cal_client_add_timezone_sync (editor->priv->cal_client, zone, NULL, &error);
- e_cal_add_timezone (editor->priv->client, zone, NULL);
+ if (error) {
+ g_debug ("%s: Failed to add timezone: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
static gboolean
@@ -448,8 +488,8 @@ save_comp (CompEditor *editor)
/* If we are not the organizer, we don't update the sequence number */
if (!e_cal_component_has_organizer (clone) ||
- itip_organizer_is_user (clone, priv->client) ||
- itip_sentby_is_user (clone, priv->client))
+ itip_organizer_is_user (clone, priv->cal_client) ||
+ itip_sentby_is_user (clone, priv->cal_client))
e_cal_component_commit_sequence (clone);
else
e_cal_component_abort_sequence (clone);
@@ -472,10 +512,14 @@ save_comp (CompEditor *editor)
priv->comp, get_attachment_list (editor));
icalcomp = e_cal_component_get_icalcomponent (priv->comp);
/* send the component to the server */
- if (!cal_comp_is_on_server (priv->comp, priv->client)) {
- result = e_cal_create_object (priv->client, icalcomp, NULL, &error);
- if (result)
+ if (!cal_comp_is_on_server (priv->comp, priv->cal_client)) {
+ gchar *uid = NULL;
+ result = e_cal_client_create_object_sync (priv->cal_client, icalcomp, &uid, NULL, &error);
+ if (result) {
+ icalcomponent_set_uid (icalcomp, uid);
+ g_free (uid);
g_signal_emit_by_name (editor, "object_created");
+ }
} else {
gboolean has_recurrences;
@@ -484,7 +528,7 @@ save_comp (CompEditor *editor)
if (has_recurrences && priv->mod == CALOBJ_MOD_ALL)
comp_util_sanitize_recurrence_master (
- priv->comp, priv->client);
+ priv->comp, priv->cal_client);
if (priv->mod == CALOBJ_MOD_THIS) {
e_cal_component_set_rdate_list (priv->comp, NULL);
@@ -492,13 +536,13 @@ save_comp (CompEditor *editor)
e_cal_component_set_exdate_list (priv->comp, NULL);
e_cal_component_set_exrule_list (priv->comp, NULL);
}
- result = e_cal_modify_object (priv->client, icalcomp, priv->mod, &error);
+ result = e_cal_client_modify_object_sync (priv->cal_client, icalcomp, priv->mod, NULL, &error);
if (priv->mod == CALOBJ_MOD_THIS) {
if (result && ((flags & COMP_EDITOR_DELEGATE) ||
!e_cal_component_has_organizer (clone) ||
- itip_organizer_is_user (clone, priv->client) ||
- itip_sentby_is_user (clone, priv->client)))
+ itip_organizer_is_user (clone, priv->cal_client) ||
+ itip_sentby_is_user (clone, priv->cal_client)))
e_cal_component_commit_sequence (clone);
else
e_cal_component_abort_sequence (clone);
@@ -550,25 +594,31 @@ save_comp (CompEditor *editor)
return FALSE;
} else {
if (priv->source_client &&
- !e_source_equal (e_cal_get_source (priv->client),
- e_cal_get_source (priv->source_client)) &&
+ !e_source_equal (e_client_get_source (E_CLIENT (priv->cal_client)),
+ e_client_get_source (E_CLIENT (priv->source_client))) &&
cal_comp_is_on_server (priv->comp, priv->source_client)) {
/* Comp found a new home. Remove it from old one. */
+ GError *error = NULL;
if (e_cal_component_is_instance (priv->comp) ||
e_cal_component_has_recurrences (priv->comp))
- e_cal_remove_object_with_mod (
+ e_cal_client_remove_object_sync (
priv->source_client, orig_uid_copy,
- NULL, CALOBJ_MOD_ALL, NULL);
+ NULL, CALOBJ_MOD_ALL, NULL, &error);
else
- e_cal_remove_object (
+ e_cal_client_remove_object_sync (
priv->source_client,
- orig_uid_copy, NULL);
+ orig_uid_copy, NULL, CALOBJ_MOD_THIS, NULL, &error);
+
+ if (error) {
+ g_debug ("%s: Failed to remove object: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
/* Let priv->source_client point to new home,
* so we can move it again this session. */
g_object_unref (priv->source_client);
- priv->source_client = g_object_ref (priv->client);
+ priv->source_client = g_object_ref (priv->cal_client);
listen_for_changes (editor);
}
@@ -608,9 +658,9 @@ save_comp_with_send (CompEditor *editor)
if (!save_comp (editor))
return FALSE;
- delegated = delegate && !e_cal_get_save_schedules (priv->client);
+ delegated = delegate && !e_cal_client_check_save_schedules (priv->cal_client);
if (delegated || (send && send_component_dialog (
- (GtkWindow *) editor, priv->client, priv->comp,
+ (GtkWindow *) editor, priv->cal_client, priv->comp,
!priv->existing_org, &strip_alarms, !priv->existing_org ?
NULL : &only_new_attendees))) {
if (delegated)
@@ -622,8 +672,8 @@ save_comp_with_send (CompEditor *editor)
(only_new_attendees ?
COMP_EDITOR_SEND_TO_NEW_ATTENDEES_ONLY : 0));
- if ((itip_organizer_is_user (priv->comp, priv->client) ||
- itip_sentby_is_user (priv->comp, priv->client))) {
+ if ((itip_organizer_is_user (priv->comp, priv->cal_client) ||
+ itip_sentby_is_user (priv->comp, priv->cal_client))) {
if (e_cal_component_get_vtype (priv->comp) == E_CAL_COMPONENT_JOURNAL)
return comp_editor_send_comp (
editor, E_CAL_COMPONENT_METHOD_PUBLISH,
@@ -768,7 +818,7 @@ action_print_cb (GtkAction *action,
use_24_hour_format = comp_editor_get_use_24_hour_format (editor);
print_comp (
- comp, priv->client, zone, use_24_hour_format,
+ comp, priv->cal_client, zone, use_24_hour_format,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG);
g_object_unref (comp);
@@ -798,14 +848,14 @@ action_print_preview_cb (GtkAction *action,
use_24_hour_format = comp_editor_get_use_24_hour_format (editor);
print_comp (
- comp, priv->client, zone, use_24_hour_format,
+ comp, priv->cal_client, zone, use_24_hour_format,
GTK_PRINT_OPERATION_ACTION_PREVIEW);
g_object_unref (comp);
}
static gboolean
-remove_event_dialog (ECal *client,
+remove_event_dialog (ECalClient *client,
ECalComponent *comp,
GtkWindow *parent)
{
@@ -833,7 +883,7 @@ action_save_cb (GtkAction *action,
EAttachmentView *view;
ECalComponentText text;
gboolean delegated = FALSE;
- gboolean read_only, correct = FALSE;
+ gboolean correct = FALSE;
ECalComponent *comp;
view = E_ATTACHMENT_VIEW (priv->attachment_view);
@@ -860,12 +910,12 @@ action_save_cb (GtkAction *action,
return;
}
- if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) {
+ if (e_client_is_readonly (E_CLIENT (priv->cal_client))) {
e_alert_submit (
E_ALERT_SINK (editor),
"calendar:prompt-read-only-cal-editor",
e_source_peek_name (
- e_cal_get_source (priv->client)),
+ e_client_get_source (E_CLIENT (priv->cal_client))),
NULL);
return;
}
@@ -873,7 +923,7 @@ action_save_cb (GtkAction *action,
commit_all_fields (editor);
if (e_cal_component_has_recurrences (priv->comp)) {
if (!recur_component_dialog (
- priv->client, priv->comp, &priv->mod,
+ priv->cal_client, priv->comp, &priv->mod,
GTK_WINDOW (editor), delegated))
return;
} else if (e_cal_component_is_instance (priv->comp))
@@ -888,7 +938,7 @@ action_save_cb (GtkAction *action,
if (!text.value)
if (!send_component_prompt_subject (
- (GtkWindow *) editor, priv->client, priv->comp))
+ (GtkWindow *) editor, priv->cal_client, priv->comp))
return;
if (save_comp_with_send (editor)) {
@@ -899,7 +949,7 @@ action_save_cb (GtkAction *action,
delegate = flags & COMP_EDITOR_DELEGATE;
if (delegate && !remove_event_dialog (
- priv->client, priv->comp, GTK_WINDOW (editor))) {
+ priv->cal_client, priv->comp, GTK_WINDOW (editor))) {
const gchar *uid = NULL;
GError *error = NULL;
@@ -909,12 +959,10 @@ action_save_cb (GtkAction *action,
e_cal_component_has_recurrences (priv->comp)) {
gchar *rid;
rid = e_cal_component_get_recurid_as_string (priv->comp);
- e_cal_remove_object_with_mod (
- priv->client, uid, rid,
- priv->mod, &error);
+ e_cal_client_remove_object_sync (priv->cal_client, uid, rid, priv->mod, NULL, &error);
g_free (rid);
} else
- e_cal_remove_object (priv->client, uid, &error);
+ e_cal_client_remove_object_sync (priv->cal_client, uid, NULL, CALOBJ_MOD_THIS, NULL, &error);
g_clear_error (&error);
}
@@ -1470,9 +1518,9 @@ comp_editor_dispose (GObject *object)
priv->window_group = NULL;
}
- if (priv->client) {
- g_object_unref (priv->client);
- priv->client = NULL;
+ if (priv->cal_client) {
+ g_object_unref (priv->cal_client);
+ priv->cal_client = NULL;
}
if (priv->source_client) {
@@ -1480,6 +1528,12 @@ comp_editor_dispose (GObject *object)
priv->source_client = NULL;
}
+ if (priv->view_cancellable) {
+ g_cancellable_cancel (priv->view_cancellable);
+ g_object_unref (priv->view_cancellable);
+ priv->view_cancellable = NULL;
+ }
+
if (priv->view) {
g_signal_handlers_disconnect_matched (G_OBJECT (priv->view),
G_SIGNAL_MATCH_DATA,
@@ -1690,7 +1744,7 @@ comp_editor_class_init (CompEditorClass *class)
"client",
NULL,
NULL,
- E_TYPE_CAL,
+ E_TYPE_CAL_CLIENT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
@@ -2074,7 +2128,7 @@ static gboolean
prompt_and_save_changes (CompEditor *editor, gboolean send)
{
CompEditorPrivate *priv;
- gboolean read_only, correct = FALSE;
+ gboolean correct = FALSE;
ECalComponent *comp;
ECalComponentText text;
@@ -2085,12 +2139,12 @@ prompt_and_save_changes (CompEditor *editor, gboolean send)
switch (save_component_dialog (GTK_WINDOW (editor), priv->comp)) {
case GTK_RESPONSE_YES: /* Save */
- if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) {
+ if (e_client_is_readonly (E_CLIENT (priv->cal_client))) {
e_alert_submit (
E_ALERT_SINK (editor),
"calendar:prompt-read-only-cal-editor",
e_source_peek_name (
- e_cal_get_source (priv->client)),
+ e_client_get_source (E_CLIENT (priv->cal_client))),
NULL);
/* don't discard changes when selected readonly calendar */
return FALSE;
@@ -2105,12 +2159,12 @@ prompt_and_save_changes (CompEditor *editor, gboolean send)
if (!text.value)
if (!send_component_prompt_subject (
- (GtkWindow *) editor, priv->client, priv->comp))
+ (GtkWindow *) editor, priv->cal_client, priv->comp))
return FALSE;
if (e_cal_component_is_instance (priv->comp))
if (!recur_component_dialog (
- priv->client, priv->comp, &priv->mod,
+ priv->cal_client, priv->comp, &priv->mod,
GTK_WINDOW (editor), FALSE))
return FALSE;
@@ -2815,27 +2869,27 @@ comp_editor_show_page (CompEditor *editor, CompEditorPage *page)
/**
* comp_editor_set_client:
* @editor: A component editor
- * @client: The calendar client to use
+ * @cal_client: The calendar client to use
*
* Sets the calendar client used by the editor to update components
**/
void
comp_editor_set_client (CompEditor *editor,
- ECal *client)
+ ECalClient *cal_client)
{
g_return_if_fail (IS_COMP_EDITOR (editor));
- g_return_if_fail (client == NULL || E_IS_CAL (client));
+ g_return_if_fail (cal_client == NULL || E_IS_CAL_CLIENT (cal_client));
- if (client != NULL)
- g_object_ref (client);
+ if (cal_client != NULL)
+ g_object_ref (cal_client);
- if (editor->priv->client != NULL)
- g_object_unref (editor->priv->client);
+ if (editor->priv->cal_client != NULL)
+ g_object_unref (editor->priv->cal_client);
- editor->priv->client = client;
+ editor->priv->cal_client = cal_client;
- if (editor->priv->source_client == NULL && client != NULL)
- editor->priv->source_client = g_object_ref (client);
+ if (editor->priv->source_client == NULL && cal_client != NULL)
+ editor->priv->source_client = g_object_ref (cal_client);
g_object_notify (G_OBJECT (editor), "client");
}
@@ -2848,12 +2902,12 @@ comp_editor_set_client (CompEditor *editor,
*
* Return value: The calendar client of the editor
**/
-ECal *
+ECalClient *
comp_editor_get_client (CompEditor *editor)
{
g_return_val_if_fail (IS_COMP_EDITOR (editor), NULL);
- return editor->priv->client;
+ return editor->priv->cal_client;
}
static void
@@ -3046,7 +3100,7 @@ set_attendees_for_delegation (ECalComponent *comp,
}
static void
-get_users_from_memo_comp (ECalComponent *comp, GList **users)
+get_users_from_memo_comp (ECalComponent *comp, GSList **users)
{
icalcomponent *icalcomp;
icalproperty *icalprop;
@@ -3072,7 +3126,7 @@ get_users_from_memo_comp (ECalComponent *comp, GList **users)
iter = emails;
while (*iter) {
- *users = g_list_append (*users, g_strdup (*iter));
+ *users = g_slist_append (*users, g_strdup (*iter));
iter++;
}
g_strfreev (emails);
@@ -3088,7 +3142,7 @@ real_send_comp (CompEditor *editor,
CompEditorFlags flags;
ECalComponent *send_comp = NULL;
gchar *address = NULL;
- GList *users = NULL;
+ GSList *users = NULL;
g_return_val_if_fail (IS_COMP_EDITOR (editor), FALSE);
@@ -3101,7 +3155,7 @@ real_send_comp (CompEditor *editor,
const gchar *uid = NULL;
e_cal_component_get_uid (priv->comp, &uid);
- if (e_cal_get_object (priv->client, uid, NULL, &icalcomp, NULL) && icalcomp) {
+ if (e_cal_client_get_object_sync (priv->cal_client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) {
send_comp = e_cal_component_new ();
if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) {
icalcomponent_free (icalcomp);
@@ -3122,17 +3176,17 @@ real_send_comp (CompEditor *editor,
/* The user updates the delegated status to the Organizer,
* so remove all other attendees. */
if (flags & COMP_EDITOR_DELEGATE) {
- address = itip_get_comp_attendee (send_comp, priv->client);
+ address = itip_get_comp_attendee (send_comp, priv->cal_client);
if (address)
set_attendees_for_delegation (send_comp, address, method);
}
if (!e_cal_component_has_attachments (priv->comp) ||
- e_cal_get_static_capability (priv->client,
+ e_client_check_capability (E_CLIENT (priv->cal_client),
CAL_STATIC_CAPABILITY_CREATE_MESSAGES)) {
if (itip_send_comp (
- method, send_comp, priv->client,
+ method, send_comp, priv->cal_client,
NULL, NULL, users, strip_alarms,
priv->flags & COMP_EDITOR_SEND_TO_NEW_ATTENDEES_ONLY)) {
g_object_unref (send_comp);
@@ -3162,7 +3216,7 @@ real_send_comp (CompEditor *editor,
}
if (itip_send_comp (
- method, send_comp, priv->client,
+ method, send_comp, priv->cal_client,
NULL, mime_attach_list, users, strip_alarms,
priv->flags & COMP_EDITOR_SEND_TO_NEW_ATTENDEES_ONLY)) {
gboolean saved = save_comp (editor);
@@ -3279,10 +3333,10 @@ comp_editor_delete_comp (CompEditor *editor)
e_cal_component_get_uid (priv->comp, &uid);
if (e_cal_component_is_instance (priv->comp) ||
e_cal_component_has_recurrences (priv->comp))
- e_cal_remove_object_with_mod (priv->client, uid, NULL,
- CALOBJ_MOD_ALL, NULL);
+ e_cal_client_remove_object_sync (priv->cal_client, uid, NULL,
+ CALOBJ_MOD_ALL, NULL, NULL);
else
- e_cal_remove_object (priv->client, uid, NULL);
+ e_cal_client_remove_object_sync (priv->cal_client, uid, NULL, CALOBJ_MOD_THIS, NULL, NULL);
close_dialog (editor);
}
@@ -3428,8 +3482,8 @@ page_dates_changed_cb (CompEditor *editor,
}
static void
-obj_modified_cb (ECal *client,
- GList *objects,
+obj_modified_cb (ECalClientView *view,
+ const GSList *objects,
CompEditor *editor)
{
CompEditorPrivate *priv;
@@ -3465,8 +3519,8 @@ obj_modified_cb (ECal *client,
}
static void
-obj_removed_cb (ECal *client,
- GList *uids,
+obj_removed_cb (ECalClientView *view,
+ const GSList *uids,
CompEditor *editor)
{
CompEditorPrivate *priv = editor->priv;
diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h
index 591300ffd2..3f1ddbb673 100644
--- a/calendar/gui/dialogs/comp-editor.h
+++ b/calendar/gui/dialogs/comp-editor.h
@@ -26,7 +26,7 @@
#define COMP_EDITOR_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include "../itip-utils.h"
#include "comp-editor-page.h"
#include <shell/e-shell.h>
@@ -165,8 +165,8 @@ void comp_editor_remove_page (CompEditor *editor,
void comp_editor_show_page (CompEditor *editor,
CompEditorPage *page);
void comp_editor_set_client (CompEditor *editor,
- ECal *client);
-ECal * comp_editor_get_client (CompEditor *editor);
+ ECalClient *cal_client);
+ECalClient * comp_editor_get_client (CompEditor *editor);
void comp_editor_edit_comp (CompEditor *ee,
ECalComponent *comp);
ECalComponent * comp_editor_get_comp (CompEditor *editor);
diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c
index 547a91069c..7b75624a56 100644
--- a/calendar/gui/dialogs/copy-source-dialog.c
+++ b/calendar/gui/dialogs/copy-source-dialog.c
@@ -27,33 +27,35 @@
#endif
#include <glib/gi18n.h>
+#include <libedataserverui/e-client-utils.h>
+
#include "copy-source-dialog.h"
#include "select-source-dialog.h"
-#include "common/authentication.h"
typedef struct {
GtkWindow *parent;
ESource *orig_source;
- ECalSourceType obj_type;
+ EClientSourceType obj_type;
ESource *selected_source;
+ ECalClient *source_client, *dest_client;
} CopySourceDialogData;
static void
-show_error (CopySourceDialogData *csdd, const gchar *msg)
+show_error (CopySourceDialogData *csdd, const gchar *msg, const GError *error)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (
csdd->parent, 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE, "%s", msg);
+ GTK_BUTTONS_CLOSE, error ? "%s\n%s" : "%s", msg, error ? error->message : "");
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
struct ForeachTzidData
{
- ECal *source_client;
- ECal *dest_client;
+ ECalClient *source_client;
+ ECalClient *dest_client;
};
static void
@@ -71,61 +73,70 @@ add_timezone_to_cal_cb (icalparameter *param, gpointer data)
if (!tzid || !*tzid)
return;
- if (e_cal_get_timezone (ftd->source_client, tzid, &tz, NULL) && tz)
- e_cal_add_timezone (ftd->dest_client, tz, NULL);
+ if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, NULL, NULL) && tz)
+ e_cal_client_add_timezone_sync (ftd->dest_client, tz, NULL, NULL);
}
-static gboolean
-copy_source (CopySourceDialogData *csdd)
+static void
+free_copy_data (CopySourceDialogData *csdd)
{
- ECal *source_client, *dest_client;
- gboolean read_only = TRUE;
- GList *obj_list = NULL;
- gboolean result = FALSE;
-
- if (!csdd->selected_source)
- return FALSE;
-
- /* open the source */
- source_client = e_auth_new_cal_from_source (csdd->orig_source, csdd->obj_type);
- if (!e_cal_open (source_client, TRUE, NULL)) {
- show_error (csdd, _("Could not open source"));
- g_object_unref (source_client);
- return FALSE;
- }
+ if (!csdd)
+ return;
- /* open the destination */
- dest_client = e_auth_new_cal_from_source (csdd->selected_source, csdd->obj_type);
- if (!e_cal_open (dest_client, FALSE, NULL)) {
- show_error (csdd, _("Could not open destination"));
- g_object_unref (dest_client);
- g_object_unref (source_client);
- return FALSE;
+ if (csdd->orig_source)
+ g_object_unref (csdd->orig_source);
+ if (csdd->selected_source)
+ g_object_unref (csdd->selected_source);
+ if (csdd->source_client)
+ g_object_unref (csdd->source_client);
+ if (csdd->dest_client)
+ g_object_unref (csdd->dest_client);
+ g_free (csdd);
+}
+
+static void
+dest_source_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ CopySourceDialogData *csdd = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ if (!client) {
+ show_error (csdd, _("Could not open destination"), error);
+ if (error)
+ g_error_free (error);
+ free_copy_data (csdd);
+ return;
}
+ csdd->dest_client = E_CAL_CLIENT (client);
+
+ e_client_utils_open_new (csdd->selected_source, csdd->obj_type, FALSE, NULL,
+ e_client_utils_authenticate_handler, csdd->parent,
+ dest_source_opened_cb, csdd);
+
/* check if the destination is read only */
- e_cal_is_read_only (dest_client, &read_only, NULL);
- if (read_only) {
- show_error (csdd, _("Destination is read only"));
+ if (e_client_is_readonly (E_CLIENT (csdd->dest_client))) {
+ show_error (csdd, _("Destination is read only"), NULL);
} else {
- if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) {
- GList *l;
+ GSList *obj_list = NULL;
+ if (e_cal_client_get_object_list_sync (csdd->source_client, "#t", &obj_list, NULL, NULL)) {
+ GSList *l;
icalcomponent *icalcomp;
struct ForeachTzidData ftd;
- ftd.source_client = source_client;
- ftd.dest_client = dest_client;
+ ftd.source_client = csdd->source_client;
+ ftd.dest_client = csdd->dest_client;
for (l = obj_list; l != NULL; l = l->next) {
/* FIXME: process recurrences */
/* FIXME: process errors */
- if (e_cal_get_object (
- dest_client,
- icalcomponent_get_uid (l->data),
- NULL, &icalcomp, NULL)) {
- e_cal_modify_object (
- dest_client, l->data,
- CALOBJ_MOD_ALL, NULL);
+ if (e_cal_client_get_object_sync (csdd->dest_client, icalcomponent_get_uid (l->data), NULL,
+ &icalcomp, NULL, NULL)) {
+ e_cal_client_modify_object_sync (csdd->dest_client, l->data, CALOBJ_MOD_ALL, NULL, NULL);
icalcomponent_free (icalcomp);
} else {
gchar *uid = NULL;
@@ -139,11 +150,11 @@ copy_source (CopySourceDialogData *csdd)
icalcomp,
add_timezone_to_cal_cb, &ftd);
- if (e_cal_create_object (dest_client, icalcomp, &uid, &error)) {
+ if (e_cal_client_create_object_sync (csdd->dest_client, icalcomp, &uid, NULL, &error)) {
g_free (uid);
} else {
if (error) {
- show_error (csdd, error->message);
+ show_error (csdd, _("Cannot create object"), error);
g_error_free (error);
}
break;
@@ -151,15 +162,57 @@ copy_source (CopySourceDialogData *csdd)
}
}
- e_cal_free_object_list (obj_list);
+ e_cal_client_free_icalcomp_slist (obj_list);
}
}
- /* free memory */
- g_object_unref (dest_client);
- g_object_unref (source_client);
+ free_copy_data (csdd);
+}
+
+static void
+orig_source_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ CopySourceDialogData *csdd = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ if (!client) {
+ show_error (csdd, _("Could not open source"), error);
+ if (error)
+ g_error_free (error);
+ free_copy_data (csdd);
+ return;
+ }
+
+ csdd->source_client = E_CAL_CLIENT (client);
+
+ e_client_utils_open_new (csdd->selected_source, csdd->obj_type, FALSE, NULL,
+ e_client_utils_authenticate_handler, csdd->parent,
+ dest_source_opened_cb, csdd);
+}
+
+static void
+copy_source (const CopySourceDialogData *const_csdd)
+{
+ CopySourceDialogData *csdd;
+
+ if (!const_csdd->selected_source)
+ return;
- return result;
+ g_return_if_fail (const_csdd->obj_type != E_CLIENT_SOURCE_TYPE_LAST);
+
+ csdd = g_new0 (CopySourceDialogData, 1);
+ csdd->parent = const_csdd->parent;
+ csdd->orig_source = g_object_ref (const_csdd->orig_source);
+ csdd->obj_type = const_csdd->obj_type;
+ csdd->selected_source = g_object_ref (const_csdd->selected_source);
+
+ e_client_utils_open_new (csdd->orig_source, csdd->obj_type, FALSE, NULL,
+ e_client_utils_authenticate_handler, csdd->parent,
+ orig_source_opened_cb, csdd);
}
/**
@@ -168,26 +221,29 @@ copy_source (CopySourceDialogData *csdd)
* Implements the Copy command for sources, allowing the user to select a target
* source to copy to.
*/
-gboolean
-copy_source_dialog (GtkWindow *parent, ESource *source, ECalSourceType obj_type)
+void
+copy_source_dialog (GtkWindow *parent, ESource *source, ECalClientSourceType obj_type)
{
CopySourceDialogData csdd;
- gboolean result = FALSE;
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
+ g_return_if_fail (E_IS_SOURCE (source));
+ g_return_if_fail (obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ||
+ obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS ||
+ obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS);
csdd.parent = parent;
csdd.orig_source = source;
csdd.selected_source = NULL;
- csdd.obj_type = obj_type;
+ csdd.obj_type = obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? E_CLIENT_SOURCE_TYPE_EVENTS :
+ obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS ? E_CLIENT_SOURCE_TYPE_TASKS :
+ obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS ? E_CLIENT_SOURCE_TYPE_MEMOS :
+ E_CLIENT_SOURCE_TYPE_LAST;
csdd.selected_source = select_source_dialog (parent, obj_type, source);
if (csdd.selected_source) {
- result = copy_source (&csdd);
+ copy_source (&csdd);
/* free memory */
g_object_unref (csdd.selected_source);
}
-
- return result;
}
diff --git a/calendar/gui/dialogs/copy-source-dialog.h b/calendar/gui/dialogs/copy-source-dialog.h
index 4c6f5b19c8..d9475f742c 100644
--- a/calendar/gui/dialogs/copy-source-dialog.h
+++ b/calendar/gui/dialogs/copy-source-dialog.h
@@ -28,9 +28,9 @@
#include <gtk/gtk.h>
#include <libedataserver/e-source.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-util.h>
-gboolean copy_source_dialog (GtkWindow *parent, ESource *source, ECalSourceType type);
+void copy_source_dialog (GtkWindow *parent, ESource *source, ECalClientSourceType type);
#endif
diff --git a/calendar/gui/dialogs/delete-error.c b/calendar/gui/dialogs/delete-error.c
index 9b9d22ae4c..cd461c7858 100644
--- a/calendar/gui/dialogs/delete-error.c
+++ b/calendar/gui/dialogs/delete-error.c
@@ -45,11 +45,11 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype)
const gchar *str;
const gchar *icon_name = NULL;
- if (!error)
+ if (!error || error->domain != E_CLIENT_ERROR)
return;
switch (error->code) {
- case E_CALENDAR_STATUS_DBUS_EXCEPTION:
+ case E_CLIENT_ERROR_DBUS_ERROR:
switch (vtype) {
case E_CAL_COMPONENT_EVENT:
/* Translators: The '%s' is replaced with a detailed error message */
@@ -69,7 +69,7 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype)
break;
}
break;
- case E_CALENDAR_STATUS_PERMISSION_DENIED:
+ case E_CLIENT_ERROR_PERMISSION_DENIED:
switch (vtype) {
case E_CAL_COMPONENT_EVENT:
str = _("The event could not be deleted because permission was denied");
@@ -85,7 +85,7 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype)
break;
}
break;
- case E_CALENDAR_STATUS_OTHER_ERROR:
+ case E_CLIENT_ERROR_OTHER_ERROR:
switch (vtype) {
case E_CAL_COMPONENT_EVENT:
/* Translators: The '%s' is replaced with a detailed error message */
@@ -105,8 +105,6 @@ delete_error_dialog (const GError *error, ECalComponentVType vtype)
break;
}
break;
- case E_CALENDAR_STATUS_OK:
- case E_CALENDAR_STATUS_OBJECT_NOT_FOUND:
default:
/* If not found, we don't care - its gone anyhow */
return;
diff --git a/calendar/gui/dialogs/delete-error.h b/calendar/gui/dialogs/delete-error.h
index 480edcbd42..91e38c146f 100644
--- a/calendar/gui/dialogs/delete-error.h
+++ b/calendar/gui/dialogs/delete-error.h
@@ -26,7 +26,7 @@
#ifndef DELETE_ERROR_H
#define DELETE_ERROR_H
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
void delete_error_dialog (const GError *error, ECalComponentVType vtype);
diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c
index 64d3b67891..f4c798bfd1 100644
--- a/calendar/gui/dialogs/event-editor.c
+++ b/calendar/gui/dialogs/event-editor.c
@@ -286,7 +286,7 @@ event_editor_constructor (GType type,
GtkActionGroup *action_group;
GtkWidget *content_area;
EShell *shell;
- ECal *client;
+ ECalClient *client;
gboolean is_meeting;
GtkWidget *alarm_page;
GtkWidget *attendee_page;
@@ -363,8 +363,7 @@ event_editor_constructor (GType type,
if (is_meeting) {
- if (e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS))
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS))
event_page_show_options (priv->event_page);
comp_editor_set_group_item (editor, TRUE);
@@ -604,7 +603,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
ECalComponentOrganizer organizer;
gboolean delegate;
ECalComponentDateTime dtstart, dtend;
- ECal *client;
+ ECalClient *client;
GSList *attendees = NULL;
priv = EVENT_EDITOR (editor)->priv;
@@ -645,8 +644,8 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
gtk_action_set_visible (action, TRUE);
}
- if (!(delegate && e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))) {
+ if (!(delegate && e_client_check_capability (
+ E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))) {
event_page_remove_all_attendees (priv->event_page);
for (l = attendees; l != NULL; l = l->next) {
@@ -685,7 +684,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
if (ia != NULL)
e_meeting_attendee_set_edit_level (
ia, E_MEETING_ATTENDEE_EDIT_STATUS);
- } else if (e_cal_get_organizer_must_attend (client)) {
+ } else if (e_cal_client_check_organizer_must_attend (client)) {
EMeetingAttendee *ia;
ia = e_meeting_store_find_attendee (
@@ -726,7 +725,7 @@ event_editor_send_comp (CompEditor *editor,
comp = event_page_get_cancel_comp (priv->event_page);
if (comp != NULL) {
- ECal *client;
+ ECalClient *client;
gboolean result;
client = e_meeting_store_get_client (priv->model);
@@ -748,7 +747,7 @@ event_editor_send_comp (CompEditor *editor,
/**
* event_editor_new:
- * @client: a ECal
+ * @client: a ECalClient
*
* Creates a new event editor dialog.
*
@@ -756,11 +755,11 @@ event_editor_send_comp (CompEditor *editor,
* editor could not be created.
**/
CompEditor *
-event_editor_new (ECal *client,
+event_editor_new (ECalClient *client,
EShell *shell,
CompEditorFlags flags)
{
- g_return_val_if_fail (E_IS_CAL (client), NULL);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL);
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
return g_object_new (
diff --git a/calendar/gui/dialogs/event-editor.h b/calendar/gui/dialogs/event-editor.h
index abb8f0e659..eaa2c49057 100644
--- a/calendar/gui/dialogs/event-editor.h
+++ b/calendar/gui/dialogs/event-editor.h
@@ -65,7 +65,7 @@ struct _EventEditorClass {
};
GType event_editor_get_type (void);
-CompEditor * event_editor_new (ECal *client,
+CompEditor * event_editor_new (ECalClient *client,
EShell *shell,
CompEditorFlags flags);
void event_editor_show_meeting (EventEditor *ee);
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index b6d7c2630b..68210d1090 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -35,8 +35,8 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <libedataserverui/e-category-completion.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-combo-box.h>
-#include "common/authentication.h"
#include "misc/e-dateedit.h"
#include "misc/e-send-options.h"
#include "misc/e-buffer-tagger.h"
@@ -604,7 +604,7 @@ create_alarm_image_button (const gchar *image_text,
static void
sensitize_widgets (EventPage *epage)
{
- ECal *client;
+ ECalClient *client;
EShell *shell;
CompEditor *editor;
CompEditorFlags flags;
@@ -623,8 +623,7 @@ sensitize_widgets (EventPage *epage)
if (flags & COMP_EDITOR_MEETING)
sens = flags & COMP_EDITOR_USER_ORG;
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
+ read_only = e_client_is_readonly (E_CLIENT (client));
delegate = flags & COMP_EDITOR_DELEGATE;
@@ -724,7 +723,7 @@ update_time (EventPage *epage,
ECalComponentDateTime *end_date)
{
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
GtkAction *action;
struct icaltimetype *start_tt, *end_tt, implied_tt;
icaltimezone *start_zone = NULL, *def_zone = NULL;
@@ -734,15 +733,20 @@ update_time (EventPage *epage,
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
client = comp_editor_get_client (editor);
- /* Note that if we are creating a new event, the timezones may not be
- on the server, so we try to get the builtin timezone with the TZID
- first. */
- start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid);
- if (!start_zone) {
- /* FIXME: Handle error better. */
- if (!e_cal_get_timezone (client, start_date->tzid, &start_zone, NULL)) {
- g_warning ("Couldn't get timezone from server: %s",
- start_date->tzid ? start_date->tzid : "");
+ if (start_date->tzid) {
+ /* Note that if we are creating a new event, the timezones may not be
+ on the server, so we try to get the builtin timezone with the TZID
+ first. */
+ start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid);
+ if (!start_zone) {
+ /* FIXME: Handle error better. */
+ GError *error = NULL;
+ if (!e_cal_client_get_timezone_sync (client, start_date->tzid, &start_zone, NULL, &error)) {
+ g_warning ("Couldn't get timezone '%s' from server: %s",
+ start_date->tzid ? start_date->tzid : "", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ }
}
}
@@ -1068,7 +1072,7 @@ static gboolean
event_page_fill_widgets (CompEditorPage *page,
ECalComponent *comp)
{
- ECal *client;
+ ECalClient *client;
CompEditor *editor;
CompEditorFlags flags;
EventPage *epage;
@@ -1135,7 +1139,7 @@ event_page_fill_widgets (CompEditorPage *page,
e_cal_component_free_text_list (l);
e_buffer_tagger_update_tags (GTK_TEXT_VIEW (priv->description));
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
set_subscriber_info_string (epage, backend_addr);
if (priv->is_meeting) {
@@ -1156,13 +1160,13 @@ event_page_fill_widgets (CompEditorPage *page,
gchar *string;
if (itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp, client)) {
- if (e_cal_get_static_capability (
- client,
+ if (e_client_check_capability (
+ E_CLIENT (client),
CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS))
priv->user_org = TRUE;
} else {
- if (e_cal_get_static_capability (
- client,
+ if (e_client_check_capability (
+ E_CLIENT (client),
CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS))
gtk_widget_set_sensitive (priv->invite, FALSE);
gtk_widget_set_sensitive (priv->add, FALSE);
@@ -1171,7 +1175,7 @@ event_page_fill_widgets (CompEditorPage *page,
priv->user_org = FALSE;
}
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE))
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE))
string = g_strdup (backend_addr);
else if ( organizer.cn != NULL)
string = g_strdup_printf ("%s <%s>", organizer.cn, strip);
@@ -1224,7 +1228,7 @@ event_page_fill_widgets (CompEditorPage *page,
backend_mailto = mailto = NULL;
}
- if (client && e_cal_get_organizer_must_accept (client))
+ if (client && e_cal_client_check_organizer_must_accept (client))
e_meeting_attendee_set_status (
attendee, ICAL_PARTSTAT_NEEDSACTION);
else
@@ -1277,7 +1281,7 @@ event_page_fill_widgets (CompEditorPage *page,
break;
}
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_TRANSPARENCY))
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_TRANSPARENCY))
enable_busy_time_menu (epage, FALSE);
else
enable_busy_time_menu (epage, TRUE);
@@ -1318,7 +1322,7 @@ event_page_fill_widgets (CompEditorPage *page,
/* Source */
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_selector),
- e_cal_get_source (client));
+ e_client_get_source (E_CLIENT (client)));
e_cal_component_get_uid (comp, &uid);
if (!(flags & COMP_EDITOR_DELEGATE)
@@ -1337,7 +1341,7 @@ event_page_fill_component (CompEditorPage *page,
{
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
EventPage *epage;
EventPagePrivate *priv;
ECalComponentClassification classification;
@@ -1622,7 +1626,7 @@ event_page_fill_component (CompEditorPage *page,
gchar *name;
gchar *mailto;
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
/* Find the identity for the organizer or sentby field */
if (!get_current_identity (epage, &name, &mailto)) {
@@ -2172,7 +2176,7 @@ attendee_added_cb (EMeetingListView *emlv,
EventPagePrivate *priv = epage->priv;
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
client = comp_editor_get_client (editor);
@@ -2186,7 +2190,7 @@ attendee_added_cb (EMeetingListView *emlv,
/* do not remove here, it did EMeetingListView already */
e_meeting_attendee_set_delfrom (ia, g_strdup_printf ("MAILTO:%s", priv->user_add ? priv->user_add : ""));
- if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) {
+ if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) {
EMeetingAttendee *delegator;
gtk_widget_set_sensitive (priv->invite, FALSE);
@@ -2822,7 +2826,7 @@ event_page_send_options_clicked_cb (EventPage *epage)
CompEditor *editor;
GtkWidget *toplevel;
ESource *source;
- ECal *client;
+ ECalClient *client;
priv = epage->priv;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
@@ -2836,7 +2840,7 @@ event_page_send_options_clicked_cb (EventPage *epage)
priv->sod->data->initialized = TRUE;
}
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) {
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) {
e_send_options_set_need_general_options (priv->sod, FALSE);
}
@@ -2850,25 +2854,28 @@ source_changed_cb (ESourceComboBox *source_combo_box, EventPage *epage)
EventPagePrivate *priv = epage->priv;
CompEditor *editor;
ESource *source;
- ECal *client;
+ ECalClient *client;
+ GError *error = NULL;
if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (epage)))
return;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
source = e_source_combo_box_get_active (source_combo_box);
- client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
+ client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &error);
if (client) {
icaltimezone *zone;
zone = e_meeting_store_get_timezone (epage->priv->meeting_store);
- e_cal_set_default_timezone (client, zone, NULL);
+ e_cal_client_set_default_timezone (client, zone);
+
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
}
- if (!client || !e_cal_open (client, FALSE, NULL)) {
+ if (!client || !e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error)) {
GtkWidget *dialog;
- ECal *old_client;
+ ECalClient *old_client;
old_client = comp_editor_get_client (editor);
@@ -2877,17 +2884,21 @@ source_changed_cb (ESourceComboBox *source_combo_box, EventPage *epage)
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_selector),
- e_cal_get_source (old_client));
+ e_client_get_source (E_CLIENT (old_client)));
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- _("Unable to open the calendar '%s'."),
- e_source_peek_name (source));
+ _("Unable to open the calendar '%s': %s"),
+ e_source_peek_name (source),
+ error ? error->message : _("Unknown error"));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+
+ if (error)
+ g_error_free (error);
} else {
comp_editor_set_client (editor, client);
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_meeting)
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_meeting)
event_page_show_options (epage);
else
event_page_hide_options (epage);
@@ -2895,7 +2906,7 @@ source_changed_cb (ESourceComboBox *source_combo_box, EventPage *epage)
if (client) {
gchar *backend_addr = NULL;
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
if (priv->is_meeting)
event_page_select_organizer (epage, backend_addr);
@@ -2914,12 +2925,12 @@ static void
set_subscriber_info_string (EventPage *epage, const gchar *backend_address)
{
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
ESource *source;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
client = comp_editor_get_client (editor);
- source = e_cal_get_source (client);
+ source = e_client_get_source (E_CLIENT (client));
if (e_source_get_property (source, "subscriber")) {
g_free (epage->priv->subscriber_info_text);
@@ -3033,7 +3044,7 @@ alarm_custom_clicked_cb (GtkWidget *widget,
GtkTreeIter iter;
gboolean valid_iter;
GtkWidget *toplevel;
- ECal *client;
+ ECalClient *client;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
client = comp_editor_get_client (editor);
@@ -3084,7 +3095,7 @@ init_widgets (EventPage *epage)
GtkAction *action;
GtkTreeSelection *selection;
gboolean active;
- ECal *client;
+ ECalClient *client;
GtkTreeIter iter;
GtkListStore *store;
@@ -3328,7 +3339,7 @@ event_page_select_organizer (EventPage *epage, const gchar *backend_address)
{
EventPagePrivate *priv = epage->priv;
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
const gchar *default_address;
gboolean subscribed_cal = FALSE;
ESource *source = NULL;
@@ -3339,7 +3350,7 @@ event_page_select_organizer (EventPage *epage, const gchar *backend_address)
client = comp_editor_get_client (editor);
if (client)
- source = e_cal_get_source (client);
+ source = e_client_get_source (E_CLIENT (client));
if (source)
user_addr = e_source_get_property (source, "subscriber");
diff --git a/calendar/gui/dialogs/goto-dialog.c b/calendar/gui/dialogs/goto-dialog.c
index bc20baa7c2..3ef0db31bf 100644
--- a/calendar/gui/dialogs/goto-dialog.c
+++ b/calendar/gui/dialogs/goto-dialog.c
@@ -89,7 +89,7 @@ ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data)
{
GoToDialog *dlg = user_data;
ECalModel *model;
- ECal *client;
+ ECalClient *client;
model = gnome_calendar_get_model (dlg->gcal);
client = e_cal_model_get_default_client (model);
diff --git a/calendar/gui/dialogs/memo-editor.c b/calendar/gui/dialogs/memo-editor.c
index 2f64910cab..e7dd1e7f93 100644
--- a/calendar/gui/dialogs/memo-editor.c
+++ b/calendar/gui/dialogs/memo-editor.c
@@ -158,7 +158,7 @@ memo_editor_init (MemoEditor *me)
/**
* memo_editor_new:
- * @client: an ECal
+ * @client: an #ECalClient
*
* Creates a new event editor dialog.
*
@@ -166,11 +166,11 @@ memo_editor_init (MemoEditor *me)
* editor could not be created.
**/
CompEditor *
-memo_editor_new (ECal *client,
+memo_editor_new (ECalClient *client,
EShell *shell,
CompEditorFlags flags)
{
- g_return_val_if_fail (E_IS_CAL (client), NULL);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL);
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
return g_object_new (
diff --git a/calendar/gui/dialogs/memo-editor.h b/calendar/gui/dialogs/memo-editor.h
index cd4bc194ac..a5d32c07eb 100644
--- a/calendar/gui/dialogs/memo-editor.h
+++ b/calendar/gui/dialogs/memo-editor.h
@@ -67,7 +67,7 @@ struct _MemoEditorClass {
};
GType memo_editor_get_type (void);
-CompEditor * memo_editor_new (ECal *client,
+CompEditor * memo_editor_new (ECalClient *client,
EShell *shell,
CompEditorFlags flags);
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index e055072959..d720e91b1d 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -34,6 +34,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libedataserverui/e-category-completion.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-combo-box.h>
#include <libedataserverui/e-name-selector.h>
#include <libedataserverui/e-name-selector-entry.h>
@@ -48,7 +49,6 @@
#include "e-util/e-dialog-widgets.h"
#include "e-util/e-util-private.h"
-#include "common/authentication.h"
#include "../calendar-config.h"
#include "comp-editor.h"
#include "comp-editor-util.h"
@@ -242,7 +242,7 @@ memo_page_fill_widgets (CompEditorPage *page,
MemoPagePrivate *priv;
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
ECalComponentClassification cl;
ECalComponentText text;
ECalComponentDateTime d;
@@ -297,7 +297,7 @@ memo_page_fill_widgets (CompEditorPage *page,
e_cal_component_get_categories (comp, &categories);
e_dialog_editable_set (priv->categories, categories);
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
set_subscriber_info_string (mpage, backend_addr);
if (e_cal_component_has_organizer (comp)) {
@@ -333,7 +333,7 @@ memo_page_fill_widgets (CompEditorPage *page,
/* Source */
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_selector),
- e_cal_get_source (client));
+ e_client_get_source (E_CLIENT (client)));
if (priv->to_entry && (flags & COMP_EDITOR_IS_SHARED) && !(flags & COMP_EDITOR_NEW_ITEM))
gtk_entry_set_text (GTK_ENTRY (priv->to_entry), get_recipients (comp));
@@ -403,7 +403,7 @@ sensitize_widgets (MemoPage *mpage)
CompEditor *editor;
CompEditorFlags flags;
MemoPagePrivate *priv;
- ECal *client;
+ ECalClient *client;
priv = mpage->priv;
@@ -411,8 +411,7 @@ sensitize_widgets (MemoPage *mpage)
client = comp_editor_get_client (editor);
flags = comp_editor_get_flags (editor);
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
+ read_only = e_client_is_readonly (E_CLIENT (client));
if (flags & COMP_EDITOR_IS_SHARED)
sens = flags & COMP_EDITOR_USER_ORG;
@@ -511,53 +510,51 @@ fill_comp_with_recipients (ENameSelector *name_selector, ECalComponent *comp)
/* check if the contact is contact list which is not expanded yet */
/* we expand it by getting the list again from the server forming the query */
if (contact && e_contact_get (contact , E_CONTACT_IS_LIST)) {
- EBook *book = NULL;
+ EBookClient *book_client = NULL;
ENameSelectorDialog *dialog;
ENameSelectorModel *model;
EContactStore *c_store;
- GList *books, *l;
+ GSList *clients, *l;
gchar *uri = e_contact_get (contact, E_CONTACT_BOOK_URI);
dialog = e_name_selector_peek_dialog (name_selector);
model = e_name_selector_dialog_peek_model (dialog);
c_store = e_name_selector_model_peek_contact_store (model);
- books = e_contact_store_get_books (c_store);
+ clients = e_contact_store_get_clients (c_store);
- for (l = books; l; l = l->next) {
- EBook *b = l->data;
- if (g_str_equal (uri, e_book_get_uri (b))) {
- book = b;
+ for (l = clients; l; l = l->next) {
+ EBookClient *b = l->data;
+ if (g_str_equal (uri, e_client_get_uri (E_CLIENT (b)))) {
+ book_client = b;
break;
}
}
- if (book) {
- GList *contacts = NULL;
+ if (book_client) {
+ GSList *contacts = NULL;
EContact *n_con = NULL;
- gchar *qu;
- EBookQuery *query;
+ gchar *query;
- qu = g_strdup_printf ("(is \"full_name\" \"%s\")",
+ query = g_strdup_printf ("(is \"full_name\" \"%s\")",
(gchar *) e_contact_get (contact, E_CONTACT_FULL_NAME));
- query = e_book_query_from_string (qu);
- if (!e_book_get_contacts (book, query, &contacts, NULL)) {
+ if (!e_book_client_get_contacts_sync (book_client, query, &contacts, NULL, NULL)) {
g_warning ("Could not get contact from the book \n");
} else {
des = e_destination_new ();
n_con = contacts->data;
e_destination_set_contact (des, n_con, 0);
+ e_destination_set_client (des, book_client);
list_dests = e_destination_list_get_dests (des);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
+ g_slist_free (contacts);
}
- e_book_query_unref (query);
- g_free (qu);
+ g_free (query);
}
- g_list_free (books);
+ g_slist_free (clients);
} else {
card_dest.next = NULL;
card_dest.prev = NULL;
@@ -611,7 +608,7 @@ memo_page_fill_component (CompEditorPage *page,
MemoPagePrivate *priv;
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
ECalComponentClassification classification;
ECalComponentDateTime start_date;
struct icaltimetype start_tt;
@@ -724,7 +721,7 @@ memo_page_fill_component (CompEditorPage *page,
gchar *name;
gchar *mailto;
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
/* Find the identity for the organizer or sentby field */
if (!get_current_identity (mpage, &name, &mailto)) {
@@ -888,7 +885,8 @@ source_changed_cb (ESourceComboBox *source_combo_box,
CompEditor *editor;
CompEditorFlags flags;
ESource *source;
- ECal *client;
+ ECalClient *client;
+ GError *error = NULL;
if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (mpage)))
return;
@@ -897,11 +895,14 @@ source_changed_cb (ESourceComboBox *source_combo_box,
flags = comp_editor_get_flags (editor);
source = e_source_combo_box_get_active (source_combo_box);
- client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
+ client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, &error);
- if (!client || !e_cal_open (client, FALSE, NULL)) {
+ if (client)
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!client || !e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error)) {
GtkWidget *dialog;
- ECal *old_client;
+ ECalClient *old_client;
old_client = comp_editor_get_client (editor);
@@ -910,21 +911,25 @@ source_changed_cb (ESourceComboBox *source_combo_box,
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_selector),
- e_cal_get_source (old_client));
+ e_client_get_source (E_CLIENT (old_client)));
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- _("Unable to open memos in '%s'."),
- e_source_peek_name (source));
+ _("Unable to open memos in '%s': %s"),
+ e_source_peek_name (source),
+ error ? error->message : _("Unknown error"));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+
+ if (error)
+ g_error_free (error);
} else {
comp_editor_set_client (editor, client);
if (client) {
gchar *backend_addr = NULL;
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
if (flags & COMP_EDITOR_IS_SHARED)
memo_page_select_organizer (mpage, backend_addr);
@@ -942,12 +947,12 @@ set_subscriber_info_string (MemoPage *mpage,
const gchar *backend_address)
{
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
ESource *source;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (mpage));
client = comp_editor_get_client (editor);
- source = e_cal_get_source (client);
+ source = e_client_get_source (E_CLIENT (client));
if (e_source_get_property (source, "subscriber")) {
g_free (mpage->priv->subscriber_info_text);
@@ -1097,7 +1102,7 @@ memo_page_select_organizer (MemoPage *mpage, const gchar *backend_address)
MemoPagePrivate *priv;
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
const gchar *default_address;
gboolean subscribed_cal = FALSE;
ESource *source = NULL;
@@ -1110,7 +1115,7 @@ memo_page_select_organizer (MemoPage *mpage, const gchar *backend_address)
flags = comp_editor_get_flags (editor);
if (client)
- source = e_cal_get_source (client);
+ source = e_client_get_source (E_CLIENT (client));
if (source)
user_addr = e_source_get_property (source, "subscriber");
diff --git a/calendar/gui/dialogs/recur-comp.c b/calendar/gui/dialogs/recur-comp.c
index 7793647723..3514c03dbf 100644
--- a/calendar/gui/dialogs/recur-comp.c
+++ b/calendar/gui/dialogs/recur-comp.c
@@ -32,7 +32,7 @@
gboolean
-recur_component_dialog (ECal *client,
+recur_component_dialog (ECalClient *client,
ECalComponent *comp,
CalObjModType *mod,
GtkWindow *parent, gboolean delegated)
@@ -90,13 +90,13 @@ recur_component_dialog (ECal *client,
rb_this = gtk_radio_button_new_with_label (NULL, _("This Instance Only"));
gtk_container_add (GTK_CONTAINER (vbox), rb_this);
- if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) {
+ if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) {
rb_prior = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Prior Instances"));
gtk_container_add (GTK_CONTAINER (vbox), rb_prior);
} else
rb_prior = NULL;
- if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) {
+ if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) {
rb_future = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Future Instances"));
gtk_container_add (GTK_CONTAINER (vbox), rb_future);
} else
diff --git a/calendar/gui/dialogs/recur-comp.h b/calendar/gui/dialogs/recur-comp.h
index 47236ef8cd..7087daa166 100644
--- a/calendar/gui/dialogs/recur-comp.h
+++ b/calendar/gui/dialogs/recur-comp.h
@@ -26,11 +26,11 @@
#define RECUR_COMP_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
#include <libecal/e-cal-util.h>
-gboolean recur_component_dialog (ECal *client,
+gboolean recur_component_dialog (ECalClient *client,
ECalComponent *comp,
CalObjModType *mod,
GtkWindow *parent,
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index 8d2701fab2..bf8f1c191c 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -212,7 +212,7 @@ preview_recur (RecurrencePage *rpage)
{
RecurrencePagePrivate *priv = rpage->priv;
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
ECalComponent *comp;
ECalComponentDateTime cdt;
GSList *l;
@@ -236,8 +236,8 @@ preview_recur (RecurrencePage *rpage)
e_cal_component_get_dtstart (priv->comp, &cdt);
if (cdt.tzid != NULL) {
- /* FIXME Will e_cal_get_timezone really not return builtin zones? */
- if (!e_cal_get_timezone (client, cdt.tzid, &zone, NULL))
+ /* FIXME Will e_cal_client_get_timezone_sync really not return builtin zones? */
+ if (!e_cal_client_get_timezone_sync (client, cdt.tzid, &zone, NULL, NULL))
zone = icaltimezone_get_builtin_timezone_from_tzid (cdt.tzid);
}
e_cal_component_set_dtstart (comp, &cdt);
@@ -586,7 +586,7 @@ sensitize_buttons (RecurrencePage *rpage)
gboolean read_only, sensitize = TRUE;
gint selected_rows;
icalcomponent *icalcomp;
- ECal *client;
+ ECalClient *client;
const gchar *uid;
if (priv->comp == NULL)
@@ -602,27 +602,26 @@ sensitize_buttons (RecurrencePage *rpage)
selected_rows = gtk_tree_selection_count_selected_rows (
gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->exception_list)));
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
+ read_only = e_client_is_readonly (E_CLIENT (client));
if (!read_only) {
e_cal_component_get_uid (priv->comp, &uid);
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR) && e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) {
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR) && e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL)) {
read_only = TRUE;
icalcomponent_free (icalcomp);
}
if (!read_only) {
- GList *list;
+ GSList *list = NULL;
/* see if we have detached instances */
- if (e_cal_get_objects_for_uid (client, uid, &list, NULL)) {
- if (list && g_list_length (list) > 1)
+ if (e_cal_client_get_objects_for_uid_sync (client, uid, &list, NULL, NULL)) {
+ if (list && g_slist_length (list) > 1)
read_only = TRUE;
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ g_slist_foreach (list, (GFunc) g_object_unref, NULL);
+ g_slist_free (list);
}
}
}
@@ -1485,7 +1484,7 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r)
{
RecurrencePagePrivate *priv = rpage->priv;
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage));
client = comp_editor_get_client (editor);
@@ -1512,9 +1511,16 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r)
to_zone = e_meeting_store_get_timezone (priv->meeting_store);
else if (dt.tzid == NULL)
to_zone = icaltimezone_get_utc_timezone ();
- else
+ else {
+ GError *error = NULL;
/* FIXME Error checking? */
- e_cal_get_timezone (client, dt.tzid, &to_zone, NULL);
+ e_cal_client_get_timezone_sync (client, dt.tzid, &to_zone, NULL, &error);
+
+ if (error) {
+ g_debug ("%s: Failed to get timezone: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+ }
from_zone = icaltimezone_get_utc_timezone ();
icaltimezone_convert_time (&r->until, from_zone, to_zone);
@@ -2069,7 +2075,7 @@ type_toggled_cb (GtkToggleButton *toggle,
{
RecurrencePagePrivate *priv = rpage->priv;
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
gboolean read_only;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage));
@@ -2079,8 +2085,7 @@ type_toggled_cb (GtkToggleButton *toggle,
sensitize_buttons (rpage);
/* enable/disable the 'Add' button */
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
+ read_only = e_client_is_readonly (E_CLIENT (client));
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->recurs)) || read_only)
gtk_widget_set_sensitive (priv->exception_add, FALSE);
diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c
index 26ea1cdf5c..c4191e68dc 100644
--- a/calendar/gui/dialogs/schedule-page.c
+++ b/calendar/gui/dialogs/schedule-page.c
@@ -68,16 +68,12 @@ sensitize_widgets (SchedulePage *spage)
{
SchedulePagePrivate *priv = spage->priv;
CompEditor *editor;
- ECal *client;
- gboolean read_only;
+ ECalClient *client;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (spage));
client = comp_editor_get_client (editor);
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
-
- e_meeting_time_selector_set_read_only (priv->sel, read_only);
+ e_meeting_time_selector_set_read_only (priv->sel, e_client_is_readonly (E_CLIENT (client)));
}
/* Set date/time */
@@ -90,30 +86,43 @@ update_time (SchedulePage *spage,
CompEditor *editor;
struct icaltimetype start_tt, end_tt;
icaltimezone *start_zone = NULL, *end_zone = NULL;
- ECal *client;
+ ECalClient *client;
gboolean all_day;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (spage));
client = comp_editor_get_client (editor);
- /* Note that if we are creating a new event, the timezones may not be
- on the server, so we try to get the builtin timezone with the TZID
- first. */
- start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid);
- if (!start_zone) {
- if (!e_cal_get_timezone (client, start_date->tzid, &start_zone, NULL)) {
- /* FIXME: Handle error better. */
- g_warning ("Couldn't get timezone from server: %s",
- start_date->tzid ? start_date->tzid : "");
+ if (start_date->tzid) {
+ /* Note that if we are creating a new event, the timezones may not be
+ on the server, so we try to get the builtin timezone with the TZID
+ first. */
+ start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid);
+ if (!start_zone) {
+ GError *error = NULL;
+
+ if (!e_cal_client_get_timezone_sync (client, start_date->tzid, &start_zone, NULL, &error)) {
+ /* FIXME: Handle error better. */
+ g_warning ("Couldn't get timezone '%s' from server: %s",
+ start_date->tzid ? start_date->tzid : "",
+ error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ }
}
}
- end_zone = icaltimezone_get_builtin_timezone_from_tzid (end_date->tzid);
- if (!end_zone) {
- if (!e_cal_get_timezone (client, end_date->tzid, &end_zone, NULL)) {
- /* FIXME: Handle error better. */
- g_warning ("Couldn't get timezone from server: %s",
- end_date->tzid ? end_date->tzid : "");
+ if (end_date->tzid) {
+ end_zone = icaltimezone_get_builtin_timezone_from_tzid (end_date->tzid);
+ if (!end_zone) {
+ GError *error = NULL;
+ if (!e_cal_client_get_timezone_sync (client, end_date->tzid, &end_zone, NULL, &error)) {
+ /* FIXME: Handle error better. */
+ g_warning ("Couldn't get timezone '%s' from server: %s",
+ end_date->tzid ? end_date->tzid : "",
+ error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ }
}
}
diff --git a/calendar/gui/dialogs/select-source-dialog.c b/calendar/gui/dialogs/select-source-dialog.c
index 79905d5f01..4ae9f0a0d8 100644
--- a/calendar/gui/dialogs/select-source-dialog.c
+++ b/calendar/gui/dialogs/select-source-dialog.c
@@ -35,7 +35,7 @@
* Implements dialog for allowing user to select a destination source.
*/
ESource *
-select_source_dialog (GtkWindow *parent, ECalSourceType obj_type, ESource *except_source)
+select_source_dialog (GtkWindow *parent, ECalClientSourceType obj_type, ESource *except_source)
{
GtkWidget *dialog;
ESourceList *source_list;
@@ -44,11 +44,11 @@ select_source_dialog (GtkWindow *parent, ECalSourceType obj_type, ESource *excep
GConfClient *conf_client;
const gchar *icon_name = NULL;
- if (obj_type == E_CAL_SOURCE_TYPE_EVENT)
+ if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
gconf_key = "/apps/evolution/calendar/sources";
- else if (obj_type == E_CAL_SOURCE_TYPE_TODO)
+ else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS)
gconf_key = "/apps/evolution/tasks/sources";
- else if (obj_type == E_CAL_SOURCE_TYPE_JOURNAL)
+ else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
gconf_key = "/apps/evolution/memos/sources";
else
return NULL;
@@ -59,11 +59,11 @@ select_source_dialog (GtkWindow *parent, ECalSourceType obj_type, ESource *excep
/* create the dialog */
dialog = e_source_selector_dialog_new (parent, source_list);
- if (obj_type == E_CAL_SOURCE_TYPE_EVENT)
+ if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
icon_name = "x-office-calendar";
- else if (obj_type == E_CAL_SOURCE_TYPE_TODO)
+ else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_TASKS)
icon_name = "stock_todo";
- else if (obj_type == E_CAL_SOURCE_TYPE_JOURNAL)
+ else if (obj_type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
icon_name = "stock_journal";
if (icon_name)
diff --git a/calendar/gui/dialogs/select-source-dialog.h b/calendar/gui/dialogs/select-source-dialog.h
index 902ac3fc03..6d64fb825a 100644
--- a/calendar/gui/dialogs/select-source-dialog.h
+++ b/calendar/gui/dialogs/select-source-dialog.h
@@ -28,8 +28,8 @@
#include <gtk/gtk.h>
#include <libedataserver/e-source.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
-ESource *select_source_dialog (GtkWindow *parent, ECalSourceType type, ESource *except_source);
+ESource *select_source_dialog (GtkWindow *parent, ECalClientSourceType type, ESource *except_source);
#endif
diff --git a/calendar/gui/dialogs/send-comp.c b/calendar/gui/dialogs/send-comp.c
index 070fb6b735..d67d9fb626 100644
--- a/calendar/gui/dialogs/send-comp.c
+++ b/calendar/gui/dialogs/send-comp.c
@@ -133,7 +133,7 @@ add_checkbox (GtkBox *where, const gchar *caption)
* Return value: TRUE if the user clicked Yes, FALSE otherwise.
**/
gboolean
-send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees)
+send_component_dialog (GtkWindow *parent, ECalClient *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees)
{
ECalComponentVType vtype;
const gchar *id;
@@ -144,7 +144,7 @@ send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gbo
if (strip_alarms)
*strip_alarms = TRUE;
- if (e_cal_get_save_schedules (client) || !component_has_recipients (comp))
+ if (e_cal_client_check_save_schedules (client) || !component_has_recipients (comp))
return FALSE;
vtype = e_cal_component_get_vtype (comp);
@@ -206,7 +206,7 @@ send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gbo
}
gboolean
-send_component_prompt_subject (GtkWindow *parent, ECal *client, ECalComponent *comp)
+send_component_prompt_subject (GtkWindow *parent, ECalClient *client, ECalComponent *comp)
{
ECalComponentVType vtype;
const gchar *id;
diff --git a/calendar/gui/dialogs/send-comp.h b/calendar/gui/dialogs/send-comp.h
index 83f356b142..91584a7f4b 100644
--- a/calendar/gui/dialogs/send-comp.h
+++ b/calendar/gui/dialogs/send-comp.h
@@ -25,10 +25,10 @@
#define SEND_COMP_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
-gboolean send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees);
-gboolean send_component_prompt_subject (GtkWindow *parent, ECal *client, ECalComponent *comp);
+gboolean send_component_dialog (GtkWindow *parent, ECalClient *client, ECalComponent *comp, gboolean new, gboolean *strip_alarms, gboolean *only_new_attendees);
+gboolean send_component_prompt_subject (GtkWindow *parent, ECalClient *client, ECalComponent *comp);
#endif
diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c
index 7f72dd3e38..bc828cf431 100644
--- a/calendar/gui/dialogs/task-details-page.c
+++ b/calendar/gui/dialogs/task-details-page.c
@@ -149,14 +149,13 @@ sensitize_widgets (TaskDetailsPage *tdpage)
TaskDetailsPagePrivate *priv = tdpage->priv;
CompEditor *editor;
GtkWidget *entry;
- ECal *client;
+ ECalClient *client;
gboolean read_only;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage));
client = comp_editor_get_client (editor);
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
+ read_only = e_client_is_readonly (E_CLIENT (client));
gtk_widget_set_sensitive (priv->status_combo, !read_only);
gtk_widget_set_sensitive (priv->priority_combo, !read_only);
diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c
index f24db192b2..1e859cb293 100644
--- a/calendar/gui/dialogs/task-editor.c
+++ b/calendar/gui/dialogs/task-editor.c
@@ -148,7 +148,7 @@ task_editor_constructor (GType type,
CompEditorFlags flags;
TaskEditorPrivate *priv;
GtkActionGroup *action_group;
- ECal *client;
+ ECalClient *client;
gboolean is_assigned;
/* Chain up to parent's constructor() method. */
@@ -168,8 +168,7 @@ task_editor_constructor (GType type,
gtk_action_group_set_visible (action_group, is_assigned);
if (is_assigned) {
- if (e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS))
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS))
task_page_show_options (priv->task_page);
comp_editor_set_group_item (editor, TRUE);
}
@@ -380,7 +379,7 @@ task_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
{
TaskEditorPrivate *priv;
ECalComponentOrganizer organizer;
- ECal *client;
+ ECalClient *client;
GSList *attendees = NULL;
priv = TASK_EDITOR_GET_PRIVATE (editor);
@@ -429,7 +428,7 @@ task_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
if (ia != NULL)
e_meeting_attendee_set_edit_level (ia, E_MEETING_ATTENDEE_EDIT_STATUS);
- } else if (e_cal_get_organizer_must_attend (client)) {
+ } else if (e_cal_client_check_organizer_must_attend (client)) {
EMeetingAttendee *ia;
ia = e_meeting_store_find_attendee (priv->model, organizer.value, &row);
@@ -466,7 +465,7 @@ task_editor_send_comp (CompEditor *editor,
comp = task_page_get_cancel_comp (priv->task_page);
if (comp != NULL) {
- ECal *client;
+ ECalClient *client;
gboolean result;
client = e_meeting_store_get_client (priv->model);
@@ -488,7 +487,7 @@ task_editor_send_comp (CompEditor *editor,
/**
* task_editor_new:
- * @client: a ECal
+ * @client: a ECalClient
*
* Creates a new event editor dialog.
*
@@ -496,11 +495,11 @@ task_editor_send_comp (CompEditor *editor,
* editor could not be created.
**/
CompEditor *
-task_editor_new (ECal *client,
+task_editor_new (ECalClient *client,
EShell *shell,
CompEditorFlags flags)
{
- g_return_val_if_fail (E_IS_CAL (client), NULL);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL);
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
return g_object_new (
diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h
index f026acae0c..0808cd547d 100644
--- a/calendar/gui/dialogs/task-editor.h
+++ b/calendar/gui/dialogs/task-editor.h
@@ -65,7 +65,7 @@ struct _TaskEditorClass {
};
GType task_editor_get_type (void);
-CompEditor * task_editor_new (ECal *client,
+CompEditor * task_editor_new (ECalClient *client,
EShell *shell,
CompEditorFlags flags);
void task_editor_show_assignment (TaskEditor *te);
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index bb18780250..12902ff6d4 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -34,11 +34,11 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <libedataserverui/e-category-completion.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-combo-box.h>
#include <misc/e-dateedit.h>
#include "misc/e-buffer-tagger.h"
#include <e-util/e-dialog-utils.h>
-#include "common/authentication.h"
#include "../e-timezone-entry.h"
#include "comp-editor.h"
#include "comp-editor-util.h"
@@ -111,7 +111,7 @@ struct _TaskPagePrivate {
GtkWidget *attendees_label;
/* ListView stuff */
- ECal *client;
+ ECalClient *client;
EMeetingStore *meeting_store;
EMeetingListView *list_view;
gint row;
@@ -264,7 +264,7 @@ sensitize_widgets (TaskPage *tpage)
TaskPagePrivate *priv = tpage->priv;
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
GtkActionGroup *action_group;
GtkAction *action;
gboolean read_only, sens = TRUE, sensitize;
@@ -273,8 +273,7 @@ sensitize_widgets (TaskPage *tpage)
client = comp_editor_get_client (editor);
flags = comp_editor_get_flags (editor);
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
+ read_only = e_client_is_readonly (E_CLIENT (client));
if (flags & COMP_EDITOR_IS_ASSIGNED)
sens = flags & COMP_EDITOR_USER_ORG;
@@ -473,7 +472,7 @@ task_page_fill_widgets (CompEditorPage *page,
CompEditor *editor;
CompEditorFlags flags;
GtkAction *action;
- ECal *client;
+ ECalClient *client;
GSList *l;
icalcomponent *icalcomp;
const gchar *categories, *uid;
@@ -555,10 +554,13 @@ task_page_fill_widgets (CompEditorPage *page,
on the server, so we try to get the builtin timezone with the TZID
first. */
if (!zone && d.tzid) {
- if (!e_cal_get_timezone (client, d.tzid, &zone, NULL))
+ GError *error = NULL;
+ if (!e_cal_client_get_timezone_sync (client, d.tzid, &zone, NULL, &error))
/* FIXME: Handle error better. */
- g_warning ("Couldn't get timezone from server: %s",
- d.tzid ? d.tzid : "");
+ g_warning ("Couldn't get timezone '%s' from server: %s",
+ d.tzid ? d.tzid : "", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
}
e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->timezone),
@@ -611,7 +613,7 @@ task_page_fill_widgets (CompEditorPage *page,
comp_editor_set_classification (editor, cl);
e_cal_component_get_uid (comp, &uid);
- if (e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) {
+ if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL)) {
icalcomponent_free (icalcomp);
task_page_hide_options (tpage);
}
@@ -623,9 +625,9 @@ task_page_fill_widgets (CompEditorPage *page,
/* Source */
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_selector),
- e_cal_get_source (client));
+ e_client_get_source (E_CLIENT (client)));
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
set_subscriber_info_string (tpage, backend_addr);
if (priv->is_assignment) {
@@ -646,14 +648,10 @@ task_page_fill_widgets (CompEditorPage *page,
gchar *string;
if (itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp, client)) {
- if (e_cal_get_static_capability (
- client,
- CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS))
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS))
priv->user_org = TRUE;
} else {
- if (e_cal_get_static_capability (
- client,
- CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS))
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS))
gtk_widget_set_sensitive (priv->invite, FALSE);
gtk_widget_set_sensitive (priv->add, FALSE);
gtk_widget_set_sensitive (priv->edit, FALSE);
@@ -661,7 +659,7 @@ task_page_fill_widgets (CompEditorPage *page,
priv->user_org = FALSE;
}
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE))
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (flags & COMP_EDITOR_DELEGATE))
string = g_strdup (priv->user_add);
else if ( organizer.cn != NULL)
string = g_strdup_printf ("%s <%s>", organizer.cn, strip);
@@ -714,7 +712,7 @@ task_page_fill_widgets (CompEditorPage *page,
backend_mailto = mailto = NULL;
}
- if (client && e_cal_get_organizer_must_accept (client))
+ if (client && e_cal_client_check_organizer_must_accept (client))
e_meeting_attendee_set_status (
attendee, ICAL_PARTSTAT_NEEDSACTION);
else
@@ -748,7 +746,7 @@ task_page_fill_component (CompEditorPage *page,
ECalComponentDateTime date;
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
struct icaltimetype start_tt, due_tt;
gchar *cat, *str;
gboolean start_date_set, due_date_set, time_set;
@@ -898,7 +896,7 @@ task_page_fill_component (CompEditorPage *page,
gchar *name;
gchar *mailto;
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
/* Find the identity for the organizer or sentby field */
if (!get_current_identity (tpage, &name, &mailto)) {
@@ -1314,7 +1312,7 @@ attendee_added_cb (EMeetingListView *emlv,
TaskPagePrivate *priv = page->priv;
CompEditor *editor;
CompEditorFlags flags;
- ECal *client;
+ ECalClient *client;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (page));
client = comp_editor_get_client (editor);
@@ -1328,7 +1326,7 @@ attendee_added_cb (EMeetingListView *emlv,
/* do not remove here, it did EMeetingListView already */
e_meeting_attendee_set_delfrom (ia, g_strdup_printf ("MAILTO:%s", priv->user_add ? priv->user_add : ""));
- if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) {
+ if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) {
EMeetingAttendee *delegator;
gtk_widget_set_sensitive (priv->invite, FALSE);
@@ -1773,7 +1771,8 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage)
TaskPagePrivate *priv = tpage->priv;
CompEditor *editor;
ESource *source;
- ECal *client;
+ ECalClient *client;
+ GError *error = NULL;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage));
source = e_source_combo_box_get_active (source_combo_box);
@@ -1781,15 +1780,18 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage)
if (comp_editor_page_get_updating (COMP_EDITOR_PAGE (tpage)))
return;
- client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
+ client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_TASKS, &error);
if (client) {
icaltimezone *zone;
zone = comp_editor_get_timezone (editor);
- e_cal_set_default_timezone (client, zone, NULL);
+ e_cal_client_set_default_timezone (client, zone);
}
- if (!client || !e_cal_open (client, FALSE, NULL)) {
+ if (client)
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!client || !e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error)) {
GtkWidget *dialog;
if (client)
@@ -1799,18 +1801,22 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage)
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_selector),
- e_cal_get_source (client));
+ e_client_get_source (E_CLIENT (client)));
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
- _("Unable to open tasks in '%s'."),
- e_source_peek_name (source));
+ _("Unable to open tasks in '%s': %s"),
+ e_source_peek_name (source),
+ error ? error->message : _("Unknown error"));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+
+ if (error)
+ g_error_free (error);
} else {
comp_editor_set_client (editor, client);
comp_editor_page_changed (COMP_EDITOR_PAGE (tpage));
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_assignment)
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_assignment)
task_page_show_options (tpage);
else
task_page_hide_options (tpage);
@@ -1818,7 +1824,7 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage)
if (client) {
gchar *backend_addr = NULL;
- e_cal_get_cal_address (client, &backend_addr, NULL);
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &backend_addr, NULL, NULL);
if (priv->is_assignment)
task_page_select_organizer (tpage, backend_addr);
@@ -1835,12 +1841,12 @@ static void
set_subscriber_info_string (TaskPage *tpage, const gchar *backend_address)
{
CompEditor *editor;
- ECal *client;
+ ECalClient *client;
ESource *source;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage));
client = comp_editor_get_client (editor);
- source = e_cal_get_source (client);
+ source = e_client_get_source (E_CLIENT (client));
if (e_source_get_property (source, "subscriber")) {
g_free (tpage->priv->subscriber_info_text);
@@ -1863,7 +1869,7 @@ task_page_send_options_clicked_cb (TaskPage *tpage)
CompEditor *editor;
GtkWidget *toplevel;
ESource *source;
- ECal *client;
+ ECalClient *client;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage));
client = comp_editor_get_client (editor);
@@ -1876,7 +1882,7 @@ task_page_send_options_clicked_cb (TaskPage *tpage)
e_send_options_utils_set_default_data (priv->sod, source, "task");
}
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) {
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)) {
e_send_options_set_need_general_options (priv->sod, FALSE);
}
@@ -2041,7 +2047,7 @@ task_page_select_organizer (TaskPage *tpage, const gchar *backend_address)
const gchar *default_address;
gboolean subscribed_cal = FALSE;
ESource *source = NULL;
- ECal *client;
+ ECalClient *client;
const gchar *user_addr = NULL;
gint ii;
@@ -2049,7 +2055,7 @@ task_page_select_organizer (TaskPage *tpage, const gchar *backend_address)
client = comp_editor_get_client (editor);
if (client)
- source = e_cal_get_source (client);
+ source = e_client_get_source (E_CLIENT (client));
if (source)
user_addr = e_source_get_property (source, "subscriber");
@@ -2094,7 +2100,7 @@ task_page_select_organizer (TaskPage *tpage, const gchar *backend_address)
TaskPage *
task_page_construct (TaskPage *tpage,
EMeetingStore *meeting_store,
- ECal *client)
+ ECalClient *client)
{
TaskPagePrivate *priv;
GtkTreeModel *model;
@@ -2155,7 +2161,7 @@ TaskPage *
task_page_new (EMeetingStore *model, CompEditor *editor)
{
TaskPage *tpage;
- ECal *client;
+ ECalClient *client;
tpage = g_object_new (TYPE_TASK_PAGE, "editor", editor, NULL);
client = comp_editor_get_client (editor);
diff --git a/calendar/gui/dialogs/task-page.h b/calendar/gui/dialogs/task-page.h
index 007dcdeec4..9d713deaef 100644
--- a/calendar/gui/dialogs/task-page.h
+++ b/calendar/gui/dialogs/task-page.h
@@ -72,7 +72,7 @@ struct _TaskPageClass {
GType task_page_get_type (void);
TaskPage * task_page_construct (TaskPage *epage,
EMeetingStore *model,
- ECal *client);
+ ECalClient *client);
TaskPage * task_page_new (EMeetingStore *model,
CompEditor *editor);
ECalComponent * task_page_get_cancel_comp (TaskPage *page);
diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c
index c964a6f1ed..d2c979151f 100644
--- a/calendar/gui/e-cal-component-preview.c
+++ b/calendar/gui/e-cal-component-preview.c
@@ -70,7 +70,7 @@ clear_comp_info (ECalComponentPreview *preview)
returns whether component in the preview changed */
static gboolean
update_comp_info (ECalComponentPreview *preview,
- ECal *ecal,
+ ECalClient *client,
ECalComponent *comp)
{
ECalComponentPreviewPrivate *priv;
@@ -81,7 +81,7 @@ update_comp_info (ECalComponentPreview *preview,
priv = preview->priv;
- if (!E_IS_CAL_COMPONENT (comp) || !E_IS_CAL (ecal)) {
+ if (!E_IS_CAL_COMPONENT (comp) || !E_IS_CAL_CLIENT (client)) {
changed = !priv->cal_uid;
clear_comp_info (preview);
} else {
@@ -92,7 +92,7 @@ update_comp_info (ECalComponentPreview *preview,
gint *sequence = NULL;
gint comp_sequence;
- cal_uid = g_strdup (e_source_peek_uid (e_cal_get_source (ecal)));
+ cal_uid = g_strdup (e_source_peek_uid (e_client_get_source (E_CLIENT (client))));
e_cal_component_get_uid (comp, &uid);
comp_uid = g_strdup (uid);
e_cal_component_get_last_modified (comp, &itm);
@@ -128,7 +128,7 @@ update_comp_info (ECalComponentPreview *preview,
/* Converts a time_t to a string, relative to the specified timezone */
static gchar *
timet_to_str_with_zone (ECalComponentDateTime *dt,
- ECal *ecal,
+ ECalClient *client,
icaltimezone *default_zone,
gboolean use_24_hour_format)
{
@@ -139,7 +139,7 @@ timet_to_str_with_zone (ECalComponentDateTime *dt,
if (dt->tzid) {
/* If we can't find the zone, we'll guess its "local" */
- if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL))
+ if (!e_cal_client_get_timezone_sync (client, dt->tzid, &zone, NULL, NULL))
zone = NULL;
} else if (dt->value->is_utc) {
zone = icaltimezone_get_utc_timezone ();
@@ -161,7 +161,7 @@ timet_to_str_with_zone (ECalComponentDateTime *dt,
static void
cal_component_preview_write_html (GString *buffer,
- ECal *ecal,
+ ECalClient *client,
ECalComponent *comp,
icaltimezone *default_zone,
gboolean use_24_hour_format)
@@ -240,7 +240,7 @@ cal_component_preview_write_html (GString *buffer,
e_cal_component_get_dtstart (comp, &dt);
if (dt.value != NULL) {
str = timet_to_str_with_zone (
- &dt, ecal, default_zone, use_24_hour_format);
+ &dt, client, default_zone, use_24_hour_format);
g_string_append_printf (
buffer, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\">"
"<B>%s</B></TD><TD>%s</TD></TR>",
@@ -254,7 +254,7 @@ cal_component_preview_write_html (GString *buffer,
e_cal_component_get_dtend (comp, &dt);
if (dt.value != NULL) {
str = timet_to_str_with_zone (
- &dt, ecal, default_zone, use_24_hour_format);
+ &dt, client, default_zone, use_24_hour_format);
g_string_append_printf (
buffer, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\">"
"<B>%s</B></TD><TD>%s</TD></TR>",
@@ -268,7 +268,7 @@ cal_component_preview_write_html (GString *buffer,
e_cal_component_get_due (comp, &dt);
if (dt.value != NULL) {
str = timet_to_str_with_zone (
- &dt, ecal, default_zone, use_24_hour_format);
+ &dt, client, default_zone, use_24_hour_format);
g_string_append_printf (
buffer, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\">"
"<B>%s</B></TD><TD>%s</TD></TR>",
@@ -444,7 +444,7 @@ e_cal_component_preview_new (void)
void
e_cal_component_preview_display (ECalComponentPreview *preview,
- ECal *ecal,
+ ECalClient *client,
ECalComponent *comp,
icaltimezone *zone,
gboolean use_24_hour_format)
@@ -456,14 +456,14 @@ e_cal_component_preview_display (ECalComponentPreview *preview,
/* do not update preview when setting the same component as last time,
which even didn't change */
- if (!update_comp_info (preview, ecal, comp))
+ if (!update_comp_info (preview, client, comp))
return;
/* XXX The initial buffer size is arbitrary. Tune it. */
buffer = g_string_sized_new (4096);
cal_component_preview_write_html (
- buffer, ecal, comp, zone, use_24_hour_format);
+ buffer, client, comp, zone, use_24_hour_format);
e_web_view_load_string (E_WEB_VIEW (preview), buffer->str);
g_string_free (buffer, TRUE);
}
diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h
index f713df7321..091f66c252 100644
--- a/calendar/gui/e-cal-component-preview.h
+++ b/calendar/gui/e-cal-component-preview.h
@@ -25,7 +25,7 @@
#define E_CAL_COMPONENT_PREVIEW_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <misc/e-web-view.h>
/* Standard GObject macros */
@@ -69,7 +69,7 @@ struct _ECalComponentPreviewClass {
GType e_cal_component_preview_get_type (void);
GtkWidget * e_cal_component_preview_new (void);
void e_cal_component_preview_display (ECalComponentPreview *preview,
- ECal *ecal,
+ ECalClient *client,
ECalComponent *comp,
icaltimezone *zone,
gboolean use_24_hour_format);
diff --git a/calendar/gui/e-cal-config.h b/calendar/gui/e-cal-config.h
index 7751c3e42f..f803e99285 100644
--- a/calendar/gui/e-cal-config.h
+++ b/calendar/gui/e-cal-config.h
@@ -24,7 +24,7 @@
#ifndef __E_CAL_CONFIG_H__
#define __E_CAL_CONFIG_H__
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include "e-util/e-config.h"
/* Standard GObject macros */
@@ -74,7 +74,7 @@ struct _ECalConfigTargetSource {
EConfigTarget target;
struct _ESource *source;
- ECalSourceType source_type;
+ ECalClientSourceType source_type;
};
struct _ECalConfigTargetPrefs {
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 7893dae0e8..c287b7a6ca 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -102,7 +102,6 @@ e_cal_list_view_class_init (ECalListViewClass *class)
static void
e_cal_list_view_init (ECalListView *cal_list_view)
{
- cal_list_view->query = NULL;
cal_list_view->table = NULL;
cal_list_view->cursor_event = NULL;
cal_list_view->set_table_id = 0;
@@ -330,13 +329,6 @@ e_cal_list_view_dispose (GObject *object)
cal_list_view = E_CAL_LIST_VIEW (object);
- if (cal_list_view->query) {
- g_signal_handlers_disconnect_matched (cal_list_view->query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cal_list_view);
- g_object_unref (cal_list_view->query);
- cal_list_view->query = NULL;
- }
-
if (cal_list_view->set_table_id) {
g_source_remove (cal_list_view->set_table_id);
cal_list_view->set_table_id = 0;
diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h
index faf37bbc9f..ed4636f753 100644
--- a/calendar/gui/e-cal-list-view.h
+++ b/calendar/gui/e-cal-list-view.h
@@ -67,9 +67,6 @@ struct _ECalListView {
/* The main display table */
ETable *table;
- /* S-expression for query and the query object */
- ECalView *query;
-
/* The default category for new events */
gchar *default_category;
diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c
index 4ac73089bb..ea8dd7bba7 100644
--- a/calendar/gui/e-cal-model-calendar.c
+++ b/calendar/gui/e-cal-model-calendar.c
@@ -130,7 +130,7 @@ get_dtend (ECalModelCalendar *model, ECalModelComponent *comp_data)
tt_end = icalproperty_get_dtend (prop);
if (icaltime_get_tzid (tt_end)
- && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_end), &zone, NULL))
+ && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_end), &zone, NULL, NULL))
got_zone = TRUE;
model_zone = e_cal_model_get_timezone (E_CAL_MODEL (model));
@@ -295,6 +295,7 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
CalObjModType mod = CALOBJ_MOD_ALL;
ECalComponent *comp;
ECalModelCalendar *model = (ECalModelCalendar *) etm;
+ GError *error = NULL;
g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model));
g_return_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST);
@@ -335,7 +336,7 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
break;
}
- if (e_cal_modify_object (comp_data->client, comp_data->icalcomp, mod, NULL)) {
+ if (e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, mod, NULL, &error)) {
gboolean strip_alarms = TRUE;
if (itip_organizer_is_user (comp, comp_data->client) &&
@@ -348,7 +349,7 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
const gchar *uid = NULL;
e_cal_component_get_uid (comp, &uid);
- if (e_cal_get_object (comp_data->client, uid, NULL, &icalcomp, NULL) && icalcomp) {
+ if (e_cal_client_get_object_sync (comp_data->client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) {
send_comp = e_cal_component_new ();
if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) {
icalcomponent_free (icalcomp);
@@ -365,9 +366,11 @@ ecmc_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
g_object_unref (send_comp);
}
} else {
- g_warning (G_STRLOC ": Could not modify the object!");
+ g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error");
/* FIXME Show error dialog */
+ if (error)
+ g_error_free (error);
}
g_object_unref (comp);
diff --git a/calendar/gui/e-cal-model-memos.c b/calendar/gui/e-cal-model-memos.c
index 0356dacf0c..59a48d031c 100644
--- a/calendar/gui/e-cal-model-memos.c
+++ b/calendar/gui/e-cal-model-memos.c
@@ -140,6 +140,7 @@ ecmm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
{
ECalModelComponent *comp_data;
ECalModelMemos *model = (ECalModelMemos *) etm;
+ GError *error = NULL;
g_return_if_fail (E_IS_CAL_MODEL_MEMOS (model));
g_return_if_fail (col >= 0 && col < E_CAL_MODEL_MEMOS_FIELD_LAST);
@@ -157,10 +158,12 @@ ecmm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
}
/* TODO ask about mod type */
- if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) {
- g_warning (G_STRLOC ": Could not modify the object!");
+ if (!e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL, &error)) {
+ g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error");
/* TODO Show error dialog */
+ if (error)
+ g_error_free (error);
}
}
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index ff829e319f..51811c783f 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -325,7 +325,7 @@ get_completed (ECalModelComponent *comp_data)
comp_data->completed->tt = tt_completed;
if (icaltime_get_tzid (tt_completed)
- && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_completed), &zone, NULL))
+ && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_completed), &zone, NULL, NULL))
comp_data->completed->zone = zone;
else
comp_data->completed->zone = NULL;
@@ -355,7 +355,7 @@ get_due (ECalModelComponent *comp_data)
comp_data->due->tt = tt_due;
if (icaltime_get_tzid (tt_due)
- && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_due), &zone, NULL))
+ && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_due), &zone, NULL, NULL))
comp_data->due->zone = zone;
else
comp_data->due->zone = NULL;
@@ -525,7 +525,7 @@ get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data)
/* Get the current time in the same timezone as the DUE date.*/
tzid = icalparameter_get_tzid (param);
- if (!e_cal_get_timezone (comp_data->client, tzid, &zone, NULL))
+ if (!e_cal_client_get_timezone_sync (comp_data->client, tzid, &zone, NULL, NULL))
return E_CAL_MODEL_TASKS_DUE_FUTURE;
now_tt = icaltime_current_time_with_zone (zone);
@@ -1252,13 +1252,17 @@ void e_cal_model_tasks_mark_comp_incomplete (ECalModelTasks *model, ECalModelCom
static void
commit_component_changes (ECalModelComponent *comp_data)
{
+ GError *error = NULL;
+
g_return_if_fail (comp_data != NULL);
/* FIXME ask about mod type */
- if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) {
- g_warning (G_STRLOC ": Could not modify the object!");
+ if (!e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL, &error)) {
+ g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error");
/* FIXME Show error dialog */
+ if (error)
+ g_error_free (error);
}
}
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index a2e0418cbc..5e0c9cc337 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <libedataserver/e-flag.h>
#include <libedataserver/e-time-utils.h>
+#include <libecal/e-cal-client-view.h>
#include <libecal/e-cal-time-util.h>
#include "comp-util.h"
#include "e-cal-model.h"
@@ -41,8 +42,8 @@
#include "e-util/e-util-enumtypes.h"
typedef struct {
- ECal *client;
- ECalView *query;
+ ECalClient *client;
+ ECalClientView *view;
gboolean do_query;
} ECalModelClient;
@@ -52,7 +53,7 @@ struct _ECalModelPrivate {
GList *clients;
/* The default client in the list */
- ECal *default_client;
+ ECalClient *default_client;
/* Array for storing the objects. Each element is of type ECalModelComponent */
GPtrArray *objects;
@@ -108,9 +109,9 @@ struct _ECalModelPrivate {
gboolean in_modified;
gboolean in_removed;
- GList *notify_added;
- GList *notify_modified;
- GList *notify_removed;
+ GSList *notify_added;
+ GSList *notify_modified;
+ GSList *notify_removed;
GMutex *notify_lock;
};
@@ -129,8 +130,8 @@ static gchar *ecm_value_to_string (ETableModel *etm, gint col, gconstpointer val
static const gchar *ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data);
-static ECalModelClient *add_new_client (ECalModel *model, ECal *client, gboolean do_query);
-static ECalModelClient *find_client_data (ECalModel *model, ECal *client);
+static ECalModelClient *add_new_client (ECalModel *model, ECalClient *client, gboolean do_query);
+static ECalModelClient *find_client_data (ECalModel *model, ECalClient *client);
static void remove_client_objects (ECalModel *model, ECalModelClient *client_data);
static void remove_client (ECalModel *model, ECalModelClient *client_data);
@@ -156,9 +157,6 @@ enum {
ROW_APPENDED,
COMPS_DELETED,
CAL_VIEW_PROGRESS,
- #ifndef E_CAL_DISABLE_DEPRECATED
- CAL_VIEW_DONE,
- #endif
CAL_VIEW_COMPLETE,
STATUS_MESSAGE,
TIMEZONE_CHANGED,
@@ -385,15 +383,15 @@ cal_model_dispose (GObject *object)
g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, object);
- if (client_data->query)
- g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA,
+ if (client_data->view)
+ g_signal_handlers_disconnect_matched (client_data->view, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, object);
priv->clients = g_list_remove (priv->clients, client_data);
g_object_unref (client_data->client);
- if (client_data->query)
- g_object_unref (client_data->query);
+ if (client_data->view)
+ g_object_unref (client_data->view);
g_free (client_data);
}
@@ -493,9 +491,9 @@ e_cal_model_class_init (ECalModelClass *class)
PROP_DEFAULT_CLIENT,
g_param_spec_object (
"default-client",
- "Default Client",
+ "Default ECalClient",
NULL,
- E_TYPE_CAL,
+ E_TYPE_CAL_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (
@@ -646,25 +644,14 @@ e_cal_model_class_init (ECalModelClass *class)
e_marshal_VOID__STRING_INT_INT,
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT);
- #ifndef E_CAL_DISABLE_DEPRECATED
- signals[CAL_VIEW_DONE] =
- g_signal_new ("cal_view_done",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalModelClass, cal_view_done),
- NULL, NULL,
- e_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
- #endif
-
signals[CAL_VIEW_COMPLETE] =
g_signal_new ("cal_view_complete",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ECalModelClass, cal_view_complete),
NULL, NULL,
- e_marshal_VOID__INT_STRING_INT,
- G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT);
+ e_marshal_VOID__BOXED_INT,
+ G_TYPE_NONE, 2, G_TYPE_ERROR, G_TYPE_INT);
signals[STATUS_MESSAGE] = g_signal_new (
"status-message",
@@ -827,7 +814,7 @@ get_dtstart (ECalModel *model, ECalModelComponent *comp_data)
tt_start = icalproperty_get_dtstart (prop);
if (icaltime_get_tzid (tt_start)
- && e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL))
+ && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL, NULL))
got_zone = TRUE;
if (e_cal_model_get_flags (model) & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) {
@@ -1080,7 +1067,7 @@ set_description (ECalModelComponent *comp_data, const gchar *value)
}
static void
-datetime_to_zone (ECal *client, struct icaltimetype *tt, icaltimezone *tt_zone, const gchar *tzid)
+datetime_to_zone (ECalClient *client, struct icaltimetype *tt, icaltimezone *tt_zone, const gchar *tzid)
{
icaltimezone *from, *to;
const gchar *tt_tzid = NULL;
@@ -1098,7 +1085,7 @@ datetime_to_zone (ECal *client, struct icaltimetype *tt, icaltimezone *tt_zone,
to = icaltimezone_get_builtin_timezone_from_tzid (tzid);
if (!to) {
/* do not check failure here, maybe the zone is not available there */
- e_cal_get_timezone (client, tzid, &to, NULL);
+ e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL);
}
icaltimezone_convert_time (tt, from, to);
@@ -1196,6 +1183,7 @@ ecm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
ECalModelPrivate *priv;
ECalModelComponent *comp_data;
ECalModel *model = (ECalModel *) etm;
+ GError *error = NULL;
g_return_if_fail (E_IS_CAL_MODEL (model));
@@ -1226,10 +1214,12 @@ ecm_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value)
}
/* FIXME ask about mod type */
- if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) {
- g_warning (G_STRLOC ": Could not modify the object!");
+ if (!e_cal_client_modify_object_sync (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL, &error)) {
+ g_warning (G_STRLOC ": Could not modify the object! %s", error ? error->message : "Unknown error");
/* FIXME Show error dialog */
+ if (error)
+ g_error_free (error);
}
}
@@ -1248,7 +1238,7 @@ gboolean
e_cal_model_test_row_editable (ECalModel *model, gint row)
{
gboolean readonly;
- ECal *cal = NULL;
+ ECalClient *client = NULL;
if (row != -1) {
ECalModelComponent *comp_data;
@@ -1256,17 +1246,16 @@ e_cal_model_test_row_editable (ECalModel *model, gint row)
comp_data = e_cal_model_get_component_at (model, row);
if (comp_data)
- cal = comp_data->client;
+ client = comp_data->client;
} else {
- cal = e_cal_model_get_default_client (model);
+ client = e_cal_model_get_default_client (model);
}
- readonly = cal == NULL;
+ readonly = client == NULL;
if (!readonly)
- if (!e_cal_is_read_only (cal, &readonly, NULL))
- readonly = TRUE;
+ readonly = e_client_is_readonly (E_CLIENT (client));
return !readonly;
}
@@ -1305,6 +1294,8 @@ ecm_append_row (ETableModel *etm, ETableModel *source, gint row)
ECalModelClass *model_class;
ECalModelComponent *comp_data;
ECalModel *model = (ECalModel *) etm;
+ gchar *uid = NULL;
+ GError *error = NULL;
g_return_if_fail (E_IS_CAL_MODEL (model));
g_return_if_fail (E_IS_TABLE_MODEL (source));
@@ -1316,7 +1307,7 @@ ecm_append_row (ETableModel *etm, ETableModel *source, gint row)
g_object_ref (comp_data->client);
/* guard against saving before the calendar is open */
- if (!(comp_data->client && e_cal_get_load_state (comp_data->client) == E_CAL_LOAD_LOADED)) {
+ if (!comp_data->client || !e_client_is_opened (E_CLIENT (comp_data->client))) {
g_object_unref (comp_data);
return;
}
@@ -1353,14 +1344,20 @@ ecm_append_row (ETableModel *etm, ETableModel *source, gint row)
model_class->fill_component_from_model (model, comp_data, source, row);
}
- if (!e_cal_create_object (comp_data->client, comp_data->icalcomp, NULL, NULL)) {
- g_warning (G_STRLOC ": Could not create the object!");
+ if (!e_cal_client_create_object_sync (comp_data->client, comp_data->icalcomp, &uid, NULL, &error)) {
+ g_warning (G_STRLOC ": Could not create the object! %s", error ? error->message : "Unknown error");
/* FIXME: show error dialog */
+ if (error)
+ g_error_free (error);
} else {
+ if (uid)
+ icalcomponent_set_uid (comp_data->icalcomp, uid);
+
g_signal_emit (G_OBJECT (model), signals[ROW_APPENDED], 0);
}
+ g_free (uid);
g_object_unref (comp_data);
}
@@ -1561,7 +1558,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- source = e_cal_get_source (comp_data->client);
+ source = e_client_get_source (E_CLIENT (comp_data->client));
color_spec = e_source_peek_color_spec (source);
if (color_spec != NULL) {
g_free (comp_data->color);
@@ -1579,7 +1576,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
for (l = assigned_colors[i].uris; l != NULL; l = l->next) {
if (!strcmp ((const gchar *) l->data,
- e_cal_get_uri (comp_data->client)))
+ e_client_get_uri (E_CLIENT (comp_data->client))))
{
return assigned_colors[i].color;
}
@@ -1588,7 +1585,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
/* return the first unused color */
assigned_colors[first_empty].uris = g_list_append (assigned_colors[first_empty].uris,
- g_strdup (e_cal_get_uri (comp_data->client)));
+ g_strdup (e_client_get_uri (E_CLIENT (comp_data->client))));
return assigned_colors[first_empty].color;
}
@@ -1887,7 +1884,7 @@ e_cal_model_set_work_day_start_minute (ECalModel *model,
g_object_notify (G_OBJECT (model), "work-day-start-minute");
}
-ECal *
+ECalClient *
e_cal_model_get_default_client (ECalModel *model)
{
ECalModelPrivate *priv;
@@ -1913,7 +1910,7 @@ e_cal_model_get_default_client (ECalModel *model)
}
void
-e_cal_model_set_default_client (ECalModel *model, ECal *client)
+e_cal_model_set_default_client (ECalModel *model, ECalClient *client)
{
ECalModelPrivate *priv;
ECalModelClient *client_data;
@@ -1921,7 +1918,7 @@ e_cal_model_set_default_client (ECalModel *model, ECal *client)
g_return_if_fail (E_IS_CAL_MODEL (model));
if (client != NULL)
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
priv = model->priv;
@@ -1951,7 +1948,7 @@ GList *
e_cal_model_get_client_list (ECalModel *model)
{
GList *list = NULL, *l;
- ECal *default_client;
+ ECalClient *default_client;
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
@@ -1975,7 +1972,7 @@ e_cal_model_get_client_list (ECalModel *model)
* @model: A calendar model.
* @uri: Uri for the client to get.
*/
-ECal *
+ECalClient *
e_cal_model_get_client_for_uri (ECalModel *model, const gchar *uri)
{
GList *l;
@@ -1986,7 +1983,7 @@ e_cal_model_get_client_for_uri (ECalModel *model, const gchar *uri)
for (l = model->priv->clients; l != NULL; l = l->next) {
ECalModelClient *client_data = (ECalModelClient *) l->data;
- if (!strcmp (uri, e_cal_get_uri (client_data->client)))
+ if (!strcmp (uri, e_client_get_uri (E_CLIENT (client_data->client))))
return client_data->client;
}
@@ -1994,7 +1991,7 @@ e_cal_model_get_client_for_uri (ECalModel *model, const gchar *uri)
}
static ECalModelClient *
-find_client_data (ECalModel *model, ECal *client)
+find_client_data (ECalModel *model, ECalClient *client)
{
ECalModelPrivate *priv;
GList *l;
@@ -2012,7 +2009,7 @@ find_client_data (ECalModel *model, ECal *client)
}
static ECalModelComponent *
-search_by_id_and_client (ECalModelPrivate *priv, ECal *client, const ECalComponentId *id)
+search_by_id_and_client (ECalModelPrivate *priv, ECalClient *client, const ECalComponentId *id)
{
gint i;
@@ -2051,8 +2048,8 @@ search_by_id_and_client (ECalModelPrivate *priv, ECal *client, const ECalCompone
}
typedef struct {
- ECal *client;
- ECalView *query;
+ ECalClient *client;
+ ECalClientView *view;
ECalModel *model;
icalcomponent *icalcomp;
} RecurrenceExpansionData;
@@ -2075,7 +2072,8 @@ add_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end
/* set the right instance start date to component */
e_cal_component_get_dtstart (comp, &datetime);
- e_cal_get_timezone (rdata->client, datetime.tzid, &zone, NULL);
+ if (datetime.tzid)
+ e_cal_client_get_timezone_sync (rdata->client, datetime.tzid, &zone, NULL, NULL);
time = icaltime_from_timet_with_zone (instance_start, FALSE, zone ? zone : priv->zone);
to_set.value = &time;
to_set.tzid = datetime.tzid;
@@ -2084,7 +2082,9 @@ add_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end
/* set the right instance end date to component*/
e_cal_component_get_dtend (comp, &datetime);
- e_cal_get_timezone (rdata->client, datetime.tzid, &zone, NULL);
+ zone = NULL;
+ if (datetime.tzid)
+ e_cal_client_get_timezone_sync (rdata->client, datetime.tzid, &zone, NULL, NULL);
time = icaltime_from_timet_with_zone (instance_end, FALSE, zone ? zone : priv->zone);
to_set.value = &time;
to_set.tzid = datetime.tzid;
@@ -2162,24 +2162,25 @@ place_master_object_first_cb (gconstpointer p1, gconstpointer p2)
return res;
}
-static void e_cal_view_objects_added_cb (ECalView *query, GList *objects, ECalModel *model);
+static void client_view_objects_added_cb (ECalClientView *view, const GSList *objects, ECalModel *model);
static void
-process_added (ECalView *query, GList *objects, ECalModel *model)
+process_added (ECalClientView *view, const GSList *objects, ECalModel *model)
{
ECalModelPrivate *priv;
- GList *l, *copy;
+ const GSList *l;
+ GSList *copy;
priv = model->priv;
/* order matters, process master object first, then detached instances */
- copy = g_list_sort (g_list_copy (objects), place_master_object_first_cb);
+ copy = g_slist_sort (g_slist_copy ((GSList *) objects), place_master_object_first_cb);
for (l = copy; l; l = l->next) {
ECalModelComponent *comp_data;
ECalComponentId *id;
ECalComponent *comp = e_cal_component_new ();
- ECal *client = e_cal_view_get_client (query);
+ ECalClient *client = e_cal_client_view_get_client (view);
/* This will fail for alarm or VCalendar component */
if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) {
@@ -2217,19 +2218,17 @@ process_added (ECalView *query, GList *objects, ECalModel *model)
if (e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES)) {
RecurrenceExpansionData rdata;
- rdata.client = e_cal_view_get_client (query);
- rdata.query = query;
+ rdata.client = client;
+ rdata.view = view;
rdata.model = model;
rdata.icalcomp = l->data;
- e_cal_generate_instances_for_object (rdata.client, l->data,
- priv->start, priv->end,
- (ECalRecurInstanceFn) add_instance_cb,
- &rdata);
+ e_cal_client_generate_instances_for_object (rdata.client, l->data, priv->start, priv->end,
+ (ECalRecurInstanceFn) add_instance_cb, &rdata);
} else {
e_table_model_pre_change (E_TABLE_MODEL (model));
comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL);
- comp_data->client = g_object_ref (e_cal_view_get_client (query));
+ comp_data->client = g_object_ref (client);
comp_data->icalcomp = icalcomponent_new_clone (l->data);
e_cal_model_set_instance_times (comp_data, priv->zone);
@@ -2238,27 +2237,28 @@ process_added (ECalView *query, GList *objects, ECalModel *model)
}
}
- g_list_free (copy);
+ g_slist_free (copy);
}
static void
-process_modified (ECalView *query, GList *objects, ECalModel *model)
+process_modified (ECalClientView *view, const GSList *objects, ECalModel *model)
{
ECalModelPrivate *priv;
- GList *l, *list = NULL;
+ const GSList *l;
+ GSList *list = NULL;
priv = model->priv;
/* re-add only the recurrence objects */
- for (l = objects; l != NULL; l = g_list_next (l)) {
+ for (l = objects; l != NULL; l = g_slist_next (l)) {
if (!e_cal_util_component_is_instance (l->data) && e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES))
- list = g_list_prepend (list, l->data);
+ list = g_slist_prepend (list, l->data);
else {
gint pos;
ECalModelComponent *comp_data;
ECalComponentId *id;
ECalComponent *comp = e_cal_component_new ();
- ECal *client = e_cal_view_get_client (query);
+ ECalClient *client = e_cal_client_view_get_client (view);
if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) {
g_object_unref (comp);
@@ -2319,15 +2319,15 @@ process_modified (ECalView *query, GList *objects, ECalModel *model)
}
}
- e_cal_view_objects_added_cb (query, list, model);
- g_list_free (list);
+ client_view_objects_added_cb (view, list, model);
+ g_slist_free (list);
}
static void
-process_removed (ECalView *query, GList *ids, ECalModel *model)
+process_removed (ECalClientView *view, const GSList *ids, ECalModel *model)
{
ECalModelPrivate *priv;
- GList *l;
+ const GSList *l;
priv = model->priv;
@@ -2337,7 +2337,7 @@ process_removed (ECalView *query, GList *ids, ECalModel *model)
gint pos;
/* make sure we remove all objects with this UID */
- while ((comp_data = search_by_id_and_client (priv, e_cal_view_get_client (query), id))) {
+ while ((comp_data = search_by_id_and_client (priv, e_cal_client_view_get_client (view), id))) {
GSList *l = NULL;
pos = get_position_in_array (priv->objects, comp_data);
@@ -2387,19 +2387,19 @@ free_comp_id (gpointer id)
}
static void
-process_event (ECalView *query, GList *objects, ECalModel *model,
- void (*process_fn) (ECalView *query, GList *objects, ECalModel *model),
- gboolean *in, GList **save_list, gpointer (*copy_fn) (gpointer data), void (*free_fn)(gpointer data))
+process_event (ECalClientView *view, const GSList *objects, ECalModel *model,
+ void (*process_fn) (ECalClientView *view, const GSList *objects, ECalModel *model),
+ gboolean *in, GSList **save_list, gpointer (*copy_fn) (gpointer data), void (*free_fn)(gpointer data))
{
gboolean skip = FALSE;
- GList *l;
+ const GSList *l;
g_mutex_lock (model->priv->notify_lock);
if (*in) {
skip = TRUE;
for (l = objects; l; l = l->next) {
if (l->data)
- *save_list = g_list_append (*save_list, copy_fn (l->data));
+ *save_list = g_slist_append (*save_list, copy_fn (l->data));
}
} else {
*in = TRUE;
@@ -2411,23 +2411,23 @@ process_event (ECalView *query, GList *objects, ECalModel *model,
return;
/* do it */
- process_fn (query, objects, model);
+ process_fn (view, objects, model);
g_mutex_lock (model->priv->notify_lock);
while (*save_list) {
- GList *copy = *save_list;
+ GSList *copy = *save_list;
*save_list = NULL;
g_mutex_unlock (model->priv->notify_lock);
/* do it */
- process_fn (query, copy, model);
+ process_fn (view, copy, model);
for (l = copy; l; l = l->next) {
if (l->data) {
free_fn (l->data);
}
}
- g_list_free (copy);
+ g_slist_free (copy);
g_mutex_lock (model->priv->notify_lock);
}
@@ -2437,56 +2437,51 @@ process_event (ECalView *query, GList *objects, ECalModel *model,
}
static void
-e_cal_view_objects_added_cb (ECalView *query, GList *objects, ECalModel *model)
+client_view_objects_added_cb (ECalClientView *view, const GSList *objects, ECalModel *model)
{
- process_event (query, objects, model,
+ process_event (view, objects, model,
process_added, &model->priv->in_added, &model->priv->notify_added,
(gpointer (*)(gpointer)) icalcomponent_new_clone, (void (*)(gpointer)) icalcomponent_free);
}
static void
-e_cal_view_objects_modified_cb (ECalView *query, GList *objects, ECalModel *model)
+client_view_objects_modified_cb (ECalClientView *view, const GSList *objects, ECalModel *model)
{
- process_event (query, objects, model,
+ process_event (view, objects, model,
process_modified, &model->priv->in_modified, &model->priv->notify_modified,
(gpointer (*)(gpointer)) icalcomponent_new_clone, (void (*)(gpointer)) icalcomponent_free);
}
static void
-e_cal_view_objects_removed_cb (ECalView *query, GList *ids, ECalModel *model)
+client_view_objects_removed_cb (ECalClientView *view, const GSList *ids, ECalModel *model)
{
- process_event (query, ids, model,
+ process_event (view, ids, model,
process_removed, &model->priv->in_removed, &model->priv->notify_removed,
copy_comp_id, free_comp_id);
}
static void
-e_cal_view_progress_cb (ECalView *query, const gchar *message, gint percent, gpointer user_data)
+client_view_progress_cb (ECalClientView *view, gint percent, const gchar *message, gpointer user_data)
{
ECalModel *model = (ECalModel *) user_data;
- ECal *client = e_cal_view_get_client (query);
+ ECalClient *client = e_cal_client_view_get_client (view);
g_return_if_fail (E_IS_CAL_MODEL (model));
g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_PROGRESS], 0, message,
- percent, e_cal_get_source_type (client));
+ percent, e_cal_client_get_source_type (client));
}
static void
-e_cal_view_complete_cb (ECalView *query, ECalendarStatus status, const gchar *error_msg, gpointer user_data)
+client_view_complete_cb (ECalClientView *view, const GError *error, gpointer user_data)
{
ECalModel *model = (ECalModel *) user_data;
- ECal *client = e_cal_view_get_client (query);
+ ECalClient *client = e_cal_client_view_get_client (view);
g_return_if_fail (E_IS_CAL_MODEL (model));
- #ifndef E_CAL_DISABLE_DEPRECATED
- /* emit the signal on the model and let the view catch it to display */
- g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_DONE], 0, status,
- e_cal_get_source_type (client));
- #endif
- g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_COMPLETE], 0, status, error_msg,
- e_cal_get_source_type (client));
+ g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_COMPLETE], 0, error,
+ e_cal_client_get_source_type (client));
}
static void
@@ -2499,27 +2494,27 @@ update_e_cal_view_for_client (ECalModel *model, ECalModelClient *client_data)
priv = model->priv;
/* Skip if this client has not finished loading yet */
- if (e_cal_get_load_state (client_data->client) != E_CAL_LOAD_LOADED)
+ if (!e_client_is_opened (E_CLIENT (client_data->client)))
return;
- /* free the previous query, if any */
- if (client_data->query) {
- g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA,
+ /* free the previous view, if any */
+ if (client_data->view) {
+ g_signal_handlers_disconnect_matched (client_data->view, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, model);
- g_object_unref (client_data->query);
- client_data->query = NULL;
+ g_object_unref (client_data->view);
+ client_data->view = NULL;
}
- /* prepare the query */
+ /* prepare the view */
g_return_if_fail (priv->full_sexp != NULL);
/* Don't create the new query if we won't use it */
if (!client_data->do_query)
return;
-try_again:
- if (!e_cal_get_query (client_data->client, priv->full_sexp, &client_data->query, &error)) {
- if (error->code == E_CALENDAR_STATUS_BUSY && tries != 10) {
+ try_again:
+ if (!e_cal_client_get_view_sync (client_data->client, priv->full_sexp, &client_data->view, NULL, &error)) {
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY) && tries != 10) {
tries++;
/*TODO chose an optimal value */
g_usleep (500);
@@ -2527,18 +2522,24 @@ try_again:
goto try_again;
}
- g_warning (G_STRLOC ": Unable to get query, %s", error->message);
+ g_warning (G_STRLOC ": Unable to get query, %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return;
}
- g_signal_connect (client_data->query, "objects_added", G_CALLBACK (e_cal_view_objects_added_cb), model);
- g_signal_connect (client_data->query, "objects_modified", G_CALLBACK (e_cal_view_objects_modified_cb), model);
- g_signal_connect (client_data->query, "objects_removed", G_CALLBACK (e_cal_view_objects_removed_cb), model);
- g_signal_connect (client_data->query, "view_progress", G_CALLBACK (e_cal_view_progress_cb), model);
- g_signal_connect (client_data->query, "view_complete", G_CALLBACK (e_cal_view_complete_cb), model);
+ g_signal_connect (client_data->view, "objects-added", G_CALLBACK (client_view_objects_added_cb), model);
+ g_signal_connect (client_data->view, "objects-modified", G_CALLBACK (client_view_objects_modified_cb), model);
+ g_signal_connect (client_data->view, "objects-removed", G_CALLBACK (client_view_objects_removed_cb), model);
+ g_signal_connect (client_data->view, "progress", G_CALLBACK (client_view_progress_cb), model);
+ g_signal_connect (client_data->view, "complete", G_CALLBACK (client_view_complete_cb), model);
- e_cal_view_start (client_data->query);
+ e_cal_client_view_start (client_data->view, &error);
+ if (error) {
+ g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
void
@@ -2550,7 +2551,7 @@ e_cal_model_update_status_message (ECalModel *model, const gchar *message, gdoub
}
static void
-backend_died_cb (ECal *client, gpointer user_data)
+backend_died_cb (ECalClient *client, gpointer user_data)
{
ECalModel *model;
@@ -2559,35 +2560,20 @@ backend_died_cb (ECal *client, gpointer user_data)
e_cal_model_remove_client (model, client);
}
-static gboolean
-wait_open_cb (gpointer data)
-{
- ECal *client = data;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (E_IS_CAL (client), FALSE);
-
- e_cal_open_async (client, FALSE);
-
- return FALSE;
-}
-
static void
-cal_opened_cb (ECal *client, const GError *error, gpointer user_data)
+client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
+ ECalClient *client = E_CAL_CLIENT (source_object);
ECalModel *model = (ECalModel *) user_data;
ECalModelClient *client_data;
+ GError *error = NULL;
- if (g_error_matches (error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY)) {
- g_timeout_add (250, wait_open_cb, client);
- return;
- }
-
- /* Stop listening for this calendar to be opened */
- g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, cal_opened_cb, model);
+ e_client_open_finish (E_CLIENT (client), result, &error);
if (error) {
e_cal_model_remove_client (model, client);
+ g_debug ("%s: Failed to open '%s': %s", G_STRFUNC, e_client_get_uri (E_CLIENT (client)), error->message);
+ g_error_free (error);
e_cal_model_update_status_message (model, NULL, -1.0);
return;
}
@@ -2601,7 +2587,7 @@ cal_opened_cb (ECal *client, const GError *error, gpointer user_data)
}
static ECalModelClient *
-add_new_client (ECalModel *model, ECal *client, gboolean do_query)
+add_new_client (ECalModel *model, ECalClient *client, gboolean do_query)
{
ECalModelPrivate *priv;
ECalModelClient *client_data;
@@ -2626,7 +2612,7 @@ add_new_client (ECalModel *model, ECal *client, gboolean do_query)
client_data = g_new0 (ECalModelClient, 1);
client_data->client = g_object_ref (client);
- client_data->query = NULL;
+ client_data->view = NULL;
client_data->do_query = do_query;
priv->clients = g_list_append (priv->clients, client_data);
@@ -2635,19 +2621,18 @@ add_new_client (ECalModel *model, ECal *client, gboolean do_query)
G_CALLBACK (backend_died_cb), model);
load:
- if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) {
+ if (e_client_is_opened (E_CLIENT (client))) {
update_e_cal_view_for_client (model, client_data);
} else {
gchar *msg;
- msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (client));
+ msg = g_strdup_printf (_("Opening %s"), e_client_get_uri (E_CLIENT (client)));
e_cal_model_update_status_message (model, msg, -1.0);
g_free (msg);
- e_cal_set_default_timezone (client, e_cal_model_get_timezone (model), NULL);
+ e_cal_client_set_default_timezone (client, e_cal_model_get_timezone (model));
- g_signal_connect (client, "cal_opened_ex", G_CALLBACK (cal_opened_cb), model);
- e_cal_open_async (client, TRUE);
+ e_client_open (E_CLIENT (client), TRUE, NULL, client_opened_cb, model);
}
return client_data;
@@ -2657,10 +2642,10 @@ add_new_client (ECalModel *model, ECal *client, gboolean do_query)
* e_cal_model_add_client
*/
void
-e_cal_model_add_client (ECalModel *model, ECal *client)
+e_cal_model_add_client (ECalModel *model, ECalClient *client)
{
g_return_if_fail (E_IS_CAL_MODEL (model));
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
add_new_client (model, client, TRUE);
}
@@ -2701,8 +2686,8 @@ remove_client (ECalModel *model, ECalModelClient *client_data)
{
/* FIXME We might not want to disconnect the open signal for the default client */
g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model);
- if (client_data->query)
- g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model);
+ if (client_data->view)
+ g_signal_handlers_disconnect_matched (client_data->view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model);
remove_client_objects (model, client_data);
@@ -2722,8 +2707,8 @@ remove_client (ECalModel *model, ECalModelClient *client_data)
/* free all remaining memory */
g_object_unref (client_data->client);
- if (client_data->query)
- g_object_unref (client_data->query);
+ if (client_data->view)
+ g_object_unref (client_data->view);
g_free (client_data);
}
@@ -2731,12 +2716,12 @@ remove_client (ECalModel *model, ECalModelClient *client_data)
* e_cal_model_remove_client
*/
void
-e_cal_model_remove_client (ECalModel *model, ECal *client)
+e_cal_model_remove_client (ECalModel *model, ECalClient *client)
{
ECalModelClient *client_data;
g_return_if_fail (E_IS_CAL_MODEL (model));
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
client_data = find_client_data (model, client);
if (client_data)
@@ -2876,7 +2861,7 @@ redo_queries (ECalModel *model)
e_flag_free (data.eflag);
- /* update the query for all clients */
+ /* update the view for all clients */
for (l = priv->clients; l != NULL; l = l->next) {
ECalModelClient *client_data;
@@ -3002,7 +2987,7 @@ e_cal_model_create_component_with_defaults (ECalModel *model, gboolean all_day)
ECalModelPrivate *priv;
ECalComponent *comp;
icalcomponent *icalcomp;
- ECal *client;
+ ECalClient *client;
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
@@ -3302,7 +3287,7 @@ e_cal_model_generate_instances (ECalModel *model, time_t start, time_t end,
mdata.cb_data = cb_data;
if (comp_data->instance_start < end && comp_data->instance_end > start)
- e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp, start, end, cb, &mdata);
+ e_cal_client_generate_instances_for_object (comp_data->client, comp_data->icalcomp, start, end, cb, &mdata);
}
}
@@ -3361,7 +3346,8 @@ e_cal_model_set_instance_times (ECalModelComponent *comp_data, const icaltimezon
icaltimezone *st_zone = NULL;
tzid = icalparameter_get_tzid (param);
- e_cal_get_timezone (comp_data->client, tzid, &st_zone, NULL);
+ if (tzid)
+ e_cal_client_get_timezone_sync (comp_data->client, tzid, &st_zone, NULL, NULL);
if (st_zone)
zone = st_zone;
@@ -3385,7 +3371,8 @@ e_cal_model_set_instance_times (ECalModelComponent *comp_data, const icaltimezon
icaltimezone *end_zone = NULL;
tzid = icalparameter_get_tzid (param);
- e_cal_get_timezone (comp_data->client, tzid, &end_zone, NULL);
+ if (tzid)
+ e_cal_client_get_timezone_sync (comp_data->client, tzid, &end_zone, NULL, NULL);
if (end_zone)
zone = end_zone;
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index db744d3d32..766fd6286f 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -28,7 +28,7 @@
#include <e-util/e-util-enums.h>
#include <table/e-table-model.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include "e-cell-date-edit-text.h"
/* Standard GObject macros */
@@ -105,7 +105,7 @@ typedef struct _ECalModelComponentPrivate ECalModelComponentPrivate;
struct _ECalModelComponent {
GObject object;
- ECal *client;
+ ECalClient *client;
icalcomponent *icalcomp;
time_t instance_start;
time_t instance_end;
@@ -160,16 +160,10 @@ struct _ECalModelClass {
void (*cal_view_progress) (ECalModel *model,
const gchar *message,
gint progress,
- ECalSourceType type);
- #ifndef E_CAL_DISABLE_DEPRECATED
- void (*cal_view_done) (ECalModel *model,
- ECalendarStatus status,
- ECalSourceType type);
- #endif
+ ECalClientSourceType type);
void (*cal_view_complete) (ECalModel *model,
- ECalendarStatus status,
- const gchar *error_msg,
- ECalSourceType type);
+ const GError *error,
+ ECalClientSourceType type);
void (*status_message) (ECalModel *model,
const gchar *message,
gdouble percent);
@@ -246,16 +240,16 @@ gint e_cal_model_get_work_day_start_minute
void e_cal_model_set_work_day_start_minute
(ECalModel *model,
gint work_day_start_minute);
-ECal * e_cal_model_get_default_client (ECalModel *model);
+ECalClient * e_cal_model_get_default_client (ECalModel *model);
void e_cal_model_set_default_client (ECalModel *model,
- ECal *client);
+ ECalClient *client);
GList * e_cal_model_get_client_list (ECalModel *model);
-ECal * e_cal_model_get_client_for_uri (ECalModel *model,
+ECalClient * e_cal_model_get_client_for_uri (ECalModel *model,
const gchar *uri);
void e_cal_model_add_client (ECalModel *model,
- ECal *client);
+ ECalClient *cal_client);
void e_cal_model_remove_client (ECalModel *model,
- ECal *client);
+ ECalClient *cal_client);
void e_cal_model_remove_all_clients (ECalModel *model);
void e_cal_model_get_time_range (ECalModel *model,
time_t *start,
diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c
index 86d42aedb1..d31578cbd0 100644
--- a/calendar/gui/e-calendar-selector.c
+++ b/calendar/gui/e-calendar-selector.c
@@ -24,9 +24,9 @@
#include "e-calendar-selector.h"
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
+#include <libedataserverui/e-client-utils.h>
#include "e-util/e-selection.h"
-#include "common/authentication.h"
struct _ECalendarSelectorPrivate {
gint dummy_value;
@@ -35,7 +35,7 @@ struct _ECalendarSelectorPrivate {
static gpointer parent_class;
static gboolean
-calendar_selector_update_single_object (ECal *client,
+calendar_selector_update_single_object (ECalClient *client,
icalcomponent *icalcomp)
{
gchar *uid;
@@ -43,15 +43,23 @@ calendar_selector_update_single_object (ECal *client,
uid = (gchar *) icalcomponent_get_uid (icalcomp);
- if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
- return e_cal_modify_object (
- client, icalcomp, CALOBJ_MOD_ALL, NULL);
+ if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL))
+ return e_cal_client_modify_object_sync (
+ client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
- return e_cal_create_object (client, icalcomp, &uid, NULL);
+ uid = NULL;
+ if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL))
+ return FALSE;
+
+ if (uid)
+ icalcomponent_set_uid (icalcomp, uid);
+ g_free (uid);
+
+ return TRUE;
}
static gboolean
-calendar_selector_update_objects (ECal *client,
+calendar_selector_update_objects (ECalClient *client,
icalcomponent *icalcomp)
{
icalcomponent *subcomp;
@@ -72,14 +80,19 @@ calendar_selector_update_objects (ECal *client,
kind = icalcomponent_isa (subcomp);
if (kind == ICAL_VTIMEZONE_COMPONENT) {
icaltimezone *zone;
+ GError *error = NULL;
zone = icaltimezone_new ();
icaltimezone_set_component (zone, subcomp);
- success = e_cal_add_timezone (client, zone, NULL);
+ success = e_cal_client_add_timezone_sync (client, zone, NULL, &error);
icaltimezone_free (zone, 1);
- if (!success)
+ if (!success) {
+ g_debug ("%s: Failed to ass timezone: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return FALSE;
+ }
} else if (kind == ICAL_VTODO_COMPONENT ||
kind == ICAL_VEVENT_COMPONENT) {
success = calendar_selector_update_single_object (
@@ -95,6 +108,31 @@ calendar_selector_update_objects (ECal *client,
return TRUE;
}
+static void
+client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EClient *client = NULL;
+ icalcomponent *icalcomp = user_data;
+ GError *error = NULL;
+
+ g_return_if_fail (icalcomp != NULL);
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ if (client) {
+ calendar_selector_update_objects (E_CAL_CLIENT (client), icalcomp);
+ g_object_unref (client);
+ }
+
+ if (error) {
+ g_debug ("%s: Failed to open client: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ icalcomponent_free (icalcomp);
+}
+
static gboolean
calendar_selector_data_dropped (ESourceSelector *selector,
GtkSelectionData *selection_data,
@@ -103,7 +141,6 @@ calendar_selector_data_dropped (ESourceSelector *selector,
guint info)
{
GtkTreePath *path = NULL;
- ECal *client;
icalcomponent *icalcomp;
const guchar *data;
gboolean success = FALSE;
@@ -123,17 +160,9 @@ calendar_selector_data_dropped (ESourceSelector *selector,
icalcomponent_set_uid (icalcomp, uid);
}
- client = e_auth_new_cal_from_source (
- destination, E_CAL_SOURCE_TYPE_EVENT);
-
- if (client != NULL) {
- if (e_cal_open (client, TRUE, NULL))
- calendar_selector_update_objects (client, icalcomp);
-
- g_object_unref (client);
- }
-
- icalcomponent_free (icalcomp);
+ e_client_utils_open_new (destination, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ client_opened_cb, icalcomp);
success = TRUE;
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 34f6eae6b0..32c5301fe1 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -31,6 +31,7 @@
#include <glib/gstdio.h>
#include <gdk/gdkkeysyms.h>
#include <libedataserver/e-time-utils.h>
+#include <libedataserverui/e-client-utils.h>
#include <e-util/e-util.h>
#include <e-util/e-alert-dialog.h>
#include <e-util/e-extensible.h>
@@ -43,7 +44,6 @@
#include <misc/e-selectable.h>
#include <shell/e-shell.h>
-#include "common/authentication.h"
#include "comp-util.h"
#include "ea-calendar.h"
#include "e-cal-model-calendar.h"
@@ -132,7 +132,7 @@ calendar_view_add_retract_data (ECalComponent *comp,
static gboolean
calendar_view_check_for_retract (ECalComponent *comp,
- ECal *client)
+ ECalClient *client)
{
ECalComponentOrganizer organizer;
const gchar *strip;
@@ -142,14 +142,14 @@ calendar_view_check_for_retract (ECalComponent *comp,
if (!e_cal_component_has_attendees (comp))
return FALSE;
- if (!e_cal_get_save_schedules (client))
+ if (!e_cal_client_check_save_schedules (client))
return FALSE;
e_cal_component_get_organizer (comp, &organizer);
strip = itip_strip_mailto (organizer.value);
ret_val =
- e_cal_get_cal_address (client, &email, NULL) &&
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) &&
(g_ascii_strcasecmp (email, strip) == 0);
g_free (email);
@@ -177,7 +177,7 @@ calendar_view_delete_event (ECalendarView *cal_view,
vtype = e_cal_component_get_vtype (comp);
/*FIXME remove it once the we dont set the recurrence id for all the generated instances */
- if (!e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER))
+ if (!e_cal_client_check_recurrences_no_master (event->comp_data->client))
e_cal_component_set_recurid (comp, NULL);
/*FIXME Retract should be moved to Groupwise features plugin */
@@ -187,15 +187,15 @@ calendar_view_delete_event (ECalendarView *cal_view,
delete = prompt_retract_dialog (comp, &retract_comment, GTK_WIDGET (cal_view), &retract);
if (retract) {
- GList *users = NULL;
+ GSList *users = NULL;
icalcomponent *icalcomp = NULL, *mod_comp = NULL;
calendar_view_add_retract_data (
comp, retract_comment, CALOBJ_MOD_ALL);
icalcomp = e_cal_component_get_icalcomponent (comp);
icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL);
- if (!e_cal_send_objects (event->comp_data->client, icalcomp, &users,
- &mod_comp, &error)) {
+ if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users,
+ &mod_comp, NULL, &error)) {
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
g_clear_error (&error);
error = NULL;
@@ -205,8 +205,8 @@ calendar_view_delete_event (ECalendarView *cal_view,
icalcomponent_free (mod_comp);
if (users) {
- g_list_foreach (users, (GFunc) g_free, NULL);
- g_list_free (users);
+ g_slist_foreach (users, (GFunc) g_free, NULL);
+ g_slist_free (users);
}
}
}
@@ -232,10 +232,10 @@ calendar_view_delete_event (ECalendarView *cal_view,
}
rid = e_cal_component_get_recurid_as_string (comp);
if (e_cal_util_component_is_instance (event->comp_data->icalcomp) || e_cal_util_component_has_recurrences (event->comp_data->icalcomp))
- e_cal_remove_object_with_mod (event->comp_data->client, uid,
- rid, CALOBJ_MOD_ALL, &error);
+ e_cal_client_remove_object_sync (event->comp_data->client, uid,
+ rid, CALOBJ_MOD_ALL, NULL, &error);
else
- e_cal_remove_object (event->comp_data->client, uid, &error);
+ e_cal_client_remove_object_sync (event->comp_data->client, uid, NULL, CALOBJ_MOD_THIS, NULL, &error);
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
g_clear_error (&error);
@@ -392,9 +392,8 @@ calendar_view_update_actions (ESelectable *selectable,
for (iter = list; iter != NULL; iter = iter->next) {
ECalendarViewEvent *event = iter->data;
- ECal *client;
+ ECalClient *client;
icalcomponent *icalcomp;
- gboolean read_only;
if (event == NULL || event->comp_data == NULL)
continue;
@@ -402,8 +401,7 @@ calendar_view_update_actions (ESelectable *selectable,
client = event->comp_data->client;
icalcomp = event->comp_data->icalcomp;
- e_cal_is_read_only (client, &read_only, NULL);
- sources_are_editable &= !read_only;
+ sources_are_editable = sources_are_editable && !e_client_is_readonly (E_CLIENT (client));
recurring |=
e_cal_util_component_is_instance (icalcomp) ||
@@ -488,17 +486,14 @@ calendar_view_cut_clipboard (ESelectable *selectable)
/* when cutting detached instances, only cut that instance */
rid = e_cal_component_get_recurid_as_string (comp);
- if (e_cal_get_object (event->comp_data->client, uid, rid, &icalcomp, NULL)) {
- e_cal_remove_object_with_mod (event->comp_data->client, uid,
- rid, CALOBJ_MOD_THIS,
- &error);
+ if (e_cal_client_get_object_sync (event->comp_data->client, uid, rid, &icalcomp, NULL, NULL)) {
+ e_cal_client_remove_object_sync (event->comp_data->client, uid, rid, CALOBJ_MOD_THIS, NULL, &error);
icalcomponent_free (icalcomp);
} else
- e_cal_remove_object_with_mod (event->comp_data->client, uid, NULL,
- CALOBJ_MOD_ALL, &error);
+ e_cal_client_remove_object_sync (event->comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error);
g_free (rid);
} else
- e_cal_remove_object (event->comp_data->client, uid, &error);
+ e_cal_client_remove_object_sync (event->comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error);
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
g_clear_error (&error);
@@ -514,7 +509,7 @@ calendar_view_cut_clipboard (ESelectable *selectable)
}
static void
-add_related_timezones (icalcomponent *des_icalcomp, icalcomponent *src_icalcomp, ECal *client)
+add_related_timezones (icalcomponent *des_icalcomp, icalcomponent *src_icalcomp, ECalClient *client)
{
icalproperty_kind look_in[] = {
ICAL_DTSTART_PROPERTY,
@@ -540,7 +535,7 @@ add_related_timezones (icalcomponent *des_icalcomp, icalcomponent *src_icalcomp,
GError *error = NULL;
icaltimezone *zone = NULL;
- if (!e_cal_get_timezone (client, tzid, &zone, &error)) {
+ if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) {
g_warning ("%s: Cannot get timezone for '%s'. %s", G_STRFUNC, tzid, error ? error->message : "");
if (error)
g_error_free (error);
@@ -628,7 +623,7 @@ clipboard_get_calendar_data (ECalendarView *cal_view,
icalcomponent_kind kind;
time_t selected_time_start, selected_time_end;
icaltimezone *default_zone;
- ECal *client;
+ ECalClient *client;
gboolean in_top_canvas;
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
@@ -671,7 +666,7 @@ clipboard_get_calendar_data (ECalendarView *cal_view,
zone = icaltimezone_new ();
icaltimezone_set_component (zone, subcomp);
- if (!e_cal_add_timezone (client, zone, &error)) {
+ if (!e_cal_client_add_timezone_sync (client, zone, NULL, &error)) {
icalproperty *tzidprop = icalcomponent_get_first_property (subcomp, ICAL_TZID_PROPERTY);
g_warning ("%s: Add zone '%s' failed. %s", G_STRFUNC, tzidprop ? icalproperty_get_tzid (tzidprop) : "???", error ? error->message : "");
@@ -949,7 +944,7 @@ e_calendar_view_popup_event (ECalendarView *calendar_view,
}
void
-e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart,
+e_calendar_view_add_event (ECalendarView *cal_view, ECalClient *client, time_t dtstart,
icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas)
{
ECalComponent *comp;
@@ -1049,7 +1044,7 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart
e_cal_component_commit_sequence (comp);
uid = NULL;
- if (e_cal_create_object (client, e_cal_component_get_icalcomponent (comp), &uid, &error)) {
+ if (e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) {
gboolean strip_alarms = TRUE;
if (uid) {
@@ -1284,15 +1279,15 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
delete = prompt_retract_dialog (comp, &retract_comment, GTK_WIDGET (cal_view), &retract);
if (retract) {
- GList *users = NULL;
+ GSList *users = NULL;
icalcomponent *icalcomp = NULL, *mod_comp = NULL;
calendar_view_add_retract_data (
comp, retract_comment, CALOBJ_MOD_THIS);
icalcomp = e_cal_component_get_icalcomponent (comp);
icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL);
- if (!e_cal_send_objects (event->comp_data->client, icalcomp, &users,
- &mod_comp, &error)) {
+ if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users,
+ &mod_comp, NULL, &error)) {
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
g_clear_error (&error);
error = NULL;
@@ -1300,8 +1295,8 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
if (mod_comp)
icalcomponent_free (mod_comp);
if (users) {
- g_list_foreach (users, (GFunc) g_free, NULL);
- g_list_free (users);
+ g_slist_foreach (users, (GFunc) g_free, NULL);
+ g_slist_free (users);
}
}
}
@@ -1323,7 +1318,7 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
if (dt.tzid) {
GError *error = NULL;
- e_cal_get_timezone (event->comp_data->client, dt.tzid, &zone, &error);
+ e_cal_client_get_timezone_sync (event->comp_data->client, dt.tzid, &zone, NULL, &error);
if (error) {
zone = e_calendar_view_get_timezone (cal_view);
g_clear_error (&error);
@@ -1339,7 +1334,7 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
if ((itip_organizer_is_user (comp, event->comp_data->client) || itip_sentby_is_user (comp, event->comp_data->client))
&& cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
event->comp_data->client,
- comp, TRUE) && !e_cal_get_save_schedules (event->comp_data->client)) {
+ comp, TRUE) && !e_cal_client_check_save_schedules (event->comp_data->client)) {
if (!e_cal_component_is_instance (comp)) {
ECalComponentRange range;
@@ -1355,15 +1350,14 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
}
if (is_instance)
- e_cal_remove_object_with_mod (event->comp_data->client, uid, rid, CALOBJ_MOD_THIS, &error);
+ e_cal_client_remove_object_sync (event->comp_data->client, uid, rid, CALOBJ_MOD_THIS, NULL, &error);
else {
struct icaltimetype instance_rid;
instance_rid = icaltime_from_timet_with_zone (event->comp_data->instance_start,
TRUE, zone ? zone : icaltimezone_get_utc_timezone ());
e_cal_util_remove_instances (event->comp_data->icalcomp, instance_rid, CALOBJ_MOD_THIS);
- e_cal_modify_object (event->comp_data->client, event->comp_data->icalcomp, CALOBJ_MOD_THIS,
- &error);
+ e_cal_client_modify_object_sync (event->comp_data->client, event->comp_data->icalcomp, CALOBJ_MOD_THIS, NULL, &error);
}
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
@@ -1414,10 +1408,9 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
ECalComponent *comp;
icalcomponent *icalcomp;
ECalComponentTransparency transparency;
- ECal *default_client = NULL;
+ ECalClient *default_client = NULL;
gpointer parent;
guint32 flags = 0;
- gboolean readonly = FALSE;
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
@@ -1428,15 +1421,15 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
default_client = e_cal_model_get_default_client (priv->model);
- if (!default_client || e_cal_get_load_state (default_client) != E_CAL_LOAD_LOADED) {
+ if (!default_client || !e_client_is_opened (E_CLIENT (default_client))) {
g_warning ("Default client not loaded \n");
return;
}
- if (e_cal_is_read_only (default_client, &readonly, NULL) && readonly) {
+ if (e_client_is_readonly (E_CLIENT (default_client))) {
GtkWidget *widget;
- widget = e_alert_dialog_new_for_args (parent, "calendar:prompt-read-only-cal", e_source_peek_name (e_cal_get_source (default_client)), NULL);
+ widget = e_alert_dialog_new_for_args (parent, "calendar:prompt-read-only-cal", e_source_peek_name (e_client_get_source (E_CLIENT (default_client))), NULL);
g_signal_connect ((GtkDialog *)widget, "response", G_CALLBACK (gtk_widget_destroy),
widget);
@@ -1588,7 +1581,7 @@ object_created_cb (CompEditor *ce, ECalendarView *cal_view)
}
CompEditor *
-e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, icalcomponent *icalcomp, guint32 flags)
+e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECalClient *client, icalcomponent *icalcomp, guint32 flags)
{
CompEditor *ce;
const gchar *uid;
@@ -1631,12 +1624,12 @@ e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, ic
* object.
*/
void
-e_calendar_view_edit_appointment (ECalendarView *cal_view, ECal *client, icalcomponent *icalcomp, EEditEventMode mode)
+e_calendar_view_edit_appointment (ECalendarView *cal_view, ECalClient *client, icalcomponent *icalcomp, EEditEventMode mode)
{
guint32 flags = 0;
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
g_return_if_fail (icalcomp != NULL);
if ((mode == EDIT_EVENT_AUTODETECT && icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY) != NULL)
@@ -1654,15 +1647,17 @@ e_calendar_view_edit_appointment (ECalendarView *cal_view, ECal *client, icalcom
void
e_calendar_view_modify_and_send (ECalComponent *comp,
- ECal *client,
+ ECalClient *client,
CalObjModType mod,
GtkWindow *toplevel,
gboolean new)
{
gboolean only_new_attendees = FALSE;
+ GError *error = NULL;
+
e_cal_component_commit_sequence (comp);
- if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) {
+ if (e_cal_client_modify_object_sync (client, e_cal_component_get_icalcomponent (comp), mod, NULL, &error)) {
gboolean strip_alarms = TRUE;
if ((itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp, client)) &&
@@ -1675,7 +1670,7 @@ e_calendar_view_modify_and_send (ECalComponent *comp,
const gchar *uid = NULL;
e_cal_component_get_uid (comp, &uid);
- if (e_cal_get_object (client, uid, NULL, &icalcomp, NULL) && icalcomp) {
+ if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) {
send_comp = e_cal_component_new ();
if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) {
icalcomponent_free (icalcomp);
@@ -1694,7 +1689,10 @@ e_calendar_view_modify_and_send (ECalComponent *comp,
g_object_unref (send_comp);
}
} else {
- g_message (G_STRLOC ": Could not update the object!");
+ g_message (G_STRLOC ": Could not update the object! %s", error ? error->message : "Unknown error");
+
+ if (error)
+ g_error_free (error);
}
}
@@ -1770,7 +1768,7 @@ e_calendar_view_move_tip (GtkWidget *widget, gint x, gint y)
* Free returned pointer with g_free.
**/
gchar *
-e_calendar_view_get_attendees_status_info (ECalComponent *comp, ECal *client)
+e_calendar_view_get_attendees_status_info (ECalComponent *comp, ECalClient *client)
{
struct _values {
icalparameter_partstat status;
@@ -1867,7 +1865,7 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data)
GdkWindow *window;
ECalComponent *newcomp = e_cal_component_new ();
icaltimezone *zone, *default_zone;
- ECal *client = NULL;
+ ECalClient *client = NULL;
gboolean free_text = FALSE;
/* Delete any stray tooltip if left */
@@ -1961,7 +1959,7 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data)
if (dtstart.tzid) {
zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (newcomp), dtstart.tzid);
if (!zone)
- e_cal_get_timezone (client, dtstart.tzid, &zone, NULL);
+ e_cal_client_get_timezone_sync (client, dtstart.tzid, &zone, NULL, NULL);
if (!zone)
zone = default_zone;
@@ -2067,7 +2065,7 @@ icalcomp_contains_category (icalcomponent *icalcomp, const gchar *category)
*/
const gchar *
-e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text)
+e_calendar_view_get_icalcomponent_summary (ECalClient *client, icalcomponent *icalcomp, gboolean *free_text)
{
const gchar *summary;
@@ -2081,11 +2079,11 @@ e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp,
struct icaltimetype dtstart, dtnow;
icalcomponent *item_icalcomp = NULL;
- if (e_cal_get_object (ecal,
+ if (e_cal_client_get_object_sync (client,
icalcomponent_get_uid (icalcomp),
icalcomponent_get_relcalid (icalcomp),
&item_icalcomp,
- NULL)) {
+ NULL, NULL)) {
dtstart = icalcomponent_get_dtstart (item_icalcomp);
dtnow = icalcomponent_get_dtstart (icalcomp);
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index 88ebbeea66..decfdfffbf 100644
--- a/calendar/gui/e-calendar-view.h
+++ b/calendar/gui/e-calendar-view.h
@@ -24,7 +24,7 @@
#define E_CALENDAR_VIEW_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include "e-cal-model.h"
#include "gnome-cal.h"
#include "dialogs/comp-editor.h"
@@ -210,7 +210,7 @@ void e_calendar_view_delete_selected_occurrence
(ECalendarView *cal_view);
CompEditor * e_calendar_view_open_event_with_flags
(ECalendarView *cal_view,
- ECal *client,
+ ECalClient *client,
icalcomponent *icalcomp,
guint32 flags);
@@ -218,7 +218,7 @@ void e_calendar_view_popup_event (ECalendarView *cal_view,
GdkEventButton *event);
void e_calendar_view_add_event (ECalendarView *cal_view,
- ECal *client,
+ ECalClient *client,
time_t dtstart,
icaltimezone *default_zone,
icalcomponent *icalcomp,
@@ -236,12 +236,12 @@ void e_calendar_view_new_appointment_full
gboolean no_past_date);
void e_calendar_view_new_appointment (ECalendarView *cal_view);
void e_calendar_view_edit_appointment (ECalendarView *cal_view,
- ECal *client,
+ ECalClient *client,
icalcomponent *icalcomp,
EEditEventMode mode);
void e_calendar_view_open_event (ECalendarView *cal_view);
void e_calendar_view_modify_and_send (ECalComponent *comp,
- ECal *client,
+ ECalClient *client,
CalObjModType mod,
GtkWindow *toplevel,
gboolean new);
@@ -253,12 +253,12 @@ void e_calendar_view_move_tip (GtkWidget *widget,
gint y);
const gchar * e_calendar_view_get_icalcomponent_summary
- (ECal *ecal,
+ (ECalClient *ecal,
icalcomponent *icalcomp,
gboolean *free_text);
gchar * e_calendar_view_get_attendees_status_info
(ECalComponent *comp,
- ECal *client);
+ ECalClient *client);
void e_calendar_view_emit_user_created
(ECalendarView *cal_view);
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 4aa87719fe..e7e44bab46 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -273,7 +273,7 @@ static ECalendarViewPosition e_day_view_convert_position_in_main_canvas (EDayVie
gint *row_return,
gint *event_num_return);
static gboolean e_day_view_find_event_from_uid (EDayView *day_view,
- ECal *client,
+ ECalClient *client,
const gchar *uid,
const gchar *rid,
gint *day_return,
@@ -2137,7 +2137,7 @@ e_day_view_update_event_label (EDayView *day_view,
"text", text,
NULL);
- if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)
+ if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)
&& e_cal_util_component_has_attendee (event->comp_data->icalcomp))
set_text_as_bold (event);
@@ -2172,7 +2172,7 @@ e_day_view_update_long_event_label (EDayView *day_view,
if (free_text)
g_free ((gchar *) summary);
- if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)
+ if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)
&& e_cal_util_component_has_attendee (event->comp_data->icalcomp))
set_text_as_bold (event);
}
@@ -2225,7 +2225,7 @@ e_day_view_find_event_from_item (EDayView *day_view,
see if any events with the uid exist. */
static gboolean
e_day_view_find_event_from_uid (EDayView *day_view,
- ECal *client,
+ ECalClient *client,
const gchar *uid,
const gchar *rid,
gint *day_return,
@@ -3475,9 +3475,7 @@ e_day_view_on_event_click (EDayView *day_view,
!e_cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (pos == E_CALENDAR_VIEW_POS_TOP_EDGE
|| pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE)) {
- gboolean read_only = FALSE;
-
- if (event && (!event->is_editable || (e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && read_only))) {
+ if (event && (!event->is_editable || e_client_is_readonly (E_CLIENT (event->comp_data->client)))) {
return;
}
@@ -3936,11 +3934,10 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
gtk_target_list_unref (target_list);
}
} else {
- gboolean read_only = FALSE;
cursor = day_view->normal_cursor;
/* Check if the event is editable and client is not readonly while changing the cursor */
- if (event && event->is_editable && is_comp_data_valid (event) && e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && !read_only) {
+ if (event && event->is_editable && is_comp_data_valid (event) && !e_client_is_readonly (E_CLIENT (event->comp_data->client))) {
switch (pos) {
case E_CALENDAR_VIEW_POS_LEFT_EDGE:
@@ -4119,7 +4116,6 @@ e_day_view_update_resize (EDayView *day_view,
EDayViewEvent *event;
gint day, event_num;
gboolean need_reshape = FALSE;
- gboolean read_only = FALSE;
#if 0
g_print ("Updating resize Row:%i\n", row);
@@ -4137,7 +4133,7 @@ e_day_view_update_resize (EDayView *day_view,
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- if (event && (!event->is_editable || !is_comp_data_valid (event) || (e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && read_only))) {
+ if (event && (!event->is_editable || !is_comp_data_valid (event) || e_client_is_readonly (E_CLIENT (event->comp_data->client)))) {
return;
}
@@ -4175,7 +4171,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
ECalComponentDateTime date;
struct icaltimetype itt;
time_t dt;
- ECal *client;
+ ECalClient *client;
CalObjModType mod = CALOBJ_MOD_ALL;
GtkWindow *toplevel;
gint is_date;
@@ -4290,7 +4286,7 @@ e_day_view_finish_resize (EDayView *day_view)
ECalComponentDateTime date;
struct icaltimetype itt;
time_t dt;
- ECal *client;
+ ECalClient *client;
CalObjModType mod = CALOBJ_MOD_ALL;
GtkWindow *toplevel;
@@ -5062,7 +5058,7 @@ static gboolean
e_day_view_add_new_event_in_selected_range (EDayView *day_view, GdkEventKey *key_event)
{
icalcomponent *icalcomp;
- ECal *ecal;
+ ECalClient *client;
ECalModel *model;
ECalComponent *comp;
gint day, event_num;
@@ -5071,12 +5067,11 @@ e_day_view_add_new_event_in_selected_range (EDayView *day_view, GdkEventKey *key
struct icaltimetype start_tt, end_tt;
const gchar *uid;
AddEventData add_event_data;
- gboolean read_only = TRUE;
/* Check if the client is read only */
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
- ecal = e_cal_model_get_default_client (model);
- if (!e_cal_is_read_only (ecal, &read_only, NULL) || read_only)
+ client = e_cal_model_get_default_client (model);
+ if (e_client_is_readonly (E_CLIENT (client)))
return FALSE;
icalcomp = e_cal_model_create_component_with_defaults (model, day_view->selection_in_top_canvas);
@@ -5128,7 +5123,7 @@ e_day_view_add_new_event_in_selected_range (EDayView *day_view, GdkEventKey *key
gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas);
- if (!e_day_view_find_event_from_uid (day_view, ecal, uid, NULL, &day, &event_num)) {
+ if (!e_day_view_find_event_from_uid (day_view, client, uid, NULL, &day, &event_num)) {
g_warning ("Couldn't find event to start editing.\n");
g_object_unref (comp);
return FALSE;
@@ -5980,7 +5975,6 @@ e_day_view_start_editing_event (EDayView *day_view,
EDayViewEvent *event;
ETextEventProcessor *event_processor = NULL;
ETextEventProcessorCommand command;
- gboolean read_only;
#if 0
g_print ("In e_day_view_start_editing_event\n");
@@ -6008,7 +6002,7 @@ e_day_view_start_editing_event (EDayView *day_view,
if (!is_comp_data_valid (event))
return;
- if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only)
+ if (e_client_is_readonly (E_CLIENT (event->comp_data->client)))
return;
/* If the event is not shown, don't try to edit it. */
@@ -6416,7 +6410,7 @@ e_day_view_change_event_time (EDayView *day_view, time_t start_dt, time_t end_dt
ECalComponent *comp;
ECalComponentDateTime date;
struct icaltimetype itt;
- ECal *client;
+ ECalClient *client;
CalObjModType mod = CALOBJ_MOD_ALL;
GtkWindow *toplevel;
@@ -6643,7 +6637,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
gchar *text = NULL;
ECalComponentText summary;
ECalComponent *comp;
- ECal *client;
+ ECalClient *client;
gboolean on_server;
/* Note: the item we are passed here isn't reliable, so we just stop
@@ -6728,11 +6722,21 @@ e_day_view_on_editing_stopped (EDayView *day_view,
e_cal_component_commit_sequence (comp);
if (!on_server) {
- if (!e_cal_create_object (client, icalcomp, NULL, NULL))
- g_message (G_STRLOC ": Could not create the object!");
- else
+ gchar *uid = NULL;
+ GError *error = NULL;
+
+ if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, &error)) {
+ uid = NULL;
+ g_debug (G_STRLOC ": Could not create the object! %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ } else {
+ icalcomponent_set_uid (icalcomp, uid);
e_calendar_view_emit_user_created (
E_CALENDAR_VIEW (day_view));
+ }
+
+ g_free (uid);
/* we remove the object since we either got the update from the server or failed */
e_day_view_remove_event_cb (day_view, day, event_num, NULL);
@@ -7801,7 +7805,7 @@ e_day_view_on_drag_data_get (GtkWidget *widget,
comp_str = icalcomponent_as_ical_string_r (vcal);
if (comp_str) {
- ESource *source = e_cal_get_source (event->comp_data->client);
+ ESource *source = e_client_get_source (E_CLIENT (event->comp_data->client));
const gchar *source_uid = e_source_peek_uid (source);
GdkAtom target;
gchar *tmp;
@@ -7841,7 +7845,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
struct icaltimetype itt;
time_t dt;
gboolean all_day_event;
- ECal *client;
+ ECalClient *client;
ECalModel *model;
ECalendarView *cal_view;
gboolean drag_from_same_window;
@@ -8043,7 +8047,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
zone = icaltimezone_new ();
icaltimezone_set_component (zone, subcomp);
- e_cal_add_timezone (client, zone, NULL);
+ e_cal_client_add_timezone_sync (client, zone, NULL, NULL);
icaltimezone_free (zone, 1);
}
@@ -8087,7 +8091,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
ECalComponentDateTime date;
struct icaltimetype itt;
time_t dt;
- ECal *client;
+ ECalClient *client;
gboolean drag_from_same_window;
const guchar *data;
gint format, length;
@@ -8270,7 +8274,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
zone = icaltimezone_new ();
icaltimezone_set_component (zone, subcomp);
- e_cal_add_timezone (client, zone, NULL);
+ e_cal_client_add_timezone_sync (client, zone, NULL, NULL);
icaltimezone_free (zone, 1);
}
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index 8728b24283..ae1cf79d56 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -235,9 +235,6 @@ struct _EDayView {
/* label showing week number in upper-left corner */
GtkWidget *week_number_label;
- /* S-expression for query and the query object */
- ECalView *query;
-
/* The start and end of the days shown. */
time_t lower;
time_t upper;
diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c
index c702bdfd77..11f47e6030 100644
--- a/calendar/gui/e-meeting-list-view.c
+++ b/calendar/gui/e-meeting-list-view.c
@@ -28,7 +28,7 @@
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-vcard.h>
#include <libecal/e-cal-component.h>
#include <libecal/e-cal-util.h>
@@ -762,54 +762,54 @@ process_section (EMeetingListView *view, GList *destinations, icalparameter_role
/* check if the contact is contact list which is not expanded yet */
/* we expand it by getting the list again from the server forming the query */
if (contact && e_contact_get (contact , E_CONTACT_IS_LIST)) {
- EBook *book = NULL;
+ EBookClient *book_client = NULL;
ENameSelectorDialog *dialog;
ENameSelectorModel *model;
EContactStore *c_store;
- GList *books, *l;
+ GSList *clients, *l;
gchar *uri = e_contact_get (contact, E_CONTACT_BOOK_URI);
dialog = e_name_selector_peek_dialog (view->priv->name_selector);
model = e_name_selector_dialog_peek_model (dialog);
c_store = e_name_selector_model_peek_contact_store (model);
- books = e_contact_store_get_books (c_store);
+ clients = e_contact_store_get_clients (c_store);
- for (l = books; l; l = l->next) {
- EBook *b = l->data;
- if (g_str_equal (uri, e_book_get_uri (b))) {
- book = b;
+ for (l = clients; l; l = l->next) {
+ EBookClient *b = l->data;
+ if (g_str_equal (uri, e_client_get_uri (E_CLIENT (b)))) {
+ book_client = b;
break;
}
}
- if (book) {
- GList *contacts;
+ if (book_client) {
+ GSList *contacts;
EContact *n_con = NULL;
- gchar *qu;
- EBookQuery *query;
+ gchar *query;
- qu = g_strdup_printf ("(is \"full_name\" \"%s\")",
+ query = g_strdup_printf ("(is \"full_name\" \"%s\")",
(gchar *) e_contact_get (contact, E_CONTACT_FULL_NAME));
- query = e_book_query_from_string (qu);
- if (!e_book_get_contacts (book, query, &contacts, NULL)) {
+ if (!e_book_client_get_contacts_sync (book_client, query, &contacts, NULL, NULL)) {
g_warning ("Could not get contact from the book \n");
+ g_free (query);
+ g_slist_free (clients);
return;
} else {
des = e_destination_new ();
n_con = contacts->data;
e_destination_set_contact (des, n_con, 0);
+ e_destination_set_client (des, book_client);
list_dests = e_destination_list_get_dests (des);
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
+ g_slist_free (contacts);
}
- e_book_query_unref (query);
- g_free (qu);
+ g_free (query);
}
- g_list_free (books);
+ g_slist_free (clients);
} else {
card_dest.next = NULL;
card_dest.prev = NULL;
@@ -822,31 +822,10 @@ process_section (EMeetingListView *view, GList *destinations, icalparameter_role
EDestination *dest = l->data;
EContact *contact;
const gchar *name, *attendee = NULL;
- gchar *attr = NULL, *fburi = NULL;
+ gchar *fburi = NULL;
name = e_destination_get_name (dest);
-
- /* Get the field as attendee from the backend */
- if (e_cal_get_ldap_attribute (e_meeting_store_get_client (priv->store),
- &attr, NULL)) {
- /* FIXME this should be more general */
- if (!g_ascii_strcasecmp (attr, "icscalendar")) {
-
- /* FIXME: this does not work, have to use first
- e_destination_use_contact () */
- contact = e_destination_get_contact (dest);
- if (contact) {
- attendee = e_contact_get (contact, E_CONTACT_FREEBUSY_URL);
- if (!attendee)
- attendee = e_contact_get (contact, E_CONTACT_CALENDAR_URI);
- }
- }
- }
-
- /* If we couldn't get the attendee prior, get the email address as the default */
- if (attendee == NULL || *attendee == '\0') {
- attendee = e_destination_get_email (dest);
- }
+ attendee = e_destination_get_email (dest);
if (attendee == NULL || *attendee == '\0')
continue;
diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c
index e18c259f65..ca4df0b854 100644
--- a/calendar/gui/e-meeting-store.c
+++ b/calendar/gui/e-meeting-store.c
@@ -49,7 +49,7 @@ struct _EMeetingStorePrivate {
GPtrArray *attendees;
gint stamp;
- ECal *client;
+ ECalClient *client;
icaltimezone *zone;
gint default_reminder_interval;
@@ -756,9 +756,9 @@ e_meeting_store_class_init (EMeetingStoreClass *class)
PROP_CLIENT,
g_param_spec_object (
"client",
- "Client",
+ "ECalClient",
NULL,
- E_TYPE_CAL,
+ E_TYPE_CAL_CLIENT,
G_PARAM_READWRITE));
g_object_class_install_property (
@@ -840,7 +840,7 @@ e_meeting_store_new (void)
return g_object_new (E_TYPE_MEETING_STORE, NULL);
}
-ECal *
+ECalClient *
e_meeting_store_get_client (EMeetingStore *store)
{
g_return_val_if_fail (E_IS_MEETING_STORE (store), NULL);
@@ -850,12 +850,12 @@ e_meeting_store_get_client (EMeetingStore *store)
void
e_meeting_store_set_client (EMeetingStore *store,
- ECal *client)
+ ECalClient *client)
{
g_return_if_fail (E_IS_MEETING_STORE (store));
if (client != NULL) {
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
g_object_ref (client);
}
@@ -1454,11 +1454,11 @@ replace_string (gchar *string, const gchar *from_value, gchar *to_value)
static void start_async_read (const gchar *uri, gpointer data);
typedef struct {
- ECal *client;
+ ECalClient *client;
time_t startt;
time_t endt;
- GList *users;
- GList *fb_data;
+ GSList *users;
+ GSList *fb_data;
gchar *fb_uri;
gchar *email;
EMeetingAttendee *attendee;
@@ -1469,6 +1469,21 @@ typedef struct {
#define USER_SUB "%u"
#define DOMAIN_SUB "%d"
+static void
+client_free_busy_data_cb (ECalClient *client, const GSList *ecalcomps, FreeBusyAsyncData *fbd)
+{
+ const GSList *iter;
+
+ g_return_if_fail (fbd != NULL);
+
+ for (iter = ecalcomps; iter != NULL; iter = iter->next) {
+ ECalComponent *comp = iter->data;
+
+ if (comp)
+ fbd->fb_data = g_slist_prepend (fbd->fb_data, g_object_ref (comp));
+ }
+}
+
static gboolean
freebusy_async (gpointer data)
{
@@ -1480,19 +1495,20 @@ freebusy_async (gpointer data)
EMeetingStorePrivate *priv = fbd->store->priv;
if (fbd->client) {
+ guint sigid;
/* FIXME This a workaround for getting all the free busy
* information for the users. We should be able to
* get free busy asynchronously. */
g_static_mutex_lock (&mutex);
priv->num_queries++;
- e_cal_get_free_busy (
- fbd->client, fbd->users, fbd->startt,
- fbd->endt, &(fbd->fb_data), NULL);
+ sigid = g_signal_connect (fbd->client, "free-busy-data", G_CALLBACK (client_free_busy_data_cb), fbd);
+ e_cal_client_get_free_busy_sync (fbd->client, fbd->startt, fbd->endt, fbd->users, NULL, NULL);
+ g_signal_handler_disconnect (fbd->client, sigid);
priv->num_queries--;
g_static_mutex_unlock (&mutex);
- g_list_foreach (fbd->users, (GFunc) g_free, NULL);
- g_list_free (fbd->users);
+ g_slist_foreach (fbd->users, (GFunc) g_free, NULL);
+ g_slist_free (fbd->users);
if (fbd->fb_data != NULL) {
ECalComponent *comp = fbd->fb_data->data;
@@ -1623,7 +1639,7 @@ refresh_busy_periods (gpointer data)
fbd->endt = icaltime_as_timet_with_zone (itt, priv->zone);
fbd->qdata = qdata;
- fbd->users = g_list_append (fbd->users, g_strdup (fbd->email));
+ fbd->users = g_slist_append (fbd->users, g_strdup (fbd->email));
}
@@ -1634,8 +1650,8 @@ refresh_busy_periods (gpointer data)
thread = g_thread_create ((GThreadFunc) freebusy_async, fbd, FALSE, &error);
if (!thread) {
/* do clean up stuff here */
- g_list_foreach (fbd->users, (GFunc) g_free, NULL);
- g_list_free (fbd->users);
+ g_slist_foreach (fbd->users, (GFunc) g_free, NULL);
+ g_slist_free (fbd->users);
g_free (fbd->email);
priv->refresh_idle_id = 0;
diff --git a/calendar/gui/e-meeting-store.h b/calendar/gui/e-meeting-store.h
index 2c863ef506..ec98bae554 100644
--- a/calendar/gui/e-meeting-store.h
+++ b/calendar/gui/e-meeting-store.h
@@ -24,7 +24,7 @@
#define E_MEETING_STORE_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <e-util/e-util-enums.h>
#include "e-meeting-attendee.h"
@@ -86,9 +86,9 @@ void e_meeting_store_set_value (EMeetingStore *meeting_store,
gint row,
gint col,
const gchar *val);
-ECal * e_meeting_store_get_client (EMeetingStore *meeting_store);
+ECalClient * e_meeting_store_get_client (EMeetingStore *meeting_store);
void e_meeting_store_set_client (EMeetingStore *meeting_store,
- ECal *client);
+ ECalClient *client);
gint e_meeting_store_get_default_reminder_interval
(EMeetingStore *meeting_store);
void e_meeting_store_set_default_reminder_interval
diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c
index bb41412417..abc4bf9bf3 100644
--- a/calendar/gui/e-memo-list-selector.c
+++ b/calendar/gui/e-memo-list-selector.c
@@ -25,9 +25,9 @@
#include "e-memo-list-selector.h"
#include <string.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
+#include <libedataserverui/e-client-utils.h>
#include "e-util/e-selection.h"
-#include "calendar/common/authentication.h"
#include "calendar/gui/comp-util.h"
struct _EMemoListSelectorPrivate {
@@ -37,23 +37,31 @@ struct _EMemoListSelectorPrivate {
static gpointer parent_class;
static gboolean
-memo_list_selector_update_single_object (ECal *client,
+memo_list_selector_update_single_object (ECalClient *client,
icalcomponent *icalcomp)
{
- gchar *uid;
+ gchar *uid = NULL;
icalcomponent *tmp_icalcomp;
uid = (gchar *) icalcomponent_get_uid (icalcomp);
- if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
- return e_cal_modify_object (
- client, icalcomp, CALOBJ_MOD_ALL, NULL);
+ if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL))
+ return e_cal_client_modify_object_sync (
+ client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
- return e_cal_create_object (client, icalcomp, &uid, NULL);
+ if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL))
+ return FALSE;
+
+ if (uid)
+ icalcomponent_set_uid (icalcomp, uid);
+
+ g_free (uid);
+
+ return TRUE;
}
static gboolean
-memo_list_selector_update_objects (ECal *client,
+memo_list_selector_update_objects (ECalClient *client,
icalcomponent *icalcomp)
{
icalcomponent *subcomp;
@@ -74,14 +82,19 @@ memo_list_selector_update_objects (ECal *client,
kind = icalcomponent_isa (subcomp);
if (kind == ICAL_VTIMEZONE_COMPONENT) {
icaltimezone *zone;
+ GError *error = NULL;
zone = icaltimezone_new ();
icaltimezone_set_component (zone, subcomp);
- success = e_cal_add_timezone (client, zone, NULL);
+ success = e_cal_client_add_timezone_sync (client, zone, NULL, &error);
icaltimezone_free (zone, 1);
- if (!success)
+ if (!success) {
+ g_debug ("%s: Failed to add timezone: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return FALSE;
+ }
} else if (kind == ICAL_VJOURNAL_COMPONENT) {
success = memo_list_selector_update_single_object (
client, subcomp);
@@ -96,9 +109,36 @@ memo_list_selector_update_objects (ECal *client,
return TRUE;
}
+static void
+client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ gchar *uid = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (uid != NULL);
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ if (error) {
+ g_debug ("%s: Failed to open memo list: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ if (client) {
+ if (!e_client_is_readonly (client))
+ e_cal_client_remove_object_sync (E_CAL_CLIENT (client), uid, NULL, CALOBJ_MOD_THIS, NULL, NULL);
+
+ g_object_unref (client);
+ }
+
+ g_free (uid);
+}
+
static gboolean
memo_list_selector_process_data (ESourceSelector *selector,
- ECal *client,
+ ECalClient *client,
const gchar *source_uid,
icalcomponent *icalcomp,
GdkDragAction action)
@@ -109,7 +149,6 @@ memo_list_selector_process_data (ESourceSelector *selector,
const gchar *uid;
gchar *old_uid = NULL;
gboolean success = FALSE;
- gboolean read_only = TRUE;
GError *error = NULL;
/* FIXME Deal with GDK_ACTION_ASK. */
@@ -123,13 +162,13 @@ memo_list_selector_process_data (ESourceSelector *selector,
if (old_uid == NULL)
old_uid = g_strdup (uid);
- if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) {
+ if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) {
icalcomponent_free (tmp_icalcomp);
success = TRUE;
goto exit;
}
- if (error != NULL && error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
+ if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
g_message (
"Failed to search the object in destination "
"task list: %s", error->message);
@@ -137,6 +176,9 @@ memo_list_selector_process_data (ESourceSelector *selector,
goto exit;
}
+ if (error)
+ g_error_free (error);
+
success = memo_list_selector_update_objects (client, icalcomp);
if (!success || action != GDK_ACTION_MOVE)
@@ -148,74 +190,93 @@ memo_list_selector_process_data (ESourceSelector *selector,
if (!E_IS_SOURCE (source) || e_source_get_readonly (source))
goto exit;
- client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
- if (client == NULL) {
- g_message ("Cannot create source client to remove old memo");
- goto exit;
- }
-
- e_cal_is_read_only (client, &read_only, NULL);
- if (!read_only && e_cal_open (client, TRUE, NULL))
- e_cal_remove_object (client, old_uid, NULL);
- else if (!read_only)
- g_message ("Cannot open source client to remove old memo");
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ client_opened_cb, g_strdup (old_uid));
- g_object_unref (client);
-
-exit:
+ exit:
g_free (old_uid);
return success;
}
-static gboolean
-memo_list_selector_data_dropped (ESourceSelector *selector,
- GtkSelectionData *selection_data,
- ESource *destination,
- GdkDragAction action,
- guint info)
+struct DropData
{
- ECal *client;
- GSList *list, *iter;
- gboolean success = FALSE;
+ ESourceSelector *selector;
+ GdkDragAction action;
+ GSList *list;
+};
- client = e_auth_new_cal_from_source (
- destination, E_CAL_SOURCE_TYPE_JOURNAL);
+static void
+client_opened_for_drop_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ struct DropData *dd = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
- if (client == NULL || !e_cal_open (client, TRUE, NULL))
- goto exit;
+ g_return_if_fail (dd != NULL);
- list = cal_comp_selection_get_string_list (selection_data);
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
- for (iter = list; iter != NULL; iter = iter->next) {
- gchar *source_uid = iter->data;
- icalcomponent *icalcomp;
- gchar *component_string;
+ if (error) {
+ g_debug ("%s: Failed to open memo list: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
- /* Each string is "source_uid\ncomponent_string". */
- component_string = strchr (source_uid, '\n');
- if (component_string == NULL)
- continue;
+ if (client) {
+ ECalClient *cal_client = E_CAL_CLIENT (client);
+ GSList *iter;
- *component_string++ = '\0';
- icalcomp = icalparser_parse_string (component_string);
- if (icalcomp == NULL)
- continue;
+ for (iter = dd->list; iter != NULL; iter = iter->next) {
+ gchar *source_uid = iter->data;
+ icalcomponent *icalcomp;
+ gchar *component_string;
- success = memo_list_selector_process_data (
- selector, client, source_uid, icalcomp, action);
+ /* Each string is "source_uid\ncomponent_string". */
+ component_string = strchr (source_uid, '\n');
+ if (component_string == NULL)
+ continue;
- icalcomponent_free (icalcomp);
- }
+ *component_string++ = '\0';
+ icalcomp = icalparser_parse_string (component_string);
+ if (icalcomp == NULL)
+ continue;
+
+ memo_list_selector_process_data (
+ dd->selector, cal_client, source_uid, icalcomp, dd->action);
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ icalcomponent_free (icalcomp);
+ }
-exit:
- if (client != NULL)
g_object_unref (client);
+ }
- return success;
+ g_slist_foreach (dd->list, (GFunc) g_free, NULL);
+ g_slist_free (dd->list);
+ g_object_unref (dd->selector);
+ g_free (dd);
+}
+
+static gboolean
+memo_list_selector_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *selection_data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info)
+{
+ struct DropData *dd;
+
+ dd = g_new0 (struct DropData, 1);
+ dd->selector = g_object_ref (selector);
+ dd->action = action;
+ dd->list = cal_comp_selection_get_string_list (selection_data);
+
+ e_client_utils_open_new (destination, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ client_opened_for_drop_cb, dd);
+
+ return TRUE;
}
static void
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index ab0ce1253d..e6396427da 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -155,7 +155,7 @@ static void
memo_table_model_cal_view_progress_cb (EMemoTable *memo_table,
const gchar *message,
gint progress,
- ECalSourceType type)
+ ECalClientSourceType type)
{
gdouble percent = (gdouble) progress;
@@ -164,9 +164,8 @@ memo_table_model_cal_view_progress_cb (EMemoTable *memo_table,
static void
memo_table_model_cal_view_complete_cb ( EMemoTable *memo_table,
- ECalendarStatus status,
- const gchar *error_msg,
- ECalSourceType type)
+ const GError *error,
+ ECalClientSourceType type)
{
memo_table_emit_status_message (memo_table, NULL, -1.0);
}
@@ -187,8 +186,8 @@ delete_selected_components (EMemoTable *memo_table)
ECalModelComponent *comp_data = (ECalModelComponent *) l->data;
GError *error = NULL;
- e_cal_remove_object (comp_data->client,
- icalcomponent_get_uid (comp_data->icalcomp), &error);
+ e_cal_client_remove_object_sync (comp_data->client,
+ icalcomponent_get_uid (comp_data->icalcomp), NULL, CALOBJ_MOD_THIS, NULL, &error);
delete_error_dialog (error, E_CAL_COMPONENT_JOURNAL);
g_clear_error (&error);
}
@@ -560,8 +559,8 @@ memo_table_query_tooltip (GtkWidget *widget,
e_cal_component_get_icalcomponent (new_comp),
dtstart.tzid);
if (!zone)
- e_cal_get_timezone (
- comp_data->client, dtstart.tzid, &zone, NULL);
+ e_cal_client_get_timezone_sync (
+ comp_data->client, dtstart.tzid, &zone, NULL, NULL);
if (!zone)
zone = default_zone;
} else {
@@ -701,12 +700,10 @@ memo_table_update_actions (ESelectable *selectable,
n_selected = e_table_selected_count (E_TABLE (memo_table));
list = e_memo_table_get_selected (memo_table);
- for (iter = list; iter != NULL; iter = iter->next) {
+ for (iter = list; iter != NULL && sources_are_editable; iter = iter->next) {
ECalModelComponent *comp_data = iter->data;
- gboolean read_only;
- e_cal_is_read_only (comp_data->client, &read_only, NULL);
- sources_are_editable &= !read_only;
+ sources_are_editable = sources_are_editable && !e_client_is_readonly (E_CLIENT (comp_data->client));
}
g_slist_free (list);
@@ -826,7 +823,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table,
icalcomponent *icalcomp;
gchar *uid;
ECalComponent *comp;
- ECal *client;
+ ECalClient *client;
ECalModel *model;
icalcomponent_kind kind;
const gchar *status_message;
@@ -869,6 +866,7 @@ clipboard_get_calendar_data (EMemoTable *memo_table,
child_kind == ICAL_VTODO_COMPONENT ||
child_kind == ICAL_VJOURNAL_COMPONENT) {
ECalComponent *tmp_comp;
+ GError *error = NULL;
uid = e_cal_component_gen_uid ();
tmp_comp = e_cal_component_new ();
@@ -876,31 +874,45 @@ clipboard_get_calendar_data (EMemoTable *memo_table,
tmp_comp,
icalcomponent_new_clone (subcomp));
e_cal_component_set_uid (tmp_comp, uid);
- free (uid);
+ g_free (uid);
+ uid = NULL;
/* FIXME Should we convert start/due/complete
* times? Also, need error handling.*/
- e_cal_create_object (
- client, e_cal_component_get_icalcomponent (tmp_comp),
- NULL, NULL);
+ if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error))
+ uid = NULL;
+ g_free (uid);
g_object_unref (tmp_comp);
+
+ if (error) {
+ g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
subcomp = icalcomponent_get_next_component (
vcal_comp, ICAL_ANY_COMPONENT);
}
} else {
+ GError *error = NULL;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
uid = e_cal_component_gen_uid ();
e_cal_component_set_uid (comp, (const gchar *) uid);
- free (uid);
+ g_free (uid);
- e_cal_create_object (
- client, e_cal_component_get_icalcomponent (comp),
- NULL, NULL);
+ uid = NULL;
+ if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error))
+ uid = NULL;
+ g_free (uid);
g_object_unref (comp);
+
+ if (error) {
+ g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
memo_table_emit_status_message (memo_table, NULL, -1.0);
diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c
index 6967648b1f..9d1fb5cb99 100644
--- a/calendar/gui/e-task-list-selector.c
+++ b/calendar/gui/e-task-list-selector.c
@@ -25,9 +25,9 @@
#include "e-task-list-selector.h"
#include <string.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
+#include <libedataserverui/e-client-utils.h>
#include "e-util/e-selection.h"
-#include "calendar/common/authentication.h"
#include "calendar/gui/comp-util.h"
struct _ETaskListSelectorPrivate {
@@ -37,23 +37,31 @@ struct _ETaskListSelectorPrivate {
static gpointer parent_class;
static gboolean
-task_list_selector_update_single_object (ECal *client,
+task_list_selector_update_single_object (ECalClient *client,
icalcomponent *icalcomp)
{
- gchar *uid;
+ gchar *uid = NULL;
icalcomponent *tmp_icalcomp;
uid = (gchar *) icalcomponent_get_uid (icalcomp);
- if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
- return e_cal_modify_object (
- client, icalcomp, CALOBJ_MOD_ALL, NULL);
+ if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL))
+ return e_cal_client_modify_object_sync (
+ client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
- return e_cal_create_object (client, icalcomp, &uid, NULL);
+ if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL))
+ return FALSE;
+
+ if (uid)
+ icalcomponent_set_uid (icalcomp, uid);
+
+ g_free (uid);
+
+ return TRUE;
}
static gboolean
-task_list_selector_update_objects (ECal *client,
+task_list_selector_update_objects (ECalClient *client,
icalcomponent *icalcomp)
{
icalcomponent *subcomp;
@@ -74,14 +82,19 @@ task_list_selector_update_objects (ECal *client,
kind = icalcomponent_isa (subcomp);
if (kind == ICAL_VTIMEZONE_COMPONENT) {
icaltimezone *zone;
+ GError *error = NULL;
zone = icaltimezone_new ();
icaltimezone_set_component (zone, subcomp);
- success = e_cal_add_timezone (client, zone, NULL);
+ success = e_cal_client_add_timezone_sync (client, zone, NULL, &error);
icaltimezone_free (zone, 1);
- if (!success)
+ if (!success) {
+ g_debug ("%s: Failed to add timezone: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return FALSE;
+ }
} else if (kind == ICAL_VTODO_COMPONENT ||
kind == ICAL_VEVENT_COMPONENT) {
success = task_list_selector_update_single_object (
@@ -97,9 +110,36 @@ task_list_selector_update_objects (ECal *client,
return TRUE;
}
+static void
+client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ gchar *uid = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (uid != NULL);
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ if (error) {
+ g_debug ("%s: Failed to open task list: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ if (client) {
+ if (!e_client_is_readonly (client))
+ e_cal_client_remove_object_sync (E_CAL_CLIENT (client), uid, NULL, CALOBJ_MOD_THIS, NULL, NULL);
+
+ g_object_unref (client);
+ }
+
+ g_free (uid);
+}
+
static gboolean
task_list_selector_process_data (ESourceSelector *selector,
- ECal *client,
+ ECalClient *client,
const gchar *source_uid,
icalcomponent *icalcomp,
GdkDragAction action)
@@ -110,7 +150,6 @@ task_list_selector_process_data (ESourceSelector *selector,
const gchar *uid;
gchar *old_uid = NULL;
gboolean success = FALSE;
- gboolean read_only = TRUE;
GError *error = NULL;
/* FIXME Deal with GDK_ACTION_ASK. */
@@ -124,13 +163,13 @@ task_list_selector_process_data (ESourceSelector *selector,
if (old_uid == NULL)
old_uid = g_strdup (uid);
- if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) {
+ if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) {
icalcomponent_free (tmp_icalcomp);
success = TRUE;
goto exit;
}
- if (error != NULL && error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
+ if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
g_message (
"Failed to search the object in destination "
"task list: %s", error->message);
@@ -138,6 +177,10 @@ task_list_selector_process_data (ESourceSelector *selector,
goto exit;
}
+ if (error)
+ g_error_free (error);
+ error = NULL;
+
success = task_list_selector_update_objects (client, icalcomp);
if (!success || action != GDK_ACTION_MOVE)
@@ -149,74 +192,93 @@ task_list_selector_process_data (ESourceSelector *selector,
if (!E_IS_SOURCE (source) || e_source_get_readonly (source))
goto exit;
- client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
- if (client == NULL) {
- g_message ("Cannot create source client to remove old task");
- goto exit;
- }
-
- e_cal_is_read_only (client, &read_only, NULL);
- if (!read_only && e_cal_open (client, TRUE, NULL))
- e_cal_remove_object (client, old_uid, NULL);
- else if (!read_only)
- g_message ("Cannot open source client to remove old task");
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ client_opened_cb, g_strdup (old_uid));
- g_object_unref (client);
-
-exit:
+ exit:
g_free (old_uid);
return success;
}
-static gboolean
-task_list_selector_data_dropped (ESourceSelector *selector,
- GtkSelectionData *selection_data,
- ESource *destination,
- GdkDragAction action,
- guint info)
+struct DropData
{
- ECal *client;
- GSList *list, *iter;
- gboolean success = FALSE;
+ ESourceSelector *selector;
+ GdkDragAction action;
+ GSList *list;
+};
- client = e_auth_new_cal_from_source (
- destination, E_CAL_SOURCE_TYPE_TODO);
+static void
+client_opened_for_drop_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ struct DropData *dd = user_data;
+ EClient *client = NULL;
+ GError *error = NULL;
- if (client == NULL || !e_cal_open (client, TRUE, NULL))
- goto exit;
+ g_return_if_fail (dd != NULL);
- list = cal_comp_selection_get_string_list (selection_data);
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
- for (iter = list; iter != NULL; iter = iter->next) {
- gchar *source_uid = iter->data;
- icalcomponent *icalcomp;
- gchar *component_string;
+ if (error) {
+ g_debug ("%s: Failed to open task list: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
- /* Each string is "source_uid\ncomponent_string". */
- component_string = strchr (source_uid, '\n');
- if (component_string == NULL)
- continue;
+ if (client) {
+ ECalClient *cal_client = E_CAL_CLIENT (client);
+ GSList *iter;
- *component_string++ = '\0';
- icalcomp = icalparser_parse_string (component_string);
- if (icalcomp == NULL)
- continue;
+ for (iter = dd->list; iter != NULL; iter = iter->next) {
+ gchar *source_uid = iter->data;
+ icalcomponent *icalcomp;
+ gchar *component_string;
- success = task_list_selector_process_data (
- selector, client, source_uid, icalcomp, action);
+ /* Each string is "source_uid\ncomponent_string". */
+ component_string = strchr (source_uid, '\n');
+ if (component_string == NULL)
+ continue;
- icalcomponent_free (icalcomp);
- }
+ *component_string++ = '\0';
+ icalcomp = icalparser_parse_string (component_string);
+ if (icalcomp == NULL)
+ continue;
+
+ task_list_selector_process_data (
+ dd->selector, cal_client, source_uid, icalcomp, dd->action);
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ icalcomponent_free (icalcomp);
+ }
-exit:
- if (client != NULL)
g_object_unref (client);
+ }
- return success;
+ g_slist_foreach (dd->list, (GFunc) g_free, NULL);
+ g_slist_free (dd->list);
+ g_object_unref (dd->selector);
+ g_free (dd);
+}
+
+static gboolean
+task_list_selector_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *selection_data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info)
+{
+ struct DropData *dd;
+
+ dd = g_new0 (struct DropData, 1);
+ dd->selector = g_object_ref (selector);
+ dd->action = action;
+ dd->list = cal_comp_selection_get_string_list (selection_data);
+
+ e_client_utils_open_new (destination, E_CLIENT_SOURCE_TYPE_TASKS, TRUE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ client_opened_for_drop_cb, dd);
+
+ return TRUE;
}
static void
diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c
index 540ce1cc63..38b1d9ece5 100644
--- a/calendar/gui/e-task-table.c
+++ b/calendar/gui/e-task-table.c
@@ -233,7 +233,7 @@ static void
task_table_model_cal_view_progress_cb (ETaskTable *task_table,
const gchar *message,
gint progress,
- ECalSourceType type)
+ ECalClientSourceType type)
{
gdouble percent = (gdouble) progress;
@@ -242,9 +242,8 @@ task_table_model_cal_view_progress_cb (ETaskTable *task_table,
static void
task_table_model_cal_view_complete_cb ( ETaskTable *task_table,
- ECalendarStatus status,
- const gchar *error_msg,
- ECalSourceType type)
+ const GError *error,
+ ECalClientSourceType type)
{
task_table_emit_status_message (task_table, NULL, -1.0);
}
@@ -265,8 +264,7 @@ delete_selected_components (ETaskTable *task_table)
ECalModelComponent *comp_data = (ECalModelComponent *) l->data;
GError *error = NULL;
- e_cal_remove_object (comp_data->client,
- icalcomponent_get_uid (comp_data->icalcomp), &error);
+ e_cal_client_remove_object_sync (comp_data->client, icalcomponent_get_uid (comp_data->icalcomp), NULL, CALOBJ_MOD_THIS, NULL, &error);
delete_error_dialog (error, E_CAL_COMPONENT_TODO);
g_clear_error (&error);
}
@@ -782,8 +780,8 @@ task_table_query_tooltip (GtkWidget *widget,
e_cal_component_get_icalcomponent (new_comp),
dtstart.tzid);
if (!zone)
- e_cal_get_timezone (
- comp_data->client, dtstart.tzid, &zone, NULL);
+ e_cal_client_get_timezone_sync (
+ comp_data->client, dtstart.tzid, &zone, NULL, NULL);
if (!zone)
zone = default_zone;
} else {
@@ -932,12 +930,10 @@ task_table_update_actions (ESelectable *selectable,
n_selected = e_table_selected_count (E_TABLE (task_table));
list = e_task_table_get_selected (task_table);
- for (iter = list; iter != NULL; iter = iter->next) {
+ for (iter = list; iter != NULL && sources_are_editable; iter = iter->next) {
ECalModelComponent *comp_data = iter->data;
- gboolean read_only;
- e_cal_is_read_only (comp_data->client, &read_only, NULL);
- sources_are_editable &= !read_only;
+ sources_are_editable = sources_are_editable && !e_client_is_readonly (E_CLIENT (comp_data->client));
}
g_slist_free (list);
@@ -1058,7 +1054,7 @@ clipboard_get_calendar_data (ETaskTable *task_table,
gchar *uid;
ECalComponent *comp;
ECalModel *model;
- ECal *client;
+ ECalClient *client;
icalcomponent_kind kind;
const gchar *status_message;
@@ -1100,6 +1096,7 @@ clipboard_get_calendar_data (ETaskTable *task_table,
child_kind == ICAL_VTODO_COMPONENT ||
child_kind == ICAL_VJOURNAL_COMPONENT) {
ECalComponent *tmp_comp;
+ GError *error = NULL;
uid = e_cal_component_gen_uid ();
tmp_comp = e_cal_component_new ();
@@ -1107,31 +1104,45 @@ clipboard_get_calendar_data (ETaskTable *task_table,
tmp_comp,
icalcomponent_new_clone (subcomp));
e_cal_component_set_uid (tmp_comp, uid);
- free (uid);
+ g_free (uid);
+ uid = NULL;
/* FIXME should we convert start/due/complete
* times? Also, need error handling. */
- e_cal_create_object (
- client, e_cal_component_get_icalcomponent (tmp_comp),
- NULL, NULL);
+ if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error))
+ uid = NULL;
+
+ if (error) {
+ g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
g_object_unref (tmp_comp);
+ g_free (uid);
}
subcomp = icalcomponent_get_next_component (
vcal_comp, ICAL_ANY_COMPONENT);
}
} else {
+ GError *error = NULL;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
uid = e_cal_component_gen_uid ();
e_cal_component_set_uid (comp, (const gchar *) uid);
- free (uid);
+ g_free (uid);
+ uid = NULL;
- e_cal_create_object (
- client, e_cal_component_get_icalcomponent (comp),
- NULL, NULL);
+ if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error))
+ uid = NULL;
+
+ if (error) {
+ g_debug ("%s: Failed to create object: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
g_object_unref (comp);
+ g_free (uid);
}
task_table_emit_status_message (task_table, NULL, -1.0);
@@ -1228,7 +1239,7 @@ add_retract_data (ECalComponent *comp, const gchar *retract_comment)
}
static gboolean
-check_for_retract (ECalComponent *comp, ECal *client)
+check_for_retract (ECalComponent *comp, ECalClient *client)
{
ECalComponentOrganizer org;
gchar *email = NULL;
@@ -1238,15 +1249,15 @@ check_for_retract (ECalComponent *comp, ECal *client)
if (!e_cal_component_has_attendees (comp))
return FALSE;
- if (!e_cal_get_save_schedules (client))
+ if (!e_cal_client_check_save_schedules (client))
return FALSE;
e_cal_component_get_organizer (comp, &org);
strip = itip_strip_mailto (org.value);
ret_val =
- e_cal_get_cal_address (client, &email, NULL) &&
- g_ascii_strcasecmp (email, strip) == 0;
+ e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) &&
+ email && g_ascii_strcasecmp (email, strip) == 0;
g_free (email);
@@ -1292,14 +1303,13 @@ task_table_delete_selection (ESelectable *selectable)
comp, &retract_comment,
GTK_WIDGET (task_table), &retract);
if (retract) {
- GList *users = NULL;
+ GSList *users = NULL;
icalcomponent *icalcomp = NULL, *mod_comp = NULL;
add_retract_data (comp, retract_comment);
icalcomp = e_cal_component_get_icalcomponent (comp);
icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL);
- if (!e_cal_send_objects (comp_data->client, icalcomp, &users,
- &mod_comp, &error)) {
+ if (!e_cal_client_send_objects_sync (comp_data->client, icalcomp, &users, &mod_comp, NULL, &error)) {
delete_error_dialog (error, E_CAL_COMPONENT_TODO);
g_clear_error (&error);
error = NULL;
@@ -1309,8 +1319,8 @@ task_table_delete_selection (ESelectable *selectable)
icalcomponent_free (mod_comp);
if (users) {
- g_list_foreach (users, (GFunc) g_free, NULL);
- g_list_free (users);
+ g_slist_foreach (users, (GFunc) g_free, NULL);
+ g_slist_free (users);
}
}
@@ -1596,17 +1606,21 @@ hide_completed_rows (ECalModel *model,
gchar *hide_sexp,
GPtrArray *comp_objects)
{
- GList *l, *m, *objects;
- ECal *client;
+ GList *l;
+ GSList *m, *objects;
+ ECalClient *client;
gint pos;
gboolean changed = FALSE;
for (l = clients_list; l != NULL; l = l->next) {
- client = l->data;
+ GError *error = NULL;
- if (!e_cal_get_object_list (client, hide_sexp, &objects, NULL)) {
- g_warning (G_STRLOC ": Could not get the objects");
+ client = l->data;
+ if (!e_cal_client_get_object_list_sync (client, hide_sexp, &objects, NULL, &error)) {
+ g_debug ("%s: Could not get the objects: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
continue;
}
@@ -1635,8 +1649,8 @@ hide_completed_rows (ECalModel *model,
g_object_unref (comp);
}
- g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
- g_list_free (objects);
+ g_slist_foreach (objects, (GFunc) icalcomponent_free, NULL);
+ g_slist_free (objects);
}
if (changed) {
@@ -1652,15 +1666,19 @@ show_completed_rows (ECalModel *model,
gchar *show_sexp,
GPtrArray *comp_objects)
{
- GList *l, *m, *objects;
- ECal *client;
+ GList *l;
+ GSList *m, *objects;
+ ECalClient *client;
for (l = clients_list; l != NULL; l = l->next) {
- client = l->data;
+ GError *error = NULL;
- if (!e_cal_get_object_list (client, show_sexp, &objects, NULL)) {
- g_warning (G_STRLOC ": Could not get the objects");
+ client = l->data;
+ if (!e_cal_client_get_object_list_sync (client, show_sexp, &objects, NULL, &error)) {
+ g_debug ("%s: Could not get the objects: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
continue;
}
@@ -1697,6 +1715,9 @@ show_completed_rows (ECalModel *model,
e_cal_component_free_id (id);
g_object_unref (comp);
}
+
+ g_slist_foreach (objects, (GFunc) icalcomponent_free, NULL);
+ g_slist_free (objects);
}
}
diff --git a/calendar/gui/e-timezone-entry.h b/calendar/gui/e-timezone-entry.h
index 6c0cd1dc6b..59d2c00cb1 100644
--- a/calendar/gui/e-timezone-entry.h
+++ b/calendar/gui/e-timezone-entry.h
@@ -33,7 +33,7 @@
#define E_TIMEZONE_ENTRY_H
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
/* Standard GObject macros */
#define E_TYPE_TIMEZONE_ENTRY \
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index d6f430f2a1..47f03a9fa2 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -148,7 +148,7 @@ static void e_week_view_on_editing_started (EWeekView *week_view,
static void e_week_view_on_editing_stopped (EWeekView *week_view,
GnomeCanvasItem *item);
static gboolean e_week_view_find_event_from_uid (EWeekView *week_view,
- ECal *client,
+ ECalClient *client,
const gchar *uid,
const gchar *rid,
gint *event_num_return);
@@ -708,7 +708,6 @@ e_week_view_init (EWeekView *week_view)
gtk_widget_set_can_focus (GTK_WIDGET (week_view), TRUE);
- week_view->query = NULL;
week_view->event_destroyed = FALSE;
week_view->events = g_array_new (FALSE, FALSE,
sizeof (EWeekViewEvent));
@@ -875,13 +874,6 @@ e_week_view_dispose (GObject *object)
week_view->events = NULL;
}
- if (week_view->query) {
- g_signal_handlers_disconnect_matched (week_view->query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, week_view);
- g_object_unref (week_view->query);
- week_view->query = NULL;
- }
-
if (week_view->small_font_desc) {
pango_font_description_free (week_view->small_font_desc);
week_view->small_font_desc = NULL;
@@ -3018,7 +3010,7 @@ tooltip_event_cb (GnomeCanvasItem *item,
}
static const gchar *
-get_comp_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text)
+get_comp_summary (ECalClient *client, icalcomponent *icalcomp, gboolean *free_text)
{
const gchar *my_summary, *location;
const gchar *summary;
@@ -3026,7 +3018,7 @@ get_comp_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text)
g_return_val_if_fail (icalcomp != NULL && free_text != NULL, NULL);
- my_summary = e_calendar_view_get_icalcomponent_summary (ecal, icalcomp, &my_free_text);
+ my_summary = e_calendar_view_get_icalcomponent_summary (client, icalcomp, &my_free_text);
location = icalcomponent_get_location (icalcomp);
if (location && *location) {
@@ -3172,7 +3164,7 @@ e_week_view_reshape_event_span (EWeekView *week_view,
if (free_text)
g_free ((gchar *) summary);
- if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)
+ if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)
&& e_cal_util_component_has_attendee (event->comp_data->icalcomp)) {
set_text_as_bold (event, span);
}
@@ -3335,7 +3327,6 @@ e_week_view_start_editing_event (EWeekView *week_view,
ETextEventProcessor *event_processor = NULL;
ETextEventProcessorCommand command;
ECalModelComponent *comp_data;
- gboolean read_only;
/* If we are already editing the event, just return. */
if (event_num == week_view->editing_event_num
@@ -3356,7 +3347,7 @@ e_week_view_start_editing_event (EWeekView *week_view,
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
- if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only)
+ if (e_client_is_readonly (E_CLIENT (event->comp_data->client)))
return FALSE;
/* If the event is not shown, don't try to edit it. */
@@ -3814,7 +3805,7 @@ e_week_view_change_event_time (EWeekView *week_view, time_t start_dt, time_t end
ECalComponent *comp;
ECalComponentDateTime date;
struct icaltimetype itt;
- ECal *client;
+ ECalClient *client;
CalObjModType mod = CALOBJ_MOD_ALL;
GtkWindow *toplevel;
@@ -3924,7 +3915,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
gchar *text = NULL;
ECalComponent *comp;
ECalComponentText summary;
- ECal *client;
+ ECalClient *client;
const gchar *uid;
gboolean on_server;
@@ -4003,11 +3994,24 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
e_cal_component_commit_sequence (comp);
if (!on_server) {
- if (!e_cal_create_object (client, icalcomp, NULL, NULL))
- g_message (G_STRLOC ": Could not create the object!");
- else
+ gchar *uid = NULL;
+ GError *error = NULL;
+
+ if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, &error)) {
+ g_message (G_STRLOC ": Could not create the object! %s", error ? error->message : "Unknown error");
+ uid = NULL;
+ } else {
+ if (uid)
+ icalcomponent_set_uid (icalcomp, uid);
+
e_calendar_view_emit_user_created (
E_CALENDAR_VIEW (week_view));
+ }
+
+ if (uid)
+ g_free (uid);
+ if (error)
+ g_error_free (error);
/* we remove the object since we either got the update from the server or failed */
e_week_view_remove_event_cb (week_view, event_num, NULL);
@@ -4130,7 +4134,7 @@ e_week_view_find_event_from_item (EWeekView *week_view,
see if any events with the uid exist. */
static gboolean
e_week_view_find_event_from_uid (EWeekView *week_view,
- ECal *client,
+ ECalClient *client,
const gchar *uid,
const gchar *rid,
gint *event_num_return)
@@ -4256,7 +4260,7 @@ e_week_view_cursor_key_right (EWeekView *week_view)
static gboolean
e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar *initial_text)
{
- ECal *ecal;
+ ECalClient *client;
ECalModel *model;
ECalComponent *comp;
icalcomponent *icalcomp;
@@ -4266,14 +4270,13 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar *
time_t dtstart, dtend;
const gchar *uid;
AddEventData add_event_data;
- gboolean read_only = TRUE;
EWeekViewEvent *wvevent;
EWeekViewEventSpan *span;
/* Check if the client is read only */
model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
- ecal = e_cal_model_get_default_client (model);
- if (!e_cal_is_read_only (ecal, &read_only, NULL) || read_only)
+ client = e_cal_model_get_default_client (model);
+ if (e_client_is_readonly (E_CLIENT (client)))
return FALSE;
/* Add a new event covering the selected range. */
@@ -4316,7 +4319,7 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar *
e_week_view_check_layout (week_view);
gtk_widget_queue_draw (week_view->main_canvas);
- if (!e_week_view_find_event_from_uid (week_view, ecal, uid, NULL, &event_num)) {
+ if (!e_week_view_find_event_from_uid (week_view, client, uid, NULL, &event_num)) {
g_warning ("Couldn't find event to start editing.\n");
g_object_unref (comp);
return FALSE;
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 3f65149f19..9525b87c02 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -185,9 +185,6 @@ struct _EWeekView {
GtkWidget *vscrollbar;
- /* The query object */
- ECalView *query;
-
/* The array of EWeekViewEvent elements. */
GArray *events;
gboolean events_sorted;
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index ffbc449584..78721bf214 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -38,7 +38,9 @@
#include <libedataserver/e-categories.h>
#include <libedataserver/e-url.h>
#include <libedataserverui/e-passwords.h>
+#include <libedataserverui/e-client-utils.h>
+#include <libecal/e-cal-client-view.h>
#include <libecal/e-cal-time-util.h>
#include <widgets/menus/gal-view-factory-etable.h>
#include <widgets/menus/gal-view-etable.h>
@@ -63,7 +65,6 @@
#include "tag-calendar.h"
#include "misc.h"
#include "ea-calendar.h"
-#include "common/authentication.h"
#include "e-memo-table.h"
#include "e-task-table.h"
@@ -290,7 +291,7 @@ static void
view_progress_cb (ECalModel *model,
const gchar *message,
gint percent,
- ECalSourceType type,
+ ECalClientSourceType type,
GnomeCalendar *gcal)
{
gcal_update_status_message (gcal, message, percent);
@@ -298,9 +299,8 @@ view_progress_cb (ECalModel *model,
static void
view_complete_cb (ECalModel *model,
- ECalendarStatus status,
- const gchar *error_msg,
- ECalSourceType type,
+ const GError *error,
+ ECalClientSourceType type,
GnomeCalendar *gcal)
{
gcal_update_status_message (gcal, NULL, -1);
@@ -752,11 +752,11 @@ ensure_dates_are_in_default_zone (GnomeCalendar *gcal,
/* Callback used when the calendar query reports of an updated object */
static void
-dn_e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer data)
+dn_client_view_objects_added_cb (ECalClientView *view, const GSList *objects, gpointer data)
{
GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
- GList *l;
+ const GSList *l;
gcal = GNOME_CALENDAR (data);
priv = gcal->priv;
@@ -774,14 +774,14 @@ dn_e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer data)
tag_calendar_by_comp (
priv->date_navigator, comp,
- e_cal_view_get_client (query),
+ e_cal_client_view_get_client (view),
NULL, FALSE, TRUE, TRUE);
g_object_unref (comp);
}
}
static void
-dn_e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer data)
+dn_client_view_objects_modified_cb (ECalClientView *view, const GSList *objects, gpointer data)
{
GnomeCalendar *gcal;
@@ -796,7 +796,7 @@ dn_e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer dat
/* Callback used when the calendar query reports of a removed object */
static void
-dn_e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer data)
+dn_client_view_objects_removed_cb (ECalClientView *view, const GSList *ids, gpointer data)
{
GnomeCalendar *gcal;
@@ -808,17 +808,11 @@ dn_e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer data)
/* Callback used when the calendar query is done */
static void
-dn_e_cal_view_complete_cb (ECalView *query,
- ECalendarStatus status,
- const gchar *error_msg,
- gpointer data)
+dn_client_view_complete_cb (ECalClientView *query, const GError *error, gpointer data)
{
/* FIXME Better error reporting */
- if (status != E_CALENDAR_STATUS_OK)
- g_warning (
- G_STRLOC ": Query did not successfully complete, "
- "code: %d (%s)", status, error_msg ? error_msg :
- "Unknown error");
+ if (error)
+ g_debug ("%s: Query did not complete successfully: %s", G_STRFUNC, error->message);
}
ECalendarView *
@@ -1009,7 +1003,7 @@ get_date_navigator_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_t
/* Adjusts a given query sexp with the time range of the date navigator */
static gchar *
-adjust_e_cal_view_sexp (GnomeCalendar *gcal, const gchar *sexp)
+adjust_client_view_sexp (GnomeCalendar *gcal, const gchar *sexp)
{
time_t start_time, end_time;
gchar *start, *end;
@@ -1058,9 +1052,7 @@ free_dn_queries (GnomeCalendar *gcal)
for (l = priv->dn_queries; l != NULL; l = l->next) {
if (!l->data)
continue;
- g_signal_handlers_disconnect_matched (
- l->data, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
+ g_signal_handlers_disconnect_matched (l->data, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal);
g_object_unref (l->data);
}
@@ -1075,7 +1067,7 @@ update_query_async (struct _date_query_msg *msg)
{
GnomeCalendar *gcal = msg->gcal;
GnomeCalendarPrivate *priv;
- ECalView *new_query;
+ ECalClientView *new_view;
gchar *real_sexp;
GList *list, *iter;
@@ -1086,7 +1078,7 @@ update_query_async (struct _date_query_msg *msg)
g_return_if_fail (priv->sexp != NULL);
- real_sexp = adjust_e_cal_view_sexp (gcal, priv->sexp);
+ real_sexp = adjust_client_view_sexp (gcal, priv->sexp);
if (!real_sexp) {
return; /* No time range is set, so don't start a query */
}
@@ -1096,19 +1088,19 @@ update_query_async (struct _date_query_msg *msg)
/* create queries for each loaded client */
for (iter = list; iter != NULL; iter = iter->next) {
- ECal *client = E_CAL (iter->data);
+ ECalClient *client = E_CAL_CLIENT (iter->data);
GError *error = NULL;
gint tries = 0;
/* don't create queries for clients not loaded yet */
- if (e_cal_get_load_state (client) != E_CAL_LOAD_LOADED)
+ if (!e_client_is_opened (E_CLIENT (client)))
continue;
-try_again:
- new_query = NULL;
- if (!e_cal_get_query (client, real_sexp, &new_query, &error)) {
+ try_again:
+ new_view = NULL;
+ if (!e_cal_client_get_view_sync (client, real_sexp, &new_view, NULL, &error)) {
/* If calendar is busy try again for 3 times. */
- if (error->code == E_CALENDAR_STATUS_BUSY && tries != 10) {
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY) && tries != 10) {
tries++;
/*TODO chose an optimal value */
g_usleep (500);
@@ -1117,24 +1109,28 @@ try_again:
goto try_again;
}
- g_warning (G_STRLOC ": Could not create the query: %s ", error->message);
+ g_warning (G_STRLOC ": Could not create the view: %s ", error->message);
g_clear_error (&error);
continue;
}
- g_signal_connect (new_query, "objects_added",
- G_CALLBACK (dn_e_cal_view_objects_added_cb), gcal);
- g_signal_connect (new_query, "objects_modified",
- G_CALLBACK (dn_e_cal_view_objects_modified_cb), gcal);
- g_signal_connect (new_query, "objects_removed",
- G_CALLBACK (dn_e_cal_view_objects_removed_cb), gcal);
- g_signal_connect (new_query, "view_complete",
- G_CALLBACK (dn_e_cal_view_complete_cb), gcal);
+ g_signal_connect (new_view, "objects-added",
+ G_CALLBACK (dn_client_view_objects_added_cb), gcal);
+ g_signal_connect (new_view, "objects-modified",
+ G_CALLBACK (dn_client_view_objects_modified_cb), gcal);
+ g_signal_connect (new_view, "objects-removed",
+ G_CALLBACK (dn_client_view_objects_removed_cb), gcal);
+ g_signal_connect (new_view, "complete",
+ G_CALLBACK (dn_client_view_complete_cb), gcal);
g_mutex_lock (priv->dn_query_lock);
- priv->dn_queries = g_list_append (priv->dn_queries, new_query);
- e_cal_view_start (new_query);
+ priv->dn_queries = g_list_append (priv->dn_queries, new_view);
+ e_cal_client_view_start (new_view, &error);
+ if (error) {
+ g_debug ("%s: Failed to start view: %s", G_STRFUNC, error->message);
+ g_clear_error (&error);
+ }
g_mutex_unlock (priv->dn_query_lock);
}
@@ -2221,15 +2217,17 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
/* FIXME Confirm expunge */
clients = e_cal_model_get_client_list (gnome_calendar_get_model (gcal));
for (l = clients; l != NULL; l = l->next) {
- ECal *client = l->data;
- GList *objects, *m;
- gboolean read_only;
+ ECalClient *client = l->data;
+ GSList *objects, *m;
+ GError *error = NULL;
- if (!e_cal_is_read_only (client, &read_only, NULL) || read_only)
+ if (e_client_is_readonly (E_CLIENT (client)))
continue;
- if (!e_cal_get_object_list (client, sexp, &objects, NULL)) {
- g_warning (G_STRLOC ": Could not get the objects");
+ if (!e_cal_client_get_object_list_sync (client, sexp, &objects, NULL, &error)) {
+ g_warning (G_STRLOC ": Could not get the objects: %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
continue;
}
@@ -2240,16 +2238,15 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
/* FIXME write occur-before and occur-after
* sexp funcs so we don't have to use the max
* gint */
- if (!e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+ if (!e_cal_client_check_recurrences_no_master (client)) {
struct purge_data pd;
pd.remove = TRUE;
pd.older_than = older_than;
- e_cal_generate_instances_for_object (client, m->data,
+ e_cal_client_generate_instances_for_object (client, m->data,
older_than, G_MAXINT32,
- (ECalRecurInstanceFn) check_instance_cb,
+ check_instance_cb,
&pd);
remove = pd.remove;
@@ -2270,23 +2267,21 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than)
if (!icaltime_is_null_time (recur_id) )
rid = icaltime_as_ical_string_r (recur_id);
- e_cal_remove_object_with_mod (
- client, uid, rid,
- CALOBJ_MOD_ALL, &error);
+ e_cal_client_remove_object_sync (client, uid, rid, CALOBJ_MOD_ALL, NULL, &error);
g_free (rid);
} else {
- e_cal_remove_object (client, uid, &error);
+ e_cal_client_remove_object_sync (client, uid, NULL, CALOBJ_MOD_THIS, NULL, &error);
}
if (error) {
- g_warning ("Unable to purge events %s \n", error->message);
+ g_debug ("%s: Unable to purge events: %s", G_STRFUNC, error->message);
g_error_free (error);
}
}
}
- g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
- g_list_free (objects);
+ g_slist_foreach (objects, (GFunc) icalcomponent_free, NULL);
+ g_slist_free (objects);
}
g_list_free (clients);
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 92f6f3ad36..6657b8efe3 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -30,7 +30,7 @@
#include <time.h>
#include <gtk/gtk.h>
#include <misc/e-calendar.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include "e-cal-model.h"
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index 4d56645b38..d095d4ecbe 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -157,14 +157,14 @@ itip_address_is_user (const gchar *address)
gboolean
itip_organizer_is_user (ECalComponent *comp,
- ECal *client)
+ ECalClient *cal_client)
{
- return itip_organizer_is_user_ex (comp, client, FALSE);
+ return itip_organizer_is_user_ex (comp, cal_client, FALSE);
}
gboolean
itip_organizer_is_user_ex (ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
gboolean skip_cap_test)
{
ECalComponentOrganizer organizer;
@@ -172,8 +172,8 @@ itip_organizer_is_user_ex (ECalComponent *comp,
gboolean user_org = FALSE;
if (!e_cal_component_has_organizer (comp) ||
- (!skip_cap_test && e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_NO_ORGANIZER)))
+ (!skip_cap_test && e_client_check_capability (
+ E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_NO_ORGANIZER)))
return FALSE;
e_cal_component_get_organizer (comp, &organizer);
@@ -181,11 +181,10 @@ itip_organizer_is_user_ex (ECalComponent *comp,
strip = itip_strip_mailto (organizer.value);
- if (e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) {
+ if (e_client_check_capability (E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) {
gchar *email = NULL;
- if (e_cal_get_cal_address (client, &email, NULL) &&
+ if (e_client_get_backend_property_sync (E_CLIENT (cal_client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) &&
!g_ascii_strcasecmp (email, strip)) {
g_free (email);
@@ -204,15 +203,15 @@ itip_organizer_is_user_ex (ECalComponent *comp,
gboolean
itip_sentby_is_user (ECalComponent *comp,
- ECal *client)
+ ECalClient *cal_client)
{
ECalComponentOrganizer organizer;
const gchar *strip;
gboolean user_sentby = FALSE;
if (!e_cal_component_has_organizer (comp) ||
- e_cal_get_static_capability (
- client, CAL_STATIC_CAPABILITY_NO_ORGANIZER))
+ e_client_check_capability (
+ E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_NO_ORGANIZER))
return FALSE;
e_cal_component_get_organizer (comp, &organizer);
@@ -277,7 +276,7 @@ html_new_lines_for (const gchar *string)
gchar *
itip_get_comp_attendee (ECalComponent *comp,
- ECal *client)
+ ECalClient *cal_client)
{
GSList *attendees;
EAccountList *al;
@@ -289,8 +288,8 @@ itip_get_comp_attendee (ECalComponent *comp,
e_cal_component_get_attendee_list (comp, &attendees);
al = e_get_account_list ();
- if (client)
- e_cal_get_cal_address (client, &address, NULL);
+ if (cal_client)
+ e_client_get_backend_property_sync (E_CLIENT (cal_client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &address, NULL, NULL);
if (address && *address) {
attendee = get_attendee (attendees, address);
@@ -386,7 +385,7 @@ get_label (struct icaltimetype *tt,
typedef struct {
GHashTable *tzids;
icalcomponent *icomp;
- ECal *client;
+ ECalClient *client;
icalcomponent *zones;
} ItipUtilTZData;
@@ -409,7 +408,7 @@ foreach_tzid_callback (icalparameter *param, gpointer data)
if (zone == NULL)
zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
if (zone == NULL && tz_data->client != NULL)
- e_cal_get_timezone (tz_data->client, tzid, &zone, NULL);
+ e_cal_client_get_timezone_sync (tz_data->client, tzid, &zone, NULL, NULL);
if (zone == NULL)
return;
@@ -426,7 +425,7 @@ foreach_tzid_callback (icalparameter *param, gpointer data)
static icalcomponent *
comp_toplevel_with_zones (ECalComponentItipMethod method,
ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
icalcomponent *zones)
{
icalcomponent *top_level, *icomp;
@@ -446,7 +445,7 @@ comp_toplevel_with_zones (ECalComponentItipMethod method,
tz_data.tzids = g_hash_table_new (g_str_hash, g_str_equal);
tz_data.icomp = top_level;
- tz_data.client = client;
+ tz_data.client = cal_client;
tz_data.zones = zones;
icalcomponent_foreach_tzid (icomp, foreach_tzid_callback, &tz_data);
g_hash_table_destroy (tz_data.tzids);
@@ -457,10 +456,10 @@ comp_toplevel_with_zones (ECalComponentItipMethod method,
}
static gboolean
-users_has_attendee (GList *users,
+users_has_attendee (const GSList *users,
const gchar *address)
{
- GList *l;
+ const GSList *l;
for (l = users; l != NULL; l = l->next) {
if (!g_ascii_strcasecmp (address, l->data))
@@ -525,7 +524,7 @@ comp_from (ECalComponentItipMethod method,
static EDestination **
comp_to_list (ECalComponentItipMethod method,
ECalComponent *comp,
- GList *users,
+ const GSList *users,
gboolean reply_all,
const GSList *only_attendees)
{
@@ -703,7 +702,7 @@ comp_to_list (ECalComponentItipMethod method,
break;
case E_CAL_COMPONENT_METHOD_PUBLISH:
if (users) {
- GList *list;
+ const GSList *list;
array = g_ptr_array_new ();
@@ -945,19 +944,19 @@ comp_description (ECalComponent *comp,
static gboolean
comp_server_send (ECalComponentItipMethod method,
ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
icalcomponent *zones,
- GList **users)
+ GSList **users)
{
icalcomponent *top_level, *returned_icalcomp = NULL;
gboolean retval = TRUE;
GError *error = NULL;
- top_level = comp_toplevel_with_zones (method, comp, client, zones);
- if (!e_cal_send_objects (client, top_level, users, &returned_icalcomp, &error)) {
+ top_level = comp_toplevel_with_zones (method, comp, cal_client, zones);
+ if (!e_cal_client_send_objects_sync (cal_client, top_level, users, &returned_icalcomp, NULL, &error)) {
/* FIXME Really need a book problem status code */
- if (error->code != E_CALENDAR_STATUS_OK) {
- if (error->code == E_CALENDAR_STATUS_OBJECT_ID_ALREADY_EXISTS) {
+ if (error) {
+ if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS)) {
e_notice (
NULL, GTK_MESSAGE_ERROR,
_("Unable to book a resource, the "
@@ -1051,7 +1050,7 @@ comp_limit_attendees (ECalComponent *comp)
}
static void
-comp_sentby (ECalComponent *comp, ECal *client)
+comp_sentby (ECalComponent *comp, ECalClient *cal_client)
{
ECalComponentOrganizer organizer;
GSList * attendees, *l;
@@ -1073,7 +1072,7 @@ comp_sentby (ECalComponent *comp, ECal *client)
}
e_cal_component_get_attendee_list (comp, &attendees);
- user = itip_get_comp_attendee (comp, client);
+ user = itip_get_comp_attendee (comp, cal_client);
for (l = attendees; l; l = l->next) {
ECalComponentAttendee *a = l->data;
@@ -1086,8 +1085,7 @@ comp_sentby (ECalComponent *comp, ECal *client)
}
}
- if (!itip_organizer_is_user (comp, client) &&
- !itip_sentby_is_user (comp, client)) {
+ if (!itip_organizer_is_user (comp, cal_client) && !itip_sentby_is_user (comp, cal_client)) {
EAccount *a = e_get_default_account ();
organizer.value = g_strdup (organizer.value);
@@ -1213,7 +1211,7 @@ strip_x_microsoft_props (ECalComponent *comp)
static ECalComponent *
comp_compliant (ECalComponentItipMethod method,
ECalComponent *comp,
- ECal *client,
+ ECalClient *client,
icalcomponent *zones,
icaltimezone *default_zone,
gboolean strip_alarms)
@@ -1252,7 +1250,7 @@ comp_compliant (ECalComponentItipMethod method,
from_zone = icaltimezone_get_builtin_timezone_from_tzid (dt.tzid);
if (from_zone == NULL && client != NULL)
/* FIXME Error checking */
- e_cal_get_timezone (client, dt.tzid, &from_zone, NULL);
+ e_cal_client_get_timezone_sync (client, dt.tzid, &from_zone, NULL, NULL);
}
to_zone = icaltimezone_get_utc_timezone ();
@@ -1420,7 +1418,7 @@ find_enabled_account (EAccountList *accounts,
static void
setup_from (ECalComponentItipMethod method,
ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
EComposerHeaderTable *table)
{
EAccountList *accounts;
@@ -1430,7 +1428,7 @@ setup_from (ECalComponentItipMethod method,
EAccount *account = NULL;
/* always use organizer's email when user is an organizer */
- if (itip_organizer_is_user (comp, client)) {
+ if (itip_organizer_is_user (comp, cal_client)) {
ECalComponentOrganizer organizer = {0};
e_cal_component_get_organizer (comp, &organizer);
@@ -1458,10 +1456,10 @@ setup_from (ECalComponentItipMethod method,
gboolean
itip_send_comp (ECalComponentItipMethod method,
ECalComponent *send_comp,
- ECal *client,
+ ECalClient *cal_client,
icalcomponent *zones,
GSList *attachments_list,
- GList *users,
+ GSList *users,
gboolean strip_alarms,
gboolean only_new_attendees)
{
@@ -1490,29 +1488,29 @@ itip_send_comp (ECalComponentItipMethod method,
shell_settings, "cal-use-24-hour-format");
/* check whether backend could handle auto-saving requests/updates */
- if (method != E_CAL_COMPONENT_METHOD_PUBLISH && e_cal_get_save_schedules (client))
+ if (method != E_CAL_COMPONENT_METHOD_PUBLISH && e_cal_client_check_save_schedules (cal_client))
return TRUE;
/* Give the server a chance to manipulate the comp */
if (method != E_CAL_COMPONENT_METHOD_PUBLISH) {
- if (!comp_server_send (method, send_comp, client, zones, &users))
+ if (!comp_server_send (method, send_comp, cal_client, zones, &users))
goto cleanup;
}
/* check whether backend could handle sending requests/updates */
if (method != E_CAL_COMPONENT_METHOD_PUBLISH &&
- e_cal_get_static_capability (client,
+ e_client_check_capability (E_CLIENT (cal_client),
CAL_STATIC_CAPABILITY_CREATE_MESSAGES)) {
if (users) {
- g_list_foreach (users, (GFunc) g_free, NULL);
- g_list_free (users);
+ g_slist_foreach (users, (GFunc) g_free, NULL);
+ g_slist_free (users);
}
return TRUE;
}
/* Tidy up the comp */
comp = comp_compliant (
- method, send_comp, client, zones, default_zone, strip_alarms);
+ method, send_comp, cal_client, zones, default_zone, strip_alarms);
if (comp == NULL)
goto cleanup;
@@ -1536,7 +1534,7 @@ itip_send_comp (ECalComponentItipMethod method,
composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
- setup_from (method, send_comp, client, table);
+ setup_from (method, send_comp, cal_client, table);
e_composer_header_table_set_subject (table, subject);
e_composer_header_table_set_destinations_to (table, destinations);
@@ -1545,7 +1543,7 @@ itip_send_comp (ECalComponentItipMethod method,
/* Content type */
content_type = comp_content_type (comp, method);
- top_level = comp_toplevel_with_zones (method, comp, client, zones);
+ top_level = comp_toplevel_with_zones (method, comp, cal_client, zones);
ical_string = icalcomponent_as_ical_string_r (top_level);
if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) {
@@ -1595,8 +1593,8 @@ cleanup:
icalcomponent_free (top_level);
if (users) {
- g_list_foreach (users, (GFunc) g_free, NULL);
- g_list_free (users);
+ g_slist_foreach (users, (GFunc) g_free, NULL);
+ g_slist_free (users);
}
g_free (content_type);
@@ -1609,7 +1607,7 @@ cleanup:
gboolean
reply_to_calendar_comp (ECalComponentItipMethod method,
ECalComponent *send_comp,
- ECal *client,
+ ECalClient *cal_client,
gboolean reply_all,
icalcomponent *zones,
GSList *attachments_list)
@@ -1622,7 +1620,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
ECalComponent *comp = NULL;
icalcomponent *top_level = NULL;
icaltimezone *default_zone;
- GList *users = NULL;
+ GSList *users = NULL;
gchar *subject = NULL;
gchar *ical_string = NULL;
gboolean retval = FALSE;
@@ -1636,7 +1634,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
/* Tidy up the comp */
comp = comp_compliant (
- method, send_comp, client, zones, default_zone, TRUE);
+ method, send_comp, cal_client, zones, default_zone, TRUE);
if (comp == NULL)
goto cleanup;
@@ -1649,13 +1647,13 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
- setup_from (method, send_comp, client, table);
+ setup_from (method, send_comp, cal_client, table);
e_composer_header_table_set_subject (table, subject);
e_composer_header_table_set_destinations_to (table, destinations);
e_destination_freev (destinations);
- top_level = comp_toplevel_with_zones (method, comp, client, zones);
+ top_level = comp_toplevel_with_zones (method, comp, cal_client, zones);
ical_string = icalcomponent_as_ical_string_r (top_level);
if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) {
@@ -1703,12 +1701,15 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
e_cal_component_get_dtstart (comp, &dtstart);
if (dtstart.value) {
start_zone = icaltimezone_get_builtin_timezone_from_tzid (dtstart.tzid);
- if (!start_zone) {
- if (!e_cal_get_timezone (client, dtstart.tzid, &start_zone, NULL))
- g_warning (
- "Couldn't get timezone from "
- "server: %s", dtstart.tzid ?
- dtstart.tzid : "");
+ if (!start_zone && dtstart.tzid) {
+ GError *error = NULL;
+
+ if (!e_cal_client_get_timezone_sync (cal_client, dtstart.tzid, &start_zone, NULL, &error))
+ g_debug ("%s: Couldn't get timezone '%s' from server: %s", G_STRFUNC,
+ dtstart.tzid ? dtstart.tzid : "", error ? error->message : "Unknown error");
+
+ if (error)
+ g_error_free (error);
}
if (!start_zone || dtstart.value->is_date)
@@ -1767,8 +1768,8 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
icalcomponent_free (top_level);
if (users) {
- g_list_foreach (users, (GFunc) g_free, NULL);
- g_list_free (users);
+ g_slist_foreach (users, (GFunc) g_free, NULL);
+ g_slist_free (users);
}
g_free (subject);
@@ -1778,11 +1779,11 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
gboolean
itip_publish_begin (ECalComponent *pub_comp,
- ECal *client,
+ ECalClient *cal_client,
gboolean cloned,
ECalComponent **clone)
{
- icalcomponent *icomp =NULL, *icomp_clone = NULL;
+ icalcomponent *icomp = NULL, *icomp_clone = NULL;
icalproperty *prop;
if (e_cal_component_get_vtype (pub_comp) == E_CAL_COMPONENT_FREEBUSY) {
@@ -1920,7 +1921,7 @@ comp_fb_normalize (icalcomponent *icomp)
}
gboolean
-itip_publish_comp (ECal *client,
+itip_publish_comp (ECalClient *cal_client,
gchar *uri,
gchar *username,
gchar *password,
diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h
index c5718894fc..6da2519d07 100644
--- a/calendar/gui/itip-utils.h
+++ b/calendar/gui/itip-utils.h
@@ -22,7 +22,7 @@
#include <libical/ical.h>
#include <string.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
#include <libedataserver/e-account-list.h>
@@ -53,35 +53,35 @@ gchar ** itip_get_user_identities (void);
gchar * itip_get_fallback_identity (void);
gboolean itip_address_is_user (const gchar *address);
gboolean itip_organizer_is_user (ECalComponent *comp,
- ECal *client);
+ ECalClient *cal_client);
gboolean itip_organizer_is_user_ex (ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
gboolean skip_cap_test);
gboolean itip_sentby_is_user (ECalComponent *comp,
- ECal *client);
+ ECalClient *cal_client);
const gchar * itip_strip_mailto (const gchar *address);
gchar * itip_get_comp_attendee (ECalComponent *comp,
- ECal *client);
+ ECalClient *cal_client);
gboolean itip_send_comp (ECalComponentItipMethod method,
ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
icalcomponent *zones,
GSList *attachments_list,
- GList *users,
+ GSList *users,
gboolean strip_alarms,
gboolean only_new_attendees);
-gboolean itip_publish_comp (ECal *client,
+gboolean itip_publish_comp (ECalClient *cal_client,
gchar *uri,
gchar *username,
gchar *password,
ECalComponent **pub_comp);
gboolean itip_publish_begin (ECalComponent *pub_comp,
- ECal *client,
+ ECalClient *cal_client,
gboolean cloned,
ECalComponent **clone);
gboolean reply_to_calendar_comp (ECalComponentItipMethod method,
ECalComponent *send_comp,
- ECal *client,
+ ECalClient *cal_client,
gboolean reply_all,
icalcomponent *zones,
GSList *attachments_list);
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index a4d4fd61c8..702f281b5a 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -57,7 +57,7 @@ typedef struct PrintCompItem PrintCompItem;
typedef struct PrintCalItem PrintCalItem;
struct PrintCompItem {
- ECal *client;
+ ECalClient *client;
ECalComponent *comp;
icaltimezone *zone;
gboolean use_24_hour_format;
@@ -2924,18 +2924,22 @@ write_label_piece (time_t t,
}
static icaltimezone*
-get_zone_from_tzid (ECal *client, const gchar *tzid)
+get_zone_from_tzid (ECalClient *client, const gchar *tzid)
{
icaltimezone *zone;
/* Note that the timezones may not be on the server, so we try to get
the builtin timezone with the TZID first. */
zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone) {
- if (!e_cal_get_timezone (client, tzid, &zone, NULL))
- /* FIXME: Handle error better. */
- g_warning ("Couldn't get timezone from server: %s",
- tzid ? tzid : "");
+ if (!zone && tzid) {
+ GError *error = NULL;
+
+ if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) {
+ g_warning ("Couldn't get timezone '%s' from server: %s",
+ tzid ? tzid : "", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ }
}
return zone;
@@ -2944,7 +2948,7 @@ get_zone_from_tzid (ECal *client, const gchar *tzid)
static void
print_date_label (GtkPrintContext *context,
ECalComponent *comp,
- ECal *client,
+ ECalClient *client,
icaltimezone *zone,
gboolean use_24_hour_format,
gdouble left,
@@ -3137,7 +3141,7 @@ print_comp_draw_real (GtkPrintOperation *operation,
{
GtkPageSetup *setup;
PangoFontDescription *font;
- ECal *client;
+ ECalClient *client;
ECalComponent *comp;
ECalComponentVType vtype;
ECalComponentText text;
@@ -3413,7 +3417,7 @@ print_comp_begin_print (GtkPrintOperation *operation,
void
print_comp (ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
icaltimezone *zone,
gboolean use_24_hour_format,
GtkPrintOperationAction action)
@@ -3424,7 +3428,7 @@ print_comp (ECalComponent *comp,
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
pci.comp = comp;
- pci.client = client;
+ pci.client = cal_client;
pci.zone = zone;
pci.use_24_hour_format = use_24_hour_format;
diff --git a/calendar/gui/print.h b/calendar/gui/print.h
index 85397b0356..b81bcfa36c 100644
--- a/calendar/gui/print.h
+++ b/calendar/gui/print.h
@@ -40,7 +40,7 @@ void print_calendar (GnomeCalendar *gcal,
GtkPrintOperationAction action,
time_t start);
void print_comp (ECalComponent *comp,
- ECal *client,
+ ECalClient *cal_client,
icaltimezone *zone,
gboolean use_24_hour_format,
GtkPrintOperationAction action);
diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c
index 0af271e1de..dff1285587 100644
--- a/calendar/gui/tag-calendar.c
+++ b/calendar/gui/tag-calendar.c
@@ -151,18 +151,18 @@ get_recur_events_italic (void)
**/
void
tag_calendar_by_client (ECalendar *ecal,
- ECal *client)
+ ECalClient *client)
{
struct calendar_tag_closure c;
g_return_if_fail (E_IS_CALENDAR (ecal));
- g_return_if_fail (E_IS_CAL (client));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
/* If the ECalendar isn't visible, we just return. */
if (!gtk_widget_get_visible (GTK_WIDGET (ecal)))
return;
- if (e_cal_get_load_state (client) != E_CAL_LOAD_LOADED)
+ if (!e_client_is_opened (E_CLIENT (client)))
return;
if (!prepare_tag (ecal, &c, NULL, TRUE))
@@ -171,7 +171,7 @@ tag_calendar_by_client (ECalendar *ecal,
c.skip_transparent_events = TRUE;
c.recur_events_italic = get_recur_events_italic ();
- e_cal_generate_instances (
+ e_cal_client_generate_instances (
client, c.start_time, c.end_time, tag_calendar_cb, &c);
}
@@ -182,19 +182,25 @@ static icaltimezone*
resolve_tzid_cb (const gchar *tzid,
gpointer data)
{
- ECal *client;
+ ECalClient *client;
icaltimezone *zone = NULL;
- g_return_val_if_fail (E_IS_CAL (data), NULL);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (data), NULL);
- client = E_CAL (data);
+ client = E_CAL_CLIENT (data);
/* Try to find the builtin timezone first. */
zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone) {
+ if (!zone && tzid) {
/* FIXME: Handle errors. */
- e_cal_get_timezone (client, tzid, &zone, NULL);
+ GError *error = NULL;
+
+ if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) {
+ g_debug ("%s: Failed to get timezone '%s': %s", G_STRFUNC, tzid, error->message);
+ if (error)
+ g_error_free (error);
+ }
}
return zone;
@@ -217,7 +223,7 @@ resolve_tzid_cb (const gchar *tzid,
void
tag_calendar_by_comp (ECalendar *ecal,
ECalComponent *comp,
- ECal *client,
+ ECalClient *client,
icaltimezone *display_zone,
gboolean clear_first,
gboolean comp_is_on_server,
@@ -239,7 +245,7 @@ tag_calendar_by_comp (ECalendar *ecal,
c.recur_events_italic = can_recur_events_italic && get_recur_events_italic ();
if (comp_is_on_server)
- e_cal_generate_instances_for_object (
+ e_cal_client_generate_instances_for_object (
client, e_cal_component_get_icalcomponent (comp),
c.start_time, c.end_time, tag_calendar_cb, &c);
else
diff --git a/calendar/gui/tag-calendar.h b/calendar/gui/tag-calendar.h
index ebf996173e..2dc5bff176 100644
--- a/calendar/gui/tag-calendar.h
+++ b/calendar/gui/tag-calendar.h
@@ -28,11 +28,11 @@
#define TAG_CALENDAR_H
#include <misc/e-calendar.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
-void tag_calendar_by_client (ECalendar *ecal, ECal *client);
+void tag_calendar_by_client (ECalendar *ecal, ECalClient *client);
void tag_calendar_by_comp (ECalendar *ecal, ECalComponent *comp,
- ECal *client, icaltimezone *display_zone,
+ ECalClient *client, icaltimezone *display_zone,
gboolean clear_first, gboolean comp_is_on_server,
gboolean can_recur_events_italic);
diff --git a/calendar/importers/Makefile.am b/calendar/importers/Makefile.am
index b54e619249..dc7b0dc89f 100644
--- a/calendar/importers/Makefile.am
+++ b/calendar/importers/Makefile.am
@@ -19,7 +19,6 @@ libevolution_calendar_importers_la_LDFLAGS = $(NO_UNDEFINED)
libevolution_calendar_importers_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(top_builddir)/shell/libeshell.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
$(EVOLUTION_CALENDAR_LIBS) \
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index 38c1fc8251..c523e57e39 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -35,13 +35,13 @@
#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-time-util.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
#include <libical/icalvcal.h>
#include "evolution-calendar-importer.h"
#include "shell/e-shell.h"
-#include "common/authentication.h"
#include "gui/calendar-config-keys.h"
#include "e-util/e-import.h"
@@ -58,21 +58,25 @@ typedef struct {
guint idle_id;
- ECal *client;
- ECalSourceType source_type;
+ ECalClient *cal_client;
+ EClientSourceType source_type;
icalcomponent *icalcomp;
- guint cancelled:1;
+ GCancellable *cancellable;
} ICalImporter;
typedef struct {
- guint cancelled:1;
+ EImport *ei;
+ EImportTarget *target;
+ GList *tasks;
+ icalcomponent *icalcomp;
+ GCancellable *cancellable;
} ICalIntelligentImporter;
static const gint import_type_map[] = {
- E_CAL_SOURCE_TYPE_EVENT,
- E_CAL_SOURCE_TYPE_TODO,
+ E_CLIENT_SOURCE_TYPE_EVENTS,
+ E_CLIENT_SOURCE_TYPE_TASKS,
-1
};
@@ -99,11 +103,13 @@ is_icalcomp_usable (icalcomponent *icalcomp)
static void
ivcal_import_done (ICalImporter *ici)
{
- g_object_unref (ici->client);
+ if (ici->cal_client)
+ g_object_unref (ici->cal_client);
icalcomponent_free (ici->icalcomp);
e_import_complete (ici->import, ici->target);
g_object_unref (ici->import);
+ g_object_unref (ici->cancellable);
g_free (ici);
}
@@ -165,12 +171,39 @@ prepare_tasks (icalcomponent *icalcomp, GList *vtodos)
g_list_free (vtodos);
}
-static gboolean
-update_objects (ECal *client, icalcomponent *icalcomp)
+struct UpdateObjectsData
+{
+ void (*done_cb) (gpointer user_data);
+ gpointer user_data;
+};
+
+static void
+receive_objects_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ ECalClient *cal_client = E_CAL_CLIENT (source_object);
+ struct UpdateObjectsData *uod = user_data;
+ GError *error = NULL;
+
+ g_return_if_fail (uod != NULL);
+
+ e_cal_client_receive_objects_finish (cal_client, result, &error);
+
+ if (error) {
+ g_debug ("%s: Failed to receive objects: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ if (uod->done_cb)
+ uod->done_cb (uod->user_data);
+ g_free (uod);
+}
+
+static void
+update_objects (ECalClient *cal_client, icalcomponent *icalcomp, GCancellable *cancellable, void (*done_cb)(gpointer user_data), gpointer user_data)
{
icalcomponent_kind kind;
icalcomponent *vcal;
- gboolean success = TRUE;
+ struct UpdateObjectsData *uod;
kind = icalcomponent_isa (icalcomp);
if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) {
@@ -184,15 +217,21 @@ update_objects (ECal *client, icalcomponent *icalcomp)
vcal = icalcomponent_new_clone (icalcomp);
if (!icalcomponent_get_first_property (vcal, ICAL_METHOD_PROPERTY))
icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
- } else
- return FALSE;
+ } else {
+ if (done_cb)
+ done_cb (user_data);
+ return;
+ }
- if (!e_cal_receive_objects (client, vcal, NULL))
- success = FALSE;
+ uod = g_new0 (struct UpdateObjectsData, 1);
+ uod->done_cb = done_cb;
+ uod->user_data = user_data;
+
+ e_cal_client_receive_objects (cal_client, vcal, cancellable, receive_objects_ready_cb, uod);
icalcomponent_free (vcal);
- return success;
+ return;
}
struct _selector_data {
@@ -246,7 +285,7 @@ ivcal_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im)
struct _selector_data *sd;
/* FIXME Better error handling */
- if (!e_cal_get_sources (&source_list, import_type_map[i], NULL))
+ if (!e_cal_client_get_sources (&source_list, import_type_map[i], NULL))
continue;
selector = e_source_selector_new (source_list);
@@ -290,71 +329,86 @@ ivcal_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im)
return vbox;
}
+static void
+ivcal_call_import_done (gpointer user_data)
+{
+ ivcal_import_done (user_data);
+}
+
static gboolean
ivcal_import_items (gpointer d)
{
ICalImporter *ici = d;
switch (ici->source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CLIENT_SOURCE_TYPE_EVENTS:
prepare_events (ici->icalcomp, NULL);
- if (!update_objects (ici->client, ici->icalcomp)) {
- /* FIXME: e_alert ... */;
- }
+ update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici);
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CLIENT_SOURCE_TYPE_TASKS:
prepare_tasks (ici->icalcomp, NULL);
- if (!update_objects (ici->client, ici->icalcomp)) {
- /* FIXME: e_alert ... */;
- }
+ update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici);
break;
default:
- g_return_val_if_reached (FALSE);
+ g_warn_if_reached ();
+
+ ici->idle_id = 0;
+ ivcal_import_done (ici);
+ return FALSE;
}
- ivcal_import_done (ici);
ici->idle_id = 0;
return FALSE;
}
static void
-ivcal_opened (ECal *ecal, const GError *error, ICalImporter *ici)
+ivcal_opened (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- if (!ici->cancelled && !error) {
+ EClient *client = NULL;
+ ICalImporter *ici = user_data;
+ GError *error = NULL;
+
+ g_return_if_fail (ici != NULL);
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ ici->cal_client = client ? E_CAL_CLIENT (client) : NULL;
+
+ if (!g_cancellable_is_cancelled (ici->cancellable) && !error) {
e_import_status(ici->import, ici->target, _("Importing..."), 0);
ici->idle_id = g_idle_add (ivcal_import_items, ici);
} else
ivcal_import_done (ici);
+
+ if (error) {
+ g_debug ("%s: Failed to open calendar: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
static void
ivcal_import (EImport *ei, EImportTarget *target, icalcomponent *icalcomp)
{
- ECal *client;
- ECalSourceType type;
+ EClientSourceType type;
+ ICalImporter *ici = g_malloc0 (sizeof (*ici));
type = GPOINTER_TO_INT(g_datalist_get_data(&target->data, "primary-type"));
- client = e_auth_new_cal_from_source (g_datalist_get_data(&target->data, "primary-source"), type);
- if (client) {
- ICalImporter *ici = g_malloc0 (sizeof (*ici));
-
- ici->import = ei;
- g_datalist_set_data(&target->data, "ivcal-data", ici);
- g_object_ref (ei);
- ici->target = target;
- ici->icalcomp = icalcomp;
- ici->client = client;
- ici->source_type = type;
- e_import_status(ei, target, _("Opening calendar"), 0);
- g_signal_connect(client, "cal-opened-ex", G_CALLBACK(ivcal_opened), ici);
- e_cal_open_async (client, TRUE);
- return;
- } else {
- icalcomponent_free (icalcomp);
- e_import_complete (ei, target);
- }
+ ici->import = ei;
+ g_datalist_set_data(&target->data, "ivcal-data", ici);
+ g_object_ref (ei);
+ ici->target = target;
+ ici->icalcomp = icalcomp;
+ ici->cal_client = NULL;
+ ici->source_type = type;
+ ici->cancellable = g_cancellable_new ();
+ e_import_status (ei, target, _("Opening calendar"), 0);
+
+ e_client_utils_open_new (g_datalist_get_data(&target->data, "primary-source"), type, FALSE, ici->cancellable,
+ e_client_utils_authenticate_handler, NULL,
+ ivcal_opened, ici);
}
static void
@@ -363,7 +417,7 @@ ivcal_cancel (EImport *ei, EImportTarget *target, EImportImporter *im)
ICalImporter *ici = g_datalist_get_data(&target->data, "ivcal-data");
if (ici)
- ici->cancelled = 1;
+ g_cancellable_cancel (ici->cancellable);
}
/* ********************************************************************** */
@@ -684,13 +738,152 @@ gnome_calendar_supported (EImport *ei, EImportTarget *target, EImportImporter *i
}
static void
+free_ici (gpointer ptr)
+{
+ ICalIntelligentImporter *ici = ptr;
+
+ if (!ici)
+ return;
+
+ if (ici->icalcomp)
+ icalcomponent_free (ici->icalcomp);
+
+ g_object_unref (ici->cancellable);
+ g_free (ici);
+}
+
+struct OpenDefaultSourceData
+{
+ ICalIntelligentImporter *ici;
+ void (* opened_cb) (ECalClient *cal_client, const GError *error, ICalIntelligentImporter *ici);
+};
+
+static void
+default_source_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EClient *client = NULL;
+ struct OpenDefaultSourceData *odsd = user_data;
+ GError *error = NULL;
+
+ g_return_if_fail (odsd != NULL);
+ g_return_if_fail (odsd->ici != NULL);
+ g_return_if_fail (odsd->opened_cb != NULL);
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ odsd->opened_cb (client ? E_CAL_CLIENT (client) : NULL, error, odsd->ici);
+
+ if (client)
+ g_object_unref (client);
+ if (error)
+ g_error_free (error);
+
+ g_free (odsd);
+}
+
+static void
+open_default_source (ICalIntelligentImporter *ici, ECalClientSourceType source_type, void (* opened_cb) (ECalClient *cal_client, const GError *error, ICalIntelligentImporter *ici))
+{
+ ESource *source;
+ ECalClient *cal_client;
+ GError *error = NULL;
+ struct OpenDefaultSourceData *odsd;
+
+ g_return_if_fail (ici != NULL);
+ g_return_if_fail (opened_cb != NULL);
+
+ cal_client = e_cal_client_new_default (source_type, NULL);
+ if (!cal_client)
+ cal_client = e_cal_client_new_system (source_type, &error);
+
+ if (!cal_client) {
+ opened_cb (NULL, error, ici);
+ if (error)
+ g_error_free (error);
+ return;
+ }
+
+ source = e_client_get_source (E_CLIENT (cal_client));
+ g_return_if_fail (source != NULL);
+
+ source = g_object_ref (source);
+ g_object_unref (cal_client);
+
+ odsd = g_new0 (struct OpenDefaultSourceData, 1);
+ odsd->ici = ici;
+ odsd->opened_cb = opened_cb;
+
+ e_import_status (ici->ei, ici->target, _("Opening calendar"), 0);
+
+ e_client_utils_open_new (source, source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? E_CLIENT_SOURCE_TYPE_EVENTS : E_CLIENT_SOURCE_TYPE_TASKS, FALSE, ici->cancellable,
+ e_client_utils_authenticate_handler, NULL,
+ default_source_opened_cb, odsd);
+
+ g_object_unref (source);
+}
+
+static void
+continue_done_cb (gpointer user_data)
+{
+ ICalIntelligentImporter *ici = user_data;
+
+ g_return_if_fail (ici != NULL);
+
+ e_import_complete (ici->ei, ici->target);
+}
+
+static void
+gc_import_tasks (ECalClient *cal_client, const GError *error, ICalIntelligentImporter *ici)
+{
+ g_return_if_fail (ici != NULL);
+
+ if (!cal_client) {
+ g_debug ("%s: Failed to open tasks: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ e_import_complete (ici->ei, ici->target);
+ return;
+ }
+
+ e_import_status (ici->ei, ici->target, _("Importing..."), 0);
+
+ prepare_tasks (ici->icalcomp, ici->tasks);
+ update_objects (cal_client, ici->icalcomp, ici->cancellable, continue_done_cb, ici);
+}
+
+static void
+continue_tasks_cb (gpointer user_data)
+{
+ ICalIntelligentImporter *ici = user_data;
+
+ g_return_if_fail (ici != NULL);
+
+ open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks);
+}
+
+static void
+gc_import_events (ECalClient *cal_client, const GError *error, ICalIntelligentImporter *ici)
+{
+ g_return_if_fail (ici != NULL);
+
+ if (!cal_client) {
+ g_debug ("%s: Failed to open events calendar: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (ici->tasks)
+ open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks);
+ else
+ e_import_complete (ici->ei, ici->target);
+ return;
+ }
+
+ e_import_status (ici->ei, ici->target, _("Importing..."), 0);
+
+ update_objects (cal_client, ici->icalcomp, ici->cancellable, ici->tasks ? continue_tasks_cb : continue_done_cb, ici);
+}
+
+static void
gnome_calendar_import (EImport *ei, EImportTarget *target, EImportImporter *im)
{
icalcomponent *icalcomp = NULL;
gchar *filename;
- GList *vtodos;
- ECal *calendar_client = NULL, *tasks_client = NULL;
- gint t;
gint do_calendar, do_tasks;
ICalIntelligentImporter *ici;
@@ -704,21 +897,6 @@ gnome_calendar_import (EImport *ei, EImportTarget *target, EImportImporter *im)
if (!do_calendar && !do_tasks)
return;
- e_import_status(ei, target, _("Opening calendar"), 0);
-
- /* Try to open the default calendar & tasks folders. */
- if (do_calendar) {
- calendar_client = e_auth_new_cal_from_default (E_CAL_SOURCE_TYPE_EVENT);
- if (!calendar_client)
- goto out;
- }
-
- if (do_tasks) {
- tasks_client = e_auth_new_cal_from_default (E_CAL_SOURCE_TYPE_TODO);
- if (!tasks_client)
- goto out;
- }
-
/* Load the Gnome Calendar file and convert to iCalendar. */
filename = g_build_filename(g_get_home_dir (), "user-cal.vcf", NULL);
icalcomp = load_vcalendar_file (filename);
@@ -729,64 +907,29 @@ gnome_calendar_import (EImport *ei, EImportTarget *target, EImportImporter *im)
goto out;
ici = g_malloc0 (sizeof (*ici));
- g_datalist_set_data_full(&target->data, "gnomecal-data", ici, g_free);
+ ici->ei = ei;
+ ici->target = target;
+ ici->cancellable = g_cancellable_new ();
+ ici->icalcomp = icalcomp;
+ icalcomp = NULL;
- /* Wait for client to finish opening the calendar & tasks folders. */
- for (t = 0; t < IMPORTER_TIMEOUT_SECONDS; t++) {
- ECalLoadState calendar_state, tasks_state;
+ g_datalist_set_data_full(&target->data, "gnomecal-data", ici, free_ici);
- calendar_state = tasks_state = E_CAL_LOAD_LOADED;
-
- /* We need this so the ECal gets notified that the
- folder is opened, via Corba. */
- while (gtk_events_pending ())
- gtk_main_iteration ();
-
- if (do_calendar)
- calendar_state = e_cal_get_load_state (calendar_client);
-
- if (do_tasks)
- tasks_state = e_cal_get_load_state (tasks_client);
-
- if (calendar_state == E_CAL_LOAD_LOADED
- && tasks_state == E_CAL_LOAD_LOADED)
- break;
-
- g_usleep (1000000);
- if (ici->cancelled)
- goto out;
+ prepare_events (ici->icalcomp, &ici->tasks);
+ if (do_calendar) {
+ open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, gc_import_events);
+ return;
}
- /* If we timed out, just return. */
- if (t == IMPORTER_TIMEOUT_SECONDS)
- goto out;
-
- e_import_status(ei, target, _("Importing..."), 0);
-
- /*
- * Import the calendar events into the default calendar folder.
- */
- prepare_events (icalcomp, &vtodos);
- if (do_calendar)
- update_objects (calendar_client, icalcomp);
-
- if (ici->cancelled)
- goto out;
-
- /*
- * Import the tasks into the default tasks folder.
- */
- prepare_tasks (icalcomp, vtodos);
- if (do_tasks)
- update_objects (tasks_client, icalcomp);
+ prepare_tasks (ici->icalcomp, ici->tasks);
+ if (do_tasks) {
+ open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks);
+ return;
+ }
out:
if (icalcomp)
icalcomponent_free (icalcomp);
- if (calendar_client)
- g_object_unref (calendar_client);
- if (tasks_client)
- g_object_unref (tasks_client);
e_import_complete (ei, target);
}
@@ -841,7 +984,7 @@ gnome_calendar_cancel (EImport *ei, EImportTarget *target, EImportImporter *im)
ICalIntelligentImporter *ici = g_datalist_get_data(&target->data, "gnomecal-data");
if (ici)
- ici->cancelled = 1;
+ g_cancellable_cancel (ici->cancellable);
}
static EImportImporter gnome_calendar_importer = {
diff --git a/capplet/settings/mail-capplet-shell.c b/capplet/settings/mail-capplet-shell.c
index a22bb88dcf..5a70fad6d4 100644
--- a/capplet/settings/mail-capplet-shell.c
+++ b/capplet/settings/mail-capplet-shell.c
@@ -285,9 +285,12 @@ setup_abooks (void)
ESourceList *list = NULL;
ESourceGroup *on_this_computer = NULL;
ESource *personal_source = NULL;
+ GError *error = NULL;
- if (!e_book_get_addressbooks (&list, NULL)) {
- g_warning ("Unable to get books\n");
+ if (!e_book_client_get_sources (&list, &error)) {
+ g_debug ("%s: Unable to get books: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return;
}
diff --git a/composer/e-composer-name-header.c b/composer/e-composer-name-header.c
index dcaecab464..a99f1cd949 100644
--- a/composer/e-composer-name-header.c
+++ b/composer/e-composer-name-header.c
@@ -51,7 +51,7 @@ G_DEFINE_TYPE (
E_TYPE_COMPOSER_HEADER)
static gpointer
-contact_editor_fudge_new (EBook *book,
+contact_editor_fudge_new (EBookClient *book_client,
EContact *contact,
gboolean is_new,
gboolean editable)
@@ -62,11 +62,11 @@ contact_editor_fudge_new (EBook *book,
* was a terrible idea. Now we're stuck with it. */
return e_contact_editor_new (
- shell, book, contact, is_new, editable);
+ shell, book_client, contact, is_new, editable);
}
static gpointer
-contact_list_editor_fudge_new (EBook *book,
+contact_list_editor_fudge_new (EBookClient *book_client,
EContact *contact,
gboolean is_new,
gboolean editable)
@@ -77,7 +77,7 @@ contact_list_editor_fudge_new (EBook *book,
* was a terrible idea. Now we're stuck with it. */
return e_contact_list_editor_new (
- shell, book, contact, is_new, editable);
+ shell, book_client, contact, is_new, editable);
}
static void
diff --git a/configure.ac b/configure.ac
index 3afa648953..1078197d2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,8 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
-DEDS_DISABLE_DEPRECATED
-DG_DISABLE_SINGLE_INCLUDES
-DGTK_DISABLE_SINGLE_INCLUDES
+ -DE_BOOK_DISABLE_DEPRECATED
+ -DE_CAL_DISABLE_DEPRECATED
-Wall -Wextra
-Wno-missing-field-initializers
-Wno-sign-compare
@@ -1687,7 +1689,6 @@ widgets/text/Makefile
widgets/table/Makefile
calendar/Makefile
calendar/importers/Makefile
-calendar/common/Makefile
calendar/gui/Makefile
calendar/gui/alarm-notify/Makefile
calendar/gui/dialogs/Makefile
diff --git a/e-util/e-marshal.list b/e-util/e-marshal.list
index 3a9e367cb9..ce8e393fce 100644
--- a/e-util/e-marshal.list
+++ b/e-util/e-marshal.list
@@ -20,6 +20,7 @@ INT:INT,INT,BOXED
INT:INT,POINTER,INT,BOXED
INT:OBJECT,BOXED
INT:POINTER
+NONE:BOXED,INT
NONE:ENUM,OBJECT,OBJECT
NONE:INT,INT
NONE:INT,INT,BOXED
@@ -34,7 +35,6 @@ NONE:INT,POINTER,INT,OBJECT
NONE:INT,POINTER,INT,OBJECT,BOXED,UINT,UINT
NONE:INT,POINTER,INT,OBJECT,INT,INT,BOXED,UINT,UINT
NONE:INT,POINTER,INT,OBJECT,UINT
-NONE:INT,STRING,INT
NONE:LONG,LONG
NONE:OBJECT,BOOLEAN
NONE:OBJECT,DOUBLE,DOUBLE,BOOLEAN
@@ -51,6 +51,7 @@ NONE:POINTER,OBJECT
NONE:POINTER,POINTER
NONE:POINTER,POINTER,INT
NONE:STRING,DOUBLE
+NONE:STRING,INT
NONE:STRING,INT,INT
NONE:STRING,POINTER,POINTER
NONE:STRING,STRING
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 7d11f5e9bf..db6bd958f9 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -41,7 +41,8 @@
#undef interface
#endif
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
#include "em-filter-editor.h"
@@ -1439,35 +1440,30 @@ emu_addr_setup (gpointer user_data)
GError *err = NULL;
ESourceList **psource_list = user_data;
- if (!e_book_get_addressbooks (psource_list, &err))
+ if (!e_book_client_get_sources (psource_list, &err))
g_error_free (err);
return NULL;
}
static void
-emu_addr_cancel_book (gpointer data)
+emu_addr_cancel_stop (gpointer data)
{
- EBook **pbook = data;
- GError *err = NULL;
+ gboolean *stop = data;
- g_return_if_fail (pbook != NULL);
+ g_return_if_fail (stop != NULL);
- if (*pbook) {
- /* we dunna care if this fails, its just the best we can try */
- e_book_cancel (*pbook, &err);
- g_clear_error (&err);
- }
+ *stop = TRUE;
}
static void
-emu_addr_cancel_stop (gpointer data)
+emu_addr_cancel_cancellable (gpointer data)
{
- gboolean *stop = data;
+ GCancellable *cancellable = data;
- g_return_if_fail (stop != NULL);
+ g_return_if_fail (cancellable != NULL);
- *stop = TRUE;
+ g_cancellable_cancel (cancellable);
}
struct TryOpenEBookStruct {
@@ -1477,32 +1473,36 @@ struct TryOpenEBookStruct {
};
static void
-try_open_e_book_cb (EBook *book, const GError *error, gpointer closure)
+try_open_book_client_cb (GObject *source_object, GAsyncResult *result, gpointer closure)
{
+ EBookClient *book_client = E_BOOK_CLIENT (source_object);
struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *) closure;
+ GError *error = NULL;
if (!data)
return;
+ e_client_open_finish (E_CLIENT (book_client), result, &error);
+
data->result = error == NULL;
if (!data->result) {
g_clear_error (data->error);
- g_propagate_error (data->error, g_error_copy (error));
+ g_propagate_error (data->error, error);
}
e_flag_set (data->flag);
}
-/**
- * try_open_e_book:
+/*
+ * try_open_book_client:
* Tries to open address book asynchronously, but acts as synchronous.
* The advantage is it checks periodically whether the camel_operation
* has been canceled or not, and if so, then stops immediately, with
- * result FALSE. Otherwise returns same as e_book_open
- **/
+ * result FALSE. Otherwise returns same as e_client_open()
+ */
static gboolean
-try_open_e_book (EBook *book, gboolean only_if_exists, GError **error)
+try_open_book_client (EBookClient *book_client, gboolean only_if_exists, GCancellable *cancellable, GError **error)
{
struct TryOpenEBookStruct data;
gboolean canceled = FALSE;
@@ -1512,15 +1512,7 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error)
data.flag = flag;
data.result = FALSE;
- if (!e_book_open_async (book, only_if_exists, try_open_e_book_cb, &data)) {
- e_flag_free (flag);
- g_clear_error (error);
- g_set_error (
- error, E_BOOK_ERROR,
- E_BOOK_ERROR_OTHER_ERROR,
- "Failed to call e_book_open_async.");
- return FALSE;
- }
+ e_client_open (E_CLIENT (book_client), only_if_exists, cancellable, try_open_book_client_cb, &data);
while (canceled = camel_operation_cancel_check (NULL),
!canceled && !e_flag_is_set (flag)) {
@@ -1533,16 +1525,10 @@ try_open_e_book (EBook *book, gboolean only_if_exists, GError **error)
}
if (canceled) {
+ g_cancellable_cancel (cancellable);
+
g_clear_error (error);
- g_set_error (
- error, E_BOOK_ERROR,
- E_BOOK_ERROR_CANCELLED,
- "Operation has been canceled.");
- /* if the operation is cancelled sucessfully set the flag
- * else wait. file, groupwise,.. backend's operations
- * are not cancellable */
- if (e_book_cancel_async_op (book, NULL))
- e_flag_set (flag);
+ g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_CANCELLED, NULL));
}
e_flag_wait (flag);
@@ -1578,8 +1564,11 @@ search_address_in_addressbooks (const gchar *address,
gboolean found = FALSE, stop = FALSE, found_any = FALSE;
gchar *lowercase_addr;
gpointer ptr;
- EBookQuery *query;
+ EBookQuery *book_query;
+ gchar *query;
GSList *s, *g, *addr_sources = NULL;
+ GHook *hook_cancellable;
+ GCancellable *cancellable;
if (!address || !*address)
return FALSE;
@@ -1611,7 +1600,9 @@ search_address_in_addressbooks (const gchar *address,
return ptr != NOT_FOUND_BOOK;
}
- query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address);
+ book_query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address);
+ query = e_book_query_to_string (book_query);
+ e_book_query_unref (book_query);
for (g = e_source_list_peek_groups (emu_books_source_list);
g; g = g_slist_next (g)) {
@@ -1635,11 +1626,14 @@ search_address_in_addressbooks (const gchar *address,
}
}
+ cancellable = g_cancellable_new ();
+ hook_cancellable = mail_cancel_hook_add (emu_addr_cancel_cancellable, cancellable);
+
for (s = addr_sources; !stop && !found && s; s = g_slist_next (s)) {
ESource *source = s->data;
- GList *contacts;
- EBook *book = NULL;
- GHook *hook_book, *hook_stop;
+ GSList *contacts;
+ EBookClient *book_client = NULL;
+ GHook *hook_stop;
gboolean cached_book = FALSE;
GError *err = NULL;
@@ -1653,17 +1647,14 @@ search_address_in_addressbooks (const gchar *address,
d(printf(" checking '%s'\n", e_source_get_uri(source)));
- hook_book = mail_cancel_hook_add (emu_addr_cancel_book, &book);
hook_stop = mail_cancel_hook_add (emu_addr_cancel_stop, &stop);
- book = g_hash_table_lookup (emu_books_hash, e_source_peek_uid (source));
- if (!book) {
- book = e_book_new (source, &err);
+ book_client = g_hash_table_lookup (emu_books_hash, e_source_peek_uid (source));
+ if (!book_client) {
+ book_client = e_book_client_new (source, &err);
- if (book == NULL) {
- if (err && g_error_matches (
- err, E_BOOK_ERROR,
- E_BOOK_ERROR_CANCELLED)) {
+ if (book_client == NULL) {
+ if (err && g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) {
stop = TRUE;
} else if (err) {
gchar *source_uid;
@@ -1682,13 +1673,11 @@ search_address_in_addressbooks (const gchar *address,
err->message);
}
g_clear_error (&err);
- } else if (!stop && !try_open_e_book (book, TRUE, &err)) {
- g_object_unref (book);
- book = NULL;
+ } else if (!stop && !try_open_book_client (book_client, TRUE, cancellable, &err)) {
+ g_object_unref (book_client);
+ book_client = NULL;
- if (err && g_error_matches (
- err, E_BOOK_ERROR,
- E_BOOK_ERROR_CANCELLED)) {
+ if (err && g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) {
stop = TRUE;
} else if (err) {
gchar *source_uid;
@@ -1712,18 +1701,15 @@ search_address_in_addressbooks (const gchar *address,
cached_book = TRUE;
}
- if (book && !stop && e_book_get_contacts (book, query, &contacts, &err)) {
+ if (book_client && !stop && e_book_client_get_contacts_sync (book_client, query, &contacts, cancellable, &err)) {
if (contacts != NULL) {
if (!found_any) {
- g_hash_table_insert (
- contact_cache,
- g_strdup (lowercase_addr),
- book);
+ g_hash_table_insert (contact_cache, g_strdup (lowercase_addr), book_client);
}
found_any = TRUE;
if (check_contact) {
- GList *l;
+ GSList *l;
for (l = contacts; l && !found; l = l->next) {
EContact *contact = l->data;
@@ -1734,12 +1720,12 @@ search_address_in_addressbooks (const gchar *address,
found = TRUE;
}
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_list_free (contacts);
+ g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
+ g_slist_free (contacts);
}
- } else if (book) {
+ } else if (book_client) {
stop = stop || (err && g_error_matches (
- err, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED));
+ err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED));
if (err && !stop) {
gchar *source_uid = g_strdup (e_source_peek_uid (source));
@@ -1753,24 +1739,26 @@ search_address_in_addressbooks (const gchar *address,
g_clear_error (&err);
}
- mail_cancel_hook_remove (hook_book);
mail_cancel_hook_remove (hook_stop);
stop = stop || camel_operation_cancel_check (NULL);
- if (stop && !cached_book && book) {
- g_object_unref (book);
- } else if (!stop && book && !cached_book) {
+ if (stop && !cached_book && book_client) {
+ g_object_unref (book_client);
+ } else if (!stop && book_client && !cached_book) {
g_hash_table_insert (
emu_books_hash, g_strdup (
- e_source_peek_uid (source)), book);
+ e_source_peek_uid (source)), book_client);
}
}
+ mail_cancel_hook_remove (hook_cancellable);
+ g_object_unref (cancellable);
+
g_slist_foreach (addr_sources, (GFunc) g_object_unref, NULL);
g_slist_free (addr_sources);
- e_book_query_unref (query);
+ g_free (query);
if (!found_any) {
g_hash_table_insert (contact_cache, lowercase_addr, NOT_FOUND_BOOK);
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index fea9218e2e..c75a78a332 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -38,7 +38,7 @@
#include <gconf/gconf-client.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-destination.h>
#include "mail-importer.h"
@@ -98,7 +98,7 @@ FIXME: we dont handle aliases in lists.
*/
static void
-import_contact (EBook *book, gchar *line)
+import_contact (EBookClient *book_client, gchar *line)
{
gchar **strings, *addr, **addrs;
gint i;
@@ -106,10 +106,13 @@ import_contact (EBook *book, gchar *line)
/*EContactName *name;*/
EContact *card;
gsize len;
+ GError *error = NULL;
card = e_contact_new ();
strings = g_strsplit(line, "\t", 5);
if (strings[0] && strings[1] && strings[2]) {
+ gchar *new_uid = NULL;
+
e_contact_set (card, E_CONTACT_NICKNAME, strings[0]);
e_contact_set (card, E_CONTACT_FULL_NAME, strings[1]);
@@ -150,8 +153,15 @@ import_contact (EBook *book, gchar *line)
if (strings[3] && strings[4])
e_contact_set (card, E_CONTACT_NOTE, strings[4]);
- /* FIXME Error checking */
- e_book_add_contact (book, card, NULL);
+ if (!e_book_client_add_contact_sync (book_client, card, &new_uid, NULL, &error)) {
+ g_debug ("%s: Failed to add contact: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ error = NULL;
+ } else {
+ g_free (new_uid);
+ }
+
g_object_unref (card);
}
g_strfreev (strings);
@@ -162,16 +172,22 @@ import_contacts (void)
{
ESource *primary;
ESourceList *source_list;
- EBook *book;
+ EBookClient *book_client;
gchar *name;
GString *line;
FILE *fp;
gsize offset;
+ GError *error = NULL;
printf("importing pine addressbook\n");
- if (!e_book_get_addressbooks (&source_list, NULL))
+ if (!e_book_client_get_sources (&source_list, &error)) {
+ if (error) {
+ g_debug ("%s: Failed to get book sources: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
return;
+ }
name = g_build_filename(g_get_home_dir(), ".addressbook", NULL);
fp = fopen(name, "r");
@@ -181,13 +197,24 @@ import_contacts (void)
primary = e_source_list_peek_source_any (source_list);
/* FIXME Better error handling */
- if ((book = e_book_new (primary,NULL)) == NULL) {
+ if ((book_client = e_book_client_new (primary, &error)) == NULL) {
fclose (fp);
- g_warning ("Could not create EBook.");
+ g_warning ("Could not create EBook: %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return;
}
- e_book_open (book, TRUE, NULL);
+ if (!e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error)) {
+ g_object_unref (primary);
+ g_object_unref (source_list);
+ fclose (fp);
+
+ g_warning ("%s: Failed to open book client: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ return;
+ }
g_object_unref (primary);
g_object_unref (source_list);
@@ -208,13 +235,13 @@ import_contacts (void)
g_string_truncate (line, len);
}
- import_contact (book, line->str);
+ import_contact (book_client, line->str);
offset = 0;
}
g_string_free (line, TRUE);
fclose (fp);
- g_object_unref (book);
+ g_object_unref (book_client);
}
static gchar *
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"
diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c
index bfb63c5505..e0005a967e 100644
--- a/plugins/bbdb/bbdb.c
+++ b/plugins/bbdb/bbdb.c
@@ -28,8 +28,9 @@
#include <glib/gi18n.h>
#include <string.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libedataserverui/e-source-combo-box.h>
+#include <libedataserverui/e-client-utils.h>
#include <e-util/e-config.h>
#include <mail/em-config.h>
@@ -58,7 +59,7 @@ struct bbdb_stuff {
/* Static forward declarations */
static gboolean bbdb_timeout (gpointer data);
-static void bbdb_do_it (EBook *book, const gchar *name, const gchar *email);
+static void bbdb_do_it (EBookClient *client, const gchar *name, const gchar *email);
static void add_email_to_contact (EContact *contact, const gchar *email);
static void enable_toggled_cb (GtkWidget *widget, gpointer data);
static void source_changed_cb (ESourceComboBox *source_combo_box, struct bbdb_stuff *stuff);
@@ -191,10 +192,10 @@ G_LOCK_DEFINE_STATIC (todo);
static gpointer
bbdb_do_in_thread (gpointer data)
{
- EBook *book = data;
+ EBookClient *client = data;
/* Open the addressbook */
- if (!book || !bbdb_open_ebook (book)) {
+ if (!client || !bbdb_open_book_client (client)) {
G_LOCK (todo);
g_slist_foreach (todo, (GFunc) free_todo_struct, NULL);
@@ -214,7 +215,7 @@ bbdb_do_in_thread (gpointer data)
G_UNLOCK (todo);
if (td) {
- bbdb_do_it (book, td->name, td->email);
+ bbdb_do_it (client, td->name, td->email);
free_todo_struct (td);
}
@@ -222,7 +223,7 @@ bbdb_do_in_thread (gpointer data)
}
G_UNLOCK (todo);
- g_object_unref (book);
+ g_object_unref (client);
return NULL;
}
@@ -246,18 +247,18 @@ bbdb_do_thread (const gchar *name, const gchar *email)
todo = g_slist_append (todo, td);
} else {
GError *error = NULL;
- EBook *book = bbdb_create_ebook (AUTOMATIC_CONTACTS_ADDRESSBOOK);
+ EBookClient *client = bbdb_create_book_client (AUTOMATIC_CONTACTS_ADDRESSBOOK);
/* list was empty, add item and create a thread */
todo = g_slist_append (todo, td);
- g_thread_create (bbdb_do_in_thread, book, FALSE, &error);
+ g_thread_create (bbdb_do_in_thread, client, FALSE, &error);
if (error) {
g_warning ("%s: Creation of the thread failed with error: %s", G_STRFUNC, error->message);
g_error_free (error);
G_UNLOCK (todo);
- bbdb_do_in_thread (book);
+ bbdb_do_in_thread (client);
G_LOCK (todo);
}
}
@@ -324,16 +325,15 @@ bbdb_handle_send (EPlugin *ep, EMEventTargetComposer *target)
}
static void
-bbdb_do_it (EBook *book, const gchar *name, const gchar *email)
+bbdb_do_it (EBookClient *client, const gchar *name, const gchar *email)
{
- gchar *query_string, *delim, *temp_name = NULL;
- EBookQuery *query;
- GList *contacts = NULL, *l;
+ gchar *query_string, *delim, *temp_name = NULL, *uid;
+ GSList *contacts = NULL;
gboolean status;
EContact *contact;
GError *error = NULL;
- g_return_if_fail (book != NULL);
+ g_return_if_fail (client != NULL);
if (email == NULL || !strcmp (email, ""))
return;
@@ -349,16 +349,10 @@ bbdb_do_it (EBook *book, const gchar *name, const gchar *email)
/* If any contacts exists with this email address, don't do anything */
query_string = g_strdup_printf ("(contains \"email\" \"%s\")", email);
- query = e_book_query_from_string (query_string);
+ status = e_book_client_get_contacts_sync (client, query_string, &contacts, NULL, NULL);
g_free (query_string);
-
- status = e_book_get_contacts (book, query, &contacts, NULL);
- if (query)
- e_book_query_unref (query);
if (contacts != NULL || !status) {
- for (l = contacts; l != NULL; l = l->next)
- g_object_unref ((GObject *) l->data);
- g_list_free (contacts);
+ e_client_util_free_object_slist (contacts);
g_free (temp_name);
return;
@@ -376,39 +370,31 @@ bbdb_do_it (EBook *book, const gchar *name, const gchar *email)
name = temp_name;
}
+ contacts = NULL;
/* If a contact exists with this name, add the email address to it. */
query_string = g_strdup_printf ("(is \"full_name\" \"%s\")", name);
- query = e_book_query_from_string (query_string);
+ status = e_book_client_get_contacts_sync (client, query_string, &contacts, NULL, NULL);
g_free (query_string);
-
- status = e_book_get_contacts (book, query, &contacts, NULL);
- if (query)
- e_book_query_unref (query);
if (contacts != NULL || !status) {
-
/* FIXME: If there's more than one contact with this
name, just give up; we're not smart enough for
this. */
if (!status || contacts->next != NULL) {
- for (l = contacts; l != NULL; l = l->next)
- g_object_unref ((GObject *) l->data);
- g_list_free (contacts);
+ e_client_util_free_object_slist (contacts);
g_free (temp_name);
return;
}
contact = (EContact *) contacts->data;
add_email_to_contact (contact, email);
- if (!e_book_commit_contact (book, contact, &error)) {
+ if (!e_book_client_modify_contact_sync (client, contact, NULL, &error)) {
g_warning ("bbdb: Could not modify contact: %s\n", error->message);
g_error_free (error);
}
- for (l = contacts; l != NULL; l = l->next)
- g_object_unref ((GObject *) l->data);
- g_list_free (contacts);
-
+ e_client_util_free_object_slist (contacts);
g_free (temp_name);
+ g_free (uid);
return;
}
@@ -418,21 +404,22 @@ bbdb_do_it (EBook *book, const gchar *name, const gchar *email)
add_email_to_contact (contact, email);
g_free (temp_name);
- if (!e_book_add_contact (book, contact, &error)) {
- g_warning ("bbdb: Failed to add new contact: %s\n", error->message);
+ uid = NULL;
+ if (!e_book_client_add_contact_sync (client, contact, &uid, NULL, &error)) {
+ g_warning ("bbdb: Failed to add new contact: %s", error->message);
g_error_free (error);
- return;
}
g_object_unref (G_OBJECT (contact));
+ g_free (uid);
}
-EBook *
-bbdb_create_ebook (gint type)
+EBookClient *
+bbdb_create_book_client (gint type)
{
GConfClient *gconf;
gchar *uri;
- EBook *book = NULL;
+ EBookClient *client = NULL;
GError *error = NULL;
gboolean enable = TRUE;
@@ -454,33 +441,36 @@ bbdb_create_ebook (gint type)
g_object_unref (G_OBJECT (gconf));
if (uri == NULL)
- book = e_book_new_system_addressbook (&error);
+ client = e_book_client_new_system (&error);
else {
- book = e_book_new_from_uri (uri, &error);
+ client = e_book_client_new_from_uri (uri, &error);
g_free (uri);
}
- if (book == NULL) {
- g_warning ("bbdb: failed to get addressbook: %s\n", error->message);
- g_error_free (error);
+ if (client == NULL) {
+ g_warning ("bbdb: failed to get addressbook: %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return NULL;
}
- return book;
+ return client;
}
gboolean
-bbdb_open_ebook (EBook *book)
+bbdb_open_book_client (EBookClient *client)
{
GError *error = NULL;
- if (!book)
+ if (!client)
return FALSE;
- if (!e_book_open (book, FALSE, &error)) {
- g_warning ("bbdb: failed to open addressbook: %s\n", error->message);
- g_error_free (error);
- g_object_unref (book);
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+ if (!e_client_open_sync (E_CLIENT (client), FALSE, NULL, &error)) {
+ g_warning ("bbdb: failed to open addressbook: %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ g_object_unref (client);
return FALSE;
}
diff --git a/plugins/bbdb/bbdb.h b/plugins/bbdb/bbdb.h
index fe7b998274..cbeb4ebb42 100644
--- a/plugins/bbdb/bbdb.h
+++ b/plugins/bbdb/bbdb.h
@@ -37,14 +37,17 @@
#define GAIM_ADDRESSBOOK 1
#define AUTOMATIC_CONTACTS_ADDRESSBOOK 0
+#include <libebook/e-book-client.h>
+#include <libebook/e-contact.h>
+
/* bbdb.c */
-/* creates an EBook for a given type (gaim or contacts), but doesn't open it;
+/* creates an EBookClient for a given type (gaim or contacts), but doesn't open it;
this function should be called in a main thread. */
-EBook *bbdb_create_ebook (gint type);
+EBookClient *bbdb_create_book_client (gint type);
-/* opens an EBook. Returns false if it fails, and unrefs the book too;
+/* opens an EBookClient. Returns false if it fails, and unrefs the book too;
this function can be called in any thread */
-gboolean bbdb_open_ebook (EBook *book);
+gboolean bbdb_open_book_client (EBookClient *client);
gboolean bbdb_check_gaim_enabled (void);
diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c
index f6a048e975..1becdee0ac 100644
--- a/plugins/bbdb/gaimbuddies.c
+++ b/plugins/bbdb/gaimbuddies.c
@@ -42,7 +42,8 @@
#include <glib/gi18n.h>
#include <string.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
#include <libedataserverui/e-source-combo-box.h>
#include <sys/time.h>
@@ -60,7 +61,7 @@ typedef struct {
} GaimBuddy;
/* Forward declarations for this file. */
-static gboolean bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact *c);
+static gboolean bbdb_merge_buddy_to_contact (EBookClient *client, GaimBuddy *b, EContact *c);
static GList *bbdb_get_gaim_buddy_list (void);
static gchar *get_node_text (xmlNodePtr node);
static gchar *get_buddy_icon_from_setting (xmlNodePtr setting);
@@ -189,7 +190,7 @@ G_LOCK_DEFINE_STATIC (syncing);
struct sync_thread_data
{
GList *blist;
- EBook *book;
+ EBookClient *client;
};
static gpointer
@@ -200,8 +201,8 @@ bbdb_sync_buddy_list_in_thread (gpointer data)
g_return_val_if_fail (std != NULL, NULL);
- if (!bbdb_open_ebook (std->book)) {
- /* book got freed in bbdb_open_ebook on a failure */
+ if (!bbdb_open_book_client (std->client)) {
+ /* client got freed in bbdb_open_book_client on a failure */
free_buddy_list (std->blist);
g_free (std);
@@ -217,7 +218,8 @@ bbdb_sync_buddy_list_in_thread (gpointer data)
for (l = std->blist; l != NULL; l = l->next) {
GaimBuddy *b = l->data;
EBookQuery *query;
- GList *contacts = NULL;
+ gchar *query_string, *uid;
+ GSList *contacts = NULL;
GError *error = NULL;
EContact *c;
@@ -227,52 +229,59 @@ bbdb_sync_buddy_list_in_thread (gpointer data)
}
/* Look for an exact match full name == buddy alias */
- query = e_book_query_field_test (
- E_CONTACT_FULL_NAME, E_BOOK_QUERY_IS, b->alias);
-
- if (!e_book_get_contacts (std->book, query, &contacts, NULL)) {
- e_book_query_unref (query);
+ query = e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_IS, b->alias);
+ query_string = e_book_query_to_string (query);
+ e_book_query_unref (query);
+ if (!e_book_client_get_contacts_sync (std->client, query_string, &contacts, NULL, NULL)) {
+ g_free (query_string);
continue;
}
- e_book_query_unref (query);
+ g_free (query_string);
if (contacts != NULL) {
/* FIXME: If there's more than one contact with this
name, just give up; we're not smart enough for
this. */
- if (contacts->next != NULL)
+ if (contacts->next != NULL) {
+ e_client_util_free_object_slist (contacts);
continue;
+ }
c = E_CONTACT (contacts->data);
- if (!bbdb_merge_buddy_to_contact (std->book, b, c))
+ if (!bbdb_merge_buddy_to_contact (std->client, b, c)) {
+ e_client_util_free_object_slist (contacts);
continue;
+ }
/* Write it out to the addressbook */
- if (!e_book_commit_contact (std->book, c, &error)) {
- g_warning ("bbdb: Could not modify contact: %s\n", error->message);
+ if (!e_book_client_modify_contact_sync (std->client, c, NULL, &error)) {
+ g_warning ("bbdb: Could not modify contact: %s", error->message);
g_error_free (error);
}
+ e_client_util_free_object_slist (contacts);
continue;
}
/* Otherwise, create a new contact. */
c = e_contact_new ();
e_contact_set (c, E_CONTACT_FULL_NAME, (gpointer) b->alias);
- if (!bbdb_merge_buddy_to_contact (std->book, b, c)) {
- g_object_unref (G_OBJECT (c));
+ if (!bbdb_merge_buddy_to_contact (std->client, b, c)) {
+ g_object_unref (c);
continue;
}
- if (!e_book_add_contact (std->book, c, &error)) {
- g_warning ("bbdb: Failed to add new contact: %s\n", error->message);
+ uid = NULL;
+ if (!e_book_client_add_contact_sync (std->client, c, &uid, NULL, &error)) {
+ g_warning ("bbdb: Failed to add new contact: %s", error->message);
g_error_free (error);
goto finish;
}
- g_object_unref (G_OBJECT (c));
+ g_object_unref (c);
+ g_free (uid);
}
g_idle_add (store_last_sync_idle_cb, NULL);
@@ -280,7 +289,7 @@ bbdb_sync_buddy_list_in_thread (gpointer data)
finish:
printf ("bbdb: Done syncing buddy list to contacts.\n");
- g_object_unref (std->book);
+ g_object_unref (std->client);
free_buddy_list (std->blist);
g_free (std);
@@ -296,7 +305,7 @@ bbdb_sync_buddy_list (void)
{
GList *blist;
GError *error = NULL;
- EBook *book = NULL;
+ EBookClient *client = NULL;
struct sync_thread_data *std;
G_LOCK (syncing);
@@ -314,8 +323,8 @@ bbdb_sync_buddy_list (void)
}
/* Open the addressbook */
- book = bbdb_create_ebook (GAIM_ADDRESSBOOK);
- if (book == NULL) {
+ client = bbdb_create_book_client (GAIM_ADDRESSBOOK);
+ if (client == NULL) {
free_buddy_list (blist);
G_UNLOCK (syncing);
return;
@@ -323,7 +332,7 @@ bbdb_sync_buddy_list (void)
std = g_new0 (struct sync_thread_data, 1);
std->blist = blist;
- std->book = book;
+ std->client = client;
syncing = TRUE;
@@ -358,7 +367,7 @@ im_list_contains_buddy (GList *ims, GaimBuddy *b)
}
static gboolean
-bbdb_merge_buddy_to_contact (EBook *book, GaimBuddy *b, EContact *c)
+bbdb_merge_buddy_to_contact (EBookClient *client, GaimBuddy *b, EContact *c)
{
EContactField field;
GList *ims;
diff --git a/plugins/caldav/caldav-browse-server.c b/plugins/caldav/caldav-browse-server.c
index 3a78217b1a..d169dda8f8 100644
--- a/plugins/caldav/caldav-browse-server.c
+++ b/plugins/caldav/caldav-browse-server.c
@@ -32,7 +32,7 @@
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libedataserver/e-proxy.h>
#include <libedataserverui/e-cell-renderer-color.h>
#include <libedataserverui/e-passwords.h>
@@ -1369,13 +1369,13 @@ init_dialog (GtkDialog *dialog, GtkWidget **new_url_entry, GtkWidget **new_userm
switch (source_type) {
default:
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
source_type_str = "VEVENT";
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
source_type_str = "VTODO";
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
source_type_str = "VJOURNAL";
break;
}
diff --git a/plugins/caldav/caldav-source.c b/plugins/caldav/caldav-source.c
index 11c651f7d9..41cebef760 100644
--- a/plugins/caldav/caldav-source.c
+++ b/plugins/caldav/caldav-source.c
@@ -33,7 +33,7 @@
#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
#include <libedataserver/e-account-list.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <string.h>
@@ -53,12 +53,15 @@ GtkWidget * oge_caldav (EPlugin *epl,
/* plugin intialization */
static void
-ensure_caldav_source_group (ECalSourceType source_type)
+ensure_caldav_source_group (ECalClientSourceType source_type)
{
- ESourceList *slist;
+ ESourceList *slist;
+ GError *error = NULL;
- if (!e_cal_get_sources (&slist, source_type, NULL)) {
- g_warning ("Could not get calendar source list from GConf!");
+ if (!e_cal_client_get_sources (&slist, source_type, &error)) {
+ g_warning ("Could not get calendar sources: %s", error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return;
}
@@ -72,9 +75,9 @@ e_plugin_lib_enable (EPlugin *ep, gint enable)
if (enable) {
d(g_print ("CalDAV Eplugin starting up ...\n"));
- ensure_caldav_source_group (E_CAL_SOURCE_TYPE_EVENT);
- ensure_caldav_source_group (E_CAL_SOURCE_TYPE_TODO);
- ensure_caldav_source_group (E_CAL_SOURCE_TYPE_JOURNAL);
+ ensure_caldav_source_group (E_CAL_CLIENT_SOURCE_TYPE_EVENTS);
+ ensure_caldav_source_group (E_CAL_CLIENT_SOURCE_TYPE_TASKS);
+ ensure_caldav_source_group (E_CAL_CLIENT_SOURCE_TYPE_MEMOS);
}
return 0;
diff --git a/plugins/calendar-file/calendar-file.c b/plugins/calendar-file/calendar-file.c
index f162914dd8..a7b821d285 100644
--- a/plugins/calendar-file/calendar-file.c
+++ b/plugins/calendar-file/calendar-file.c
@@ -165,16 +165,16 @@ e_calendar_file_customs (EPlugin *epl, EConfigHookItemFactoryData *data)
const gchar *file_name = NULL;
switch (t->source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
file_name = "calendar.ics";
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
file_name = "tasks.ics";
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
file_name = "journal.ics";
break;
- case E_CAL_SOURCE_TYPE_LAST:
+ case E_CAL_CLIENT_SOURCE_TYPE_LAST:
break;
}
diff --git a/plugins/dbx-import/dbx-importer.c b/plugins/dbx-import/dbx-importer.c
index 1c977750b1..3bc70030db 100644
--- a/plugins/dbx-import/dbx-importer.c
+++ b/plugins/dbx-import/dbx-importer.c
@@ -57,9 +57,8 @@
#include <shell/e-shell-view.h>
#include <libebook/e-contact.h>
-#include <libebook/e-book.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
#include <libedataserver/e-data-server-util.h>
diff --git a/plugins/default-source/default-source.c b/plugins/default-source/default-source.c
index 770dc25852..02a0d42baa 100644
--- a/plugins/default-source/default-source.c
+++ b/plugins/default-source/default-source.c
@@ -30,8 +30,8 @@
#include <calendar/gui/e-cal-config.h>
#include <libedataserver/e-source.h>
#include <addressbook/gui/widgets/eab-config.h>
-#include <libebook/e-book.h>
-#include <libecal/e-cal.h>
+#include <libebook/e-book-client.h>
+#include <libecal/e-cal-client.h>
#include <glib/gi18n.h>
#include <string.h>
@@ -58,7 +58,7 @@ commit_default_calendar (EPlugin *epl, EConfigTarget *target)
cal_target = (ECalConfigTargetSource *) target;
source = cal_target->source;
if (e_source_get_property (source, "default"))
- e_cal_set_default_source (source, cal_target->source_type, NULL);
+ e_cal_client_set_default_source (source, cal_target->source_type, NULL);
}
void
@@ -70,7 +70,7 @@ commit_default_book (EPlugin *epl, EConfigTarget *target)
book_target = (EABConfigTargetSource *) target;
source = book_target->source;
if (e_source_get_property (source, "default"))
- e_book_set_default_source (source, NULL);
+ e_book_client_set_default_source (source, NULL);
}
@@ -101,14 +101,14 @@ org_gnome_autocomplete_book (EPlugin *epl, EConfigHookItemFactoryData *data)
}
static const gchar *
-get_calendar_option_caption (ECalSourceType source_type)
+get_calendar_option_caption (ECalClientSourceType source_type)
{
const gchar *res = "???";
switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT: res = _("Mark as _default calendar"); break;
- case E_CAL_SOURCE_TYPE_TODO: res = _("Mark as _default task list"); break;
- case E_CAL_SOURCE_TYPE_JOURNAL: res = _("Mark as _default memo list"); break;
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: res = _("Mark as _default calendar"); break;
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS: res = _("Mark as _default task list"); break;
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: res = _("Mark as _default memo list"); break;
default: break;
}
diff --git a/plugins/google-account-setup/google-source.c b/plugins/google-account-setup/google-source.c
index 38bbad3385..1fce9858b8 100644
--- a/plugins/google-account-setup/google-source.c
+++ b/plugins/google-account-setup/google-source.c
@@ -42,7 +42,7 @@
#include <libedataserver/e-url.h>
#include <libedataserver/e-account-list.h>
#include <libedataserver/e-proxy.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libedataserverui/e-cell-renderer-color.h>
#include <libedataserverui/e-passwords.h>
@@ -71,9 +71,12 @@ static void
ensure_google_source_group (void)
{
ESourceList *slist;
+ GError *error = NULL;
- if (!e_cal_get_sources (&slist, E_CAL_SOURCE_TYPE_EVENT, NULL)) {
- g_warning ("Could not get calendar source list from GConf!");
+ if (!e_cal_client_get_sources (&slist, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &error)) {
+ g_debug ("%s: Could not get calendar source list: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return;
}
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index 95c6238c0a..c8adbcf615 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -28,9 +28,10 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-time-util.h>
#include <libedataserverui/e-source-selector.h>
+#include <libedataserverui/e-client-utils.h>
#include <gtkhtml/gtkhtml-embedded.h>
#include <mail/em-format-hook.h>
#include <mail/em-config.h>
@@ -44,7 +45,6 @@
#include <e-util/e-alert-dialog.h>
#include <e-util/e-mktemp.h>
#include <calendar/gui/itip-utils.h>
-#include <calendar/common/authentication.h>
#include <shell/e-shell.h>
#include <shell/e-shell-utils.h>
#include "itip-view.h"
@@ -66,11 +66,11 @@ struct _itip_puri {
gchar *uid;
GtkWidget *view;
- ESourceList *source_lists[E_CAL_SOURCE_TYPE_LAST];
- GHashTable *ecals[E_CAL_SOURCE_TYPE_LAST];
+ ESourceList *source_lists[E_CAL_CLIENT_SOURCE_TYPE_LAST];
+ GHashTable *ecals[E_CAL_CLIENT_SOURCE_TYPE_LAST];
- ECal *current_ecal;
- ECalSourceType type;
+ ECalClient *current_client;
+ ECalClientSourceType type;
gchar *vcalendar;
ECalComponent *comp;
@@ -145,8 +145,6 @@ typedef struct {
gint count;
} FormatItipFindData;
-typedef void (* FormatItipOpenFunc) (ECal *ecal, const GError *error, gpointer data);
-
static gboolean check_is_instance (icalcomponent *icalcomp);
gint
@@ -419,7 +417,7 @@ get_real_item (struct _itip_puri *pitip)
e_cal_component_get_uid (pitip->comp, &uid);
- found = e_cal_get_object (pitip->current_ecal, uid, NULL, &icalcomp, NULL);
+ found = e_cal_client_get_object_sync (pitip->current_client, uid, NULL, &icalcomp, NULL, NULL);
if (!found)
return NULL;
@@ -465,10 +463,10 @@ set_buttons_sensitive (struct _itip_puri *pitip)
{
gboolean read_only = TRUE;
- if (pitip->current_ecal)
- e_cal_is_read_only (pitip->current_ecal, &read_only, NULL);
+ if (pitip->current_client)
+ read_only = e_client_is_readonly (E_CLIENT (pitip->current_client));
- itip_view_set_buttons_sensitive (ITIP_VIEW (pitip->view), pitip->current_ecal != NULL && !read_only);
+ itip_view_set_buttons_sensitive (ITIP_VIEW (pitip->view), pitip->current_client != NULL && !read_only);
}
static void
@@ -490,32 +488,42 @@ add_failed_to_load_msg (ItipView *view, ESource *source, const GError *error)
}
static void
-cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
+cal_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- struct _itip_puri *pitip = data;
+ struct _itip_puri *pitip = user_data;
ESource *source;
- ECalSourceType source_type;
+ ECalClientSourceType source_type;
+ ECalClient *client = E_CAL_CLIENT (source_object);
+ GError *error = NULL;
- source_type = e_cal_get_source_type (ecal);
- source = e_cal_get_source (ecal);
+ if (!e_client_open_finish (E_CLIENT (client), result, &error)) {
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
+ g_error_free (error);
+ e_client_open (E_CLIENT (client), TRUE, NULL, cal_opened_cb, user_data);
+ return;
+ }
+ }
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, cal_opened_cb, NULL);
+ source_type = e_cal_client_get_source_type (client);
+ source = e_client_get_source (E_CLIENT (client));
if (error) {
d(printf ("Failed opening itip formatter calendar '%s' during non-search opening\n", e_source_peek_name (source)));
add_failed_to_load_msg (ITIP_VIEW (pitip->view), source, error);
- if (pitip->current_ecal == ecal) {
- pitip->current_ecal = NULL;
+ if (pitip->current_client == client) {
+ pitip->current_client = NULL;
itip_view_set_buttons_sensitive (ITIP_VIEW (pitip->view), FALSE);
}
g_hash_table_remove (pitip->ecals[source_type], e_source_peek_uid (source));
+
+ g_error_free (error);
return;
}
- if (e_cal_get_static_capability (ecal, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+ if (e_cal_client_check_recurrences_no_master (client)) {
icalcomponent *icalcomp = e_cal_component_get_icalcomponent (pitip->comp);
if (check_is_instance (icalcomp))
@@ -524,23 +532,23 @@ cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
itip_view_set_show_recur_check (ITIP_VIEW (pitip->view), FALSE);
}
- if (pitip->type == E_CAL_SOURCE_TYPE_JOURNAL) {
- if (e_cal_get_static_capability (ecal, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING))
+ if (pitip->type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS) {
+ if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING))
itip_view_set_needs_decline (ITIP_VIEW (pitip->view), TRUE);
else
itip_view_set_needs_decline (ITIP_VIEW (pitip->view), FALSE);
itip_view_set_mode (ITIP_VIEW (pitip->view), ITIP_VIEW_MODE_PUBLISH);
}
- pitip->current_ecal = ecal;
+ pitip->current_client = client;
set_buttons_sensitive (pitip);
}
-static ECal *
-start_calendar_server (struct _itip_puri *pitip, ESource *source, ECalSourceType type, FormatItipOpenFunc func, gpointer data)
+static ECalClient *
+start_calendar_server (struct _itip_puri *pitip, ESource *source, ECalClientSourceType type, GAsyncReadyCallback func, gpointer data)
{
- ECal *ecal;
+ ECalClient *client;
EShell *shell;
EShellSettings *shell_settings;
icaltimezone *zone = NULL;
@@ -550,43 +558,41 @@ start_calendar_server (struct _itip_puri *pitip, ESource *source, ECalSourceType
shell = e_shell_get_default ();
shell_settings = e_shell_get_shell_settings (shell);
- ecal = g_hash_table_lookup (pitip->ecals[type], e_source_peek_uid (source));
- if (ecal) {
- pitip->current_ecal = ecal;
+ client = g_hash_table_lookup (pitip->ecals[type], e_source_peek_uid (source));
+ if (client) {
+ pitip->current_client = client;
itip_view_remove_lower_info_item (ITIP_VIEW (pitip->view), pitip->progress_info_id);
pitip->progress_info_id = 0;
set_buttons_sensitive (pitip);
- return ecal;
+ return client;
}
- ecal = e_auth_new_cal_from_source (source, type);
-
- if (!ecal)
+ client = e_cal_client_new (source, type, NULL);
+ if (!client)
return NULL;
- g_signal_connect (G_OBJECT (ecal), "cal_opened_ex", G_CALLBACK (func), data);
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
- g_hash_table_insert (pitip->ecals[type], g_strdup (e_source_peek_uid (source)), ecal);
+ g_hash_table_insert (pitip->ecals[type], g_strdup (e_source_peek_uid (source)), client);
zone = e_shell_settings_get_pointer (shell_settings, "cal-timezone");
- e_cal_set_default_timezone (ecal, zone, NULL);
+ e_cal_client_set_default_timezone (client, zone);
+ e_client_open (E_CLIENT (client), TRUE, NULL, func, data);
- e_cal_open_async (ecal, TRUE);
-
- return ecal;
+ return client;
}
-static ECal *
-start_calendar_server_by_uid (struct _itip_puri *pitip, const gchar *uid, ECalSourceType type)
+static ECalClient *
+start_calendar_server_by_uid (struct _itip_puri *pitip, const gchar *uid, ECalClientSourceType type)
{
gint i;
itip_view_set_buttons_sensitive (ITIP_VIEW (pitip->view), FALSE);
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+ for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) {
ESource *source;
source = e_source_list_peek_source_by_uid (pitip->source_lists[i], uid);
@@ -610,21 +616,29 @@ source_selected_cb (ItipView *view, ESource *source, gpointer data)
}
static void
-find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
+find_cal_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- FormatItipFindData *fd = data;
+ FormatItipFindData *fd = user_data;
struct _itip_puri *pitip = fd->puri;
ESource *source;
- ECalSourceType source_type;
+ ECalClientSourceType source_type;
icalcomponent *icalcomp;
- GList *objects = NULL;
+ GSList *objects = NULL;
+ ECalClient *client = E_CAL_CLIENT (source_object);
+ GError *error = NULL;
- source_type = e_cal_get_source_type (ecal);
- source = e_cal_get_source (ecal);
+ if (!e_client_open_finish (E_CLIENT (client), result, &error)) {
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
+ g_error_free (error);
+ e_client_open (E_CLIENT (client), TRUE, NULL, find_cal_opened_cb, user_data);
+ return;
+ }
+ }
- fd->count--;
+ source_type = e_cal_client_get_source_type (client);
+ source = e_client_get_source (E_CLIENT (client));
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, find_cal_opened_cb, NULL);
+ fd->count--;
if (error) {
/* FIXME Do we really want to warn here? If we fail
@@ -633,31 +647,32 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
d(printf ("Failed opening itip formatter calendar '%s' during search opening... ", e_source_peek_name (source)));
add_failed_to_load_msg (ITIP_VIEW (pitip->view), source, error);
- if (pitip->current_ecal == ecal) {
- pitip->current_ecal = NULL;
+ if (pitip->current_client == client) {
+ pitip->current_client = NULL;
itip_view_set_buttons_sensitive (ITIP_VIEW (pitip->view), FALSE);
}
g_hash_table_remove (pitip->ecals[source_type], e_source_peek_uid (source));
+ g_error_free (error);
goto cleanup;
}
/* Check for conflicts */
/* If the query fails, we'll just ignore it */
/* FIXME What happens for recurring conflicts? */
- if (pitip->type == E_CAL_SOURCE_TYPE_EVENT
+ if (pitip->type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS
&& e_source_get_property (E_SOURCE (source), "conflict")
&& !g_ascii_strcasecmp (e_source_get_property (E_SOURCE (source), "conflict"), "true")
- && e_cal_get_object_list (ecal, fd->sexp, &objects, NULL)
- && g_list_length (objects) > 0) {
+ && e_cal_client_get_object_list_sync (client, fd->sexp, &objects, NULL, NULL)
+ && g_slist_length (objects) > 0) {
itip_view_add_upper_info_item_printf (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_WARNING,
_("An appointment in the calendar '%s' conflicts with this meeting"), e_source_peek_name (source));
- e_cal_free_object_list (objects);
+ e_cal_client_free_icalcomp_slist (objects);
}
/* search for a master object if the detached object doesn't exist in the calendar */
- if (!pitip->current_ecal && (e_cal_get_object (ecal, fd->uid, fd->rid, &icalcomp, NULL) || (fd->rid && e_cal_get_object (ecal, fd->uid, NULL, &icalcomp, NULL)))) {
+ if (!pitip->current_client && (e_cal_client_get_object_sync (client, fd->uid, fd->rid, &icalcomp, NULL, NULL) || (fd->rid && e_cal_client_get_object_sync (client, fd->uid, NULL, &icalcomp, NULL, NULL)))) {
if ((pitip->method == ICAL_METHOD_PUBLISH || pitip->method == ICAL_METHOD_REQUEST) &&
(icalcomponent_get_first_component (icalcomp, ICAL_VALARM_COMPONENT) ||
icalcomponent_get_first_component (icalcomp, ICAL_XAUDIOALARM_COMPONENT) ||
@@ -670,7 +685,7 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
icalcomponent_free (icalcomp);
- pitip->current_ecal = ecal;
+ pitip->current_client = client;
/* Provide extra info, since its not in the component */
/* FIXME Check sequence number of meeting? */
@@ -690,11 +705,11 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
_("Found the appointment in the calendar '%s'"), e_source_peek_name (source));
set_buttons_sensitive (pitip);
- } else if (!pitip->current_ecal)
+ } else if (!pitip->current_client)
itip_view_set_show_keep_alarm_check (ITIP_VIEW (pitip->view), FALSE);
- if (pitip->current_ecal) {
- if (e_cal_get_static_capability (pitip->current_ecal, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
+ if (pitip->current_client) {
+ if (e_cal_client_check_recurrences_no_master (pitip->current_client)) {
icalcomponent *icalcomp = e_cal_component_get_icalcomponent (pitip->comp);
if (check_is_instance (icalcomp))
@@ -703,9 +718,9 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
itip_view_set_show_recur_check (ITIP_VIEW (pitip->view), FALSE);
}
- if (pitip->type == E_CAL_SOURCE_TYPE_JOURNAL) {
+ if (pitip->type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS) {
/* TODO The static capability should be made generic to convey that the calendar contains unaccepted items */
- if (e_cal_get_static_capability (pitip->current_ecal, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING))
+ if (e_client_check_capability (E_CLIENT (pitip->current_client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING))
itip_view_set_needs_decline (ITIP_VIEW (pitip->view), TRUE);
else
itip_view_set_needs_decline (ITIP_VIEW (pitip->view), FALSE);
@@ -729,7 +744,7 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
* invitiations (REQUEST), but not replies (REPLY).
* Replies only make sense for events with an organizer.
*/
- if (!e_cal_get_static_capability (ecal, CAL_STATIC_CAPABILITY_SAVE_SCHEDULES) &&
+ if (!e_cal_client_check_save_schedules (client) &&
(pitip->method == ICAL_METHOD_PUBLISH || pitip->method == ICAL_METHOD_REQUEST) &&
pitip->has_organizer) {
rsvp_enabled = TRUE;
@@ -740,7 +755,7 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
itip_view_set_rsvp (ITIP_VIEW (pitip->view), !pitip->no_reply_wanted);
if ((pitip->method == ICAL_METHOD_PUBLISH || pitip->method == ICAL_METHOD_REQUEST)
- && !pitip->current_ecal) {
+ && !pitip->current_client) {
/* Reuse already declared one or rename? */
EShell *shell;
EShellSettings *shell_settings;
@@ -752,15 +767,15 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
shell_settings = e_shell_get_shell_settings (shell);
switch (pitip->type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
uid = e_shell_settings_get_string (
shell_settings, "cal-primary-calendar");
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
uid = e_shell_settings_get_string (
shell_settings, "cal-primary-task-list");
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
uid = e_shell_settings_get_string (
shell_settings, "cal-primary-memo-list");
break;
@@ -789,17 +804,17 @@ find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data)
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_ERROR, _("Unable to find any calendars"));
itip_view_set_buttons_sensitive (ITIP_VIEW (pitip->view), FALSE);
}
- } else if (!pitip->current_ecal) {
+ } else if (!pitip->current_client) {
switch (pitip->type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
itip_view_add_lower_info_item_printf (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_WARNING,
_("Unable to find this meeting in any calendar"));
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
itip_view_add_lower_info_item_printf (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_WARNING,
_("Unable to find this task in any task list"));
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
itip_view_add_lower_info_item_printf (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_WARNING,
_("Unable to find this memo in any memo list"));
break;
@@ -913,7 +928,7 @@ find_server (struct _itip_puri *pitip, ECalComponent *comp)
d(printf ("Increasing itip formatter search count to %d\n", fd->count));
if (current_source == source)
- pitip->current_ecal = start_calendar_server (pitip, source, pitip->type, find_cal_opened_cb, fd);
+ pitip->current_client = start_calendar_server (pitip, source, pitip->type, find_cal_opened_cb, fd);
else
start_calendar_server (pitip, source, pitip->type, find_cal_opened_cb, fd);
@@ -925,18 +940,6 @@ find_server (struct _itip_puri *pitip, ECalComponent *comp)
g_free (rid);
}
-static void
-cleanup_ecal (gpointer data)
-{
- ECal *ecal = data;
-
- /* Clean up any signals */
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, cal_opened_cb, NULL);
- g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, find_cal_opened_cb, NULL);
-
- g_object_unref (ecal);
-}
-
static gboolean
change_status (icalcomponent *ical_comp, const gchar *address, icalparameter_partstat status)
{
@@ -1167,7 +1170,7 @@ update_item (struct _itip_puri *pitip, ItipViewResponse response)
result = FALSE;
goto cleanup;
}
- source = e_cal_get_source (pitip->current_ecal);
+ source = e_client_get_source (E_CLIENT (pitip->current_client));
if (itip_view_get_keep_alarm_check_state (ITIP_VIEW (pitip->view))) {
ECalComponent *real_comp;
@@ -1250,7 +1253,7 @@ update_item (struct _itip_puri *pitip, ItipViewResponse response)
e_cal_component_set_attachment_list (clone_comp, new_attachments);
}
- if (!e_cal_receive_objects (pitip->current_ecal, pitip->top_level, &error)) {
+ if (!e_cal_client_receive_objects_sync (pitip->current_client, pitip->top_level, NULL, &error)) {
itip_view_add_lower_info_item_printf (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO,
_("Unable to send item to calendar '%s'. %s"),
e_source_peek_name (source), error->message);
@@ -1340,7 +1343,7 @@ set_attendee (ECalComponent *comp, const gchar *address)
}
static gboolean
-send_comp_to_attendee (ECalComponentItipMethod method, ECalComponent *comp, const gchar *user, ECal *client, const gchar *comment)
+send_comp_to_attendee (ECalComponentItipMethod method, ECalComponent *comp, const gchar *user, ECalClient *client, const gchar *comment)
{
gboolean status;
ECalComponent *send_comp = e_cal_component_clone (comp);
@@ -1375,9 +1378,9 @@ remove_delegate (struct _itip_puri *pitip, const gchar *delegate, const gchar *d
gchar *comment = g_strdup_printf (_("Organizer has removed the delegate %s "), itip_strip_mailto (delegate));
/* send cancellation notice to delegate */
- status = send_comp_to_attendee (E_CAL_COMPONENT_METHOD_CANCEL, pitip->comp, delegate, pitip->current_ecal, comment);
+ status = send_comp_to_attendee (E_CAL_COMPONENT_METHOD_CANCEL, pitip->comp, delegate, pitip->current_client, comment);
if (status)
- send_comp_to_attendee (E_CAL_COMPONENT_METHOD_REQUEST, pitip->comp, delegator, pitip->current_ecal, comment);
+ send_comp_to_attendee (E_CAL_COMPONENT_METHOD_REQUEST, pitip->comp, delegator, pitip->current_client, comment);
if (status) {
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO, _("Sent a cancelation notice to the delegate"));
} else
@@ -1424,7 +1427,7 @@ update_attendee_status (struct _itip_puri *pitip)
rid = e_cal_component_get_recurid_as_string (pitip->comp);
/* search for a master object if the detached object doesn't exist in the calendar */
- if (e_cal_get_object (pitip->current_ecal, uid, rid, &icalcomp, NULL) || (rid && e_cal_get_object (pitip->current_ecal, uid, NULL, &icalcomp, NULL))) {
+ if (e_cal_client_get_object_sync (pitip->current_client, uid, rid, &icalcomp, NULL, NULL) || (rid && e_cal_client_get_object_sync (pitip->current_client, uid, NULL, &icalcomp, NULL, NULL))) {
GSList *attendees;
comp = e_cal_component_new ();
@@ -1516,10 +1519,10 @@ update_attendee_status (struct _itip_puri *pitip)
if (itip_view_get_update (ITIP_VIEW (pitip->view))) {
e_cal_component_commit_sequence (comp);
- itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_ecal, NULL, NULL, NULL, TRUE, FALSE);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_client, NULL, NULL, NULL, TRUE, FALSE);
}
- if (!e_cal_modify_object (pitip->current_ecal, icalcomp, rid ? CALOBJ_MOD_THIS : CALOBJ_MOD_ALL, &error)) {
+ if (!e_cal_client_modify_object_sync (pitip->current_client, icalcomp, rid ? CALOBJ_MOD_THIS : CALOBJ_MOD_ALL, NULL, &error)) {
itip_view_add_lower_info_item_printf (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_ERROR,
_("Unable to update attendee. %s"), error->message);
@@ -1546,17 +1549,17 @@ send_item (struct _itip_puri *pitip)
comp = get_real_item (pitip);
if (comp != NULL) {
- itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_ecal, NULL, NULL, NULL, TRUE, FALSE);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_client, NULL, NULL, NULL, TRUE, FALSE);
g_object_unref (comp);
switch (pitip->type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO, _("Meeting information sent"));
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO, _("Task information sent"));
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO, _("Memo information sent"));
break;
default:
@@ -1565,13 +1568,13 @@ send_item (struct _itip_puri *pitip)
}
} else {
switch (pitip->type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_ERROR, _("Unable to send meeting information, the meeting does not exist"));
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_ERROR, _("Unable to send task information, the task does not exist"));
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_ERROR, _("Unable to send memo information, the memo does not exist"));
break;
default:
@@ -1760,7 +1763,7 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
switch (icalcomponent_isa (pitip->ical_comp)) {
case ICAL_VEVENT_COMPONENT:
- pitip->type = E_CAL_SOURCE_TYPE_EVENT;
+ pitip->type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
pitip->has_organizer = icalcomponent_get_first_property (pitip->ical_comp, ICAL_ORGANIZER_PROPERTY) != NULL;
if (icalcomponent_get_first_property (pitip->ical_comp, ICAL_ATTENDEE_PROPERTY) == NULL) {
/* no attendees: assume that that this is not a meeting and organizer doesn't want a reply */
@@ -1773,10 +1776,10 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
}
break;
case ICAL_VTODO_COMPONENT:
- pitip->type = E_CAL_SOURCE_TYPE_TODO;
+ pitip->type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
break;
case ICAL_VJOURNAL_COMPONENT:
- pitip->type = E_CAL_SOURCE_TYPE_JOURNAL;
+ pitip->type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
break;
default:
set_itip_error (pitip, container,
@@ -2023,8 +2026,8 @@ view_response_cb (GtkWidget *widget, ItipViewResponse response, gpointer data)
e_cal_component_set_transparency (pitip->comp, E_CAL_COMPONENT_TRANSP_OPAQUE);
}
- if (!pitip->to_address && pitip->current_ecal != NULL)
- e_cal_get_cal_address (pitip->current_ecal, &pitip->to_address, NULL);
+ if (!pitip->to_address && pitip->current_client != NULL)
+ e_client_get_backend_property_sync (E_CLIENT (pitip->current_client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &pitip->to_address, NULL, NULL);
/* check if it is a recur instance (no master object) and
* add a property */
@@ -2035,12 +2038,11 @@ view_response_cb (GtkWidget *widget, ItipViewResponse response, gpointer data)
}
/*FIXME Save schedules is misused here, remove it */
- save_schedules = e_cal_get_static_capability (pitip->current_ecal,
- CAL_STATIC_CAPABILITY_SAVE_SCHEDULES);
+ save_schedules = e_cal_client_check_save_schedules (pitip->current_client);
switch (response) {
case ITIP_VIEW_RESPONSE_ACCEPT:
- if (pitip->type != E_CAL_SOURCE_TYPE_JOURNAL)
+ if (pitip->type != E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
status = change_status (pitip->ical_comp, pitip->to_address,
ICAL_PARTSTAT_ACCEPTED);
else
@@ -2064,7 +2066,7 @@ view_response_cb (GtkWidget *widget, ItipViewResponse response, gpointer data)
}
break;
case ITIP_VIEW_RESPONSE_DECLINE:
- if (pitip->type != E_CAL_SOURCE_TYPE_JOURNAL)
+ if (pitip->type != E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
status = change_status (pitip->ical_comp, pitip->to_address,
ICAL_PARTSTAT_DECLINED);
else {
@@ -2220,7 +2222,7 @@ view_response_cb (GtkWidget *widget, ItipViewResponse response, gpointer data)
}
e_cal_component_rescan (comp);
- if (itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, pitip->current_ecal, pitip->top_level, NULL, NULL, TRUE, FALSE) && pitip->folder) {
+ if (itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, pitip->current_client, pitip->top_level, NULL, NULL, TRUE, FALSE) && pitip->folder) {
camel_folder_set_message_flags (
pitip->folder, pitip->uid,
CAMEL_MESSAGE_ANSWERED,
@@ -2323,13 +2325,13 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
info->accounts = e_get_account_list ();
/* Source Lists and open ecal clients */
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
- if (!e_cal_get_sources (&info->source_lists[i], i, NULL))
+ for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) {
+ if (!e_cal_client_get_sources (&info->source_lists[i], i, NULL))
/* FIXME More error handling? */
info->source_lists[i] = NULL;
/* Initialize the ecal hashes */
- info->ecals[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, cleanup_ecal);
+ info->ecals[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
}
/* FIXME Handle multiple VEVENTS with the same UID, ie detached instances */
@@ -2587,13 +2589,13 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
if (e_cal_component_has_recurrences (info->comp)) {
/* FIXME Tell the user we don't support recurring tasks */
switch (info->type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
itip_view_add_upper_info_item (ITIP_VIEW (info->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO, _("This meeting recurs"));
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
itip_view_add_upper_info_item (ITIP_VIEW (info->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO, _("This task recurs"));
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
itip_view_add_upper_info_item (ITIP_VIEW (info->view), ITIP_VIEW_INFO_ITEM_TYPE_INFO, _("This memo recurs"));
break;
default:
@@ -2605,10 +2607,10 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
if (response_enabled) {
g_signal_connect (info->view, "response", G_CALLBACK (view_response_cb), info);
- itip_view_set_show_free_time_check (ITIP_VIEW (info->view), info->type == E_CAL_SOURCE_TYPE_EVENT && (info->method == ICAL_METHOD_PUBLISH || info->method == ICAL_METHOD_REQUEST));
+ itip_view_set_show_free_time_check (ITIP_VIEW (info->view), info->type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS && (info->method == ICAL_METHOD_PUBLISH || info->method == ICAL_METHOD_REQUEST));
if (info->calendar_uid)
- info->current_ecal = start_calendar_server_by_uid (info, info->calendar_uid, info->type);
+ info->current_client = start_calendar_server_by_uid (info, info->calendar_uid, info->type);
else {
find_server (info, info->comp);
set_buttons_sensitive (info);
@@ -2624,7 +2626,7 @@ puri_free (EMFormatPURI *puri)
struct _itip_puri *pitip = (struct _itip_puri*) puri;
gint i;
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+ for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) {
if (pitip->source_lists[i])
g_object_unref (pitip->source_lists[i]);
pitip->source_lists[i] = NULL;
@@ -2857,7 +2859,7 @@ itip_formatter_page_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (inner_vbox), label, FALSE, FALSE, 0);
- if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) {
+ if (!e_cal_client_get_sources (&source_list, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL)) {
/* FIXME Error handling */;
}
diff --git a/plugins/itip-formatter/itip-view.c b/plugins/itip-formatter/itip-view.c
index 70ae97784e..50d0fe3534 100644
--- a/plugins/itip-formatter/itip-view.c
+++ b/plugins/itip-formatter/itip-view.c
@@ -30,7 +30,7 @@
#include <libedataserver/e-time-utils.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserverui/e-source-combo-box.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-time-util.h>
#include <gtkhtml/gtkhtml-embedded.h>
#include <mail/em-format-hook.h>
@@ -54,7 +54,7 @@ typedef struct {
struct _ItipViewPrivate {
ItipViewMode mode;
- ECalSourceType type;
+ ECalClientSourceType type;
GtkWidget *sender_label;
gchar *organizer;
@@ -585,13 +585,13 @@ set_sender_text (ItipView *view)
priv = view->priv;
switch (priv->type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
set_calendar_sender_text (view);
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
set_tasklist_sender_text (view);
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
set_journal_sender_text (view);
break;
default:
@@ -855,7 +855,7 @@ set_buttons (ItipView *view)
set_one_button (view, is_recur_set ? _("A_ccept all") : _("A_ccept"), GTK_STOCK_APPLY, ITIP_VIEW_RESPONSE_ACCEPT);
break;
case ITIP_VIEW_MODE_ADD:
- if (priv->type != E_CAL_SOURCE_TYPE_JOURNAL) {
+ if (priv->type != E_CAL_CLIENT_SOURCE_TYPE_MEMOS) {
set_one_button (view, _("_Decline"), GTK_STOCK_CANCEL, ITIP_VIEW_RESPONSE_DECLINE);
set_one_button (view, _("_Tentative"), GTK_STOCK_DIALOG_QUESTION, ITIP_VIEW_RESPONSE_TENTATIVE);
}
@@ -1232,7 +1232,7 @@ itip_view_get_mode (ItipView *view)
}
void
-itip_view_set_item_type (ItipView *view, ECalSourceType type)
+itip_view_set_item_type (ItipView *view, ECalClientSourceType type)
{
ItipViewPrivate *priv;
@@ -1246,7 +1246,7 @@ itip_view_set_item_type (ItipView *view, ECalSourceType type)
set_sender_text (view);
}
-ECalSourceType
+ECalClientSourceType
itip_view_get_item_type (ItipView *view)
{
ItipViewPrivate *priv;
@@ -1918,11 +1918,11 @@ itip_view_set_source_list (ItipView *view, ESourceList *source_list)
G_CALLBACK (source_changed_cb), view);
if (!priv->escb_header) {
- if (priv->type == E_CAL_SOURCE_TYPE_EVENT)
+ if (priv->type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
priv->escb_header = gtk_label_new_with_mnemonic (_("_Calendar:"));
- else if (priv->type == E_CAL_SOURCE_TYPE_TODO)
+ else if (priv->type == E_CAL_CLIENT_SOURCE_TYPE_TASKS)
priv->escb_header = gtk_label_new_with_mnemonic (_("_Tasks:"));
- else if (priv->type == E_CAL_SOURCE_TYPE_JOURNAL)
+ else if (priv->type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS)
priv->escb_header = gtk_label_new_with_mnemonic (_("_Memos:"));
gtk_label_set_selectable (GTK_LABEL (priv->escb_header), TRUE);
diff --git a/plugins/itip-formatter/itip-view.h b/plugins/itip-formatter/itip-view.h
index b9da4eac8b..d68ebdf9a9 100644
--- a/plugins/itip-formatter/itip-view.h
+++ b/plugins/itip-formatter/itip-view.h
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <gtk/gtk.h>
#include <libedataserver/e-source-list.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
G_BEGIN_DECLS
@@ -96,8 +96,8 @@ GtkWidget *itip_view_new (void);
void itip_view_set_mode (ItipView *view, ItipViewMode mode);
ItipViewMode itip_view_get_mode (ItipView *view);
-void itip_view_set_item_type (ItipView *view, ECalSourceType type);
-ECalSourceType itip_view_get_item_type (ItipView *view);
+void itip_view_set_item_type (ItipView *view, ECalClientSourceType type);
+ECalClientSourceType itip_view_get_item_type (ItipView *view);
void itip_view_set_organizer (ItipView *view, const gchar *organizer);
const gchar *itip_view_get_organizer (ItipView *view);
diff --git a/plugins/mail-to-task/Makefile.am b/plugins/mail-to-task/Makefile.am
index 481390ced0..c263702904 100644
--- a/plugins/mail-to-task/Makefile.am
+++ b/plugins/mail-to-task/Makefile.am
@@ -21,7 +21,6 @@ liborg_gnome_mail_to_task_la_LIBADD = \
$(top_builddir)/shell/libeshell.la \
$(top_builddir)/em-format/libemformat.la \
$(top_builddir)/calendar/gui/libevolution-calendar.la \
- $(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(top_builddir)/mail/libevolution-mail.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
$(EVOLUTION_CALENDAR_LIBS) \
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index 3ebc818013..29e0a10e5b 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -34,9 +34,10 @@
#include <gtkhtml/gtkhtml.h>
#include <gconf/gconf-client.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libedataserver/e-account.h>
#include <libedataserverui/e-source-selector-dialog.h>
+#include <libedataserverui/e-client-utils.h>
#include <mail/e-mail-browser.h>
#include <mail/em-utils.h>
@@ -44,7 +45,6 @@
#include <mail/message-list.h>
#include <e-util/e-account-utils.h>
#include <e-util/e-dialog-utils.h>
-#include <calendar/common/authentication.h>
#include <misc/e-popup-action.h>
#include <shell/e-shell-view.h>
#include <shell/e-shell-window-actions.h>
@@ -291,7 +291,7 @@ attachment_save_finished (EAttachmentStore *store,
}
static void
-set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message)
+set_attachments (ECalClient *client, ECalComponent *comp, CamelMimeMessage *message)
{
/* XXX Much of this is copied from CompEditor::get_attachment_list().
* Perhaps it should be split off as a separate utility? */
@@ -321,7 +321,7 @@ set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message)
return;
e_cal_component_get_uid (comp, &comp_uid);
- local_store = e_cal_get_local_attachment_store (client);
+ local_store = e_cal_client_get_local_attachment_store (client);
path = g_build_path ("/", local_store, comp_uid, NULL);
destination = g_file_new_for_path (path);
@@ -438,7 +438,7 @@ report_error_idle (const gchar *format, const gchar *param)
struct _manage_comp
{
- ECal *client;
+ ECalClient *client;
ECalComponent *comp;
icalcomponent *stored_comp; /* the one in client already */
};
@@ -481,18 +481,18 @@ do_ask (const gchar *text, gboolean is_create_edit_add)
}
static const gchar *
-get_question_edit_old (ECalSourceType source_type)
+get_question_edit_old (ECalClientSourceType source_type)
{
const gchar *ask = NULL;
switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
ask = _("Selected calendar contains event '%s' already. Would you like to edit the old event?");
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
ask = _("Selected task list contains task '%s' already. Would you like to edit the old task?");
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
ask = _("Selected memo list contains memo '%s' already. Would you like to edit the old memo?");
break;
default:
@@ -504,24 +504,24 @@ get_question_edit_old (ECalSourceType source_type)
}
static const gchar *
-get_question_create_new (ECalSourceType source_type)
+get_question_create_new (ECalClientSourceType source_type)
{
const gchar *ask = NULL;
switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
/* Translators: Codewise it is impossible to provide separate strings for all
combinations of singular and plural. Please translate it in the way that you
feel is most appropriate for your language. */
ask = _("Selected calendar contains some events for the given mails already. Would you like to create new events anyway?");
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
/* Translators: Codewise it is impossible to provide separate strings for all
combinations of singular and plural. Please translate it in the way that you
feel is most appropriate for your language. */
ask = _("Selected task list contains some tasks for the given mails already. Would you like to create new tasks anyway?");
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
/* Translators: Codewise it is impossible to provide separate strings for all
combinations of singular and plural. Please translate it in the way that you
feel is most appropriate for your language. */
@@ -536,12 +536,12 @@ get_question_create_new (ECalSourceType source_type)
}
static const gchar *
-get_question_create_new_n (ECalSourceType source_type, gint count)
+get_question_create_new_n (ECalClientSourceType source_type, gint count)
{
const gchar *ask = NULL;
switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
ask = ngettext (
/* Translators: Codewise it is impossible to provide separate strings for all
combinations of singular and plural. Please translate it in the way that you
@@ -550,7 +550,7 @@ get_question_create_new_n (ECalSourceType source_type, gint count)
"Selected calendar contains events for the given mails already. Would you like to create new events anyway?",
count);
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
ask = ngettext (
/* Translators: Codewise it is impossible to provide separate strings for all
combinations of singular and plural. Please translate it in the way that you
@@ -559,7 +559,7 @@ get_question_create_new_n (ECalSourceType source_type, gint count)
"Selected task list contains tasks for the given mails already. Would you like to create new tasks anyway?",
count);
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
ask = ngettext (
/* Translators: Codewise it is impossible to provide separate strings for all
combinations of singular and plural. Please translate it in the way that you
@@ -582,7 +582,7 @@ do_manage_comp_idle (GSList *manage_comp_datas)
GError *error = NULL;
guint with_old = 0;
gboolean need_editor = FALSE;
- ECalSourceType source_type = E_CAL_SOURCE_TYPE_LAST;
+ ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST;
GSList *l;
g_return_val_if_fail (manage_comp_datas != NULL, FALSE);
@@ -593,10 +593,10 @@ do_manage_comp_idle (GSList *manage_comp_datas)
if (mc->comp && (e_cal_component_has_attendees (mc->comp) || e_cal_component_has_organizer (mc->comp)))
need_editor = TRUE;
- source_type = e_cal_get_source_type (mc->client);
+ source_type = e_cal_client_get_source_type (mc->client);
}
- if (source_type == E_CAL_SOURCE_TYPE_LAST) {
+ if (source_type == E_CAL_CLIENT_SOURCE_TYPE_LAST) {
g_slist_foreach (manage_comp_datas, (GFunc) free_manage_comp_struct, NULL);
g_slist_free (manage_comp_datas);
@@ -634,7 +634,7 @@ do_manage_comp_idle (GSList *manage_comp_datas)
g_object_unref (edit_comp);
edit_comp = NULL;
- error = g_error_new (E_CALENDAR_ERROR, E_CALENDAR_STATUS_INVALID_OBJECT, "%s", _("Invalid object returned from a server"));
+ error = g_error_new (E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, "%s", _("Invalid object returned from a server"));
}
} else if (chosen == GTK_RESPONSE_NO) {
/* user wants to create a new event, thus generate a new UID */
@@ -686,6 +686,7 @@ do_manage_comp_idle (GSList *manage_comp_datas)
if (can) {
for (l = manage_comp_datas; l && !error; l = l->next) {
struct _manage_comp *mc = l->data;
+ gchar *uid = NULL;
if (!mc)
continue;
@@ -699,7 +700,8 @@ do_manage_comp_idle (GSList *manage_comp_datas)
g_free (new_uid);
}
- e_cal_create_object (mc->client, e_cal_component_get_icalcomponent (mc->comp), NULL, &error);
+ e_cal_client_create_object_sync (mc->client, e_cal_component_get_icalcomponent (mc->comp), &uid, NULL, &error);
+ g_free (uid);
}
}
}
@@ -716,7 +718,7 @@ do_manage_comp_idle (GSList *manage_comp_datas)
}
typedef struct {
- ECal *client;
+ ECalClient *client;
CamelFolder *folder;
GPtrArray *uids;
gchar *selected_text;
@@ -726,27 +728,26 @@ typedef struct {
static gboolean
do_mail_to_event (AsyncData *data)
{
- ECal *client = data->client;
+ ECalClient *client = data->client;
CamelFolder *folder = data->folder;
GPtrArray *uids = data->uids;
GError *err = NULL;
- gboolean readonly = FALSE;
/* open the task client */
- if (!e_cal_open (client, FALSE, &err)) {
+ if (!e_client_open_sync (E_CLIENT (client), FALSE, NULL, &err)) {
report_error_idle (_("Cannot open calendar. %s"), err ? err->message : _("Unknown error."));
- } else if (!e_cal_is_read_only (client, &readonly, &err) || readonly) {
+ } else if (e_client_is_readonly (E_CLIENT (client))) {
if (err)
report_error_idle ("Check readonly failed. %s", err->message);
else {
- switch (e_cal_get_source_type (client)) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ switch (e_cal_client_get_source_type (client)) {
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
report_error_idle (_("Selected source is read only, thus cannot create event there. Select other source, please."), NULL);
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
report_error_idle (_("Selected source is read only, thus cannot create task there. Select other source, please."), NULL);
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
report_error_idle (_("Selected source is read only, thus cannot create memo there. Select other source, please."), NULL);
break;
default:
@@ -757,7 +758,7 @@ do_mail_to_event (AsyncData *data)
} else {
GSList *mcs = NULL;
gint i;
- ECalSourceType source_type = e_cal_get_source_type (client);
+ ECalClientSourceType source_type = e_cal_client_get_source_type (client);
ECalComponentDateTime dt, dt2;
struct icaltimetype tt, tt2;
@@ -791,13 +792,13 @@ do_mail_to_event (AsyncData *data)
comp = e_cal_component_new ();
switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
break;
- case E_CAL_SOURCE_TYPE_TODO:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
break;
- case E_CAL_SOURCE_TYPE_JOURNAL:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL);
break;
default:
@@ -808,7 +809,7 @@ do_mail_to_event (AsyncData *data)
e_cal_component_set_uid (comp, camel_mime_message_get_message_id (message));
e_cal_component_set_dtstart (comp, &dt);
- if (source_type == E_CAL_SOURCE_TYPE_EVENT) {
+ if (source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS) {
/* make it an all-day event */
e_cal_component_set_dtend (comp, &dt2);
}
@@ -859,7 +860,7 @@ do_mail_to_event (AsyncData *data)
mc->client = g_object_ref (client);
mc->comp = g_object_ref (comp);
- if (!e_cal_get_object (client, icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL))
+ if (!e_cal_client_get_object_sync (client, icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL, NULL))
mc->stored_comp = NULL;
mcs = g_slist_append (mcs, mc);
@@ -937,7 +938,7 @@ get_selected_text (EMailReader *reader)
}
static void
-mail_to_event (ECalSourceType source_type,
+mail_to_event (ECalClientSourceType source_type,
gboolean with_attendees,
EMailReader *reader)
{
@@ -952,7 +953,7 @@ mail_to_event (ECalSourceType source_type,
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
- if (!e_cal_get_sources (&source_list, source_type, &error)) {
+ if (!e_cal_client_get_sources (&source_list, source_type, &error)) {
e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot get source list. %s"), error ? error->message : _("Unknown error."));
if (error)
@@ -999,21 +1000,26 @@ mail_to_event (ECalSourceType source_type,
if (source) {
/* if a source has been selected, perform the mail2event operation */
- ECal *client = NULL;
+ ECalClient *client = NULL;
AsyncData *data = NULL;
GThread *thread = NULL;
+ GError *error = NULL;
- client = e_auth_new_cal_from_source (source, source_type);
+ client = e_cal_client_new (source, source_type, &error);
if (!client) {
gchar *uri = e_source_get_uri (source);
- e_notice (NULL, GTK_MESSAGE_ERROR, "Could not create the client: %s", uri);
+ e_notice (NULL, GTK_MESSAGE_ERROR, "Could not create the client '%s': %s", uri, error ? error->message : "Unknown error");
g_free (uri);
g_object_unref (source_list);
+ if (error)
+ g_error_free (error);
return;
}
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
/* Fill the elements in AsynData */
data = g_new0 (AsyncData, 1);
data->client = client;
@@ -1040,28 +1046,28 @@ static void
action_mail_convert_to_event_cb (GtkAction *action,
EMailReader *reader)
{
- mail_to_event (E_CAL_SOURCE_TYPE_EVENT, FALSE, reader);
+ mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, FALSE, reader);
}
static void
action_mail_convert_to_meeting_cb (GtkAction *action,
EMailReader *reader)
{
- mail_to_event (E_CAL_SOURCE_TYPE_EVENT, TRUE, reader);
+ mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, TRUE, reader);
}
static void
action_mail_convert_to_memo_cb (GtkAction *action,
EMailReader *reader)
{
- mail_to_event (E_CAL_SOURCE_TYPE_JOURNAL, FALSE, reader);
+ mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_MEMOS, FALSE, reader);
}
static void
action_mail_convert_to_task_cb (GtkAction *action,
EMailReader *reader)
{
- mail_to_event (E_CAL_SOURCE_TYPE_TODO, FALSE, reader);
+ mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_TASKS, FALSE, reader);
}
/* Note, we're not using EPopupActions here because we update the state
diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c
index 9ede806b73..201b09df7b 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -44,9 +44,9 @@
#include <e-util/e-plugin.h>
#include <libebook/e-contact.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-component.h>
#include <libedataserver/e-data-server-util.h>
@@ -125,10 +125,10 @@ struct _PstImporter {
gint folder_count;
gint current_item;
- EBook *addressbook;
- ECal *calendar;
- ECal *tasks;
- ECal *journal;
+ EBookClient *addressbook;
+ ECalClient *calendar;
+ ECalClient *tasks;
+ ECalClient *journal;
};
gboolean
@@ -366,29 +366,41 @@ pst_import_describe (PstImporter *m, gint complete)
return g_strdup (_("Importing Outlook data"));
}
-static ECal*
-open_ecal (ECalSourceType type, const gchar *name)
+static ECalClient *
+open_ecal (ECalClientSourceType type, const gchar *name)
{
/* Hack - grab the first calendar we can find
TODO - add a selection mechanism in get_widget */
ESource *primary;
ESourceList *source_list;
- ECal *cal;
+ ECalClient *cal;
+ GError *error = NULL;
- if ((e_cal_get_sources (&source_list, type, NULL)) == 0) {
- g_warning ("Could not get any sources of type %s.", name);
+ if ((e_cal_client_get_sources (&source_list, type, &error)) == 0) {
+ g_debug ("%s: Could not get any sources of type %s: %s", G_STRFUNC, name, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
return NULL;
}
primary = e_source_list_peek_source_any (source_list);
- if ((cal = e_cal_new (primary, type)) == NULL) {
- g_warning ("Could not create %s.", name);
+ if ((cal = e_cal_client_new (primary, type, &error)) == NULL) {
+ g_debug ("%s: Could not create %s: %s", G_STRFUNC, name, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
g_object_unref (source_list);
return NULL;
}
- e_cal_open (cal, TRUE, NULL);
+ if (!e_client_open_sync (E_CLIENT (cal), TRUE, NULL, &error)) {
+ g_debug ("%s: Failed to open %s: %s", G_STRFUNC, name, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
+ g_object_unref (cal);
+ cal = NULL;
+ }
+
g_object_unref (primary);
g_object_unref (source_list);
@@ -405,32 +417,39 @@ pst_import_import (PstImporter *m,
TODO - add a selection mechanism in get_widget */
ESource *primary;
ESourceList *source_list;
+ GError *error = NULL;
- if (e_book_get_addressbooks (&source_list, NULL)) {
+ if (e_book_client_get_sources (&source_list, &error)) {
primary = e_source_list_peek_source_any (source_list);
- if ((m->addressbook = e_book_new (primary,NULL))) {
- e_book_open (m->addressbook, TRUE, NULL);
+ if ((m->addressbook = e_book_client_new (primary, &error))) {
+ if (!e_client_open_sync (E_CLIENT (m->addressbook), TRUE, NULL, &error)) {
+ g_debug ("%s: Failed to open book client: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ }
+
g_object_unref (primary);
g_object_unref (source_list);
} else {
- g_warning ("Could not create EBook.");
+ g_debug ("%s: Could not create book client: %s", G_STRFUNC, error ? error->message : "Unknown error");
}
} else {
- g_warning ("Could not get address books.");
+ g_debug ("%s: Could not get address books: %s", G_STRFUNC, error ? error->message : "Unknown error");
}
+
+ if (error)
+ g_error_free (error);
}
if (GPOINTER_TO_INT (g_datalist_get_data (&m->target->data, "pst-do-appt"))) {
- m->calendar = open_ecal (E_CAL_SOURCE_TYPE_EVENT, "calendar");
+ m->calendar = open_ecal (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, "calendar");
}
if (GPOINTER_TO_INT (g_datalist_get_data (&m->target->data, "pst-do-task"))) {
- m->tasks = open_ecal (E_CAL_SOURCE_TYPE_TODO, "task list");
+ m->tasks = open_ecal (E_CAL_CLIENT_SOURCE_TYPE_TASKS, "task list");
}
if (GPOINTER_TO_INT (g_datalist_get_data (&m->target->data, "pst-do-journal"))) {
- m->journal = open_ecal (E_CAL_SOURCE_TYPE_JOURNAL, "journal");
+ m->journal = open_ecal (E_CAL_CLIENT_SOURCE_TYPE_MEMOS, "journal");
}
pst_import_file (m);
@@ -1082,6 +1101,8 @@ pst_process_contact (PstImporter *m, pst_item *item)
pst_item_contact *c;
EContact *ec;
GString *notes;
+ gchar *uid = NULL;
+ GError *error = NULL;
c = item->contact;
notes = g_string_sized_new (2048);
@@ -1218,9 +1239,16 @@ pst_process_contact (PstImporter *m, pst_item *item)
contact_set_string (ec, E_CONTACT_NOTE, notes->str);
g_string_free (notes, TRUE);
- e_book_add_contact (m->addressbook, ec, NULL);
+ if (!e_book_client_add_contact_sync (m->addressbook, ec, &uid, NULL, &error))
+ uid = NULL;
+
g_object_unref (ec);
+ g_free (uid);
+ if (error) {
+ g_debug ("%s: Failed to add contact: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
}
/**
@@ -1246,7 +1274,7 @@ get_ical_date (FILETIME *date, gboolean is_date)
}
static void
-set_cal_attachments (ECal *cal, ECalComponent *ec, PstImporter *m, pst_item_attach *attach)
+set_cal_attachments (ECalClient *cal, ECalComponent *ec, PstImporter *m, pst_item_attach *attach)
{
GSList *list = NULL;
const gchar *uid;
@@ -1257,7 +1285,7 @@ set_cal_attachments (ECal *cal, ECalComponent *ec, PstImporter *m, pst_item_atta
}
e_cal_component_get_uid (ec, &uid);
- store_dir = g_filename_from_uri (e_cal_get_local_attachment_store (cal), NULL, NULL);
+ store_dir = g_filename_from_uri (e_cal_client_get_local_attachment_store (cal), NULL, NULL);
while (attach != NULL) {
const gchar * orig_filename;
@@ -1502,9 +1530,10 @@ fill_calcomponent (PstImporter *m, pst_item *item, ECalComponent *ec, const gcha
}
static void
-pst_process_component (PstImporter *m, pst_item *item, const gchar *comp_type, ECal *cal)
+pst_process_component (PstImporter *m, pst_item *item, const gchar *comp_type, ECalClient *cal)
{
ECalComponent *ec;
+ gchar *uid = NULL;
GError *error = NULL;
g_return_if_fail (item->appointment != NULL);
@@ -1515,12 +1544,13 @@ pst_process_component (PstImporter *m, pst_item *item, const gchar *comp_type, E
fill_calcomponent (m, item, ec, comp_type);
set_cal_attachments (cal, ec, m, item->attach);
- if (!e_cal_create_object (cal, e_cal_component_get_icalcomponent (ec), NULL, &error)) {
+ if (!e_cal_client_create_object_sync (cal, e_cal_component_get_icalcomponent (ec), &uid, NULL, &error)) {
+ uid = NULL;
g_warning ("Creation of %s failed: %s", comp_type, error ? error->message : "Unknown error");
}
g_object_unref (ec);
-
+ g_free (uid);
if (error)
g_error_free (error);
}
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index 2f9b0626cf..65762e0c8a 100644
--- a/plugins/publish-calendar/publish-format-fb.c
+++ b/plugins/publish-calendar/publish-format-fb.c
@@ -30,23 +30,38 @@
#include <gconf/gconf-client.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
-#include <libecal/e-cal.h>
+#include <libedataserverui/e-client-utils.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-util.h>
#include <libecal/e-cal-time-util.h>
-#include <calendar/common/authentication.h>
#include "publish-format-fb.h"
+static void
+free_busy_data_cb (ECalClient *client, const GSList *free_busy_ecalcomps, GSList **pobjects)
+{
+ const GSList *iter;
+
+ g_return_if_fail (pobjects != NULL);
+
+ for (iter = free_busy_ecalcomps; iter != NULL; iter = iter->next) {
+ ECalComponent *comp = iter->data;
+
+ if (comp)
+ *pobjects = g_slist_prepend (*pobjects, g_object_ref (comp));
+ }
+}
+
static gboolean
-write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, gint dur_type, gint dur_value, GError **error)
+write_calendar (const gchar *uid, ESourceList *source_list, GOutputStream *stream, gint dur_type, gint dur_value, GError **error)
{
ESource *source;
- ECal *client = NULL;
- GList *objects;
+ ECalClient *client = NULL;
+ GSList *objects = NULL;
icaltimezone *utc;
time_t start = time (NULL), end;
icalcomponent *top_level;
gchar *email = NULL;
- GList *users = NULL;
+ GSList *users = NULL;
gboolean res = FALSE;
utc = icaltimezone_get_utc_timezone ();
@@ -67,46 +82,52 @@ write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, gin
source = e_source_list_peek_source_by_uid (source_list, uid);
if (source)
- client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
+ client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
if (!client) {
- if (error)
- *error = g_error_new (e_calendar_error_quark (), E_CALENDAR_STATUS_NO_SUCH_CALENDAR, _("Could not publish calendar: Calendar backend no longer exists"));
+ if (error && !*error)
+ *error = g_error_new (E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR, _("Could not publish calendar: Calendar backend no longer exists"));
return FALSE;
}
- if (!e_cal_open (client, TRUE, error)) {
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!e_client_open_sync (E_CLIENT (client), TRUE, NULL, error)) {
g_object_unref (client);
return FALSE;
}
- if (e_cal_get_cal_address (client, &email, NULL)) {
+ if (e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL)) {
if (email && *email)
- users = g_list_append (users, email);
+ users = g_slist_append (users, email);
}
top_level = e_cal_util_new_top_level ();
- if (e_cal_get_free_busy (client, users, start, end, &objects, error)) {
+ g_signal_connect (client, "free-busy-data", G_CALLBACK (free_busy_data_cb), &objects);
+
+ if (e_cal_client_get_free_busy_sync (client, start, end, users, NULL, error)) {
gchar *ical_string;
+ GSList *iter;
- while (objects) {
+ for (iter = objects; iter; iter = iter->next) {
ECalComponent *comp = objects->data;
icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
icalcomponent_add_component (top_level, icalcomp);
- objects = g_list_remove (objects, comp);
}
ical_string = icalcomponent_as_ical_string_r (top_level);
res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, error);
+ e_cal_client_free_ecalcomp_slist (objects);
g_free (ical_string);
}
if (users)
- g_list_free (users);
+ g_slist_free (users);
g_free (email);
g_object_unref (client);
+ icalcomponent_free (top_level);
return res;
}
@@ -116,12 +137,11 @@ publish_calendar_as_fb (GOutputStream *stream, EPublishUri *uri, GError **error)
{
GSList *l;
ESourceList *source_list;
- GConfClient *gconf_client;
- gconf_client = gconf_client_get_default ();
+ if (!e_cal_client_get_sources (&source_list, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error))
+ return;
/* events */
- source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/calendar/sources");
l = uri->events;
while (l) {
gchar *uid = l->data;
@@ -129,7 +149,6 @@ publish_calendar_as_fb (GOutputStream *stream, EPublishUri *uri, GError **error)
break;
l = g_slist_next (l);
}
- g_object_unref (source_list);
- g_object_unref (gconf_client);
+ g_object_unref (source_list);
}
diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c
index b4b5451a2f..de6b342c3d 100644
--- a/plugins/publish-calendar/publish-format-ical.c
+++ b/plugins/publish-calendar/publish-format-ical.c
@@ -29,14 +29,14 @@
#include <gconf/gconf-client.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
-#include <libecal/e-cal.h>
+#include <libedataserverui/e-client-utils.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-util.h>
-#include <calendar/common/authentication.h>
#include "publish-format-ical.h"
typedef struct {
GHashTable *zones;
- ECal *ecal;
+ ECalClient *client;
} CompTzData;
static void
@@ -53,7 +53,7 @@ insert_tz_comps (icalparameter *param, gpointer cb_data)
if (g_hash_table_lookup (tdata->zones, tzid))
return;
- if (!e_cal_get_timezone (tdata->ecal, tzid, &zone, &error)) {
+ if (!e_cal_client_get_timezone_sync (tdata->client, tzid, &zone, NULL, &error)) {
g_warning ("Could not get the timezone information for %s : %s \n", tzid, error->message);
g_error_free (error);
return;
@@ -70,42 +70,44 @@ append_tz_to_comp (gpointer key, gpointer value, icalcomponent *toplevel)
}
static gboolean
-write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, GError **error)
+write_calendar (const gchar *uid, ESourceList *source_list, GOutputStream *stream, GError **error)
{
ESource *source;
- ECal *client = NULL;
- GList *objects;
+ ECalClient *client = NULL;
+ GSList *objects;
icalcomponent *top_level;
gboolean res = FALSE;
source = e_source_list_peek_source_by_uid (source_list, uid);
if (source)
- client = e_auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
+ client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
if (!client) {
- if (error)
- *error = g_error_new (e_calendar_error_quark (), E_CALENDAR_STATUS_NO_SUCH_CALENDAR, _("Could not publish calendar: Calendar backend no longer exists"));
+ if (error && !error)
+ *error = g_error_new (E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR, _("Could not publish calendar: Calendar backend no longer exists"));
return FALSE;
}
- if (!e_cal_open (client, TRUE, error)) {
+ g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!e_client_open_sync (E_CLIENT (client), TRUE, NULL, error)) {
g_object_unref (client);
return FALSE;
}
top_level = e_cal_util_new_top_level ();
- if (e_cal_get_object_list (client, "#t", &objects, error)) {
+ if (e_cal_client_get_object_list_sync (client, "#t", &objects, NULL, error)) {
+ GSList *iter;
gchar *ical_string;
CompTzData tdata;
tdata.zones = g_hash_table_new (g_str_hash, g_str_equal);
- tdata.ecal = client;
+ tdata.client = client;
- while (objects) {
+ for (iter = objects; iter; iter = iter->next) {
icalcomponent *icalcomp = objects->data;
icalcomponent_foreach_tzid (icalcomp, insert_tz_comps, &tdata);
icalcomponent_add_component (top_level, icalcomp);
- objects = g_list_remove (objects, icalcomp);
}
g_hash_table_foreach (tdata.zones, (GHFunc) append_tz_to_comp, top_level);
@@ -116,9 +118,11 @@ write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, GEr
ical_string = icalcomponent_as_ical_string_r (top_level);
res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, error);
g_free (ical_string);
+ e_cal_client_free_icalcomp_slist (objects);
}
g_object_unref (client);
+ icalcomponent_free (top_level);
return res;
}
@@ -128,12 +132,11 @@ publish_calendar_as_ical (GOutputStream *stream, EPublishUri *uri, GError **erro
{
GSList *l;
ESourceList *source_list;
- GConfClient *gconf_client;
-
- gconf_client = gconf_client_get_default ();
/* events */
- source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/calendar/sources");
+ if (!e_cal_client_get_sources (&source_list, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error))
+ return;
+
l = uri->events;
while (l) {
gchar *uid = l->data;
@@ -141,7 +144,6 @@ publish_calendar_as_ical (GOutputStream *stream, EPublishUri *uri, GError **erro
break;
l = g_slist_next (l);
}
- g_object_unref (source_list);
- g_object_unref (gconf_client);
+ g_object_unref (source_list);
}
diff --git a/plugins/save-calendar/csv-format.c b/plugins/save-calendar/csv-format.c
index 15ed83817e..da21588d8c 100644
--- a/plugins/save-calendar/csv-format.c
+++ b/plugins/save-calendar/csv-format.c
@@ -30,8 +30,8 @@
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
-#include "calendar/common/authentication.h"
+#include <libedataserverui/e-client-utils.h>
+#include <libecal/e-cal-client.h>
#include <string.h>
#include "format-handler.h"
@@ -300,7 +300,7 @@ userstring_to_systemstring (const gchar *userstring)
static void
do_save_calendar_csv (FormatHandler *handler,
ESourceSelector *selector,
- ECalSourceType type,
+ ECalClientSourceType type,
gchar *dest_uri)
{
@@ -314,9 +314,9 @@ do_save_calendar_csv (FormatHandler *handler,
*/
ESource *primary_source;
- ECal *source_client;
+ ECalClient *source_client;
GError *error = NULL;
- GList *objects=NULL;
+ GSList *objects = NULL;
GOutputStream *stream;
GString *line = NULL;
CsvConfig *config = NULL;
@@ -329,12 +329,16 @@ do_save_calendar_csv (FormatHandler *handler,
primary_source = e_source_selector_get_primary_selection (selector);
/* open source client */
- source_client = e_auth_new_cal_from_source (primary_source, type);
- if (!e_cal_open (source_client, TRUE, &error)) {
+ source_client = e_cal_client_new (primary_source, type, &error);
+ if (source_client)
+ g_signal_connect (source_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!source_client || !e_client_open_sync (E_CLIENT (source_client), TRUE, NULL, &error)) {
display_error_message (
gtk_widget_get_toplevel (GTK_WIDGET (selector)),
error);
- g_object_unref (source_client);
+ if (source_client)
+ g_object_unref (source_client);
g_error_free (error);
return;
}
@@ -354,8 +358,8 @@ do_save_calendar_csv (FormatHandler *handler,
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (selector))),
dest_uri, &error);
- if (stream && e_cal_get_object_list_as_comp (
- source_client, "#t", &objects, NULL)) {
+ if (stream && e_cal_client_get_object_list_as_comps_sync (source_client, "#t", &objects, NULL, NULL)) {
+ GSList *iter;
if (config->header) {
@@ -396,7 +400,7 @@ do_save_calendar_csv (FormatHandler *handler,
g_string_free (line, TRUE);
}
- while (objects != NULL) {
+ for (iter = objects; iter; iter = iter->next) {
ECalComponent *comp = objects->data;
gchar *delimiter_temp = NULL;
const gchar *temp_constchar;
@@ -521,11 +525,11 @@ do_save_calendar_csv (FormatHandler *handler,
/* It's written, so we can free it */
g_string_free (line, TRUE);
-
- objects = g_list_next (objects);
}
g_output_stream_close (stream, NULL, NULL);
+
+ e_cal_client_free_ecalcomp_slist (objects);
}
if (stream)
diff --git a/plugins/save-calendar/format-handler.h b/plugins/save-calendar/format-handler.h
index e04d95fbf1..b7376920ef 100644
--- a/plugins/save-calendar/format-handler.h
+++ b/plugins/save-calendar/format-handler.h
@@ -24,7 +24,7 @@
#include <gio/gio.h>
#include <libedataserver/e-source.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
typedef struct _FormatHandler FormatHandler;
@@ -39,7 +39,7 @@ struct _FormatHandler
void (*save) (FormatHandler *handler,
ESourceSelector *selector,
- ECalSourceType type,
+ ECalClientSourceType type,
gchar *dest_uri);
};
diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c
index fa4f6a5515..39cac6f2e0 100644
--- a/plugins/save-calendar/ical-format.c
+++ b/plugins/save-calendar/ical-format.c
@@ -29,9 +29,9 @@
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libedataserverui/e-client-utils.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-util.h>
-#include <calendar/common/authentication.h>
#include <string.h>
#include "format-handler.h"
@@ -48,7 +48,7 @@ display_error_message (GtkWidget *parent, const gchar *message)
typedef struct {
GHashTable *zones;
- ECal *ecal;
+ ECalClient *client;
} CompTzData;
static void
@@ -65,7 +65,7 @@ insert_tz_comps (icalparameter *param, gpointer cb_data)
if (g_hash_table_lookup (tdata->zones, tzid))
return;
- if (!e_cal_get_timezone (tdata->ecal, tzid, &zone, &error)) {
+ if (!e_cal_client_get_timezone_sync (tdata->client, tzid, &zone, NULL, &error)) {
g_warning ("Could not get the timezone information for %s : %s \n", tzid, error->message);
g_error_free (error);
return;
@@ -82,12 +82,12 @@ append_tz_to_comp (gpointer key, gpointer value, icalcomponent *toplevel)
}
static void
-do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSourceType type, gchar *dest_uri)
+do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalClientSourceType type, gchar *dest_uri)
{
ESource *primary_source;
- ECal *source_client;
+ ECalClient *source_client;
GError *error = NULL;
- GList *objects;
+ GSList *objects = NULL;
icalcomponent *top_level = NULL;
primary_source = e_source_selector_get_primary_selection (selector);
@@ -96,10 +96,14 @@ do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSo
return;
/* open source client */
- source_client = (ECal*) e_auth_new_cal_from_source (primary_source, type);
- if (!e_cal_open (source_client, TRUE, &error)) {
+ source_client = e_cal_client_new (primary_source, type, &error);
+ if (source_client)
+ g_signal_connect (source_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!source_client || !e_client_open_sync (E_CLIENT (source_client), TRUE, NULL, &error)) {
display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), error->message);
- g_object_unref (source_client);
+ if (source_client)
+ g_object_unref (source_client);
g_error_free (error);
return;
}
@@ -108,21 +112,19 @@ do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSo
top_level = e_cal_util_new_top_level ();
error = NULL;
- if (e_cal_get_object_list (source_client, "#t", &objects, &error)) {
+ if (e_cal_client_get_object_list_sync (source_client, "#t", &objects, NULL, &error)) {
CompTzData tdata;
GOutputStream *stream;
+ GSList *iter;
tdata.zones = g_hash_table_new (g_str_hash, g_str_equal);
- tdata.ecal = source_client;
+ tdata.client = source_client;
- while (objects != NULL) {
+ for (iter = objects; iter; iter = iter->next) {
icalcomponent *icalcomp = objects->data;
icalcomponent_foreach_tzid (icalcomp, insert_tz_comps, &tdata);
icalcomponent_add_component (top_level, icalcomp);
-
- /* remove item from the list */
- objects = g_list_remove (objects, icalcomp);
}
g_hash_table_foreach (tdata.zones, (GHFunc) append_tz_to_comp, top_level);
@@ -142,6 +144,8 @@ do_save_calendar_ical (FormatHandler *handler, ESourceSelector *selector, ECalSo
g_object_unref (stream);
g_free (ical_str);
}
+
+ e_cal_client_free_icalcomp_slist (objects);
}
if (error) {
diff --git a/plugins/save-calendar/rdf-format.c b/plugins/save-calendar/rdf-format.c
index 084250e70c..c64b31f055 100644
--- a/plugins/save-calendar/rdf-format.c
+++ b/plugins/save-calendar/rdf-format.c
@@ -27,8 +27,9 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-data-server-util.h>
#include <libxml/xmlmemory.h>
@@ -38,7 +39,6 @@
#include <libxml/xpath.h>
#include <string.h>
-#include "calendar/common/authentication.c"
#include "format-handler.h"
static void
@@ -169,7 +169,7 @@ add_string_to_rdf (xmlNodePtr node, const gchar *tag, const gchar *value)
}
static void
-do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSourceType type, gchar *dest_uri)
+do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalClientSourceType type, gchar *dest_uri)
{
/*
@@ -182,9 +182,9 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
*/
ESource *primary_source;
- ECal *source_client;
+ ECalClient *source_client;
GError *error = NULL;
- GList *objects=NULL;
+ GSList *objects = NULL;
gchar *temp = NULL;
GOutputStream *stream;
@@ -194,17 +194,23 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
primary_source = e_source_selector_get_primary_selection (selector);
/* open source client */
- source_client = e_auth_new_cal_from_source (primary_source, type);
- if (!e_cal_open (source_client, TRUE, &error)) {
+ source_client = e_cal_client_new (primary_source, type, &error);
+ if (source_client)
+ g_signal_connect (source_client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+
+ if (!source_client || !e_client_open_sync (E_CLIENT (source_client), TRUE, NULL, &error)) {
display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), error);
- g_object_unref (source_client);
+ if (source_client)
+ g_object_unref (source_client);
g_error_free (error);
return;
}
stream = open_for_writing (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (selector))), dest_uri, &error);
- if (stream && e_cal_get_object_list_as_comp (source_client, "#t", &objects, NULL)) {
+ if (stream && e_cal_client_get_object_list_as_comps_sync (source_client, "#t", &objects, NULL, NULL)) {
+ GSList *iter;
+
xmlBufferPtr buffer=xmlBufferCreate ();
xmlDocPtr doc = xmlNewDoc((xmlChar *) "1.0");
xmlNodePtr fnode;
@@ -238,7 +244,7 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
/* Version of this RDF-format */
xmlNewChild (fnode, NULL, (const guchar *)"version", (const guchar *)"2.0");
- while (objects != NULL) {
+ for (iter = objects; iter; iter = iter->next) {
ECalComponent *comp = objects->data;
const gchar *temp_constchar;
gchar *tmp_str = NULL;
@@ -334,8 +340,6 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
* http://www.gnome.org/projects/evolution/developer-doc/libecal/ECalComponent.html
* #e-cal-component-get-last-modified
*/
-
- objects = g_list_next (objects);
}
/* I used a buffer rather than xmlDocDump: I want gio support */
@@ -344,6 +348,8 @@ do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalSou
g_output_stream_write_all (stream, xmlBufferContent (buffer), xmlBufferLength (buffer), NULL, NULL, &error);
g_output_stream_close (stream, NULL, NULL);
+ e_cal_client_free_ecalcomp_slist (objects);
+
xmlBufferFree (buffer);
xmlFreeDoc (doc);
}
diff --git a/plugins/save-calendar/save-calendar.c b/plugins/save-calendar/save-calendar.c
index 8bf0067b79..a1a48be7cf 100644
--- a/plugins/save-calendar/save-calendar.c
+++ b/plugins/save-calendar/save-calendar.c
@@ -32,7 +32,7 @@
#include <glib/gi18n.h>
#include <libedataserver/e-source.h>
#include <libedataserverui/e-source-selector.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include <e-util/e-alert-dialog.h>
#include <e-util/e-plugin.h>
#include <string.h>
@@ -113,7 +113,7 @@ format_handlers_foreach_free (gpointer data, gpointer user_data)
}
static void
-ask_destination_and_save (ESourceSelector *selector, ECalSourceType type)
+ask_destination_and_save (ESourceSelector *selector, ECalClientSourceType type)
{
FormatHandler *handler = NULL;
@@ -284,7 +284,7 @@ open_for_writing (GtkWindow *parent, const gchar *uri, GError **error)
static void
save_general (EShellView *shell_view,
- ECalSourceType type)
+ ECalClientSourceType type)
{
EShellSidebar *shell_sidebar;
ESourceSelector *selector = NULL;
@@ -302,21 +302,21 @@ static void
action_calendar_save_as_cb (GtkAction *action,
EShellView *shell_view)
{
- save_general (shell_view, E_CAL_SOURCE_TYPE_EVENT);
+ save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_EVENTS);
}
static void
action_memo_list_save_as_cb (GtkAction *action,
EShellView *shell_view)
{
- save_general (shell_view, E_CAL_SOURCE_TYPE_JOURNAL);
+ save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_MEMOS);
}
static void
action_task_list_save_as_cb (GtkAction *action,
EShellView *shell_view)
{
- save_general (shell_view, E_CAL_SOURCE_TYPE_TODO);
+ save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_TASKS);
}
gboolean
diff --git a/plugins/vcard-inline/vcard-inline.c b/plugins/vcard-inline/vcard-inline.c
index 062f21e598..7e56da440b 100644
--- a/plugins/vcard-inline/vcard-inline.c
+++ b/plugins/vcard-inline/vcard-inline.c
@@ -22,10 +22,10 @@
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
#include <gtkhtml/gtkhtml-embedded.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector-dialog.h>
#include "addressbook/gui/merging/eab-contact-merging.h"
@@ -41,7 +41,7 @@ typedef struct _VCardInlinePObject VCardInlinePObject;
struct _VCardInlinePObject {
EMFormatHTMLPObject object;
- GList *contact_list;
+ GSList *contact_list;
ESourceList *source_list;
GtkWidget *contact_display;
GtkWidget *message_label;
@@ -66,10 +66,7 @@ org_gnome_vcard_inline_pobject_free (EMFormatHTMLPObject *object)
vcard_object = (VCardInlinePObject *) object;
- g_list_foreach (
- vcard_object->contact_list,
- (GFunc) g_object_unref, NULL);
- g_list_free (vcard_object->contact_list);
+ e_client_util_free_object_slist (vcard_object->contact_list);
vcard_object->contact_list = NULL;
if (vcard_object->source_list != NULL) {
@@ -95,7 +92,7 @@ org_gnome_vcard_inline_decode (VCardInlinePObject *vcard_object,
CamelDataWrapper *data_wrapper;
CamelMedium *medium;
CamelStream *stream;
- GList *contact_list;
+ GSList *contact_list;
GByteArray *array;
const gchar *string;
const guint8 padding[2] = {0};
@@ -121,37 +118,43 @@ org_gnome_vcard_inline_decode (VCardInlinePObject *vcard_object,
}
static void
-org_gnome_vcard_inline_book_loaded_cb (ESource *source,
- GAsyncResult *result,
- GList *contact_list)
+org_gnome_vcard_inline_client_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EBook *book;
- GList *iter;
-
- book = e_load_book_source_finish (source, result, NULL);
-
- if (book == NULL)
+ EClient *client = NULL;
+ EBookClient *book_client;
+ GSList *contact_list = user_data, *iter;
+ GError *error = NULL;
+
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
+ client = NULL;
+
+ if (client == NULL) {
+ g_debug ("%s: Failed to open book client: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ if (error)
+ g_error_free (error);
goto exit;
+ }
+
+ book_client = E_BOOK_CLIENT (client);
for (iter = contact_list; iter != NULL; iter = iter->next) {
EContact *contact;
contact = E_CONTACT (iter->data);
- eab_merging_book_add_contact (book, contact, NULL, NULL);
+ eab_merging_book_add_contact (book_client, contact, NULL, NULL);
}
- g_object_unref (book);
+ g_object_unref (client);
-exit:
- g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (contact_list);
+ exit:
+ e_client_util_free_object_slist (contact_list);
}
static void
org_gnome_vcard_inline_save_cb (VCardInlinePObject *vcard_object)
{
ESource *source;
- GList *contact_list;
+ GSList *contact_list;
GtkWidget*dialog;
g_return_if_fail (vcard_object->source_list != NULL);
@@ -173,12 +176,11 @@ org_gnome_vcard_inline_save_cb (VCardInlinePObject *vcard_object)
g_return_if_fail (source != NULL);
- contact_list = g_list_copy (vcard_object->contact_list);
- g_list_foreach (contact_list, (GFunc) g_object_ref, NULL);
+ contact_list = e_client_util_copy_object_slist (NULL, vcard_object->contact_list);
- e_load_book_source_async (
- source, NULL, NULL, (GAsyncReadyCallback)
- org_gnome_vcard_inline_book_loaded_cb, contact_list);
+ e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ org_gnome_vcard_inline_client_loaded_cb, contact_list);
}
static void
@@ -218,7 +220,7 @@ org_gnome_vcard_inline_embed (EMFormatHTML *format,
guint length;
vcard_object = (VCardInlinePObject *) object;
- length = g_list_length (vcard_object->contact_list);
+ length = g_slist_length (vcard_object->contact_list);
if (vcard_object->contact_list != NULL)
contact = E_CONTACT (vcard_object->contact_list->data);
@@ -328,7 +330,7 @@ org_gnome_vcard_inline_format (gpointer ep, EMFormatHookTarget *target)
vcard_object->object.free = org_gnome_vcard_inline_pobject_free;
org_gnome_vcard_inline_decode (vcard_object, target->part);
- e_book_get_addressbooks (&vcard_object->source_list, NULL);
+ e_book_client_get_sources (&vcard_object->source_list, NULL);
camel_stream_printf (
target->stream, "<object classid=%s></object>", classid);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b11778909d..fc0d0207f0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -37,7 +37,6 @@ addressbook/tools/evolution-addressbook-export-list-cards.c
addressbook/tools/evolution-addressbook-export-list-folders.c
addressbook/tools/evolution-addressbook-export.c
calendar/calendar.error.xml
-calendar/common/authentication.c
calendar/gui/alarm-notify/alarm-notify-dialog.c
[type: gettext/glade]calendar/gui/alarm-notify/alarm-notify.ui
calendar/gui/alarm-notify/alarm-queue.c
diff --git a/widgets/misc/e-contact-map-window.c b/widgets/misc/e-contact-map-window.c
index 117051528d..1618086a1b 100644
--- a/widgets/misc/e-contact-map-window.c
+++ b/widgets/misc/e-contact-map-window.c
@@ -30,7 +30,8 @@
#include <champlain/champlain.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
#include <libebook/e-contact.h>
#include <string.h>
@@ -73,25 +74,27 @@ marker_doubleclick_cb (ClutterActor *marker,
}
static void
-book_contacts_received_cb (EBook *book,
- const GError *error,
- GList *list,
- gpointer closure)
+book_contacts_received_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
- EContactMapWindow *window = closure;
- GList *p;
+ EContactMapWindow *window = user_data;
+ EBookClient *client = E_BOOK_CLIENT (source_object);
+ GSList *contacts = NULL, *p;
+ GError *error = NULL;
- g_return_if_fail (error == NULL);
+ if (!e_book_client_get_contacts_finish (client, result, &contacts, &error))
+ contacts = NULL;
- for (p = list; p; p = p->next) {
+ if (error) {
+ g_debug ("%s: Failed to get contacts: %s", G_STRFUNC, error ? error->message : "Unknown error");
+ g_clear_error (&error);
+ }
+ for (p = contacts; p; p = p->next) {
e_contact_map_add_contact (window->priv->map, (EContact*) p->data);
-
}
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
- g_object_unref (book);
+ e_client_util_free_object_slist (contacts);
+ g_object_unref (client);
}
static void
@@ -435,23 +438,26 @@ e_contact_map_window_new (void)
*/
void
e_contact_map_window_load_addressbook (EContactMapWindow *map,
- EBook *book)
+ EBookClient *book_client)
{
EBookQuery *book_query;
+ gchar *query_string;
+
+ g_return_if_fail (E_IS_CONTACT_MAP_WINDOW (map));
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
+
/* Reference book, so that it does not get deleted before the callback is
involved. The book is unrefed in the callback */
- g_object_ref (book);
-
- g_return_if_fail (E_IS_CONTACT_MAP_WINDOW (map));
- g_return_if_fail (E_IS_BOOK (book));
+ g_object_ref (book_client);
book_query = e_book_query_field_exists (E_CONTACT_ADDRESS);
+ query_string = e_book_query_to_string (book_query);
+ e_book_query_unref (book_query);
- e_book_get_contacts_async (book, book_query,
- (EBookListAsyncCallback) book_contacts_received_cb, map);
+ e_book_client_get_contacts (book_client, query_string, NULL, book_contacts_received_cb, map);
- e_book_query_unref (book_query);
+ g_free (query_string);
}
EContactMap*
diff --git a/widgets/misc/e-contact-map-window.h b/widgets/misc/e-contact-map-window.h
index ea96d88e39..ea92d75c46 100644
--- a/widgets/misc/e-contact-map-window.h
+++ b/widgets/misc/e-contact-map-window.h
@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <e-contact-map.h>
@@ -68,7 +68,7 @@ GType e_contact_map_window_get_type (void) G_GNUC_CONST;
EContactMapWindow* e_contact_map_window_new (void);
void e_contact_map_window_load_addressbook (EContactMapWindow *window,
- EBook *book);
+ EBookClient *book);
EContactMap* e_contact_map_window_get_map (EContactMapWindow *window);