[evolution-data-server] Fixed some bugs found in api testing and added some missing api's
- From: Chenthill Palanisamy <pchen src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-data-server] Fixed some bugs found in api testing and added some missing api's
- Date: Mon, 20 Jul 2009 06:54:08 +0000 (UTC)
commit e8c5e6592ff4a5855120621c70f91099cc8c6296
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Mon Jul 20 01:16:04 2009 +0530
Fixed some bugs found in api testing and added some missing api's
store_get_components, store_remove.
calendar/libedata-cal/e-cal-backend-file-store.c | 90 +++++++++++++++++++--
calendar/libedata-cal/e-cal-backend-store.c | 21 +++++
calendar/libedata-cal/e-cal-backend-store.h | 5 +-
3 files changed, 106 insertions(+), 10 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend-file-store.c b/calendar/libedata-cal/e-cal-backend-file-store.c
index 718eecf..509e416 100644
--- a/calendar/libedata-cal/e-cal-backend-file-store.c
+++ b/calendar/libedata-cal/e-cal-backend-file-store.c
@@ -62,6 +62,7 @@ create_new_full_object (void)
FullCompObject *obj;
obj = g_new0 (FullCompObject, 1);
+ obj->comp = NULL;
obj->recurrences = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
return obj;
@@ -75,7 +76,10 @@ destroy_full_object (FullCompObject *obj)
if (obj->comp)
g_object_unref (obj->comp);
+ obj->comp = NULL;
+
g_hash_table_destroy (obj->recurrences);
+ obj->recurrences = NULL;
g_free (obj);
obj = NULL;
@@ -104,6 +108,7 @@ put_component (ECalBackendFileStore *fstore, ECalComponent *comp)
if (obj == NULL) {
obj = create_new_full_object ();
+ g_hash_table_insert (priv->comp_uid_hash, g_strdup (uid), obj);
}
if (!e_cal_component_is_instance (comp)) {
@@ -111,10 +116,11 @@ put_component (ECalBackendFileStore *fstore, ECalComponent *comp)
g_object_unref (obj->comp);
obj->comp = comp;
- g_hash_table_insert (priv->comp_uid_hash, g_strdup (uid), obj);
+ g_object_ref (comp);
} else {
gchar *rid = e_cal_component_get_recurid_as_string (comp);
+ g_object_ref (comp);
g_hash_table_insert (obj->recurrences, g_strdup (rid), comp);
}
@@ -150,7 +156,7 @@ remove_component (ECalBackendFileStore *fstore, const gchar *uid, const gchar *r
remove_completely = TRUE;
if (remove_completely)
- destroy_full_object (obj);
+ g_hash_table_remove (priv->comp_uid_hash, uid);
end:
g_static_rw_lock_writer_unlock (&priv->lock);
@@ -260,11 +266,13 @@ e_cal_backend_file_store_put_timezone (ECalBackendStore *store, const icaltimezo
ECalBackendFileStore *fstore = E_CAL_BACKEND_FILE_STORE (store);
ECalBackendFileStorePrivate *priv;
gboolean ret_val = FALSE;
+ icaltimezone *copy;
priv = GET_PRIVATE (fstore);
g_static_rw_lock_writer_lock (&priv->lock);
- g_hash_table_insert (priv->timezones, g_strdup (icaltimezone_get_tzid ((icaltimezone *) zone)), (icaltimezone *) zone);
+ copy = icaltimezone_copy ((icaltimezone *) zone);
+ g_hash_table_insert (priv->timezones, g_strdup (icaltimezone_get_tzid ((icaltimezone *) zone)), copy);
g_static_rw_lock_writer_unlock (&priv->lock);
if (ret_val) {
@@ -326,7 +334,12 @@ e_cal_backend_file_store_put_key_value (ECalBackendStore *store, const gchar *ke
priv = GET_PRIVATE (fstore);
g_static_rw_lock_writer_lock (&priv->lock);
- ret_val = e_file_cache_replace_object (priv->keys_cache, key, value);
+
+ if (e_file_cache_get_object (priv->keys_cache, key))
+ ret_val = e_file_cache_replace_object (priv->keys_cache, key, value);
+ else
+ ret_val = e_file_cache_add_object (priv->keys_cache, key, value);
+
g_static_rw_lock_writer_unlock (&priv->lock);
return ret_val;
@@ -359,14 +372,22 @@ e_cal_backend_file_store_set_default_timezone (ECalBackendStore *store, const ic
ECalBackendFileStore *fstore = E_CAL_BACKEND_FILE_STORE (store);
ECalBackendFileStorePrivate *priv;
const gchar *tzid;
+ icaltimezone *copy;
+ const char *key = "default-zone";
+ gboolean ret_val;
priv = GET_PRIVATE (fstore);
g_static_rw_lock_writer_lock (&priv->lock);
tzid = icaltimezone_get_tzid ((icaltimezone*) zone);
- g_hash_table_insert (priv->timezones, g_strdup (tzid), (icaltimezone *) zone);
- e_file_cache_replace_object (priv->keys_cache, "default-zone", tzid);
+ copy = icaltimezone_copy ((icaltimezone *) zone);
+ g_hash_table_insert (priv->timezones, g_strdup (tzid), copy);
+
+ if (e_file_cache_get_object (priv->keys_cache, key))
+ ret_val = e_file_cache_replace_object (priv->keys_cache, key, tzid);
+ else
+ ret_val = e_file_cache_add_object (priv->keys_cache, key, tzid);
g_static_rw_lock_writer_unlock (&priv->lock);
@@ -440,6 +461,37 @@ end:
}
static void
+add_full_comp_to_slist (gpointer key, gpointer value, gpointer user_data)
+{
+ GSList **slist = (GSList **) user_data;
+ FullCompObject *obj = NULL;
+
+ obj = value;
+ if (obj->comp) {
+ g_object_ref (obj->comp);
+ *slist = g_slist_prepend (*slist, obj->comp);
+ }
+
+ g_hash_table_foreach (obj->recurrences, (GHFunc) add_comp_to_slist, slist);
+}
+
+static GSList *
+e_cal_backend_file_store_get_components (ECalBackendStore *store)
+{
+ ECalBackendFileStore *fstore = E_CAL_BACKEND_FILE_STORE (store);
+ ECalBackendFileStorePrivate *priv;
+ GSList *comps = NULL;
+
+ priv = GET_PRIVATE (fstore);
+
+ g_static_rw_lock_reader_lock (&priv->lock);
+ g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) add_full_comp_to_slist, &comps);
+ g_static_rw_lock_reader_unlock (&priv->lock);
+
+ return comps;
+}
+
+static void
add_timezone (ECalBackendFileStore *fstore, icalcomponent *vtzcomp)
{
ECalBackendFileStorePrivate *priv;
@@ -447,6 +499,8 @@ add_timezone (ECalBackendFileStore *fstore, icalcomponent *vtzcomp)
icaltimezone *zone;
const gchar *tzid;
+ priv = GET_PRIVATE(fstore);
+
prop = icalcomponent_get_first_property (vtzcomp, ICAL_TZID_PROPERTY);
if (!prop)
return;
@@ -498,7 +552,7 @@ scan_vcalendar (ECalBackendFileStore *fstore, icalcomponent *top_icalcomp)
comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icalcomp))
+ if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)))
continue;
put_component (fstore, comp);
@@ -532,10 +586,17 @@ e_cal_backend_file_store_load (ECalBackendStore *store)
}
scan_vcalendar (fstore, icalcomp);
+ icalcomponent_free (icalcomp);
return TRUE;
}
+static gboolean
+e_cal_backend_file_store_remove (ECalBackendStore *store)
+{
+
+}
+
static void
save_instance (gpointer key, gpointer value, gpointer user_data)
{
@@ -629,6 +690,14 @@ save_cache (ECalBackendFileStore *store)
}
static void
+free_timezone (gpointer data)
+{
+ icaltimezone *zone = data;
+
+ icaltimezone_free (zone, 1);
+}
+
+static void
e_cal_backend_file_store_construct (ECalBackendFileStore *fstore)
{
ECalBackendFileStorePrivate *priv;
@@ -705,6 +774,7 @@ e_cal_backend_file_store_class_init (ECalBackendFileStoreClass *klass)
object_class->finalize = e_cal_backend_file_store_finalize;
store_class->load = e_cal_backend_file_store_load;
+ store_class->remove = e_cal_backend_file_store_remove;
store_class->get_component = e_cal_backend_file_store_get_component;
store_class->put_component = e_cal_backend_file_store_put_component;
store_class->remove_component = e_cal_backend_file_store_remove_component;
@@ -718,6 +788,7 @@ e_cal_backend_file_store_class_init (ECalBackendFileStoreClass *klass)
store_class->put_key = e_cal_backend_file_store_put_key_value;
store_class->thaw_changes = e_cal_backend_file_store_thaw_changes;
store_class->freeze_changes = e_cal_backend_file_store_freeze_changes;
+ store_class->get_components = e_cal_backend_file_store_get_components;
}
static void
@@ -728,7 +799,8 @@ e_cal_backend_file_store_init (ECalBackendFileStore *self)
priv = GET_PRIVATE(self);
self->priv = priv;
- priv->timezones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ priv->timezones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) free_timezone);
priv->comp_uid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) destroy_full_object);
priv->keys_cache = NULL;
g_static_rw_lock_init (&priv->lock);
@@ -744,7 +816,7 @@ e_cal_backend_file_store_new (const gchar *uri, ECalSourceType source_type)
{
ECalBackendFileStore *fstore;
- fstore = g_object_new (E_TYPE_CAL_BACKEND_FILE_STORE, "source_type", source_type, "uri", uri);
+ fstore = g_object_new (E_TYPE_CAL_BACKEND_FILE_STORE, "source_type", source_type, "uri", uri, NULL);
e_cal_backend_file_store_construct (fstore);
return fstore;
diff --git a/calendar/libedata-cal/e-cal-backend-store.c b/calendar/libedata-cal/e-cal-backend-store.c
index 4877673..1380399 100644
--- a/calendar/libedata-cal/e-cal-backend-store.c
+++ b/calendar/libedata-cal/e-cal-backend-store.c
@@ -104,9 +104,11 @@ e_cal_backend_store_set_property (GObject *object, guint property_id, const GVal
switch (property_id) {
case PROP_SOURCE_TYPE:
priv->source_type = g_value_get_enum (value);
+ break;
case PROP_URI:
set_uri (store, g_value_dup_string (value));
set_store_path (store);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec);
}
@@ -125,6 +127,7 @@ e_cal_backend_store_get_property (GObject *object, guint property_id, GValue *va
{
case PROP_SOURCE_TYPE:
g_value_set_enum (value, priv->source_type);
+ break;
case PROP_URI :
g_value_set_string (value, priv->uri);
break;
@@ -231,6 +234,15 @@ e_cal_backend_store_load (ECalBackendStore *store)
return (E_CAL_BACKEND_STORE_GET_CLASS (store))->load (store);
}
+gboolean
+e_cal_backend_store_remove (ECalBackendStore *store)
+{
+ g_return_val_if_fail (store != NULL, FALSE);
+ g_return_val_if_fail (E_IS_CAL_BACKEND_STORE (store), FALSE);
+
+ return (E_CAL_BACKEND_STORE_GET_CLASS (store))->remove (store);
+}
+
ECalComponent *
e_cal_backend_store_get_component (ECalBackendStore *store, const gchar *uid, const gchar *rid)
{
@@ -323,6 +335,15 @@ e_cal_backend_store_get_components_by_uid (ECalBackendStore *store, const gchar
return (E_CAL_BACKEND_STORE_GET_CLASS (store))->get_components_by_uid (store, uid);
}
+GSList *
+e_cal_backend_store_get_components (ECalBackendStore *store)
+{
+ g_return_val_if_fail (store != NULL, NULL);
+ g_return_val_if_fail (E_IS_CAL_BACKEND_STORE (store), NULL);
+
+ return (E_CAL_BACKEND_STORE_GET_CLASS (store))->get_components (store);
+}
+
const gchar *
e_cal_backend_store_get_key (ECalBackendStore *store, const gchar *key)
{
diff --git a/calendar/libedata-cal/e-cal-backend-store.h b/calendar/libedata-cal/e-cal-backend-store.h
index 8c05406..6b4f5bd 100644
--- a/calendar/libedata-cal/e-cal-backend-store.h
+++ b/calendar/libedata-cal/e-cal-backend-store.h
@@ -57,11 +57,13 @@ typedef struct {
/* virtual methods */
gboolean (*load) (ECalBackendStore *store);
+ gboolean (*remove) (ECalBackendStore *store);
ECalComponent * (*get_component) (ECalBackendStore *store, const gchar *uid, const gchar *rid);
gboolean (*put_component) (ECalBackendStore *store, ECalComponent *comp);
gboolean (*remove_component) (ECalBackendStore *store, const gchar *uid, const gchar *rid);
GSList * (*get_components_by_uid) (ECalBackendStore *store, const gchar *uid);
+ GSList * (*get_components) (ECalBackendStore *store);
const icaltimezone * (*get_timezone) (ECalBackendStore *store, const gchar *tzid);
gboolean (*put_timezone) (ECalBackendStore *store, const icaltimezone *zone);
@@ -83,6 +85,7 @@ GType e_cal_backend_store_get_type (void);
const gchar *e_cal_backend_store_get_path (ECalBackendStore *store);
gboolean e_cal_backend_store_load (ECalBackendStore *store);
+gboolean e_cal_backend_store_remove (ECalBackendStore *store);
ECalComponent * e_cal_backend_store_get_component (ECalBackendStore *store, const gchar *uid, const gchar *rid);
gboolean e_cal_backend_store_put_component (ECalBackendStore *store, ECalComponent *comp);
gboolean e_cal_backend_store_remove_component (ECalBackendStore *store, const gchar *uid, const gchar *rid);
@@ -92,7 +95,7 @@ gboolean e_cal_backend_store_remove_timezone (ECalBackendStore *store, const g
const icaltimezone * e_cal_backend_store_get_default_timezone (ECalBackendStore *store);
gboolean e_cal_backend_store_set_default_timezone (ECalBackendStore *store, const icaltimezone *zone);
GSList * e_cal_backend_store_get_components_by_uid (ECalBackendStore *store, const gchar *uid);
-GSList * e_cal_backend_store_get_objects_list (ECalBackendStore *store, const gchar *sexp);
+GSList * e_cal_backend_store_get_components (ECalBackendStore *store);
const gchar * e_cal_backend_store_get_key (ECalBackendStore *store, const gchar *key);
gboolean e_cal_backend_store_put_key (ECalBackendStore *store, const gchar *key, const gchar *value);
void e_cal_backend_store_thaw_changes (ECalBackendStore *store);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]