diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-02-17 17:21:20 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-02-17 17:21:20 +0800 |
commit | cf16aa4fb112337616d20f4f2f9c2512cbe5e82f (patch) | |
tree | e8e3eb3c798e3a2492a9f8c1a045b85a04479d99 | |
parent | 514b2de963c04ce463ff84a54933673be284ad45 (diff) | |
download | gsoc2013-evolution-cf16aa4fb112337616d20f4f2f9c2512cbe5e82f.tar.gz gsoc2013-evolution-cf16aa4fb112337616d20f4f2f9c2512cbe5e82f.tar.zst gsoc2013-evolution-cf16aa4fb112337616d20f4f2f9c2512cbe5e82f.zip |
Implemented.
2000-02-17 Federico Mena Quintero <federico@helixcode.com>
* cal-client.c (cal_client_remove_object): Implemented.
* cal.c (cal_notify_remove): Implemented.
(Cal_remove_object): Implemented.
(cal_get_epv): Fill in the remove_object field in the epv.
* cal-backend.c (cal_backend_remove_object): Implemented.
(notify_remove): New function to notify clients that an object was
removed.
svn path=/trunk/; revision=1821
-rw-r--r-- | calendar/ChangeLog | 12 | ||||
-rw-r--r-- | calendar/cal-backend.c | 52 | ||||
-rw-r--r-- | calendar/cal-backend.h | 2 | ||||
-rw-r--r-- | calendar/cal-client.c | 35 | ||||
-rw-r--r-- | calendar/cal-client.h | 2 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.c | 35 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.h | 2 | ||||
-rw-r--r-- | calendar/cal.c | 50 | ||||
-rw-r--r-- | calendar/cal.h | 1 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.c | 52 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.h | 2 | ||||
-rw-r--r-- | calendar/pcs/cal.c | 50 | ||||
-rw-r--r-- | calendar/pcs/cal.h | 1 |
13 files changed, 282 insertions, 14 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index d71c28a186..679107d985 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,15 @@ +2000-02-17 Federico Mena Quintero <federico@helixcode.com> + + * cal-client.c (cal_client_remove_object): Implemented. + + * cal.c (cal_notify_remove): Implemented. + (Cal_remove_object): Implemented. + (cal_get_epv): Fill in the remove_object field in the epv. + + * cal-backend.c (cal_backend_remove_object): Implemented. + (notify_remove): New function to notify clients that an object was + removed. + 2000-02-16 Russell Steinthal <rms39@columbia.edu> * calobj.[ch], eventedit.c, main.c: Change iCalObject.organizer diff --git a/calendar/cal-backend.c b/calendar/cal-backend.c index 1ce4b615c3..6b9894e098 100644 --- a/calendar/cal-backend.c +++ b/calendar/cal-backend.c @@ -856,6 +856,23 @@ notify_update (CalBackend *backend, const char *uid) } } +/* Notifies a backend's clients that an object was removed */ +static void +notify_remove (CalBackend *backend, const char *uid) +{ + CalBackendPrivate *priv; + GList *l; + + priv = backend->priv; + + for (l = priv->clients; l; l = l->next) { + Cal *cal; + + cal = CAL (l->data); + cal_notify_remove (cal, uid); + } +} + /** * cal_backend_update_object: * @backend: A calendar backend. @@ -900,22 +917,45 @@ cal_backend_update_object (CalBackend *backend, const char *uid, const char *cal add_object (backend, new_ico); + /* FIXME: do the notification asynchronously */ + notify_update (backend, new_ico->uid); return TRUE; } -void +/** + * cal_backend_remove_object: + * @backend: A calendar backend. + * @uid: Unique identifier of the object to remove. + * + * Removes an object in a calendar backend. The backend will notify all of its + * clients about the change. + * + * Return value: TRUE on success, FALSE on being passed an UID for an object + * that does not exist in the backend. + **/ +gboolean cal_backend_remove_object (CalBackend *backend, const char *uid) { CalBackendPrivate *priv; + iCalObject *ico; - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); + g_return_val_if_fail (backend != NULL, FALSE); + g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); priv = backend->priv; - g_return_if_fail (priv->loaded); + g_return_val_if_fail (priv->loaded, FALSE); - g_return_if_fail (uid != NULL); + g_return_val_if_fail (uid != NULL, FALSE); - /* FIXME */ + ico = lookup_object (backend, uid); + if (!ico) + return FALSE; + + remove_object (backend, ico); + + /* FIXME: do the notification asynchronously */ + + notify_remove (backend, uid); + return TRUE; } diff --git a/calendar/cal-backend.h b/calendar/cal-backend.h index fab83e4b82..66b1b8f5e3 100644 --- a/calendar/cal-backend.h +++ b/calendar/cal-backend.h @@ -78,7 +78,7 @@ GList *cal_backend_get_events_in_range (CalBackend *backend, time_t start, time_ gboolean cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj); -void cal_backend_remove_object (CalBackend *backend, const char *uid); +gboolean cal_backend_remove_object (CalBackend *backend, const char *uid); diff --git a/calendar/cal-client.c b/calendar/cal-client.c index 9b25740318..ebf2b5cb31 100644 --- a/calendar/cal-client.c +++ b/calendar/cal-client.c @@ -746,3 +746,38 @@ cal_client_update_object (CalClient *client, const char *uid, const char *calobj CORBA_exception_free (&ev); return retval; } + +gboolean +cal_client_remove_object (CalClient *client, const char *uid) +{ + 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); + + retval = FALSE; + + CORBA_exception_init (&ev); + Evolution_Calendar_Cal_remove_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_remove_object(): could not remove the object"); + goto out; + } + + retval = TRUE; + + out: + CORBA_exception_free (&ev); + return retval; +} diff --git a/calendar/cal-client.h b/calendar/cal-client.h index 7baad2c733..7b5c66e510 100644 --- a/calendar/cal-client.h +++ b/calendar/cal-client.h @@ -81,6 +81,8 @@ GList *cal_client_get_events_in_range (CalClient *client, time_t start, time_t e gboolean cal_client_update_object (CalClient *client, const char *uid, const char *calobj); +gboolean cal_client_remove_object (CalClient *client, const char *uid); + END_GNOME_DECLS diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 9b25740318..ebf2b5cb31 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -746,3 +746,38 @@ cal_client_update_object (CalClient *client, const char *uid, const char *calobj CORBA_exception_free (&ev); return retval; } + +gboolean +cal_client_remove_object (CalClient *client, const char *uid) +{ + 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); + + retval = FALSE; + + CORBA_exception_init (&ev); + Evolution_Calendar_Cal_remove_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_remove_object(): could not remove the object"); + goto out; + } + + retval = TRUE; + + out: + CORBA_exception_free (&ev); + return retval; +} diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index 7baad2c733..7b5c66e510 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -81,6 +81,8 @@ GList *cal_client_get_events_in_range (CalClient *client, time_t start, time_t e gboolean cal_client_update_object (CalClient *client, const char *uid, const char *calobj); +gboolean cal_client_remove_object (CalClient *client, const char *uid); + END_GNOME_DECLS diff --git a/calendar/cal.c b/calendar/cal.c index 158e4c493c..8263bfe491 100644 --- a/calendar/cal.c +++ b/calendar/cal.c @@ -325,6 +325,24 @@ Cal_update_object (PortableServer_Servant servant, NULL); } +/* Cal::remove_object method */ +static void +Cal_remove_object (PortableServer_Servant servant, + const Evolution_Calendar_CalObjUID uid, + CORBA_Environment *ev) +{ + Cal *cal; + CalPrivate *priv; + + cal = CAL (bonobo_object_from_servant (servant)); + priv = cal->priv; + + if (!cal_backend_remove_object (priv->backend, uid)) + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Evolution_Calendar_Cal_NotFound, + NULL); +} + /** * cal_get_epv: * @void: @@ -344,6 +362,7 @@ cal_get_epv (void) epv->get_uids = Cal_get_uids; epv->get_events_in_range = Cal_get_events_in_range; epv->update_object = Cal_update_object; + epv->remove_object = Cal_remove_object; return epv; } @@ -507,3 +526,34 @@ cal_notify_update (Cal *cal, const char *uid) CORBA_exception_free (&ev); } + +/** + * cal_notify_remove: + * @cal: A calendar client interface. + * @uid: UID of object that was removed. + * + * Notifies a listener attached to a calendar client interface object about a + * calendar object that was removed. + **/ +void +cal_notify_remove (Cal *cal, const char *uid) +{ + CalPrivate *priv; + CORBA_Environment ev; + + g_return_if_fail (cal != NULL); + g_return_if_fail (IS_CAL (cal)); + g_return_if_fail (uid != NULL); + + priv = cal->priv; + g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); + + CORBA_exception_init (&ev); + Evolution_Calendar_Listener_obj_removed (priv->listener, uid, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("cal_notify_remove(): could not notify the listener " + "about a removed object"); + + CORBA_exception_free (&ev); +} diff --git a/calendar/cal.h b/calendar/cal.h index 18f38f5655..508f36d56c 100644 --- a/calendar/cal.h +++ b/calendar/cal.h @@ -59,6 +59,7 @@ Evolution_Calendar_Cal cal_corba_object_create (BonoboObject *object); Cal *cal_new (CalBackend *backend, Evolution_Calendar_Listener listener); void cal_notify_update (Cal *cal, const char *uid); +void cal_notify_remove (Cal *cal, const char *uid); POA_Evolution_Calendar_Cal__epv *cal_get_epv (void); diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 1ce4b615c3..6b9894e098 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -856,6 +856,23 @@ notify_update (CalBackend *backend, const char *uid) } } +/* Notifies a backend's clients that an object was removed */ +static void +notify_remove (CalBackend *backend, const char *uid) +{ + CalBackendPrivate *priv; + GList *l; + + priv = backend->priv; + + for (l = priv->clients; l; l = l->next) { + Cal *cal; + + cal = CAL (l->data); + cal_notify_remove (cal, uid); + } +} + /** * cal_backend_update_object: * @backend: A calendar backend. @@ -900,22 +917,45 @@ cal_backend_update_object (CalBackend *backend, const char *uid, const char *cal add_object (backend, new_ico); + /* FIXME: do the notification asynchronously */ + notify_update (backend, new_ico->uid); return TRUE; } -void +/** + * cal_backend_remove_object: + * @backend: A calendar backend. + * @uid: Unique identifier of the object to remove. + * + * Removes an object in a calendar backend. The backend will notify all of its + * clients about the change. + * + * Return value: TRUE on success, FALSE on being passed an UID for an object + * that does not exist in the backend. + **/ +gboolean cal_backend_remove_object (CalBackend *backend, const char *uid) { CalBackendPrivate *priv; + iCalObject *ico; - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); + g_return_val_if_fail (backend != NULL, FALSE); + g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); priv = backend->priv; - g_return_if_fail (priv->loaded); + g_return_val_if_fail (priv->loaded, FALSE); - g_return_if_fail (uid != NULL); + g_return_val_if_fail (uid != NULL, FALSE); - /* FIXME */ + ico = lookup_object (backend, uid); + if (!ico) + return FALSE; + + remove_object (backend, ico); + + /* FIXME: do the notification asynchronously */ + + notify_remove (backend, uid); + return TRUE; } diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index fab83e4b82..66b1b8f5e3 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -78,7 +78,7 @@ GList *cal_backend_get_events_in_range (CalBackend *backend, time_t start, time_ gboolean cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj); -void cal_backend_remove_object (CalBackend *backend, const char *uid); +gboolean cal_backend_remove_object (CalBackend *backend, const char *uid); diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 158e4c493c..8263bfe491 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -325,6 +325,24 @@ Cal_update_object (PortableServer_Servant servant, NULL); } +/* Cal::remove_object method */ +static void +Cal_remove_object (PortableServer_Servant servant, + const Evolution_Calendar_CalObjUID uid, + CORBA_Environment *ev) +{ + Cal *cal; + CalPrivate *priv; + + cal = CAL (bonobo_object_from_servant (servant)); + priv = cal->priv; + + if (!cal_backend_remove_object (priv->backend, uid)) + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Evolution_Calendar_Cal_NotFound, + NULL); +} + /** * cal_get_epv: * @void: @@ -344,6 +362,7 @@ cal_get_epv (void) epv->get_uids = Cal_get_uids; epv->get_events_in_range = Cal_get_events_in_range; epv->update_object = Cal_update_object; + epv->remove_object = Cal_remove_object; return epv; } @@ -507,3 +526,34 @@ cal_notify_update (Cal *cal, const char *uid) CORBA_exception_free (&ev); } + +/** + * cal_notify_remove: + * @cal: A calendar client interface. + * @uid: UID of object that was removed. + * + * Notifies a listener attached to a calendar client interface object about a + * calendar object that was removed. + **/ +void +cal_notify_remove (Cal *cal, const char *uid) +{ + CalPrivate *priv; + CORBA_Environment ev; + + g_return_if_fail (cal != NULL); + g_return_if_fail (IS_CAL (cal)); + g_return_if_fail (uid != NULL); + + priv = cal->priv; + g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); + + CORBA_exception_init (&ev); + Evolution_Calendar_Listener_obj_removed (priv->listener, uid, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("cal_notify_remove(): could not notify the listener " + "about a removed object"); + + CORBA_exception_free (&ev); +} diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h index 18f38f5655..508f36d56c 100644 --- a/calendar/pcs/cal.h +++ b/calendar/pcs/cal.h @@ -59,6 +59,7 @@ Evolution_Calendar_Cal cal_corba_object_create (BonoboObject *object); Cal *cal_new (CalBackend *backend, Evolution_Calendar_Listener listener); void cal_notify_update (Cal *cal, const char *uid); +void cal_notify_remove (Cal *cal, const char *uid); POA_Evolution_Calendar_Cal__epv *cal_get_epv (void); |