aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/publish-calendar/publish-format-ical.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/publish-calendar/publish-format-ical.c')
-rw-r--r--plugins/publish-calendar/publish-format-ical.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c
index f6dcc461c9..13962fc849 100644
--- a/plugins/publish-calendar/publish-format-ical.c
+++ b/plugins/publish-calendar/publish-format-ical.c
@@ -21,6 +21,7 @@
*/
#include <string.h>
+#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
@@ -65,11 +66,10 @@ append_tz_to_comp (gpointer key, gpointer value, icalcomponent *toplevel)
}
static gboolean
-write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream)
+write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream, GError **error)
{
ESource *source;
ECal *client = NULL;
- GError *error = NULL;
GList *objects;
icalcomponent *top_level;
gboolean res = FALSE;
@@ -78,23 +78,19 @@ write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream)
if (source)
client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
if (!client) {
- g_warning (G_STRLOC ": Could not publish calendar: Calendar backend no longer exists");
+ if (error)
+ *error = g_error_new (e_calendar_error_quark (), E_CALENDAR_STATUS_NO_SUCH_CALENDAR, _("Could not publish calendar: Calendar backend no longer exists"));
return FALSE;
}
- if (!e_cal_open (client, TRUE, &error)) {
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ if (!e_cal_open (client, TRUE, error)) {
g_object_unref (client);
return FALSE;
}
top_level = e_cal_util_new_top_level ();
- error = NULL;
- if (e_cal_get_object_list (client, "#t", &objects, &error)) {
+ if (e_cal_get_object_list (client, "#t", &objects, error)) {
char *ical_string;
CompTzData tdata;
@@ -114,22 +110,17 @@ write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream)
tdata.zones = NULL;
ical_string = icalcomponent_as_ical_string_r (top_level);
- res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, &error);
+ res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, error);
g_free (ical_string);
}
g_object_unref (client);
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
return res;
}
void
-publish_calendar_as_ical (GOutputStream *stream, EPublishUri *uri)
+publish_calendar_as_ical (GOutputStream *stream, EPublishUri *uri, GError **error)
{
GSList *l;
ESourceList *source_list;
@@ -142,7 +133,7 @@ publish_calendar_as_ical (GOutputStream *stream, EPublishUri *uri)
l = uri->events;
while (l) {
gchar *uid = l->data;
- if (!write_calendar (uid, source_list, stream))
+ if (!write_calendar (uid, source_list, stream, error))
break;
l = g_slist_next (l);
}