Patch to split the cache into multiple files based on the type of objects
authorHarish Krishnaswamy <kharish@novell.com>
Mon, 24 Jul 2006 13:09:34 +0000 (13:09 +0000)
committerHarish Krishnaswamy <kharish@src.gnome.org>
Mon, 24 Jul 2006 13:09:34 +0000 (13:09 +0000)
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.

calendar/ChangeLog
calendar/backends/caldav/e-cal-backend-caldav.c
calendar/backends/groupwise/e-cal-backend-groupwise.c
calendar/backends/http/e-cal-backend-http.c
calendar/backends/weather/e-cal-backend-weather.c
calendar/libecal/e-cal.c
calendar/libecal/e-cal.h
calendar/libedata-cal/e-cal-backend-cache.c
calendar/libedata-cal/e-cal-backend-cache.h

index 82448f2..73a28b5 100644 (file)
@@ -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:
index 3a2fa16..510e8f5 100644 (file)
@@ -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;
index 7202fc6..773b840 100644 (file)
@@ -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);
index 6e22f69..3c7bd93 100644 (file)
@@ -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) {
index f65dde9..8a8a230 100644 (file)
@@ -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"));
index 5274fb7..adcbfd7 100644 (file)
@@ -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) 
 {
index 7e12bfb..99076a4 100644 (file)
@@ -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);
 
index fb38b7c..2a3c6e4 100644 (file)
 
 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;
 }
index 2624665..750368f 100644 (file)
@@ -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);