summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarish Krishnaswamy <kharish@novell.com>2006-07-24 13:09:34 +0000
committerHarish Krishnaswamy <kharish@src.gnome.org>2006-07-24 13:09:34 +0000
commite6b895c9c11bd5bbf47aaa32f292473a2d96a1f6 (patch)
tree086e8cf548f2d6a2d726f59ee98c0a952baa5260
parentab94ebc968d24fd53a6160b28f3f77491134441b (diff)
downloadevolution-data-server-e6b895c9c11bd5bbf47aaa32f292473a2d96a1f6.tar.gz
Patch to split the cache into multiple files based on the type of objects
2006-07-24 Harish Krishnaswamy <kharish@novell.com> Patch to split the cache into multiple files based on the type of objects it stores. This substantially reduces the primary memory requirements of Evolution and EDS for providers like GW, Exchange that manipulate event/tasks/journals together. * backends/caldav/e-cal-backend-caldav.c: (initialize_backend): * backends/groupwise/e-cal-backend-groupwise.c: (connect_to_server), (e_cal_backend_groupwise_open): * backends/http/e-cal-backend-http.c: (e_cal_backend_http_open): * backends/weather/e-cal-backend-weather.c: (e_cal_backend_weather_open): Update e_cal_backend_cache_new calls with an additional source type argument. * libecal/e-cal.[ch]: (e_cal_source_type_enum_get_type): Implement the function. * libedata-cal/e-cal-backend-cache.c: (get_filename_from_uri), (e_cal_backend_cache_set_property), (e_cal_backend_cache_get_property), (e_cal_backend_cache_constructor), (e_cal_backend_cache_class_init), (e_cal_backend_cache_new): Compute the cache destination using the source type. * libedata-cal/e-cal-backend-cache.h: Include header e-cal.h.
-rw-r--r--calendar/ChangeLog27
-rw-r--r--calendar/backends/caldav/e-cal-backend-caldav.c2
-rw-r--r--calendar/backends/groupwise/e-cal-backend-groupwise.c222
-rw-r--r--calendar/backends/http/e-cal-backend-http.c2
-rw-r--r--calendar/backends/weather/e-cal-backend-weather.c2
-rw-r--r--calendar/libecal/e-cal.c30
-rw-r--r--calendar/libecal/e-cal.h1
-rw-r--r--calendar/libedata-cal/e-cal-backend-cache.c53
-rw-r--r--calendar/libedata-cal/e-cal-backend-cache.h3
9 files changed, 237 insertions, 105 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 82448f204..73a28b5c7 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,30 @@
+2006-07-24 Harish Krishnaswamy <kharish@novell.com>
+
+ Patch to split the cache into multiple files based
+ on the type of objects it stores. This substantially
+ reduces the primary memory requirements of Evolution
+ and EDS for providers like GW, Exchange that manipulate
+ event/tasks/journals together.
+
+ * backends/caldav/e-cal-backend-caldav.c: (initialize_backend):
+ * backends/groupwise/e-cal-backend-groupwise.c:
+ (connect_to_server), (e_cal_backend_groupwise_open):
+ * backends/http/e-cal-backend-http.c: (e_cal_backend_http_open):
+ * backends/weather/e-cal-backend-weather.c:
+ (e_cal_backend_weather_open):
+ Update e_cal_backend_cache_new calls with an additional source
+ type argument.
+ * libecal/e-cal.[ch]: (e_cal_source_type_enum_get_type):
+ Implement the function.
+ * libedata-cal/e-cal-backend-cache.c:
+ (get_filename_from_uri),
+ (e_cal_backend_cache_set_property),
+ (e_cal_backend_cache_get_property),
+ (e_cal_backend_cache_constructor),
+ (e_cal_backend_cache_class_init), (e_cal_backend_cache_new):
+ Compute the cache destination using the source type.
+ * libedata-cal/e-cal-backend-cache.h: Include header e-cal.h.
+
2006-07-22 Harish Krishnaswamy <kharish@novell.com>
* backends/groupwise/e-cal-backend-groupwise-utils.c:
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 3a2fa16f9..510e8f53e 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -1393,7 +1393,7 @@ initialize_backend (ECalBackendCalDAV *cbdav)
}
if (priv->cache == NULL) {
- priv->cache = e_cal_backend_cache_new (priv->uri);
+ priv->cache = e_cal_backend_cache_new (priv->uri, E_CAL_SOURCE_TYPE_EVENT);
if (priv->cache == NULL) {
result = GNOME_Evolution_Calendar_OtherError;
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index 7202fc696..773b84018 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -813,6 +813,7 @@ connect_to_server (ECalBackendGroupwise *cbgw)
char *real_uri;
ECalBackendGroupwisePrivate *priv;
ESource *source;
+ ECalSourceType source_type;
const char *use_ssl;
char *http_uri;
int permissions;
@@ -832,118 +833,134 @@ connect_to_server (ECalBackendGroupwise *cbgw)
if (!real_uri) {
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Invalid server URI"));
return GNOME_Evolution_Calendar_NoSuchCal;
- } else {
- parent_user = (char *) e_source_get_property (source, "parent_id_name");
- /* create connection to server */
- if (parent_user) {
- EGwConnection *cnc;
- /* create connection to server */
- cnc = e_gw_connection_new (real_uri, parent_user, priv->password);
- if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
- http_uri = g_strconcat ("http://", real_uri + 8, NULL);
- cnc = e_gw_connection_new (http_uri, parent_user, priv->password);
- g_free (http_uri);
- }
-
- if (!cnc) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
- }
-
- priv->cnc = e_gw_connection_get_proxy_connection (cnc, parent_user, priv->password, priv->username, &permissions);
+ }
- g_object_unref(cnc);
-
- if (!priv->cnc) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
- }
+ kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
- kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
+ parent_user = (char *) e_source_get_property (source, "parent_id_name");
+ /* create connection to server */
+ if (parent_user) {
+ EGwConnection *cnc;
+ /* create connection to server */
+ cnc = e_gw_connection_new (real_uri, parent_user, priv->password);
+ if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
+ http_uri = g_strconcat ("http://", real_uri + 8, NULL);
+ cnc = e_gw_connection_new (http_uri, parent_user, priv->password);
+ g_free (http_uri);
+ }
- cbgw->priv->read_only = TRUE;
-
- if (kind == ICAL_VEVENT_COMPONENT && (permissions & E_GW_PROXY_APPOINTMENT_WRITE) )
- cbgw->priv->read_only = FALSE;
- else if (kind == ICAL_VTODO_COMPONENT && (permissions & E_GW_PROXY_TASK_WRITE))
- cbgw->priv->read_only = FALSE;
- else if (kind == ICAL_VJOURNAL_COMPONENT && (permissions & E_GW_PROXY_NOTES_WRITE))
- cbgw->priv->read_only = FALSE;
+ if (!cnc) {
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
+ return GNOME_Evolution_Calendar_AuthenticationFailed;
+ }
+
+ priv->cnc = e_gw_connection_get_proxy_connection (cnc, parent_user, priv->password, priv->username, &permissions);
- } else {
+ g_object_unref(cnc);
+
+ if (!priv->cnc) {
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
+ return GNOME_Evolution_Calendar_AuthenticationFailed;
+ }
- priv->cnc = e_gw_connection_new (
- real_uri,
- priv->username,
- priv->password);
- if (!E_IS_GW_CONNECTION(priv->cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
- http_uri = g_strconcat ("http://", real_uri + 8, NULL);
- priv->cnc = e_gw_connection_new (http_uri, priv->username, priv->password);
- g_free (http_uri);
- }
+ cbgw->priv->read_only = TRUE;
+
+ if (kind == ICAL_VEVENT_COMPONENT && (permissions & E_GW_PROXY_APPOINTMENT_WRITE) )
+ cbgw->priv->read_only = FALSE;
+ else if (kind == ICAL_VTODO_COMPONENT && (permissions & E_GW_PROXY_TASK_WRITE))
+ cbgw->priv->read_only = FALSE;
+ else if (kind == ICAL_VJOURNAL_COMPONENT && (permissions & E_GW_PROXY_NOTES_WRITE))
cbgw->priv->read_only = FALSE;
- }
- g_free (real_uri);
-
- if (priv->cnc && priv->cache && priv->container_id) {
- char *utc_str;
- priv->mode = CAL_MODE_REMOTE;
- if (priv->mode_changed && !priv->timeout_id ) {
- GThread *thread1;
- priv->mode_changed = FALSE;
- thread1 = g_thread_create ((GThreadFunc) get_deltas, cbgw, FALSE, &error);
- if (!thread1) {
- g_warning (G_STRLOC ": %s", error->message);
- g_error_free (error);
+ } else {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create thread for getting deltas"));
- return GNOME_Evolution_Calendar_OtherError;
- }
- priv->timeout_id = g_timeout_add (CACHE_REFRESH_INTERVAL, (GSourceFunc) get_deltas_timeout, (gpointer)cbgw);
- }
- utc_str = (char *) e_gw_connection_get_server_time (priv->cnc);
- e_cal_backend_cache_put_server_utc_time (priv->cache, utc_str);
+ priv->cnc = e_gw_connection_new (
+ real_uri,
+ priv->username,
+ priv->password);
- return GNOME_Evolution_Calendar_Success;
+ if (!E_IS_GW_CONNECTION(priv->cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
+ http_uri = g_strconcat ("http://", real_uri + 8, NULL);
+ priv->cnc = e_gw_connection_new (http_uri, priv->username, priv->password);
+ g_free (http_uri);
}
- priv->mode_changed = FALSE;
-
- if (E_IS_GW_CONNECTION (priv->cnc)) {
- ECalBackendSyncStatus status;
- /* get the ID for the container */
- if (priv->container_id)
- g_free (priv->container_id);
-
- if ((status = set_container_id_with_count (cbgw)) != GNOME_Evolution_Calendar_Success) {
- return status;
- }
+ cbgw->priv->read_only = FALSE;
+ }
+ g_free (real_uri);
- priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)));
- if (!priv->cache) {
- g_mutex_unlock (priv->mutex);
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
- return GNOME_Evolution_Calendar_OtherError;
- }
+ if (priv->cnc && priv->cache && priv->container_id) {
+ char *utc_str;
+ priv->mode = CAL_MODE_REMOTE;
+ if (priv->mode_changed && !priv->timeout_id ) {
+ GThread *thread1;
+ priv->mode_changed = FALSE;
- e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
-
- /* spawn a new thread for opening the calendar */
- thread = g_thread_create ((GThreadFunc) cache_init, cbgw, FALSE, &error);
- if (!thread) {
+ thread1 = g_thread_create ((GThreadFunc) get_deltas, cbgw, FALSE, &error);
+ if (!thread1) {
g_warning (G_STRLOC ": %s", error->message);
g_error_free (error);
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create thread for populating cache"));
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create thread for getting deltas"));
return GNOME_Evolution_Calendar_OtherError;
}
+ priv->timeout_id = g_timeout_add (CACHE_REFRESH_INTERVAL, (GSourceFunc) get_deltas_timeout, (gpointer)cbgw);
+ }
+ utc_str = (char *) e_gw_connection_get_server_time (priv->cnc);
+ e_cal_backend_cache_put_server_utc_time (priv->cache, utc_str);
+ return GNOME_Evolution_Calendar_Success;
+ }
+ priv->mode_changed = FALSE;
- } else {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
- return GNOME_Evolution_Calendar_AuthenticationFailed;
+ 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)) {
+ ECalBackendSyncStatus status;
+ /* get the ID for the container */
+ if (priv->container_id)
+ g_free (priv->container_id);
+
+ if ((status = set_container_id_with_count (cbgw)) != GNOME_Evolution_Calendar_Success) {
+ return status;
+ }
+
+ priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)), source_type);
+ if (!priv->cache) {
+ g_mutex_unlock (priv->mutex);
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
+ return GNOME_Evolution_Calendar_OtherError;
+ }
+
+ e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
+
+ /* spawn a new thread for opening the calendar */
+ thread = g_thread_create ((GThreadFunc) cache_init, cbgw, FALSE, &error);
+ if (!thread) {
+ g_warning (G_STRLOC ": %s", error->message);
+ g_error_free (error);
+
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create thread for populating cache"));
+ return GNOME_Evolution_Calendar_OtherError;
}
+
+
+ } else {
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
+ return GNOME_Evolution_Calendar_AuthenticationFailed;
}
if (!e_gw_connection_get_version (priv->cnc))
@@ -1146,6 +1163,8 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
ECalBackendSyncStatus status;
+ ECalSourceType source_type;
+ char *source;
char *filename;
char *mangled_uri;
int i;
@@ -1157,6 +1176,23 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
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 *source;
const char *display_contents = NULL;
@@ -1171,7 +1207,7 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
}
if (!priv->cache) {
- priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)));
+ priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)), source_type);
if (!priv->cache) {
g_mutex_unlock (priv->mutex);
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
@@ -1201,7 +1237,7 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
}
filename = g_build_filename (g_get_home_dir (),
- ".evolution/cache/calendar",
+ ".evolution/cache/", source,
mangled_uri,
NULL);
g_free (mangled_uri);
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 6e22f6965..3c7bd937b 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -519,7 +519,7 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
priv = cbhttp->priv;
if (!priv->cache) {
- priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (backend)));
+ priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (backend)), E_CAL_SOURCE_TYPE_EVENT );
if (!priv->cache) {
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index f65dde992..8a8a23020 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -444,7 +444,7 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on
priv->city = g_strdup (strrchr (uri, '/') + 1);
if (!priv->cache) {
- priv->cache = e_cal_backend_cache_new (uri);
+ priv->cache = e_cal_backend_cache_new (uri, E_CAL_SOURCE_TYPE_EVENT);
if (!priv->cache) {
e_cal_backend_notify_error (E_CAL_BACKEND (cbw), _("Could not create cache file"));
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 5274fb73e..adcbfd717 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -196,6 +196,34 @@ e_calendar_error_quark (void)
}
/**
+ * e_cal_source_type_enum_get_type:
+ *
+ * Registers the #ECalSourceTypeEnum type with glib.
+ *
+ * Return value: the ID of the #ECalSourceTypeEnum type.
+ */
+GType
+e_cal_source_type_enum_get_type (void)
+{
+ static GType e_cal_source_type_enum_type = 0;
+
+ if (!e_cal_source_type_enum_type) {
+ static GEnumValue values [] = {
+ { E_CAL_SOURCE_TYPE_EVENT, "Event", NULL},
+ { E_CAL_SOURCE_TYPE_TODO, "ToDo", NULL},
+ { E_CAL_SOURCE_TYPE_JOURNAL, "Journal", NULL},
+ { E_CAL_SOURCE_TYPE_LAST, "Invalid", NULL},
+ { -1, NULL, NULL}
+ };
+
+ e_cal_source_type_enum_type =
+ g_enum_register_static ("ECalSourceTypeEnum", values);
+ }
+
+ return e_cal_source_type_enum_type;
+}
+
+/**
* e_cal_set_mode_status_enum_get_type:
*
* Registers the #ECalSetModeStatusEnum type with glib.
@@ -249,6 +277,8 @@ cal_mode_enum_get_type (void)
return cal_mode_enum_type;
}
+
+
static GNOME_Evolution_Calendar_CalObjType
convert_type (ECalSourceType type)
{
diff --git a/calendar/libecal/e-cal.h b/calendar/libecal/e-cal.h
index 7e12bfbe6..99076a464 100644
--- a/calendar/libecal/e-cal.h
+++ b/calendar/libecal/e-cal.h
@@ -97,6 +97,7 @@ typedef char * (* ECalAuthFunc) (ECal *ecal,
GType e_cal_get_type (void);
GType e_cal_open_status_enum_get_type (void);
+GType e_cal_source_type_enum_get_type (void);
GType e_cal_set_mode_status_enum_get_type (void);
GType cal_mode_enum_get_type (void);
diff --git a/calendar/libedata-cal/e-cal-backend-cache.c b/calendar/libedata-cal/e-cal-backend-cache.c
index fb38b7c42..2a3c6e43b 100644
--- a/calendar/libedata-cal/e-cal-backend-cache.c
+++ b/calendar/libedata-cal/e-cal-backend-cache.c
@@ -29,23 +29,41 @@
struct _ECalBackendCachePrivate {
char *uri;
+ ECalSourceType source_type;
GHashTable *timezones;
};
/* Property IDs */
enum {
PROP_0,
+ PROP_SOURCE_TYPE,
PROP_URI
};
static GObjectClass *parent_class = NULL;
static char *
-get_filename_from_uri (const char *uri)
+get_filename_from_uri (const char *uri, ECalSourceType source_type)
{
char *mangled_uri, *filename;
+ char *source = NULL;
int i;
+ 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 = "journal";
+ break;
+ case E_CAL_SOURCE_TYPE_LAST :
+ default :
+ break;
+ }
+
/* mangle the URI to not contain invalid characters */
mangled_uri = g_strdup (uri);
for (i = 0; i < strlen (mangled_uri); i++) {
@@ -57,8 +75,8 @@ get_filename_from_uri (const char *uri)
}
/* generate the file name */
- filename = g_build_filename (g_get_home_dir (), ".evolution/cache/calendar",
- mangled_uri, "cache.xml", NULL);
+ filename = g_build_filename (g_get_home_dir (), ".evolution/cache/",
+ source, mangled_uri, "cache.xml", NULL);
/* free memory */
g_free (mangled_uri);
@@ -72,13 +90,20 @@ e_cal_backend_cache_set_property (GObject *object, guint property_id, const GVal
ECalBackendCache *cache;
ECalBackendCachePrivate *priv;
char *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 :
- cache_file = get_filename_from_uri (g_value_get_string (value));
+ /* 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;
@@ -104,6 +129,8 @@ e_cal_backend_cache_get_property (GObject *object, guint property_id, GValue *va
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;
@@ -154,6 +181,7 @@ e_cal_backend_cache_constructor (GType type,
{
GObject *obj;
const char *uri;
+ ECalSourceType source_type;
ECalBackendCacheClass *klass;
GObjectClass *parent_class;
@@ -163,13 +191,15 @@ e_cal_backend_cache_constructor (GType type,
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")) {
char *cache_file;
uri = g_value_get_string (construct_properties->value);
- cache_file = get_filename_from_uri (uri);
+ cache_file = get_filename_from_uri (uri, source_type);
g_object_set (obj, "filename", cache_file, NULL);
g_free (cache_file);
}
@@ -190,6 +220,13 @@ e_cal_backend_cache_class_init (ECalBackendCacheClass *klass)
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
@@ -254,11 +291,11 @@ e_cal_backend_cache_get_type (void)
* Return value: The newly created object.
*/
ECalBackendCache *
-e_cal_backend_cache_new (const char *uri)
+e_cal_backend_cache_new (const char *uri, ECalSourceType source_type)
{
ECalBackendCache *cache;
- cache = g_object_new (E_TYPE_CAL_BACKEND_CACHE, "uri", uri, NULL);
+ cache = g_object_new (E_TYPE_CAL_BACKEND_CACHE, "source_type", source_type, "uri", uri, NULL);
return cache;
}
diff --git a/calendar/libedata-cal/e-cal-backend-cache.h b/calendar/libedata-cal/e-cal-backend-cache.h
index 262466571..750368fcf 100644
--- a/calendar/libedata-cal/e-cal-backend-cache.h
+++ b/calendar/libedata-cal/e-cal-backend-cache.h
@@ -24,6 +24,7 @@
#include <libedataserver/e-file-cache.h>
#include <libecal/e-cal-component.h>
+#include <libecal/e-cal.h>
G_BEGIN_DECLS
@@ -46,7 +47,7 @@ typedef struct {
GType e_cal_backend_cache_get_type (void);
-ECalBackendCache *e_cal_backend_cache_new (const char *uri);
+ECalBackendCache *e_cal_backend_cache_new (const char *uri, ECalSourceType source_type);
ECalComponent *e_cal_backend_cache_get_component (ECalBackendCache *cache,
const char *uid,
const char *rid);