[evolution-mapi] Bug #641911 - Ignores offline request



commit 61f9d565634794a7e3099702a301e6e082cbc35b
Author: Milan Crha <mcrha redhat com>
Date:   Mon Feb 28 19:27:32 2011 +0100

    Bug #641911 - Ignores offline request

 .../exchange-mapi-account-listener.c               |    4 +++
 .../exchange-mapi-account-setup.c                  |    6 ++++
 src/camel/camel-mapi-folder.c                      |   10 ++++---
 src/camel/camel-mapi-store.c                       |   28 ++++++++++----------
 src/libexchangemapi/exchange-mapi-mail-utils.c     |    5 +++
 5 files changed, 35 insertions(+), 18 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.c b/src/account-setup-eplugin/exchange-mapi-account-listener.c
index bfa6dcf..2572f4a 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.c
@@ -36,6 +36,7 @@
 #include <libedataserver/e-account-list.h>
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-source-list.h>
+#include <shell/e-shell.h>
 
 #include <exchange-mapi-folder.h>
 #include <exchange-mapi-connection.h>
@@ -1102,6 +1103,9 @@ create_profile_entry (CamelURL *url, EAccount *account)
 	gboolean status = FALSE;
 	guint8 attempts = 0;
 
+	if (!e_shell_get_online (e_shell_get_default ()))
+		return FALSE;
+
 	while (!status && attempts <= 3) {
 		gchar *password = NULL, *key = NULL;
 
diff --git a/src/account-setup-eplugin/exchange-mapi-account-setup.c b/src/account-setup-eplugin/exchange-mapi-account-setup.c
index a176959..564fe56 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-setup.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-setup.c
@@ -39,6 +39,7 @@
 #include "exchange-mapi-account-setup.h"
 #include <addressbook/gui/widgets/eab-config.h>
 #include <calendar/gui/e-cal-config.h>
+#include <shell/e-shell.h>
 
 #include <exchange-mapi-folder.h>
 #include <exchange-mapi-connection.h>
@@ -199,6 +200,11 @@ validate_credentials (GtkWidget *widget, EConfig *config)
 	gchar *key = NULL, *password = NULL;
 	const gchar *domain_name = NULL;
 
+	if (!e_shell_get_online (e_shell_get_default ())) {
+		e_notice (NULL, GTK_MESSAGE_ERROR, "%s", _("Cannot create MAPI folders in offline mode."));
+		return;
+	}
+
 	url = camel_url_new (e_account_get_string (target_account->account, E_ACCOUNT_SOURCE_URL), NULL);
 	domain_name = camel_url_get_param (url, "domain");
 
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 04853d2..750a852 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -48,6 +48,8 @@
 #define SUMMARY_FETCH_BATCH_COUNT 150
 #define d(x)
 
+extern gint camel_application_is_exiting;
+
 struct _CamelMapiFolderPrivate {
 
 //#ifdef ENABLE_THREADS
@@ -227,7 +229,7 @@ fetch_items_summary_cb (FetchItemsCallbackData *item_data, gpointer data)
 	if (item_data->total > 0)
                camel_operation_progress (NULL, (item_data->index * 100)/item_data->total);
 
-	if (camel_operation_cancel_check(NULL))
+	if (camel_operation_cancel_check (NULL) || camel_application_is_exiting)
 		return FALSE;
 
 	return TRUE;
@@ -541,7 +543,7 @@ deleted_items_sync_cb (FetchItemsCallbackData *item_data, gpointer data)
 		camel_operation_progress (NULL, (item_data->index * 100)/item_data->total);
 
 	/* Check if we have to stop */
-	if (camel_operation_cancel_check(NULL))
+	if (camel_operation_cancel_check (NULL) || camel_application_is_exiting)
 		return FALSE;
 
 	return TRUE;
@@ -596,7 +598,7 @@ mapi_sync_deleted (CamelSession *session, CamelSessionThreadMsg *msg)
 	camel_service_unlock (CAMEL_SERVICE (mapi_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	/* Check if we have to stop */
-	if (camel_operation_cancel_check(NULL)) {
+	if (camel_operation_cancel_check (NULL) || camel_application_is_exiting) {
 		g_hash_table_destroy (server_messages);
 		return;
 	}
@@ -649,7 +651,7 @@ mapi_sync_deleted (CamelSession *session, CamelSessionThreadMsg *msg)
 		camel_operation_progress (NULL, (index * 100)/count); /* ;-) */
 
 		/* Check if we have to stop */
-		if (camel_operation_cancel_check(NULL)) {
+		if (camel_operation_cancel_check (NULL) || camel_application_is_exiting) {
 			g_hash_table_destroy (server_messages);
 			if (camel_folder_change_info_changed (changes))
 				camel_folder_changed (m->folder, changes);
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 4dff0fc..072b0e1 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -908,22 +908,22 @@ mapi_store_get_folder_info_sync (CamelStore *store,
 			((CamelService *)store)->status = CAMEL_SERVICE_CONNECTING;
 			mapi_connect_sync ((CamelService *)store, cancellable, NULL);
 		}
-	}
 
-	/* update folders from the server only when asking for the top most or the 'top' is not known;
-	   otherwise believe the local cache, because folders sync is pretty slow operation to be done
-	   one every single question on the folder info */
-	if (((flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST) != 0 ||
-	     (!(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)) ||
-	     (!mapi_store->priv->folders_synced) ||
-	     (top && *top && !camel_mapi_store_folder_id_lookup (mapi_store, top))) &&
-	    (check_for_connection ((CamelService *)store, NULL) || ((CamelService *)store)->status == CAMEL_SERVICE_CONNECTING)) {
-		if (!mapi_folders_sync (mapi_store, flags, error)) {
-			camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
-			return NULL;
+		/* update folders from the server only when asking for the top most or the 'top' is not known;
+		   otherwise believe the local cache, because folders sync is pretty slow operation to be done
+		   one every single question on the folder info */
+		if (((flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST) != 0 ||
+		    (!(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)) ||
+		    (!mapi_store->priv->folders_synced) ||
+		    (top && *top && !camel_mapi_store_folder_id_lookup (mapi_store, top))) &&
+		    (check_for_connection ((CamelService *)store, NULL) || ((CamelService *)store)->status == CAMEL_SERVICE_CONNECTING)) {
+			if (!mapi_folders_sync (mapi_store, flags, error)) {
+				camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+				return NULL;
+			}
+			camel_store_summary_touch ((CamelStoreSummary *)mapi_store->summary);
+			camel_store_summary_save ((CamelStoreSummary *)mapi_store->summary);
 		}
-		camel_store_summary_touch ((CamelStoreSummary *)mapi_store->summary);
-		camel_store_summary_save ((CamelStoreSummary *)mapi_store->summary);
 	}
 
 	camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
diff --git a/src/libexchangemapi/exchange-mapi-mail-utils.c b/src/libexchangemapi/exchange-mapi-mail-utils.c
index 2993a84..9af7a9b 100644
--- a/src/libexchangemapi/exchange-mapi-mail-utils.c
+++ b/src/libexchangemapi/exchange-mapi-mail-utils.c
@@ -28,6 +28,8 @@
 #include "exchange-mapi-cal-utils.h"
 #include "exchange-mapi-mail-utils.h"
 
+extern gint camel_application_is_exiting;
+
 void
 mail_item_free (MailItem *item)
 {
@@ -157,6 +159,9 @@ fetch_props_to_mail_item_cb (FetchItemsCallbackData *item_data, gpointer data)
 
 	*i = item;
 
+	if (camel_application_is_exiting)
+		return FALSE;
+
 	return TRUE;
 }
 



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