diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-02-12 10:03:58 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 2000-02-12 10:03:58 +0800 |
commit | d2fe58c56857e9e4b2e37f87174da6956b0d985c (patch) | |
tree | e71df413e8a7862616755f64700b1dbbc513f9be /calendar/cal-client.c | |
parent | 123f506198c535dcb073c1998fed37c25ad131f9 (diff) | |
download | gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar.gz gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar.bz2 gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar.lz gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar.xz gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.tar.zst gsoc2013-evolution-d2fe58c56857e9e4b2e37f87174da6956b0d985c.zip |
Implemented.
2000-02-11 Federico Mena Quintero <federico@helixcode.com>
* cal-client.c (cal_client_update_object): Implemented.
* cal.c (cal_notify_update): New function to notify the listener
about an updated object.
(Cal_update_object): Implemented.
(Cal_get_uids): set_release() the sequence to TRUE.
(Cal_get_events_in_range): Likewise.
* cal-backend.c (remove_object): New function to remove objects
from a calendar backend.
(cal_backend_update_object): New public function to update an
object and notify clients about it.
* evolution-calendar.idl (Cal): Added update_object() and
delete_object() methods.
(Listener): Removed the obj_changed method and renamed obj_added
to obj_updated. We now only have updated and removed notifiers.
* cal-listener.[ch]: Removed the "changed" notification code.
Changed the "added" notification code to the "updated"
notification.
* cal-client.c: Likewise.
* tlacuache.c (create_cal_factory): Connect to "destroy" on the
factory and exit the main loop when the factory is destroyed.
* cal-factory.c (backend_destroy_cb): New callback used when a
backend is destroyed. Removes the backend from the factory's hash
table and unrefs the factory if all backends go away.
(add_calendar_client): Free the environment.
* cal.c (cal_new): Use bonobo_object_unref() if we fail to
initialize.
* cal-listener.c (cal_listener_new): Likewise.
* layout.c (layout_events): Plug li.partition memory leak.
svn path=/trunk/; revision=1742
Diffstat (limited to 'calendar/cal-client.c')
-rw-r--r-- | calendar/cal-client.c | 93 |
1 files changed, 60 insertions, 33 deletions
diff --git a/calendar/cal-client.c b/calendar/cal-client.c index aa8cdcf50c..9b25740318 100644 --- a/calendar/cal-client.c +++ b/calendar/cal-client.c @@ -54,9 +54,8 @@ typedef struct { /* Signal IDs */ enum { CAL_LOADED, - OBJ_ADDED, + OBJ_UPDATED, OBJ_REMOVED, - OBJ_CHANGED, LAST_SIGNAL }; @@ -120,11 +119,11 @@ cal_client_class_init (CalClientClass *class) gtk_marshal_NONE__ENUM, GTK_TYPE_NONE, 1, GTK_TYPE_ENUM); - cal_client_signals[OBJ_ADDED] = - gtk_signal_new ("obj_added", + cal_client_signals[OBJ_UPDATED] = + gtk_signal_new ("obj_updated", GTK_RUN_FIRST, object_class->type, - GTK_SIGNAL_OFFSET (CalClientClass, obj_added), + GTK_SIGNAL_OFFSET (CalClientClass, obj_updated), gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING); @@ -136,14 +135,6 @@ cal_client_class_init (CalClientClass *class) gtk_marshal_NONE__STRING, GTK_TYPE_NONE, 1, GTK_TYPE_STRING); - cal_client_signals[OBJ_CHANGED] = - gtk_signal_new ("obj_changed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (CalClientClass, obj_changed), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, - GTK_TYPE_STRING); gtk_object_class_add_signals (object_class, cal_client_signals, LAST_SIGNAL); @@ -215,7 +206,7 @@ static void destroy_cal (CalClient *client) { CalClientPrivate *priv; - CORBA_Environment ev; + CORBA_Environment ev; int result; priv = client->priv; @@ -233,7 +224,7 @@ destroy_cal (CalClient *client) if (result) return; - + CORBA_exception_init (&ev); Evolution_Calendar_Cal_unref (priv->cal, &ev); if (ev._major != CORBA_NO_EXCEPTION) @@ -343,14 +334,14 @@ cal_loaded_cb (CalListener *listener, client_status); } -/* Handle the obj_added signal from the listener */ +/* Handle the obj_updated signal from the listener */ static void -obj_added_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data) +obj_updated_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data) { CalClient *client; client = CAL_CLIENT (data); - gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_ADDED], uid); + gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_UPDATED], uid); } /* Handle the obj_removed signal from the listener */ @@ -363,16 +354,6 @@ obj_removed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, g gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_REMOVED], uid); } -/* Handle the obj_changed signal from the listener */ -static void -obj_changed_cb (CalListener *listener, const Evolution_Calendar_CalObjUID uid, gpointer data) -{ - CalClient *client; - - client = CAL_CLIENT (data); - gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[OBJ_CHANGED], uid); -} - /** @@ -484,15 +465,12 @@ load_or_create (CalClient *client, const char *str_uri, gboolean load) gtk_signal_connect (GTK_OBJECT (priv->listener), "cal_loaded", GTK_SIGNAL_FUNC (cal_loaded_cb), client); - gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_added", - GTK_SIGNAL_FUNC (obj_added_cb), + gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_updated", + GTK_SIGNAL_FUNC (obj_updated_cb), client); gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_removed", GTK_SIGNAL_FUNC (obj_removed_cb), client); - gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_changed", - GTK_SIGNAL_FUNC (obj_changed_cb), - client); corba_listener = (Evolution_Calendar_Listener) bonobo_object_corba_objref ( BONOBO_OBJECT (priv->listener)); @@ -719,3 +697,52 @@ cal_client_get_events_in_range (CalClient *client, time_t start, time_t end) return elist; } + +/** + * cal_client_update_object: + * @client: A calendar client. + * @uid: Unique identifier of object to update. + * @calobj: String representation of the new calendar object. + * + * Asks a calendar to update an object based on its UID. Any existing object + * with the specified UID will be replaced. The client program should not + * assume that the object is actually in the server's storage until it has + * received the "obj_updated" notification signal. + * + * Return value: TRUE on success, FALSE on specifying an invalid object. + **/ +gboolean +cal_client_update_object (CalClient *client, const char *uid, const char *calobj) +{ + CalClientPrivate *priv; + CORBA_Environment ev; + gboolean retval; + + g_return_val_if_fail (client != NULL, FALSE); + g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); + + priv = client->priv; + g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE); + + g_return_val_if_fail (uid != NULL, FALSE); + g_return_val_if_fail (calobj != NULL, FALSE); + + retval = FALSE; + + CORBA_exception_init (&ev); + Evolution_Calendar_Cal_update_object (priv->cal, uid, calobj, &ev); + + if (ev._major == CORBA_USER_EXCEPTION && + strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_InvalidObject) == 0) + goto out; + else if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("cal_client_update_object(): could not update the object"); + goto out; + } + + retval = TRUE; + + out: + CORBA_exception_free (&ev); + return retval; +} |