Hi guys,

This is a patch I need to apply to shell and mail to allow the mailer to
be ready to handle the summary's requests for folder info.

Basically, the shell now sets the evolution directory in bonoboconf, and
on startup the mailer reads that directory instead of waiting for the
owner_set callback to set it. This allows mail_session_init to be called
at startup rather than at owner_set.

May I commit?

iain
-- 
"No offence to them, but forty years from now,
 who's going to remember the Chemical Brothers?" - Steve Vai
Index: shell//e-corba-storage-registry.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-corba-storage-registry.c,v
retrieving revision 1.17
diff -U2 -r1.17 e-corba-storage-registry.c
--- shell//e-corba-storage-registry.c	9 Apr 2002 14:59:26 -0000	1.17
+++ shell//e-corba-storage-registry.c	22 Apr 2002 14:11:12 -0000
@@ -108,5 +108,6 @@
 	EStorage *storage;
 	GNOME_Evolution_StorageListener listener_interface;
-
+	GSList *iter;
+	
 	bonobo_object = bonobo_object_from_servant (servant);
 	storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
@@ -125,4 +126,14 @@
 	gtk_object_unref (GTK_OBJECT (storage));
 
+
+       /* FIXME: if we remove a listener while looping through the list we can
+        * crash. Yay CORBA reentrancy. */
+	g_print ("Added name: %s\n", name);
+	for (iter = priv->listeners; iter; iter = iter->next) {
+		listener_notify (iter->data,
+				 GNOME_Evolution_StorageRegistry_STORAGE_CREATED,
+				 name);
+	}
+	
 	listener_interface = CORBA_Object_duplicate (e_corba_storage_get_StorageListener
 						     (E_CORBA_STORAGE (storage)), ev);
Index: shell//e-shell.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell.c,v
retrieving revision 1.158
diff -U2 -r1.158 e-shell.c
--- shell//e-shell.c	18 Apr 2002 18:57:45 -0000	1.158
+++ shell//e-shell.c	22 Apr 2002 14:11:13 -0000
@@ -1205,4 +1205,5 @@
 	gchar *shortcut_path;
 	gboolean start_online;
+	char *evo_path;
 
 	g_return_val_if_fail (shell != NULL, E_SHELL_CONSTRUCT_RESULT_INVALIDARG);
@@ -1255,4 +1256,12 @@
 	CORBA_exception_free (&ev);
 
+	/* Set the evolution directory */
+	evo_path = gnome_util_prepend_user_home ("evolution");
+	bonobo_config_set_string (priv->db, "shell/evolution_path", evo_path, NULL);
+	g_free (evo_path);
+	CORBA_exception_init (&ev);
+	Bonobo_ConfigDatabase_sync (priv->db, &ev);
+	CORBA_exception_free (&ev);
+	
 	/* Now we can register into OAF.  Notice that we shouldn't be
 	   registering into OAF until we are sure we can complete.  */
Index: mail/component-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/component-factory.c,v
retrieving revision 1.248
diff -U2 -r1.248 component-factory.c
--- mail/component-factory.c	9 Apr 2002 15:00:57 -0000	1.248
+++ mail/component-factory.c	22 Apr 2002 14:11:30 -0000
@@ -26,4 +26,5 @@
 
 #include <bonobo/bonobo-generic-factory.h>
+#include <bonobo/bonobo-exception.h>
 #include <gal/widgets/e-gui-utils.h>
 
@@ -65,5 +66,5 @@
 char *default_outbox_folder_uri;
 CamelFolder *outbox_folder = NULL;
-char *evolution_dir;
+char *evolution_dir = NULL;
 
 EvolutionShellClient *global_shell_client = NULL;
@@ -710,7 +711,8 @@
 	gtk_signal_connect (GTK_OBJECT (shell_client), "destroy",
 			    shell_client_destroy, NULL);
-	
-	evolution_dir = g_strdup (evolution_homedir);
-	mail_session_init ();
+
+	if (evolution_dir == NULL) {
+		evolution_dir = g_strdup (evolution_homedir);
+	}
 
 	async_event = mail_async_event_new();
@@ -936,8 +938,28 @@
 create_component (void)
 {
+	Bonobo_ConfigDatabase db;
+	CORBA_Environment ev;
 	EvolutionShellComponentDndDestinationFolder *destination_interface;
 	MailOfflineHandler *offline_handler;
 	GdkPixbuf *new_mail_icon;
 	int i;
+
+	/* Get evolution path out of the config */
+	CORBA_exception_init (&ev);
+	db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+	if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+		char *err;
+		g_error ("Very serious error, cannot activate config database '%s'",
+			 (err = bonobo_exception_get_text (&ev)));
+		g_free (&ev);
+		CORBA_exception_free (&ev);
+	}
+
+	evolution_dir = bonobo_config_get_string (db, "shell/evolution_path", NULL);
+	g_print ("Evolution dir: %s\n", evolution_dir);
+	bonobo_object_release_unref (db, NULL);
+
+	/* Now we know the directory, init the session code */
+	mail_session_init ();
 	
 	shell_component = evolution_shell_component_new (folder_types,
Index: mail/folder-info.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/folder-info.c,v
retrieving revision 1.8
diff -U2 -r1.8 folder-info.c
--- mail/folder-info.c	30 Oct 2001 11:10:48 -0000	1.8
+++ mail/folder-info.c	22 Apr 2002 14:11:30 -0000
@@ -71,45 +71,4 @@
 	CamelFolder *folder;
 	CamelException *ex;
-#if 0
-	char *uri_dup;
-	char *foldername, *start, *end;
-	char *storage, *protocol, *uri;
-	/* Fixme: Do other stuff. Different stuff to the stuff below */
-	uri_dup = g_strdup (m->foldername);
-	start = uri_dup + 11;
-	g_warning ("Start: %s", start);
-
-	end = strrchr (start, '/');
-	if (end == NULL) {
-		g_warning ("Bugger");
-		return;
-	}
-
-	storage = g_strndup (start, end - start);
-	start = end + 1;
-	foldername = g_strdup (start);
-
-	g_free (uri_dup);
-
-	/* Work out the protocol.
-	   The storage is going to start as local, or vfolder, or an imap
-	   server. */
-	g_warning ("Storage: %s", storage);
-	if (strncmp (storage, "local", 5) == 0) {
-		char *evolution_dir;
-		char *proto;
-
-		evolution_dir = gnome_util_prepend_user_home ("evolution/local");
-		proto = g_strconcat ("file://", evolution_dir, NULL);
-		uri = e_path_to_physical (proto, foldername);
-		g_free (evolution_dir);
-		g_free (proto);
-
-	} else if (strncmp (storage, "vfolder", 7) == 0) {
-		uri = g_strconcat ("vfolder://", foldername, NULL);
-	} else {
-		uri = g_strconcat ("imap://", storage, foldername, NULL);
-	}
-#endif
 
 	ex = camel_exception_new ();
@@ -118,7 +77,11 @@
 		g_warning ("Camel exception: %s", camel_exception_get_description (ex));
 	}
-
 	camel_exception_free (ex);
+	
+	if (folder == NULL) {
+		g_warning ("Camel returned NULL for %s", m->foldername);
+	}
 
+	g_print ("Getting mail\n");
 	m->read = camel_folder_get_message_count (folder);
 	m->unread = camel_folder_get_unread_message_count (folder);
@@ -133,5 +96,5 @@
 	GNOME_Evolution_FolderInfo_MessageCount count;
 
-	/*g_print ("You've got mail: %d, %d\n", m->read, m->unread);*/
+	g_print ("You've got mail: %d, %d\n", m->read, m->unread);
 
 	count.path = m->foldername;
@@ -196,4 +159,5 @@
 					 CORBA_Environment *ev)
 {
+	g_print ("Get mail info: %s\n", foldername);
 	mail_get_info (foldername, listener);
 }

Reply via email to