[evolution-mapi/gnome-2-32] Bug #629507 - gal re-fetches itself (part ][)
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi/gnome-2-32] Bug #629507 - gal re-fetches itself (part ][)
- Date: Mon, 4 Oct 2010 13:54:59 +0000 (UTC)
commit 8301f569d7f0bb0284acc53daa7125dc92e915b7
Author: Milan Crha <mcrha redhat com>
Date: Mon Oct 4 15:54:26 2010 +0200
Bug #629507 - gal re-fetches itself (part ][)
src/addressbook/e-book-backend-mapi-gal.c | 7 +++++--
src/addressbook/e-book-backend-mapi.c | 17 ++++++++++++++---
2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi-gal.c b/src/addressbook/e-book-backend-mapi-gal.c
index 58ea50a..87dbf4d 100644
--- a/src/addressbook/e-book-backend-mapi-gal.c
+++ b/src/addressbook/e-book-backend-mapi-gal.c
@@ -139,6 +139,7 @@ ebbm_gal_fetch_contacts (EBookBackendMAPI *ebma, struct mapi_SRestriction *restr
struct FetchGalData fgd = { 0 };
ExchangeMapiConnection *conn;
gchar *last_fetch;
+ gboolean fetch_successful;
e_book_backend_mapi_lock_connection (ebma);
@@ -146,7 +147,6 @@ ebbm_gal_fetch_contacts (EBookBackendMAPI *ebma, struct mapi_SRestriction *restr
if (!conn) {
e_book_backend_mapi_unlock_connection (ebma);
g_propagate_error (error, EDB_ERROR (REPOSITORY_OFFLINE));
-
return;
}
@@ -161,6 +161,7 @@ ebbm_gal_fetch_contacts (EBookBackendMAPI *ebma, struct mapi_SRestriction *restr
if (g_time_val_from_iso8601 (last_fetch, &last_tv) && now.tv_sec - last_tv.tv_sec <= 60 * 60 * 24 * 7) {
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
g_free (last_fetch);
+ e_book_backend_mapi_unlock_connection (ebma);
return;
}
@@ -172,13 +173,15 @@ ebbm_gal_fetch_contacts (EBookBackendMAPI *ebma, struct mapi_SRestriction *restr
fgd.notify_contact_data = notify_contact_data;
fgd.fid = exchange_mapi_connection_get_default_folder_id (conn, olFolderContacts, NULL);
- exchange_mapi_connection_fetch_gal (conn, restriction,
+ fetch_successful = exchange_mapi_connection_fetch_gal (conn, restriction,
mapi_book_utils_get_prop_list, GET_ALL_KNOWN_IDS,
fetch_gal_cb, &fgd, &mapi_error);
if (mapi_error) {
mapi_error_to_edb_error (error, mapi_error, E_DATA_BOOK_STATUS_OTHER_ERROR, _("Failed to fetch GAL entries"));
g_error_free (mapi_error);
+ } else if (!fetch_successful) {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
} else {
GTimeVal now = { 0 };
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 8c5a402..e161ab7 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -326,6 +326,10 @@ ebbm_update_cache_cb (gpointer data)
last_modification_secs = 0;
ebbm_fetch_contacts (ebma, restriction, NULL, &last_modification_secs, &error);
+ if (!error)
+ e_book_backend_cache_set_populated (priv->cache);
+ else
+ e_file_cache_remove_object (E_FILE_CACHE (priv->cache), "populated");
talloc_free (mem_ctx);
}
@@ -695,7 +699,7 @@ ebbm_book_view_thread (gpointer data)
e_book_backend_mapi_update_view_by_cache (bvtd->ebma, bvtd->book_view, &error);
- if (!error && priv && priv->conn && !priv->update_cache_thread
+ if (!error && priv && priv->conn && (!priv->update_cache_thread || g_cancellable_is_cancelled (priv->update_cache))
&& e_book_backend_mapi_book_view_is_running (bvtd->ebma, bvtd->book_view)) {
EBookBackendMAPIClass *ebmac;
@@ -703,13 +707,20 @@ ebbm_book_view_thread (gpointer data)
if (ebmac && ebmac->op_book_view_thread)
ebmac->op_book_view_thread (bvtd->ebma, bvtd->book_view, &error);
- if (!error && !priv->marked_for_offline && !e_book_backend_cache_is_populated (priv->cache)) {
+ if (!error && !e_book_backend_cache_is_populated (priv->cache)) {
/* todo: create restriction based on the book_view */
+ g_cancellable_reset (priv->update_cache);
ebbm_fetch_contacts (bvtd->ebma, NULL, bvtd->book_view, NULL, &error);
- e_book_backend_cache_set_populated (priv->cache);
+ g_cancellable_cancel (priv->update_cache);
+
+ if (!error)
+ e_book_backend_cache_set_populated (priv->cache);
}
}
+ if (error && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_clear_error (&error);
+
/* do not stop book view when filling cache */
if (e_book_backend_mapi_book_view_is_running (bvtd->ebma, bvtd->book_view)
&& (!priv->update_cache_thread || g_cancellable_is_cancelled (priv->update_cache)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]