+2003-12-03 Rodrigo Moya <rodrigo@ximian.com>
+
+ * backends/groupwise/e-cal-backend-groupwise.c: use a cache
+ to keep the objects from the server.
+ (e_cal_backend_groupwise_finalize): unref the cache object.
+ (e_cal_backend_groupwise_open): load/create the local cache.
+ (e_cal_backend_groupwise_get_object): look for the object in
+ the cache.
+ (e_cal_backend_groupwise_class_init): fixed warning.
+
2003-12-01 William Jon McCann <mccann@jhu.edu>
* libecal/e-cal.c (e_cal_generate_instances): Fix query and
#include <config.h>
#endif
+#include <libedata-cal/e-cal-backend-cache.h>
#include "e-cal-backend-groupwise.h"
#include "e-gw-connection.h"
/* Private part of the CalBackendGroupwise structure */
struct _ECalBackendGroupwisePrivate {
EGwConnection *cnc;
+ ECalBackendCache *cache;
};
static void e_cal_backend_groupwise_dispose (GObject *object);
priv->cnc = NULL;
}
+ if (priv->cache) {
+ g_object_unref (priv->cache);
+ priv->cache = NULL;
+ }
+
g_free (priv);
cbgw->priv = NULL;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
+ /* create the local cache */
+ if (priv->cache)
+ g_object_unref (priv->cache);
+ priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (backend)));
+
/* FIXME: obtain username/password from the user */
+ /* FIXME: login to the server only if we're online */
/* create connection to server */
priv->cnc = e_gw_connection_new ();
switch (e_gw_connection_login (priv->cnc, e_cal_backend_get_uri (E_CAL_BACKEND (backend)),
static ECalBackendSyncStatus
e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, char **object)
{
+ ECalComponent *comp;
+ ECalBackendGroupwisePrivate *priv;
+ ECalBackendGroupwise *cbgw = (ECalBackendGroupwise *) backend;
+
+ g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_OtherError);
+
+ priv = cbgw->priv;
+
+ /* search the object in the cache */
+ comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+ if (comp) {
+ *object = e_cal_component_get_as_string (comp);
+ g_object_unref (comp);
+
+ return GNOME_Evolution_Calendar_Success;
+ }
+
+ /* FIXME: get the object from the server */
+ return GNOME_Evolution_Calendar_ObjectNotFound;
}
/* Get_timezone_object handler for the file backend */
backend_class = (ECalBackendClass *) class;
sync_class = (ECalBackendSyncClass *) class;
- parent_class = (ECalBackendSyncClass *) g_type_class_peek_parent (class);
+ parent_class = g_type_class_peek_parent (class);
object_class->dispose = e_cal_backend_groupwise_dispose;
object_class->finalize = e_cal_backend_groupwise_finalize;