aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client/cal-client.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/cal-client/cal-client.c
parentd91a0645f9f595cbfa953187c366dc569f5e8e41 (diff)
downloadgsoc2013-evolution-d509f47a95ddc37b4ee566eb5980c27f6626c8dc.tar.gz
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/cal-client/cal-client.c')
-rw-r--r--calendar/cal-client/cal-client.c137
1 files changed, 120 insertions, 17 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index c7f5302d14..2e83345d27 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -654,6 +654,34 @@ cal_client_get_uids (CalClient *client, CalObjType type)
return uids;
}
+/* Builds a GList of CalObjInstance structures from the CORBA sequence */
+static GList *
+build_object_instance_list (Evolution_Calendar_CalObjInstanceSeq *seq)
+{
+ GList *list;
+ int i;
+
+ /* Create the list in reverse order */
+
+ list = NULL;
+ for (i = 0; i < seq->_length; i++) {
+ Evolution_Calendar_CalObjInstance *corba_icoi;
+ CalObjInstance *icoi;
+
+ corba_icoi = &seq->_buffer[i];
+ icoi = g_new (CalObjInstance, 1);
+
+ icoi->uid = g_strdup (corba_icoi->uid);
+ icoi->start = corba_icoi->start;
+ icoi->end = corba_icoi->end;
+
+ list = g_list_prepend (list, icoi);
+ }
+
+ list = g_list_reverse (list);
+ return list;
+}
+
/**
* cal_client_get_events_in_range:
* @client: A calendar client.
@@ -671,22 +699,18 @@ cal_client_get_events_in_range (CalClient *client, time_t start, time_t end)
CalClientPrivate *priv;
CORBA_Environment ev;
Evolution_Calendar_CalObjInstanceSeq *seq;
- GList *elist;
- int i;
+ GList *events;
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
priv = client->priv;
- /*g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL);*/
if (priv->load_state != LOAD_STATE_LOADED)
return NULL;
g_return_val_if_fail (start != -1 && end != -1, NULL);
g_return_val_if_fail (start <= end, NULL);
- priv = client->priv;
-
CORBA_exception_init (&ev);
seq = Evolution_Calendar_Cal_get_events_in_range (priv->cal, start, end, &ev);
@@ -697,28 +721,107 @@ cal_client_get_events_in_range (CalClient *client, time_t start, time_t end)
}
CORBA_exception_free (&ev);
- /* Create the list in reverse order */
+ events = build_object_instance_list (seq);
+ CORBA_free (seq);
+
+ return events;
+}
+
+/* Translates the CORBA representation of an AlarmType */
+static enum AlarmType
+uncorba_alarm_type (Evolution_Calendar_AlarmType corba_type)
+{
+ switch (corba_type) {
+ case Evolution_Calendar_MAIL:
+ return ALARM_MAIL;
+
+ case Evolution_Calendar_PROGRAM:
+ return ALARM_PROGRAM;
+
+ case Evolution_Calendar_DISPLAY:
+ return ALARM_DISPLAY;
+
+ case Evolution_Calendar_AUDIO:
+ return ALARM_AUDIO;
+
+ default:
+ g_assert_not_reached ();
+ return ALARM_DISPLAY;
+ }
+}
+
+/* Builds a GList of CalAlarmInstance structures from the CORBA sequence */
+static GList *
+build_alarm_instance_list (Evolution_Calendar_CalAlarmInstanceSeq *seq)
+{
+ GList *list;
+ int i;
- elist = NULL;
+ /* Create the list in reverse order */
+ list = NULL;
for (i = 0; i < seq->_length; i++) {
- Evolution_Calendar_CalObjInstance *corba_icoi;
- CalObjInstance *icoi;
+ Evolution_Calendar_CalAlarmInstance *corba_ai;
+ CalAlarmInstance *ai;
- corba_icoi = &seq->_buffer[i];
- icoi = g_new (CalObjInstance, 1);
+ corba_ai = &seq->_buffer[i];
+ ai = g_new (CalAlarmInstance, 1);
- icoi->uid = g_strdup (corba_icoi->uid);
- icoi->start = corba_icoi->start;
- icoi->end = corba_icoi->end;
+ ai->uid = g_strdup (corba_ai->uid);
+ ai->type = uncorba_alarm_type (corba_ai->type);
+ ai->trigger = corba_ai->trigger;
+ ai->occur = corba_ai->occur;
- elist = g_list_prepend (elist, icoi);
+ list = g_list_prepend (list, ai);
}
+ list = g_list_reverse (list);
+ return list;
+}
+
+/**
+ * cal_client_get_alarms_in_range:
+ * @client: A calendar client.
+ * @start: Start time for query.
+ * @end: End time for query.
+ *
+ * Queries a calendar for the alarms that trigger in the specified range of
+ * time.
+ *
+ * Return value: A list of #CalAlarmInstance structures.
+ **/
+GList *
+cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end)
+{
+ CalClientPrivate *priv;
+ CORBA_Environment ev;
+ Evolution_Calendar_CalAlarmInstanceSeq *seq;
+ GList *alarms;
+
+ g_return_val_if_fail (client != NULL, NULL);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
+
+ priv = client->priv;
+ if (priv->load_state != LOAD_STATE_LOADED)
+ return NULL;
+
+ g_return_val_if_fail (start != -1 && end != -1, NULL);
+ g_return_val_if_fail (start <= end, NULL);
+
+ CORBA_exception_init (&ev);
+
+ seq = Evolution_Calendar_Cal_get_alarms_in_range (priv->cal, start, end, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_message ("cal_client_get_alarms_in_range(): could not get the alarm range");
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+ CORBA_exception_free (&ev);
+
+ alarms = build_alarm_instance_list (seq);
CORBA_free (seq);
- elist = g_list_reverse (elist);
- return elist;
+ return alarms;
}
/**