aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/cal-client')
-rw-r--r--calendar/cal-client/cal-client.c137
-rw-r--r--calendar/cal-client/cal-client.h2
2 files changed, 122 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;
}
/**
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index e4731980e0..5bb672229d 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -80,6 +80,8 @@ GList *cal_client_get_uids (CalClient *client, CalObjType type);
GList *cal_client_get_events_in_range (CalClient *client, time_t start, time_t end);
+GList *cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end);
+
gboolean cal_client_update_object (CalClient *client, const char *uid, const char *calobj);
gboolean cal_client_remove_object (CalClient *client, const char *uid);