diff options
author | JP Rosevear <jpr@helixcode.com> | 2000-09-06 17:59:17 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2000-09-06 17:59:17 +0800 |
commit | 5c279839005d2218319fa5546b6e498df753e68e (patch) | |
tree | 60eb5df767d2b73d52bc23760d62c189afd1aa38 /calendar/cal-util | |
parent | 114f5b7f916184cf8269b36a06b74b74bb7b18e2 (diff) | |
download | gsoc2013-evolution-5c279839005d2218319fa5546b6e498df753e68e.tar gsoc2013-evolution-5c279839005d2218319fa5546b6e498df753e68e.tar.gz gsoc2013-evolution-5c279839005d2218319fa5546b6e498df753e68e.tar.bz2 gsoc2013-evolution-5c279839005d2218319fa5546b6e498df753e68e.tar.lz gsoc2013-evolution-5c279839005d2218319fa5546b6e498df753e68e.tar.xz gsoc2013-evolution-5c279839005d2218319fa5546b6e498df753e68e.tar.zst gsoc2013-evolution-5c279839005d2218319fa5546b6e498df753e68e.zip |
Use new convenience functions and only get the recurrence stuff if needed.
2000-09-06 JP Rosevear <jpr@helixcode.com>
* cal-util/cal-recur.c (cal_recur_generate_instances): Use
new convenience functions and only get the recurrence
stuff if needed. Free the recurrence stuff if used.
2000-09-05 JP Rosevear <jpr@helixcode.com>
* cal-util/cal-component.h: Add new prototypes
* cal-util/cal-component.c (cal_component_has_exrules): Utility
function to determine whether a cal component has any exrules
(cal_component_has_exdates): Ditto for exdates
(cal_component_has_exceptions): Utility function to determine
whether a cal component has any exception rules
(cal_component_has_recurrences):Utility function to determine
whether a cal component has any recurrence rules
svn path=/trunk/; revision=5219
Diffstat (limited to 'calendar/cal-util')
-rw-r--r-- | calendar/cal-util/cal-component.c | 74 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.h | 6 | ||||
-rw-r--r-- | calendar/cal-util/cal-recur.c | 22 |
3 files changed, 94 insertions, 8 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 3c063cf990..60e0a1bbd5 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -1991,6 +1991,29 @@ cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list) priv->need_sequence_inc = TRUE; } +/** + * cal_component_has_exdates: + * @comp: A calendar component object. + * + * Queries whether a calendar component object has any exception dates defined + * for it. + * + * Return value: TRUE if the component has exception dates, FALSE otherwise. + **/ +gboolean +cal_component_has_exdates (CalComponent *comp) +{ + CalComponentPrivate *priv; + + g_return_val_if_fail (comp != NULL, FALSE); + g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); + + priv = comp->priv; + g_return_val_if_fail (priv->icalcomp != NULL, FALSE); + + return (priv->exdate_list != NULL); +} + /* Gets a list of recurrence rules */ static void get_recur_list (GSList *recur_list, @@ -2108,6 +2131,43 @@ cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list) } /** + * cal_component_has_exrules: + * @comp: A calendar component object. + * + * Queries whether a calendar component object has any exception rules defined + * for it. + * + * Return value: TRUE if the component has exception rules, FALSE otherwise. + **/ +gboolean +cal_component_has_exrules (CalComponent *comp) +{ + CalComponentPrivate *priv; + + g_return_val_if_fail (comp != NULL, FALSE); + g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); + + priv = comp->priv; + g_return_val_if_fail (priv->icalcomp != NULL, FALSE); + + return (priv->exrule_list != NULL); +} + +/** + * cal_component_has_exceptions: + * @comp: A calendar component object + * + * Queries whether a calendar component object has any exceptions defined + * + * Return value: TRUE if the component has exceptions, FALSE otherwise + **/ +gboolean +cal_component_has_exceptions (CalComponent *comp) +{ + return cal_component_has_exdates (comp) || cal_component_has_exrules (comp); +} + +/** * cal_component_get_geo: * @comp: A calendar component object. * @geo: Return value for the geographic position property. This should be @@ -2492,6 +2552,20 @@ cal_component_has_rrules (CalComponent *comp) } /** + * cal_component_has_recurrence: + * @comp: A calendar component object + * + * Queries whether a calendar component object has any recurrences defined + * + * Return value: TRUE if the component has recurrences, FALSE otherwise + **/ +gboolean +cal_component_has_recurrences (CalComponent *comp) +{ + return cal_component_has_rdates (comp) || cal_component_has_rrules (comp); +} + +/** * cal_component_get_sequence: * @comp: A calendar component object. * @sequence: Return value for the sequence number. This should be freed using diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index c8e2627448..2f9067896b 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -197,9 +197,13 @@ void cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt); void cal_component_get_exdate_list (CalComponent *comp, GSList **exdate_list); void cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list); +gboolean cal_component_has_exdates (CalComponent *comp); void cal_component_get_exrule_list (CalComponent *comp, GSList **recur_list); void cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list); +gboolean cal_component_has_exrules (CalComponent *comp); + +gboolean cal_component_has_exceptions (CalComponent *comp); void cal_component_get_geo (CalComponent *comp, struct icalgeotype **geo); void cal_component_set_geo (CalComponent *comp, struct icalgeotype *geo); @@ -221,6 +225,8 @@ void cal_component_get_rrule_list (CalComponent *comp, GSList **recur_list); void cal_component_set_rrule_list (CalComponent *comp, GSList *recur_list); gboolean cal_component_has_rrules (CalComponent *comp); +gboolean cal_component_has_recurrences (CalComponent *comp); + void cal_component_get_sequence (CalComponent *comp, int **sequence); void cal_component_set_sequence (CalComponent *comp, int *sequence); diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c index 49bf9a9a08..648e5293e9 100644 --- a/calendar/cal-util/cal-recur.c +++ b/calendar/cal-util/cal-recur.c @@ -489,16 +489,10 @@ cal_recur_generate_instances (CalComponent *comp, else dtend_time = time_day_end (dtstart_time); - - cal_component_get_rrule_list (comp, &rrules); - cal_component_get_rdate_list (comp, &rdates); - cal_component_get_exrule_list (comp, &exrules); - cal_component_get_exdate_list (comp, &exdates); - /* If there is no recurrence, just call the callback if the event intersects the given interval. */ - - if (!(rrules || rdates || exrules || exdates)) { + if (!(cal_component_has_recurrences (comp) + || cal_component_has_exceptions (comp))) { if ((end && dtstart_time < end && dtend_time > start) || (end == 0 && dtend_time > start)) { (* cb) (comp, dtstart_time, dtend_time, cb_data); @@ -507,6 +501,12 @@ cal_recur_generate_instances (CalComponent *comp, goto out; } + /* Get the recurrence rules */ + cal_component_get_rrule_list (comp, &rrules); + cal_component_get_rdate_list (comp, &rdates); + cal_component_get_exrule_list (comp, &exrules); + cal_component_get_exdate_list (comp, &exdates); + /* Convert the interval start & end to CalObjTime. */ cal_object_time_from_time (&interval_start, start); cal_object_time_from_time (&interval_end, end); @@ -558,6 +558,12 @@ cal_recur_generate_instances (CalComponent *comp, break; } + cal_component_free_recur_list (rrules); + cal_component_free_period_list (rdates); + cal_component_free_recur_list (exrules); + cal_component_free_exdate_list (exdates); + + out: cal_component_free_datetime (&dtstart); cal_component_free_datetime (&dtend); |