[evolution-kolab/account-mgmt: 12/12] ECalBackendKolab: Eliminate priv->cal_uri.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/account-mgmt: 12/12] ECalBackendKolab: Eliminate priv->cal_uri.
- Date: Fri, 29 Jun 2012 13:32:06 +0000 (UTC)
commit 829da7a7b5ecb41c045892c5df506939af3cc685
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Jun 29 09:30:14 2012 -0400
ECalBackendKolab: Eliminate priv->cal_uri.
src/calendar/e-cal-backend-kolab.c | 68 ++++++++++++++++-------------------
1 files changed, 31 insertions(+), 37 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index e92a6de..69032ee 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -87,7 +87,6 @@ struct _ECalBackendKolabPrivate {
gchar *user_email;
ECalComponent *default_zone;
ECalSourceType source_type;
- gchar *cal_uri;
GError *mode_switch_err;
};
@@ -263,7 +262,9 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
KolabMailAccess *tmp_koma = NULL;
KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
icalcomponent_kind icalkind = ICAL_VEVENT_COMPONENT;
- gchar *sourcename = NULL;
+ const gchar *foldername;
+ const gchar *cache_dir;
+ gchar *cache_filename;
gchar *servername = NULL;
gchar *username = NULL;
gchar *user_at_server = NULL;
@@ -318,8 +319,6 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
goto exit;
}
- priv->cal_uri = e_source_get_uri (esource);
-
kolab_settings = cal_backend_kolab_get_collection_settings (self);
network_settings = CAMEL_NETWORK_SETTINGS (kolab_settings);
@@ -332,13 +331,18 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
if (priv->cal_cache != NULL) {
g_object_unref (priv->cal_cache);
}
- priv->cal_cache = e_cal_backend_cache_new (priv->cal_uri);
+
+ cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (backend));
+ cache_filename = g_build_filename (cache_dir, "cache.xml", NULL);
+ priv->cal_cache = e_cal_backend_cache_new (cache_filename);
+ g_free (cache_filename);
+
ok = e_file_cache_clean (E_FILE_CACHE (priv->cal_cache));
g_debug (" + Cal cache cleaning %s.", ok ? "was successful" : "FAILED");
/* Prepare data from sync strategy property */
sync_value = camel_kolab_imapx_settings_get_sync_strategy (kolab_settings);
- sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
/* Check whether we have a KolabMailAccess (KoMA) instance already */
user_at_server = g_strdup_printf ("%s %s",
@@ -362,7 +366,7 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
NULL,
NULL,
NULL,
- sourcename,
+ foldername,
&sync_value);
/* We may find that we do not yet have a password set.
* In case we're requested to go online, we will need
@@ -415,7 +419,7 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
servername,
username,
NULL,
- sourcename,
+ foldername,
&sync_value);
/* create new KolabMailAccess instance */
@@ -720,7 +724,7 @@ e_cal_backend_kolab_get_object_list (ECalBackendSync *backend,
ECalBackendKolabPrivate *priv = NULL;
GList *uid_list = NULL;
GList *it = NULL;
- gchar *sourcename = NULL;
+ const gchar *foldername;
gboolean ok = FALSE;
GError *tmp_err = NULL;
@@ -746,12 +750,11 @@ e_cal_backend_kolab_get_object_list (ECalBackendSync *backend,
return;
}
- sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
uid_list = kolab_mail_access_query_uids (priv->cal_koma,
- sourcename,
+ foldername,
sexp,
&tmp_err);
- g_free (sourcename);
if (tmp_err != NULL) {
kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
g_error_free (tmp_err);
@@ -1248,7 +1251,7 @@ e_cal_backend_kolab_remove_objects (ECalBackendSync *backend,
ECalComponentId *id = NULL;
const gchar *uid, *rid;
KolabSettingsHandler *ksettings = NULL;
- gchar *sourcename = NULL;
+ const gchar *foldername;
GError *tmp_err = NULL;
gboolean trigger_needed = FALSE;
gboolean ok = FALSE;
@@ -1278,6 +1281,8 @@ e_cal_backend_kolab_remove_objects (ECalBackendSync *backend,
if (rid == NULL)
mod = CALOBJ_MOD_ALL;
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
+
oldcomp = kolab_util_calendar_cache_get_object (backend,
priv->cal_cache,
priv->cal_koma,
@@ -1352,13 +1357,11 @@ e_cal_backend_kolab_remove_objects (ECalBackendSync *backend,
break;
case CALOBJ_MOD_ALL:
default:
- sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
ok = kolab_mail_access_delete_by_uid (priv->cal_koma,
uid,
- sourcename,
+ foldername,
cancellable,
&tmp_err);
- g_free (sourcename);
(void) e_cal_backend_cache_remove_component (priv->cal_cache,
uid,
NULL);
@@ -1373,15 +1376,13 @@ e_cal_backend_kolab_remove_objects (ECalBackendSync *backend,
}
}
- sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
trigger_needed = kolab_mail_access_source_fbtrigger_needed (priv->cal_koma,
- sourcename,
+ foldername,
&tmp_err);
if (tmp_err != NULL) {
kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
g_error_free (tmp_err);
e_cal_component_free_id (id);
- g_free (sourcename);
g_object_unref (oldcomp);
g_slist_free (*old_components);
*old_components = NULL;
@@ -1390,7 +1391,7 @@ e_cal_backend_kolab_remove_objects (ECalBackendSync *backend,
if (trigger_needed) {
ksettings = kolab_mail_access_get_settings_handler (priv->cal_koma);
ok = kolab_util_calendar_toggle_pfb_trigger (ksettings,
- sourcename,
+ foldername,
&tmp_err);
g_object_unref (ksettings);
if (! ok) {
@@ -1789,7 +1790,7 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
GList *it = NULL;
GSList *iCal_objects = NULL;
const gchar *query = NULL;
- gchar *sourcename = NULL;
+ const gchar *foldername;
GError *tmp_err = NULL;
GError *view_err = NULL;
gboolean ok = FALSE;
@@ -1806,9 +1807,9 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
query = e_data_cal_view_get_text (view);
- sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
- ok = kolab_util_calendar_cache_update_on_query (backend,
+ ok = kolab_util_calendar_cache_update_on_query (E_CAL_BACKEND_SYNC (backend),
priv->cal_cache,
priv->cal_koma,
query,
@@ -1818,7 +1819,7 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
goto exit;
uid_list = kolab_mail_access_query_uids (priv->cal_koma,
- sourcename,
+ foldername,
query,
&tmp_err);
if (tmp_err != NULL)
@@ -1827,7 +1828,7 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
for (it = uid_list; it != NULL; it = g_list_next (it)) {
gchar *uid = it->data;
ECalComponent *ecalcomp = NULL;
- ecalcomp = kolab_util_calendar_cache_get_object (backend,
+ ecalcomp = kolab_util_calendar_cache_get_object (E_CAL_BACKEND_SYNC (backend),
priv->cal_cache,
priv->cal_koma,
uid,
@@ -1880,8 +1881,6 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
g_slist_foreach (iCal_objects, (GFunc) g_free, NULL);
g_slist_free (iCal_objects);
}
- if (sourcename != NULL)
- g_free (sourcename);
if (uid_list != NULL)
kolab_util_glib_glist_free (uid_list);
@@ -1934,7 +1933,6 @@ e_cal_backend_kolab_init (ECalBackendKolab *backend)
priv->user_email = NULL;
priv->default_zone = NULL;
priv->source_type = 0;
- priv->cal_uri = NULL;
priv->mode_switch_err = NULL;
g_signal_connect (E_BACKEND (backend), "notify::online", G_CALLBACK (cal_backend_kolab_signal_online_cb), NULL);
@@ -1977,8 +1975,6 @@ e_cal_backend_kolab_finalize (GObject *object)
if (priv->user_email != NULL)
g_free (priv->user_email);
- if (priv->cal_uri != NULL)
- g_free (priv->cal_uri);
if (priv->mode_switch_err != NULL) {
g_warning ("%s()[%u]: %s",
@@ -2218,7 +2214,7 @@ e_cal_backend_kolab_set_mode (ECalBackend *backend,
GError *error = NULL;
KolabMailAccessOpmodeID koma_mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
KolabMailAccessOpmodeID tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
- gchar *sourcename = NULL;
+ const gchar *foldername;
KolabSettingsHandler *ksettings = NULL;
gboolean ok;
@@ -2269,9 +2265,9 @@ e_cal_backend_kolab_set_mode (ECalBackend *backend,
if (ok && (koma_mode < KOLAB_MAIL_ACCESS_OPMODE_ONLINE))
return;
- sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
ok = kolab_mail_access_source_fbtrigger_needed (priv->cal_koma,
- sourcename,
+ foldername,
&error);
if (error != NULL)
{
@@ -2279,16 +2275,14 @@ e_cal_backend_kolab_set_mode (ECalBackend *backend,
__func__, __LINE__, error->message);
g_error_free (error);
error = NULL;
- goto cleanup;
+ return;
}
if (ok) {
ksettings = kolab_mail_access_get_settings_handler (priv->cal_koma);
kolab_util_calendar_toggle_pfb_trigger (ksettings,
- sourcename);
+ foldername);
g_object_unref (ksettings);
}
- cleanup:
- g_free (sourcename);
} /* e_cal_backend_kolab_set_mode () */
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]