[evolution-patches] #41413, creating a subfolder of an unexpanded tree



(Tim reported this against Connector public folders, but the same thing
would happen if you tried to make a new IMAP folder before opening the
storage.)

Also adds some storage ref/unrefs for safety.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/shell/ChangeLog,v
retrieving revision 1.1240
diff -u -r1.1240 ChangeLog
--- ChangeLog	16 Apr 2003 14:49:22 -0000	1.1240
+++ ChangeLog	16 Apr 2003 15:14:55 -0000
@@ -1,3 +1,13 @@
+2003-04-16  Dan Winship  <danw ximian com>
+
+	* e-corba-storage.c (async_create_folder): If the new folder's
+	parent has unresolved children, async_open the parent first, then
+	create the new folder. [#41413]
+	(async_create_folder, async_remove_folder, async_xfer_folder,
+	async_open_folder, async_discover_shared_folder,
+	async_remove_shared_folder): Ref the storage.
+	(async_folder_cb, async_folder_discovery_cb): Unref it
+
 2003-04-16  Ettore Perazzoli  <ettore ximian com>
 
 	* apps_evolution_shell.schemas: Increase the default value for
Index: e-corba-storage.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-corba-storage.c,v
retrieving revision 1.54
diff -u -r1.54 e-corba-storage.c
--- e-corba-storage.c	25 Mar 2003 15:48:33 -0000	1.54
+++ e-corba-storage.c	16 Apr 2003 15:14:55 -0000
@@ -363,6 +363,40 @@
 
 	(* closure->callback) (closure->storage, result, closure->data);
 	bonobo_object_unref (BONOBO_OBJECT (listener));
+
+	g_object_unref (closure->storage);
+	g_free (closure);
+}
+
+
+struct async_create_open_closure {
+	EStorage *storage;
+	char *path, *type, *description;
+	EStorageResultCallback callback;
+	void *data;
+};
+
+static void
+async_create_open_cb (EStorage *storage, EStorageResult result,
+		      const char *path, void *data)
+{
+	struct async_create_open_closure *closure = data;
+
+	if (result != E_STORAGE_OK) {
+		(* closure->callback) (closure->storage, result,
+				       closure->data);
+	} else {
+		e_storage_async_create_folder (closure->storage,
+					       closure->path, closure->type,
+					       closure->description,
+					       closure->callback,
+					       closure->data);
+	}
+
+	g_object_unref (closure->storage);
+	g_free (closure->path);
+	g_free (closure->type);
+	g_free (closure->description);
 	g_free (closure);
 }
 
@@ -385,18 +419,39 @@
 
 	p = strrchr (path, '/');
 	if (p && p != path) {
-		char *parent_path;
 		EFolder *parent;
+		char *parent_path;
 
 		parent_path = g_strndup (path, p - path);
 		parent = e_storage_get_folder (storage, parent_path);
 		parent_uri = e_folder_get_physical_uri (parent);
+
+		if (e_folder_get_has_subfolders (parent)) {
+			struct async_create_open_closure *open_closure;
+
+			/* Force the parent folder to resolve its
+			 * children before creating the new folder.
+			 */
+			open_closure = g_new (struct async_create_open_closure, 1);
+			open_closure->storage = storage;
+			g_object_ref (storage);
+			open_closure->path = g_strdup (path);
+			open_closure->type = g_strdup (type);
+			open_closure->description = g_strdup (description);
+			open_closure->callback = callback;
+			open_closure->data = data;
+			e_storage_async_open_folder (storage, parent_path,
+						     async_create_open_cb,
+						     open_closure);
+			return;
+		}
 	} else
 		parent_uri = "";
 
 	closure = g_new (struct async_folder_closure, 1);
 	closure->callback = callback;
 	closure->storage = storage;
+	g_object_ref (storage);
 	closure->data = data;
 	listener = bonobo_listener_new (async_folder_cb, closure);
 	corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
@@ -410,6 +465,7 @@
 	if (ev._major != CORBA_NO_EXCEPTION) {
 		(* callback) (storage, E_STORAGE_GENERICERROR, data);
 		bonobo_object_unref (BONOBO_OBJECT (listener));
+		g_object_unref (storage);
 		g_free (closure);
 	}
 	CORBA_exception_free (&ev);
@@ -445,6 +501,7 @@
 	closure = g_new (struct async_folder_closure, 1);
 	closure->callback = callback;
 	closure->storage = storage;
+	g_object_ref (storage);
 	closure->data = data;
 	listener = bonobo_listener_new (async_folder_cb, closure);
 	corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
@@ -458,6 +515,7 @@
 	if (ev._major != CORBA_NO_EXCEPTION) {
 		(* callback) (storage, E_STORAGE_GENERICERROR, data);
 		bonobo_object_unref (BONOBO_OBJECT (listener));
+		g_object_unref (storage);
 		g_free (closure);
 	}
 	CORBA_exception_free (&ev);
@@ -489,6 +547,7 @@
 	closure = g_new (struct async_folder_closure, 1);
 	closure->callback = callback;
 	closure->storage = storage;
+	g_object_ref (storage);
 	closure->data = data;
 	listener = bonobo_listener_new (async_folder_cb, closure);
 	corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
@@ -501,6 +560,7 @@
 	if (ev._major != CORBA_NO_EXCEPTION) {
 		(* callback) (storage, E_STORAGE_GENERICERROR, data);
 		bonobo_object_unref (BONOBO_OBJECT (listener));
+		g_object_unref (storage);
 		g_free (closure);
 	}
 	CORBA_exception_free (&ev);
@@ -545,6 +605,7 @@
 			p = p->next;
 	}
 
+	g_object_unref (orig_closure->storage);
 	g_free (orig_closure->path);
 	g_free (orig_closure);
 }
@@ -563,13 +624,6 @@
 
 	corba_storage = E_CORBA_STORAGE (storage);
 	priv = corba_storage->priv;
-	if (priv == NULL) {
-		(* closure->callback) (storage, E_STORAGE_GENERICERROR,
-				       closure->path, closure->data);
-		g_free (closure->path);
-		g_free (closure);
-		return FALSE;
-	}
 
 	for (p = priv->pending_opens; p; p = p->next) {
 		old_closure = p->data;
@@ -590,6 +644,7 @@
 		(* closure->callback) (storage, E_STORAGE_GENERICERROR,
 				       closure->path, closure->data);
 		bonobo_object_unref (BONOBO_OBJECT (listener));
+		g_object_unref (closure->storage);
 		g_free (closure->path);
 		g_free (closure);
 	}
@@ -610,6 +665,7 @@
 	closure = g_new (struct async_open_closure, 1);
 	closure->callback = callback;
 	closure->storage = storage;
+	g_object_ref (storage);
 	closure->data = data;
 	closure->path = g_strdup (path);
 
@@ -664,6 +720,7 @@
 	(* callback) (closure->storage, result, path, closure->data);
 
 	bonobo_object_unref (BONOBO_OBJECT (listener));
+	g_object_unref (closure->storage);
 	g_free (closure);
 }
 
@@ -687,6 +744,7 @@
 	closure = g_new (struct async_folder_closure, 1);
 	closure->callback = (EStorageResultCallback)callback;
 	closure->storage = storage;
+	g_object_ref (storage);
 	closure->data = data;
 	listener = bonobo_listener_new (async_folder_discovery_cb, closure);
 	corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
@@ -698,6 +756,7 @@
 	if (ev._major != CORBA_NO_EXCEPTION) {
 		(* callback) (storage, E_STORAGE_GENERICERROR, NULL, data);
 		bonobo_object_unref (BONOBO_OBJECT (listener));
+		g_object_unref (storage);
 		g_free (closure);
 	}
 	CORBA_exception_free (&ev);
@@ -742,6 +801,7 @@
 	closure = g_new (struct async_folder_closure, 1);
 	closure->callback = callback;
 	closure->storage = storage;
+	g_object_ref (storage);
 	closure->data = data;
 	listener = bonobo_listener_new (async_folder_cb, closure);
 	corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
@@ -753,6 +813,7 @@
 	if (ev._major != CORBA_NO_EXCEPTION) {
 		(* callback) (storage, E_STORAGE_GENERICERROR, data);
 		bonobo_object_unref (BONOBO_OBJECT (listener));
+		g_object_unref (storage);
 		g_free (closure);
 	}
 	CORBA_exception_free (&ev);


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