aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/alarm-notify/alarm-notify.c24
-rw-r--r--calendar/gui/dialogs/copy-source-dialog.c59
-rw-r--r--calendar/gui/dialogs/event-page.c59
-rw-r--r--calendar/gui/dialogs/memo-page.c58
-rw-r--r--calendar/gui/dialogs/task-page.c59
-rw-r--r--calendar/gui/e-calendar-selector.c25
-rw-r--r--calendar/gui/e-memo-list-selector.c50
-rw-r--r--calendar/gui/e-task-list-selector.c50
-rw-r--r--calendar/importers/icalendar-importer.c65
-rw-r--r--modules/calendar/e-cal-attachment-handler.c36
-rw-r--r--modules/calendar/e-cal-shell-backend.c51
-rw-r--r--modules/calendar/e-cal-shell-sidebar.c424
-rw-r--r--modules/calendar/e-cal-shell-sidebar.h3
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c30
-rw-r--r--modules/calendar/e-memo-shell-backend.c43
-rw-r--r--modules/calendar/e-memo-shell-sidebar.c424
-rw-r--r--modules/calendar/e-memo-shell-sidebar.h3
-rw-r--r--modules/calendar/e-task-shell-backend.c43
-rw-r--r--modules/calendar/e-task-shell-sidebar.c424
-rw-r--r--modules/calendar/e-task-shell-sidebar.h3
-rw-r--r--modules/itip-formatter/itip-view.c34
-rw-r--r--plugins/mail-to-task/mail-to-task.c57
-rw-r--r--plugins/publish-calendar/publish-format-fb.c24
-rw-r--r--plugins/publish-calendar/publish-format-ical.c24
-rw-r--r--plugins/save-calendar/csv-format.c16
-rw-r--r--plugins/save-calendar/ical-format.c22
-rw-r--r--plugins/save-calendar/rdf-format.c28
27 files changed, 1185 insertions, 953 deletions
diff --git a/calendar/alarm-notify/alarm-notify.c b/calendar/alarm-notify/alarm-notify.c
index ce7efee9ac..a4552a055b 100644
--- a/calendar/alarm-notify/alarm-notify.c
+++ b/calendar/alarm-notify/alarm-notify.c
@@ -225,17 +225,17 @@ alarm_notify_new (GCancellable *cancellable,
}
static void
-client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ESource *source = E_SOURCE (source_object);
AlarmNotify *an = ALARM_NOTIFY (user_data);
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
/* Sanity check. */
g_return_if_fail (
@@ -276,7 +276,7 @@ void
alarm_notify_add_calendar (AlarmNotify *an,
ESource *source)
{
- EClientSourceType client_source_type;
+ ECalClientSourceType source_type;
const gchar *extension_name;
g_return_if_fail (IS_ALARM_NOTIFY (an));
@@ -291,11 +291,11 @@ alarm_notify_add_calendar (AlarmNotify *an,
/* Check if this is an ESource we're interested in. */
if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR))
- client_source_type = E_CLIENT_SOURCE_TYPE_EVENTS;
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
else if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST))
- client_source_type = E_CLIENT_SOURCE_TYPE_MEMOS;
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
else if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST))
- client_source_type = E_CLIENT_SOURCE_TYPE_TASKS;
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
else {
g_mutex_unlock (&an->priv->mutex);
return;
@@ -314,9 +314,9 @@ alarm_notify_add_calendar (AlarmNotify *an,
debug (("Opening '%s' (%s)", e_source_get_display_name (source), e_source_get_uid (source)));
- e_client_utils_open_new (
- source, client_source_type, TRUE, NULL,
- client_opened_cb, an);
+ e_cal_client_connect (
+ source, source_type, NULL,
+ client_connect_cb, an);
g_mutex_unlock (&an->priv->mutex);
}
diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c
index f8b668b933..0f0dc0545e 100644
--- a/calendar/gui/dialogs/copy-source-dialog.c
+++ b/calendar/gui/dialogs/copy-source-dialog.c
@@ -36,7 +36,7 @@
typedef struct {
GtkWindow *parent;
ESource *orig_source;
- EClientSourceType obj_type;
+ ECalClientSourceType obj_type;
ESource *selected_source;
ECalClient *source_client, *dest_client;
} CopySourceDialogData;
@@ -99,27 +99,28 @@ free_copy_data (CopySourceDialogData *csdd)
}
static void
-dest_source_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+dest_source_connected_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
CopySourceDialogData *csdd = user_data;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
show_error (csdd, _("Could not open destination"), error);
g_error_free (error);
free_copy_data (csdd);
return;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
csdd->dest_client = E_CAL_CLIENT (client);
/* check if the destination is read only */
@@ -174,32 +175,33 @@ dest_source_opened_cb (GObject *source_object,
}
static void
-orig_source_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+orig_source_connected_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
CopySourceDialogData *csdd = user_data;
- EClient *client = NULL;
+ EClient *client;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
show_error (csdd, _("Could not open source"), error);
g_error_free (error);
free_copy_data (csdd);
return;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
csdd->source_client = E_CAL_CLIENT (client);
- e_client_utils_open_new (
- csdd->selected_source, csdd->obj_type, FALSE, NULL,
- dest_source_opened_cb, csdd);
+ e_cal_client_connect (
+ csdd->selected_source, csdd->obj_type, NULL,
+ dest_source_connected_cb, csdd);
}
static void
@@ -210,17 +212,15 @@ copy_source (const CopySourceDialogData *const_csdd)
if (!const_csdd->selected_source)
return;
- 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,
- orig_source_opened_cb, csdd);
+ e_cal_client_connect (
+ csdd->orig_source, csdd->obj_type, NULL,
+ orig_source_connected_cb, csdd);
}
/**
@@ -246,10 +246,7 @@ copy_source_dialog (GtkWindow *parent,
csdd.parent = parent;
csdd.orig_source = source;
csdd.selected_source = NULL;
- 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.obj_type = obj_type;
csdd.selected_source = select_source_dialog (
parent, registry, obj_type, source);
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index c12b7c7360..6850a3b151 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -183,7 +183,7 @@ struct _EventPagePrivate {
/* either with-user-time or without it */
const gint *alarm_map;
- GCancellable *open_cancellable;
+ GCancellable *connect_cancellable;
};
static void event_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates);
@@ -878,10 +878,10 @@ event_page_dispose (GObject *object)
priv = EVENT_PAGE_GET_PRIVATE (object);
- if (priv->open_cancellable) {
- g_cancellable_cancel (priv->open_cancellable);
- g_object_unref (priv->open_cancellable);
- priv->open_cancellable = NULL;
+ if (priv->connect_cancellable != NULL) {
+ g_cancellable_cancel (priv->connect_cancellable);
+ g_object_unref (priv->connect_cancellable);
+ priv->connect_cancellable = NULL;
}
if (priv->location_completion != NULL) {
@@ -1842,7 +1842,6 @@ event_page_init (EventPage *epage)
epage->priv->alarm_interval = -1;
epage->priv->alarm_map = alarm_map_with_user_time;
epage->priv->location_completion = gtk_entry_completion_new ();
- epage->priv->open_cancellable = NULL;
}
void
@@ -2988,23 +2987,27 @@ event_page_send_options_clicked_cb (EventPage *epage)
}
static void
-epage_client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+epage_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
EventPage *epage = user_data;
EventPagePrivate *priv;
CompEditor *editor;
GError *error = NULL;
- if (!e_client_utils_open_new_finish (source, result, &client, &error)) {
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_clear_error (&error);
- return;
- }
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
+ g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_clear_error (&error);
+ return;
}
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage));
@@ -3013,9 +3016,13 @@ epage_client_opened_cb (GObject *source_object,
if (error) {
GtkWidget *dialog;
ECalClient *old_client;
+ ESource *source;
old_client = comp_editor_get_client (editor);
+ source = e_source_combo_box_ref_active (
+ E_SOURCE_COMBO_BOX (priv->source_combo_box));
+
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_combo_box),
e_client_get_source (E_CLIENT (old_client)));
@@ -3029,6 +3036,8 @@ epage_client_opened_cb (GObject *source_object,
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+ g_object_unref (source);
+
g_clear_error (&error);
} else {
gchar *backend_addr = NULL;
@@ -3074,16 +3083,16 @@ source_changed_cb (ESourceComboBox *source_combo_box,
source = e_source_combo_box_ref_active (source_combo_box);
g_return_if_fail (source != NULL);
- if (priv->open_cancellable) {
- g_cancellable_cancel (priv->open_cancellable);
- g_object_unref (priv->open_cancellable);
+ if (priv->connect_cancellable != NULL) {
+ g_cancellable_cancel (priv->connect_cancellable);
+ g_object_unref (priv->connect_cancellable);
}
- priv->open_cancellable = g_cancellable_new ();
+ priv->connect_cancellable = g_cancellable_new ();
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_EVENTS,
- FALSE, priv->open_cancellable,
- epage_client_opened_cb, epage);
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
+ priv->connect_cancellable,
+ epage_client_connect_cb, epage);
g_object_unref (source);
}
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index d6f9d93ffc..a93068cb14 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -85,7 +85,7 @@ struct _MemoPagePrivate {
ENameSelector *name_selector;
- GCancellable *open_cancellable;
+ GCancellable *connect_cancellable;
};
static void set_subscriber_info_string (MemoPage *mpage, const gchar *backend_address);
@@ -187,10 +187,10 @@ memo_page_dispose (GObject *object)
priv = MEMO_PAGE_GET_PRIVATE (object);
- if (priv->open_cancellable) {
- g_cancellable_cancel (priv->open_cancellable);
- g_object_unref (priv->open_cancellable);
- priv->open_cancellable = NULL;
+ if (priv->connect_cancellable != NULL) {
+ g_cancellable_cancel (priv->connect_cancellable);
+ g_object_unref (priv->connect_cancellable);
+ priv->connect_cancellable = NULL;
}
g_strfreev (priv->address_strings);
@@ -941,23 +941,27 @@ categories_clicked_cb (GtkWidget *button,
}
static void
-mpage_client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+mpage_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
MemoPage *mpage = user_data;
MemoPagePrivate *priv;
CompEditor *editor;
GError *error = NULL;
- if (!e_client_utils_open_new_finish (source, result, &client, &error)) {
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_clear_error (&error);
- return;
- }
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
+ g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_clear_error (&error);
+ return;
}
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (mpage));
@@ -966,9 +970,13 @@ mpage_client_opened_cb (GObject *source_object,
if (error != NULL) {
GtkWidget *dialog;
ECalClient *old_client;
+ ESource *source;
old_client = comp_editor_get_client (editor);
+ source = e_source_combo_box_ref_active (
+ E_SOURCE_COMBO_BOX (priv->source_combo_box));
+
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_combo_box),
e_client_get_source (E_CLIENT (old_client)));
@@ -982,6 +990,8 @@ mpage_client_opened_cb (GObject *source_object,
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+ g_object_unref (source);
+
g_clear_error (&error);
} else {
icaltimezone *zone;
@@ -1025,16 +1035,16 @@ source_changed_cb (ESourceComboBox *source_combo_box,
source = e_source_combo_box_ref_active (source_combo_box);
g_return_if_fail (source != NULL);
- if (priv->open_cancellable) {
- g_cancellable_cancel (priv->open_cancellable);
- g_object_unref (priv->open_cancellable);
+ if (priv->connect_cancellable != NULL) {
+ g_cancellable_cancel (priv->connect_cancellable);
+ g_object_unref (priv->connect_cancellable);
}
- priv->open_cancellable = g_cancellable_new ();
+ priv->connect_cancellable = g_cancellable_new ();
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_MEMOS,
- FALSE, priv->open_cancellable,
- mpage_client_opened_cb, mpage);
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS,
+ priv->connect_cancellable,
+ mpage_client_connect_cb, mpage);
g_object_unref (source);
}
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index b8324331c8..b728b6f873 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -113,7 +113,7 @@ struct _TaskPagePrivate {
ESendOptionsDialog *sod;
- GCancellable *open_cancellable;
+ GCancellable *connect_cancellable;
};
static const gint classification_map[] = {
@@ -399,10 +399,10 @@ task_page_dispose (GObject *object)
priv = TASK_PAGE_GET_PRIVATE (object);
- if (priv->open_cancellable) {
- g_cancellable_cancel (priv->open_cancellable);
- g_object_unref (priv->open_cancellable);
- priv->open_cancellable = NULL;
+ if (priv->connect_cancellable != NULL) {
+ g_cancellable_cancel (priv->connect_cancellable);
+ g_object_unref (priv->connect_cancellable);
+ priv->connect_cancellable = NULL;
}
if (priv->main != NULL) {
@@ -1049,7 +1049,6 @@ task_page_init (TaskPage *tpage)
{
tpage->priv = TASK_PAGE_GET_PRIVATE (tpage);
tpage->priv->deleted_attendees = g_ptr_array_new ();
- tpage->priv->open_cancellable = NULL;
}
void
@@ -1785,23 +1784,27 @@ due_date_changed_cb (TaskPage *tpage)
}
static void
-tpage_client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+tpage_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
TaskPage *tpage = user_data;
TaskPagePrivate *priv;
CompEditor *editor;
GError *error = NULL;
- if (!e_client_utils_open_new_finish (source, result, &client, &error)) {
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_clear_error (&error);
- return;
- }
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
+ g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_clear_error (&error);
+ return;
}
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage));
@@ -1809,9 +1812,13 @@ tpage_client_opened_cb (GObject *source_object,
if (error) {
GtkWidget *dialog;
ECalClient *old_client;
+ ESource *source;
old_client = comp_editor_get_client (editor);
+ source = e_source_combo_box_ref_active (
+ E_SOURCE_COMBO_BOX (priv->source_combo_box));
+
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (priv->source_combo_box),
e_client_get_source (E_CLIENT (old_client)));
@@ -1825,6 +1832,8 @@ tpage_client_opened_cb (GObject *source_object,
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+ g_object_unref (source);
+
g_clear_error (&error);
} else {
icaltimezone *zone;
@@ -1871,16 +1880,16 @@ source_changed_cb (ESourceComboBox *source_combo_box,
source = e_source_combo_box_ref_active (source_combo_box);
g_return_if_fail (source != NULL);
- if (priv->open_cancellable) {
- g_cancellable_cancel (priv->open_cancellable);
- g_object_unref (priv->open_cancellable);
+ if (priv->connect_cancellable != NULL) {
+ g_cancellable_cancel (priv->connect_cancellable);
+ g_object_unref (priv->connect_cancellable);
}
- priv->open_cancellable = g_cancellable_new ();
+ priv->connect_cancellable = g_cancellable_new ();
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_TASKS,
- FALSE, priv->open_cancellable,
- tpage_client_opened_cb, tpage);
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_TASKS,
+ priv->connect_cancellable,
+ tpage_client_connect_cb, tpage);
g_object_unref (source);
}
diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c
index 19eb4335b1..798280f852 100644
--- a/calendar/gui/e-calendar-selector.c
+++ b/calendar/gui/e-calendar-selector.c
@@ -117,29 +117,30 @@ calendar_selector_update_objects (ECalClient *client,
}
static void
-client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
icalcomponent *icalcomp = user_data;
GError *error = NULL;
g_return_if_fail (icalcomp != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open client: %s",
G_STRFUNC, error->message);
g_error_free (error);
}
- g_return_if_fail (E_IS_CLIENT (client));
-
calendar_selector_update_objects (E_CAL_CLIENT (client), icalcomp);
g_object_unref (client);
@@ -191,9 +192,9 @@ calendar_selector_data_dropped (ESourceSelector *selector,
icalcomponent_set_uid (icalcomp, uid);
}
- e_client_utils_open_new (
- destination, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL,
- client_opened_cb, icalcomp);
+ e_cal_client_connect (
+ destination, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL,
+ client_connect_cb, icalcomp);
success = TRUE;
diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c
index 366d41e702..74ca1d1b64 100644
--- a/calendar/gui/e-memo-list-selector.c
+++ b/calendar/gui/e-memo-list-selector.c
@@ -118,21 +118,24 @@ memo_list_selector_update_objects (ECalClient *client,
}
static void
-client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
gchar *uid = user_data;
GError *error = NULL;
g_return_if_fail (uid != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open memo list: %s",
G_STRFUNC, error->message);
@@ -140,8 +143,6 @@ client_opened_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
if (!e_client_is_readonly (client))
e_cal_client_remove_object_sync (
E_CAL_CLIENT (client), uid, NULL,
@@ -205,9 +206,9 @@ memo_list_selector_process_data (ESourceSelector *selector,
source = e_source_registry_ref_source (registry, source_uid);
if (source != NULL) {
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL,
- client_opened_cb, g_strdup (old_uid));
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL,
+ client_connect_cb, g_strdup (old_uid));
g_object_unref (source);
}
@@ -225,23 +226,26 @@ struct DropData
};
static void
-client_opened_for_drop_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+client_connect_for_drop_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
struct DropData *dd = user_data;
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
GSList *iter;
GError *error = NULL;
g_return_if_fail (dd != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open memo list: %s",
G_STRFUNC, error->message);
@@ -249,8 +253,6 @@ client_opened_for_drop_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
cal_client = E_CAL_CLIENT (client);
for (iter = dd->list; iter != NULL; iter = iter->next) {
@@ -316,9 +318,9 @@ memo_list_selector_data_dropped (ESourceSelector *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,
- client_opened_for_drop_cb, dd);
+ e_cal_client_connect (
+ destination, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL,
+ client_connect_for_drop_cb, dd);
return TRUE;
}
diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c
index 0989e7436c..151967f7f4 100644
--- a/calendar/gui/e-task-list-selector.c
+++ b/calendar/gui/e-task-list-selector.c
@@ -119,21 +119,24 @@ task_list_selector_update_objects (ECalClient *client,
}
static void
-client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
gchar *uid = user_data;
GError *error = NULL;
g_return_if_fail (uid != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open task list: %s",
G_STRFUNC, error->message);
@@ -141,8 +144,6 @@ client_opened_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
if (!e_client_is_readonly (client))
e_cal_client_remove_object_sync (
E_CAL_CLIENT (client), uid, NULL,
@@ -207,9 +208,9 @@ task_list_selector_process_data (ESourceSelector *selector,
source = e_source_registry_ref_source (registry, source_uid);
if (source != NULL) {
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_MEMOS, TRUE, NULL,
- client_opened_cb, g_strdup (old_uid));
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL,
+ client_connect_cb, g_strdup (old_uid));
g_object_unref (source);
}
@@ -227,23 +228,26 @@ struct DropData
};
static void
-client_opened_for_drop_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+client_connect_for_drop_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
struct DropData *dd = user_data;
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
GSList *iter;
GError *error = NULL;
g_return_if_fail (dd != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open task list: %s",
G_STRFUNC, error->message);
@@ -251,8 +255,6 @@ client_opened_for_drop_cb (GObject *source_object,
goto exit;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
cal_client = E_CAL_CLIENT (client);
for (iter = dd->list; iter != NULL; iter = iter->next) {
@@ -318,9 +320,9 @@ task_list_selector_data_dropped (ESourceSelector *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,
- client_opened_for_drop_cb, dd);
+ e_cal_client_connect (
+ destination, E_CAL_CLIENT_SOURCE_TYPE_TASKS, NULL,
+ client_connect_for_drop_cb, dd);
return TRUE;
}
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index 891dc7b226..96c10bd6ab 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -53,7 +53,7 @@ typedef struct {
guint idle_id;
ECalClient *cal_client;
- EClientSourceType source_type;
+ ECalClientSourceType source_type;
icalcomponent *icalcomp;
@@ -69,8 +69,8 @@ typedef struct {
} ICalIntelligentImporter;
static const gint import_type_map[] = {
- E_CLIENT_SOURCE_TYPE_EVENTS,
- E_CLIENT_SOURCE_TYPE_TASKS,
+ E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
+ E_CAL_CLIENT_SOURCE_TYPE_TASKS,
-1
};
@@ -316,10 +316,10 @@ ivcal_getwidget (EImport *ei,
GList *list;
switch (import_type_map[i]) {
- case E_CLIENT_SOURCE_TYPE_EVENTS:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
extension_name = E_SOURCE_EXTENSION_CALENDAR;
break;
- case E_CLIENT_SOURCE_TYPE_TASKS:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
extension_name = E_SOURCE_EXTENSION_TASK_LIST;
break;
default:
@@ -389,11 +389,11 @@ ivcal_import_items (gpointer d)
ICalImporter *ici = d;
switch (ici->source_type) {
- case E_CLIENT_SOURCE_TYPE_EVENTS:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
prepare_events (ici->icalcomp, NULL);
update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici);
break;
- case E_CLIENT_SOURCE_TYPE_TASKS:
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
prepare_tasks (ici->icalcomp, NULL);
update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici);
break;
@@ -411,21 +411,24 @@ ivcal_import_items (gpointer d)
}
static void
-ivcal_opened (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+ivcal_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
ICalImporter *ici = user_data;
GError *error = NULL;
g_return_if_fail (ici != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open calendar: %s",
G_STRFUNC, error->message);
@@ -434,8 +437,6 @@ ivcal_opened (GObject *source_object,
return;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
ici->cal_client = E_CAL_CLIENT (client);
e_import_status (ici->import, ici->target, _("Importing..."), 0);
@@ -447,7 +448,7 @@ ivcal_import (EImport *ei,
EImportTarget *target,
icalcomponent *icalcomp)
{
- EClientSourceType type;
+ ECalClientSourceType type;
ICalImporter *ici = g_malloc0 (sizeof (*ici));
type = GPOINTER_TO_INT (g_datalist_get_data (&target->data, "primary-type"));
@@ -462,9 +463,9 @@ ivcal_import (EImport *ei,
ici->cancellable = g_cancellable_new ();
e_import_status (ei, target, _("Opening calendar"), 0);
- e_client_utils_open_new (
+ e_cal_client_connect (
g_datalist_get_data (&target->data, "primary-source"),
- type, FALSE, ici->cancellable, ivcal_opened, ici);
+ type, ici->cancellable, ivcal_connect_cb, ici);
}
static void
@@ -833,12 +834,11 @@ struct OpenDefaultSourceData
};
static void
-default_source_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+default_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EClient *client = NULL;
+ EClient *client;
struct OpenDefaultSourceData *odsd = user_data;
GError *error = NULL;
@@ -846,7 +846,12 @@ default_source_opened_cb (GObject *source_object,
g_return_if_fail (odsd->ici != NULL);
g_return_if_fail (odsd->opened_cb != NULL);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* Client may be NULL; don't use a type cast macro. */
odsd->opened_cb ((ECalClient *) client, error, odsd->ici);
@@ -869,7 +874,6 @@ open_default_source (ICalIntelligentImporter *ici,
EShell *shell;
ESource *source;
ESourceRegistry *registry;
- EClientSourceType client_source_type;
struct OpenDefaultSourceData *odsd;
g_return_if_fail (ici != NULL);
@@ -880,15 +884,12 @@ open_default_source (ICalIntelligentImporter *ici,
switch (source_type) {
case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- client_source_type = E_CLIENT_SOURCE_TYPE_EVENTS;
source = e_source_registry_ref_default_calendar (registry);
break;
case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- client_source_type = E_CLIENT_SOURCE_TYPE_TASKS;
source = e_source_registry_ref_default_task_list (registry);
break;
case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- client_source_type = E_CLIENT_SOURCE_TYPE_MEMOS;
source = e_source_registry_ref_default_memo_list (registry);
break;
default:
@@ -901,9 +902,9 @@ open_default_source (ICalIntelligentImporter *ici,
e_import_status (ici->ei, ici->target, _("Opening calendar"), 0);
- e_client_utils_open_new (
- source, client_source_type, FALSE, ici->cancellable,
- default_source_opened_cb, odsd);
+ e_cal_client_connect (
+ source, source_type, ici->cancellable,
+ default_client_connect_cb, odsd);
g_object_unref (source);
}
diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c
index 372b826e51..d16f4a6bfc 100644
--- a/modules/calendar/e-cal-attachment-handler.c
+++ b/modules/calendar/e-cal-attachment-handler.c
@@ -171,16 +171,20 @@ attachment_handler_import_event (GObject *source_object,
{
ESource *source = E_SOURCE (source_object);
EAttachment *attachment = user_data;
- EClient *client = NULL;
- GError *error = NULL;
+ EClient *client;
icalcomponent *component;
icalcomponent *subcomponent;
icalcompiter iter;
+ GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
G_STRFUNC, e_source_get_display_name (source),
@@ -190,8 +194,6 @@ attachment_handler_import_event (GObject *source_object,
return;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
component = attachment_handler_get_component (attachment);
g_return_if_fail (component != NULL);
@@ -227,16 +229,20 @@ attachment_handler_import_todo (GObject *source_object,
{
ESource *source = E_SOURCE (source_object);
EAttachment *attachment = user_data;
- EClient *client = NULL;
- GError *error = NULL;
+ EClient *client;
icalcomponent *component;
icalcomponent *subcomponent;
icalcompiter iter;
+ GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
G_STRFUNC, e_source_get_display_name (source),
@@ -246,8 +252,6 @@ attachment_handler_import_todo (GObject *source_object,
return;
}
- g_return_if_fail (E_IS_CLIENT (client));
-
component = attachment_handler_get_component (attachment);
g_return_if_fail (component != NULL);
@@ -363,14 +367,14 @@ attachment_handler_run_dialog (GtkWindow *parent,
switch (source_type) {
case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, 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_cal_client_connect (
+ source, source_type, NULL,
attachment_handler_import_todo,
g_object_ref (attachment));
break;
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index 476831987a..4d9eee63c4 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -67,18 +67,22 @@ cal_shell_backend_new_event (ESource *source,
CompEditorFlags flags,
gboolean all_day)
{
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
ECalComponent *comp;
EShellSettings *shell_settings;
CompEditor *editor;
GError *error = NULL;
- /* XXX Handle errors better. */
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+ /* XXX Handle errors better. */
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
G_STRFUNC, e_source_get_display_name (source),
@@ -87,8 +91,6 @@ cal_shell_backend_new_event (ESource *source,
return;
}
- g_return_if_fail (E_IS_CAL_CLIENT (client));
-
cal_client = E_CAL_CLIENT (client);
shell_settings = e_shell_get_shell_settings (shell);
@@ -173,7 +175,7 @@ action_event_new_cb (GtkAction *action,
EShellBackend *shell_backend;
ESource *source;
ESourceRegistry *registry;
- EClientSourceType source_type;
+ ECalClientSourceType source_type;
const gchar *action_name;
shell = e_shell_window_get_shell (shell_window);
@@ -216,7 +218,7 @@ action_event_new_cb (GtkAction *action,
/* This callback is used for both appointments and meetings. */
- source_type = E_CLIENT_SOURCE_TYPE_EVENTS;
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
registry = e_shell_get_registry (shell);
source = e_source_registry_ref_default_calendar (registry);
@@ -227,18 +229,18 @@ action_event_new_cb (GtkAction *action,
/* Use a callback function appropriate for the action.
* FIXME Need to obtain a better default time zone. */
if (strcmp (action_name, "event-all-day-new") == 0)
- e_client_utils_open_new (
- source, source_type, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, NULL,
cal_shell_backend_event_all_day_new_cb,
g_object_ref (shell));
else if (strcmp (action_name, "event-meeting-new") == 0)
- e_client_utils_open_new (
- source, source_type, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, NULL,
cal_shell_backend_event_meeting_new_cb,
g_object_ref (shell));
else
- e_client_utils_open_new (
- source, source_type, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, NULL,
cal_shell_backend_event_new_cb,
g_object_ref (shell));
@@ -346,7 +348,7 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
EShellSettings *shell_settings;
CompEditor *editor;
CompEditorFlags flags = 0;
- ECalClient *client;
+ EClient *client;
ECalComponent *comp;
ESource *source;
ESourceRegistry *registry;
@@ -457,18 +459,18 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
goto exit;
}
- client = e_cal_client_new (source, source_type, &error);
+ client = e_cal_client_connect_sync (source, source_type, NULL, &error);
- if (client != NULL)
- e_client_open_sync (E_CLIENT (client), TRUE, NULL, &error);
+ /* Sanity check. */
+ g_return_val_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)), FALSE);
if (error != NULL) {
g_warning (
"%s: Failed to create/open client '%s': %s",
G_STRFUNC, e_source_get_display_name (source),
error->message);
- if (client != NULL)
- g_object_unref (client);
g_object_unref (source);
g_error_free (error);
goto exit;
@@ -486,7 +488,8 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
goto present;
e_cal_client_get_object_sync (
- client, comp_uid, comp_rid, &icalcomp, NULL, &error);
+ E_CAL_CLIENT (client),comp_uid,
+ comp_rid, &icalcomp, NULL, &error);
if (error != NULL) {
g_warning (
@@ -509,16 +512,16 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
if (icalprop != NULL)
flags |= COMP_EDITOR_MEETING;
- if (itip_organizer_is_user (registry, comp, client))
+ if (itip_organizer_is_user (registry, comp, E_CAL_CLIENT (client)))
flags |= COMP_EDITOR_USER_ORG;
- if (itip_sentby_is_user (registry, comp, client))
+ if (itip_sentby_is_user (registry, comp, E_CAL_CLIENT (client)))
flags |= COMP_EDITOR_USER_ORG;
if (!e_cal_component_has_attendees (comp))
flags |= COMP_EDITOR_USER_ORG;
- editor = event_editor_new (client, shell, flags);
+ editor = event_editor_new (E_CAL_CLIENT (client), shell, flags);
comp_editor_edit_comp (editor, comp);
g_object_unref (comp);
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index 5f736b088c..aafae792e1 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -39,6 +39,8 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarPrivate))
+typedef struct _ConnectClosure ConnectClosure;
+
struct _ECalShellSidebarPrivate {
GtkWidget *paned;
GtkWidget *selector;
@@ -55,14 +57,23 @@ 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. */
- ECalClient *default_client;
+ EClient *default_client;
- ESource *loading_default_source_instance; /* not-reffed, only for comparison */
+ /* Not referenced, only for pointer comparison. */
+ ESource *connecting_default_source_instance;
- GCancellable *loading_default_client;
+ GCancellable *connecting_default_client;
GCancellable *loading_clients;
};
+struct _ConnectClosure {
+ ECalShellSidebar *cal_shell_sidebar;
+
+ /* For error messages. */
+ gchar *source_display_name;
+ gchar *parent_display_name;
+};
+
enum {
PROP_0,
PROP_DATE_NAVIGATOR,
@@ -84,9 +95,45 @@ G_DEFINE_DYNAMIC_TYPE (
e_cal_shell_sidebar,
E_TYPE_SHELL_SIDEBAR)
+static ConnectClosure *
+connect_closure_new (ECalShellSidebar *cal_shell_sidebar,
+ ESource *source)
+{
+ ConnectClosure *closure;
+ ESourceRegistry *registry;
+ ESourceSelector *selector;
+ ESource *parent;
+ const gchar *parent_uid;
+
+ selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
+ registry = e_source_selector_get_registry (selector);
+ parent_uid = e_source_get_parent (source);
+ parent = e_source_registry_ref_source (registry, parent_uid);
+
+ closure = g_slice_new0 (ConnectClosure);
+ closure->cal_shell_sidebar = g_object_ref (cal_shell_sidebar);
+ closure->source_display_name = e_source_dup_display_name (source);
+ closure->parent_display_name = e_source_dup_display_name (parent);
+
+ g_object_unref (parent);
+
+ return closure;
+}
+
+static void
+connect_closure_free (ConnectClosure *closure)
+{
+ g_object_unref (closure->cal_shell_sidebar);
+
+ g_free (closure->source_display_name);
+ g_free (closure->parent_display_name);
+
+ g_slice_free (ConnectClosure, closure);
+}
+
static void
cal_shell_sidebar_emit_client_added (ECalShellSidebar *cal_shell_sidebar,
- ECalClient *client)
+ EClient *client)
{
guint signal_id = signals[CLIENT_ADDED];
@@ -188,170 +235,170 @@ cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar,
}
static void
-cal_shell_sidebar_retrieve_capabilies_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+cal_shell_sidebar_handle_connect_error (ECalShellSidebar *cal_shell_sidebar,
+ const gchar *parent_display_name,
+ const gchar *source_display_name,
+ const GError *error)
{
- ECalClient *client = E_CAL_CLIENT (source_object);
- ECalShellSidebar *cal_shell_sidebar = user_data;
- gchar *capabilities = NULL;
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
+ gboolean cancelled = FALSE;
+ gboolean offline_error;
- g_return_if_fail (client != NULL);
- g_return_if_fail (cal_shell_sidebar != 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);
- e_client_retrieve_capabilities_finish (
- E_CLIENT (client), result, &capabilities, NULL);
- g_free (capabilities);
+ cancelled |= g_error_matches (
+ error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
+ cancelled |= g_error_matches (
+ error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED);
- cal_shell_sidebar_emit_status_message (
- cal_shell_sidebar, _("Loading calendars"));
- cal_shell_sidebar_emit_client_added (cal_shell_sidebar, client);
- cal_shell_sidebar_emit_status_message (cal_shell_sidebar, NULL);
+ offline_error = g_error_matches (
+ error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE);
+
+ if (cancelled) {
+ /* do nothing */
+ } else if (offline_error) {
+ e_alert_submit (
+ E_ALERT_SINK (shell_content),
+ "calendar:prompt-no-contents-offline-calendar",
+ parent_display_name,
+ source_display_name,
+ NULL);
+ } else {
+ e_alert_submit (
+ E_ALERT_SINK (shell_content),
+ "calendar:failed-open-calendar",
+ parent_display_name,
+ source_display_name,
+ error->message,
+ NULL);
+ }
}
static void
-cal_shell_sidebar_client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+cal_shell_sidebar_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ECalClient *client = E_CAL_CLIENT (source_object);
- ECalShellSidebar *cal_shell_sidebar = user_data;
- ESource *source, *parent;
- EShellView *shell_view;
+ EClient *client;
+ ConnectClosure *closure = user_data;
+ ECalShellContent *cal_shell_content;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- ESourceRegistry *registry;
+ EShellView *shell_view;
+ ECalModel *model;
+ icaltimezone *timezone;
GError *error = NULL;
- source = e_client_get_source (E_CLIENT (client));
+ client = e_cal_client_connect_finish (result, &error);
- e_client_open_finish (E_CLIENT (client), result, &error);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_clear_error (&error);
- return;
+ if (error != NULL) {
+ cal_shell_sidebar_handle_connect_error (
+ closure->cal_shell_sidebar,
+ closure->parent_display_name,
+ closure->source_display_name,
+ error);
+ g_error_free (error);
+ goto exit;
}
- shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar);
+ /* FIXME Sidebar should not be accessing the EShellContent.
+ * This probably needs to be moved to ECalShellView. */
+ shell_sidebar = E_SHELL_SIDEBAR (closure->cal_shell_sidebar);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_content = e_shell_view_get_shell_content (shell_view);
- registry = e_shell_get_registry (e_shell_backend_get_shell (e_shell_view_get_shell_backend (shell_view)));
- parent = e_source_registry_ref_source (registry, e_source_get_parent (source));
-
- /* Handle errors. */
- switch ((error && error->domain == E_CLIENT_ERROR) ? error->code : -1) {
- case -1:
- break;
-
- case E_CLIENT_ERROR_REPOSITORY_OFFLINE:
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:prompt-no-contents-offline-calendar",
- e_source_get_display_name (parent),
- e_source_get_display_name (source), NULL);
- /* fall through */
-
- default:
- if (error->code != E_CLIENT_ERROR_REPOSITORY_OFFLINE) {
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:failed-open-calendar",
- e_source_get_display_name (parent),
- e_source_get_display_name (source),
- error->message, NULL);
- }
-
- e_cal_shell_sidebar_remove_source (
- cal_shell_sidebar,
- e_client_get_source (E_CLIENT (client)));
- g_clear_error (&error);
- g_object_unref (parent);
- return;
- }
- g_clear_error (&error);
- g_object_unref (parent);
+ 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);
- /* to have them ready for later use */
- e_client_retrieve_capabilities (
- E_CLIENT (client), NULL,
- cal_shell_sidebar_retrieve_capabilies_cb,
- cal_shell_sidebar);
+ e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone);
+
+ e_cal_shell_sidebar_add_client (closure->cal_shell_sidebar, client);
+
+ g_object_unref (client);
+
+exit:
+ connect_closure_free (closure);
}
static void
-cal_shell_sidebar_default_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+cal_shell_sidebar_default_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EShellSidebar *shell_sidebar = user_data;
+ EClient *client;
+ ESource *source;
+ ConnectClosure *closure = user_data;
ECalShellSidebarPrivate *priv;
EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
EShellView *shell_view;
ECalShellContent *cal_shell_content;
ECalModel *model;
- EClient *client = NULL;
+ icaltimezone *timezone;
GError *error = NULL;
- priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
+ priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (closure->cal_shell_sidebar);
- 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_cal_client_connect_finish (result, &error);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
- if (priv->loading_default_client) {
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client != NULL) {
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
- if (source == priv->loading_default_source_instance)
- priv->loading_default_source_instance = NULL;
-
- /* Ignore cancellations. */
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
+ if (error != NULL) {
+ cal_shell_sidebar_handle_connect_error (
+ closure->cal_shell_sidebar,
+ closure->parent_display_name,
+ closure->source_display_name,
+ error);
g_error_free (error);
goto exit;
-
- } else if (error != NULL) {
- ESourceRegistry *registry;
- ESource *parent;
-
- registry = e_shell_get_registry (e_shell_backend_get_shell (e_shell_view_get_shell_backend (shell_view)));
- parent = e_source_registry_ref_source (registry, e_source_get_parent (source));
-
- g_warn_if_fail (client == NULL);
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:failed-open-calendar",
- e_source_get_display_name (parent),
- e_source_get_display_name (source),
- error->message, NULL);
- g_error_free (error);
- g_object_unref (parent);
- goto exit;
}
- g_return_if_fail (E_IS_CAL_CLIENT (client));
+ source = e_client_get_source (client);
+
+ if (source == priv->connecting_default_source_instance)
+ priv->connecting_default_source_instance = NULL;
if (priv->default_client != NULL)
g_object_unref (priv->default_client);
- priv->default_client = E_CAL_CLIENT (client);
+ priv->default_client = g_object_ref (client);
- e_cal_client_set_default_timezone (
- priv->default_client, e_cal_model_get_timezone (model));
+ /* FIXME Sidebar should not be accessing the EShellContent.
+ * This probably needs to be moved to ECalShellView. */
+ shell_sidebar = E_SHELL_SIDEBAR (closure->cal_shell_sidebar);
+ 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);
+ timezone = e_cal_model_get_timezone (model);
+
+ e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone);
g_object_notify (G_OBJECT (shell_sidebar), "default-client");
- exit:
- g_object_unref (shell_sidebar);
+ g_object_unref (client);
+
+exit:
+ connect_closure_free (closure);
}
static void
@@ -366,7 +413,7 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar,
priv = cal_shell_sidebar->priv;
/* already loading that source as default source */
- if (source == priv->loading_default_source_instance)
+ if (source == priv->connecting_default_source_instance)
return;
/* FIXME Sidebar should not be accessing the EShellContent.
@@ -374,10 +421,10 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar,
shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar);
/* Cancel any unfinished previous request. */
- if (priv->loading_default_client != NULL) {
- g_cancellable_cancel (priv->loading_default_client);
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client != NULL) {
+ g_cancellable_cancel (priv->connecting_default_client);
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
uid = e_source_get_uid (source);
@@ -394,14 +441,14 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar,
}
/* it's only for pointer comparison, no need to ref it */
- priv->loading_default_source_instance = source;
- priv->loading_default_client = g_cancellable_new ();
-
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_EVENTS,
- FALSE, priv->loading_default_client,
- cal_shell_sidebar_default_loaded_cb,
- g_object_ref (shell_sidebar));
+ priv->connecting_default_source_instance = source;
+ priv->connecting_default_client = g_cancellable_new ();
+
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
+ priv->connecting_default_client,
+ cal_shell_sidebar_default_connect_cb,
+ connect_closure_new (cal_shell_sidebar, source));
}
static void
@@ -569,10 +616,10 @@ cal_shell_sidebar_dispose (GObject *object)
priv->default_client = NULL;
}
- if (priv->loading_default_client != NULL) {
- g_cancellable_cancel (priv->loading_default_client);
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client != NULL) {
+ g_cancellable_cancel (priv->connecting_default_client);
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
if (priv->loading_clients != NULL) {
@@ -946,7 +993,7 @@ e_cal_shell_sidebar_get_default_client (ECalShellSidebar *cal_shell_sidebar)
g_return_val_if_fail (
E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar), NULL);
- return cal_shell_sidebar->priv->default_client;
+ return (ECalClient *) cal_shell_sidebar->priv->default_client;
}
GtkWidget *
@@ -968,20 +1015,56 @@ e_cal_shell_sidebar_get_selector (ECalShellSidebar *cal_shell_sidebar)
}
void
+e_cal_shell_sidebar_add_client (ECalShellSidebar *cal_shell_sidebar,
+ EClient *client)
+{
+ ESource *source;
+ ESourceSelector *selector;
+ GHashTable *client_table;
+ const gchar *message;
+ const gchar *uid;
+
+ g_return_if_fail (E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
+
+ client_table = cal_shell_sidebar->priv->client_table;
+
+ source = e_client_get_source (client);
+ uid = e_source_get_uid (source);
+
+ if (g_hash_table_contains (client_table, uid))
+ return;
+
+ g_hash_table_insert (
+ client_table, g_strdup (uid), g_object_ref (client));
+
+ g_signal_connect_swapped (
+ client, "backend-died",
+ G_CALLBACK (cal_shell_sidebar_backend_died_cb),
+ cal_shell_sidebar);
+
+ g_signal_connect_swapped (
+ client, "backend-error",
+ G_CALLBACK (cal_shell_sidebar_backend_error_cb),
+ cal_shell_sidebar);
+
+ selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
+ e_source_selector_select_source (selector, source);
+
+ message = _("Loading calendars");
+ cal_shell_sidebar_emit_status_message (cal_shell_sidebar, message);
+ cal_shell_sidebar_emit_client_added (cal_shell_sidebar, client);
+ cal_shell_sidebar_emit_status_message (cal_shell_sidebar, NULL);
+}
+
+void
e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
ESource *source)
{
- EShellView *shell_view;
- EShellContent *shell_content;
- EShellSidebar *shell_sidebar;
- ECalShellContent *cal_shell_content;
ECalClientSourceType source_type;
ESourceSelector *selector;
GHashTable *client_table;
- ECalModel *model;
- ECalClient *default_client;
- ECalClient *client;
- icaltimezone *timezone;
+ EClient *default_client;
const gchar *display_name;
const gchar *uid;
gchar *message;
@@ -995,38 +1078,22 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
uid = e_source_get_uid (source);
- client = g_hash_table_lookup (client_table, uid);
- if (client != NULL)
+ if (g_hash_table_contains (client_table, uid))
return;
if (default_client != NULL) {
ESource *default_source;
- const gchar *default_uid;
- default_source = e_client_get_source (E_CLIENT (default_client));
- default_uid = e_source_get_uid (default_source);
+ default_source = e_client_get_source (default_client);
- if (g_strcmp0 (uid, default_uid) == 0)
- client = g_object_ref (default_client);
+ if (e_source_equal (source, default_source)) {
+ e_cal_shell_sidebar_add_client (
+ cal_shell_sidebar, default_client);
+ return;
+ }
}
- if (client == NULL)
- client = e_cal_client_new (source, source_type, NULL);
-
- g_return_if_fail (client != NULL);
-
- g_signal_connect_swapped (
- client, "backend-died",
- G_CALLBACK (cal_shell_sidebar_backend_died_cb),
- cal_shell_sidebar);
-
- g_signal_connect_swapped (
- client, "backend-error",
- G_CALLBACK (cal_shell_sidebar_backend_error_cb),
- cal_shell_sidebar);
-
- g_hash_table_insert (client_table, g_strdup (uid), client);
e_source_selector_select_source (selector, source);
display_name = e_source_get_display_name (source);
@@ -1034,22 +1101,11 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
cal_shell_sidebar_emit_status_message (cal_shell_sidebar, message);
g_free (message);
- /* 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);
-
- 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);
-
- e_cal_client_set_default_timezone (client, timezone);
-
- e_client_open (
- E_CLIENT (client), FALSE,
+ e_cal_client_connect (
+ source, source_type,
cal_shell_sidebar->priv->loading_clients,
- cal_shell_sidebar_client_opened_cb, cal_shell_sidebar);
+ cal_shell_sidebar_client_connect_cb,
+ connect_closure_new (cal_shell_sidebar, source));
}
void
diff --git a/modules/calendar/e-cal-shell-sidebar.h b/modules/calendar/e-cal-shell-sidebar.h
index 6daabe25ca..6296b44b6a 100644
--- a/modules/calendar/e-cal-shell-sidebar.h
+++ b/modules/calendar/e-cal-shell-sidebar.h
@@ -96,6 +96,9 @@ GtkWidget * e_cal_shell_sidebar_get_new_calendar_button
ESourceSelector *
e_cal_shell_sidebar_get_selector
(ECalShellSidebar *cal_shell_sidebar);
+void e_cal_shell_sidebar_add_client
+ (ECalShellSidebar *cal_shell_sidebar,
+ EClient *client);
void e_cal_shell_sidebar_add_source
(ECalShellSidebar *cal_shell_sidebar,
ESource *source);
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index 8c66a68ed7..f9fdf1caf1 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -538,7 +538,7 @@ action_event_copy_cb (GtkAction *action,
ESource *source_source = NULL;
ESource *destination_source = NULL;
ESourceRegistry *registry;
- ECalClient *destination_client = NULL;
+ EClient *destination_client = NULL;
GList *selected, *iter;
GError *error = NULL;
@@ -571,12 +571,10 @@ action_event_copy_cb (GtkAction *action,
return;
/* Open the destination calendar. */
- destination_client = e_cal_client_new (
- destination_source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL);
- if (destination_client == NULL)
- goto exit;
-
- e_client_open_sync (E_CLIENT (destination_client), FALSE, NULL, &error);
+ destination_client = e_cal_client_connect_sync (
+ destination_source,
+ E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
+ NULL, &error);
if (error != NULL) {
g_warning (
@@ -594,7 +592,8 @@ action_event_copy_cb (GtkAction *action,
gboolean remove = FALSE;
e_cal_shell_view_transfer_item_to (
- cal_shell_view, event, destination_client, remove);
+ cal_shell_view, event,
+ E_CAL_CLIENT (destination_client), remove);
}
e_cal_shell_view_set_status_message (cal_shell_view, NULL, -1.0);
@@ -832,7 +831,7 @@ action_event_move_cb (GtkAction *action,
ESource *source_source = NULL;
ESource *destination_source = NULL;
ESourceRegistry *registry;
- ECalClient *destination_client = NULL;
+ EClient *destination_client = NULL;
GList *selected, *iter;
GError *error = NULL;
@@ -865,12 +864,10 @@ action_event_move_cb (GtkAction *action,
return;
/* Open the destination calendar. */
- destination_client = e_cal_client_new (
- destination_source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL);
- if (destination_client == NULL)
- goto exit;
-
- e_client_open_sync (E_CLIENT (destination_client), FALSE, NULL, &error);
+ destination_client = e_cal_client_connect_sync (
+ destination_source,
+ E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
+ NULL, &error);
if (error != NULL) {
g_warning (
@@ -888,7 +885,8 @@ action_event_move_cb (GtkAction *action,
gboolean remove = TRUE;
e_cal_shell_view_transfer_item_to (
- cal_shell_view, event, destination_client, remove);
+ cal_shell_view, event,
+ E_CAL_CLIENT (destination_client), remove);
}
e_cal_shell_view_set_status_message (cal_shell_view, NULL, -1.0);
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index 75fabd6d83..6f3d481d95 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -62,17 +62,21 @@ memo_shell_backend_new_memo (ESource *source,
EShell *shell,
CompEditorFlags flags)
{
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
ECalComponent *comp;
CompEditor *editor;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* XXX Handle errors better. */
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
G_STRFUNC, e_source_get_display_name (source),
@@ -81,8 +85,6 @@ memo_shell_backend_new_memo (ESource *source,
return;
}
- 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);
@@ -134,7 +136,7 @@ action_memo_new_cb (GtkAction *action,
EShell *shell;
ESource *source;
ESourceRegistry *registry;
- EClientSourceType source_type;
+ ECalClientSourceType source_type;
const gchar *action_name;
/* This callback is used for both memos and shared memos. */
@@ -142,20 +144,20 @@ action_memo_new_cb (GtkAction *action,
shell = e_shell_window_get_shell (shell_window);
registry = e_shell_get_registry (shell);
- source_type = E_CLIENT_SOURCE_TYPE_MEMOS;
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
source = e_source_registry_ref_default_memo_list (registry);
/* Use a callback function appropriate for the 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_client_utils_open_new (
- source, source_type, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, NULL,
memo_shell_backend_memo_shared_new_cb,
g_object_ref (shell));
else
- e_client_utils_open_new (
- source, source_type, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, NULL,
memo_shell_backend_memo_new_cb,
g_object_ref (shell));
@@ -226,7 +228,7 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
EShell *shell;
CompEditor *editor;
CompEditorFlags flags = 0;
- ECalClient *client;
+ EClient *client;
ECalComponent *comp;
ESource *source;
ESourceRegistry *registry;
@@ -304,17 +306,17 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
goto exit;
}
- client = e_cal_client_new (source, source_type, &error);
+ client = e_cal_client_connect_sync (source, source_type, NULL, &error);
- if (client != NULL)
- e_client_open_sync (E_CLIENT (client), TRUE, NULL, &error);
+ /* Sanity check. */
+ g_return_val_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)), FALSE);
if (error != NULL) {
g_warning (
"%s: Failed to create/open client: %s",
G_STRFUNC, error->message);
- if (client != NULL)
- g_object_unref (client);
g_object_unref (source);
g_error_free (error);
goto exit;
@@ -332,7 +334,8 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
goto present;
e_cal_client_get_object_sync (
- client, comp_uid, comp_rid, &icalcomp, NULL, &error);
+ E_CAL_CLIENT (client), comp_uid,
+ comp_rid, &icalcomp, NULL, &error);
if (error != NULL) {
g_warning (
@@ -353,10 +356,10 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
if (e_cal_component_has_organizer (comp))
flags |= COMP_EDITOR_IS_SHARED;
- if (itip_organizer_is_user (registry, comp, client))
+ if (itip_organizer_is_user (registry, comp, E_CAL_CLIENT (client)))
flags |= COMP_EDITOR_USER_ORG;
- editor = memo_editor_new (client, shell, flags);
+ editor = memo_editor_new (E_CAL_CLIENT (client), shell, flags);
comp_editor_edit_comp (editor, comp);
g_object_unref (comp);
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c
index 5251763944..24e6f841d1 100644
--- a/modules/calendar/e-memo-shell-sidebar.c
+++ b/modules/calendar/e-memo-shell-sidebar.c
@@ -40,6 +40,8 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MEMO_SHELL_SIDEBAR, EMemoShellSidebarPrivate))
+typedef struct _ConnectClosure ConnectClosure;
+
struct _EMemoShellSidebarPrivate {
GtkWidget *selector;
@@ -53,14 +55,23 @@ 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. */
- ECalClient *default_client;
+ EClient *default_client;
- ESource *loading_default_source_instance; /* not-reffed, only for comparison */
+ /* Not referenced, only for pointer comparison. */
+ ESource *connecting_default_source_instance;
- GCancellable *loading_default_client;
+ GCancellable *connecting_default_client;
GCancellable *loading_clients;
};
+struct _ConnectClosure {
+ EMemoShellSidebar *memo_shell_sidebar;
+
+ /* For error messages. */
+ gchar *source_display_name;
+ gchar *parent_display_name;
+};
+
enum {
PROP_0,
PROP_DEFAULT_CLIENT,
@@ -81,9 +92,45 @@ G_DEFINE_DYNAMIC_TYPE (
e_memo_shell_sidebar,
E_TYPE_SHELL_SIDEBAR)
+static ConnectClosure *
+connect_closure_new (EMemoShellSidebar *memo_shell_sidebar,
+ ESource *source)
+{
+ ConnectClosure *closure;
+ ESourceRegistry *registry;
+ ESourceSelector *selector;
+ ESource *parent;
+ const gchar *parent_uid;
+
+ selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
+ registry = e_source_selector_get_registry (selector);
+ parent_uid = e_source_get_parent (source);
+ parent = e_source_registry_ref_source (registry, parent_uid);
+
+ closure = g_slice_new0 (ConnectClosure);
+ closure->memo_shell_sidebar = g_object_ref (memo_shell_sidebar);
+ closure->source_display_name = e_source_dup_display_name (source);
+ closure->parent_display_name = e_source_dup_display_name (parent);
+
+ g_object_unref (parent);
+
+ return closure;
+}
+
+static void
+connect_closure_free (ConnectClosure *closure)
+{
+ g_object_unref (closure->memo_shell_sidebar);
+
+ g_free (closure->source_display_name);
+ g_free (closure->parent_display_name);
+
+ g_slice_free (ConnectClosure, closure);
+}
+
static void
memo_shell_sidebar_emit_client_added (EMemoShellSidebar *memo_shell_sidebar,
- ECalClient *client)
+ EClient *client)
{
guint signal_id = signals[CLIENT_ADDED];
@@ -185,170 +232,170 @@ memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar,
}
static void
-memo_shell_sidebar_retrieve_capabilies_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+memo_shell_sidebar_handle_connect_error (EMemoShellSidebar *memo_shell_sidebar,
+ const gchar *parent_display_name,
+ const gchar *source_display_name,
+ const GError *error)
{
- ECalClient *client = E_CAL_CLIENT (source_object);
- EMemoShellSidebar *memo_shell_sidebar = user_data;
- gchar *capabilities = NULL;
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
+ gboolean cancelled = FALSE;
+ gboolean offline_error;
- g_return_if_fail (client != NULL);
- g_return_if_fail (memo_shell_sidebar != 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);
- e_client_retrieve_capabilities_finish (
- E_CLIENT (client), result, &capabilities, NULL);
- g_free (capabilities);
+ cancelled |= g_error_matches (
+ error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
+ cancelled |= g_error_matches (
+ error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED);
- memo_shell_sidebar_emit_status_message (
- memo_shell_sidebar, _("Loading memos"));
- memo_shell_sidebar_emit_client_added (memo_shell_sidebar, client);
- memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL);
+ offline_error = g_error_matches (
+ error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE);
+
+ if (cancelled) {
+ /* do nothing */
+ } else if (offline_error) {
+ e_alert_submit (
+ E_ALERT_SINK (shell_content),
+ "calendar:prompt-no-contents-offline-calendar",
+ parent_display_name,
+ source_display_name,
+ NULL);
+ } else {
+ e_alert_submit (
+ E_ALERT_SINK (shell_content),
+ "calendar:failed-open-calendar",
+ parent_display_name,
+ source_display_name,
+ error->message,
+ NULL);
+ }
}
static void
-memo_shell_sidebar_client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+memo_shell_sidebar_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ECalClient *client = E_CAL_CLIENT (source_object);
- EMemoShellSidebar *memo_shell_sidebar = user_data;
- ESource *source, *parent;
- EShellView *shell_view;
+ EClient *client;
+ ConnectClosure *closure = user_data;
+ EMemoShellContent *memo_shell_content;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- ESourceRegistry *registry;
+ EShellView *shell_view;
+ ECalModel *model;
+ icaltimezone *timezone;
GError *error = NULL;
- source = e_client_get_source (E_CLIENT (client));
+ client = e_cal_client_connect_finish (result, &error);
- e_client_open_finish (E_CLIENT (client), result, &error);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_clear_error (&error);
- return;
+ if (error != NULL) {
+ memo_shell_sidebar_handle_connect_error (
+ closure->memo_shell_sidebar,
+ closure->parent_display_name,
+ closure->source_display_name,
+ error);
+ g_error_free (error);
+ goto exit;
}
- shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar);
+ /* FIXME Sidebar should not be accessing the EShellContent.
+ * This probably needs to be moved to EMemoShellView. */
+ shell_sidebar = E_SHELL_SIDEBAR (closure->memo_shell_sidebar);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_content = e_shell_view_get_shell_content (shell_view);
- registry = e_shell_get_registry (e_shell_backend_get_shell (e_shell_view_get_shell_backend (shell_view)));
- parent = e_source_registry_ref_source (registry, e_source_get_parent (source));
-
- /* Handle errors. */
- switch ((error && error->domain == E_CLIENT_ERROR) ? error->code : -1) {
- case -1:
- break;
-
- case E_CLIENT_ERROR_REPOSITORY_OFFLINE:
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:prompt-no-contents-offline-memos",
- e_source_get_display_name (parent),
- e_source_get_display_name (source), NULL);
- /* fall through */
-
- default:
- if (error->code != E_CLIENT_ERROR_REPOSITORY_OFFLINE) {
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:failed-open-memos",
- e_source_get_display_name (parent),
- e_source_get_display_name (source),
- error->message, NULL);
- }
-
- e_memo_shell_sidebar_remove_source (
- memo_shell_sidebar,
- e_client_get_source (E_CLIENT (client)));
- g_clear_error (&error);
- g_object_unref (parent);
- return;
- }
- g_clear_error (&error);
- g_object_unref (parent);
+ 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);
- /* to have them ready for later use */
- e_client_retrieve_capabilities (
- E_CLIENT (client), NULL,
- memo_shell_sidebar_retrieve_capabilies_cb,
- memo_shell_sidebar);
+ e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone);
+
+ e_memo_shell_sidebar_add_client (closure->memo_shell_sidebar, client);
+
+ g_object_unref (client);
+
+exit:
+ connect_closure_free (closure);
}
static void
-memo_shell_sidebar_default_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+memo_shell_sidebar_default_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EShellSidebar *shell_sidebar = user_data;
+ EClient *client;
+ ESource *source;
+ ConnectClosure *closure = user_data;
EMemoShellSidebarPrivate *priv;
EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
EShellView *shell_view;
EMemoShellContent *memo_shell_content;
ECalModel *model;
- EClient *client = NULL;
+ icaltimezone *timezone;
GError *error = NULL;
- priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
+ priv = E_MEMO_SHELL_SIDEBAR_GET_PRIVATE (closure->memo_shell_sidebar);
- 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_cal_client_connect_finish (result, &error);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
- if (priv->loading_default_client) {
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client) {
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
- if (source == priv->loading_default_source_instance)
- priv->loading_default_source_instance = NULL;
-
- /* Ignore cancellations. */
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
+ if (error != NULL) {
+ memo_shell_sidebar_handle_connect_error (
+ closure->memo_shell_sidebar,
+ closure->parent_display_name,
+ closure->source_display_name,
+ error);
g_error_free (error);
goto exit;
-
- } else if (error != NULL) {
- ESourceRegistry *registry;
- ESource *parent;
-
- registry = e_shell_get_registry (e_shell_backend_get_shell (e_shell_view_get_shell_backend (shell_view)));
- parent = e_source_registry_ref_source (registry, e_source_get_parent (source));
-
- g_warn_if_fail (client == NULL);
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:failed-open-memos",
- e_source_get_display_name (parent),
- e_source_get_display_name (source),
- error->message, NULL);
- g_error_free (error);
- g_object_unref (parent);
- goto exit;
}
- g_return_if_fail (E_IS_CAL_CLIENT (client));
+ source = e_client_get_source (client);
+
+ if (source == priv->connecting_default_source_instance)
+ priv->connecting_default_source_instance = NULL;
if (priv->default_client != NULL)
g_object_unref (priv->default_client);
- priv->default_client = E_CAL_CLIENT (client);
+ priv->default_client = g_object_ref (client);
- e_cal_client_set_default_timezone (
- priv->default_client, e_cal_model_get_timezone (model));
+ /* FIXME Sidebar should not be accessing the EShellContent.
+ * This probably needs to be moved to EMemoShellView. */
+ shell_sidebar = E_SHELL_SIDEBAR (closure->memo_shell_sidebar);
+ 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);
+ timezone = e_cal_model_get_timezone (model);
+
+ e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone);
g_object_notify (G_OBJECT (shell_sidebar), "default-client");
- exit:
- g_object_unref (shell_sidebar);
+ g_object_unref (client);
+
+exit:
+ connect_closure_free (closure);
}
static void
@@ -363,7 +410,7 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar,
priv = memo_shell_sidebar->priv;
/* already loading that source as default source */
- if (source == priv->loading_default_source_instance)
+ if (source == priv->connecting_default_source_instance)
return;
/* FIXME Sidebar should not be accessing the EShellContent.
@@ -371,10 +418,10 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar,
shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar);
/* Cancel any unfinished previous request. */
- if (priv->loading_default_client != NULL) {
- g_cancellable_cancel (priv->loading_default_client);
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client != NULL) {
+ g_cancellable_cancel (priv->connecting_default_client);
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
uid = e_source_get_uid (source);
@@ -391,14 +438,14 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar,
}
/* it's only for pointer comparison, no need to ref it */
- priv->loading_default_source_instance = source;
- priv->loading_default_client = g_cancellable_new ();
-
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_MEMOS,
- FALSE, priv->loading_default_client,
- memo_shell_sidebar_default_loaded_cb,
- g_object_ref (shell_sidebar));
+ priv->connecting_default_source_instance = source;
+ priv->connecting_default_client = g_cancellable_new ();
+
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_MEMOS,
+ priv->connecting_default_client,
+ memo_shell_sidebar_default_connect_cb,
+ connect_closure_new (memo_shell_sidebar, source));
}
static void
@@ -533,10 +580,10 @@ memo_shell_sidebar_dispose (GObject *object)
priv->default_client = NULL;
}
- if (priv->loading_default_client != NULL) {
- g_cancellable_cancel (priv->loading_default_client);
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client != NULL) {
+ g_cancellable_cancel (priv->connecting_default_client);
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
if (priv->loading_clients != NULL) {
@@ -842,7 +889,7 @@ e_memo_shell_sidebar_get_default_client (EMemoShellSidebar *memo_shell_sidebar)
g_return_val_if_fail (
E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar), NULL);
- return memo_shell_sidebar->priv->default_client;
+ return (ECalClient *) memo_shell_sidebar->priv->default_client;
}
ESourceSelector *
@@ -855,20 +902,56 @@ e_memo_shell_sidebar_get_selector (EMemoShellSidebar *memo_shell_sidebar)
}
void
+e_memo_shell_sidebar_add_client (EMemoShellSidebar *memo_shell_sidebar,
+ EClient *client)
+{
+ ESource *source;
+ ESourceSelector *selector;
+ GHashTable *client_table;
+ const gchar *message;
+ const gchar *uid;
+
+ g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
+
+ client_table = memo_shell_sidebar->priv->client_table;
+
+ source = e_client_get_source (client);
+ uid = e_source_get_uid (source);
+
+ if (g_hash_table_contains (client_table, uid))
+ return;
+
+ g_hash_table_insert (
+ client_table, g_strdup (uid), g_object_ref (client));
+
+ g_signal_connect_swapped (
+ client, "backend-died",
+ G_CALLBACK (memo_shell_sidebar_backend_died_cb),
+ memo_shell_sidebar);
+
+ g_signal_connect_swapped (
+ client, "backend-error",
+ G_CALLBACK (memo_shell_sidebar_backend_error_cb),
+ memo_shell_sidebar);
+
+ selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
+ e_source_selector_select_source (selector, source);
+
+ message = _("Loading memo list");
+ memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message);
+ memo_shell_sidebar_emit_client_added (memo_shell_sidebar, client);
+ memo_shell_sidebar_emit_status_message (memo_shell_sidebar, NULL);
+}
+
+void
e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
ESource *source)
{
- EShellView *shell_view;
- EShellContent *shell_content;
- EShellSidebar *shell_sidebar;
- EMemoShellContent *memo_shell_content;
ECalClientSourceType source_type;
ESourceSelector *selector;
GHashTable *client_table;
- ECalModel *model;
- ECalClient *default_client;
- ECalClient *client;
- icaltimezone *timezone;
+ EClient *default_client;
const gchar *display_name;
const gchar *uid;
gchar *message;
@@ -882,38 +965,22 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
uid = e_source_get_uid (source);
- client = g_hash_table_lookup (client_table, uid);
- if (client != NULL)
+ if (g_hash_table_contains (client_table, uid))
return;
if (default_client != NULL) {
ESource *default_source;
- const gchar *default_uid;
- default_source = e_client_get_source (E_CLIENT (default_client));
- default_uid = e_source_get_uid (default_source);
+ default_source = e_client_get_source (default_client);
- if (g_strcmp0 (uid, default_uid) == 0)
- client = g_object_ref (default_client);
+ if (e_source_equal (source, default_source)) {
+ e_memo_shell_sidebar_add_client (
+ memo_shell_sidebar, default_client);
+ return;
+ }
}
- if (client == NULL)
- client = e_cal_client_new (source, source_type, NULL);
-
- g_return_if_fail (client != NULL);
-
- g_signal_connect_swapped (
- client, "backend-died",
- G_CALLBACK (memo_shell_sidebar_backend_died_cb),
- memo_shell_sidebar);
-
- g_signal_connect_swapped (
- client, "backend-error",
- G_CALLBACK (memo_shell_sidebar_backend_error_cb),
- memo_shell_sidebar);
-
- g_hash_table_insert (client_table, g_strdup (uid), client);
e_source_selector_select_source (selector, source);
display_name = e_source_get_display_name (source);
@@ -921,22 +988,11 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message);
g_free (message);
- /* 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);
-
- 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);
-
- e_cal_client_set_default_timezone (client, timezone);
-
- e_client_open (
- E_CLIENT (client), FALSE,
+ e_cal_client_connect (
+ source, source_type,
memo_shell_sidebar->priv->loading_clients,
- memo_shell_sidebar_client_opened_cb, memo_shell_sidebar);
+ memo_shell_sidebar_client_connect_cb,
+ connect_closure_new (memo_shell_sidebar, source));
}
void
diff --git a/modules/calendar/e-memo-shell-sidebar.h b/modules/calendar/e-memo-shell-sidebar.h
index 17814ebaea..31fc25c649 100644
--- a/modules/calendar/e-memo-shell-sidebar.h
+++ b/modules/calendar/e-memo-shell-sidebar.h
@@ -94,6 +94,9 @@ ECalClient * e_memo_shell_sidebar_get_default_client
ESourceSelector *
e_memo_shell_sidebar_get_selector
(EMemoShellSidebar *memo_shell_sidebar);
+void e_memo_shell_sidebar_add_client
+ (EMemoShellSidebar *memo_shell_sidebar,
+ EClient *client);
void e_memo_shell_sidebar_add_source
(EMemoShellSidebar *memo_shell_sidebar,
ESource *source);
diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c
index 90ffb3cc6e..831e35de18 100644
--- a/modules/calendar/e-task-shell-backend.c
+++ b/modules/calendar/e-task-shell-backend.c
@@ -60,17 +60,21 @@ task_shell_backend_new_task (ESource *source,
EShell *shell,
CompEditorFlags flags)
{
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
ECalComponent *comp;
CompEditor *editor;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* XXX Handle errors better. */
if (error != NULL) {
- g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
G_STRFUNC, e_source_get_display_name (source),
@@ -79,8 +83,6 @@ task_shell_backend_new_task (ESource *source,
return;
}
- 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);
@@ -131,7 +133,7 @@ action_task_new_cb (GtkAction *action,
EShell *shell;
ESource *source;
ESourceRegistry *registry;
- EClientSourceType source_type;
+ ECalClientSourceType source_type;
const gchar *action_name;
/* This callback is used for both tasks and assigned tasks. */
@@ -139,20 +141,20 @@ action_task_new_cb (GtkAction *action,
shell = e_shell_window_get_shell (shell_window);
registry = e_shell_get_registry (shell);
- source_type = E_CLIENT_SOURCE_TYPE_TASKS;
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
source = e_source_registry_ref_default_task_list (registry);
/* Use a callback function appropriate for the 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_client_utils_open_new (
- source, source_type, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, NULL,
task_shell_backend_task_assigned_new_cb,
g_object_ref (shell));
else
- e_client_utils_open_new (
- source, source_type, FALSE, NULL,
+ e_cal_client_connect (
+ source, source_type, NULL,
task_shell_backend_task_new_cb,
g_object_ref (shell));
@@ -223,7 +225,7 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
EShell *shell;
CompEditor *editor;
CompEditorFlags flags = 0;
- ECalClient *client;
+ EClient *client;
ECalComponent *comp;
ESource *source;
ESourceRegistry *registry;
@@ -302,17 +304,17 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
goto exit;
}
- client = e_cal_client_new (source, source_type, &error);
+ client = e_cal_client_connect_sync (source, source_type, NULL, &error);
- if (client != NULL)
- e_client_open_sync (E_CLIENT (client), TRUE, NULL, &error);
+ /* Sanity check. */
+ g_return_val_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)), FALSE);
if (error != NULL) {
g_warning (
"%s: Failed to create/open client: %s",
G_STRFUNC, error->message);
- if (client != NULL)
- g_object_unref (client);
g_object_unref (source);
g_error_free (error);
goto exit;
@@ -330,7 +332,8 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
goto present;
e_cal_client_get_object_sync (
- client, comp_uid, comp_rid, &icalcomp, NULL, &error);
+ E_CAL_CLIENT (client), comp_uid,
+ comp_rid, &icalcomp, NULL, &error);
if (error != NULL) {
g_warning (
@@ -353,13 +356,13 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
if (icalprop != NULL)
flags |= COMP_EDITOR_IS_ASSIGNED;
- if (itip_organizer_is_user (registry, comp, client))
+ if (itip_organizer_is_user (registry, comp, E_CAL_CLIENT (client)))
flags |= COMP_EDITOR_USER_ORG;
if (!e_cal_component_has_attendees (comp))
flags |= COMP_EDITOR_USER_ORG;
- editor = task_editor_new (client, shell, flags);
+ editor = task_editor_new (E_CAL_CLIENT (client), shell, flags);
comp_editor_edit_comp (editor, comp);
g_object_unref (comp);
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c
index 7c7742e295..dc25f3921a 100644
--- a/modules/calendar/e-task-shell-sidebar.c
+++ b/modules/calendar/e-task-shell-sidebar.c
@@ -40,6 +40,8 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_TASK_SHELL_SIDEBAR, ETaskShellSidebarPrivate))
+typedef struct _ConnectClosure ConnectClosure;
+
struct _ETaskShellSidebarPrivate {
GtkWidget *selector;
@@ -53,14 +55,23 @@ 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. */
- ECalClient *default_client;
+ EClient *default_client;
- ESource *loading_default_source_instance; /* not-reffed, only for comparison */
+ /* Not referenced, only for pointer comparison. */
+ ESource *connecting_default_source_instance;
- GCancellable *loading_default_client;
+ GCancellable *connecting_default_client;
GCancellable *loading_clients;
};
+struct _ConnectClosure {
+ ETaskShellSidebar *task_shell_sidebar;
+
+ /* For error messages. */
+ gchar *source_display_name;
+ gchar *parent_display_name;
+};
+
enum {
PROP_0,
PROP_DEFAULT_CLIENT,
@@ -81,9 +92,45 @@ G_DEFINE_DYNAMIC_TYPE (
e_task_shell_sidebar,
E_TYPE_SHELL_SIDEBAR)
+static ConnectClosure *
+connect_closure_new (ETaskShellSidebar *task_shell_sidebar,
+ ESource *source)
+{
+ ConnectClosure *closure;
+ ESourceRegistry *registry;
+ ESourceSelector *selector;
+ ESource *parent;
+ const gchar *parent_uid;
+
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ registry = e_source_selector_get_registry (selector);
+ parent_uid = e_source_get_parent (source);
+ parent = e_source_registry_ref_source (registry, parent_uid);
+
+ closure = g_slice_new0 (ConnectClosure);
+ closure->task_shell_sidebar = g_object_ref (task_shell_sidebar);
+ closure->source_display_name = e_source_dup_display_name (source);
+ closure->parent_display_name = e_source_dup_display_name (parent);
+
+ g_object_unref (parent);
+
+ return closure;
+}
+
+static void
+connect_closure_free (ConnectClosure *closure)
+{
+ g_object_unref (closure->task_shell_sidebar);
+
+ g_free (closure->source_display_name);
+ g_free (closure->parent_display_name);
+
+ g_slice_free (ConnectClosure, closure);
+}
+
static void
task_shell_sidebar_emit_client_added (ETaskShellSidebar *task_shell_sidebar,
- ECalClient *client)
+ EClient *client)
{
guint signal_id = signals[CLIENT_ADDED];
@@ -185,170 +232,170 @@ task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar,
}
static void
-task_shell_sidebar_retrieve_capabilies_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+task_shell_sidebar_handle_connect_error (ETaskShellSidebar *task_shell_sidebar,
+ const gchar *parent_display_name,
+ const gchar *source_display_name,
+ const GError *error)
{
- ECalClient *client = E_CAL_CLIENT (source_object);
- ETaskShellSidebar *task_shell_sidebar = user_data;
- gchar *capabilities = NULL;
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
+ gboolean cancelled = FALSE;
+ gboolean offline_error;
- g_return_if_fail (client != NULL);
- g_return_if_fail (task_shell_sidebar != 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);
- e_client_retrieve_capabilities_finish (
- E_CLIENT (client), result, &capabilities, NULL);
- g_free (capabilities);
+ cancelled |= g_error_matches (
+ error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
+ cancelled |= g_error_matches (
+ error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED);
- task_shell_sidebar_emit_status_message (
- task_shell_sidebar, _("Loading tasks"));
- task_shell_sidebar_emit_client_added (task_shell_sidebar, client);
- task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL);
+ offline_error = g_error_matches (
+ error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE);
+
+ if (cancelled) {
+ /* do nothing */
+ } else if (offline_error) {
+ e_alert_submit (
+ E_ALERT_SINK (shell_content),
+ "calendar:prompt-no-contents-offline-calendar",
+ parent_display_name,
+ source_display_name,
+ NULL);
+ } else {
+ e_alert_submit (
+ E_ALERT_SINK (shell_content),
+ "calendar:failed-open-calendar",
+ parent_display_name,
+ source_display_name,
+ error->message,
+ NULL);
+ }
}
static void
-task_shell_sidebar_client_opened_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+task_shell_sidebar_client_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ECalClient *client = E_CAL_CLIENT (source_object);
- ETaskShellSidebar *task_shell_sidebar = user_data;
- ESource *source, *parent;
- EShellView *shell_view;
+ EClient *client;
+ ConnectClosure *closure = user_data;
+ ETaskShellContent *task_shell_content;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- ESourceRegistry *registry;
+ EShellView *shell_view;
+ ECalModel *model;
+ icaltimezone *timezone;
GError *error = NULL;
- source = e_client_get_source (E_CLIENT (client));
+ client = e_cal_client_connect_finish (result, &error);
- e_client_open_finish (E_CLIENT (client), result, &error);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_clear_error (&error);
- return;
+ if (error != NULL) {
+ task_shell_sidebar_handle_connect_error (
+ closure->task_shell_sidebar,
+ closure->parent_display_name,
+ closure->source_display_name,
+ error);
+ g_error_free (error);
+ goto exit;
}
- shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar);
+ /* FIXME Sidebar should not be accessing the EShellContent.
+ * This probably needs to be moved to ETaskShellView. */
+ shell_sidebar = E_SHELL_SIDEBAR (closure->task_shell_sidebar);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_content = e_shell_view_get_shell_content (shell_view);
- registry = e_shell_get_registry (e_shell_backend_get_shell (e_shell_view_get_shell_backend (shell_view)));
- parent = e_source_registry_ref_source (registry, e_source_get_parent (source));
-
- /* Handle errors. */
- switch ((error && error->domain == E_CLIENT_ERROR) ? error->code : -1) {
- case -1:
- break;
-
- case E_CLIENT_ERROR_REPOSITORY_OFFLINE:
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:prompt-no-contents-offline-tasks",
- e_source_get_display_name (parent),
- e_source_get_display_name (source), NULL);
- /* fall through */
-
- default:
- if (error->code != E_CLIENT_ERROR_REPOSITORY_OFFLINE) {
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:failed-open-tasks",
- e_source_get_display_name (parent),
- e_source_get_display_name (source),
- error->message, NULL);
- }
-
- e_task_shell_sidebar_remove_source (
- task_shell_sidebar,
- e_client_get_source (E_CLIENT (client)));
- g_clear_error (&error);
- g_object_unref (parent);
- return;
- }
- g_clear_error (&error);
- g_object_unref (parent);
+ 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);
- /* to have them ready for later use */
- e_client_retrieve_capabilities (
- E_CLIENT (client), NULL,
- task_shell_sidebar_retrieve_capabilies_cb,
- task_shell_sidebar);
+ e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone);
+
+ e_task_shell_sidebar_add_client (closure->task_shell_sidebar, client);
+
+ g_object_unref (client);
+
+exit:
+ connect_closure_free (closure);
}
static void
-task_shell_sidebar_default_loaded_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+task_shell_sidebar_default_connect_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EShellSidebar *shell_sidebar = user_data;
+ EClient *client;
+ ESource *source;
+ ConnectClosure *closure = user_data;
ETaskShellSidebarPrivate *priv;
EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
EShellView *shell_view;
ETaskShellContent *task_shell_content;
ECalModel *model;
- EClient *client = NULL;
+ icaltimezone *timezone;
GError *error = NULL;
- priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
+ priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (closure->task_shell_sidebar);
- 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_cal_client_connect_finish (result, &error);
- e_client_utils_open_new_finish (source, result, &client, &error);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
- if (priv->loading_default_client) {
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client) {
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
- if (source == priv->loading_default_source_instance)
- priv->loading_default_source_instance = NULL;
-
- /* Ignore cancellations. */
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
- g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
+ if (error != NULL) {
+ task_shell_sidebar_handle_connect_error (
+ closure->task_shell_sidebar,
+ closure->parent_display_name,
+ closure->source_display_name,
+ error);
g_error_free (error);
goto exit;
-
- } else if (error != NULL) {
- ESourceRegistry *registry;
- ESource *parent;
-
- registry = e_shell_get_registry (e_shell_backend_get_shell (e_shell_view_get_shell_backend (shell_view)));
- parent = e_source_registry_ref_source (registry, e_source_get_parent (source));
-
- g_warn_if_fail (client == NULL);
- e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:failed-open-tasks",
- e_source_get_display_name (parent),
- e_source_get_display_name (source),
- error->message, NULL);
- g_error_free (error);
- g_object_unref (parent);
- goto exit;
}
- g_return_if_fail (E_IS_CAL_CLIENT (client));
+ source = e_client_get_source (client);
+
+ if (source == priv->connecting_default_source_instance)
+ priv->connecting_default_source_instance = NULL;
if (priv->default_client != NULL)
g_object_unref (priv->default_client);
- priv->default_client = E_CAL_CLIENT (client);
+ priv->default_client = g_object_ref (client);
- e_cal_client_set_default_timezone (
- priv->default_client, e_cal_model_get_timezone (model));
+ /* FIXME Sidebar should not be accessing the EShellContent.
+ * This probably needs to be moved to ETaskShellView. */
+ shell_sidebar = E_SHELL_SIDEBAR (closure->task_shell_sidebar);
+ 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);
+ timezone = e_cal_model_get_timezone (model);
+
+ e_cal_client_set_default_timezone (E_CAL_CLIENT (client), timezone);
g_object_notify (G_OBJECT (shell_sidebar), "default-client");
- exit:
- g_object_unref (shell_sidebar);
+ g_object_unref (client);
+
+exit:
+ connect_closure_free (closure);
}
static void
@@ -363,7 +410,7 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar,
priv = task_shell_sidebar->priv;
/* already loading that source as default source */
- if (source == priv->loading_default_source_instance)
+ if (source == priv->connecting_default_source_instance)
return;
/* FIXME Sidebar should not be accessing the EShellContent.
@@ -371,10 +418,10 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar,
shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar);
/* Cancel any unfinished previous request. */
- if (priv->loading_default_client != NULL) {
- g_cancellable_cancel (priv->loading_default_client);
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client != NULL) {
+ g_cancellable_cancel (priv->connecting_default_client);
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
uid = e_source_get_uid (source);
@@ -391,14 +438,14 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar,
}
/* it's only for pointer comparison, no need to ref it */
- priv->loading_default_source_instance = source;
- priv->loading_default_client = g_cancellable_new ();
-
- e_client_utils_open_new (
- source, E_CLIENT_SOURCE_TYPE_TASKS,
- FALSE, priv->loading_default_client,
- task_shell_sidebar_default_loaded_cb,
- g_object_ref (shell_sidebar));
+ priv->connecting_default_source_instance = source;
+ priv->connecting_default_client = g_cancellable_new ();
+
+ e_cal_client_connect (
+ source, E_CAL_CLIENT_SOURCE_TYPE_TASKS,
+ priv->connecting_default_client,
+ task_shell_sidebar_default_connect_cb,
+ connect_closure_new (task_shell_sidebar, source));
}
static void
@@ -533,10 +580,10 @@ task_shell_sidebar_dispose (GObject *object)
priv->default_client = NULL;
}
- if (priv->loading_default_client != NULL) {
- g_cancellable_cancel (priv->loading_default_client);
- g_object_unref (priv->loading_default_client);
- priv->loading_default_client = NULL;
+ if (priv->connecting_default_client != NULL) {
+ g_cancellable_cancel (priv->connecting_default_client);
+ g_object_unref (priv->connecting_default_client);
+ priv->connecting_default_client = NULL;
}
if (priv->loading_clients != NULL) {
@@ -842,7 +889,7 @@ e_task_shell_sidebar_get_default_client (ETaskShellSidebar *task_shell_sidebar)
g_return_val_if_fail (
E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar), NULL);
- return task_shell_sidebar->priv->default_client;
+ return (ECalClient *) task_shell_sidebar->priv->default_client;
}
ESourceSelector *
@@ -855,20 +902,56 @@ e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar)
}
void
+e_task_shell_sidebar_add_client (ETaskShellSidebar *task_shell_sidebar,
+ EClient *client)
+{
+ ESource *source;
+ ESourceSelector *selector;
+ GHashTable *client_table;
+ const gchar *message;
+ const gchar *uid;
+
+ g_return_if_fail (E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar));
+ g_return_if_fail (E_IS_CAL_CLIENT (client));
+
+ client_table = task_shell_sidebar->priv->client_table;
+
+ source = e_client_get_source (client);
+ uid = e_source_get_uid (source);
+
+ if (g_hash_table_contains (client_table, uid))
+ return;
+
+ g_hash_table_insert (
+ client_table, g_strdup (uid), g_object_ref (client));
+
+ g_signal_connect_swapped (
+ client, "backend-died",
+ G_CALLBACK (task_shell_sidebar_backend_died_cb),
+ task_shell_sidebar);
+
+ g_signal_connect_swapped (
+ client, "backend-error",
+ G_CALLBACK (task_shell_sidebar_backend_error_cb),
+ task_shell_sidebar);
+
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ e_source_selector_select_source (selector, source);
+
+ message = _("Loading task list");
+ task_shell_sidebar_emit_status_message (task_shell_sidebar, message);
+ task_shell_sidebar_emit_client_added (task_shell_sidebar, client);
+ task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL);
+}
+
+void
e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
ESource *source)
{
- EShellView *shell_view;
- EShellContent *shell_content;
- EShellSidebar *shell_sidebar;
- ETaskShellContent *task_shell_content;
ECalClientSourceType source_type;
ESourceSelector *selector;
GHashTable *client_table;
- ECalModel *model;
- ECalClient *default_client;
- ECalClient *client;
- icaltimezone *timezone;
+ EClient *default_client;
const gchar *display_name;
const gchar *uid;
gchar *message;
@@ -882,38 +965,22 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
uid = e_source_get_uid (source);
- client = g_hash_table_lookup (client_table, uid);
- if (client != NULL)
+ if (g_hash_table_contains (client_table, uid))
return;
if (default_client != NULL) {
ESource *default_source;
- const gchar *default_uid;
- default_source = e_client_get_source (E_CLIENT (default_client));
- default_uid = e_source_get_uid (default_source);
+ default_source = e_client_get_source (default_client);
- if (g_strcmp0 (uid, default_uid) == 0)
- client = g_object_ref (default_client);
+ if (e_source_equal (source, default_source)) {
+ e_task_shell_sidebar_add_client (
+ task_shell_sidebar, default_client);
+ return;
+ }
}
- if (client == NULL)
- client = e_cal_client_new (source, source_type, NULL);
-
- g_return_if_fail (client != NULL);
-
- g_signal_connect_swapped (
- client, "backend-died",
- G_CALLBACK (task_shell_sidebar_backend_died_cb),
- task_shell_sidebar);
-
- g_signal_connect_swapped (
- client, "backend-error",
- G_CALLBACK (task_shell_sidebar_backend_error_cb),
- task_shell_sidebar);
-
- g_hash_table_insert (client_table, g_strdup (uid), client);
e_source_selector_select_source (selector, source);
display_name = e_source_get_display_name (source);
@@ -921,22 +988,11 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
task_shell_sidebar_emit_status_message (task_shell_sidebar, message);
g_free (message);
- /* 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);
-
- 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);
-
- e_cal_client_set_default_timezone (client, timezone);
-
- e_client_open (
- E_CLIENT (client), FALSE,
+ e_cal_client_connect (
+ source, source_type,
task_shell_sidebar->priv->loading_clients,
- task_shell_sidebar_client_opened_cb, task_shell_sidebar);
+ task_shell_sidebar_client_connect_cb,
+ connect_closure_new (task_shell_sidebar, source));
}
void
diff --git a/modules/calendar/e-task-shell-sidebar.h b/modules/calendar/e-task-shell-sidebar.h
index d9a143e278..736b273486 100644
--- a/modules/calendar/e-task-shell-sidebar.h
+++ b/modules/calendar/e-task-shell-sidebar.h
@@ -94,6 +94,9 @@ ECalClient * e_task_shell_sidebar_get_default_client
ESourceSelector *
e_task_shell_sidebar_get_selector
(ETaskShellSidebar *task_shell_sidebar);
+void e_task_shell_sidebar_add_client
+ (ETaskShellSidebar *task_shell_sidebar,
+ EClient *client);
void e_task_shell_sidebar_add_source
(ETaskShellSidebar *task_shell_sidebar,
ESource *source);
diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c
index 1ee2dffe98..a996b1e764 100644
--- a/modules/itip-formatter/itip-view.c
+++ b/modules/itip-formatter/itip-view.c
@@ -3516,29 +3516,30 @@ cal_opened_cb (GObject *source_object,
ItipView *view = user_data;
EMailPartItip *pitip = itip_view_get_mail_part (view);
ECalClientSourceType source_type;
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
const gchar *uid;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* Ignore cancellations. */
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
g_error_free (error);
return;
} else if (error != NULL) {
- g_warn_if_fail (client == NULL);
add_failed_to_load_msg (view, source, error);
g_error_free (error);
return;
}
- g_return_if_fail (E_IS_CAL_CLIENT (client));
-
cal_client = E_CAL_CLIENT (client);
g_return_if_fail (cal_client != NULL);
@@ -3596,13 +3597,7 @@ start_calendar_server (EMailPartItip *pitip,
return;
}
- e_client_utils_open_new (
- source,
- type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? E_CLIENT_SOURCE_TYPE_EVENTS :
- type == E_CAL_CLIENT_SOURCE_TYPE_MEMOS ? E_CLIENT_SOURCE_TYPE_MEMOS :
- type == E_CAL_CLIENT_SOURCE_TYPE_TASKS ? E_CLIENT_SOURCE_TYPE_TASKS : E_CLIENT_SOURCE_TYPE_LAST,
- TRUE, pitip->cancellable,
- func, data);
+ e_cal_client_connect (source, type, pitip->cancellable, func, data);
}
static void
@@ -3994,19 +3989,23 @@ find_cal_opened_cb (GObject *source_object,
EMailPartItip *pitip = fd->puri;
ItipView *view = fd->view;
ECalClientSourceType source_type;
- EClient *client = NULL;
+ EClient *client;
ECalClient *cal_client;
gboolean search_for_conflicts = FALSE;
const gchar *extension_name;
const gchar *uid;
GError *error = NULL;
- e_client_utils_open_new_finish (source, result, &client, &error);
+ client = e_cal_client_connect_finish (result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
/* Ignore cancellations. */
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (client == NULL);
decrease_find_data (fd);
g_error_free (error);
return;
@@ -4022,15 +4021,12 @@ find_cal_opened_cb (GObject *source_object,
/* FIXME Do we really want to warn here? If we fail
* to find the item, this won't be cleared but the
* selector might be shown */
- g_warn_if_fail (client == NULL);
add_failed_to_load_msg (view, source, error);
decrease_find_data (fd);
g_error_free (error);
return;
}
- g_return_if_fail (E_IS_CAL_CLIENT (client));
-
/* Do not process read-only calendars */
if (e_client_is_readonly (client)) {
g_object_unref (client);
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index fcffbadbb5..978011f12f 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -824,7 +824,8 @@ do_manage_comp_idle (struct _manage_comp *mc)
}
typedef struct {
- ECalClient *client;
+ ESource *source;
+ ECalClientSourceType source_type;
CamelFolder *folder;
GPtrArray *uids;
gchar *selected_text;
@@ -834,21 +835,26 @@ typedef struct {
static gboolean
do_mail_to_event (AsyncData *data)
{
- ECalClient *client = data->client;
+ EClient *client;
CamelFolder *folder = data->folder;
GPtrArray *uids = data->uids;
- GError *err = NULL;
+ GError *error = NULL;
+
+ client = e_cal_client_connect_sync (
+ data->source, data->source_type, NULL, &error);
- /* open the task client */
- e_client_open_sync (E_CLIENT (client), FALSE, NULL, &err);
+ /* Sanity check. */
+ g_return_val_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)), TRUE);
- if (err != NULL) {
- report_error_idle (_("Cannot open calendar. %s"), err->message);
+ if (error != NULL) {
+ report_error_idle (_("Cannot open calendar. %s"), error->message);
} else if (e_client_is_readonly (E_CLIENT (client))) {
- if (err)
- report_error_idle ("Check readonly failed. %s", err->message);
+ if (error != NULL)
+ report_error_idle ("Check readonly failed. %s", error->message);
else {
- switch (e_cal_client_get_source_type (client)) {
+ switch (data->source_type) {
case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
report_error_idle (_("Selected calendar is read only, thus cannot create event there. Select other calendar, please."), NULL);
break;
@@ -865,7 +871,6 @@ do_mail_to_event (AsyncData *data)
}
} else {
gint i;
- ECalClientSourceType source_type = e_cal_client_get_source_type (client);
ECalComponentDateTime dt, dt2;
struct icaltimetype tt, tt2;
struct _manage_comp *oldmc = NULL;
@@ -913,7 +918,7 @@ do_mail_to_event (AsyncData *data)
comp = e_cal_component_new ();
- switch (source_type) {
+ switch (data->source_type) {
case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
break;
@@ -931,7 +936,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_CLIENT_SOURCE_TYPE_EVENTS) {
+ if (data->source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS) {
/* make it an all-day event */
e_cal_component_set_dtend (comp, &dt2);
}
@@ -964,7 +969,7 @@ do_mail_to_event (AsyncData *data)
}
/* set attachment files */
- set_attachments (client, comp, message);
+ set_attachments (E_CAL_CLIENT (client), comp, message);
/* priority */
set_priority (comp, CAMEL_MIME_PART (message));
@@ -1003,7 +1008,7 @@ do_mail_to_event (AsyncData *data)
break;
}
- if (!e_cal_client_get_object_sync (client, icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL, NULL))
+ if (!e_cal_client_get_object_sync (E_CAL_CLIENT (client), icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL, NULL))
mc->stored_comp = NULL;
g_idle_add ((GSourceFunc) do_manage_comp_idle, mc);
@@ -1025,15 +1030,18 @@ do_mail_to_event (AsyncData *data)
}
/* free memory */
- g_object_unref (data->client);
+ if (client != NULL)
+ g_object_unref (client);
em_utils_uids_free (uids);
g_object_unref (folder);
+
+ g_object_unref (data->source);
g_free (data->selected_text);
g_free (data);
data = NULL;
- if (err)
- g_error_free (err);
+ if (error != NULL)
+ g_error_free (error);
return TRUE;
}
@@ -1196,23 +1204,14 @@ mail_to_event (ECalClientSourceType source_type,
if (source) {
/* if a source has been selected, perform the mail2event operation */
- ECalClient *client = NULL;
AsyncData *data = NULL;
GThread *thread = NULL;
GError *error = NULL;
- client = e_cal_client_new (source, source_type, &error);
- if (!client) {
- e_notice (
- parent, GTK_MESSAGE_ERROR,
- "Could not connect to '%s'",
- e_source_get_display_name (source));
- goto exit;
- }
-
/* Fill the elements in AsynData */
data = g_new0 (AsyncData, 1);
- data->client = client;
+ data->source = g_object_ref (source);
+ data->source_type = source_type;
data->folder = folder;
data->uids = uids;
data->with_attendees = with_attendees;
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index c2ec12e100..9ead6efe0f 100644
--- a/plugins/publish-calendar/publish-format-fb.c
+++ b/plugins/publish-calendar/publish-format-fb.c
@@ -59,7 +59,7 @@ write_calendar (const gchar *uid,
EShell *shell;
ESource *source;
ESourceRegistry *registry;
- ECalClient *client = NULL;
+ EClient *client = NULL;
GSList *objects = NULL;
icaltimezone *utc;
time_t start = time (NULL), end;
@@ -89,21 +89,21 @@ write_calendar (const gchar *uid,
source = e_source_registry_ref_source (registry, uid);
if (source != NULL) {
- client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
+ client = e_cal_client_connect_sync (
+ source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
+ NULL, error);
g_object_unref (source);
- }
- if (!client) {
- 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;
+ } else {
+ g_set_error (
+ error, E_CAL_CLIENT_ERROR,
+ E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR,
+ _("Invalid source UID '%s'"), uid);
}
- if (!e_client_open_sync (E_CLIENT (client), TRUE, NULL, error)) {
- g_object_unref (client);
+ if (client == NULL)
return FALSE;
- }
- if (e_client_get_backend_property_sync (E_CLIENT (client), CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL)) {
+ if (e_client_get_backend_property_sync (client, CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL)) {
if (email && *email)
users = g_slist_append (users, email);
}
@@ -114,7 +114,7 @@ write_calendar (const gchar *uid,
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)) {
+ if (e_cal_client_get_free_busy_sync (E_CAL_CLIENT (client), start, end, users, NULL, error)) {
gchar *ical_string;
GSList *iter;
diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c
index 08c8c287d5..95e5dd8aef 100644
--- a/plugins/publish-calendar/publish-format-ical.c
+++ b/plugins/publish-calendar/publish-format-ical.c
@@ -77,7 +77,7 @@ write_calendar (const gchar *uid,
EShell *shell;
ESource *source;
ESourceRegistry *registry;
- ECalClient *client = NULL;
+ EClient *client = NULL;
GSList *objects;
icalcomponent *top_level;
gboolean res = FALSE;
@@ -87,29 +87,29 @@ write_calendar (const gchar *uid,
source = e_source_registry_ref_source (registry, uid);
if (source != NULL) {
- client = e_cal_client_new (source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, error);
+ client = e_cal_client_connect_sync (
+ source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
+ NULL, error);
g_object_unref (source);
- }
- if (!client) {
- 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;
+ } else {
+ g_set_error (
+ error, E_CAL_CLIENT_ERROR,
+ E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR,
+ _("Invalid source UID '%s'"), uid);
}
- if (!e_client_open_sync (E_CLIENT (client), TRUE, NULL, error)) {
- g_object_unref (client);
+ if (client == NULL)
return FALSE;
- }
top_level = e_cal_util_new_top_level ();
- if (e_cal_client_get_object_list_sync (client, "#t", &objects, NULL, error)) {
+ if (e_cal_client_get_object_list_sync (E_CAL_CLIENT (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.client = client;
+ tdata.client = E_CAL_CLIENT (client);
for (iter = objects; iter; iter = iter->next) {
icalcomponent *icalcomp = icalcomponent_new_clone (iter->data);
diff --git a/plugins/save-calendar/csv-format.c b/plugins/save-calendar/csv-format.c
index 872530af16..1e1bf4a7e1 100644
--- a/plugins/save-calendar/csv-format.c
+++ b/plugins/save-calendar/csv-format.c
@@ -318,7 +318,7 @@ do_save_calendar_csv (FormatHandler *handler,
*/
ESource *primary_source;
- ECalClient *source_client;
+ EClient *source_client;
GError *error = NULL;
GSList *objects = NULL;
GOutputStream *stream;
@@ -332,15 +332,19 @@ do_save_calendar_csv (FormatHandler *handler,
/* open source client */
primary_source = e_source_selector_ref_primary_selection (selector);
- source_client = e_cal_client_new (primary_source, type, &error);
+ source_client = e_cal_client_connect_sync (
+ primary_source, type, NULL, &error);
g_object_unref (primary_source);
- if (!source_client || !e_client_open_sync (E_CLIENT (source_client), TRUE, NULL, &error)) {
+ /* Sanity check. */
+ g_return_if_fail (
+ ((source_client != NULL) && (error == NULL)) ||
+ ((source_client == NULL) && (error != NULL)));
+
+ if (source_client == NULL) {
display_error_message (
gtk_widget_get_toplevel (GTK_WIDGET (selector)),
error);
- if (source_client)
- g_object_unref (source_client);
g_error_free (error);
return;
}
@@ -360,7 +364,7 @@ do_save_calendar_csv (FormatHandler *handler,
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (selector))),
dest_uri, &error);
- if (stream && e_cal_client_get_object_list_as_comps_sync (source_client, "#t", &objects, NULL, NULL)) {
+ if (stream && e_cal_client_get_object_list_as_comps_sync (E_CAL_CLIENT (source_client), "#t", &objects, NULL, NULL)) {
GSList *iter;
if (config->header) {
diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c
index da908a1a11..a007811708 100644
--- a/plugins/save-calendar/ical-format.c
+++ b/plugins/save-calendar/ical-format.c
@@ -86,7 +86,7 @@ do_save_calendar_ical (FormatHandler *handler,
gchar *dest_uri)
{
ESource *primary_source;
- ECalClient *source_client;
+ EClient *source_client;
GError *error = NULL;
GSList *objects = NULL;
icalcomponent *top_level = NULL;
@@ -96,13 +96,19 @@ do_save_calendar_ical (FormatHandler *handler,
/* open source client */
primary_source = e_source_selector_ref_primary_selection (selector);
- source_client = e_cal_client_new (primary_source, type, &error);
+ source_client = e_cal_client_connect_sync (
+ primary_source, type, NULL, &error);
g_object_unref (primary_source);
- 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);
- if (source_client)
- g_object_unref (source_client);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((source_client != NULL) && (error == NULL)) ||
+ ((source_client == NULL) && (error != NULL)));
+
+ if (source_client == NULL) {
+ display_error_message (
+ gtk_widget_get_toplevel (GTK_WIDGET (selector)),
+ error->message);
g_error_free (error);
return;
}
@@ -111,13 +117,13 @@ do_save_calendar_ical (FormatHandler *handler,
top_level = e_cal_util_new_top_level ();
error = NULL;
- if (e_cal_client_get_object_list_sync (source_client, "#t", &objects, NULL, &error)) {
+ if (e_cal_client_get_object_list_sync (E_CAL_CLIENT (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.client = source_client;
+ tdata.client = E_CAL_CLIENT (source_client);
for (iter = objects; iter; iter = iter->next) {
icalcomponent *icalcomp = icalcomponent_new_clone (iter->data);
diff --git a/plugins/save-calendar/rdf-format.c b/plugins/save-calendar/rdf-format.c
index 28e0b4c35f..391f60cfa7 100644
--- a/plugins/save-calendar/rdf-format.c
+++ b/plugins/save-calendar/rdf-format.c
@@ -71,13 +71,13 @@ enum { /* XML helper enum */
static void
display_error_message (GtkWidget *parent,
- GError *error)
+ const gchar *error_message)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (
GTK_WINDOW (parent), 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", error->message);
+ "%s", error_message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
@@ -187,7 +187,7 @@ do_save_calendar_rdf (FormatHandler *handler,
*/
ESource *primary_source;
- ECalClient *source_client;
+ EClient *source_client;
GError *error = NULL;
GSList *objects = NULL;
gchar *temp = NULL;
@@ -198,20 +198,26 @@ do_save_calendar_rdf (FormatHandler *handler,
/* open source client */
primary_source = e_source_selector_ref_primary_selection (selector);
- source_client = e_cal_client_new (primary_source, type, &error);
+ source_client = e_cal_client_connect_sync (
+ primary_source, type, NULL, &error);
g_object_unref (primary_source);
- 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);
- if (source_client)
- g_object_unref (source_client);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((source_client != NULL) && (error == NULL)) ||
+ ((source_client == NULL) && (error != NULL)));
+
+ if (source_client == NULL) {
+ display_error_message (
+ gtk_widget_get_toplevel (GTK_WIDGET (selector)),
+ error->message);
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_client_get_object_list_as_comps_sync (source_client, "#t", &objects, NULL, NULL)) {
+ if (stream && e_cal_client_get_object_list_as_comps_sync (E_CAL_CLIENT (source_client), "#t", &objects, NULL, NULL)) {
GSList *iter;
xmlBufferPtr buffer = xmlBufferCreate ();
@@ -363,7 +369,9 @@ do_save_calendar_rdf (FormatHandler *handler,
g_object_unref (source_client);
if (error) {
- display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), error);
+ display_error_message (
+ gtk_widget_get_toplevel (GTK_WIDGET (selector)),
+ error->message);
g_error_free (error);
}