aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-10-28 21:32:55 +0800
committerDan Winship <danw@src.gnome.org>2003-10-28 21:32:55 +0800
commit179cdf36868b8702b3bc7a78201f6d70142a6a6d (patch)
treed36c7facd86131b3d6037022a6d21551b0685a86
parent196efb7acc28bd33d576a84feebf0b5c608825cf (diff)
downloadgsoc2013-evolution-179cdf36868b8702b3bc7a78201f6d70142a6a6d.tar.gz
gsoc2013-evolution-179cdf36868b8702b3bc7a78201f6d70142a6a6d.tar.zst
gsoc2013-evolution-179cdf36868b8702b3bc7a78201f6d70142a6a6d.zip
New; tell each query about a created/modified/removed object.
* pcs/cal-backend.c (cal_backend_notify_object_created, cal_backend_notify_object_modified, cal_backend_notify_object_removed): New; tell each query about a created/modified/removed object. * pcs/cal.c (cal_notify_object_created): Use cal_backend_notify_object_created. (cal_notify_object_modified, cal_notify_object_removed): Likewise for modified/removed (cal_notify_objects_received): we need both the before and after forms for the modified objects so they can be resolved as adds/modifies/removes per-query. But the caller can just call the cal_backend_* routines for each object anyway, so just remove the created/modified/removed lists. * pcs/cal-backend-sync.c (cal_backend_sync_receive_objects): Remove created/modified/removed list arguments. (_cal_backend_receive_objects): Likewise. * pcs/cal-backend-file.c (cal_backend_file_receive_objects): Remove created/modified/removed list arguments. Replace the one use of *removed with a call to cal_backend_notify_object_removed. svn path=/trunk/; revision=23102
-rw-r--r--calendar/ChangeLog25
-rw-r--r--calendar/pcs/cal-backend-file.c11
-rw-r--r--calendar/pcs/cal-backend-sync.c12
-rw-r--r--calendar/pcs/cal-backend-sync.h7
-rw-r--r--calendar/pcs/cal-backend.c123
-rw-r--r--calendar/pcs/cal-backend.h4
-rw-r--r--calendar/pcs/cal.c104
-rw-r--r--calendar/pcs/cal.h3
8 files changed, 171 insertions, 118 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 64d3db8b87..4a1c47b993 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,28 @@
+2003-10-27 Dan Winship <danw@ximian.com>
+
+ * pcs/cal-backend.c (cal_backend_notify_object_created,
+ cal_backend_notify_object_modified,
+ cal_backend_notify_object_removed): New; tell each query about a
+ created/modified/removed object.
+
+ * pcs/cal.c (cal_notify_object_created): Use
+ cal_backend_notify_object_created.
+ (cal_notify_object_modified, cal_notify_object_removed): Likewise
+ for modified/removed
+ (cal_notify_objects_received): we need both the before and after
+ forms for the modified objects so they can be resolved as
+ adds/modifies/removes per-query. But the caller can just call the
+ cal_backend_* routines for each object anyway, so just remove the
+ created/modified/removed lists.
+
+ * pcs/cal-backend-sync.c (cal_backend_sync_receive_objects):
+ Remove created/modified/removed list arguments.
+ (_cal_backend_receive_objects): Likewise.
+
+ * pcs/cal-backend-file.c (cal_backend_file_receive_objects):
+ Remove created/modified/removed list arguments. Replace the one
+ use of *removed with a call to cal_backend_notify_object_removed.
+
2003-10-27 JP Rosevear <jpr@ximian.com>
* gui/gnome-cal.c (setup_widgets): store config objects as well
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index d99b80a0b7..58429ecbe6 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -1579,8 +1579,7 @@ check_tzids (icalparameter *param, void *data)
/* Update_objects handler for the file backend. */
static CalBackendSyncStatus
-cal_backend_file_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj,
- GList **created, GList **modified, GList **removed)
+cal_backend_file_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj)
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
@@ -1613,8 +1612,6 @@ cal_backend_file_receive_objects (CalBackendSync *backend, Cal *cal, const char
method = icalcomponent_get_method (toplevel_comp);
- *created = *modified = *removed = NULL;
-
/* Build a list of timezones so we can make sure all the objects have valid info */
tzdata.zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@@ -1689,8 +1686,10 @@ cal_backend_file_receive_objects (CalBackendSync *backend, Cal *cal, const char
break;
case ICAL_METHOD_CANCEL:
/* FIXME Do we need to remove the subcomp so it isn't merged? */
- if (cancel_received_object (cbfile, subcomp))
- *removed = g_list_prepend (*removed, g_strdup (icalcomponent_get_uid (subcomp)));
+ if (cancel_received_object (cbfile, subcomp)) {
+ const char *calobj = icalcomponent_as_ical_string (subcomp);
+ cal_backend_notify_object_removed (CAL_BACKEND (backend), icalcomponent_get_uid (subcomp), calobj);
+ }
break;
default:
status = GNOME_Evolution_Calendar_UnsupportedMethod;
diff --git a/calendar/pcs/cal-backend-sync.c b/calendar/pcs/cal-backend-sync.c
index 63f08171c1..c385a89b72 100644
--- a/calendar/pcs/cal-backend-sync.c
+++ b/calendar/pcs/cal-backend-sync.c
@@ -149,15 +149,13 @@ cal_backend_sync_discard_alarm (CalBackendSync *backend, Cal *cal, const char *u
}
CalBackendSyncStatus
-cal_backend_sync_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj,
- GList **created, GList **modified, GList **removed)
+cal_backend_sync_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj)
{
g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync);
- return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync) (backend, cal, calobj,
- created, modified, removed);
+ return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync) (backend, cal, calobj);
}
CalBackendSyncStatus
@@ -393,12 +391,10 @@ static void
_cal_backend_receive_objects (CalBackend *backend, Cal *cal, const char *calobj)
{
CalBackendSyncStatus status;
- GList *created = NULL, *modified = NULL, *removed = NULL;
- status = cal_backend_sync_receive_objects (CAL_BACKEND_SYNC (backend), cal, calobj,
- &created, &modified, &removed);
+ status = cal_backend_sync_receive_objects (CAL_BACKEND_SYNC (backend), cal, calobj);
- cal_notify_objects_received (cal, status, created, modified, removed);
+ cal_notify_objects_received (cal, status);
}
static void
diff --git a/calendar/pcs/cal-backend-sync.h b/calendar/pcs/cal-backend-sync.h
index 3e5ac7c73c..2953ac2afa 100644
--- a/calendar/pcs/cal-backend-sync.h
+++ b/calendar/pcs/cal-backend-sync.h
@@ -48,7 +48,7 @@ struct _CalBackendSyncClass {
CalBackendSyncStatus (*discard_alarm_sync) (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid);
- CalBackendSyncStatus (*receive_objects_sync) (CalBackendSync *backend, Cal *cal, const char *calobj, GList **created, GList **modified, GList **removed);
+ CalBackendSyncStatus (*receive_objects_sync) (CalBackendSync *backend, Cal *cal, const char *calobj);
CalBackendSyncStatus (*send_objects_sync) (CalBackendSync *backend, Cal *cal, const char *calobj);
CalBackendSyncStatus (*get_default_object_sync) (CalBackendSync *backend, Cal *cal, char **object);
@@ -112,10 +112,7 @@ CalBackendSyncStatus cal_backend_sync_discard_alarm (CalBackendSync *backend, Ca
CalBackendSyncStatus cal_backend_sync_receive_objects (CalBackendSync *backend,
Cal *cal,
- const char *calobj,
- GList **created,
- GList **modified,
- GList **removed);
+ const char *calobj);
CalBackendSyncStatus cal_backend_sync_send_objects (CalBackendSync *backend,
Cal *cal,
const char *calobj);
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index 7b299d80bf..df2f7408e4 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -897,6 +897,129 @@ cal_backend_internal_get_timezone (CalBackend *backend, const char *tzid)
}
/**
+ * cal_backend_notify_object_created:
+ * @backend: A calendar backend.
+ * @calobj: iCalendar representation of new object
+ *
+ * Notifies each of the backend's listeners about a new object.
+ *
+ * cal_notify_object_created() calls this for you. You only need to
+ * call cal_backend_notify_object_created() yourself to report objects
+ * created by non-PCS clients.
+ **/
+void
+cal_backend_notify_object_created (CalBackend *backend, const char *calobj)
+{
+ EList *queries;
+ EIterator *iter;
+ Query *query;
+
+ queries = cal_backend_get_queries (backend);
+ iter = e_list_get_iterator (queries);
+
+ while (e_iterator_is_valid (iter)) {
+ query = QUERY (e_iterator_get (iter));
+
+ bonobo_object_ref (query);
+ if (query_object_matches (query, calobj))
+ query_notify_objects_added_1 (query, calobj);
+ bonobo_object_unref (query);
+
+ e_iterator_next (iter);
+ }
+ g_object_unref (iter);
+ g_object_unref (queries);
+}
+
+/**
+ * cal_backend_notify_object_modified:
+ * @backend: A calendar backend.
+ * @old_object: iCalendar representation of the original form of the object
+ * @object: iCalendar representation of the new form of the object
+ *
+ * Notifies each of the backend's listeners about a modified object.
+ *
+ * cal_notify_object_modified() calls this for you. You only need to
+ * call cal_backend_notify_object_modified() yourself to report objects
+ * modified by non-PCS clients.
+ **/
+void
+cal_backend_notify_object_modified (CalBackend *backend,
+ const char *old_object, const char *object)
+{
+ EList *queries;
+ EIterator *iter;
+ Query *query;
+ gboolean old_match, new_match;
+
+ queries = cal_backend_get_queries (backend);
+ iter = e_list_get_iterator (queries);
+
+ while (e_iterator_is_valid (iter)) {
+ query = QUERY (e_iterator_get (iter));
+
+ bonobo_object_ref (query);
+
+ old_match = query_object_matches (query, old_object);
+ new_match = query_object_matches (query, object);
+ if (old_match && new_match)
+ query_notify_objects_modified_1 (query, object);
+ else if (new_match)
+ query_notify_objects_added_1 (query, object);
+ else /* if (old_match) */ {
+ icalcomponent *comp;
+
+ comp = icalcomponent_new_from_string ((char *)old_object);
+ query_notify_objects_removed_1 (query, icalcomponent_get_uid (comp));
+ icalcomponent_free (comp);
+ }
+
+ bonobo_object_unref (query);
+
+ e_iterator_next (iter);
+ }
+ g_object_unref (iter);
+ g_object_unref (queries);
+}
+
+/**
+ * cal_backend_notify_object_removed:
+ * @backend: A calendar backend.
+ * @uid: the UID of the removed object
+ * @old_object: iCalendar representation of the removed object
+ *
+ * Notifies each of the backend's listeners about a removed object.
+ *
+ * cal_notify_object_removed() calls this for you. You only need to
+ * call cal_backend_notify_object_removed() yourself to report objects
+ * removed by non-PCS clients.
+ **/
+void
+cal_backend_notify_object_removed (CalBackend *backend, const char *uid,
+ const char *old_object)
+{
+ EList *queries;
+ EIterator *iter;
+ Query *query;
+
+ queries = cal_backend_get_queries (backend);
+ iter = e_list_get_iterator (queries);
+
+ while (e_iterator_is_valid (iter)) {
+ query = QUERY (e_iterator_get (iter));
+
+ bonobo_object_ref (query);
+ if (query_object_matches (query, old_object))
+ query_notify_objects_removed_1 (query, uid);
+ bonobo_object_unref (query);
+
+ e_iterator_next (iter);
+ }
+ g_object_unref (iter);
+ g_object_unref (queries);
+}
+
+/**
* cal_backend_notify_mode:
* @backend: A calendar backend.
* @status: Status of the mode set
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index 7fa209cdec..5b4e59a6a8 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -160,6 +160,10 @@ icaltimezone* cal_backend_internal_get_timezone (CalBackend *backend, const char
void cal_backend_last_client_gone (CalBackend *backend);
+void cal_backend_notify_object_created (CalBackend *backend, const char *calobj);
+void cal_backend_notify_object_modified (CalBackend *backend, const char *old_object, const char *object);
+void cal_backend_notify_object_removed (CalBackend *backend, const char *uid, const char *old_object);
+
void cal_backend_notify_mode (CalBackend *backend,
GNOME_Evolution_Calendar_Listener_SetModeStatus status,
GNOME_Evolution_Calendar_CalMode mode);
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index deaf44ec92..aec1591da3 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -768,8 +768,6 @@ cal_notify_object_created (Cal *cal, GNOME_Evolution_Calendar_CallStatus status,
const char *uid, const char *object)
{
CalPrivate *priv;
- EList *queries;
- EIterator *iter;
CORBA_Environment ev;
g_return_if_fail (cal != NULL);
@@ -778,25 +776,8 @@ cal_notify_object_created (Cal *cal, GNOME_Evolution_Calendar_CallStatus status,
priv = cal->priv;
g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
- queries = cal_backend_get_queries (priv->backend);
- iter = e_list_get_iterator (queries);
-
- while (e_iterator_is_valid (iter)) {
- Query *query = QUERY (e_iterator_get (iter));
-
- bonobo_object_dup_ref (BONOBO_OBJREF (query), NULL);
-
- if (!query_object_matches (query, object))
- continue;
-
- query_notify_objects_added_1 (query, object);
-
- bonobo_object_release_unref (BONOBO_OBJREF (query), NULL);
-
- e_iterator_next (iter);
- }
- g_object_unref (iter);
- g_object_unref (queries);
+ if (status == GNOME_Evolution_Calendar_Success)
+ cal_backend_notify_object_created (priv->backend, object);
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Listener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev);
@@ -812,8 +793,6 @@ cal_notify_object_modified (Cal *cal, GNOME_Evolution_Calendar_CallStatus status
const char *old_object, const char *object)
{
CalPrivate *priv;
- EList *queries;
- EIterator *iter;
CORBA_Environment ev;
g_return_if_fail (cal != NULL);
@@ -822,36 +801,8 @@ cal_notify_object_modified (Cal *cal, GNOME_Evolution_Calendar_CallStatus status
priv = cal->priv;
g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
- queries = cal_backend_get_queries (priv->backend);
- iter = e_list_get_iterator (queries);
-
- while (object && old_object && e_iterator_is_valid (iter)) {
- Query *query = QUERY (e_iterator_get (iter));
- gboolean old_match, new_match;
-
- bonobo_object_dup_ref (BONOBO_OBJREF (query), NULL);
-
- old_match = query_object_matches (query, old_object);
- new_match = query_object_matches (query, object);
- if (old_match && new_match)
- query_notify_objects_modified_1 (query, object);
- else if (new_match)
- query_notify_objects_added_1 (query, object);
- else /* if (old_match) */ {
- icalcomponent *comp;
-
- comp = icalcomponent_new_from_string ((char *)old_object);
- query_notify_objects_removed_1 (query, icalcomponent_get_uid (comp));
- icalcomponent_free (comp);
- }
- query_notify_query_done (query, GNOME_Evolution_Calendar_Success);
-
- bonobo_object_release_unref (BONOBO_OBJREF (query), NULL);
-
- e_iterator_next (iter);
- }
- g_object_unref (iter);
- g_object_unref (queries);
+ if (status == GNOME_Evolution_Calendar_Success)
+ cal_backend_notify_object_modified (priv->backend, old_object, object);
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Listener_notifyObjectModified (priv->listener, status, &ev);
@@ -867,8 +818,6 @@ cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus status,
const char *uid, const char *object)
{
CalPrivate *priv;
- EList *queries;
- EIterator *iter;
CORBA_Environment ev;
g_return_if_fail (cal != NULL);
@@ -877,25 +826,8 @@ cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus status,
priv = cal->priv;
g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
- queries = cal_backend_get_queries (priv->backend);
- iter = e_list_get_iterator (queries);
-
- while (uid && object && e_iterator_is_valid (iter)) {
- Query *query = QUERY (e_iterator_get (iter));
-
- bonobo_object_dup_ref (BONOBO_OBJREF (query), NULL);
-
- if (!query_object_matches (query, object))
- continue;
-
- query_notify_objects_removed_1 (query, uid);
-
- bonobo_object_release_unref (BONOBO_OBJREF (query), NULL);
-
- e_iterator_next (iter);
- }
- g_object_unref (iter);
- g_object_unref (queries);
+ if (status == GNOME_Evolution_Calendar_Success)
+ cal_backend_notify_object_removed (priv->backend, uid, object);
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Listener_notifyObjectRemoved (priv->listener, status, &ev);
@@ -907,12 +839,9 @@ cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus status,
}
void
-cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status,
- GList *created, GList *modified, GList *removed)
+cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status)
{
CalPrivate *priv;
- EList *queries;
- EIterator *iter;
CORBA_Environment ev;
g_return_if_fail (cal != NULL);
@@ -921,25 +850,6 @@ cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus statu
priv = cal->priv;
g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
- queries = cal_backend_get_queries (priv->backend);
- iter = e_list_get_iterator (queries);
-
- while (e_iterator_is_valid (iter)) {
- Query *query = QUERY (e_iterator_get (iter));
-
- bonobo_object_dup_ref (BONOBO_OBJREF (query), NULL);
-
- query_notify_objects_added (query, created);
- query_notify_objects_modified (query, modified);
- query_notify_objects_removed (query, removed);
-
- bonobo_object_release_unref (BONOBO_OBJREF (query), NULL);
-
- e_iterator_next (iter);
- }
- g_object_unref (iter);
- g_object_unref (queries);
-
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Listener_notifyObjectsReceived (priv->listener, status, &ev);
diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h
index 52d8589ab2..f3d35f1f5f 100644
--- a/calendar/pcs/cal.h
+++ b/calendar/pcs/cal.h
@@ -81,8 +81,7 @@ void cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus st
const char *uid, const char *object);
void cal_notify_alarm_discarded (Cal *cal, GNOME_Evolution_Calendar_CallStatus status);
-void cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status,
- GList *created, GList *modified, GList *removed);
+void cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status);
void cal_notify_objects_sent (Cal *cal, GNOME_Evolution_Calendar_CallStatus status);
void cal_notify_default_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object);