diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-07-03 05:46:36 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-07-03 05:46:36 +0800 |
commit | 07dacea3edab82eecc1cd487c493edc0ca65da6a (patch) | |
tree | fb5c6766a56b9c217a7592c016ffa9f0b6b321eb /calendar/cal-util | |
parent | 9550352fc56974d889b7e3a5934fcf93985349fc (diff) | |
download | gsoc2013-evolution-07dacea3edab82eecc1cd487c493edc0ca65da6a.tar.gz gsoc2013-evolution-07dacea3edab82eecc1cd487c493edc0ca65da6a.tar.zst gsoc2013-evolution-07dacea3edab82eecc1cd487c493edc0ca65da6a.zip |
Support for repeat/duration properties in alarm components.
2001-07-02 Federico Mena Quintero <federico@ximian.com>
Support for repeat/duration properties in alarm components.
* cal-util/cal-component.h (CalAlarmRepeat): New structure that
pairs the repeat/duration values of an alarm component, which must
be set both together or not set at all.
* cal-util/cal-component.c (CalComponentAlarm): Added fields for
the repeat and duration properties.
(scan_alarm_property): Scan the DURATION and REPEAT properties.
(make_alarm): Nullify/initialize all the fields in the alarm.
(cal_component_alarm_get_repeat): New function.
(cal_component_alarm_set_repeat): New function.
* gui/dialogs/alarm-page.glade: Changed the label of display
alarms from "Show a dialog" to "Display a message".
svn path=/trunk/; revision=10706
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 | 11 |
2 files changed, 85 insertions, 0 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 2398840a19..a9c39143f2 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -152,6 +152,8 @@ struct _CalComponentAlarm { /* Properties */ icalproperty *action; + icalproperty *duration; + icalproperty *repeat; icalproperty *trigger; }; @@ -4126,6 +4128,14 @@ scan_alarm_property (CalComponentAlarm *alarm, icalproperty *prop) alarm->action = prop; break; + case ICAL_DURATION_PROPERTY: + alarm->duration = prop; + break; + + case ICAL_REPEAT_PROPERTY: + alarm->repeat = prop; + break; + case ICAL_TRIGGER_PROPERTY: alarm->trigger = prop; break; @@ -4156,6 +4166,11 @@ make_alarm (icalcomponent *subcomp) alarm->icalcomp = subcomp; alarm->uid = NULL; + alarm->action = NULL; + alarm->duration = NULL; + alarm->repeat = NULL; + alarm->trigger = NULL; + for (prop = icalcomponent_get_first_property (subcomp, ICAL_ANY_PROPERTY); prop; prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY)) @@ -4602,6 +4617,65 @@ cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigg } /** + * cal_component_alarm_get_repeat: + * @alarm: An alarm. + * @repeat: Return value for the repeat/duration properties. + * + * Queries the repeat/duration properties of an alarm. + **/ +void +cal_component_alarm_get_repeat (CalComponentAlarm *alarm, CalAlarmRepeat *repeat) +{ + g_return_if_fail (alarm != NULL); + g_return_if_fail (repeat != NULL); + + g_assert (alarm->icalcomp != NULL); + + if (!(alarm->repeat && alarm->duration)) { + repeat->repetitions = 0; + memset (&repeat->duration, 0, sizeof (repeat->duration)); + return; + } + + repeat->repetitions = icalproperty_get_repeat (alarm->repeat); + repeat->duration = icalproperty_get_duration (alarm->duration); +} + +void +cal_component_alarm_set_repeat (CalComponentAlarm *alarm, CalAlarmRepeat repeat) +{ + g_return_if_fail (alarm != NULL); + g_return_if_fail (repeat.repetitions >= 0); + + g_assert (alarm->icalcomp != NULL); + + /* Delete old properties */ + + if (alarm->repeat) { + icalcomponent_remove_property (alarm->icalcomp, alarm->repeat); + icalproperty_free (alarm->repeat); + alarm->repeat = NULL; + } + + if (alarm->duration) { + icalcomponent_remove_property (alarm->icalcomp, alarm->duration); + icalproperty_free (alarm->duration); + alarm->duration = NULL; + } + + /* Set the new properties */ + + if (repeat.repetitions == 0) + return; /* For zero extra repetitions the properties should not exist */ + + alarm->repeat = icalproperty_new_repeat (repeat.repetitions); + icalcomponent_add_property (alarm->icalcomp, alarm->repeat); + + alarm->duration = icalproperty_new_duration (repeat.duration); + icalcomponent_add_property (alarm->icalcomp, alarm->duration); +} + +/** * cal_component_alarm_free: * @alarm: A calendar alarm. * diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index c8f21963b4..54f9c03a33 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -406,6 +406,14 @@ typedef struct { } u; } CalAlarmTrigger; +typedef struct { + /* Number of extra repetitions, zero for none */ + int repetitions; + + /* Interval between repetitions */ + struct icaldurationtype duration; +} CalAlarmRepeat; + gboolean cal_component_has_alarms (CalComponent *comp); void cal_component_add_alarm (CalComponent *comp, CalComponentAlarm *alarm); void cal_component_remove_alarm (CalComponent *comp, const char *auid); @@ -427,6 +435,9 @@ void cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction ac 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_repeat (CalComponentAlarm *alarm, CalAlarmRepeat *repeat); +void cal_component_alarm_set_repeat (CalComponentAlarm *alarm, CalAlarmRepeat repeat); + void cal_component_alarm_free (CalComponentAlarm *alarm); |