char *real_uri;
ECalBackendGroupwisePrivate *priv;
ESource *source;
+ ECalSourceType source_type;
const char *use_ssl;
char *http_uri;
int permissions;
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))
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
ECalBackendSyncStatus status;
+ ECalSourceType source_type;
+ char *source;
char *filename;
char *mangled_uri;
int i;
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;
}
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"));
}
filename = g_build_filename (g_get_home_dir (),
- ".evolution/cache/calendar",
+ ".evolution/cache/", source,
mangled_uri,
NULL);
g_free (mangled_uri);
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++) {
}
/* 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);
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;
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;
{
GObject *obj;
const char *uri;
+ ECalSourceType source_type;
ECalBackendCacheClass *klass;
GObjectClass *parent_class;
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);
}
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
* 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;
}