From 9d6fc52249f34b5a3985bea8ace18059be9e4bba Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 2 Feb 2000 09:51:20 +0000 Subject: Added the get_object() method. 2000-02-03 Federico Mena Quintero * evolution-calendar.idl (Cal): Added the get_object() method. * cal-client.c (cal_client_get_object): New function to get a calendar object by its UID. * cal.c (Cal_get_object): Implemented. * cal-backend.c (cal_backend_get_object): New unfinished backend function. We need some reorganizing of how the calendar objects are stored. svn path=/trunk/; revision=1663 --- calendar/cal-client/cal-client.c | 60 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) (limited to 'calendar/cal-client/cal-client.c') diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 05025a07e7..2125760eb0 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -203,7 +203,7 @@ cal_loaded_cb (CalListener *listener, client = CAL_CLIENT (data); priv = client->priv; - g_assert (priv->state == LOAD_STATE_LOADING); + g_assert (priv->load_state == LOAD_STATE_LOADING); switch (status) { case CAL_LISTENER_LOAD_SUCCESS: @@ -217,9 +217,10 @@ cal_loaded_cb (CalListener *listener, CORBA_exception_free (&ev); priv->cal = cal_copy; - priv->load_status = LOAD_STATE_LOADED; + priv->load_state = LOAD_STATE_LOADED; - gtk_signal_emit (client, cal_client_signals[CAL_LOADED], CAL_CLIENT_LOAD_SUCCESS); + gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED], + CAL_CLIENT_LOAD_SUCCESS); goto out; case CAL_LISTENER_LOAD_ERROR: @@ -231,14 +232,15 @@ cal_loaded_cb (CalListener *listener, error: - gtk_object_unref (priv->listener); + gtk_object_unref (GTK_OBJECT (priv->listener)); priv->listener = NULL; priv->load_state = LOAD_STATE_NOT_LOADED; - gtk_signal_emit (client, cal_client_signals[CAL_LOADED], CAL_CLIENT_LOAD_ERROR); + gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED], + CAL_CLIENT_LOAD_ERROR); out: - g_assert (priv->load_state != CAL_STATE_LOADING); + g_assert (priv->load_state != LOAD_STATE_LOADING); } /* Handle the obj_added signal from the listener */ @@ -422,3 +424,49 @@ cal_client_load_calendar (CalClient *client, const char *str_uri) return TRUE; } + +/** + * cal_client_get_object: + * @client: A calendar client. + * @uid: Unique identifier for a calendar object. + * + * Queries a calendar for a calendar object based on its unique identifier. + * + * Return value: The string representation of the calendar object corresponding + * to the specified @uid, or NULL if no such object was found. + **/ +char * +cal_client_get_object (CalClient *client, const char *uid) +{ + CalClientPrivate *priv; + CORBA_Environment ev; + Evolution_Calendar_CalObj calobj; + char *retval; + + 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 (uid != NULL, NULL); + + retval = NULL; + + CORBA_exception_init (&ev); + calobj = Evolution_Calendar_Cal_get_object (priv->cal, uid, &ev); + + if (ev._major == CORBA_USER_EXCEPTION + && strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0) + goto out; + else if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("cal_client_get_object(): could not get the object"); + goto out; + } + + retval = g_strdup (calobj); + + out: + CORBA_exception_free (&ev); + return retval; +} -- cgit