From c1e412618a9b31b0810be13f9fb1fbac58f8e890 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 1 Nov 2010 16:32:21 -0400 Subject: Rename CalUnits to EDurationType. And move the definition to e-util-enums.h so we get a GType for it. --- calendar/gui/comp-util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 2254d49cf6..d0182a0f8d 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -290,7 +290,7 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) icalcomponent *icalcomp; ECalComponent *comp; gint interval; - CalUnits units; + EDurationType units; ECalComponentAlarm *alarm; icalproperty *icalprop; ECalComponentAlarmTrigger trigger; @@ -331,15 +331,15 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) trigger.u.rel_duration.is_neg = TRUE; switch (units) { - case CAL_MINUTES: + case E_DURATION_MINUTES: trigger.u.rel_duration.minutes = interval; break; - case CAL_HOURS: + case E_DURATION_HOURS: trigger.u.rel_duration.hours = interval; break; - case CAL_DAYS: + case E_DURATION_DAYS: trigger.u.rel_duration.days = interval; break; -- cgit v1.2.3 From dce5bdc3699faf592453492fe201606ed47e06b9 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 2 Nov 2010 11:49:38 -0400 Subject: Move calendar preferences to the calendar module. Continue replacing the use of calendar-config functions with GObject property bindings to EShellSettings properties. --- calendar/gui/comp-util.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index d0182a0f8d..7dae1826de 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -285,12 +285,14 @@ is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client) * Return value: A newly-created calendar component. **/ ECalComponent * -cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) +cal_comp_event_new_with_defaults (ECal *client, + gboolean all_day, + gboolean use_default_reminder, + gint default_reminder_interval, + EDurationType default_reminder_units) { icalcomponent *icalcomp; ECalComponent *comp; - gint interval; - EDurationType units; ECalComponentAlarm *alarm; icalproperty *icalprop; ECalComponentAlarmTrigger trigger; @@ -305,12 +307,9 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT); } - if (all_day || !calendar_config_get_use_default_reminder ()) + if (all_day || !use_default_reminder) return comp; - interval = calendar_config_get_default_reminder_interval (); - units = calendar_config_get_default_reminder_units (); - alarm = e_cal_component_alarm_new (); /* We don't set the description of the alarm; we'll copy it from the @@ -330,21 +329,21 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) trigger.u.rel_duration.is_neg = TRUE; - switch (units) { + switch (default_reminder_units) { case E_DURATION_MINUTES: - trigger.u.rel_duration.minutes = interval; + trigger.u.rel_duration.minutes = default_reminder_interval; break; case E_DURATION_HOURS: - trigger.u.rel_duration.hours = interval; + trigger.u.rel_duration.hours = default_reminder_interval; break; case E_DURATION_DAYS: - trigger.u.rel_duration.days = interval; + trigger.u.rel_duration.days = default_reminder_interval; break; default: - g_warning ("wrong units %d\n", units); + g_warning ("wrong units %d\n", default_reminder_units); } e_cal_component_alarm_set_trigger (alarm, trigger); @@ -356,18 +355,22 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) } ECalComponent * -cal_comp_event_new_with_current_time (ECal *client, gboolean all_day) +cal_comp_event_new_with_current_time (ECal *client, + gboolean all_day, + icaltimezone *zone, + gboolean use_default_reminder, + gint default_reminder_interval, + EDurationType default_reminder_units) { ECalComponent *comp; struct icaltimetype itt; ECalComponentDateTime dt; - icaltimezone *zone; - - comp = cal_comp_event_new_with_defaults (client, all_day); - g_return_val_if_fail (comp, NULL); + comp = cal_comp_event_new_with_defaults ( + client, all_day, use_default_reminder, + default_reminder_interval, default_reminder_units); + g_return_val_if_fail (comp != NULL, NULL); - zone = calendar_config_get_icaltimezone (); if (all_day) { itt = icaltime_from_timet_with_zone (time (NULL), 1, zone); -- cgit v1.2.3 From ab870b27cd05cc39e4755de9c6d9e02944977c17 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 1 Mar 2011 13:04:09 -0500 Subject: Fix Gtk-Doc comment notation. Seeing lots of what I assume to be doxygen syntax in comment blocks. --- calendar/gui/comp-util.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 7dae1826de..36f5a841e4 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -527,11 +527,11 @@ cal_comp_util_get_n_icons (ECalComponent *comp, GSList **pixbufs) /** * cal_comp_selection_set_string_list - * Stores list of strings into selection target data. - * Use @ref cal_comp_selection_get_string_list to get this list from target data. + * @data: Selection data, where to put list of strings. + * @str_list: List of strings. (Each element is of type const gchar *.) * - * @param data Selection data, where to put list of strings. - * @param str_list List of strings. (Each element is of type const gchar *.) + * Stores list of strings into selection target data. Use + * cal_comp_selection_get_string_list() to get this list from target data. **/ void cal_comp_selection_set_string_list (GtkSelectionData *data, GSList *str_list) @@ -561,13 +561,14 @@ cal_comp_selection_set_string_list (GtkSelectionData *data, GSList *str_list) /** * cal_comp_selection_get_string_list + * @data: Selection data, where to put list of strings. + * * Converts data from selection to list of strings. Data should be assigned - * to selection data with @ref cal_comp_selection_set_string_list. - * Each string in newly created list should be freed by g_free. - * List itself should be freed by g_slist_free. + * to selection data with cal_comp_selection_set_string_list(). + * Each string in newly created list should be freed by g_free(). + * List itself should be freed by g_slist_free(). * - * @param data Selection data, where to put list of strings. - * @return Newly allocated GSList of strings. + * Returns: Newly allocated #GSList of strings. **/ GSList * cal_comp_selection_get_string_list (GtkSelectionData *selection_data) @@ -630,10 +631,11 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) /** * cal_comp_set_dtstart_with_oldzone: + * @client: ECal structure, to retrieve timezone from, when required. + * @comp: Component, where make the change. + * @pdate: Value, to change to. + * * Changes 'dtstart' of the component, but converts time to the old timezone. - * @param client ECal structure, to retrieve timezone from, when required. - * @param comp Component, where make the change. - * @param pdate Value, to change to. **/ void cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate) @@ -655,10 +657,11 @@ cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECal /** * cal_comp_set_dtend_with_oldzone: + * @client: ECal structure, to retrieve timezone from, when required. + * @comp: Component, where make the change. + * @pdate: Value, to change to. + * * Changes 'dtend' of the component, but converts time to the old timezone. - * @param client ECal structure, to retrieve timezone from, when required. - * @param comp Component, where make the change. - * @param pdate Value, to change to. **/ void cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate) @@ -748,13 +751,15 @@ update_objects (ECal *client, icalcomponent *icalcomp) /** * cal_comp_process_source_list_drop: + * @destination: Where to put the component. + * @comp: Component to move/copy. + * @action: What to do. + * @source_uid: Where the component comes from; used when moving. + * @source_list: The ESourceList over which the event was called. + * * Processes the drop signal over the ESourceList. - * @param destination Where to put the component. - * @param comp Component to move/copy. - * @param action What to do. - * @param source_uid Where the component comes from; used when moving. - * @param source_list The ESourceList over which the event was called. - * @return Whether was the operation successful. + * + * Returns: Whether was the operation successful. **/ gboolean cal_comp_process_source_list_drop (ECal *destination, icalcomponent *comp, GdkDragAction action, const gchar *source_uid, ESourceList *source_list) -- cgit v1.2.3 From 8a72144701ecac1c908b37a78e6663fabdcbc508 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 1 Mar 2011 14:32:51 -0500 Subject: Remove unused cal_comp_process_source_list_drop(). --- calendar/gui/comp-util.c | 190 ----------------------------------------------- 1 file changed, 190 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 36f5a841e4..68b5ef3307 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -681,196 +681,6 @@ cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalCo e_cal_component_free_datetime (&olddate); } -static gboolean -update_single_object (ECal *client, icalcomponent *icalcomp, gboolean fail_on_modify) -{ - const gchar *uid; - gchar *tmp; - icalcomponent *tmp_icalcomp; - gboolean res; - - uid = icalcomponent_get_uid (icalcomp); - - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) { - if (fail_on_modify) - return FALSE; - - return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL); - } - - tmp = NULL; - res = e_cal_create_object (client, icalcomp, &tmp, NULL); - - g_free (tmp); - - return res; -} - -static gboolean -update_objects (ECal *client, icalcomponent *icalcomp) -{ - icalcomponent *subcomp; - icalcomponent_kind kind; - - kind = icalcomponent_isa (icalcomp); - if (kind == ICAL_VTODO_COMPONENT || - kind == ICAL_VEVENT_COMPONENT || - kind == ICAL_VJOURNAL_COMPONENT) - return update_single_object (client, icalcomp, kind == ICAL_VJOURNAL_COMPONENT); - else if (kind != ICAL_VCALENDAR_COMPONENT) - return FALSE; - - subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT); - while (subcomp) { - gboolean success; - - kind = icalcomponent_isa (subcomp); - if (kind == ICAL_VTIMEZONE_COMPONENT) { - icaltimezone *zone; - - zone = icaltimezone_new (); - icaltimezone_set_component (zone, subcomp); - - success = e_cal_add_timezone (client, zone, NULL); - icaltimezone_free (zone, 1); - if (!success) - return success; - } else if (kind == ICAL_VTODO_COMPONENT || - kind == ICAL_VEVENT_COMPONENT || - kind == ICAL_VJOURNAL_COMPONENT) { - success = update_single_object (client, subcomp, kind == ICAL_VJOURNAL_COMPONENT); - if (!success) - return success; - } - - subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT); - } - - return TRUE; -} - -/** - * cal_comp_process_source_list_drop: - * @destination: Where to put the component. - * @comp: Component to move/copy. - * @action: What to do. - * @source_uid: Where the component comes from; used when moving. - * @source_list: The ESourceList over which the event was called. - * - * Processes the drop signal over the ESourceList. - * - * Returns: Whether was the operation successful. - **/ -gboolean -cal_comp_process_source_list_drop (ECal *destination, icalcomponent *comp, GdkDragAction action, const gchar *source_uid, ESourceList *source_list) -{ - const gchar * uid; - gchar *old_uid = NULL; - icalcomponent *tmp_icalcomp = NULL; - GError *error = NULL; - gboolean success = FALSE; - - g_return_val_if_fail (destination != NULL, FALSE); - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (source_uid != NULL, FALSE); - g_return_val_if_fail (source_list != NULL, FALSE); - - /* FIXME deal with GDK_ACTION_ASK */ - if (action == GDK_ACTION_COPY) { - gchar *tmp; - - old_uid = g_strdup (icalcomponent_get_uid (comp)); - tmp = e_cal_component_gen_uid (); - - icalcomponent_set_uid (comp, tmp); - g_free (tmp); - } - - uid = icalcomponent_get_uid (comp); - if (!old_uid) - old_uid = g_strdup (uid); - - if (!e_cal_get_object (destination, uid, NULL, &tmp_icalcomp, &error)) { - if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND)) { - switch (e_cal_get_source_type (destination)) { - case E_CAL_SOURCE_TYPE_EVENT: - g_message ("Failed to search the object in destination event list: %s", error->message); - break; - case E_CAL_SOURCE_TYPE_TODO: - g_message ("Failed to search the object in destination task list: %s", error->message); - break; - case E_CAL_SOURCE_TYPE_JOURNAL: - g_message ("Failed to search the object in destination memo list: %s", error->message); - break; - default: - break; - } - } else { - /* this will report success by last item, but we don't care */ - success = update_objects (destination, comp); - - if (success && action == GDK_ACTION_MOVE) { - /* remove components rather here, because we know which has been moved */ - ESource *source_source; - ECal *source_client; - - source_source = e_source_list_peek_source_by_uid (source_list, source_uid); - - if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) { - source_client = e_auth_new_cal_from_source (source_source, e_cal_get_source_type (destination)); - - if (source_client) { - gboolean read_only = TRUE; - - e_cal_is_read_only (source_client, &read_only, NULL); - - if (!read_only && e_cal_open (source_client, TRUE, NULL)) - e_cal_remove_object (source_client, old_uid, NULL); - else if (!read_only) { - switch (e_cal_get_source_type (destination)) { - case E_CAL_SOURCE_TYPE_EVENT: - g_message ("Cannot open source client to remove old event"); - break; - case E_CAL_SOURCE_TYPE_TODO: - g_message ("Cannot open source client to remove old task"); - break; - case E_CAL_SOURCE_TYPE_JOURNAL: - g_message ("Cannot open source client to remove old memo"); - break; - default: - break; - } - } - - g_object_unref (source_client); - } else { - switch (e_cal_get_source_type (destination)) { - case E_CAL_SOURCE_TYPE_EVENT: - g_message ("Cannot create source client to remove old event"); - break; - case E_CAL_SOURCE_TYPE_TODO: - g_message ("Cannot create source client to remove old task"); - break; - case E_CAL_SOURCE_TYPE_JOURNAL: - g_message ("Cannot create source client to remove old memo"); - break; - default: - break; - } - } - } - } - } - - g_clear_error (&error); - } else - icalcomponent_free (tmp_icalcomp); - - g_free (old_uid); - - return success; -} - void comp_util_sanitize_recurrence_master (ECalComponent *comp, ECal *client) { -- cgit v1.2.3 From 7aacf983b32ecac26bc9707697da622b3ef164a3 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 5 Mar 2011 12:33:49 -0500 Subject: Coding style and whitespace cleanup. --- calendar/gui/comp-util.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 68b5ef3307..4c5f80adcd 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -231,9 +231,11 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) */ e_cal_component_get_uid (comp, &uid); - /*TODO We should not be checking for this here. But since e_cal_util_construct_instance does not - create the instances of all day events, so we dafault to old behaviour */ - if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) { + /* TODO We should not be checking for this here. But since + * e_cal_util_construct_instance does not create the instances + * of all day events, so we default to old behaviour. */ + if (e_cal_get_static_capability ( + client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) { rid = e_cal_component_get_recurid_as_string (comp); } @@ -255,7 +257,8 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) /** * is_icalcomp_on_the_server: - * same as @cal_comp_is_on_server, only the component parameter is icalcomponent, not the ECalComponent. + * same as @cal_comp_is_on_server, only the component parameter is + * icalcomponent, not the ECalComponent. **/ gboolean is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client) @@ -446,7 +449,8 @@ cal_comp_update_time_by_active_window (ECalComponent *comp, EShell *shell) if (e_shell_window_get_active_view (shell_window) && g_str_equal (e_shell_window_get_active_view (shell_window), "calendar")) { - EShellView *view; + EShellContent *shell_content; + EShellView *shell_view; GnomeCalendar *gnome_cal; time_t start = 0, end = 0; icaltimezone *zone; @@ -454,11 +458,13 @@ cal_comp_update_time_by_active_window (ECalComponent *comp, EShell *shell) icalcomponent *icalcomp; icalproperty *prop; - view = e_shell_window_peek_shell_view (shell_window, "calendar"); - g_return_if_fail (view != NULL); + shell_view = e_shell_window_peek_shell_view ( + shell_window, "calendar"); + g_return_if_fail (shell_view != NULL); gnome_cal = NULL; - g_object_get (G_OBJECT (e_shell_view_get_shell_content (view)), "calendar", &gnome_cal, NULL); + shell_content = e_shell_view_get_shell_content (shell_view); + g_object_get (shell_content, "calendar", &gnome_cal, NULL); g_return_if_fail (gnome_cal != NULL); gnome_calendar_get_current_time_range (gnome_cal, &start, &end); @@ -616,7 +622,9 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) from = icaltimezone_get_builtin_timezone_from_tzid (date->tzid); if (!from) { if (!e_cal_get_timezone (client, date->tzid, &from, NULL)) - g_warning ("%s: Could not get timezone from server: %s", G_STRFUNC, date->tzid ? date->tzid : ""); + g_warning ( + "%s: Could not get timezone from server: %s", + G_STRFUNC, date->tzid ? date->tzid : ""); } to = icaltimezone_get_builtin_timezone_from_tzid (tzid); @@ -638,7 +646,9 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) * Changes 'dtstart' of the component, but converts time to the old timezone. **/ void -cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate) +cal_comp_set_dtstart_with_oldzone (ECal *client, + ECalComponent *comp, + const ECalComponentDateTime *pdate) { ECalComponentDateTime olddate, date; @@ -664,7 +674,9 @@ cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECal * Changes 'dtend' of the component, but converts time to the old timezone. **/ void -cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate) +cal_comp_set_dtend_with_oldzone (ECal *client, + ECalComponent *comp, + const ECalComponentDateTime *pdate) { ECalComponentDateTime olddate, date; @@ -682,7 +694,8 @@ cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalCo } void -comp_util_sanitize_recurrence_master (ECalComponent *comp, ECal *client) +comp_util_sanitize_recurrence_master (ECalComponent *comp, + ECal *client) { ECalComponent *master = NULL; icalcomponent *icalcomp = NULL; @@ -704,7 +717,9 @@ comp_util_sanitize_recurrence_master (ECalComponent *comp, ECal *client) e_cal_component_get_recurid (comp, &rid); e_cal_component_get_dtstart (comp, &sdt); - if (rid.datetime.value && sdt.value && icaltime_compare_date_only (*rid.datetime.value, *sdt.value) == 0) { + if (rid.datetime.value && sdt.value && + icaltime_compare_date_only ( + *rid.datetime.value, *sdt.value) == 0) { ECalComponentDateTime msdt, medt, edt; gint *sequence; -- cgit v1.2.3 From e7954c3f251aabbf95d099159709c8c66dfedc44 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 4 Jun 2011 15:53:10 -0500 Subject: Coding style and whitespace cleanups. --- calendar/gui/comp-util.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 4c5f80adcd..fbf9e7dc82 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -444,11 +444,15 @@ cal_comp_update_time_by_active_window (ECalComponent *comp, EShell *shell) g_return_if_fail (shell != NULL); window = e_shell_get_active_window (shell); - if (window && E_IS_SHELL_WINDOW (window)) { - EShellWindow *shell_window = E_SHELL_WINDOW (window); - if (e_shell_window_get_active_view (shell_window) - && g_str_equal (e_shell_window_get_active_view (shell_window), "calendar")) { + if (E_IS_SHELL_WINDOW (window)) { + EShellWindow *shell_window; + const gchar *active_view; + + shell_window = E_SHELL_WINDOW (window); + active_view = e_shell_window_get_active_view (shell_window); + + if (g_strcmp0 (active_view, "calendar") == 0) { EShellContent *shell_content; EShellView *shell_view; GnomeCalendar *gnome_cal; -- cgit v1.2.3 From 84339b3be5a771406fcd5898bbd21dc1c5b98c82 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 14 Jun 2011 08:54:20 +0200 Subject: Do not use deprecated EBook/ECal API --- calendar/gui/comp-util.c | 73 ++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index fbf9e7dc82..a6095d0bcc 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -32,8 +32,8 @@ #include "comp-util.h" #include "dialogs/delete-comp.h" #include +#include #include "e-util/e-categories-config.h" -#include "common/authentication.h" #include "gnome-cal.h" #include "shell/e-shell-window.h" @@ -90,7 +90,7 @@ e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2) /** * cal_comp_util_compare_event_timezones: * @comp: A calendar component object. - * @client: A #ECal. + * @client: A #ECalClient. * * Checks if the component uses the given timezone for both the start and * the end time, or if the UTC offsets of the start and end times are the same @@ -101,7 +101,7 @@ e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2) **/ gboolean cal_comp_util_compare_event_timezones (ECalComponent *comp, - ECal *client, + ECalClient *client, icaltimezone *zone) { ECalComponentDateTime start_datetime, end_datetime; @@ -151,8 +151,8 @@ 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_get_timezone (client, start_datetime.tzid, - &start_zone, NULL)) + if (!e_cal_client_get_timezone_sync (client, start_datetime.tzid, + &start_zone, NULL, NULL)) goto out; if (start_datetime.value) { @@ -166,8 +166,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, goto out; } - if (!e_cal_get_timezone (client, end_datetime.tzid, - &end_zone, NULL)) + if (!e_cal_client_get_timezone_sync (client, end_datetime.tzid, + &end_zone, NULL, NULL)) goto out; if (end_datetime.value) { @@ -211,7 +211,7 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, * user cancelled the deletion. **/ gboolean -cal_comp_is_on_server (ECalComponent *comp, ECal *client) +cal_comp_is_on_server (ECalComponent *comp, ECalClient *client) { const gchar *uid; gchar *rid = NULL; @@ -221,7 +221,7 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) g_return_val_if_fail (comp != NULL, FALSE); g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE); g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (E_IS_CAL (client), FALSE); + g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE); /* See if the component is on the server. If it is not, then it likely * means that the appointment is new, only in the day view, and we @@ -234,19 +234,18 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) /* TODO We should not be checking for this here. But since * e_cal_util_construct_instance does not create the instances * of all day events, so we default to old behaviour. */ - if (e_cal_get_static_capability ( - client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) { + if (e_cal_client_check_recurrences_no_master (client)) { rid = e_cal_component_get_recurid_as_string (comp); } - if (e_cal_get_object (client, uid, rid, &icalcomp, &error)) { + if (e_cal_client_get_object_sync (client, uid, rid, &icalcomp, NULL, &error)) { icalcomponent_free (icalcomp); g_free (rid); return TRUE; } - if (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND) + if (!g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) g_warning (G_STRLOC ": %s", error->message); g_clear_error (&error); @@ -261,7 +260,7 @@ cal_comp_is_on_server (ECalComponent *comp, ECal *client) * icalcomponent, not the ECalComponent. **/ gboolean -is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client) +is_icalcomp_on_the_server (icalcomponent *icalcomp, ECalClient *client) { gboolean on_server; ECalComponent *comp; @@ -288,7 +287,7 @@ is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client) * Return value: A newly-created calendar component. **/ ECalComponent * -cal_comp_event_new_with_defaults (ECal *client, +cal_comp_event_new_with_defaults (ECalClient *client, gboolean all_day, gboolean use_default_reminder, gint default_reminder_interval, @@ -300,7 +299,7 @@ cal_comp_event_new_with_defaults (ECal *client, icalproperty *icalprop; ECalComponentAlarmTrigger trigger; - if (!e_cal_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT); comp = e_cal_component_new (); @@ -358,7 +357,7 @@ cal_comp_event_new_with_defaults (ECal *client, } ECalComponent * -cal_comp_event_new_with_current_time (ECal *client, +cal_comp_event_new_with_current_time (ECalClient *client, gboolean all_day, icaltimezone *zone, gboolean use_default_reminder, @@ -398,12 +397,12 @@ cal_comp_event_new_with_current_time (ECal *client, } ECalComponent * -cal_comp_task_new_with_defaults (ECal *client) +cal_comp_task_new_with_defaults (ECalClient *client) { ECalComponent *comp; icalcomponent *icalcomp; - if (!e_cal_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) icalcomp = icalcomponent_new (ICAL_VTODO_COMPONENT); comp = e_cal_component_new (); @@ -417,12 +416,12 @@ cal_comp_task_new_with_defaults (ECal *client) } ECalComponent * -cal_comp_memo_new_with_defaults (ECal *client) +cal_comp_memo_new_with_defaults (ECalClient *client) { ECalComponent *comp; icalcomponent *icalcomp; - if (!e_cal_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_client_get_default_object_sync (client, &icalcomp, NULL, NULL)) icalcomp = icalcomponent_new (ICAL_VJOURNAL_COMPONENT); comp = e_cal_component_new (); @@ -613,7 +612,7 @@ cal_comp_selection_get_string_list (GtkSelectionData *selection_data) } static void -datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) +datetime_to_zone (ECalClient *client, ECalComponentDateTime *date, const gchar *tzid) { icaltimezone *from, *to; @@ -625,16 +624,21 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) from = icaltimezone_get_builtin_timezone_from_tzid (date->tzid); if (!from) { - if (!e_cal_get_timezone (client, date->tzid, &from, NULL)) + GError *error = NULL; + + if (!e_cal_client_get_timezone_sync (client, date->tzid, &from, NULL, &error)) g_warning ( - "%s: Could not get timezone from server: %s", - G_STRFUNC, date->tzid ? date->tzid : ""); + "%s: Could not get timezone '%s' from server: %s", + G_STRFUNC, date->tzid ? date->tzid : "", error ? error->message : "Unknown error"); + + if (error) + g_error_free (error); } to = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (!to) { /* do not check failure here, maybe the zone is not available there */ - e_cal_get_timezone (client, tzid, &to, NULL); + e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL); } icaltimezone_convert_time (date->value, from, to); @@ -643,14 +647,14 @@ datetime_to_zone (ECal *client, ECalComponentDateTime *date, const gchar *tzid) /** * cal_comp_set_dtstart_with_oldzone: - * @client: ECal structure, to retrieve timezone from, when required. + * @client: ECalClient structure, to retrieve timezone from, when required. * @comp: Component, where make the change. * @pdate: Value, to change to. * * Changes 'dtstart' of the component, but converts time to the old timezone. **/ void -cal_comp_set_dtstart_with_oldzone (ECal *client, +cal_comp_set_dtstart_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate) { @@ -671,14 +675,14 @@ cal_comp_set_dtstart_with_oldzone (ECal *client, /** * cal_comp_set_dtend_with_oldzone: - * @client: ECal structure, to retrieve timezone from, when required. + * @client: ECalClient structure, to retrieve timezone from, when required. * @comp: Component, where make the change. * @pdate: Value, to change to. * * Changes 'dtend' of the component, but converts time to the old timezone. **/ void -cal_comp_set_dtend_with_oldzone (ECal *client, +cal_comp_set_dtend_with_oldzone (ECalClient *client, ECalComponent *comp, const ECalComponentDateTime *pdate) { @@ -699,18 +703,21 @@ cal_comp_set_dtend_with_oldzone (ECal *client, void comp_util_sanitize_recurrence_master (ECalComponent *comp, - ECal *client) + ECalClient *client) { ECalComponent *master = NULL; icalcomponent *icalcomp = NULL; ECalComponentRange rid; ECalComponentDateTime sdt; const gchar *uid; + GError *error = NULL; /* Get the master component */ e_cal_component_get_uid (comp, &uid); - if (!e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) { - g_warning ("Unable to get the master component \n"); + if (!e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, &error)) { + g_warning ("Unable to get the master component: %s", error ? error->message : "Unknown error"); + if (error) + g_error_free (error); return; } -- cgit v1.2.3 From 19307b54bc826cebbdea8cd7e1cdd8499bc1076f Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 29 Jun 2011 23:08:37 +0200 Subject: Add a bit more error checking and do not leak icalcomponent-s --- calendar/gui/comp-util.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index a6095d0bcc..d44914fb46 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -722,7 +722,12 @@ comp_util_sanitize_recurrence_master (ECalComponent *comp, } master = e_cal_component_new (); - e_cal_component_set_icalcomponent (master, icalcomp); + if (!e_cal_component_set_icalcomponent (master, icalcomp)) { + icalcomponent_free (icalcomp); + g_object_unref (master); + g_return_if_reached (); + return; + } /* Compare recur id and start date */ e_cal_component_get_recurid (comp, &rid); @@ -739,6 +744,10 @@ comp_util_sanitize_recurrence_master (ECalComponent *comp, e_cal_component_get_dtend (comp, &edt); + g_return_if_fail (msdt.value != NULL); + g_return_if_fail (medt.value != NULL); + g_return_if_fail (edt.value != NULL); + sdt.value->year = msdt.value->year; sdt.value->month = msdt.value->month; sdt.value->day = msdt.value->day; -- cgit v1.2.3 From ae9db3ed236b0c734fd12c8dc8c99764626bf0b8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 1 Jul 2011 00:07:26 -0400 Subject: Coding style and whitespace cleanup. --- calendar/gui/comp-util.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index d44914fb46..43f87f7fa1 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -626,13 +626,16 @@ datetime_to_zone (ECalClient *client, ECalComponentDateTime *date, const gchar * if (!from) { GError *error = NULL; - if (!e_cal_client_get_timezone_sync (client, date->tzid, &from, NULL, &error)) + e_cal_client_get_timezone_sync ( + client, date->tzid, &from, NULL, &error); + + if (error != NULL) { g_warning ( "%s: Could not get timezone '%s' from server: %s", - G_STRFUNC, date->tzid ? date->tzid : "", error ? error->message : "Unknown error"); - - if (error) + G_STRFUNC, date->tzid ? date->tzid : "", + error->message); g_error_free (error); + } } to = icaltimezone_get_builtin_timezone_from_tzid (tzid); @@ -714,10 +717,15 @@ comp_util_sanitize_recurrence_master (ECalComponent *comp, /* Get the master component */ e_cal_component_get_uid (comp, &uid); - if (!e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, &error)) { - g_warning ("Unable to get the master component: %s", error ? error->message : "Unknown error"); - if (error) - g_error_free (error); + + e_cal_client_get_object_sync ( + client, uid, NULL, &icalcomp, NULL, &error); + + if (error != NULL) { + g_warning ( + "Unable to get the master component: %s", + error->message); + g_error_free (error); return; } -- cgit v1.2.3 From 777c1cbd40eb63365f2c28e38f6a93beb2d1c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- calendar/gui/comp-util.c | 51 +++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 43f87f7fa1..9405f24b5a 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -50,7 +50,9 @@ * component object. **/ void -cal_comp_util_add_exdate (ECalComponent *comp, time_t t, icaltimezone *zone) +cal_comp_util_add_exdate (ECalComponent *comp, + time_t t, + icaltimezone *zone) { GSList *list; ECalComponentDateTime *cdt; @@ -72,7 +74,8 @@ cal_comp_util_add_exdate (ECalComponent *comp, time_t t, icaltimezone *zone) /* Returns TRUE if the TZIDs are equivalent, i.e. both NULL or the same. */ static gboolean -e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2) +e_cal_component_compare_tzid (const gchar *tzid1, + const gchar *tzid2) { gboolean retval = TRUE; @@ -101,8 +104,8 @@ e_cal_component_compare_tzid (const gchar *tzid1, const gchar *tzid2) **/ gboolean cal_comp_util_compare_event_timezones (ECalComponent *comp, - ECalClient *client, - icaltimezone *zone) + ECalClient *client, + icaltimezone *zone) { ECalComponentDateTime start_datetime, end_datetime; const gchar *tzid; @@ -116,8 +119,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, e_cal_component_get_dtend (comp, &end_datetime); /* If either the DTSTART or the DTEND is a DATE value, we return TRUE. - Maybe if one was a DATE-TIME we should check that, but that should - not happen often. */ + * Maybe if one was a DATE-TIME we should check that, but that should + * not happen often. */ if ((start_datetime.value && start_datetime.value->is_date) || (end_datetime.value && end_datetime.value->is_date)) { retval = TRUE; @@ -125,8 +128,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, } /* If the event uses UTC for DTSTART & DTEND, return TRUE. Outlook - will send single events as UTC, so we don't want to mark all of - these. */ + * will send single events as UTC, so we don't want to mark all of + * these. */ if ((!start_datetime.value || start_datetime.value->is_utc) && (!end_datetime.value || end_datetime.value->is_utc)) { retval = TRUE; @@ -134,8 +137,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, } /* If the event uses floating time for DTSTART & DTEND, return TRUE. - Imported vCalendar files will use floating times, so we don't want - to mark all of these. */ + * Imported vCalendar files will use floating times, so we don't want + * to mark all of these. */ if (!start_datetime.tzid && !end_datetime.tzid) { retval = TRUE; goto out; @@ -145,12 +148,12 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, if (e_cal_component_compare_tzid (tzid, start_datetime.tzid) && e_cal_component_compare_tzid (tzid, end_datetime.tzid)) { /* If both TZIDs are the same as the given zone's TZID, then - we know the timezones are the same so we return TRUE. */ + * we know the timezones are the same so we return TRUE. */ retval = TRUE; } else { /* 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. */ + * 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)) goto out; @@ -211,7 +214,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp, * user cancelled the deletion. **/ gboolean -cal_comp_is_on_server (ECalComponent *comp, ECalClient *client) +cal_comp_is_on_server (ECalComponent *comp, + ECalClient *client) { const gchar *uid; gchar *rid = NULL; @@ -260,7 +264,8 @@ cal_comp_is_on_server (ECalComponent *comp, ECalClient *client) * icalcomponent, not the ECalComponent. **/ gboolean -is_icalcomp_on_the_server (icalcomponent *icalcomp, ECalClient *client) +is_icalcomp_on_the_server (icalcomponent *icalcomp, + ECalClient *client) { gboolean on_server; ECalComponent *comp; @@ -435,7 +440,8 @@ cal_comp_memo_new_with_defaults (ECalClient *client) } void -cal_comp_update_time_by_active_window (ECalComponent *comp, EShell *shell) +cal_comp_update_time_by_active_window (ECalComponent *comp, + EShell *shell) { GtkWindow *window; @@ -502,7 +508,8 @@ cal_comp_update_time_by_active_window (ECalComponent *comp, EShell *shell) * Returns: the number of icons owned by the component. **/ gint -cal_comp_util_get_n_icons (ECalComponent *comp, GSList **pixbufs) +cal_comp_util_get_n_icons (ECalComponent *comp, + GSList **pixbufs) { GSList *categories_list, *elem; gint num_icons = 0; @@ -543,7 +550,8 @@ cal_comp_util_get_n_icons (ECalComponent *comp, GSList **pixbufs) * cal_comp_selection_get_string_list() to get this list from target data. **/ void -cal_comp_selection_set_string_list (GtkSelectionData *data, GSList *str_list) +cal_comp_selection_set_string_list (GtkSelectionData *data, + GSList *str_list) { /* format is "str1\0str2\0...strN\0" */ GSList *p; @@ -612,7 +620,9 @@ cal_comp_selection_get_string_list (GtkSelectionData *selection_data) } static void -datetime_to_zone (ECalClient *client, ECalComponentDateTime *date, const gchar *tzid) +datetime_to_zone (ECalClient *client, + ECalComponentDateTime *date, + const gchar *tzid) { icaltimezone *from, *to; @@ -783,7 +793,8 @@ comp_util_sanitize_recurrence_master (ECalComponent *comp, } gchar * -icalcomp_suggest_filename (icalcomponent *icalcomp, const gchar *default_name) +icalcomp_suggest_filename (icalcomponent *icalcomp, + const gchar *default_name) { icalproperty *prop; const gchar *summary = NULL; -- cgit v1.2.3 From e64d6fe05c30c2cc1d7625a202afba3ba2da07cd Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 22 Nov 2011 18:22:14 -0500 Subject: Miscellaneous cleanups. --- calendar/gui/comp-util.c | 1 - 1 file changed, 1 deletion(-) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 8bb5500f23..f768335c3c 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -39,7 +39,6 @@ #include "shell/e-shell-window.h" #include "shell/e-shell-view.h" - /** * cal_comp_util_add_exdate: * @comp: A calendar component object. -- cgit v1.2.3