[evolution-mapi] Store last refresh information rather in folder's CamelStoreInfo



commit 9fa4ea3eb3d1b7ac9f39455cf7cba29e6e2ab66f
Author: Milan Crha <mcrha redhat com>
Date:   Mon Dec 19 16:20:07 2011 +0100

    Store last refresh information rather in folder's CamelStoreInfo
    
    CamelFolderSummary is freed as soon as the CamelFolder, which is freed
    when user moves to a different folder in the folder tree, thus storing
    any information about last update during current session is useless
    there. The CamelStoreInfo is persistent during the session, thus use it
    to know about last folder checking. These values are not saved, they
    are meant to be only for the current session.

 src/camel/camel-mapi-folder-summary.c |    2 --
 src/camel/camel-mapi-folder-summary.h |    3 ---
 src/camel/camel-mapi-folder.c         |   28 +++++++++++++++++++++-------
 src/camel/camel-mapi-store-summary.c  |    3 +++
 src/camel/camel-mapi-store-summary.h  |    4 ++++
 5 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/src/camel/camel-mapi-folder-summary.c b/src/camel/camel-mapi-folder-summary.c
index 7b9964c..db5b8c1 100644
--- a/src/camel/camel-mapi-folder-summary.c
+++ b/src/camel/camel-mapi-folder-summary.c
@@ -102,8 +102,6 @@ camel_mapi_folder_summary_class_init (CamelMapiFolderSummaryClass *class)
 static void
 camel_mapi_folder_summary_init (CamelMapiFolderSummary *mapi_summary)
 {
-	mapi_summary->latest_last_modify = 0;
-	mapi_summary->last_obj_total = -1;
 }
 
 /**
diff --git a/src/camel/camel-mapi-folder-summary.h b/src/camel/camel-mapi-folder-summary.h
index bc6a664..067d268 100644
--- a/src/camel/camel-mapi-folder-summary.h
+++ b/src/camel/camel-mapi-folder-summary.h
@@ -66,9 +66,6 @@ struct _CamelMapiMessageContentInfo {
 struct _CamelMapiFolderSummary {
 	CamelFolderSummary parent;
 
-	time_t latest_last_modify;
-	gint last_obj_total;
-
 	guint32 version;
 	guint32 validity;
 };
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 31dccf4..c993b4f 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -651,9 +651,10 @@ camel_mapi_folder_fetch_summary (CamelFolder *folder, GCancellable *cancellable,
 	gboolean full_download;
 	CamelSettings *settings;
 	CamelStore *store = camel_folder_get_parent_store (folder);
+	CamelStoreInfo *si = NULL;
+	CamelMapiStoreInfo *msi = NULL;
 	CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (store);
 	CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (folder);
-	CamelMapiFolderSummary *mapi_summary = CAMEL_MAPI_FOLDER_SUMMARY (folder->summary);
 	EMapiConnection *conn = camel_mapi_store_get_connection (mapi_store);
 	struct FolderBasicPropertiesData fbp;
 	struct GatherChangedObjectsData gco;
@@ -678,11 +679,24 @@ camel_mapi_folder_fetch_summary (CamelFolder *folder, GCancellable *cancellable,
 	else
 		status = e_mapi_connection_open_personal_folder (conn, mapi_folder->folder_id, &obj_folder, cancellable, mapi_error);
 
+	si = camel_mapi_store_summary_get_folder_id (mapi_store->summary, mapi_folder->folder_id);
+	msi = (CamelMapiStoreInfo *) si;
+
+	if (!msi) {
+		camel_operation_pop_message (cancellable);
+		camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+		camel_folder_thaw (folder);
+
+		g_return_val_if_fail (msi != NULL, FALSE);
+
+		return FALSE;
+	}
+
 	if (status) {
 		status = e_mapi_connection_get_folder_properties (conn, &obj_folder, NULL, NULL, e_mapi_utils_get_folder_basic_properties_cb, &fbp, cancellable, mapi_error);
 		if (status) {
-			if (mapi_summary->last_obj_total != fbp.obj_total)
-				mapi_summary->latest_last_modify = 0;
+			if (msi->last_obj_total != fbp.obj_total)
+				msi->latest_last_modify = 0;
 		}
 	}
 
@@ -692,7 +706,7 @@ camel_mapi_folder_fetch_summary (CamelFolder *folder, GCancellable *cancellable,
 	gco.to_update = NULL;
 	gco.removed_uids = NULL;
 
-	if (mapi_summary->latest_last_modify <= 0) {
+	if (msi->latest_last_modify <= 0) {
 		GPtrArray *known_uids;
 
 		camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
@@ -712,7 +726,7 @@ camel_mapi_folder_fetch_summary (CamelFolder *folder, GCancellable *cancellable,
 
 	if (status) {
 		status = e_mapi_connection_list_objects (conn, &obj_folder,
-			full_download ? NULL : e_mapi_utils_build_last_modify_restriction, &mapi_summary->latest_last_modify,
+			full_download ? NULL : e_mapi_utils_build_last_modify_restriction, &msi->latest_last_modify,
 			gather_changed_objects_to_slist, &gco, cancellable, mapi_error);
 	}
 
@@ -763,8 +777,8 @@ camel_mapi_folder_fetch_summary (CamelFolder *folder, GCancellable *cancellable,
 
 	if (status) {
 		if (gco.latest_last_modify > 0)
-			mapi_summary->latest_last_modify = gco.latest_last_modify;
-		mapi_summary->last_obj_total = fbp.obj_total;
+			msi->latest_last_modify = gco.latest_last_modify;
+		msi->last_obj_total = fbp.obj_total;
 	}
 
 	camel_folder_summary_save_to_db (folder->summary, NULL);
diff --git a/src/camel/camel-mapi-store-summary.c b/src/camel/camel-mapi-store-summary.c
index 162c3c5..5a1bbfd 100644
--- a/src/camel/camel-mapi-store-summary.c
+++ b/src/camel/camel-mapi-store-summary.c
@@ -252,6 +252,9 @@ camel_mapi_store_summary_add_from_full (CamelStoreSummary *s,
 		msi->camel_folder_flags = camel_folder_flags;
 		msi->mapi_folder_flags = mapi_folder_flags;
 		msi->foreign_user_name = g_strdup ((foreign_user_name && *foreign_user_name) ? foreign_user_name : "");
+
+		msi->latest_last_modify = 0;
+		msi->last_obj_total = -1;
 	}
 
 	return si;
diff --git a/src/camel/camel-mapi-store-summary.h b/src/camel/camel-mapi-store-summary.h
index 9715d79..3ae1390 100644
--- a/src/camel/camel-mapi-store-summary.h
+++ b/src/camel/camel-mapi-store-summary.h
@@ -72,6 +72,10 @@ struct _CamelMapiStoreInfo {
 	guint32 camel_folder_flags; /* CamelFolderInfo::flags */
 	guint32 mapi_folder_flags; /* bit-or of CamelMapiStoreFolderFlags */
 	gchar *foreign_user_name; /* only if CAMEL_MAPI_STORE_FOLDER_FLAG_FOREIGN is set */
+
+	/* these are not saved */
+	time_t latest_last_modify;
+	gint last_obj_total;
 };
 
 struct _CamelMapiStoreSummary {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]