Re: [evolution-patches] Network Manager support for Evolution



On Mon, 2005-12-12 at 11:45 -0500, Jeffrey Stedfast wrote:
> the patch is empty?
> 
> On Mon, 2005-12-12 at 14:00 +0530, Shreyas Srinivasan wrote:
> > On Mon, 2005-12-12 at 13:53 +0530, Shreyas Srinivasan wrote:
> > > On Tue, 2005-11-15 at 16:00 +0530, Shreyas Sriniavasan wrote:
> > > > Hey,
> > > > 
doh, so here goes an other attempt to challenge my 
intellect to send the right patch.

--
Shreyas

-- 
What can i do? I am just being me
Index: camel-disco-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-disco-store.c,v
retrieving revision 1.17
diff -u -p -r1.17 camel-disco-store.c
--- camel-disco-store.c	18 Nov 2005 05:55:34 -0000	1.17
+++ camel-disco-store.c	12 Dec 2005 17:47:03 -0000
@@ -296,6 +296,8 @@ static void
 set_status(CamelDiscoStore *disco_store, CamelDiscoStoreStatus status, CamelException *ex)
 {
 	CamelException x;
+	CamelService *service = CAMEL_SERVICE (disco_store);
+	gboolean network_state = camel_session_network_up (service->session);
 
 	if (disco_store->status == status)
 		return;
@@ -303,32 +305,36 @@ set_status(CamelDiscoStore *disco_store,
 	camel_exception_init(&x);
 	/* Sync the folder fully if we've been told to sync online for this store or this folder
 	   and we're going offline */
-	if (disco_store->status == CAMEL_DISCO_STORE_ONLINE
-	    && status == CAMEL_DISCO_STORE_OFFLINE) {
-		if (((CamelStore *)disco_store)->folders) {
-			GPtrArray *folders;
-			CamelFolder *folder;
-			int i, sync;
-			
-			sync =  camel_url_get_param(((CamelService *)disco_store)->url, "offline_sync") != NULL;
 
-			folders = camel_object_bag_list(((CamelStore *)disco_store)->folders);
-			for (i=0;i<folders->len;i++) {
-				folder = folders->pdata[i];
-				if (CAMEL_CHECK_TYPE(folder, CAMEL_DISCO_FOLDER_TYPE)
-				    && (sync || ((CamelDiscoFolder *)folder)->offline_sync)) {
-					camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "(match-all)", &x);
-					camel_exception_clear(&x);
+	if (network_state) {
+		if (disco_store->status == CAMEL_DISCO_STORE_ONLINE
+		    && status == CAMEL_DISCO_STORE_OFFLINE) {
+			if (((CamelStore *)disco_store)->folders) {
+				GPtrArray *folders;
+				CamelFolder *folder;
+				int i, sync;
+				
+				sync =  camel_url_get_param(((CamelService *)disco_store)->url, "offline_sync") != NULL;
+				
+				folders = camel_object_bag_list(((CamelStore *)disco_store)->folders);
+				for (i=0;i<folders->len;i++) {
+					folder = folders->pdata[i];
+					if (CAMEL_CHECK_TYPE(folder, CAMEL_DISCO_FOLDER_TYPE)
+					    && (sync || ((CamelDiscoFolder *)folder)->offline_sync)) {
+						camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "(match-all)", &x);
+						camel_exception_clear(&x);
+					}
+					camel_object_unref(folder);
 				}
-				camel_object_unref(folder);
+				g_ptr_array_free(folders, TRUE);
 			}
-			g_ptr_array_free(folders, TRUE);
 		}
+		
+		camel_store_sync(CAMEL_STORE (disco_store), FALSE, &x);
+		camel_exception_clear(&x);
 	}
-
-	camel_store_sync(CAMEL_STORE (disco_store), FALSE, &x);
-	camel_exception_clear(&x);
-	if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), TRUE, ex))
+	
+	if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), network_state, ex))
 		return;
 
 	disco_store->status = status;
Index: camel-offline-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-offline-store.c,v
retrieving revision 1.4
diff -u -p -r1.4 camel-offline-store.c
--- camel-offline-store.c	31 Aug 2005 04:21:56 -0000	1.4
+++ camel-offline-store.c	12 Dec 2005 17:47:10 -0000
@@ -115,46 +115,53 @@ void
 camel_offline_store_set_network_state (CamelOfflineStore *store, int state, CamelException *ex)
 {
 	CamelException lex;
-	
+	CamelService *service = CAMEL_SERVICE (store);
+	gboolean network_state = camel_session_get_network_state (service->session);
+
 	if (store->state == state)
 		return;
 	
 	camel_exception_init (&lex);
 	if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
 		/* network available -> network unavailable */
-		if (((CamelStore *) store)->folders) {
-			GPtrArray *folders;
-			CamelFolder *folder;
-			int i, sync;
-			
-			sync = camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL;
-			
-			folders = camel_object_bag_list (((CamelStore *) store)->folders);
-			for (i = 0; i < folders->len; i++) {
-				folder = folders->pdata[i];
+		if (network_state) {
+			if (((CamelStore *) store)->folders) {
+				GPtrArray *folders;
+				CamelFolder *folder;
+				int i, sync;
+				
+				sync = camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL;
 				
-				if (CAMEL_CHECK_TYPE (folder, CAMEL_OFFLINE_FOLDER_TYPE)
-				    && (sync || ((CamelOfflineFolder *) folder)->sync_offline)) {
-					camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex);
-					camel_exception_clear (&lex);
+				folders = camel_object_bag_list (((CamelStore *) store)->folders);
+				for (i = 0; i < folders->len; i++) {
+					folder = folders->pdata[i];
+					
+					if (CAMEL_CHECK_TYPE (folder, CAMEL_OFFLINE_FOLDER_TYPE)
+					    && (sync || ((CamelOfflineFolder *) folder)->sync_offline)) {
+						camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex);
+						camel_exception_clear (&lex);
+					}
+					
+					camel_object_unref (folder);
 				}
 				
-				camel_object_unref (folder);
+				g_ptr_array_free (folders, TRUE);
 			}
 			
-			g_ptr_array_free (folders, TRUE);
+			camel_store_sync (CAMEL_STORE (store), FALSE, &lex);
+			camel_exception_clear (&lex);
 		}
-		
-		camel_store_sync (CAMEL_STORE (store), FALSE, &lex);
-		camel_exception_clear (&lex);
-		
-		if (!camel_service_disconnect (CAMEL_SERVICE (store), TRUE, ex))
+
+		if (!camel_service_disconnect (CAMEL_SERVICE (store), network_state, ex))
 			return;
 	} else {
 		/* network unavailable -> network available */
 		if (!camel_service_connect (CAMEL_SERVICE (store), ex))
 			return;
+		fprintf (stderr, "i hit this boo wtf\n");
 	}
 	
+	if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) 
+		fprintf (stderr,"I do my job well\n");
 	store->state = state;
 }
Index: camel-session.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-session.c,v
retrieving revision 1.112
diff -u -p -r1.112 camel-session.c
--- camel-session.c	1 Dec 2005 11:21:12 -0000	1.112
+++ camel-session.c	12 Dec 2005 17:47:16 -0000
@@ -68,6 +68,7 @@ static void
 camel_session_init (CamelSession *session)
 {
 	session->online = TRUE;
+	session->network_state = TRUE;
 	session->priv = g_malloc0(sizeof(*session->priv));
 	
 	session->priv->lock = g_mutex_new();
@@ -678,4 +679,20 @@ camel_session_set_check_junk (CamelSessi
 	g_assert(CAMEL_IS_SESSION(session));
 
 	session->check_junk = check_junk;
+}
+
+gboolean
+camel_session_get_network_state (CamelSession *session)
+{
+	g_assert(CAMEL_IS_SESSION(session));
+	
+	return session->network_state;
+}
+
+void
+camel_session_set_network_state (CamelSession *session, gboolean network_state)
+{
+	g_assert(CAMEL_IS_SESSION(session));
+	
+	session->network_state = network_state;
 }
Index: camel-session.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-session.h,v
retrieving revision 1.52
diff -u -p -r1.52 camel-session.h
--- camel-session.h	31 Aug 2005 04:21:56 -0000	1.52
+++ camel-session.h	12 Dec 2005 17:47:16 -0000
@@ -68,6 +68,7 @@ struct _CamelSession
 
 	gboolean online:1;
 	gboolean check_junk:1;
+	gboolean network_state:1;
 };
 
 typedef struct _CamelSessionThreadOps CamelSessionThreadOps;
@@ -193,7 +194,8 @@ void *camel_session_thread_msg_new(Camel
 void camel_session_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *msg);
 int camel_session_thread_queue(CamelSession *session, CamelSessionThreadMsg *msg, int flags);
 void camel_session_thread_wait(CamelSession *session, int id);
-
+gboolean camel_session_get_network_state (CamelSession *session);
+void camel_session_set_network_state (CamelSession *session, gboolean network_state);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */


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