From cc670cb2ca319599eebac658f1164dbb64d70c65 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 8 Feb 2000 07:08:29 +0000 Subject: New struct to wrap instances of calendar objects for recurrencies and 2000-02-08 Federico Mena Quintero * evolution-calendar.idl (CalObjInstance): New struct to wrap instances of calendar objects for recurrencies and alarms. (Cal::get_events_in_range): New method to get ocurring and recurring events by time range. * cal-backend.c (cal_backend_get_events_in_range): New function to get a list of event instances in a time range. (string_from_ical_object): New internal function. (cal_backend_get_object): Use string_from_ical_object() instead of doing everything ourselves. (cal_backend_get_events_in_range): New function to get a list of the events that occur or recur in a specified time range. * cal-client.c (cal_client_get_events_in_range): Implemented client-side function. * cal-util.h: * cal-util.c: New files with utilities and types common to the client and server parts. (CalObjInstance): New structure to hold an instance of an actual occurrence, recurrence, or alarm trigger of a calendar object. (cal_obj_instance_list_free): New function to free a list of calendar object instances. * cal.c (Cal_get_events_in_range): Implemented new method. * corba-cal.c (cal_repo_get_updated_objects): Free `str' with free(), not g_free(), since calendar_get_as_vcal_string() uses writeMemVObject(), which uses realloc(). Fixed in gnome-pim as well. svn path=/trunk/; revision=1693 --- calendar/cal-client.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'calendar/cal-client.c') diff --git a/calendar/cal-client.c b/calendar/cal-client.c index 63d33610f6..af8b83db34 100644 --- a/calendar/cal-client.c +++ b/calendar/cal-client.c @@ -471,3 +471,57 @@ cal_client_get_object (CalClient *client, const char *uid) CORBA_exception_free (&ev); return retval; } + +GList * +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; + + 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); + + 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); + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("cal_client_get_events_in_range(): could not get the event range"); + CORBA_exception_free (&ev); + return NULL; + } + CORBA_exception_free (&ev); + + /* Create the list in reverse order */ + + elist = 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->calobj = g_strdup (corba_icoi->calobj); + icoi->start = corba_icoi->start; + icoi->end = corba_icoi->end; + + elist = g_list_prepend (elist, icoi); + } + + CORBA_free (seq); + elist = g_list_reverse (elist); + + return elist; +} -- cgit