aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs/cal.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-05-12 01:31:30 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-05-12 01:31:30 +0800
commitd509f47a95ddc37b4ee566eb5980c27f6626c8dc (patch)
tree6d3a28f5a616835ad0f81a308606850b47ace2e6 /calendar/pcs/cal.c
parentd91a0645f9f595cbfa953187c366dc569f5e8e41 (diff)
downloadgsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.tar
gsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.tar.gz
gsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.tar.bz2
gsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.tar.lz
gsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.tar.xz
gsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.tar.zst
gsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.zip
Removed unused arguments. Load the initial alarms here. (load_alarms): New
2000-05-11 Federico Mena Quintero <federico@helixcode.com> * gui/gnome-cal.c (gnome_calendar_update_all): Removed unused arguments. Load the initial alarms here. (load_alarms): New function to load a day's worth of alarms. (gnome_calendar_class_init): Eeeek! This was taking in an incorrect argument type. (gnome_calendar_init): Now the calendar keeps a hash table of UIDs->queued alarms. Create the hash table here. (gnome_calendar_destroy): Destroy the alarms hash table. (gnome_calendar_object_updated_cb): Remove the alarms for the object and regenerate them. (gnome_calendar_object_removed_cb): Remove the alarms for the object. * gui/alarm.c (alarm_add): Do not take in a CalendarAlarm, just the trigger time, the callback and the closure data. Return an opaque identifier for the alarm so that it can be removed by the client code if needed. Use the queue_alarm() helper function. (queue_alarm): Helper function to actually queue the alarm and set up the itimer. Deal with a nonzero return value from setitimer(). (alarm_remove): New function to remove an alarm based on its ID. (pop_alarm): New helper function; pops the first alarm of the queue and resets the timer as appropriate. (alarm_ready): Simplified a lot by using pop_alarm(). * idl/evolution-calendar.idl (Cal): Added get_alarms_in_range(). * pcs/cal.c (build_instance_seq): New function to build a CORBA sequence from the internal list of instances. (Cal_get_events_in_range): Use build_instance_seq(). (Cal_get_alarms_in_range): Implemented new method. * pcs/cal-backend.c (cal_backend_get_alarms_in_range): New function with the get_alarms_in_range() engine. * pcs/cal-backend-imc.c (cal_backend_imc_get_alarms_in_range): Implemented the get_alarms_in_range() method. * cal-client/cal-client.c (cal_client_get_alarms_in_range): New client-side function for getting the alarms. (build_instance_list): New helper function to build the CalObjInstance list from the CORBA sequence. (cal_client_get_events_in_range): Use build_instance_list(). * gui/calendar-commands.h: #include <cal-util/calobj.h>. #include "gnome-cal.h". * gui/e-week-view.c: #include "calendar-commands.h" instead of main.h; the latter is an obsolete file and will be killed. * gui/evolution-calendar-control.c (main): Call init_bonobo() before anything else. We need the GTK+ object system initialized. * gui/Makefile.am (evolution_calendar_SOURCES): Do not use main.h. * cal-util/cal-util.c (cal_alarm_instance_list_free): New function. svn path=/trunk/; revision=2987
Diffstat (limited to 'calendar/pcs/cal.c')
-rw-r--r--calendar/pcs/cal.c133
1 files changed, 118 insertions, 15 deletions
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index e1d3623ccf..8fc1de51b2 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -250,6 +250,40 @@ Cal_get_uids (PortableServer_Servant servant,
return seq;
}
+/* Builds a CORBA sequence of calendar object instances from a CalObjInstance
+ * list.
+ */
+static Evolution_Calendar_CalObjInstanceSeq *
+build_object_instance_seq (GList *list)
+{
+ GList *l;
+ int n, i;
+ Evolution_Calendar_CalObjInstanceSeq *seq;
+
+ n = g_list_length (list);
+
+ seq = Evolution_Calendar_CalObjInstanceSeq__alloc ();
+ CORBA_sequence_set_release (seq, TRUE);
+ seq->_length = n;
+ seq->_buffer = CORBA_sequence_Evolution_Calendar_CalObjInstance_allocbuf (n);
+
+ /* Fill the sequence */
+
+ for (i = 0, l = list; l; i++, l = l->next) {
+ CalObjInstance *icoi;
+ Evolution_Calendar_CalObjInstance *corba_icoi;
+
+ icoi = l->data;
+ corba_icoi = &seq->_buffer[i];
+
+ corba_icoi->uid = CORBA_string_dup (icoi->uid);
+ corba_icoi->start = icoi->start;
+ corba_icoi->end = icoi->end;
+ }
+
+ return seq;
+}
+
/* Cal::get_events_in_range method */
static Evolution_Calendar_CalObjInstanceSeq *
Cal_get_events_in_range (PortableServer_Servant servant,
@@ -261,8 +295,7 @@ Cal_get_events_in_range (PortableServer_Servant servant,
CalPrivate *priv;
time_t t_start, t_end;
Evolution_Calendar_CalObjInstanceSeq *seq;
- GList *elist, *l;
- int n, i;
+ GList *elist;
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
@@ -280,30 +313,99 @@ Cal_get_events_in_range (PortableServer_Servant servant,
/* Figure out the list and allocate the sequence */
elist = cal_backend_get_events_in_range (priv->backend, t_start, t_end);
- n = g_list_length (elist);
+ seq = build_object_instance_seq (elist);
+ cal_obj_instance_list_free (elist);
- seq = Evolution_Calendar_CalObjInstanceSeq__alloc ();
+ return seq;
+}
+
+/* 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;
+ }
+}
+
+/* Builds a CORBA sequence of alarm instances from a CalAlarmInstance list. */
+static Evolution_Calendar_CalAlarmInstanceSeq *
+build_alarm_instance_seq (GList *alarms)
+{
+ GList *l;
+ int n, i;
+ Evolution_Calendar_CalAlarmInstanceSeq *seq;
+
+ n = g_list_length (alarms);
+
+ seq = Evolution_Calendar_CalAlarmInstanceSeq__alloc ();
CORBA_sequence_set_release (seq, TRUE);
seq->_length = n;
- seq->_buffer = CORBA_sequence_Evolution_Calendar_CalObjInstance_allocbuf (n);
+ seq->_buffer = CORBA_sequence_Evolution_Calendar_CalAlarmInstance_allocbuf (n);
/* Fill the sequence */
- for (i = 0, l = elist; l; i++, l = l->next) {
- CalObjInstance *icoi;
- Evolution_Calendar_CalObjInstance *corba_icoi;
+ for (i = 0, l = alarms; l; i++, l = l->next) {
+ CalAlarmInstance *ai;
+ Evolution_Calendar_CalAlarmInstance *corba_ai;
- icoi = l->data;
- corba_icoi = &seq->_buffer[i];
+ ai = l->data;
+ corba_ai = &seq->_buffer[i];
- corba_icoi->uid = CORBA_string_dup (icoi->uid);
- corba_icoi->start = icoi->start;
- corba_icoi->end = icoi->end;
+ corba_ai->uid = CORBA_string_dup (ai->uid);
+ corba_ai->type = corba_alarm_type (ai->type);
+ corba_ai->trigger = ai->trigger;
+ corba_ai->occur = ai->occur;
}
- /* Done */
+ return seq;
+}
- cal_obj_instance_list_free (elist);
+/* Cal::get_alarms_in_range method */
+static Evolution_Calendar_CalAlarmInstanceSeq *
+Cal_get_alarms_in_range (PortableServer_Servant servant,
+ const Evolution_Calendar_Time_t start,
+ const Evolution_Calendar_Time_t end,
+ CORBA_Environment *ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+ time_t t_start, t_end;
+ Evolution_Calendar_CalAlarmInstanceSeq *seq;
+ GList *alarms;
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ t_start = (time_t) start;
+ t_end = (time_t) end;
+
+ if (t_start > t_end || t_start == -1 || t_end == -1) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_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;
}
@@ -363,6 +465,7 @@ cal_get_epv (void)
epv->get_object = Cal_get_object;
epv->get_uids = Cal_get_uids;
epv->get_events_in_range = Cal_get_events_in_range;
+ epv->get_alarms_in_range = Cal_get_alarms_in_range;
epv->update_object = Cal_update_object;
epv->remove_object = Cal_remove_object;