From 943862dd20ad79007900192fec5c705e9748542a Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Fri, 9 Jun 2000 07:04:09 +0000 Subject: Added a get_n_objects() method. 2000-06-09 Federico Mena Quintero * idl/evolution-calendar.idl (Cal): Added a get_n_objects() method. * pcs/cal-backend.c (cal_backend_get_n_objects): New function. * pcs/cal-backend-imc.c (cal_backend_imc_get_n_objects): Implemented. * pcs/cal.c (Cal_get_n_objects): Implemented. * cal-client/cal-client.c (cal_client_get_uids): Free the ev. (cal_client_get_n_objects): Implemented. * cal-util/calobj.h (iCalObjectField): New enumeration to identify the fields in an iCalObject. svn path=/trunk/; revision=3486 --- calendar/cal-client/cal-client.c | 43 +++++++++++++++++++++++++++++++++++++--- calendar/cal-client/cal-client.h | 2 ++ 2 files changed, 42 insertions(+), 3 deletions(-) (limited to 'calendar/cal-client') diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 23ab9bc003..921e2dac59 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -551,6 +551,42 @@ cal_client_create_calendar (CalClient *client, const char *str_uri) return load_or_create (client, str_uri, FALSE); } +int +cal_client_get_n_objects (CalClient *client, CalObjType type) +{ + CalClientPrivate *priv; + CORBA_Environment ev; + int n; + int t; + + g_return_val_if_fail (client != NULL, -1); + g_return_val_if_fail (IS_CAL_CLIENT (client), -1); + + 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_OTHER) ? Evolution_Calendar_TYPE_OTHER : 0) + /* + | ((type & CALOBJ_TYPE_ANY) ? Evolution_Calendar_TYPE_ANY : 0) + */ + ); + + CORBA_exception_init (&ev); + n = Evolution_Calendar_Cal_get_n_objects (priv->cal, t, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("cal_client_get_n_objects(): could not get the number of objects"); + CORBA_exception_free (&ev); + return -1; + } + + CORBA_exception_free (&ev); + return n; +} + /** * cal_client_get_object: * @client: A calendar client. @@ -562,9 +598,8 @@ cal_client_create_calendar (CalClient *client, const char *str_uri) * sought object, or NULL if no object had the specified UID. A complete * calendar is returned because you also need the timezone data. **/ -CalClientGetStatus cal_client_get_object (CalClient *client, - const char *uid, - iCalObject **ico) +CalClientGetStatus +cal_client_get_object (CalClient *client, const char *uid, iCalObject **ico) { CalClientPrivate *priv; CORBA_Environment ev; @@ -677,6 +712,8 @@ cal_client_get_uids (CalClient *client, CalObjType type) return NULL; } + CORBA_exception_free (&ev); + /* Create the list */ uids = NULL; diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index 755b005f74..947c9dd5dc 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -81,6 +81,8 @@ CalClient *cal_client_new (void); gboolean cal_client_load_calendar (CalClient *client, const char *str_uri); gboolean cal_client_create_calendar (CalClient *client, const char *str_uri); +int cal_client_get_n_objects (CalClient *client, CalObjType type); + CalClientGetStatus cal_client_get_object (CalClient *client, const char *uid, iCalObject **ico); -- cgit v1.2.3