aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorJP Rosevear <jpr@src.gnome.org>2003-03-05 03:52:37 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-03-05 03:52:37 +0800
commit6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62 (patch)
treebba07b5f28966c10a90de8f550af895014b0b9bb /calendar/cal-util
parentcd4477930e72b1be069d5c97b90d96e989645bfc (diff)
downloadgsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.gz
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.bz2
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.lz
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.xz
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.zst
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.zip
If only the pipe wouldn't break.
svn path=/trunk/; revision=20143
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/cal-component.c114
-rw-r--r--calendar/cal-util/cal-component.h6
-rw-r--r--calendar/cal-util/cal-recur.c2
-rw-r--r--calendar/cal-util/cal-util.c32
-rw-r--r--calendar/cal-util/cal-util.h10
5 files changed, 134 insertions, 30 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index a5300a9605..671af4a9ec 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -33,6 +33,21 @@
/* Extension property for alarm components so that we can reference them by UID */
#define EVOLUTION_ALARM_UID_PROPERTY "X-EVOLUTION-ALARM-UID"
+
+struct attendee {
+ icalproperty *prop;
+ icalparameter *cutype_param;
+ icalparameter *member_param;
+ icalparameter *role_param;
+ icalparameter *partstat_param;
+ icalparameter *rsvp_param;
+ icalparameter *delto_param;
+ icalparameter *delfrom_param;
+ icalparameter *sentby_param;
+ icalparameter *cn_param;
+ icalparameter *language_param;
+};
+
/* Private part of the CalComponent structure */
struct _CalComponentPrivate {
/* The icalcomponent we wrap */
@@ -43,21 +58,6 @@ struct _CalComponentPrivate {
icalproperty *uid;
icalproperty *status;
-
- struct attendee {
- icalproperty *prop;
- icalparameter *cutype_param;
- icalparameter *member_param;
- icalparameter *role_param;
- icalparameter *partstat_param;
- icalparameter *rsvp_param;
- icalparameter *delto_param;
- icalparameter *delfrom_param;
- icalparameter *sentby_param;
- icalparameter *cn_param;
- icalparameter *language_param;
- };
-
GSList *attendee_list;
icalproperty *categories;
@@ -174,6 +174,8 @@ struct _CalComponentAlarm {
icalproperty *duration;
icalproperty *repeat;
icalproperty *trigger;
+
+ GSList *attendee_list;
};
@@ -469,7 +471,7 @@ cal_component_clone (CalComponent *comp)
/* Scans an attendee property */
static void
-scan_attendee (CalComponent *comp, GSList **attendee_list, icalproperty *prop)
+scan_attendee (GSList **attendee_list, icalproperty *prop)
{
struct attendee *attendee;
@@ -601,7 +603,7 @@ scan_property (CalComponent *comp, icalproperty *prop)
break;
case ICAL_ATTENDEE_PROPERTY:
- scan_attendee (comp, &priv->attendee_list, prop);
+ scan_attendee (&priv->attendee_list, prop);
break;
case ICAL_CATEGORIES_PROPERTY:
@@ -3593,6 +3595,19 @@ cal_component_has_simple_recurrence (CalComponent *comp)
return simple;
}
+gboolean
+cal_component_is_instance (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;
+
+ return !(priv->recur_id.recur_time.prop == NULL);
+}
+
/**
* cal_component_get_sequence:
* @comp: A calendar component object.
@@ -4019,15 +4034,12 @@ get_attendee_list (GSList *attendee_list, GSList **al)
/* Sets a text list value */
static void
-set_attendee_list (CalComponent *comp,
+set_attendee_list (icalcomponent *icalcomp,
GSList **attendee_list,
GSList *al)
{
- CalComponentPrivate *priv;
GSList *l;
- priv = comp->priv;
-
/* Remove old attendees */
for (l = *attendee_list; l; l = l->next) {
@@ -4036,7 +4048,7 @@ set_attendee_list (CalComponent *comp,
attendee = l->data;
g_assert (attendee->prop != NULL);
- icalcomponent_remove_property (priv->icalcomp, attendee->prop);
+ icalcomponent_remove_property (icalcomp, attendee->prop);
icalproperty_free (attendee->prop);
g_free (attendee);
}
@@ -4056,7 +4068,7 @@ set_attendee_list (CalComponent *comp,
attendee = g_new0 (struct attendee, 1);
attendee->prop = icalproperty_new_attendee (a->value);
- icalcomponent_add_property (priv->icalcomp, attendee->prop);
+ icalcomponent_add_property (icalcomp, attendee->prop);
if (a->member) {
attendee->member_param = icalparameter_new_member (a->member);
@@ -4147,7 +4159,7 @@ cal_component_set_attendee_list (CalComponent *comp, GSList *attendee_list)
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
- set_attendee_list (comp, &priv->attendee_list, attendee_list);
+ set_attendee_list (priv->icalcomp, &priv->attendee_list, attendee_list);
}
gboolean
@@ -4261,6 +4273,14 @@ cal_component_free_datetime (CalComponentDateTime *dt)
g_free ((char*)dt->tzid);
}
+void
+cal_component_free_range (CalComponentRange *range)
+{
+ g_return_if_fail (range != NULL);
+
+ cal_component_free_datetime (&range->datetime);
+}
+
/**
* cal_component_free_exdate_list:
* @exdate_list: List of #CalComponentDateTime structures.
@@ -4618,6 +4638,10 @@ scan_alarm_property (CalComponentAlarm *alarm, icalproperty *prop)
alarm->trigger = prop;
break;
+ case ICAL_ATTENDEE_PROPERTY:
+ scan_attendee (&alarm->attendee_list, prop);
+ break;
+
case ICAL_X_PROPERTY:
xname = icalproperty_get_x_name (prop);
g_assert (xname != NULL);
@@ -4651,7 +4675,8 @@ make_alarm (icalcomponent *subcomp)
alarm->duration = NULL;
alarm->repeat = NULL;
alarm->trigger = NULL;
-
+ alarm->attendee_list = NULL;
+
for (prop = icalcomponent_get_first_property (subcomp, ICAL_ANY_PROPERTY);
prop;
prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY))
@@ -4804,7 +4829,8 @@ cal_component_alarm_new (void)
alarm->duration = NULL;
alarm->repeat = NULL;
alarm->trigger = NULL;
-
+ alarm->attendee_list = NULL;
+
return alarm;
}
@@ -4837,6 +4863,8 @@ cal_component_alarm_clone (CalComponentAlarm *alarm)
void
cal_component_alarm_free (CalComponentAlarm *alarm)
{
+ GSList *l;
+
g_return_if_fail (alarm != NULL);
g_assert (alarm->icalcomp != NULL);
@@ -4854,6 +4882,11 @@ cal_component_alarm_free (CalComponentAlarm *alarm)
alarm->repeat = NULL;
alarm->trigger = NULL;
+ for (l = alarm->attendee_list; l != NULL; l = l->next)
+ g_free (l->data);
+ g_slist_free (alarm->attendee_list);
+ alarm->attendee_list = NULL;
+
g_free (alarm);
}
@@ -5318,6 +5351,35 @@ cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigg
}
}
+void
+cal_component_alarm_get_attendee_list (CalComponentAlarm *alarm, GSList **attendee_list)
+{
+ g_return_if_fail (alarm != NULL);
+
+ get_attendee_list (alarm->attendee_list, attendee_list);
+}
+
+void
+cal_component_alarm_set_attendee_list (CalComponentAlarm *alarm, GSList *attendee_list)
+{
+ g_return_if_fail (alarm != NULL);
+
+ set_attendee_list (alarm->icalcomp, &alarm->attendee_list, attendee_list);
+}
+
+gboolean
+cal_component_alarm_has_attendees (CalComponentAlarm *alarm)
+{
+
+ g_return_val_if_fail (alarm != NULL, FALSE);
+
+ if (g_slist_length (alarm->attendee_list) > 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+
/**
* cal_component_alarm_get_icalcomponent
* @alarm: An alarm.
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index dba2e5a179..f363099836 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -297,6 +297,7 @@ gboolean cal_component_has_rrules (CalComponent *comp);
gboolean cal_component_has_recurrences (CalComponent *comp);
gboolean cal_component_has_simple_recurrence (CalComponent *comp);
+gboolean cal_component_is_instance (CalComponent *comp);
void cal_component_get_sequence (CalComponent *comp, int **sequence);
void cal_component_set_sequence (CalComponent *comp, int *sequence);
@@ -327,6 +328,7 @@ gboolean cal_component_event_dates_match (CalComponent *comp1, CalComponent *com
void cal_component_free_categories_list (GSList *categ_list);
void cal_component_free_datetime (CalComponentDateTime *dt);
+void cal_component_free_range (CalComponentRange *range);
void cal_component_free_exdate_list (GSList *exdate_list);
void cal_component_free_geo (struct icalgeotype *geo);
void cal_component_free_icaltimetype (struct icaltimetype *t);
@@ -434,6 +436,10 @@ void cal_component_alarm_set_repeat (CalComponentAlarm *alarm, CalAlarmRepeat re
void cal_component_alarm_get_trigger (CalComponentAlarm *alarm, CalAlarmTrigger *trigger);
void cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigger);
+void cal_component_alarm_get_attendee_list (CalComponentAlarm *alarm, GSList **attendee_list);
+void cal_component_alarm_set_attendee_list (CalComponentAlarm *alarm, GSList *attendee_list);
+gboolean cal_component_alarm_has_attendees (CalComponentAlarm *alarm);
+
icalcomponent *cal_component_alarm_get_icalcomponent (CalComponentAlarm *alarm);
diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c
index 214c642f45..123198676c 100644
--- a/calendar/cal-util/cal-recur.c
+++ b/calendar/cal-util/cal-recur.c
@@ -770,6 +770,8 @@ cal_recur_generate_instances_of_rule (CalComponent *comp,
elem.data = prop;
elem.next = NULL;
rrules = &elem;
+ } else if (cal_component_is_instance (comp)) {
+ single_rule = FALSE;
} else {
single_rule = FALSE;
diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c
index 9730bfdbc2..040e322cce 100644
--- a/calendar/cal-util/cal-util.c
+++ b/calendar/cal-util/cal-util.c
@@ -177,7 +177,8 @@ struct alarm_occurrence_data {
GList *alarm_uids;
time_t start;
time_t end;
-
+ CalAlarmAction *omit;
+
/* This is what we compute */
GSList *triggers;
int n_triggers;
@@ -213,20 +214,30 @@ add_alarm_occurrences_cb (CalComponent *comp, time_t start, time_t end, gpointer
for (l = aod->alarm_uids; l; l = l->next) {
const char *auid;
CalComponentAlarm *alarm;
+ CalAlarmAction action;
CalAlarmTrigger trigger;
CalAlarmRepeat repeat;
struct icaldurationtype *dur;
time_t dur_time;
time_t occur_time, trigger_time;
-
+ int i;
+
auid = l->data;
alarm = cal_component_get_alarm (comp, auid);
g_assert (alarm != NULL);
+ cal_component_alarm_get_action (alarm, &action);
cal_component_alarm_get_trigger (alarm, &trigger);
cal_component_alarm_get_repeat (alarm, &repeat);
cal_component_alarm_free (alarm);
+ for (i = 0; aod->omit[i] != -1; i++) {
+ if (aod->omit[i] == action)
+ break;
+ }
+ if (aod->omit[i] != -1)
+ continue;
+
if (trigger.type != CAL_ALARM_TRIGGER_RELATIVE_START
&& trigger.type != CAL_ALARM_TRIGGER_RELATIVE_END)
continue;
@@ -290,20 +301,30 @@ generate_absolute_triggers (CalComponent *comp, struct alarm_occurrence_data *ao
for (l = aod->alarm_uids; l; l = l->next) {
const char *auid;
CalComponentAlarm *alarm;
+ CalAlarmAction action;
CalAlarmRepeat repeat;
CalAlarmTrigger trigger;
time_t abs_time;
time_t occur_start, occur_end;
icaltimezone *zone;
-
+ int i;
+
auid = l->data;
alarm = cal_component_get_alarm (comp, auid);
g_assert (alarm != NULL);
+ cal_component_alarm_get_action (alarm, &action);
cal_component_alarm_get_trigger (alarm, &trigger);
cal_component_alarm_get_repeat (alarm, &repeat);
cal_component_alarm_free (alarm);
+ for (i = 0; aod->omit[i] != -1; i++) {
+ if (aod->omit[i] == action)
+ break;
+ }
+ if (aod->omit[i] != -1)
+ continue;
+
if (trigger.type != CAL_ALARM_TRIGGER_ABSOLUTE)
continue;
@@ -397,6 +418,7 @@ CalComponentAlarms *
cal_util_generate_alarms_for_comp (CalComponent *comp,
time_t start,
time_t end,
+ CalAlarmAction *omit,
CalRecurResolveTimezoneFn resolve_tzid,
gpointer user_data,
icaltimezone *default_timezone)
@@ -415,6 +437,7 @@ cal_util_generate_alarms_for_comp (CalComponent *comp,
aod.alarm_uids = alarm_uids;
aod.start = start;
aod.end = end;
+ aod.omit = omit;
aod.triggers = NULL;
aod.n_triggers = 0;
@@ -459,6 +482,7 @@ int
cal_util_generate_alarms_for_list (GList *comps,
time_t start,
time_t end,
+ CalAlarmAction *omit,
GSList **comp_alarms,
CalRecurResolveTimezoneFn resolve_tzid,
gpointer user_data,
@@ -474,7 +498,7 @@ cal_util_generate_alarms_for_list (GList *comps,
CalComponentAlarms *alarms;
comp = CAL_COMPONENT (l->data);
- alarms = cal_util_generate_alarms_for_comp (comp, start, end, resolve_tzid, user_data, default_timezone);
+ alarms = cal_util_generate_alarms_for_comp (comp, start, end, omit, resolve_tzid, user_data, default_timezone);
if (alarms) {
*comp_alarms = g_slist_prepend (*comp_alarms, alarms);
diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h
index a4d95a3e8c..bf43493f82 100644
--- a/calendar/cal-util/cal-util.h
+++ b/calendar/cal-util/cal-util.h
@@ -51,6 +51,14 @@ typedef enum {
CALOBJ_TYPE_ANY = 0x07
} CalObjType;
+/* Used for modifying objects */
+typedef enum {
+ CALOBJ_MOD_THIS = 1 << 0,
+ CALOBJ_MOD_THISANDPRIOR = 1 << 1,
+ CALOBJ_MOD_THISANDFUTURE = 1 << 2,
+ CALOBJ_MOD_ALL = 0x07
+} CalObjModType;
+
/* Used for mode stuff */
typedef enum {
CAL_MODE_INVALID = -1,
@@ -66,12 +74,14 @@ icalcomponent *cal_util_new_top_level (void);
CalComponentAlarms *cal_util_generate_alarms_for_comp (CalComponent *comp,
time_t start,
time_t end,
+ CalAlarmAction *omit,
CalRecurResolveTimezoneFn resolve_tzid,
gpointer user_data,
icaltimezone *default_timezone);
int cal_util_generate_alarms_for_list (GList *comps,
time_t start,
time_t end,
+ CalAlarmAction *omit,
GSList **comp_alarms,
CalRecurResolveTimezoneFn resolve_tzid,
gpointer user_data,