From 3da4948c0fc1f2c21b163f0ec456b2d99c881258 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 7 Sep 2013 12:31:19 -0400 Subject: Miscellaneous cleanups. --- plugins/publish-calendar/publish-calendar.c | 71 +++++++++++++++++------------ 1 file changed, 43 insertions(+), 28 deletions(-) (limited to 'plugins/publish-calendar/publish-calendar.c') diff --git a/plugins/publish-calendar/publish-calendar.c b/plugins/publish-calendar/publish-calendar.c index 2f1480187e..2713f00dd2 100644 --- a/plugins/publish-calendar/publish-calendar.c +++ b/plugins/publish-calendar/publish-calendar.c @@ -200,41 +200,48 @@ publish_online (EPublishUri *uri, GOutputStream *stream; GError *error = NULL; - stream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error)); + stream = G_OUTPUT_STREAM (g_file_replace ( + file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error)); - if (!stream || error) { - if (stream) - g_object_unref (stream); + /* Sanity check. */ + g_return_if_fail ( + ((stream != NULL) && (error == NULL)) || + ((stream == NULL) && (error != NULL))); - if (perror) { + if (error != NULL) { + if (perror != NULL) { *perror = error; - } else if (error) { - - error_queue_add (g_strdup_printf (_("Could not open %s:"), uri->location), error); } else { - error_queue_add (g_strdup_printf (_("Could not open %s: Unknown error"), uri->location), NULL); + error_queue_add ( + g_strdup_printf ( + _("Could not open %s:"), + uri->location), + error); } return; } switch (uri->publish_format) { - case URI_PUBLISH_AS_ICAL: - publish_calendar_as_ical (stream, uri, &error); - break; - case URI_PUBLISH_AS_FB: - publish_calendar_as_fb (stream, uri, &error); - break; - /* - case URI_PUBLISH_AS_HTML: - publish_calendar_as_html (handle, uri); - break; - */ + case URI_PUBLISH_AS_ICAL: + publish_calendar_as_ical (stream, uri, &error); + break; + case URI_PUBLISH_AS_FB: + publish_calendar_as_fb (stream, uri, &error); + break; } - if (error) - error_queue_add (g_strdup_printf (_("There was an error while publishing to %s:"), uri->location), error); + if (error != NULL) + error_queue_add ( + g_strdup_printf ( + _("There was an error while publishing to %s:"), + uri->location), + error); else if (can_report_success) - error_queue_add (g_strdup_printf (_("Publishing to %s finished successfully"), uri->location), NULL); + error_queue_add ( + g_strdup_printf ( + _("Publishing to %s finished successfully"), + uri->location), + NULL); update_timestamp (uri); @@ -251,7 +258,7 @@ unmount_done_cb (GObject *source_object, g_mount_unmount_with_operation_finish (G_MOUNT (source_object), result, &error); - if (error) { + if (error != NULL) { g_warning ("Unmount failed: %s", error->message); g_error_free (error); } @@ -277,8 +284,12 @@ mount_ready_cb (GObject *source_object, g_file_mount_enclosing_volume_finish (G_FILE (source_object), result, &error); - if (error) { - error_queue_add (g_strdup_printf (_("Mount of %s failed:"), ms ? ms->uri->location : "???"), error); + if (error != NULL) { + error_queue_add ( + g_strdup_printf ( + _("Mount of %s failed:"), + ms ? ms->uri->location : "???"), + error); if (ms) g_object_unref (ms->mount_op); @@ -467,8 +478,12 @@ publish (EPublishUri *uri, mount_first (uri, file, can_report_success); } - if (error) - error_queue_add (g_strdup_printf (_("Could not open %s:"), uri->location), error); + if (error != NULL) + error_queue_add ( + g_strdup_printf ( + _("Could not open %s:"), + uri->location), + error); g_object_unref (file); } else { -- cgit v1.2.3