Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1307
diff -u -r1.1307 ChangeLog
--- ChangeLog	2001/11/09 00:41:09	1.1307
+++ ChangeLog	2001/11/09 03:43:56
@@ -1,3 +1,17 @@
+2001-11-09  Not Zed  <NotZed@Ximian.com>
+
+	* camel-store.c (camel_store_get_folder): Init trash always on
+	first folder get.
+	(construct): Setup vtrash at construct time if the class supports
+	it.
+	(init_trash): Made init_trash a noop.
+	(camel_store_finalize): Unref vtrash at exit.
+	(get_trash): If we have a vtrash just return it, else NULL.
+	(trash_finalize): Remove.
+	(trash_add_folder): Remove.
+	(camel_store_get_trash): Dont check for support of VTRASH, the
+	store might want to return its own trash which isn't a vtrash.
+
 2001-11-06  Jeffrey Stedfast  <fejj@ximian.com>
 
 	* providers/imap/camel-imap-command.c
Index: camel-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-store.c,v
retrieving revision 1.99
diff -u -r1.99 camel-store.c
--- camel-store.c	2001/10/30 05:20:50	1.99
+++ camel-store.c	2001/11/09 03:43:58
@@ -137,6 +137,9 @@
 {
 	CamelStore *store = CAMEL_STORE (object);
 
+	if (store->vtrash)
+		camel_object_unref((CamelObject *)store->vtrash);
+
 	if (store->folders) {
 		if (g_hash_table_size (store->folders) != 0) {
 			d(g_warning ("Folder cache for store %p contains "
@@ -208,6 +211,9 @@
 
 	if (camel_url_get_param(url, "filter"))
 		store->flags |= CAMEL_STORE_FILTER_INBOX;
+
+	if ((store->flags & CAMEL_STORE_VTRASH))
+		store->vtrash = camel_vtrash_folder_new (store, CAMEL_VTRASH_NAME);
 }
 
 static CamelFolder *
@@ -519,65 +525,20 @@
 	return folder;
 }
 
-
-static void
-trash_add_folder (gpointer key, gpointer value, gpointer data)
-{
-	CamelFolder *folder = CAMEL_FOLDER (value);
-	CamelStore *store = CAMEL_STORE (data);
-	
-	camel_vee_folder_add_folder (CAMEL_VEE_FOLDER (store->vtrash), folder);
-}
-
-static void
-trash_finalize (CamelObject *trash, gpointer event_data, gpointer user_data)
-{
-	CamelStore *store = CAMEL_STORE (user_data);
-	
-	store->vtrash = NULL;
-}
-
 static void
 init_trash (CamelStore *store)
 {
-	if ((store->flags & CAMEL_STORE_VTRASH) == 0)
-		return;
-
-	store->vtrash = camel_vtrash_folder_new (store, CAMEL_VTRASH_NAME);
-	
-	if (store->vtrash) {
-		/* attach to the finalise event of the vtrash */
-		camel_object_hook_event (CAMEL_OBJECT (store->vtrash), "finalize",
-					 trash_finalize, store);
-		
-		/* add all the pre-opened folders to the vtrash */
-		if (store->folders) {
-			CAMEL_STORE_LOCK(store, cache_lock);
-			g_hash_table_foreach (store->folders, trash_add_folder, store);
-			CAMEL_STORE_UNLOCK(store, cache_lock);
-		}
-	}
+	g_warning("camel_store::init_trash() called, init_trash no longer used");
+	return;
 }
 
-
 static CamelFolder *
 get_trash (CamelStore *store, CamelException *ex)
 {
-	if (store->vtrash) {
+	if (store->vtrash)
 		camel_object_ref (CAMEL_OBJECT (store->vtrash));
-		return store->vtrash;
-	} else {
-		CS_CLASS (store)->init_trash (store);
-		if (store->vtrash) {
-			/* We don't ref here because we don't want the
-                           store to own a ref on the trash folder */
-			/*camel_object_ref (CAMEL_OBJECT (store->vtrash));*/
-			return store->vtrash;
-		} else {
-			w(g_warning ("This store does not support vTrash."));
-			return NULL;
-		}
-	}
+
+	return store->vtrash;
 }
 
 /** 
@@ -593,16 +554,12 @@
 {
 	CamelFolder *folder;
 
-	if ((store->flags & CAMEL_STORE_VTRASH) == 0)
-		return NULL;
-	
 	CAMEL_STORE_LOCK(store, folder_lock);
 	folder = CS_CLASS (store)->get_trash (store, ex);
 	CAMEL_STORE_UNLOCK(store, folder_lock);
 	
 	return folder;
 }
-
 
 static void
 sync_folder (gpointer key, gpointer folder, gpointer ex)
Index: camel-store.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-store.h,v
retrieving revision 1.53
diff -u -r1.53 camel-store.h
--- camel-store.h	2001/10/28 05:10:54	1.53
+++ camel-store.h	2001/11/09 03:43:59
@@ -108,7 +108,7 @@
 	CamelFolder *   (*get_inbox)                (CamelStore *store,
 						     CamelException *ex);
 	
-	void            (*init_trash)               (CamelStore *store);
+	void            (*init_trash)               (CamelStore *store); /* NOTE: THIS METHOD NO LONGER USED */
 	CamelFolder *   (*get_trash)                (CamelStore *store,
 						     CamelException *ex);
 	
