aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-01-24 05:05:08 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-01-30 22:35:27 +0800
commitf19241d136043d5cfffbfbaf5b2d6d1affc70682 (patch)
tree6abc10286b092dfc9b046bde599f24767ad0c177 /plugins
parente583928e0401a4baea4432c5b7e12a1b1eff8c2e (diff)
downloadgsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar
gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar.gz
gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar.bz2
gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar.lz
gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar.xz
gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.tar.zst
gsoc2013-evolution-f19241d136043d5cfffbfbaf5b2d6d1affc70682.zip
Use e_cal_client_connect().
Instead of e_client_utils_open_new() or e_cal_client_new().
Diffstat (limited to 'plugins')
-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
6 files changed, 94 insertions, 77 deletions
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);
}