diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-08-09 06:39:13 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-08-09 06:39:13 +0800 |
commit | 14e163207e7bea5a383f8b538041156dc2cb1c84 (patch) | |
tree | ce88eb76dbadd9a4093e8a6ad544ffe715b19d9c /calendar/cal-client/cal-client.c | |
parent | 9734f4252d8d24fede29bef124b9b5104cf8f0c6 (diff) | |
download | gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar.gz gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar.zst gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.zip |
Added a get_objects_in_range() method. Takes in a time range and the type
2000-08-08 Federico Mena Quintero <federico@helixcode.com>
* idl/evolution-calendar.idl (Cal): Added a get_objects_in_range()
method. Takes in a time range and the type of component we are
interested in; returns a list of UIDs. The idea is that
ocurrences get computed in the client; we can have multiple
recurrences in iCalendar and we cannot identify them trivially
across the wire.
(Cal): Removed the get_events_in_range() method.
* pcs/cal-backend.c (cal_backend_free_uid_list): New function.
(cal_backend_get_objects_in_range): New function.
(cal_backend_get_events_in_range): Removed.
* pcs/cal-backend-file.c (cal_backend_file_get_objects_in_range):
Implemented new method.
(cal_backend_file_get_events_in_range): Removed.
* pcs/cal.c (Cal_get_events_in_range): Removed.
(uncorba_obj_type): New function.
(Cal_get_uids): Use uncorba_obj_type().
(Cal_get_n_objects): Likewise.
(Cal_get_objects_in_range): Implemented new method.
* cal-client/cal-client.c (cal_client_get_events_in_range): Removed.
(cal_client_get_objects_in_range): Implemented.
(corba_obj_type): New function.
(cal_client_get_n_objects): Use corba_obj_type().
(cal_client_get_uids): Likewise.
svn path=/trunk/; revision=4613
Diffstat (limited to 'calendar/cal-client/cal-client.c')
-rw-r--r-- | calendar/cal-client/cal-client.c | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 88685dd1aa..cb35bafc71 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -548,6 +548,15 @@ cal_client_create_calendar (CalClient *client, const char *str_uri) return load_or_create (client, str_uri, FALSE); } +/* Converts our representation of a calendar component type into its CORBA representation */ +static Evolution_Calendar_CalObjType +corba_obj_type (CalObjType type) +{ + return (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0) + | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0) + | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0)); +} + /** * cal_client_get_n_objects: * @client: A calendar client. @@ -572,13 +581,7 @@ cal_client_get_n_objects (CalClient *client, CalObjType type) priv = client->priv; g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, -1); - t = (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0) - | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0) - | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0) - /* - | ((type & CALOBJ_TYPE_ANY) ? Evolution_Calendar_TYPE_ANY : 0) - */ - ); + t = corba_obj_type (type); CORBA_exception_init (&ev); n = Evolution_Calendar_Cal_get_n_objects (priv->cal, t, &ev); @@ -730,7 +733,20 @@ void cal_client_update_pilot_id (CalClient *client, char *uid, CORBA_exception_free (&ev); } +/* Builds an UID list out of a CORBA UID sequence */ +static GList * +build_uid_list (Evolution_Calendar_CalObjUIDSeq *seq) +{ + GList *uids; + int i; + uids = NULL; + + for (i = 0; i < seq->_length; i++) + uids = g_list_prepend (uids, g_strdup (seq->_buffer[i])); + + return uids; +} /** * cal_client_get_uids: @@ -750,23 +766,14 @@ cal_client_get_uids (CalClient *client, CalObjType type) Evolution_Calendar_CalObjUIDSeq *seq; int t; GList *uids; - 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);*/ - if (priv->load_state != LOAD_STATE_LOADED) - return NULL; + g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); - t = (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0) - | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0) - | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0) - /* - | ((type & CALOBJ_TYPE_ANY) ? Evolution_Calendar_TYPE_ANY : 0) - */ - ); + t = corba_obj_type (type); CORBA_exception_init (&ev); @@ -779,13 +786,7 @@ cal_client_get_uids (CalClient *client, CalObjType type) CORBA_exception_free (&ev); - /* Create the list */ - - uids = NULL; - - for (i = 0; i < seq->_length; i++) - uids = g_list_prepend (uids, g_strdup (seq->_buffer[i])); - + uids = build_uid_list (seq); CORBA_free (seq); return uids; @@ -820,23 +821,26 @@ build_object_instance_list (Evolution_Calendar_CalObjInstanceSeq *seq) } /** - * cal_client_get_events_in_range: + * cal_client_get_objects_in_range: * @client: A calendar client. + * @type: Bitmask with types of objects to return. * @start: Start time for query. * @end: End time for query. * - * Queries a calendar for the events that occur or recur in the specified range + * Queries a calendar for the objects that occur or recur in the specified range * of time. * - * Return value: A list of #CalObjInstance structures. + * Return value: A list of UID strings. This should be freed using the + * cal_obj_uid_list_free() function. **/ GList * -cal_client_get_events_in_range (CalClient *client, time_t start, time_t end) +cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t start, time_t end) { CalClientPrivate *priv; CORBA_Environment ev; - Evolution_Calendar_CalObjInstanceSeq *seq; - GList *events; + Evolution_Calendar_CalObjUIDSeq *seq; + GList *uids; + int t; g_return_val_if_fail (client != NULL, NULL); g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); @@ -850,18 +854,20 @@ cal_client_get_events_in_range (CalClient *client, time_t start, time_t end) CORBA_exception_init (&ev); - seq = Evolution_Calendar_Cal_get_events_in_range (priv->cal, start, end, &ev); + t = corba_obj_type (type); + + seq = Evolution_Calendar_Cal_get_objects_in_range (priv->cal, t, start, end, &ev); if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_client_get_events_in_range(): could not get the event range"); + g_message ("cal_client_get_objects_in_range(): could not get the objects"); CORBA_exception_free (&ev); return NULL; } CORBA_exception_free (&ev); - events = build_object_instance_list (seq); + uids = build_uid_list (seq); CORBA_free (seq); - return events; + return uids; } #if 0 @@ -1103,7 +1109,7 @@ cal_client_remove_object (CalClient *client, const char *uid) strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0) goto out; else if (ev._major != CORBA_NO_EXCEPTION) { - /*g_message ("cal_client_remove_object(): could not remove the object");*/ + g_message ("cal_client_remove_object(): could not remove the object"); goto out; } |