Re: [evolution-patches] connector fix for bug #72889 and others



Yes, the stub was getting unreffed in disconnect and this was causing the problem. But, we dont have to move the connect code to construct, since the stub initialization [ when started in online mode ] needs to happen in connect. so, i have modified the patch to retain the code in connect, but take care that we dont recreate the stub if its already present.  The only thing that we need to always do in connect is to initialise the stub. Please review.

Thanks
-- Sarfraaz

? camel/camel-exchange-provider.c.surf
Index: camel/camel-exchange-store.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-store.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 camel-exchange-store.c
--- camel/camel-exchange-store.c	26 Feb 2005 14:19:15 -0000	1.13
+++ camel/camel-exchange-store.c	8 Mar 2005 10:50:50 -0000
@@ -106,6 +106,7 @@ init (CamelExchangeStore *exch, CamelExc
 
 	exch->folders_lock = g_mutex_new ();
 	exch->folders = g_hash_table_new (g_str_hash, g_str_equal);
+	exch->stub = NULL;
 
 	store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
 }
@@ -117,6 +118,8 @@ finalize (CamelExchangeStore *exch)
 		camel_object_unref (CAMEL_OBJECT (exch->stub));
 		exch->stub = NULL;
 	}
+
+	g_free (exch->trash_name);
 	if (exch->folders_lock)
 		g_mutex_free (exch->folders_lock);
 }
@@ -273,24 +276,29 @@ exchange_connect (CamelService *service,
 {
 	CamelExchangeStore *store = CAMEL_EXCHANGE_STORE (service);
 	char *real_user, *socket_path;
+	gboolean new_stub = FALSE;
 	
 	if (!store->storage_path)
 		return FALSE;
 	
-	real_user = strpbrk (service->url->user, "\\/");
-	if (real_user)
-		real_user++;
-	else
-		real_user = service->url->user;
-	socket_path = g_strdup_printf ("/tmp/.exchange-%s/%s %s",
-				       g_get_user_name (),
-				       real_user, service->url->host);
-	e_filename_make_safe (strchr (socket_path + 5, '/') + 1);
+	if (!store->stub) {
+		real_user = strpbrk (service->url->user, "\\/");
+		if (real_user)
+			real_user++;
+		else
+			real_user = service->url->user;
+
+		socket_path = g_strdup_printf ("/tmp/.exchange-%s/%s %s",
+					       g_get_user_name (),
+					       real_user, service->url->host);
+		e_filename_make_safe (strchr (socket_path + 5, '/') + 1);
 	
-	store->stub = camel_stub_new (socket_path, _("Evolution Exchange backend process"), ex);
-	g_free (socket_path);
-	if (!store->stub)
-		return FALSE;
+		store->stub = camel_stub_new (socket_path, _("Evolution Exchange backend process"), ex);
+		g_free (socket_path);
+		if (!store->stub)
+			return FALSE;
+		new_stub = TRUE;
+	}
 
 	/* Initialize the stub connection */
 	if (!camel_stub_send (store->stub, NULL, CAMEL_STUB_CMD_CONNECT,
@@ -304,8 +312,10 @@ exchange_connect (CamelService *service,
 		return FALSE;
 	}
 
-	camel_object_hook_event (CAMEL_OBJECT (store->stub), "notification",
-				 stub_notification, store);
+	if (new_stub) {
+		camel_object_hook_event (CAMEL_OBJECT (store->stub), "notification",
+					 stub_notification, store);
+	}
 
 	return TRUE;
 }
@@ -313,16 +323,6 @@ exchange_connect (CamelService *service,
 static gboolean
 exchange_disconnect (CamelService *service, gboolean clean, CamelException *ex)
 {
-	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (service);
-
-	if (exch->stub) {
-		camel_object_unref (CAMEL_OBJECT (exch->stub));
-		exch->stub = NULL;
-	}
-
-	g_free (exch->trash_name);
-	exch->trash_name = NULL;
-
 	return TRUE;
 }
 


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