+2005-01-28 Rodrigo Moya <rodrigo@novell.com>
+
+ * idl/Evolution-DataServer-Calendar.idl: removed
+ notifyCategoriesChanged method on CalListener.
+
+ * libedata-cal/e-cal-backend.[ch] (e_cal_backend_init,
+ e_cal_backend_finalize, e_cal_backend_add_client): no need
+ to deal with categories now.
+ (free_category_cb, prune_changed_categories, add_category_cb,
+ notify_categories_changed, idle_notify_categories_changed,
+ e_cal_backend_ref_categories, e_cal_backend_unref_categories):
+ removed.
+
+ * libedata-cal/e-data-cal.[ch]
+ (e_data_cal_notify_categories_changed): removed.
+
+ * backends/file/e-cal-backend-file.c (add_component,
+ remove_recurrence_cb, remove_component, remove_instance,
+ remove_object_instance_cb): no need to deal with categories now.
+
+ * libecal/e-cal-listener.[ch]: removed "categories_changed" signal.
+ (impl_notifyCategoriesChanged): removed.
+ (e_cal_listener_class_init): don't set removed method. Don't create
+ "categories_changed" signal.
+
+ * libecal/e-cal.[ch]: removed "categories_changed" signal.
+ (categories_changed_idle_cb, categories_changed): removed.
+ (e_cal_init): removed connection to listener's "categories_changed"
+ signal.
+ (e_cal_class_init): don't create "categories_changed" signal.
+
2005-01-27 Chenthill Palanisamy <pchenthill@novell.com>
partially Fixes#68541
ECalBackendFilePrivate *priv;
ECalBackendFileObject *obj_data;
const char *uid;
- GSList *categories;
priv = cbfile->priv;
save (cbfile);
}
-
- /* Update the set of categories */
- e_cal_component_get_categories_list (comp, &categories);
- e_cal_backend_ref_categories (E_CAL_BACKEND (cbfile), categories);
- e_cal_component_free_categories_list (categories);
}
/* g_hash_table_foreach_remove() callback to remove recurrences from the calendar */
remove_recurrence_cb (gpointer key, gpointer value, gpointer data)
{
GList *l;
- GSList *categories;
icalcomponent *icalcomp;
ECalBackendFilePrivate *priv;
ECalComponent *comp = value;
l = g_list_find (priv->comp, comp);
priv->comp = g_list_delete_link (priv->comp, l);
- /* Update the set of categories */
- e_cal_component_get_categories_list (comp, &categories);
- e_cal_backend_unref_categories (E_CAL_BACKEND (cbfile), categories);
- e_cal_component_free_categories_list (categories);
-
return TRUE;
}
ECalBackendFilePrivate *priv;
icalcomponent *icalcomp;
GList *l;
- GSList *categories;
priv = cbfile->priv;
l = g_list_find (priv->comp, obj_data->full_object);
g_assert (l != NULL);
priv->comp = g_list_delete_link (priv->comp, l);
-
- /* Update the set of categories */
- e_cal_component_get_categories_list (obj_data->full_object, &categories);
- e_cal_backend_unref_categories (E_CAL_BACKEND (cbfile), categories);
- e_cal_component_free_categories_list (categories);
}
/* remove the recurrences also */
remove_object_instance_cb (gpointer key, gpointer value, gpointer user_data)
{
time_t fromtt, instancett;
- GSList *categories;
ECalComponent *instance = value;
RemoveRecurrenceData *rrdata = user_data;
rrdata->obj_data->recurrences_list = g_list_remove (rrdata->obj_data->recurrences_list, instance);
- /* update the set of categories */
- e_cal_component_get_categories_list (instance, &categories);
- e_cal_backend_unref_categories (E_CAL_BACKEND (rrdata->cbfile), categories);
- e_cal_component_free_categories_list (categories);
-
return TRUE;
}
}
{
char *hash_rid;
ECalComponent *comp;
- GSList *categories;
if (!rid || !*rid)
return;
if (g_hash_table_lookup_extended (obj_data->recurrences, rid, &hash_rid, &comp)) {
- /* update the set of categories */
- e_cal_component_get_categories_list (comp, &categories);
- e_cal_backend_unref_categories (E_CAL_BACKEND (cbfile), categories);
- e_cal_component_free_categories_list (categories);
-
/* remove the component from our data */
icalcomponent_remove_component (cbfile->priv->icalcomp,
e_cal_component_get_icalcomponent (comp));
/* Called from a Calendar when the mode is changed */
oneway void notifyCalSetMode (in SetModeStatus status, in CalMode mode);
- /* Called from a Calendar when the list of categories changes */
- oneway void notifyCategoriesChanged (in StringSeq categories);
-
/* Called from a Calendar when there is an error not notified otherwise */
oneway void notifyErrorOccurred (in string message);
GET_CHANGES,
GET_FREE_BUSY,
QUERY,
- CATEGORIES_CHANGED,
AUTH_REQUIRED,
BACKEND_ERROR,
LAST_SIGNAL
g_signal_emit (G_OBJECT (listener), signals[BACKEND_ERROR], 0, message);
}
-/* ::notifyCategoriesChanged method */
-static void
-impl_notifyCategoriesChanged (PortableServer_Servant servant,
- const GNOME_Evolution_Calendar_StringSeq *categories,
- CORBA_Environment *ev)
-{
- ECalListener *listener;
- ECalListenerPrivate *priv;
-
- listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (!priv->notify)
- return;
-
- g_signal_emit (G_OBJECT (listener), signals[CATEGORIES_CHANGED], 0, categories);
-}
-
\f
/* Object initialization function for the calendar listener */
klass->epv.notifyQuery = impl_notifyQuery;
klass->epv.notifyCalSetMode = impl_notifyCalSetMode;
klass->epv.notifyErrorOccurred = impl_notifyErrorOccurred;
- klass->epv.notifyCategoriesChanged = impl_notifyCategoriesChanged;
klass->epv.notifyAuthRequired = impl_notifyAuthRequired;
object_class->finalize = e_cal_listener_finalize;
NULL, NULL,
e_cal_marshal_VOID__INT_POINTER,
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_POINTER);
- signals[CATEGORIES_CHANGED] =
- g_signal_new ("categories_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ECalListenerClass, categories_changed),
- NULL, NULL,
- e_cal_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
signals [AUTH_REQUIRED] =
g_signal_new ("auth_required",
G_OBJECT_CLASS_TYPE (object_class),
void (*query) (ECalListener *listener, ECalendarStatus status, GNOME_Evolution_Calendar_CalView query);
- void (*categories_changed) (ECalListener *listener, ECalendarStatus status, GPtrArray *categories);
- void (*auth_required) (ECalListener *listener);
+ void (*auth_required) (ECalListener *listener);
void (*backend_error) (ECalListener *listener, ECalendarStatus status, const char *message);
} ECalListenerClass;
CAL_OPENED,
CAL_SET_MODE,
BACKEND_ERROR,
- CATEGORIES_CHANGED,
BACKEND_DIED,
LAST_SIGNAL
};
g_idle_add (backend_error_idle_cb, error_data);
}
-typedef struct
-{
- ECal *ecal;
- GPtrArray *categories;
-} ECalCategoryData;
-
-static gboolean
-categories_changed_idle_cb (gpointer data)
-{
- ECalCategoryData *cat_data = data;
- int i;
-
- g_signal_emit (G_OBJECT (cat_data->ecal), e_cal_signals[CATEGORIES_CHANGED], 0, cat_data->categories);
-
- g_object_unref (cat_data->ecal);
- for (i = 0; i < cat_data->categories->len; i++)
- g_free (cat_data->categories->pdata[i]);
- g_ptr_array_free (cat_data->categories, TRUE);
- g_free (cat_data);
-
- return FALSE;
-}
-
-/* Handle the categories_changed signal from the listener */
-static void
-categories_changed_cb (ECalListener *listener, const GNOME_Evolution_Calendar_StringSeq *categories,
- gpointer data)
-{
- ECalCategoryData *cat_data;
- int i;
-
- cat_data = g_new0 (ECalCategoryData, 1);
-
- cat_data->ecal = g_object_ref (data);
- cat_data->categories = g_ptr_array_new ();
- g_ptr_array_set_size (cat_data->categories, categories->_length);
-
- for (i = 0; i < categories->_length; i++)
- cat_data->categories->pdata[i] = g_strdup (categories->_buffer[i]);
-
- g_idle_add (categories_changed_idle_cb, cat_data);
-}
-
\f
static gboolean
g_signal_connect (G_OBJECT (priv->listener), "get_changes", G_CALLBACK (cal_get_changes_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "get_free_busy", G_CALLBACK (cal_get_free_busy_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "query", G_CALLBACK (cal_query_cb), ecal);
- g_signal_connect (G_OBJECT (priv->listener), "categories_changed", G_CALLBACK (categories_changed_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "backend_error", G_CALLBACK (backend_error_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "auth_required", G_CALLBACK (auth_required_cb), ecal);
}
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
- e_cal_signals[CATEGORIES_CHANGED] =
- g_signal_new ("categories_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ECalClass, categories_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
e_cal_signals[BACKEND_DIED] =
g_signal_new ("backend_died",
G_TYPE_FROM_CLASS (klass),
G_TYPE_NONE, 0);
klass->cal_opened = NULL;
- klass->categories_changed = NULL;
klass->backend_died = NULL;
object_class->finalize = e_cal_finalize;
void (* cal_opened) (ECal *ecal, ECalendarStatus status);
void (* cal_set_mode) (ECal *ecal, ECalSetModeStatus status, CalMode mode);
- void (* categories_changed) (ECal *ecal, GPtrArray *categories);
-
void (* backend_error) (ECal *ecal, const char *message);
void (* backend_died) (ECal *ecal);
};
\f
-/* A category that exists in some of the objects of the calendar */
-typedef struct {
- /* Category name, also used as the key in the categories hash table */
- char *name;
-
- /* Number of objects that have this category */
- int refcount;
-} ECalBackendCategory;
-
/* Private part of the CalBackend structure */
struct _ECalBackendPrivate {
/* The source for this backend */
GMutex *queries_mutex;
EList *queries;
-
- /* Hash table of live categories, temporary hash of
- * added/removed categories, and idle handler for sending
- * category_changed.
- */
- GHashTable *categories;
- GHashTable *changed_categories;
- guint category_idle_id;
/* ECalBackend to pass notifications on to */
ECalBackend *notification_proxy;
static void e_cal_backend_init (ECalBackend *backend);
static void e_cal_backend_finalize (GObject *object);
-static void notify_categories_changed (ECalBackend *backend);
-
#define CLASS(backend) (E_CAL_BACKEND_CLASS (G_OBJECT_GET_CLASS (backend)))
static GObjectClass *parent_class;
/* FIXME bonobo_object_ref/unref? */
priv->queries = e_list_new((EListCopyFunc) g_object_ref, (EListFreeFunc) g_object_unref, NULL);
priv->queries_mutex = g_mutex_new ();
-
- priv->categories = g_hash_table_new (g_str_hash, g_str_equal);
- priv->changed_categories = g_hash_table_new (g_str_hash, g_str_equal);
-}
-
-/* Used from g_hash_table_foreach(), frees a ECalBackendCategory structure */
-static void
-free_category_cb (gpointer key, gpointer value, gpointer data)
-{
- ECalBackendCategory *c = value;
-
- g_free (c->name);
- g_free (c);
-}
-
-static gboolean
-prune_changed_categories (gpointer key, gpointer value, gpointer data)
-{
- ECalBackendCategory *c = value;
-
- if (!c->refcount)
- free_category_cb (key, value, data);
- return TRUE;
}
void
g_object_unref (priv->queries);
- g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL);
- g_hash_table_destroy (priv->changed_categories);
-
- g_hash_table_foreach (priv->categories, free_category_cb, NULL);
- g_hash_table_destroy (priv->categories);
-
g_mutex_free (priv->clients_mutex);
g_mutex_free (priv->queries_mutex);
- if (priv->category_idle_id)
- g_source_remove (priv->category_idle_id);
-
g_free (priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
g_mutex_lock (priv->clients_mutex);
priv->clients = g_list_append (priv->clients, cal);
g_mutex_unlock (priv->clients_mutex);
-
- /* Tell the new client about the list of categories.
- * (Ends up telling all the other clients too, but *shrug*.)
- */
- /* FIXME This doesn't seem right at all */
- notify_categories_changed (backend);
}
void
for (l = priv->clients; l; l = l->next)
e_data_cal_notify_error (l->data, message);
}
-
-static void
-add_category_cb (gpointer name, gpointer category, gpointer data)
-{
- GNOME_Evolution_Calendar_StringSeq *seq = data;
-
- seq->_buffer[seq->_length++] = CORBA_string_dup (name);
-}
-
-static void
-notify_categories_changed (ECalBackend *backend)
-{
- ECalBackendPrivate *priv = backend->priv;
- GNOME_Evolution_Calendar_StringSeq *seq;
- GList *l;
-
- /* Build the sequence of category names */
- seq = GNOME_Evolution_Calendar_StringSeq__alloc ();
- seq->_length = 0;
- seq->_maximum = g_hash_table_size (priv->categories);
- seq->_buffer = CORBA_sequence_CORBA_string_allocbuf (seq->_maximum);
- CORBA_sequence_set_release (seq, TRUE);
-
- g_hash_table_foreach (priv->categories, add_category_cb, seq);
-
- /* Notify the clients */
- for (l = priv->clients; l; l = l->next)
- e_data_cal_notify_categories_changed (l->data, seq);
-
- CORBA_free (seq);
-}
-
-static gboolean
-idle_notify_categories_changed (gpointer data)
-{
- ECalBackend *backend = E_CAL_BACKEND (data);
- ECalBackendPrivate *priv = backend->priv;
-
- if (g_hash_table_size (priv->changed_categories)) {
- notify_categories_changed (backend);
- g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL);
- }
-
- priv->category_idle_id = 0;
-
- return FALSE;
-}
-
-/**
- * e_cal_backend_ref_categories:
- * @backend: A calendar backend
- * @categories: a list of categories
- *
- * Adds 1 to the refcount of each of the named categories. If any of
- * the categories are new, clients will be notified of the updated
- * category list at idle time.
- **/
-void
-e_cal_backend_ref_categories (ECalBackend *backend, GSList *categories)
-{
- ECalBackendPrivate *priv;
- ECalBackendCategory *c;
- const char *name;
-
- priv = backend->priv;
-
- while (categories) {
- name = categories->data;
- c = g_hash_table_lookup (priv->categories, name);
-
- if (c)
- c->refcount++;
- else {
- /* See if it was recently removed */
-
- c = g_hash_table_lookup (priv->changed_categories, name);
- if (c && c->refcount == 0) {
- /* Move it back to the set of live categories */
- g_hash_table_remove (priv->changed_categories, c->name);
-
- c->refcount = 1;
- g_hash_table_insert (priv->categories, c->name, c);
- } else {
- /* Create a new category */
- c = g_new (ECalBackendCategory, 1);
- c->name = g_strdup (name);
- c->refcount = 1;
- g_hash_table_insert (priv->categories, c->name, c);
- g_hash_table_insert (priv->changed_categories, c->name, c);
- }
- }
-
- categories = categories->next;
- }
-
- if (g_hash_table_size (priv->changed_categories) &&
- !priv->category_idle_id)
- priv->category_idle_id = g_idle_add (idle_notify_categories_changed, backend);
-}
-
-/**
- * e_cal_backend_unref_categories:
- * @backend: A calendar backend
- * @categories: a list of categories
- *
- * Subtracts 1 from the refcount of each of the named categories. If
- * any of the refcounts go down to 0, clients will be notified of the
- * updated category list at idle time.
- **/
-void
-e_cal_backend_unref_categories (ECalBackend *backend, GSList *categories)
-{
- ECalBackendPrivate *priv;
- ECalBackendCategory *c;
- const char *name;
-
- priv = backend->priv;
-
- while (categories) {
- name = categories->data;
- c = g_hash_table_lookup (priv->categories, name);
-
- if (c) {
- g_assert (c != NULL);
- g_assert (c->refcount > 0);
-
- c->refcount--;
-
- if (c->refcount == 0) {
- g_hash_table_remove (priv->categories, c->name);
- g_hash_table_insert (priv->changed_categories, c->name, c);
- }
- }
-
- categories = categories->next;
- }
-
- if (g_hash_table_size (priv->changed_categories) &&
- !priv->category_idle_id)
- priv->category_idle_id = g_idle_add (idle_notify_categories_changed, backend);
-}
GNOME_Evolution_Calendar_CalMode mode);
void e_cal_backend_notify_auth_required (ECalBackend *backend);
void e_cal_backend_notify_error (ECalBackend *backend, const char *message);
-void e_cal_backend_ref_categories (ECalBackend *backend, GSList *categories);
-void e_cal_backend_unref_categories (ECalBackend *backend, GSList *categories);
\f
CORBA_exception_free (&ev);
}
-
-/**
- * e_data_cal_notify_categories_changed:
- * @cal: A calendar client interface.
- * @categories: List of categories.
- *
- * Notifies a listener attached to a calendar client interface object about the
- * current set of categories in a calendar backend.
- **/
-void
-e_data_cal_notify_categories_changed (EDataCal *cal, GNOME_Evolution_Calendar_StringSeq *categories)
-{
- EDataCalPrivate *priv;
- CORBA_Environment ev;
-
- g_return_if_fail (cal != NULL);
- g_return_if_fail (E_IS_DATA_CAL (cal));
- g_return_if_fail (categories != NULL);
-
- priv = cal->priv;
- g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_CalListener_notifyCategoriesChanged (priv->listener, categories, &ev);
-
- if (BONOBO_EX (&ev))
- g_message ("e_data_cal_notify_categories_changed(): Could not notify the listener "
- "about the current set of categories");
-
- CORBA_exception_free (&ev);
-}
void e_data_cal_notify_error (EDataCal *cal, const char *message);
-void e_data_cal_notify_categories_changed (EDataCal *cal, GNOME_Evolution_Calendar_StringSeq *categories);
-
-
G_END_DECLS