diff options
| author | Matthew Barnes <mbarnes@redhat.com> | 2013-09-08 00:31:19 +0800 |
|---|---|---|
| committer | Matthew Barnes <mbarnes@redhat.com> | 2013-09-08 07:08:54 +0800 |
| commit | 3da4948c0fc1f2c21b163f0ec456b2d99c881258 (patch) | |
| tree | 479d6153d31e03cb7a65990683b5271402e5ec29 /plugins/publish-calendar | |
| parent | 2e5031cb4538b4819e5fce5d717668c3445df80a (diff) | |
| download | gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.gz gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.bz2 gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.lz gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.xz gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.tar.zst gsoc2013-evolution-3da4948c0fc1f2c21b163f0ec456b2d99c881258.zip | |
Miscellaneous cleanups.
Diffstat (limited to 'plugins/publish-calendar')
| -rw-r--r-- | plugins/publish-calendar/publish-calendar.c | 71 | ||||
| -rw-r--r-- | plugins/publish-calendar/publish-format-fb.c | 14 | ||||
| -rw-r--r-- | plugins/publish-calendar/publish-format-ical.c | 16 |
3 files changed, 65 insertions, 36 deletions
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 { diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c index 28393040da..e343445ece 100644 --- a/plugins/publish-calendar/publish-format-fb.c +++ b/plugins/publish-calendar/publish-format-fb.c @@ -66,7 +66,7 @@ write_calendar (const gchar *uid, icalcomponent *top_level; gchar *email = NULL; GSList *users = NULL; - gboolean res = FALSE; + gboolean success = FALSE; utc = icaltimezone_get_utc_timezone (); start = time_day_begin_with_zone (start, utc); @@ -114,7 +114,9 @@ write_calendar (const gchar *uid, client, "free-busy-data", G_CALLBACK (free_busy_data_cb), &objects); - if (e_cal_client_get_free_busy_sync (E_CAL_CLIENT (client), start, end, users, NULL, error)) { + success = e_cal_client_get_free_busy_sync ( + E_CAL_CLIENT (client), start, end, users, NULL, error); + if (success) { gchar *ical_string; GSList *iter; gboolean done = FALSE; @@ -135,7 +137,11 @@ write_calendar (const gchar *uid, } ical_string = icalcomponent_as_ical_string_r (top_level); - res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, error); + + success = g_output_stream_write_all ( + stream, ical_string, + strlen (ical_string), + NULL, NULL, error); e_cal_client_free_ecalcomp_slist (objects); g_free (ical_string); @@ -148,7 +154,7 @@ write_calendar (const gchar *uid, g_object_unref (client); icalcomponent_free (top_level); - return res; + return success; } void diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c index 95e5dd8aef..c875904495 100644 --- a/plugins/publish-calendar/publish-format-ical.c +++ b/plugins/publish-calendar/publish-format-ical.c @@ -51,8 +51,13 @@ insert_tz_comps (icalparameter *param, if (g_hash_table_lookup (tdata->zones, tzid)) return; - if (!e_cal_client_get_timezone_sync (tdata->client, tzid, &zone, NULL, &error)) { - g_warning ("Could not get the timezone information for %s : %s \n", tzid, error->message); + e_cal_client_get_timezone_sync ( + tdata->client, tzid, &zone, NULL, &error); + + if (error != NULL) { + g_warning ( + "Could not get the timezone information for %s: %s", + tzid, error->message); g_error_free (error); return; } @@ -78,7 +83,7 @@ write_calendar (const gchar *uid, ESource *source; ESourceRegistry *registry; EClient *client = NULL; - GSList *objects; + GSList *objects = NULL; icalcomponent *top_level; gboolean res = FALSE; @@ -103,7 +108,10 @@ write_calendar (const gchar *uid, top_level = e_cal_util_new_top_level (); - if (e_cal_client_get_object_list_sync (E_CAL_CLIENT (client), "#t", &objects, NULL, error)) { + e_cal_client_get_object_list_sync ( + E_CAL_CLIENT (client), "#t", &objects, NULL, error); + + if (objects != NULL) { GSList *iter; gchar *ical_string; CompTzData tdata; |
