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/pcs/cal.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/pcs/cal.c')
-rw-r--r-- | calendar/pcs/cal.c | 120 |
1 files changed, 45 insertions, 75 deletions
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 36791fefcd..5610267b9a 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -168,6 +168,17 @@ Cal_get_uri (PortableServer_Servant servant, return str_uri_copy; } +/* Converts a calendar object type from its CORBA representation to our own + * representation. + */ +static CalObjType +uncorba_obj_type (Evolution_Calendar_CalObjType type) +{ + return (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0) + | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0) + | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0)); +} + /* Cal::get_n_objects method */ static CORBA_long Cal_get_n_objects (PortableServer_Servant servant, @@ -182,16 +193,7 @@ Cal_get_n_objects (PortableServer_Servant servant, cal = CAL (bonobo_object_from_servant (servant)); priv = cal->priv; - /* Translate the CORBA flags to our own flags */ - - t = (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0) - | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0) - | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0) - /* - | ((type & Evolution_Calendar_TYPE_ANY) ? CALOBJ_TYPE_ANY : 0) - */ - ); - + t = uncorba_obj_type (type); n = cal_backend_get_n_objects (priv->backend, t); return n; } @@ -225,33 +227,13 @@ Cal_get_object (PortableServer_Servant servant, } } -/* Cal::get_uids method */ static Evolution_Calendar_CalObjUIDSeq * -Cal_get_uids (PortableServer_Servant servant, - Evolution_Calendar_CalObjType type, - CORBA_Environment *ev) +build_uid_seq (GList *uids) { - Cal *cal; - CalPrivate *priv; - GList *uids, *l; Evolution_Calendar_CalObjUIDSeq *seq; - int t; + GList *l; int n, i; - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - /* Translate the CORBA flags to our own flags */ - - t = (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0) - | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0) - | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0) - /* - | ((type & Evolution_Calendar_TYPE_ANY) ? CALOBJ_TYPE_ANY : 0) - */ - ); - - uids = cal_backend_get_uids (priv->backend, t); n = g_list_length (uids); seq = Evolution_Calendar_CalObjUIDSeq__alloc (); @@ -265,67 +247,56 @@ Cal_get_uids (PortableServer_Servant servant, char *uid; uid = l->data; - seq->_buffer[i] = CORBA_string_dup (uid); } - /* Done */ - - cal_obj_uid_list_free (uids); - return seq; } -/* Builds a CORBA sequence of calendar object instances from a CalObjInstance - * list. - */ -static Evolution_Calendar_CalObjInstanceSeq * -build_object_instance_seq (GList *list) +/* Cal::get_uids method */ +static Evolution_Calendar_CalObjUIDSeq * +Cal_get_uids (PortableServer_Servant servant, + Evolution_Calendar_CalObjType type, + CORBA_Environment *ev) { - 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); + Cal *cal; + CalPrivate *priv; + GList *uids; + Evolution_Calendar_CalObjUIDSeq *seq; + int t; - /* Fill the sequence */ + cal = CAL (bonobo_object_from_servant (servant)); + priv = cal->priv; - for (i = 0, l = list; l; i++, l = l->next) { - CalObjInstance *icoi; - Evolution_Calendar_CalObjInstance *corba_icoi; + t = uncorba_obj_type (type); - icoi = l->data; - corba_icoi = &seq->_buffer[i]; + uids = cal_backend_get_uids (priv->backend, t); + seq = build_uid_seq (uids); - corba_icoi->uid = CORBA_string_dup (icoi->uid); - corba_icoi->start = icoi->start; - corba_icoi->end = icoi->end; - } + cal_obj_uid_list_free (uids); return seq; } -/* Cal::get_events_in_range method */ -static Evolution_Calendar_CalObjInstanceSeq * -Cal_get_events_in_range (PortableServer_Servant servant, - Evolution_Calendar_Time_t start, - Evolution_Calendar_Time_t end, - CORBA_Environment *ev) +/* Cal::get_objects_in_range method */ +static Evolution_Calendar_CalObjUIDSeq * +Cal_get_objects_in_range (PortableServer_Servant servant, + Evolution_Calendar_CalObjType type, + Evolution_Calendar_Time_t start, + Evolution_Calendar_Time_t end, + CORBA_Environment *ev) { Cal *cal; CalPrivate *priv; + int t; time_t t_start, t_end; - Evolution_Calendar_CalObjInstanceSeq *seq; - GList *elist; + Evolution_Calendar_CalObjUIDSeq *seq; + GList *uids; cal = CAL (bonobo_object_from_servant (servant)); priv = cal->priv; + t = uncorba_obj_type (type); t_start = (time_t) start; t_end = (time_t) end; @@ -336,11 +307,10 @@ Cal_get_events_in_range (PortableServer_Servant servant, return NULL; } - /* Figure out the list and allocate the sequence */ + uids = cal_backend_get_objects_in_range (priv->backend, t, t_start, t_end); + seq = build_uid_seq (uids); - elist = cal_backend_get_events_in_range (priv->backend, t_start, t_end); - seq = build_object_instance_seq (elist); - cal_obj_instance_list_free (elist); + cal_obj_uid_list_free (uids); return seq; } @@ -588,7 +558,7 @@ cal_get_epv (void) epv->get_n_objects = Cal_get_n_objects; epv->get_object = Cal_get_object; epv->get_uids = Cal_get_uids; - epv->get_events_in_range = Cal_get_events_in_range; + epv->get_objects_in_range = Cal_get_objects_in_range; epv->get_alarms_in_range = Cal_get_alarms_in_range; epv->get_alarms_for_object = Cal_get_alarms_for_object; epv->update_object = Cal_update_object; |