aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util/cal-util.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@src.gnome.org>2003-08-20 18:16:57 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2003-08-20 18:16:57 +0800
commitba861603f446ca0fd9b4cf72f0f8357c306ce953 (patch)
treebaf495cb29eb06fc4fff07bff44d1666d0f4d6af /calendar/cal-util/cal-util.c
parent252980fd75b70401cc0525be33f9c0450933997a (diff)
downloadgsoc2013-evolution-ba861603f446ca0fd9b4cf72f0f8357c306ce953.tar.gz
gsoc2013-evolution-ba861603f446ca0fd9b4cf72f0f8357c306ce953.tar.zst
gsoc2013-evolution-ba861603f446ca0fd9b4cf72f0f8357c306ce953.zip
Merged from calendar-views-with-model branch
svn path=/trunk/; revision=22307
Diffstat (limited to 'calendar/cal-util/cal-util.c')
-rw-r--r--calendar/cal-util/cal-util.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c
index 9bedf7d53c..690bb57f6f 100644
--- a/calendar/cal-util/cal-util.c
+++ b/calendar/cal-util/cal-util.c
@@ -661,3 +661,108 @@ cal_util_add_timezones_from_component (icalcomponent *vcal_comp,
f_data.icalcomp = icalcomp;
icalcomponent_foreach_tzid (icalcomp, add_timezone_cb, &f_data);
}
+
+gboolean
+cal_util_component_is_instance (icalcomponent *icalcomp)
+{
+ icalproperty *prop;
+
+ g_return_val_if_fail (icalcomp != NULL, FALSE);
+
+ prop = icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY);
+ return prop ? TRUE : FALSE;
+}
+
+gboolean
+cal_util_component_has_alarms (icalcomponent *icalcomp)
+{
+ icalcomponent *alarm;
+
+ g_return_val_if_fail (icalcomp != NULL, FALSE);
+
+ alarm = icalcomponent_get_first_component (icalcomp, ICAL_VALARM_COMPONENT);
+ return alarm ? TRUE : FALSE;
+}
+
+gboolean
+cal_util_component_has_organizer (icalcomponent *icalcomp)
+{
+ icalproperty *prop;
+
+ g_return_val_if_fail (icalcomp != NULL, FALSE);
+
+ prop = icalcomponent_get_first_property (icalcomp, ICAL_ORGANIZER_PROPERTY);
+ return prop ? TRUE : FALSE;
+}
+
+gboolean
+cal_util_component_has_recurrences (icalcomponent *icalcomp)
+{
+ g_return_val_if_fail (icalcomp != NULL, FALSE);
+
+ return cal_util_component_has_rdates (icalcomp) || cal_util_component_has_rrules (icalcomp);
+}
+
+gboolean
+cal_util_component_has_rdates (icalcomponent *icalcomp)
+{
+ icalproperty *prop;
+
+ g_return_val_if_fail (icalcomp != NULL, FALSE);
+
+ prop = icalcomponent_get_first_property (icalcomp, ICAL_RDATE_PROPERTY);
+ return prop ? TRUE : FALSE;
+}
+
+gboolean
+cal_util_component_has_rrules (icalcomponent *icalcomp)
+{
+ icalproperty *prop;
+
+ g_return_val_if_fail (icalcomp != NULL, FALSE);
+
+ prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY);
+ return prop ? TRUE : FALSE;
+}
+
+gboolean
+cal_util_event_dates_match (icalcomponent *icalcomp1, icalcomponent *icalcomp2)
+{
+ struct icaltimetype c1_dtstart, c1_dtend, c2_dtstart, c2_dtend;
+
+ g_return_val_if_fail (icalcomp1 != NULL, FALSE);
+ g_return_val_if_fail (icalcomp2 != NULL, FALSE);
+
+ c1_dtstart = icalcomponent_get_dtstart (icalcomp1);
+ c1_dtend = icalcomponent_get_dtend (icalcomp1);
+ c2_dtstart = icalcomponent_get_dtstart (icalcomp2);
+ c2_dtend = icalcomponent_get_dtend (icalcomp2);
+
+ /* if either value is NULL, they must both be NULL to match */
+ if (icaltime_is_valid_time (c1_dtstart) || icaltime_is_valid_time (c2_dtstart)) {
+ if (!(icaltime_is_valid_time (c1_dtstart) && icaltime_is_valid_time (c2_dtstart)))
+ return FALSE;
+ } else {
+ if (icaltime_compare (c1_dtstart, c2_dtstart))
+ return FALSE;
+ }
+
+ if (icaltime_is_valid_time (c1_dtend) || icaltime_is_valid_time (c2_dtend)) {
+ if (!(icaltime_is_valid_time (c1_dtend) && icaltime_is_valid_time (c2_dtend)))
+ return FALSE;
+ } else {
+ if (icaltime_compare (c1_dtend, c2_dtend))
+ return FALSE;
+ }
+
+ /* now match the timezones */
+ if (!(!c1_dtstart.zone && !c2_dtstart.zone) ||
+ (c1_dtstart.zone && c2_dtstart.zone && !strcmp (c1_dtstart.zone, c2_dtstart.zone)))
+ return FALSE;
+
+ if (!(!c1_dtend.zone && !c2_dtend.zone) ||
+ (c1_dtend.zone && c2_dtend.zone && !strcmp (c1_dtend.zone, c2_dtend.zone)))
+ return FALSE;
+
+ return TRUE;
+}