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 /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 'calendar')
25 files changed, 524 insertions, 422 deletions
diff --git a/calendar/alarm-notify/alarm-queue.c b/calendar/alarm-notify/alarm-queue.c index 7ea3222631..bd044e5381 100644 --- a/calendar/alarm-notify/alarm-queue.c +++ b/calendar/alarm-notify/alarm-queue.c @@ -370,13 +370,16 @@ remove_queued_alarm (CompQueuedAlarms *cqa, id->rid, qa->instance->auid, NULL, &error); cqa->expecting_update = FALSE; - if (error) { - if (!g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED)) - g_warning ( - "%s: Failed to discard alarm: %s", - G_STRFUNC, error->message); + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED)) { + g_error_free (error); + + } else if (error != NULL) { + g_warning ( + "%s: Failed to discard alarm: %s", + G_STRFUNC, error->message); g_error_free (error); } + e_cal_component_free_id (id); } } @@ -776,7 +779,7 @@ get_alarms_for_object (ECalClient *cal_client, time_t end, ECalComponentAlarms **alarms) { - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; ECalComponent *comp; ECalComponentAlarmAction omit[] = {-1}; @@ -786,11 +789,10 @@ get_alarms_for_object (ECalClient *cal_client, g_return_val_if_fail (start >= 0 && end >= 0, FALSE); g_return_val_if_fail (start <= end, FALSE); - if (!e_cal_client_get_object_sync ( - cal_client, id->uid, id->rid, &icalcomp, NULL, NULL)) - return FALSE; + e_cal_client_get_object_sync ( + cal_client, id->uid, id->rid, &icalcomp, NULL, NULL); - if (!icalcomp) + if (icalcomp == NULL) return FALSE; comp = e_cal_component_new (); diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index a271100167..8ad8bd54f9 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -106,7 +106,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, ECalComponentDateTime start_datetime, end_datetime; const gchar *tzid; gboolean retval = FALSE; - icaltimezone *start_zone, *end_zone; + icaltimezone *start_zone = NULL; + icaltimezone *end_zone = NULL; gint offset1, offset2; tzid = icaltimezone_get_tzid (zone); @@ -150,8 +151,9 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, /* If the TZIDs differ, we have to compare the UTC offsets * of the start and end times, using their own timezones and * the given timezone. */ - if (!e_cal_client_get_timezone_sync (client, start_datetime.tzid, - &start_zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + client, start_datetime.tzid, &start_zone, NULL, NULL); + if (start_zone == NULL) goto out; if (start_datetime.value) { @@ -167,8 +169,9 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, goto out; } - if (!e_cal_client_get_timezone_sync (client, end_datetime.tzid, - &end_zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + client, end_datetime.tzid, &end_zone, NULL, NULL); + if (end_zone == NULL) goto out; if (end_datetime.value) { @@ -242,7 +245,10 @@ cal_comp_is_on_server (ECalComponent *comp, rid = e_cal_component_get_recurid_as_string (comp); } - if (e_cal_client_get_object_sync (client, uid, rid, &icalcomp, NULL, &error)) { + e_cal_client_get_object_sync ( + client, uid, rid, &icalcomp, NULL, &error); + + if (icalcomp != NULL) { icalcomponent_free (icalcomp); g_free (rid); @@ -298,13 +304,14 @@ cal_comp_event_new_with_defaults (ECalClient *client, gint default_reminder_interval, EDurationType default_reminder_units) { - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; ECalComponent *comp; ECalComponentAlarm *alarm; icalproperty *icalprop; ECalComponentAlarmTrigger trigger; - if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) + e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL); + if (icalcomp == NULL) icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT); comp = e_cal_component_new (); @@ -407,9 +414,10 @@ ECalComponent * cal_comp_task_new_with_defaults (ECalClient *client) { ECalComponent *comp; - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; - if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) + e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL); + if (icalcomp == NULL) icalcomp = icalcomponent_new (ICAL_VTODO_COMPONENT); comp = e_cal_component_new (); @@ -426,9 +434,10 @@ ECalComponent * cal_comp_memo_new_with_defaults (ECalClient *client) { ECalComponent *comp; - icalcomponent *icalcomp; + icalcomponent *icalcomp = NULL; - if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) + e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL); + if (icalcomp == NULL) icalcomp = icalcomponent_new (ICAL_VJOURNAL_COMPONENT); comp = e_cal_component_new (); diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 39ca3a81e1..0459e4797a 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -390,12 +390,14 @@ changes_view_ready_cb (GObject *source_object, G_STRFUNC, error->message); g_error_free (error); } - } else if (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_warning ( - "%s: Failed to get view: %s", - G_STRFUNC, error->message); + + } else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + + } else if (error != NULL) { + g_warning ( + "%s: Failed to get view: %s", + G_STRFUNC, error->message); g_error_free (error); } } @@ -619,7 +621,7 @@ save_comp (CompEditor *editor) gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - if (error) + if (error != NULL) g_error_free (error); g_free (orig_uid_copy); @@ -1055,35 +1057,23 @@ save_and_close_editor (CompEditor *editor, rid = e_cal_component_get_recurid_as_string (priv->comp); source_type = e_cal_client_get_source_type (priv->cal_client); - if (!e_cal_client_get_object_sync (priv->cal_client, uid, rid, &icalcomp, NULL, &error)) { - if (error != NULL) { - switch (source_type) { - case (E_CAL_CLIENT_SOURCE_TYPE_TASKS): - g_warning ("Unable to retrieve saved component from the task list, returned error was: %s", error->message); - break; - case (E_CAL_CLIENT_SOURCE_TYPE_MEMOS): - g_warning ("Unable to retrieve saved component from the memo list, returned error was: %s", error->message); - break; - case (E_CAL_CLIENT_SOURCE_TYPE_EVENTS): - default: - g_warning ("Unable to retrieve saved component from the calendar, returned error was: %s", error->message); - break; - } - g_clear_error (&error); - } else { - switch (source_type) { - case (E_CAL_CLIENT_SOURCE_TYPE_TASKS): - g_warning ("Unable to retrieve saved component from the task list"); + e_cal_client_get_object_sync ( + priv->cal_client, uid, rid, + &icalcomp, NULL, &error); + if (error != NULL) { + switch (source_type) { + case (E_CAL_CLIENT_SOURCE_TYPE_TASKS): + g_warning ("Unable to retrieve saved component from the task list, returned error was: %s", error->message); + break; + case (E_CAL_CLIENT_SOURCE_TYPE_MEMOS): + g_warning ("Unable to retrieve saved component from the memo list, returned error was: %s", error->message); + break; + case (E_CAL_CLIENT_SOURCE_TYPE_EVENTS): + default: + g_warning ("Unable to retrieve saved component from the calendar, returned error was: %s", error->message); break; - case (E_CAL_CLIENT_SOURCE_TYPE_MEMOS): - g_warning ("Unable to retrieve saved component from the memo list"); - break; - case (E_CAL_CLIENT_SOURCE_TYPE_EVENTS): - default: - g_warning ("Unable to retrieve saved component from the calendar"); - break; - } } + g_clear_error (&error); e_notice ( GTK_WINDOW (editor), GTK_MESSAGE_ERROR, @@ -3438,7 +3428,9 @@ real_send_comp (CompEditor *editor, const gchar *uid = NULL; e_cal_component_get_uid (priv->comp, &uid); - if (e_cal_client_get_object_sync (priv->cal_client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { + e_cal_client_get_object_sync ( + priv->cal_client, uid, NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c index 0f0dc0545e..e9e35b892c 100644 --- a/calendar/gui/dialogs/copy-source-dialog.c +++ b/calendar/gui/dialogs/copy-source-dialog.c @@ -77,8 +77,11 @@ add_timezone_to_cal_cb (icalparameter *param, if (!tzid || !*tzid) return; - if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, NULL, NULL) && tz) - e_cal_client_add_timezone_sync (ftd->dest_client, tz, NULL, NULL); + e_cal_client_get_timezone_sync ( + ftd->source_client, tzid, &tz, NULL, NULL); + if (tz != NULL) + e_cal_client_add_timezone_sync ( + ftd->dest_client, tz, NULL, NULL); } static void @@ -128,7 +131,10 @@ dest_source_connected_cb (GObject *source_object, show_error (csdd, _("Destination is read only"), NULL); } else { GSList *obj_list = NULL; - if (e_cal_client_get_object_list_sync (csdd->source_client, "#t", &obj_list, NULL, NULL)) { + + e_cal_client_get_object_list_sync ( + csdd->source_client, "#t", &obj_list, NULL, NULL); + if (obj_list != NULL) { GSList *l; icalcomponent *icalcomp; struct ForeachTzidData ftd; @@ -139,12 +145,16 @@ dest_source_connected_cb (GObject *source_object, for (l = obj_list; l != NULL; l = l->next) { /* FIXME: process recurrences */ /* FIXME: process errors */ - if (e_cal_client_get_object_sync (csdd->dest_client, icalcomponent_get_uid (l->data), NULL, - &icalcomp, NULL, NULL)) { - e_cal_client_modify_object_sync (csdd->dest_client, l->data, CALOBJ_MOD_ALL, NULL, NULL); + e_cal_client_get_object_sync ( + csdd->dest_client, + icalcomponent_get_uid (l->data), + NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { + e_cal_client_modify_object_sync ( + csdd->dest_client, l->data, + CALOBJ_MOD_ALL, NULL, NULL); icalcomponent_free (icalcomp); } else { - gchar *uid = NULL; GError *error = NULL; icalcomp = l->data; @@ -155,13 +165,13 @@ dest_source_connected_cb (GObject *source_object, icalcomp, add_timezone_to_cal_cb, &ftd); - if (e_cal_client_create_object_sync (csdd->dest_client, icalcomp, &uid, NULL, &error)) { - g_free (uid); - } else { - if (error) { - show_error (csdd, _("Cannot create object"), error); - g_error_free (error); - } + e_cal_client_create_object_sync ( + csdd->dest_client, + icalcomp, NULL, NULL, &error); + + if (error != NULL) { + show_error (csdd, _("Cannot create object"), error); + g_error_free (error); break; } } diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index f1f7c05e89..f4d9658ccb 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -992,8 +992,10 @@ event_page_load_locations_list (CompEditorPage *page, error = NULL; g_file_get_contents (file_name, &contents, NULL, &error); - if (error) { - g_warning ("%s: Failed to load locations list: %s", G_STRFUNC, error->message); + if (error != NULL) { + g_warning ( + "%s: Failed to load locations list: %s", + G_STRFUNC, error->message); g_error_free (error); g_free (file_name); return; @@ -1081,8 +1083,10 @@ event_page_save_locations_list (CompEditorPage *page, error = NULL; g_file_set_contents (file_name, contents->str, -1, &error); - if (error) { - g_warning ("%s: Failed to save locations: %s", G_STRFUNC, error->message); + if (error != NULL) { + g_warning ( + "%s: Failed to save locations: %s", + G_STRFUNC, error->message); g_error_free (error); } @@ -2997,8 +3001,7 @@ epage_get_client_cb (GObject *source_object, ((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)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } @@ -3006,7 +3009,7 @@ epage_get_client_cb (GObject *source_object, editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); priv = epage->priv; - if (error) { + if (error != NULL) { GtkWidget *dialog; ECalClient *old_client; diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c index c202444a2b..1fd9221a54 100644 --- a/calendar/gui/dialogs/memo-page.c +++ b/calendar/gui/dialogs/memo-page.c @@ -946,8 +946,7 @@ mpage_get_client_cb (GObject *source_object, ((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)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index 3ceb08476e..4fcd34794b 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -234,7 +234,9 @@ preview_recur (RecurrencePage *rpage) e_cal_component_get_dtstart (priv->comp, &cdt); if (cdt.tzid != NULL) { /* FIXME Will e_cal_client_get_timezone_sync really not return builtin zones? */ - if (!e_cal_client_get_timezone_sync (client, cdt.tzid, &zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + client, cdt.tzid, &zone, NULL, NULL); + if (zone == NULL) zone = icaltimezone_get_builtin_timezone_from_tzid (cdt.tzid); } e_cal_component_set_dtstart (comp, &cdt); @@ -630,8 +632,7 @@ rpage_get_objects_for_uid_cb (GObject *source_object, if (result && !e_cal_client_get_objects_for_uid_finish (client, result, &ecalcomps, &error)) { ecalcomps = NULL; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } @@ -658,8 +659,7 @@ rpage_get_object_cb (GObject *source_object, if (result && !e_cal_client_get_object_finish (client, result, &icalcomp, &error)) { icalcomp = NULL; - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_clear_error (&error); return; } diff --git a/calendar/gui/dialogs/send-comp.c b/calendar/gui/dialogs/send-comp.c index 9be9406965..b71c46427d 100644 --- a/calendar/gui/dialogs/send-comp.c +++ b/calendar/gui/dialogs/send-comp.c @@ -121,7 +121,10 @@ send_component_dialog (GtkWindow *parent, if (strip_alarms) *strip_alarms = TRUE; - if (e_cal_client_check_save_schedules (client) || !itip_component_has_recipients (comp)) + if (e_cal_client_check_save_schedules (client)) + return FALSE; + + if (!itip_component_has_recipients (comp)) return FALSE; vtype = e_cal_component_get_vtype (comp); @@ -210,15 +213,19 @@ send_dragged_or_resized_component_dialog (GtkWindow *parent, if (strip_alarms) *strip_alarms = TRUE; - if (e_cal_client_check_save_schedules (client) || !itip_component_has_recipients (comp)) + if (e_cal_client_check_save_schedules (client)) + save_schedules = TRUE; + + if (!itip_component_has_recipients (comp)) save_schedules = TRUE; vtype = e_cal_component_get_vtype (comp); switch (vtype) { case E_CAL_COMPONENT_EVENT: - id = save_schedules ? "calendar:prompt-save-meeting-dragged-or-resized" : - "calendar:prompt-send-updated-meeting-info-dragged-or-resized"; + id = save_schedules ? + "calendar:prompt-save-meeting-dragged-or-resized" : + "calendar:prompt-send-updated-meeting-info-dragged-or-resized"; break; default: g_message ( diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index b1f68d3381..084e519c28 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -718,7 +718,9 @@ task_page_fill_widgets (CompEditorPage *page, comp_editor_set_classification (editor, cl); e_cal_component_get_uid (comp, &uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { icalcomponent_free (icalcomp); task_page_hide_options (tpage); } @@ -2056,15 +2058,15 @@ tpage_get_client_cb (GObject *source_object, ((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)) { + if (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)); priv = tpage->priv; - if (error) { + + if (error != NULL) { GtkWidget *dialog; ECalClient *old_client; diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index 0647f9bcab..ffaba3f84b 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -164,22 +164,19 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, gboolean use_24_hour_format) { struct icaltimetype itt; - icaltimezone *zone; + icaltimezone *zone = NULL; struct tm tm; gchar buf[256]; - if (dt->tzid) { - /* If we can't find the zone, we'll guess its "local" */ - if (!e_cal_client_get_timezone_sync (client, dt->tzid, &zone, NULL, NULL)) - zone = NULL; + if (dt->tzid != NULL) { + e_cal_client_get_timezone_sync ( + client, dt->tzid, &zone, NULL, NULL); } else if (dt->value->is_utc) { zone = icaltimezone_get_utc_timezone (); - } else { - zone = NULL; } itt = *dt->value; - if (zone) + if (zone != NULL) icaltimezone_convert_time (&itt, zone, default_zone); tm = icaltimetype_to_tm (&itt); diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c index cc1e5a46e0..b24d96a40d 100644 --- a/calendar/gui/e-cal-model-calendar.c +++ b/calendar/gui/e-cal-model-calendar.c @@ -329,7 +329,10 @@ cal_model_calendar_set_value_at (ETableModel *etm, const gchar *uid = NULL; e_cal_component_get_uid (comp, &uid); - if (e_cal_client_get_object_sync (comp_data->client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { + e_cal_client_get_object_sync ( + comp_data->client, uid, NULL, + &icalcomp, NULL, NULL); + if (icalcomp != NULL) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index bb9e8f4bbf..c14371c090 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -375,7 +375,7 @@ get_due_status (ECalModelTasks *model, return E_CAL_MODEL_TASKS_DUE_NEVER; else { struct icaltimetype now_tt, due_tt; - icaltimezone *zone; + icaltimezone *zone = NULL; /* Second, is it already completed? */ if (is_complete (comp_data)) @@ -404,7 +404,9 @@ get_due_status (ECalModelTasks *model, /* Get the current time in the same timezone as the DUE date.*/ tzid = icalparameter_get_tzid (param); - if (!e_cal_client_get_timezone_sync (comp_data->client, tzid, &zone, NULL, NULL)) + e_cal_client_get_timezone_sync ( + comp_data->client, tzid, &zone, NULL, NULL); + if (zone == NULL) return E_CAL_MODEL_TASKS_DUE_FUTURE; now_tt = icaltime_current_time_with_zone (zone); diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c index 1b0ee913b3..9557c44f9a 100644 --- a/calendar/gui/e-calendar-selector.c +++ b/calendar/gui/e-calendar-selector.c @@ -47,11 +47,15 @@ calendar_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { gchar *uid; - icalcomponent *tmp_icalcomp; + icalcomponent *tmp_icalcomp = NULL; + gboolean success; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, NULL); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); return e_cal_client_modify_object_sync ( @@ -59,14 +63,15 @@ calendar_selector_update_single_object (ECalClient *client, } uid = NULL; - if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - return FALSE; + success = e_cal_client_create_object_sync ( + client, icalcomp, &uid, NULL, NULL); - if (uid) + if (uid != NULL) { icalcomponent_set_uid (icalcomp, uid); - g_free (uid); + g_free (uid); + } - return TRUE; + return success; } static gboolean @@ -152,6 +157,64 @@ client_connect_cb (GObject *source_object, } static void +calendar_selector_set_shell_view (ECalendarSelector *selector, + EShellView *shell_view) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + g_return_if_fail (selector->priv->shell_view == NULL); + + selector->priv->shell_view = g_object_ref (shell_view); +} + +static void +calendar_selector_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + calendar_selector_set_shell_view ( + E_CALENDAR_SELECTOR (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +calendar_selector_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, + e_calendar_selector_get_shell_view ( + E_CALENDAR_SELECTOR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +calendar_selector_dispose (GObject *object) +{ + ECalendarSelectorPrivate *priv; + + priv = E_CALENDAR_SELECTOR_GET_PRIVATE (object); + + g_clear_object (&priv->shell_view); + + /* Chain up to the parent' s dispose() method. */ + G_OBJECT_CLASS (e_calendar_selector_parent_class)->dispose (object); +} + +static void calendar_selector_constructed (GObject *object) { ESourceSelector *selector; @@ -212,71 +275,6 @@ exit: return success; } -EShellView * -e_calendar_selector_get_shell_view (ECalendarSelector *calendar_selector) -{ - g_return_val_if_fail (E_IS_CALENDAR_SELECTOR (calendar_selector), NULL); - - return calendar_selector->priv->shell_view; -} - -static void -e_calendar_selector_set_shell_view (ECalendarSelector *calendar_selector, - EShellView *shell_view) -{ - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_return_if_fail (calendar_selector->priv->shell_view == NULL); - - calendar_selector->priv->shell_view = g_object_ref (shell_view); -} - -static void -calendar_selector_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - e_calendar_selector_set_shell_view ( - E_CALENDAR_SELECTOR (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -calendar_selector_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - g_value_set_object ( - value, - e_calendar_selector_get_shell_view (E_CALENDAR_SELECTOR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -calendar_selector_dispose (GObject *object) -{ - ECalendarSelectorPrivate *priv; - - priv = E_CALENDAR_SELECTOR_GET_PRIVATE (object); - - g_clear_object (&priv->shell_view); - - /* Chain up to the parent' s dispose() method. */ - G_OBJECT_CLASS (e_calendar_selector_parent_class)->dispose (object); -} - static void e_calendar_selector_class_init (ECalendarSelectorClass *class) { @@ -321,7 +319,7 @@ e_calendar_selector_init (ECalendarSelector *selector) GtkWidget * e_calendar_selector_new (EClientCache *client_cache, - EShellView *shell_view) + EShellView *shell_view) { ESourceRegistry *registry; GtkWidget *widget; @@ -343,3 +341,12 @@ e_calendar_selector_new (EClientCache *client_cache, return widget; } + +EShellView * +e_calendar_selector_get_shell_view (ECalendarSelector *selector) +{ + g_return_val_if_fail (E_IS_CALENDAR_SELECTOR (selector), NULL); + + return selector->priv->shell_view; +} + diff --git a/calendar/gui/e-calendar-selector.h b/calendar/gui/e-calendar-selector.h index 2e39c4b571..6429cb0110 100644 --- a/calendar/gui/e-calendar-selector.h +++ b/calendar/gui/e-calendar-selector.h @@ -62,7 +62,7 @@ GType e_calendar_selector_get_type (void); GtkWidget * e_calendar_selector_new (EClientCache *client_cache, EShellView *shell_backend); EShellView * e_calendar_selector_get_shell_view - (ECalendarSelector *calendar_selector); + (ECalendarSelector *selector); G_END_DECLS diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 61a88850cd..b60dee47ee 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -196,11 +196,12 @@ calendar_view_delete_event (ECalendarView *cal_view, comp, retract_comment, CALOBJ_MOD_ALL); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users, - &mod_comp, NULL, &error)) { + e_cal_client_send_objects_sync ( + event->comp_data->client, icalcomp, + &users, &mod_comp, NULL, &error); + if (error != NULL) { delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); - error = NULL; } else { if (mod_comp) @@ -527,10 +528,13 @@ add_related_timezones (icalcomponent *des_icalcomp, GError *error = NULL; icaltimezone *zone = NULL; - if (!e_cal_client_get_timezone_sync (client, tzid, &zone, NULL, &error)) { - g_warning ("%s: Cannot get timezone for '%s'. %s", G_STRFUNC, tzid, error ? error->message : ""); - if (error) - g_error_free (error); + e_cal_client_get_timezone_sync ( + client, tzid, &zone, NULL, &error); + if (error != NULL) { + g_warning ( + "%s: Cannot get timezone for '%s'. %s", + G_STRFUNC, tzid, error->message); + g_error_free (error); } else if (zone && icalcomponent_get_timezone (des_icalcomp, icaltimezone_get_tzid (zone)) == NULL) { /* do not duplicate timezones in the component */ @@ -660,12 +664,24 @@ clipboard_get_calendar_data (ECalendarView *cal_view, zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - if (!e_cal_client_add_timezone_sync (client, zone, NULL, &error)) { - icalproperty *tzidprop = icalcomponent_get_first_property (subcomp, ICAL_TZID_PROPERTY); - - g_warning ("%s: Add zone '%s' failed. %s", G_STRFUNC, tzidprop ? icalproperty_get_tzid (tzidprop) : "???", error ? error->message : ""); - if (error) - g_error_free (error); + e_cal_client_add_timezone_sync ( + client, zone, NULL, &error); + if (error != NULL) { + icalproperty *tzidprop; + const gchar *tzid; + + tzidprop = icalcomponent_get_first_property ( + subcomp, ICAL_TZID_PROPERTY); + if (tzidprop != NULL) + tzid = icalproperty_get_tzid (tzidprop); + else + tzid = "???"; + + g_warning ( + "%s: Add zone '%s' failed. %s", + G_STRFUNC, tzid, error->message); + + g_error_free (error); } icaltimezone_free (zone, 1); @@ -778,14 +794,25 @@ calendar_view_paste_clipboard (ESelectable *selectable) /* when cutting detached instances, only cut that instance */ rid = e_cal_component_get_recurid_as_string (comp); - if (e_cal_client_get_object_sync (comp_data->client, uid, rid, &icalcomp, NULL, NULL)) { - e_cal_client_remove_object_sync (comp_data->client, uid, rid, CALOBJ_MOD_THIS, NULL, &error); + e_cal_client_get_object_sync ( + comp_data->client, uid, rid, + &icalcomp, NULL, NULL); + if (icalcomp != NULL) { + e_cal_client_remove_object_sync ( + comp_data->client, uid, rid, + CALOBJ_MOD_THIS, NULL, &error); icalcomponent_free (icalcomp); - } else - e_cal_client_remove_object_sync (comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error); + } else { + e_cal_client_remove_object_sync ( + comp_data->client, uid, NULL, + CALOBJ_MOD_ALL, NULL, &error); + } g_free (rid); - } else - e_cal_client_remove_object_sync (comp_data->client, uid, NULL, CALOBJ_MOD_ALL, NULL, &error); + } else { + e_cal_client_remove_object_sync ( + comp_data->client, uid, NULL, + CALOBJ_MOD_ALL, NULL, &error); + } delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); @@ -1139,7 +1166,10 @@ e_calendar_view_add_event (ECalendarView *cal_view, e_cal_component_commit_sequence (comp); uid = NULL; - if (e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) { + e_cal_client_create_object_sync ( + client, e_cal_component_get_icalcomponent (comp), + &uid, NULL, &error); + if (error == NULL) { gboolean strip_alarms = TRUE; if (uid) { @@ -1159,9 +1189,10 @@ e_calendar_view_add_event (ECalendarView *cal_view, FALSE); } } else { - g_message (G_STRLOC ": Could not create the object! %s", error ? error->message : ""); - if (error) - g_error_free (error); + g_message ( + "%s: Could not create the object! %s", + G_STRFUNC, error->message); + g_error_free (error); ret = FALSE; } @@ -1396,11 +1427,12 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) comp, retract_comment, CALOBJ_MOD_THIS); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_client_send_objects_sync (event->comp_data->client, icalcomp, &users, - &mod_comp, NULL, &error)) { + e_cal_client_send_objects_sync ( + event->comp_data->client, icalcomp, + &users, &mod_comp, NULL, &error); + if (error != NULL) { delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); - error = NULL; } else { if (mod_comp) icalcomponent_free (mod_comp); @@ -1429,7 +1461,7 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) GError *error = NULL; e_cal_client_get_timezone_sync (event->comp_data->client, dt.tzid, &zone, NULL, &error); - if (error) { + if (error != NULL) { zone = e_calendar_view_get_timezone (cal_view); g_clear_error (&error); } @@ -1839,7 +1871,9 @@ e_calendar_view_send (ECalendarView *cal_view, const gchar *uid = NULL; e_cal_component_get_uid (comp, &uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL) && icalcomp) { + e_cal_client_get_object_sync ( + client, uid, NULL, &icalcomp, NULL, NULL); + if (icalcomp != NULL) { send_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (send_comp, icalcomp)) { icalcomponent_free (icalcomp); diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index 695188f6cd..4e749f13d7 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -2063,15 +2063,17 @@ start_async_read (const gchar *uri, istream = G_INPUT_STREAM (g_file_read (file, NULL, &error)); - if (error && g_error_matches (error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) { + if (g_error_matches (error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) { download_with_libsoup (uri, qdata); g_object_unref (file); g_error_free (error); return; } - if (error) { - g_warning ("Unable to access free/busy url: %s", error->message); + if (error != NULL) { + g_warning ( + "Unable to access free/busy url: %s", + error->message); g_error_free (error); process_callbacks (qdata); g_object_unref (file); @@ -2081,10 +2083,11 @@ start_async_read (const gchar *uri, if (!istream) { process_callbacks (qdata); g_object_unref (file); - } else + } else { g_input_stream_read_async ( istream, qdata->buffer, BUF_SIZE - 1, G_PRIORITY_DEFAULT, NULL, async_read, qdata); + } } void diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c index a1cc8a7e30..8952a67258 100644 --- a/calendar/gui/e-memo-list-selector.c +++ b/calendar/gui/e-memo-list-selector.c @@ -49,27 +49,31 @@ static gboolean memo_list_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { - gchar *uid = NULL; - icalcomponent *tmp_icalcomp; + gchar *uid; + icalcomponent *tmp_icalcomp = NULL; + gboolean success; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, NULL); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); return e_cal_client_modify_object_sync ( client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); } - if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - return FALSE; + success = e_cal_client_create_object_sync ( + client, icalcomp, &uid, NULL, NULL); - if (uid) + if (uid != NULL) { icalcomponent_set_uid (icalcomp, uid); + g_free (uid); + } - g_free (uid); - - return TRUE; + return success; } static gboolean @@ -184,13 +188,23 @@ memo_list_selector_process_data (ESourceSelector *selector, if (old_uid == NULL) old_uid = g_strdup (uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) { + success = e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, &error); + + /* Sanity check. */ + g_return_val_if_fail ( + (success && (error == NULL)) || + (!success && (error != NULL)), FALSE); + + if (success) { icalcomponent_free (tmp_icalcomp); - success = TRUE; goto exit; } - if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) + g_clear_error (&error); + + if (error != NULL) { g_message ( "Failed to search the object in destination " "task list: %s", error->message); @@ -198,9 +212,6 @@ memo_list_selector_process_data (ESourceSelector *selector, goto exit; } - if (error) - g_error_free (error); - success = memo_list_selector_update_objects (client, icalcomp); if (!success || action != GDK_ACTION_MOVE) @@ -222,8 +233,7 @@ exit: return success; } -struct DropData -{ +struct DropData { ESourceSelector *selector; GdkDragAction action; GSList *list; @@ -290,71 +300,24 @@ exit: } static void -memo_list_selector_constructed (GObject *object) -{ - ESourceSelector *selector; - ESourceRegistry *registry; - ESource *source; - - selector = E_SOURCE_SELECTOR (object); - registry = e_source_selector_get_registry (selector); - source = e_source_registry_ref_default_memo_list (registry); - e_source_selector_set_primary_selection (selector, source); - g_object_unref (source); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_memo_list_selector_parent_class)-> - constructed (object); -} - -static gboolean -memo_list_selector_data_dropped (ESourceSelector *selector, - GtkSelectionData *selection_data, - ESource *destination, - GdkDragAction action, - guint info) -{ - struct DropData *dd; - - dd = g_new0 (struct DropData, 1); - dd->selector = g_object_ref (selector); - dd->action = action; - dd->list = cal_comp_selection_get_string_list (selection_data); - - e_client_selector_get_client ( - E_CLIENT_SELECTOR (selector), destination, NULL, - client_connect_for_drop_cb, dd); - - return TRUE; -} - -EShellView * -e_memo_list_selector_get_shell_view (EMemoListSelector *memo_list_selector) -{ - g_return_val_if_fail (E_IS_MEMO_LIST_SELECTOR (memo_list_selector), NULL); - - return memo_list_selector->priv->shell_view; -} - -static void -e_memo_list_selector_set_shell_view (EMemoListSelector *memo_list_selector, - EShellView *shell_view) +memo_list_selector_set_shell_view (EMemoListSelector *selector, + EShellView *shell_view) { g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_return_if_fail (memo_list_selector->priv->shell_view == NULL); + g_return_if_fail (selector->priv->shell_view == NULL); - memo_list_selector->priv->shell_view = g_object_ref (shell_view); + selector->priv->shell_view = g_object_ref (shell_view); } static void memo_list_selector_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_SHELL_VIEW: - e_memo_list_selector_set_shell_view ( + memo_list_selector_set_shell_view ( E_MEMO_LIST_SELECTOR (object), g_value_get_object (value)); return; @@ -365,15 +328,16 @@ memo_list_selector_set_property (GObject *object, static void memo_list_selector_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_SHELL_VIEW: g_value_set_object ( value, - e_memo_list_selector_get_shell_view (E_MEMO_LIST_SELECTOR (object))); + e_memo_list_selector_get_shell_view ( + E_MEMO_LIST_SELECTOR (object))); return; } @@ -389,11 +353,50 @@ memo_list_selector_dispose (GObject *object) g_clear_object (&priv->shell_view); - /* Chain up to the parent' s dispose() method. */ + /* Chain up to the parent's dispose() method. */ G_OBJECT_CLASS (e_memo_list_selector_parent_class)->dispose (object); } static void +memo_list_selector_constructed (GObject *object) +{ + ESourceSelector *selector; + ESourceRegistry *registry; + ESource *source; + + selector = E_SOURCE_SELECTOR (object); + registry = e_source_selector_get_registry (selector); + source = e_source_registry_ref_default_memo_list (registry); + e_source_selector_set_primary_selection (selector, source); + g_object_unref (source); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (e_memo_list_selector_parent_class)-> + constructed (object); +} + +static gboolean +memo_list_selector_data_dropped (ESourceSelector *selector, + GtkSelectionData *selection_data, + ESource *destination, + GdkDragAction action, + guint info) +{ + struct DropData *dd; + + dd = g_new0 (struct DropData, 1); + dd->selector = g_object_ref (selector); + dd->action = action; + dd->list = cal_comp_selection_get_string_list (selection_data); + + e_client_selector_get_client ( + E_CLIENT_SELECTOR (selector), destination, NULL, + client_connect_for_drop_cb, dd); + + return TRUE; +} + +static void e_memo_list_selector_class_init (EMemoListSelectorClass *class) { GObjectClass *object_class; @@ -437,7 +440,7 @@ e_memo_list_selector_init (EMemoListSelector *selector) GtkWidget * e_memo_list_selector_new (EClientCache *client_cache, - EShellView *shell_view) + EShellView *shell_view) { ESourceRegistry *registry; GtkWidget *widget; @@ -458,3 +461,12 @@ e_memo_list_selector_new (EClientCache *client_cache, return widget; } + +EShellView * +e_memo_list_selector_get_shell_view (EMemoListSelector *selector) +{ + g_return_val_if_fail (E_IS_MEMO_LIST_SELECTOR (selector), NULL); + + return selector->priv->shell_view; +} + diff --git a/calendar/gui/e-memo-list-selector.h b/calendar/gui/e-memo-list-selector.h index 0a68a76965..3199fef5ed 100644 --- a/calendar/gui/e-memo-list-selector.h +++ b/calendar/gui/e-memo-list-selector.h @@ -67,7 +67,7 @@ GType e_memo_list_selector_get_type (void); GtkWidget * e_memo_list_selector_new (EClientCache *client_cache, EShellView *shell_view); EShellView * e_memo_list_selector_get_shell_view - (EMemoListSelector *memo_list_selector); + (EMemoListSelector *selector); G_END_DECLS diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 4609356914..5afff70b1b 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -905,10 +905,11 @@ clipboard_get_calendar_data (EMemoTable *memo_table, /* FIXME Should we convert start/due/complete * times? Also, need error handling.*/ - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error)) - uid = NULL; + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (tmp_comp), + NULL, NULL, &error); - g_free (uid); g_object_unref (tmp_comp); if (error != NULL) { @@ -929,12 +930,13 @@ clipboard_get_calendar_data (EMemoTable *memo_table, uid = e_cal_component_gen_uid (); e_cal_component_set_uid (comp, (const gchar *) uid); g_free (uid); - uid = NULL; - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) - uid = NULL; - g_free (uid); + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (comp), + NULL, NULL, &error); + g_object_unref (comp); if (error != NULL) { diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c index dc1340eb00..c35a6610ad 100644 --- a/calendar/gui/e-task-list-selector.c +++ b/calendar/gui/e-task-list-selector.c @@ -49,27 +49,31 @@ static gboolean task_list_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { - gchar *uid = NULL; - icalcomponent *tmp_icalcomp; + gchar *uid; + icalcomponent *tmp_icalcomp = NULL; + gboolean success; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, NULL); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); return e_cal_client_modify_object_sync ( client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); } - if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - return FALSE; + success = e_cal_client_create_object_sync ( + client, icalcomp, &uid, NULL, NULL); - if (uid) + if (uid != NULL) { icalcomponent_set_uid (icalcomp, uid); + g_free (uid); + } - g_free (uid); - - return TRUE; + return success; } static gboolean @@ -185,13 +189,19 @@ task_list_selector_process_data (ESourceSelector *selector, if (old_uid == NULL) old_uid = g_strdup (uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, &error); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); success = TRUE; goto exit; } - if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { + g_clear_error (&error); + + } else if (error != NULL) { g_message ( "Failed to search the object in destination " "task list: %s", error->message); @@ -199,10 +209,6 @@ task_list_selector_process_data (ESourceSelector *selector, goto exit; } - if (error) - g_error_free (error); - error = NULL; - success = task_list_selector_update_objects (client, icalcomp); if (!success || action != GDK_ACTION_MOVE) @@ -224,8 +230,7 @@ exit: return success; } -struct DropData -{ +struct DropData { ESourceSelector *selector; GdkDragAction action; GSList *list; @@ -292,6 +297,51 @@ exit: } static void +task_list_selector_set_shell_view (ETaskListSelector *selector, + EShellView *shell_view) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + g_return_if_fail (selector->priv->shell_view == NULL); + + selector->priv->shell_view = g_object_ref (shell_view); +} + +static void +task_list_selector_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + task_list_selector_set_shell_view ( + E_TASK_LIST_SELECTOR (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +task_list_selector_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL_VIEW: + g_value_set_object ( + value, + e_task_list_selector_get_shell_view ( + E_TASK_LIST_SELECTOR (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void task_list_selector_constructed (GObject *object) { ESourceSelector *selector; @@ -330,58 +380,6 @@ task_list_selector_data_dropped (ESourceSelector *selector, return TRUE; } -EShellView * -e_task_list_selector_get_shell_view (ETaskListSelector *task_list_selector) -{ - g_return_val_if_fail (E_IS_TASK_LIST_SELECTOR (task_list_selector), NULL); - - return task_list_selector->priv->shell_view; -} - -static void -e_task_list_selector_set_shell_view (ETaskListSelector *task_list_selector, - EShellView *shell_view) -{ - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_return_if_fail (task_list_selector->priv->shell_view == NULL); - - task_list_selector->priv->shell_view = g_object_ref (shell_view); -} - -static void -task_list_selector_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - e_task_list_selector_set_shell_view ( - E_TASK_LIST_SELECTOR (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -task_list_selector_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - g_value_set_object ( - value, - e_task_list_selector_get_shell_view (E_TASK_LIST_SELECTOR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - static void task_list_selector_dispose (GObject *object) { @@ -439,7 +437,7 @@ e_task_list_selector_init (ETaskListSelector *selector) GtkWidget * e_task_list_selector_new (EClientCache *client_cache, - EShellView *shell_view) + EShellView *shell_view) { ESourceRegistry *registry; GtkWidget *widget; @@ -460,3 +458,12 @@ e_task_list_selector_new (EClientCache *client_cache, return widget; } + +EShellView * +e_task_list_selector_get_shell_view (ETaskListSelector *selector) +{ + g_return_val_if_fail (E_IS_TASK_LIST_SELECTOR (selector), NULL); + + return selector->priv->shell_view; +} + diff --git a/calendar/gui/e-task-list-selector.h b/calendar/gui/e-task-list-selector.h index c296d7d973..0f42b42ef0 100644 --- a/calendar/gui/e-task-list-selector.h +++ b/calendar/gui/e-task-list-selector.h @@ -67,7 +67,7 @@ GType e_task_list_selector_get_type (void); GtkWidget * e_task_list_selector_new (EClientCache *client_cache, EShellView *shell_view); EShellView * e_task_list_selector_get_shell_view - (ETaskListSelector *task_list_selector); + (ETaskListSelector *selector); G_END_DECLS diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index ddcc54dce0..d60ff21d34 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -1203,8 +1203,10 @@ clipboard_get_calendar_data (ETaskTable *task_table, /* FIXME should we convert start/due/complete * times? Also, need error handling. */ - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (tmp_comp), &uid, NULL, &error)) - uid = NULL; + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (tmp_comp), + NULL, NULL, &error); if (error != NULL) { g_warning ( @@ -1214,7 +1216,6 @@ clipboard_get_calendar_data (ETaskTable *task_table, } g_object_unref (tmp_comp); - g_free (uid); } subcomp = icalcomponent_get_next_component ( vcal_comp, ICAL_ANY_COMPONENT); @@ -1229,8 +1230,10 @@ clipboard_get_calendar_data (ETaskTable *task_table, g_free (uid); uid = NULL; - if (!e_cal_client_create_object_sync (client, e_cal_component_get_icalcomponent (comp), &uid, NULL, &error)) - uid = NULL; + e_cal_client_create_object_sync ( + client, + e_cal_component_get_icalcomponent (comp), + NULL, NULL, &error); if (error != NULL) { g_warning ( @@ -1240,7 +1243,6 @@ clipboard_get_calendar_data (ETaskTable *task_table, } g_object_unref (comp); - g_free (uid); } task_table_emit_status_message (task_table, NULL, -1.0); @@ -1414,10 +1416,12 @@ task_table_delete_selection (ESelectable *selectable) add_retract_data (comp, retract_comment); icalcomp = e_cal_component_get_icalcomponent (comp); icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL); - if (!e_cal_client_send_objects_sync (comp_data->client, icalcomp, &users, &mod_comp, NULL, &error)) { + e_cal_client_send_objects_sync ( + comp_data->client, icalcomp, + &users, &mod_comp, NULL, &error); + if (error != NULL) { delete_error_dialog (error, E_CAL_COMPONENT_TODO); g_clear_error (&error); - error = NULL; } else { if (mod_comp) @@ -1704,17 +1708,21 @@ hide_completed_rows_ready (GObject *source_object, e_cal_client_get_object_list_finish ( E_CAL_CLIENT (source_object), result, &objects, &error); - if (error != NULL) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && - !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { - ESource *source = e_client_get_source (E_CLIENT (source_object)); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; + + } else if (error != NULL) { + ESource *source; + + source = e_client_get_source (E_CLIENT (source_object)); + + g_warning ( + "%s: Could not get the objects from '%s': %s", + G_STRFUNC, + e_source_get_display_name (source), + error->message); - g_debug ( - "%s: Could not get the objects from '%s': %s", - G_STRFUNC, - e_source_get_display_name (source), - error->message); - } g_error_free (error); return; } @@ -1770,17 +1778,21 @@ show_completed_rows_ready (GObject *source_object, e_cal_client_get_object_list_finish ( E_CAL_CLIENT (source_object), result, &objects, &error); - if (error != NULL) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && - !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED)) { - ESource *source = e_client_get_source (E_CLIENT (source_object)); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; + + } else if (error != NULL) { + ESource *source; + + source = e_client_get_source (E_CLIENT (source_object)); + + g_debug ( + "%s: Could not get the objects from '%s': %s", + G_STRFUNC, + e_source_get_display_name (source), + error->message); - g_debug ( - "%s: Could not get the objects from '%s': %s", - G_STRFUNC, - e_source_get_display_name (source), - error->message); - } g_error_free (error); return; } diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index b00a3afa18..3751e64f25 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -4372,9 +4372,9 @@ e_week_view_on_editing_stopped (EWeekView *week_view, E_CALENDAR_VIEW (week_view), client); } - if (uid) - g_free (uid); - if (error) + g_free (uid); + + if (error != NULL) g_error_free (error); /* we remove the object since we either got the update from the server or failed */ diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 02f346d0d8..d8cc740a3b 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -1133,30 +1133,29 @@ comp_server_send (ECalComponentItipMethod method, top_level = comp_toplevel_with_zones (method, comp, cal_client, zones); d (printf ("itip-utils.c: comp_server_send: calling e_cal_send_objects... \n")); - if (!e_cal_client_send_objects_sync (cal_client, top_level, users, &returned_icalcomp, NULL, &error)) { - /* FIXME Really need a book problem status code */ - d (printf ("itip-utils.c: return value from e_cal_send_objects is: %d", error->code)); - if (error) { - if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS)) { - e_notice ( - NULL, GTK_MESSAGE_ERROR, - _("Unable to book a resource, the " - "new event collides with some other.")); - } else { - e_notice ( - NULL, GTK_MESSAGE_ERROR, - _("Unable to book a resource, error: %s"), error->message); - } - retval = FALSE; - } - } else { - d (printf ("itip-utils.c: e_cal_send_objects returned without errors\n")); + e_cal_client_send_objects_sync ( + cal_client, top_level, users, + &returned_icalcomp, NULL, &error); + + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS)) { + e_notice ( + NULL, GTK_MESSAGE_ERROR, + _("Unable to book a resource, the " + "new event collides with some other.")); + g_error_free (error); + retval = FALSE; + + } else if (error != NULL) { + e_notice ( + NULL, GTK_MESSAGE_ERROR, + _("Unable to book a resource, error: %s"), + error->message); + g_error_free (error); + retval = FALSE; } - g_clear_error (&error); - - if (returned_icalcomp) + if (returned_icalcomp != NULL) icalcomponent_free (returned_icalcomp); icalcomponent_free (top_level); diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c index 3cda9da6ac..2368643877 100644 --- a/calendar/importers/icalendar-importer.c +++ b/calendar/importers/icalendar-importer.c @@ -854,9 +854,9 @@ default_client_connect_cb (GObject *source_object, /* Client may be NULL; don't use a type cast macro. */ odsd->opened_cb ((ECalClient *) client, error, odsd->ici); - if (client) - g_object_unref (client); - if (error) + g_clear_object (&client); + + if (error != NULL) g_error_free (error); g_free (odsd); |