[evolution-kolab] kolab-util-contact-cache.c: Replace uri params with EBookBackendSync.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] kolab-util-contact-cache.c: Replace uri params with EBookBackendSync.
- Date: Thu, 12 Jul 2012 12:41:08 +0000 (UTC)
commit f55b3b58c7cbfdbb60b6aa9664e5cdda9f3703b7
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Jun 27 14:49:55 2012 -0400
kolab-util-contact-cache.c: Replace uri params with EBookBackendSync.
The "backend" parameter really only has to be an EBackend. I made it
EBookBackendSync just for calling convenience from EBookBackendKolab.
Functions can then call kolab_util_backend_get_foldername() to obtain
the Kolab IMAP foldername for the backend, instead of parsing URIs.
src/addressbook/e-book-backend-kolab.c | 32 +++++++-------
src/addressbook/kolab-util-contact-cache.c | 64 ++++++++++++++--------------
src/addressbook/kolab-util-contact-cache.h | 20 ++++----
3 files changed, 58 insertions(+), 58 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-kolab.c b/src/addressbook/e-book-backend-kolab.c
index 0fa47d4..8c826ae 100644
--- a/src/addressbook/e-book-backend-kolab.c
+++ b/src/addressbook/e-book-backend-kolab.c
@@ -576,9 +576,9 @@ e_book_backend_kolab_create_contacts (EBookBackendSync *backend,
goto exit;
}
- ok = kolab_util_contact_cache_assure_uid_on_econtact (priv->book_koma,
+ ok = kolab_util_contact_cache_assure_uid_on_econtact (backend,
+ priv->book_koma,
econtact,
- priv->book_uri,
FALSE,
cancellable,
&tmp_err);
@@ -743,8 +743,8 @@ e_book_backend_kolab_get_contact (EBookBackendSync *backend,
g_debug ("%s()[%u] called.", __func__, __LINE__);
- econtact = kolab_util_contact_cache_get_object (priv->book_koma,
- priv->book_uri,
+ econtact = kolab_util_contact_cache_get_object (backend,
+ priv->book_koma,
id,
FALSE,
cancellable,
@@ -789,9 +789,9 @@ e_book_backend_kolab_get_contact_list (EBookBackendSync *backend,
g_debug (" + query: %s", query);
/* Update the cache to contain all data requested. */
- ok = kolab_util_contact_cache_update_on_query (priv->book_koma,
+ ok = kolab_util_contact_cache_update_on_query (backend,
+ priv->book_koma,
query,
- priv->book_uri,
cancellable,
&tmp_err);
if (! ok) {
@@ -801,9 +801,9 @@ e_book_backend_kolab_get_contact_list (EBookBackendSync *backend,
}
/* Fetch information from BackendCache */;
- econtact_list = kolab_util_contact_cache_get_contacts (priv->book_koma,
+ econtact_list = kolab_util_contact_cache_get_contacts (backend,
+ priv->book_koma,
query,
- priv->book_uri,
cancellable,
&tmp_err);
if (tmp_err != NULL) {
@@ -862,9 +862,9 @@ e_book_backend_kolab_get_contact_list_uids (EBookBackendSync *backend,
*/
/* Update the cache to contain all data requested. */
- ok = kolab_util_contact_cache_update_on_query (priv->book_koma,
+ ok = kolab_util_contact_cache_update_on_query (backend,
+ priv->book_koma,
query,
- priv->book_uri,
cancellable,
&tmp_err);
if (! ok) {
@@ -874,9 +874,9 @@ e_book_backend_kolab_get_contact_list_uids (EBookBackendSync *backend,
}
/* Fetch information from BackendCache */;
- econtact_list = kolab_util_contact_cache_get_contacts (priv->book_koma,
+ econtact_list = kolab_util_contact_cache_get_contacts (backend,
+ priv->book_koma,
query,
- priv->book_uri,
cancellable,
&tmp_err);
if (tmp_err != NULL) {
@@ -1089,17 +1089,17 @@ e_book_backend_kolab_start_book_view (EBookBackend *backend,
query = e_data_book_view_get_card_query (book_view);
/* First update the BackendCache to the current situation. */
- ok = kolab_util_contact_cache_update_on_query (priv->book_koma,
+ ok = kolab_util_contact_cache_update_on_query (E_BOOK_BACKEND_SYNC (backend),
+ priv->book_koma,
query,
- priv->book_uri,
NULL, /* FIXME GCancellable */
&tmp_err);
if (! ok)
goto exit;
- econtact_list = kolab_util_contact_cache_get_contacts (priv->book_koma,
+ econtact_list = kolab_util_contact_cache_get_contacts (E_BOOK_BACKEND_SYNC (backend),
+ priv->book_koma,
query,
- priv->book_uri,
NULL, /* FIXME GCancellable */
&tmp_err);
if (tmp_err != NULL)
diff --git a/src/addressbook/kolab-util-contact-cache.c b/src/addressbook/kolab-util-contact-cache.c
index ab93c08..679107a 100644
--- a/src/addressbook/kolab-util-contact-cache.c
+++ b/src/addressbook/kolab-util-contact-cache.c
@@ -35,8 +35,8 @@
/*----------------------------------------------------------------------------*/
EContact*
-kolab_util_contact_cache_get_object (KolabMailAccess *koma,
- const gchar *uri,
+kolab_util_contact_cache_get_object (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *uid,
gboolean bulk,
GCancellable *cancellable,
@@ -45,23 +45,22 @@ kolab_util_contact_cache_get_object (KolabMailAccess *koma,
const KolabMailHandle *kmh = NULL;
EContact *econtact = NULL;
GError *tmp_error = NULL;
- gchar *sourcename = NULL;
+ const gchar *foldername;
gboolean ok = FALSE;
+ g_assert (E_IS_BOOK_BACKEND (backend));
g_assert (KOLAB_IS_MAIL_ACCESS (koma));
- g_assert (uri != NULL);
g_assert (uid != NULL);
/* cancellable may be NULL */
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- sourcename = kolab_util_backend_get_relative_path_from_uri (uri);
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
kmh = kolab_mail_access_get_handle (koma,
uid,
- sourcename,
+ foldername,
cancellable,
&tmp_error);
- g_free (sourcename);
if (kmh == NULL) {
/* empty object, could be "nothing found" */
if (tmp_error != NULL) {
@@ -85,8 +84,8 @@ kolab_util_contact_cache_get_object (KolabMailAccess *koma,
} /* kolab_util_contact_cache_get_object () */
gboolean
-kolab_util_contact_cache_update_object (KolabMailAccess *koma,
- const gchar *uri,
+kolab_util_contact_cache_update_object (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *uid,
gboolean bulk,
GCancellable *cancellable,
@@ -94,14 +93,14 @@ kolab_util_contact_cache_update_object (KolabMailAccess *koma,
{
EContact *tmp_contact = NULL;
+ g_assert (E_IS_BOOK_BACKEND (backend));
g_assert (KOLAB_IS_MAIL_ACCESS (koma));
- g_assert (uri != NULL);
g_assert (uid != NULL);
/* cancellable may be NULL */
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- tmp_contact = kolab_util_contact_cache_get_object (koma,
- uri,
+ tmp_contact = kolab_util_contact_cache_get_object (backend,
+ koma,
uid,
bulk,
cancellable,
@@ -115,9 +114,9 @@ kolab_util_contact_cache_update_object (KolabMailAccess *koma,
/**
* kolab_util_contact_cache_assure_uid_on_econtact:
+ * @backend: an #EBookBackendSync
* @koma: A KolabMailAccess instance.
* @econtact: An EContact.
- * @uri: An EContact uri string.
* @bulk: Whether or not this is a mass operation.
* @cancellable: A cancellation stack.
* @error: GError placeholder.
@@ -127,9 +126,9 @@ kolab_util_contact_cache_update_object (KolabMailAccess *koma,
* Returns: On Success TRUE is returned.
*/
gboolean
-kolab_util_contact_cache_assure_uid_on_econtact (KolabMailAccess *koma,
+kolab_util_contact_cache_assure_uid_on_econtact (EBookBackendSync *backend,
+ KolabMailAccess *koma,
EContact *econtact,
- const gchar *uri,
gboolean bulk,
GCancellable *cancellable,
GError **error)
@@ -139,9 +138,9 @@ kolab_util_contact_cache_assure_uid_on_econtact (KolabMailAccess *koma,
gchar *uid = NULL;
KolabSettingsHandler *ksettings = NULL;
+ g_assert (E_IS_BOOK_BACKEND (backend));
g_assert (KOLAB_IS_MAIL_ACCESS (koma));
g_assert (E_IS_CONTACT (econtact));
- g_assert (uri != NULL);
/* cancellable may be NULL */
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -154,8 +153,8 @@ kolab_util_contact_cache_assure_uid_on_econtact (KolabMailAccess *koma,
if (uid == NULL)
uid = e_cal_component_gen_uid();
for (;;) {
- tmp_contact = kolab_util_contact_cache_get_object (koma,
- uri,
+ tmp_contact = kolab_util_contact_cache_get_object (backend,
+ koma,
uid,
bulk,
cancellable,
@@ -181,9 +180,9 @@ kolab_util_contact_cache_assure_uid_on_econtact (KolabMailAccess *koma,
/**
* kolab_util_contact_cache_update_on_query:
+ * @backend: an #EBookBackendSync
* @koma: A KolabMailAccess object.
* @query: The query string associated with the update operation.
- * @uri: The URI string for access to the @koma object.
* @cancellable: A cancellation stack.
* @error: A GError placeholder.
*
@@ -193,28 +192,29 @@ kolab_util_contact_cache_assure_uid_on_econtact (KolabMailAccess *koma,
* Returns: TRUE on success.
*/
gboolean
-kolab_util_contact_cache_update_on_query (KolabMailAccess *koma,
+kolab_util_contact_cache_update_on_query (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *query,
- const gchar *uri,
GCancellable *cancellable,
GError **error)
{
GList *changed_uids = NULL;
- gchar *sourcename = NULL;
+ const gchar *foldername;
GError *tmp_error = NULL;
g_debug ("%s()[%u] called.", __func__, __LINE__);
- sourcename = kolab_util_backend_get_relative_path_from_uri (uri);
+ g_assert (E_IS_BOOK_BACKEND (backend));
g_assert (KOLAB_IS_MAIL_ACCESS (koma));
/* query may be NULL */
- g_assert (uri != NULL);
/* cancellable may be NULL */
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
+
/* First task: Update the BackendCache in case of changes */
changed_uids = kolab_mail_access_query_changed_uids (koma,
- sourcename,
+ foldername,
query,
cancellable,
&tmp_error);
@@ -231,31 +231,31 @@ kolab_util_contact_cache_update_on_query (KolabMailAccess *koma,
}
GList*
-kolab_util_contact_cache_get_contacts (KolabMailAccess *koma,
+kolab_util_contact_cache_get_contacts (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *query,
- const gchar *uri,
GCancellable *cancellable,
GError **error)
{
GList *contact_list = NULL;
GList *uid_list = NULL;
GList *it = NULL;
- gchar *sourcename = NULL;
const KolabMailHandle *kmh = NULL;
+ const gchar *foldername;
EContact *econtact = NULL;
gboolean ok = FALSE;
GError *tmp_error = NULL;
g_debug ("%s()[%u] called.", __func__, __LINE__);
- sourcename = kolab_util_backend_get_relative_path_from_uri (uri);
g_assert (KOLAB_IS_MAIL_ACCESS (koma));
/* query may be NULL */
- g_assert (uri != NULL);
/* cancellable may be NULL */
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+ foldername = kolab_util_backend_get_foldername (E_BACKEND (backend));
+
/* get list of Kolab UIDs */
- uid_list = kolab_mail_access_query_uids (koma, sourcename, query, &tmp_error);
+ uid_list = kolab_mail_access_query_uids (koma, foldername, query, &tmp_error);
if (tmp_error != NULL) {
g_propagate_error (error, tmp_error);
return NULL;
@@ -265,7 +265,7 @@ kolab_util_contact_cache_get_contacts (KolabMailAccess *koma,
for (it = g_list_first (uid_list); it != NULL; it = g_list_next (it)) {
kmh = kolab_mail_access_get_handle (koma,
(gchar *)it->data,
- sourcename,
+ foldername,
cancellable,
&tmp_error);
if (kmh == NULL) {
diff --git a/src/addressbook/kolab-util-contact-cache.h b/src/addressbook/kolab-util-contact-cache.h
index 3c7297a..248ed03 100644
--- a/src/addressbook/kolab-util-contact-cache.h
+++ b/src/addressbook/kolab-util-contact-cache.h
@@ -40,39 +40,39 @@
/*----------------------------------------------------------------------------*/
gboolean
-kolab_util_contact_cache_assure_uid_on_econtact (KolabMailAccess *koma,
+kolab_util_contact_cache_assure_uid_on_econtact (EBookBackendSync *backend,
+ KolabMailAccess *koma,
EContact *econtact,
- const gchar *uri,
gboolean bulk,
GCancellable *cancellable,
GError **error);
EContact*
-kolab_util_contact_cache_get_object (KolabMailAccess *koma,
- const gchar *uri,
+kolab_util_contact_cache_get_object (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *uid,
gboolean bulk,
GCancellable *cancellable,
GError **error);
gboolean
-kolab_util_contact_cache_update_object (KolabMailAccess *koma,
- const gchar *uri,
+kolab_util_contact_cache_update_object (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *uid,
gboolean bulk,
GCancellable *cancellable,
GError **error);
gboolean
-kolab_util_contact_cache_update_on_query (KolabMailAccess *koma,
+kolab_util_contact_cache_update_on_query (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *query,
- const gchar *uri,
GCancellable *cancellable,
GError **error);
GList*
-kolab_util_contact_cache_get_contacts (KolabMailAccess *koma,
+kolab_util_contact_cache_get_contacts (EBookBackendSync *backend,
+ KolabMailAccess *koma,
const gchar *query,
- const gchar *uri,
GCancellable *cancellable,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]