From ca082de77aec8542e913e1ce374dd849f51a4a27 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 9 Feb 2000 08:04:33 +0000 Subject: Added get_uids() method to get a list of UIDs based on object types. 2000-02-08 Federico Mena Quintero * evolution-calendar.idl (Cal): Added get_uids() method to get a list of UIDs based on object types. * cal-backend.c (cal_backend_get_uids): Implemented get_uids() in the backend. * cal.c (Cal_get_uids): Implemented get_uids() method. * cal-client.c (cal_client_get_uids): Implemented client-side function. * cal-util.c (cal_obj_instance_list_free): Doh. Free the list, not the last link. (cal_obj_uid_list_free): New function to free a list of UIDs. * GnomeCal.idl (Repository): Removed unused method get_object_by_id_list(). This is just for cleanup purposes and to remind me exactly of what needs to be moved over to evolution-calendar.idl. (Repository): Removed unused get_objects() method. * corba-cal.c (init_calendar_repo_class): Removed the unused get_objects method. * calobj.h (CalObjFindStatus): New status value enumeration for the find function. * calobj.c (ical_object_find_in_string): New function to parse a complete calendar and find a calendar object in it. This should be used instead ical_object_new_from_string() in the future. * evolution-calendar.idl (CalObjInstance): Added an uid field. Now the idea is that whenever calendar object strings are passed around, their UIDs are passed along with them so that the actual object can be pulled from the whole VCAL object using its UID to identify it. * cal-util.h (CalObjInstance): Added uid field. * cal-util.c (cal_obj_instance_list_free): Free the UIDs. * cal-backend.c (build_event_list): Store the object's UID in the instance structure. * cal.c (Cal_get_events_in_range): Copy the UID field to the CORBA structure. * cal-client.c (cal_client_get_events_in_range): Copy the UID field from the CORBA structure. * main.c (gnome_cal_file_menu): Removed unfinished html-month stuff. * Makefile.am (gnomecal_SOURCES): Removed html-month.c. * gnome-cal.c: #include "alarm.h" (mail_notify): Made static. * alarm.h: #include "calobj.h" * corba-cal-factory.h (init_corba_server): Fixed prototype. * quick-view.c (create_items_for_event): Made static. * gncal-todo.c (column_resized): Made static. * layout.c (find_index): Made static. svn path=/trunk/; revision=1699 --- calendar/pcs/cal.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'calendar/pcs/cal.c') diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 664d9ef416..74badc7013 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -196,6 +196,54 @@ Cal_get_object (PortableServer_Servant servant, } } +/* Cal::get_uids method */ +static Evolution_Calendar_CalObjUIDSeq * +Cal_get_uids (PortableServer_Servant servant, + const Evolution_Calendar_CalObjType type, + CORBA_Environment *ev) +{ + Cal *cal; + CalPrivate *priv; + GList *uids, *l; + Evolution_Calendar_CalObjUIDSeq *seq; + int t; + 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_OTHER) ? CALOBJ_TYPE_OTHER : 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 (); + seq->_length = n; + seq->_buffer = CORBA_sequence_Evolution_Calendar_CalObjUID_allocbuf (n); + + /* Fill the sequence */ + + for (i = 0, l = uids; l; i++, l = l->next) { + char *uid; + + uid = l->data; + + seq->_buffer[i] = CORBA_string_dup (uid); + } + + /* Done */ + + 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, @@ -234,13 +282,14 @@ Cal_get_events_in_range (PortableServer_Servant servant, /* Fill the sequence */ - for (i = 0, l = elist; i < n; i++, l = l->next) { + for (i = 0, l = elist; l; i++, l = l->next) { CalObjInstance *icoi; Evolution_Calendar_CalObjInstance *corba_icoi; icoi = l->data; corba_icoi = &seq->_buffer[i]; + corba_icoi->uid = CORBA_string_dup (icoi->uid); corba_icoi->calobj = CORBA_string_dup (icoi->calobj); corba_icoi->start = icoi->start; corba_icoi->end = icoi->end; @@ -269,6 +318,7 @@ cal_get_epv (void) epv = g_new0 (POA_Evolution_Calendar_Cal__epv, 1); epv->_get_uri = Cal_get_uri; epv->get_object = Cal_get_object; + epv->get_uids = Cal_get_uids; epv->get_events_in_range = Cal_get_events_in_range; return epv; -- cgit v1.2.3