aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs/cal.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-12-19 07:47:52 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-12-19 07:47:52 +0800
commit8d96fe16f15f653d0809603ccaecd677e5708d8d (patch)
tree56d1ccf4be7dcec8a7a09524f2d312ab1da004af /calendar/pcs/cal.c
parenta1d12a819a73754b94eeaf558aefa91e77f169f3 (diff)
downloadgsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar
gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar.gz
gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar.bz2
gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar.lz
gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar.xz
gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.tar.zst
gsoc2013-evolution-8d96fe16f15f653d0809603ccaecd677e5708d8d.zip
Alarm instance generation support for the Wombat.
2000-12-18 Federico Mena Quintero <federico@helixcode.com> Alarm instance generation support for the Wombat. * idl/evolution-calendar.idl (Cal::CalAlarmInstance): Changed to have an alarm UID, the trigger time, and the actual occurrence time. (Cal::CalComponentAlarms): New structure to hold a pair of a component and its alarms that trigger in a particular range of time. (Cal::getAlarmsInRange): Changed to return a CalComponentAlarmsSeq. * cal-util/cal-component.h (CalAlarmInstance): New C-side structure to match the one on the IDL. (CalComponentAlarms): Ditto. (CalAlarmAction): Renamed from CalComponentAlarmAction. (CalAlarmTriggerType): Renamed from CalComponentAlarmTriggerType. Encoded the START and END parameters for the RELATED parameter in this enum, too. Added a NONE value for invalid or missing trigger specifications. (CalComponentAlarmTriggerRelated): Removed. (CalAlarmTrigger): Renamed from CalComponentAlarmTrigger. Renamed the duration/time fields to rel_duration/abs_time, respectively. * cal-util/cal-component.c (cal_component_alarm_get_trigger): Changed to use the new trigger structure. (cal_component_alarm_set_trigger): Likewise. (cal_component_alarm_free_trigger): Removed function. (cal_component_has_alarms): Count the elements in the alarm_uid_hash instead of trying to fetch the first alarm subcomponent. (cal_component_alarms_free): New function to free a CalComponentAlarms structure. (CalComponentAlarmPrivate): Added an uid property pointer. (scan_alarm_property): Scan for the our extension UID property. (cal_component_alarm_get_uid): New function. * pcs/cal-backend.h (CalBackendClass): Changed the signatures of the ::get_alarms_in_range() and ::get_alarms_for_object() methods. * pcs/cal-backend.c (cal_backend_get_alarms_in_range): Changed signature; use the new method. (cal_backend_get_alarms_for_object): Likewise. * pcs/cal-backend-file.c (compute_alarm_range): New spiffy function to compute a range of time for alarm occurrences. (add_alarm_occurrences_cb): New function to add alarms for a particular occurrence of the component. (generate_absolute_triggers): New function to add the absolute alarm triggers. (generate_alarms_for_comp): New function to generate all the alarm instances for a component. (cal_backend_file_get_alarms_in_range): Implemented. * pcs/cal.c (Cal_get_alarms_in_range): Use the new CalBackend API. (Cal_get_alarms_for_object): Likewise. (build_alarm_instance_seq): Removed old function. * cal-util/cal-util.c (cal_alarm_instance_list_free): Removed function. * cal-client/cal-client.c (build_component_alarms_list): New function to demarshal the component alarms sequence. (build_alarm_instance_list): New function to demarshal the alarm instances sequence. (cal_client_get_alarms_in_range): Updated for the new API. (cal_client_get_alarms_for_object): Updated for the new API. * gui/gnome-cal.c: Temporary #ifdef-ing out of alarm-related stuff to make it build. svn path=/trunk/; revision=7076
Diffstat (limited to 'calendar/pcs/cal.c')
-rw-r--r--calendar/pcs/cal.c109
1 files changed, 23 insertions, 86 deletions
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index 179c850475..77f18806d9 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -334,68 +334,8 @@ Cal_get_objects_in_range (PortableServer_Servant servant,
return seq;
}
-#if 0
-/* Translates an enum AlarmType to its CORBA representation */
-static Evolution_Calendar_AlarmType
-corba_alarm_type (enum AlarmType type)
-{
- switch (type) {
- case ALARM_MAIL:
- return Evolution_Calendar_MAIL;
-
- case ALARM_PROGRAM:
- return Evolution_Calendar_PROGRAM;
-
- case ALARM_DISPLAY:
- return Evolution_Calendar_DISPLAY;
-
- case ALARM_AUDIO:
- return Evolution_Calendar_AUDIO;
-
- default:
- g_assert_not_reached ();
- return Evolution_Calendar_DISPLAY;
- }
-}
-#endif
-
-/* Builds a CORBA sequence of alarm instances from a CalAlarmInstance list. */
-static GNOME_Evolution_Calendar_CalAlarmInstanceSeq *
-build_alarm_instance_seq (GList *alarms)
-{
- GList *l;
- int n, i;
- GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq;
-
- n = g_list_length (alarms);
-
- seq = GNOME_Evolution_Calendar_CalAlarmInstanceSeq__alloc ();
- CORBA_sequence_set_release (seq, TRUE);
- seq->_length = n;
- seq->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalAlarmInstance_allocbuf (n);
-
- /* Fill the sequence */
-
- for (i = 0, l = alarms; l; i++, l = l->next) {
- CalAlarmInstance *ai;
- GNOME_Evolution_Calendar_CalAlarmInstance *corba_ai;
-
- ai = l->data;
- corba_ai = &seq->_buffer[i];
-
- corba_ai->uid = CORBA_string_dup (ai->uid);
-#if 0
- corba_ai->type = corba_alarm_type (ai->type);
-#endif
- corba_ai->trigger = ai->trigger;
- corba_ai->occur = ai->occur;
- }
-
- return seq;
-}
-
/* Cal::get_alarms_in_range method */
-static GNOME_Evolution_Calendar_CalAlarmInstanceSeq *
+static GNOME_Evolution_Calendar_CalComponentAlarmsSeq *
Cal_get_alarms_in_range (PortableServer_Servant servant,
GNOME_Evolution_Calendar_Time_t start,
GNOME_Evolution_Calendar_Time_t end,
@@ -404,8 +344,8 @@ Cal_get_alarms_in_range (PortableServer_Servant servant,
Cal *cal;
CalPrivate *priv;
time_t t_start, t_end;
- GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq;
- GList *alarms;
+ gboolean valid_range;
+ GNOME_Evolution_Calendar_CalComponentAlarmsSeq *seq;
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
@@ -413,36 +353,30 @@ Cal_get_alarms_in_range (PortableServer_Servant servant,
t_start = (time_t) start;
t_end = (time_t) end;
- if (t_start > t_end || t_start == -1 || t_end == -1) {
+ seq = cal_backend_get_alarms_in_range (priv->backend, t_start, t_end, &valid_range);
+ if (!valid_range) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Calendar_Cal_InvalidRange,
NULL);
return NULL;
}
- /* Figure out the list and allocate the sequence */
-
- alarms = cal_backend_get_alarms_in_range (priv->backend, t_start, t_end);
- seq = build_alarm_instance_seq (alarms);
- cal_alarm_instance_list_free (alarms);
-
return seq;
}
/* Cal::get_alarms_for_object method */
-static GNOME_Evolution_Calendar_CalAlarmInstanceSeq *
+static GNOME_Evolution_Calendar_CalComponentAlarms *
Cal_get_alarms_for_object (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CalObjUID uid,
GNOME_Evolution_Calendar_Time_t start,
GNOME_Evolution_Calendar_Time_t end,
- CORBA_Environment *ev)
+ CORBA_Environment * ev)
{
Cal *cal;
CalPrivate *priv;
time_t t_start, t_end;
- GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq;
- GList *alarms;
- gboolean result;
+ GNOME_Evolution_Calendar_CalComponentAlarms *alarms;
+ CalBackendGetAlarmsForObjectResult result;
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
@@ -450,25 +384,28 @@ Cal_get_alarms_for_object (PortableServer_Servant servant,
t_start = (time_t) start;
t_end = (time_t) end;
- if (t_start > t_end || t_start == -1 || t_end == -1) {
+ alarms = cal_backend_get_alarms_for_object (priv->backend, uid, t_start, t_end, &result);
+
+ switch (result) {
+ case CAL_BACKEND_GET_ALARMS_SUCCESS:
+ return alarms;
+
+ case CAL_BACKEND_GET_ALARMS_NOT_FOUND:
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_Cal_InvalidRange,
+ ex_GNOME_Evolution_Calendar_Cal_NotFound,
NULL);
return NULL;
- }
- result = cal_backend_get_alarms_for_object (priv->backend, uid, t_start, t_end, &alarms);
- if (!result) {
+ case CAL_BACKEND_GET_ALARMS_INVALID_RANGE:
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_Cal_NotFound,
+ ex_GNOME_Evolution_Calendar_Cal_InvalidRange,
NULL);
return NULL;
- }
-
- seq = build_alarm_instance_seq (alarms);
- cal_alarm_instance_list_free (alarms);
- return seq;
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
}
/* Cal::update_object method */