[evolution-data-server] Refactor ECalBackendStore / ECalBackendFileStore.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Refactor ECalBackendStore / ECalBackendFileStore.
- Date: Thu, 22 Jul 2010 01:23:38 +0000 (UTC)
commit 33527ca06896cc273330b748741d859449284aab
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jul 20 19:36:11 2010 -0400
Refactor ECalBackendStore / ECalBackendFileStore.
These classes don't need to know the URI and source type of the backend,
they just need a file name. Backends must now provide the name of the
cache file. This breaks the API, but eliminates duplicate logic.
libedata-cal's shared object name is bumped for the API break.
Adapt backends to the new API.
calendar/backends/caldav/e-cal-backend-caldav.c | 67 ++-----
.../groupwise/e-cal-backend-groupwise-utils.c | 7 +-
.../backends/groupwise/e-cal-backend-groupwise.c | 93 ++-------
.../backends/groupwise/e-cal-backend-groupwise.h | 1 -
calendar/backends/http/e-cal-backend-http.c | 22 +--
calendar/backends/weather/e-cal-backend-weather.c | 7 +-
calendar/libedata-cal/e-cal-backend-cache.c | 214 +++-----------------
calendar/libedata-cal/e-cal-backend-cache.h | 7 +-
calendar/libedata-cal/e-cal-backend-file-store.c | 8 +-
calendar/libedata-cal/e-cal-backend-file-store.h | 5 +-
calendar/libedata-cal/e-cal-backend-store.c | 136 +++----------
configure.ac | 2 +-
.../libecal/tmpl/e-cal-check-timezones.sgml | 1 +
.../libedata-cal/tmpl/e-cal-backend-cache.sgml | 17 +--
.../tmpl/e-cal-backend-file-store.sgml | 3 +-
.../libedata-cal/tmpl/e-cal-backend-sync.sgml | 11 -
.../reference/camel/tmpl/camel-cipher-context.sgml | 2 +
17 files changed, 128 insertions(+), 475 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index be73950..505bc12 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -79,9 +79,6 @@ struct _ECalBackendCalDAVPrivate {
/* The local disk cache */
ECalBackendStore *store;
- /* local attachments store */
- gchar *local_attachments_store;
-
/* should we sync for offline mode? */
gboolean do_offline;
@@ -2123,20 +2120,19 @@ static gboolean
initialize_backend (ECalBackendCalDAV *cbdav, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
- ECalSourceType source_type;
+ ECalBackend *backend;
ESource *source;
const gchar *os_val;
const gchar *uri;
gsize len;
const gchar *refresh;
- const gchar *stype;
- const gchar *user_cache_dir;
- gchar *filename;
- gchar *mangled_uri;
+ const gchar *cache_dir;
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- source = e_cal_backend_get_source (E_CAL_BACKEND (cbdav));
+ backend = E_CAL_BACKEND (cbdav);
+ source = e_cal_backend_get_source (backend);
+ cache_dir = e_cal_backend_get_cache_dir (backend);
if (!g_signal_handler_find (G_OBJECT (source), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, caldav_source_changed_cb, cbdav))
g_signal_connect (G_OBJECT (source), "changed", G_CALLBACK (caldav_source_changed_cb), cbdav);
@@ -2151,7 +2147,7 @@ initialize_backend (ECalBackendCalDAV *cbdav, GError **perror)
priv->need_auth = os_val != NULL;
os_val = e_source_get_property(source, "ssl");
- uri = e_cal_backend_get_uri (E_CAL_BACKEND (cbdav));
+ uri = e_cal_backend_get_uri (backend);
g_free (priv->uri);
priv->uri = NULL;
@@ -2220,26 +2216,10 @@ initialize_backend (ECalBackendCalDAV *cbdav, GError **perror)
g_free (tmp);
}
- switch (e_cal_backend_get_kind (E_CAL_BACKEND (cbdav))) {
- default:
- case ICAL_VEVENT_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
- stype = "calendar";
- break;
- case ICAL_VTODO_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_TODO;
- stype = "tasks";
- break;
- case ICAL_VJOURNAL_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_JOURNAL;
- stype = "journal";
- break;
- }
-
if (priv->store == NULL) {
/* remove the old cache while migrating to ECalBackendStore */
- e_cal_backend_cache_remove (priv->uri, source_type);
- priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (priv->uri, source_type);
+ e_cal_backend_cache_remove (cache_dir, "cache.xml");
+ priv->store = e_cal_backend_file_store_new (cache_dir);
if (priv->store == NULL) {
g_propagate_error (perror, EDC_ERROR_EX (OtherError, "Cannot create local store"));
@@ -2250,14 +2230,7 @@ initialize_backend (ECalBackendCalDAV *cbdav, GError **perror)
}
/* Set the local attachment store */
- user_cache_dir = e_get_user_cache_dir ();
- mangled_uri = g_strdelimit (g_strdup (uri), ":/", '_');
- filename = g_build_filename (user_cache_dir, stype, mangled_uri, NULL);
- g_free (mangled_uri);
- if (priv->local_attachments_store)
- g_free (priv->local_attachments_store);
- priv->local_attachments_store = filename;
- if (g_mkdir_with_parents (filename, 0700) < 0) {
+ if (g_mkdir_with_parents (cache_dir, 0700) < 0) {
g_propagate_error (perror, EDC_ERROR_EX (OtherError, "mkdir failed"));
return FALSE;
}
@@ -2772,13 +2745,18 @@ static void
convert_to_url_attachment (ECalBackendCalDAV *cbdav, icalcomponent *icalcomp)
{
ECalBackendCalDAVPrivate *priv;
+ ECalBackend *backend;
GSList *to_remove = NULL;
+ const gchar *cache_dir;
icalcomponent *cclone;
icalproperty *p;
g_return_if_fail (cbdav != NULL);
g_return_if_fail (icalcomp != NULL);
+ backend = E_CAL_BACKEND (cbdav);
+ cache_dir = e_cal_backend_get_cache_dir (backend);
+
cclone = icalcomponent_new_clone (icalcomp);
/* Remove all inline attachments first */
@@ -2806,9 +2784,8 @@ convert_to_url_attachment (ECalBackendCalDAV *cbdav, icalcomponent *icalcomp)
if (icalattach_get_is_url (attach))
continue;
- dir = g_build_filename (priv->local_attachments_store,
- icalcomponent_get_uid (icalcomp),
- NULL);
+ dir = g_build_filename (
+ cache_dir, icalcomponent_get_uid (icalcomp), NULL);
if (g_mkdir_with_parents (dir, 0700) >= 0) {
GError *error = NULL;
gchar *basename;
@@ -2880,6 +2857,8 @@ static void
remove_cached_attachment (ECalBackendCalDAV *cbdav, const gchar *uid)
{
ECalBackendCalDAVPrivate *priv;
+ ECalBackend *backend;
+ const gchar *cache_dir;
GSList *l;
guint len;
gchar *dir;
@@ -2895,8 +2874,9 @@ remove_cached_attachment (ECalBackendCalDAV *cbdav, const gchar *uid)
if (len > 0)
return;
- dir = g_build_filename (priv->local_attachments_store,
- uid, NULL);
+ backend = E_CAL_BACKEND (cbdav);
+ cache_dir = e_cal_backend_get_cache_dir (backend);
+ dir = g_build_filename (cache_dir, uid, NULL);
remove_dir (dir);
g_free (dir);
}
@@ -4458,11 +4438,6 @@ e_cal_backend_caldav_dispose (GObject *object)
g_free (priv->uri);
g_free (priv->schedule_outbox_url);
- if (priv->local_attachments_store) {
- g_free (priv->local_attachments_store);
- priv->local_attachments_store = NULL;
- }
-
if (priv->store != NULL) {
g_object_unref (priv->store);
}
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
index 4e68aec..24cdcef 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
@@ -889,6 +889,7 @@ set_attachments_to_cal_component (EGwItem *item, ECalComponent *comp, ECalBacken
{
GSList *fetch_list = NULL, *l;
GSList *comp_attachment_list = NULL;
+ const gchar *cache_dir;
const gchar *uid;
gchar *attach_file_url;
@@ -896,6 +897,8 @@ set_attachments_to_cal_component (EGwItem *item, ECalComponent *comp, ECalBacken
if (fetch_list == NULL)
return; /* No attachments exist */
+ cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (cbgw));
+
e_cal_component_get_uid (comp, &uid);
for (l = fetch_list; l; l = l->next) {
gint fd;
@@ -905,8 +908,8 @@ set_attachments_to_cal_component (EGwItem *item, ECalComponent *comp, ECalBacken
gchar *filename;
attach_item = (EGwItemAttachment *) l->data;
- attach_file_url = g_strconcat (e_cal_backend_groupwise_get_local_attachments_store (cbgw),
- "/", uid, "-", attach_item->name, NULL);
+ attach_file_url = g_strconcat (
+ cache_dir, "/", uid, "-", attach_item->name, NULL);
filename = g_filename_from_uri (attach_file_url, NULL, NULL);
if (g_stat (filename, &st) == -1) {
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index 3cc2be4..c471cf4 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -95,7 +95,6 @@ struct _ECalBackendGroupwisePrivate {
/* fields for storing info while offline */
gchar *user_email;
- gchar *local_attachments_store;
/* A mutex to control access to the private structure for the following */
GStaticRecMutex rec_mutex;
@@ -970,7 +969,6 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
gchar *real_uri;
ECalBackendGroupwisePrivate *priv;
ESource *source;
- ECalSourceType source_type;
const gchar *use_ssl;
gchar *http_uri;
gint permissions;
@@ -1063,23 +1061,9 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
}
priv->mode_changed = FALSE;
- switch (kind) {
- case ICAL_VEVENT_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
- break;
- case ICAL_VTODO_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_TODO;
- break;
- case ICAL_VJOURNAL_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_JOURNAL;
- break;
- default:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
-
- }
-
if (E_IS_GW_CONNECTION (priv->cnc)) {
- const gchar *uri = e_cal_backend_get_uri (E_CAL_BACKEND (cbgw));
+ ECalBackend *backend;
+ const gchar *cache_dir;
/* get the ID for the container */
if (priv->container_id)
@@ -1089,8 +1073,11 @@ connect_to_server (ECalBackendGroupwise *cbgw, GError **perror)
return;
}
- e_cal_backend_cache_remove (uri, source_type);
- priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
+ backend = E_CAL_BACKEND (cbgw);
+ cache_dir = e_cal_backend_get_cache_dir (backend);
+
+ e_cal_backend_cache_remove (cache_dir, "cache.xml");
+ priv->store = e_cal_backend_file_store_new (cache_dir);
if (!priv->store) {
g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
return;
@@ -1201,11 +1188,6 @@ e_cal_backend_groupwise_finalize (GObject *object)
priv->user_email = NULL;
}
- if (priv->local_attachments_store) {
- g_free (priv->local_attachments_store);
- priv->local_attachments_store = NULL;
- }
-
if (priv->sendoptions_sync_timeout) {
g_source_remove (priv->sendoptions_sync_timeout);
priv->sendoptions_sync_timeout = 0;
@@ -1327,36 +1309,17 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
- ECalSourceType source_type;
- const gchar *source = NULL;
- const gchar *user_cache_dir;
- gchar *filename;
- gchar *mangled_uri;
+ const gchar *cache_dir;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
+ cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (backend));
+
PRIV_LOCK (priv);
cbgw->priv->read_only = FALSE;
- switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
- case ICAL_VEVENT_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
- source = "calendar";
- break;
- case ICAL_VTODO_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_TODO;
- source = "tasks";
- break;
- case ICAL_VJOURNAL_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_JOURNAL;
- source = "journal";
- break;
- default:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
- }
-
if (priv->mode == CAL_MODE_LOCAL) {
ESource *esource;
const gchar *display_contents = NULL;
@@ -1372,11 +1335,9 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
}
if (!priv->store) {
- const gchar *uri = e_cal_backend_get_uri (E_CAL_BACKEND (cbgw));
-
/* remove the old cache while migrating to ECalBackendStore */
- e_cal_backend_cache_remove (uri, source_type);
- priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
+ e_cal_backend_cache_remove (cache_dir, "cache.xml");
+ priv->store = e_cal_backend_file_store_new (cache_dir);
if (!priv->store) {
PRIV_UNLOCK (priv);
g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
@@ -1393,22 +1354,6 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
priv->username = g_strdup (username);
priv->password = g_strdup (password);
- /* Set the local attachment store. */
- mangled_uri = g_strdup (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)));
-
- /* Mangle the URI to not contain invalid characters. */
- g_strdelimit (mangled_uri, ":/", '_');
-
- user_cache_dir = e_get_user_cache_dir ();
- filename = g_build_filename (user_cache_dir, source, mangled_uri, NULL);
-
- g_free (priv->local_attachments_store);
- priv->local_attachments_store =
- g_filename_to_uri (filename, NULL, NULL);
-
- g_free (mangled_uri);
- g_free (filename);
-
/* FIXME: no need to set it online here when we implement the online/offline stuff correctly */
connect_to_server (cbgw, perror);
@@ -2382,15 +2327,15 @@ fetch_attachments (ECalBackendGroupwise *cbgw, ECalComponent *comp)
{
GSList *attach_list = NULL, *new_attach_list = NULL;
GSList *l;
- gchar *attach_store;
gchar *dest_url, *dest_file;
gint fd;
+ const gchar *cache_dir;
const gchar *uid;
e_cal_component_get_attachment_list (comp, &attach_list);
e_cal_component_get_uid (comp, &uid);
/*FIXME get the uri rather than computing the path */
- attach_store = g_strdup (e_cal_backend_groupwise_get_local_attachments_store (cbgw));
+ cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (cbgw));
for (l = attach_list; l; l = l->next) {
gchar *sfname = (gchar *)l->data;
@@ -2406,7 +2351,7 @@ fetch_attachments (ECalBackendGroupwise *cbgw, ECalComponent *comp)
filename = g_path_get_basename (sfname);
new_filename = g_strconcat (uid, "-", filename, NULL);
g_free (filename);
- dest_file = g_build_filename (attach_store, new_filename, NULL);
+ dest_file = g_build_filename (cache_dir, new_filename, NULL);
g_free (new_filename);
fd = g_open (dest_file, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
if (fd == -1) {
@@ -2427,7 +2372,6 @@ fetch_attachments (ECalBackendGroupwise *cbgw, ECalComponent *comp)
g_free (dest_file);
new_attach_list = g_slist_append (new_attach_list, dest_url);
}
- g_free (attach_store);
e_cal_component_set_attachment_list (comp, new_attach_list);
for (l = new_attach_list; l != NULL; l = l->next)
@@ -2869,10 +2813,3 @@ e_cal_backend_groupwise_notify_error_code (ECalBackendGroupwise *cbgw, EGwConnec
if (msg)
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), msg);
}
-
-const gchar *
-e_cal_backend_groupwise_get_local_attachments_store (ECalBackendGroupwise *cbgw)
-{
- g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), NULL);
- return cbgw->priv->local_attachments_store;
-}
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.h b/calendar/backends/groupwise/e-cal-backend-groupwise.h
index abcc1ef..9a315f9 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.h
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.h
@@ -63,7 +63,6 @@ GHashTable* e_cal_backend_groupwise_get_categories_by_name (ECalBackendGroupwise
icaltimezone* e_cal_backend_groupwise_get_default_zone (ECalBackendGroupwise *cbgw);
void e_cal_backend_groupwise_notify_error_code (ECalBackendGroupwise *cbgw, EGwConnectionStatus status);
const gchar *e_cal_backend_groupwise_get_container_id (ECalBackendGroupwise *cbgw);
-const gchar * e_cal_backend_groupwise_get_local_attachments_store (ECalBackendGroupwise *cbgw);
void e_cal_backend_groupwise_priv_lock (ECalBackendGroupwise *cbgw);
void e_cal_backend_groupwise_priv_unlock (ECalBackendGroupwise *cbgw);
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 02c654c..738ba8c 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -646,25 +646,13 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
}
if (!priv->store) {
- ECalSourceType source_type;
- const gchar *uri = e_cal_backend_get_uri (E_CAL_BACKEND (backend));
+ const gchar *cache_dir;
- switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
- default:
- case ICAL_VEVENT_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_EVENT;
- break;
- case ICAL_VTODO_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_TODO;
- break;
- case ICAL_VJOURNAL_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_JOURNAL;
- break;
- }
+ cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (backend));
/* remove the old cache while migrating to ECalBackendStore */
- e_cal_backend_cache_remove (uri, source_type);
- priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
+ e_cal_backend_cache_remove (cache_dir, "cache.xml");
+ priv->store = e_cal_backend_file_store_new (cache_dir);
e_cal_backend_store_load (priv->store);
if (!priv->store) {
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index 244e16e..72f158b 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -466,19 +466,22 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on
{
ECalBackendWeather *cbw;
ECalBackendWeatherPrivate *priv;
+ const gchar *cache_dir;
const gchar *uri;
cbw = E_CAL_BACKEND_WEATHER (backend);
priv = cbw->priv;
uri = e_cal_backend_get_uri (E_CAL_BACKEND (backend));
+ cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (backend));
+
if (priv->city)
g_free (priv->city);
priv->city = g_strdup (strrchr (uri, '/') + 1);
if (!priv->store) {
- e_cal_backend_cache_remove (uri, E_CAL_SOURCE_TYPE_EVENT);
- priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, E_CAL_SOURCE_TYPE_EVENT);
+ e_cal_backend_cache_remove (cache_dir, "cache.xml");
+ priv->store = e_cal_backend_file_store_new (cache_dir);
if (!priv->store) {
g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
diff --git a/calendar/libedata-cal/e-cal-backend-cache.c b/calendar/libedata-cal/e-cal-backend-cache.c
index 2e418ef..dd242d4 100644
--- a/calendar/libedata-cal/e-cal-backend-cache.c
+++ b/calendar/libedata-cal/e-cal-backend-cache.c
@@ -30,195 +30,38 @@
#include <libedataserver/e-data-server-util.h>
#include "e-cal-backend-cache.h"
-G_DEFINE_TYPE (ECalBackendCache, e_cal_backend_cache, E_TYPE_FILE_CACHE)
+#define E_CAL_BACKEND_CACHE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CAL_BACKEND_CACHE, ECalBackendCachePrivate))
struct _ECalBackendCachePrivate {
- gchar *uri;
- ECalSourceType source_type;
GHashTable *timezones;
};
-/* Property IDs */
-enum {
- PROP_0,
- PROP_SOURCE_TYPE,
- PROP_URI
-};
-
-static GObjectClass *parent_class = NULL;
-
-static gchar *
-get_filename_from_uri (const gchar *uri, ECalSourceType source_type)
-{
- gchar *mangled_uri, *filename;
- const gchar *source = NULL;
- const gchar *user_cache_dir;
-
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT :
- source = "calendar";
- break;
- case E_CAL_SOURCE_TYPE_TODO :
- source = "tasks";
- break;
- case E_CAL_SOURCE_TYPE_JOURNAL :
- source = "memos";
- break;
- case E_CAL_SOURCE_TYPE_LAST :
- default :
- break;
- }
-
- user_cache_dir = e_get_user_cache_dir ();
-
- /* Mangle the URI to not contain invalid characters. */
- mangled_uri = g_strdelimit (g_strdup (uri), ":/", '_');
-
- filename = g_build_filename (
- user_cache_dir, source, mangled_uri, "cache.xml", NULL);
-
- g_free (mangled_uri);
-
- return filename;
-}
-
-static void
-e_cal_backend_cache_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
- ECalBackendCache *cache;
- ECalBackendCachePrivate *priv;
- gchar *cache_file;
- ECalSourceType source_type;
-
- cache = E_CAL_BACKEND_CACHE (object);
- priv = cache->priv;
-
- switch (property_id) {
- case PROP_SOURCE_TYPE :
- source_type = g_value_get_enum (value);
- priv->source_type = source_type;
- break;
- case PROP_URI :
- /* Ensure both properties are set and then create the
- * cache_file property */
- cache_file = get_filename_from_uri (g_value_get_string (value), priv->source_type);
- if (!cache_file)
- break;
-
- g_object_set (G_OBJECT (cache), "filename", cache_file, NULL);
- g_free (cache_file);
-
- if (priv->uri)
- g_free (priv->uri);
- priv->uri = g_value_dup_string (value);
- break;
- default :
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-e_cal_backend_cache_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
- ECalBackendCache *cache;
- ECalBackendCachePrivate *priv;
-
- cache = E_CAL_BACKEND_CACHE (object);
- priv = cache->priv;
-
- switch (property_id) {
- case PROP_SOURCE_TYPE:
- g_value_set_enum (value, priv->source_type);
- case PROP_URI :
- g_value_set_string (value, priv->uri);
- break;
- default :
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
+G_DEFINE_TYPE (ECalBackendCache, e_cal_backend_cache, E_TYPE_FILE_CACHE)
static void
e_cal_backend_cache_finalize (GObject *object)
{
- ECalBackendCache *cache;
ECalBackendCachePrivate *priv;
- cache = E_CAL_BACKEND_CACHE (object);
- priv = cache->priv;
-
- if (priv) {
- if (priv->uri) {
- g_free (priv->uri);
- priv->uri = NULL;
- }
-
- g_hash_table_destroy (priv->timezones);
- priv->timezones = NULL;
+ priv = E_CAL_BACKEND_CACHE_GET_PRIVATE (object);
- g_free (priv);
- cache->priv = NULL;
- }
-
- parent_class->finalize (object);
-}
-
-static GObject *
-e_cal_backend_cache_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- GObject *obj;
- const gchar *uri;
- ECalSourceType source_type = E_CAL_SOURCE_TYPE_EVENT;
- ECalBackendCacheClass *klass;
- GObjectClass *parent_class;
-
- /* Invoke parent constructor. */
- klass = E_CAL_BACKEND_CACHE_CLASS (g_type_class_peek (E_TYPE_CAL_BACKEND_CACHE));
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
- obj = parent_class->constructor (type,
- n_construct_properties,
- construct_properties);
-
- if (!g_ascii_strcasecmp ( g_param_spec_get_name (construct_properties->pspec), "source_type"))
- source_type = g_value_get_enum (construct_properties->value);
- /* extract uid */
- if (!g_ascii_strcasecmp ( g_param_spec_get_name (construct_properties->pspec), "uri")) {
- gchar *cache_file;
-
- uri = g_value_get_string (construct_properties->value);
- cache_file = get_filename_from_uri (uri, source_type);
- g_object_set (obj, "filename", cache_file, NULL);
- g_free (cache_file);
- }
+ g_hash_table_destroy (priv->timezones);
- return obj;
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_cal_backend_cache_parent_class)->finalize (object);
}
static void
-e_cal_backend_cache_class_init (ECalBackendCacheClass *klass)
+e_cal_backend_cache_class_init (ECalBackendCacheClass *class)
{
GObjectClass *object_class;
- parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (class, sizeof (ECalBackendCachePrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->finalize = e_cal_backend_cache_finalize;
- object_class->set_property = e_cal_backend_cache_set_property;
- object_class->get_property = e_cal_backend_cache_get_property;
-
- object_class->constructor = e_cal_backend_cache_constructor;
- g_object_class_install_property (object_class, PROP_SOURCE_TYPE,
- g_param_spec_enum ("source_type", NULL, NULL,
- e_cal_source_type_enum_get_type (),
- E_CAL_SOURCE_TYPE_EVENT,
- G_PARAM_READABLE | G_PARAM_WRITABLE
- | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class, PROP_URI,
- g_param_spec_string ("uri", NULL, NULL, "",
- G_PARAM_READABLE | G_PARAM_WRITABLE
- | G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -230,35 +73,30 @@ timezones_value_destroy (icaltimezone *zone)
static void
e_cal_backend_cache_init (ECalBackendCache *cache)
{
- ECalBackendCachePrivate *priv;
+ cache->priv = E_CAL_BACKEND_CACHE_GET_PRIVATE (cache);
- priv = g_new0 (ECalBackendCachePrivate, 1);
- priv->timezones = g_hash_table_new_full (
+ cache->priv->timezones = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) timezones_value_destroy);
-
- cache->priv = priv;
-
}
/**
* e_cal_backend_cache_new
- * @uri: URI of the backend to be cached.
+ * @filename: filename for cache data
*
* Creates a new #ECalBackendCache object, which implements a cache of
* calendar/tasks objects, very useful for remote backends.
*
- * Returns: The newly created object.
+ * Returns: a new #ECalBackendCache
*/
ECalBackendCache *
-e_cal_backend_cache_new (const gchar *uri, ECalSourceType source_type)
+e_cal_backend_cache_new (const gchar *filename)
{
- ECalBackendCache *cache;
+ g_return_val_if_fail (filename != NULL, NULL);
- cache = g_object_new (E_TYPE_CAL_BACKEND_CACHE, "source_type", source_type, "uri", uri, NULL);
-
- return cache;
+ return g_object_new (
+ E_TYPE_CAL_BACKEND_CACHE, "filename", filename, NULL);
}
static gchar *
@@ -857,27 +695,29 @@ e_cal_backend_cache_get_key_value (ECalBackendCache *cache, const gchar *key)
* Since: 2.28
**/
gboolean
-e_cal_backend_cache_remove (const gchar *uri, ECalSourceType source_type)
+e_cal_backend_cache_remove (const gchar *dirname,
+ const gchar *basename)
{
gchar *filename;
- filename = get_filename_from_uri (uri, source_type);
+ g_return_val_if_fail (dirname != NULL, FALSE);
+ g_return_val_if_fail (basename != NULL, FALSE);
+
+ filename = g_build_filename (dirname, basename, NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
- gchar *dirname, *full_path;
+ gchar *full_path;
const gchar *fname;
GDir *dir;
gboolean success;
/* remove all files in the directory */
- dirname = g_path_get_dirname (filename);
dir = g_dir_open (dirname, 0, NULL);
if (dir) {
while ((fname = g_dir_read_name (dir))) {
full_path = g_build_filename (dirname, fname, NULL);
if (g_unlink (full_path) != 0) {
g_free (full_path);
- g_free (dirname);
g_dir_close (dir);
return FALSE;
@@ -893,11 +733,11 @@ e_cal_backend_cache_remove (const gchar *uri, ECalSourceType source_type)
success = g_rmdir (dirname) == 0;
/* free all memory */
- g_free (dirname);
g_free (filename);
return success;
}
g_free (filename);
+
return FALSE;
}
diff --git a/calendar/libedata-cal/e-cal-backend-cache.h b/calendar/libedata-cal/e-cal-backend-cache.h
index 5354f3a..d699fd1 100644
--- a/calendar/libedata-cal/e-cal-backend-cache.h
+++ b/calendar/libedata-cal/e-cal-backend-cache.h
@@ -62,8 +62,7 @@ struct _ECalBackendCacheClass {
GType e_cal_backend_cache_get_type (void);
ECalBackendCache *
- e_cal_backend_cache_new (const gchar *uri,
- ECalSourceType source_type);
+ e_cal_backend_cache_new (const gchar *filename);
ECalComponent * e_cal_backend_cache_get_component
(ECalBackendCache *cache,
const gchar *uid,
@@ -108,8 +107,8 @@ gboolean e_cal_backend_cache_put_key_value
const gchar * e_cal_backend_cache_get_key_value
(ECalBackendCache *cache,
const gchar *key);
-gboolean e_cal_backend_cache_remove (const gchar *uri,
- ECalSourceType source_type);
+gboolean e_cal_backend_cache_remove (const gchar *dirname,
+ const gchar *basename);
G_END_DECLS
diff --git a/calendar/libedata-cal/e-cal-backend-file-store.c b/calendar/libedata-cal/e-cal-backend-file-store.c
index 313682b..f1ac17b 100644
--- a/calendar/libedata-cal/e-cal-backend-file-store.c
+++ b/calendar/libedata-cal/e-cal-backend-file-store.c
@@ -942,8 +942,10 @@ e_cal_backend_file_store_init (ECalBackendFileStore *store)
*
* Since: 2.28
**/
-ECalBackendFileStore*
-e_cal_backend_file_store_new (const gchar *uri, ECalSourceType source_type)
+ECalBackendStore*
+e_cal_backend_file_store_new (const gchar *path)
{
- return g_object_new (E_TYPE_CAL_BACKEND_FILE_STORE, "source_type", source_type, "uri", uri, NULL);
+ return g_object_new (
+ E_TYPE_CAL_BACKEND_FILE_STORE,
+ "path", path, NULL);
}
diff --git a/calendar/libedata-cal/e-cal-backend-file-store.h b/calendar/libedata-cal/e-cal-backend-file-store.h
index 5a9016f..f829617 100644
--- a/calendar/libedata-cal/e-cal-backend-file-store.h
+++ b/calendar/libedata-cal/e-cal-backend-file-store.h
@@ -65,9 +65,8 @@ struct _ECalBackendFileStoreClass {
};
GType e_cal_backend_file_store_get_type (void);
-ECalBackendFileStore *
- e_cal_backend_file_store_new (const gchar *uri,
- ECalSourceType source_type);
+ECalBackendStore *
+ e_cal_backend_file_store_new (const gchar *path);
G_END_DECLS
diff --git a/calendar/libedata-cal/e-cal-backend-store.c b/calendar/libedata-cal/e-cal-backend-store.c
index 27a6dfc..443d6aa 100644
--- a/calendar/libedata-cal/e-cal-backend-store.c
+++ b/calendar/libedata-cal/e-cal-backend-store.c
@@ -28,73 +28,25 @@
((obj), E_TYPE_CAL_BACKEND_STORE, ECalBackendStorePrivate))
struct _ECalBackendStorePrivate {
- ECalSourceType source_type;
- gchar *uri;
gchar *path;
gboolean loaded;
};
-/* Property IDs */
enum {
PROP_0,
- PROP_SOURCE_TYPE,
- PROP_URI
+ PROP_PATH
};
G_DEFINE_TYPE (ECalBackendStore, e_cal_backend_store, G_TYPE_OBJECT)
-static const gchar *
-get_component (ECalSourceType source_type)
-{
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT :
- return "calendar";
- case E_CAL_SOURCE_TYPE_TODO :
- return "tasks";
- case E_CAL_SOURCE_TYPE_JOURNAL :
- return "journal";
- case E_CAL_SOURCE_TYPE_LAST :
- default :
- return "invalid";
- }
-
-}
-
-static void
-set_store_path (ECalBackendStore *store)
-{
- ECalBackendStorePrivate *priv;
-
- priv = E_CAL_BACKEND_STORE_GET_PRIVATE (store);
-
- if (priv->uri) {
- const gchar *component;
- const gchar *user_cache_dir;
- gchar *mangled_uri = NULL;
-
- user_cache_dir = e_get_user_cache_dir ();
- component = get_component (priv->source_type);
- mangled_uri = g_strdelimit (g_strdup (priv->uri), ":/", '_');
-
- g_free (priv->path);
- priv->path = g_build_filename (
- user_cache_dir, component, mangled_uri, NULL);
-
- g_free (mangled_uri);
- }
-}
-
static void
-set_uri (ECalBackendStore *store, gchar *uri)
+cal_backend_store_set_path (ECalBackendStore *store,
+ const gchar *path)
{
- ECalBackendStorePrivate *priv;
+ g_return_if_fail (store->priv->path == NULL);
+ g_return_if_fail (path != NULL);
- priv = E_CAL_BACKEND_STORE_GET_PRIVATE (store);
-
- if (priv->uri)
- g_free (priv->uri);
-
- priv->uri = uri;
+ store->priv->path = g_strdup (path);
}
static void
@@ -103,23 +55,15 @@ cal_backend_store_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- ECalBackendStore *store;
- ECalBackendStorePrivate *priv;
-
- store = E_CAL_BACKEND_STORE (object);
- priv = E_CAL_BACKEND_STORE_GET_PRIVATE (store);
-
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, pspec);
+ case PROP_PATH:
+ cal_backend_store_set_path (
+ E_CAL_BACKEND_STORE (object),
+ g_value_get_string (value));
+ return;
}
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
@@ -128,23 +72,15 @@ cal_backend_store_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- ECalBackendStore *store;
- ECalBackendStorePrivate *priv;
-
- store = E_CAL_BACKEND_STORE (object);
- priv = E_CAL_BACKEND_STORE_GET_PRIVATE (store);
-
- switch (property_id)
- {
- case PROP_SOURCE_TYPE:
- g_value_set_enum (value, priv->source_type);
- break;
- case PROP_URI :
- g_value_set_string (value, priv->uri);
- break;
- default :
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ switch (property_id) {
+ case PROP_PATH:
+ g_value_set_string (
+ value, e_cal_backend_store_get_path (
+ E_CAL_BACKEND_STORE (object)));
+ return;
}
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
@@ -154,7 +90,6 @@ cal_backend_store_finalize (GObject *object)
priv = E_CAL_BACKEND_STORE_GET_PRIVATE (object);
- g_free (priv->uri);
g_free (priv->path);
/* Chain up to parent's finalize() method. */
@@ -173,29 +108,22 @@ e_cal_backend_store_class_init (ECalBackendStoreClass *class)
object_class->get_property = cal_backend_store_get_property;
object_class->finalize = cal_backend_store_finalize;
- g_object_class_install_property (object_class, PROP_SOURCE_TYPE,
- g_param_spec_enum ("source_type", NULL, NULL,
- e_cal_source_type_enum_get_type (),
- E_CAL_SOURCE_TYPE_EVENT,
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_URI,
- g_param_spec_string ("uri", NULL, NULL, "",
- G_PARAM_READABLE | G_PARAM_WRITABLE
- | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (
+ object_class,
+ PROP_PATH,
+ g_param_spec_string (
+ "path",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
}
static void
e_cal_backend_store_init (ECalBackendStore *store)
{
- ECalBackendStorePrivate *priv;
-
- priv = E_CAL_BACKEND_STORE_GET_PRIVATE (store);
-
- store->priv = priv;
- priv->uri = NULL;
- priv->path = NULL;
- priv->source_type = E_CAL_SOURCE_TYPE_EVENT;
- priv->loaded = FALSE;
+ store->priv = E_CAL_BACKEND_STORE_GET_PRIVATE (store);
}
/**
diff --git a/configure.ac b/configure.ac
index e979259..5b3108d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,7 +98,7 @@ LIBECAL_CURRENT=10
LIBECAL_REVISION=2
LIBECAL_AGE=2
-LIBEDATACAL_CURRENT=9
+LIBEDATACAL_CURRENT=10
LIBEDATACAL_REVISION=0
LIBEDATACAL_AGE=0
diff --git a/docs/reference/calendar/libecal/tmpl/e-cal-check-timezones.sgml b/docs/reference/calendar/libecal/tmpl/e-cal-check-timezones.sgml
index 4f44101..f108450 100644
--- a/docs/reference/calendar/libecal/tmpl/e-cal-check-timezones.sgml
+++ b/docs/reference/calendar/libecal/tmpl/e-cal-check-timezones.sgml
@@ -55,6 +55,7 @@ e-cal-check-timezones
@const gchar *tzid, gconstpointer custom, GError **error:
@const gchar *tzid, gconstpointer custom, GError **error:
@const gchar *tzid, gconstpointer custom, GError **error:
+ const gchar *tzid, gconstpointer custom, GError **error:
@const gchar *tzid, gconstpointer custom, GError **error:
@custom:
@error:
diff --git a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-cache.sgml b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-cache.sgml
index 221c1d5..c513cc8 100644
--- a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-cache.sgml
+++ b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-cache.sgml
@@ -26,23 +26,12 @@ Cache for calendar backends.
</para>
-<!-- ##### ARG ECalBackendCache:source-type ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ECalBackendCache:uri ##### -->
-<para>
-
-</para>
-
<!-- ##### FUNCTION e_cal_backend_cache_new ##### -->
<para>
</para>
- uri:
- source_type:
+ filename:
@Returns:
@@ -217,8 +206,8 @@ Cache for calendar backends.
</para>
- uri:
- source_type:
+ dirname:
+ basename:
@Returns:
diff --git a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-file-store.sgml b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-file-store.sgml
index 750aae4..37cb0c9 100644
--- a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-file-store.sgml
+++ b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-file-store.sgml
@@ -33,8 +33,7 @@ ECalBackendFileStore
</para>
- uri:
- source_type:
+ path:
@Returns:
diff --git a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml
index d5c44ad..599359e 100644
--- a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml
+++ b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend-sync.sgml
@@ -281,17 +281,6 @@ Base class for synchronous backends.
@error:
-<!-- ##### FUNCTION e_cal_backend_sync_set_default_timezone ##### -->
-<para>
-
-</para>
-
- backend:
- cal:
- tzid:
- error:
-
-
<!-- ##### FUNCTION e_cal_backend_sync_set_default_zone ##### -->
<para>
diff --git a/docs/reference/camel/tmpl/camel-cipher-context.sgml b/docs/reference/camel/tmpl/camel-cipher-context.sgml
index 358f5a1..d45acee 100644
--- a/docs/reference/camel/tmpl/camel-cipher-context.sgml
+++ b/docs/reference/camel/tmpl/camel-cipher-context.sgml
@@ -458,6 +458,8 @@ CamelCipherContext
@gpointer cert_data:
@gpointer cert_data:
@gpointer cert_data:
+ gpointer cert_data:
+ gpointer cert_data:
@gpointer cert_data:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]