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 04:56:34
@@ -1,3 +1,15 @@
+2001-11-09  Not Zed  <NotZed@Ximian.com>
+
+	* camel-store.c	(init_trash): Made init_trash a noop.
+	(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.
+	(store_connect): Setup vtrash folder at connect time.
+	(store_disconnect): And remove it here, so we dont have a looping
+	reference stopping the store ever being disconnected.
+
 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 04:56:37
@@ -73,6 +73,9 @@
 		       CamelProvider *provider, CamelURL *url,
 		       CamelException *ex);
 
+static gboolean store_connect(CamelService *service, CamelException *ex);
+static gboolean store_disconnect(CamelService *service, gboolean clean, CamelException *ex);
+
 static void
 camel_store_class_init (CamelStoreClass *camel_store_class)
 {
@@ -100,6 +103,8 @@
 	
 	/* virtual method overload */
 	camel_service_class->construct = construct;
+	camel_service_class->connect = store_connect;
+	camel_service_class->disconnect = store_disconnect;
 
 	camel_object_class_declare_event(camel_object_class, "folder_created", NULL);
 	camel_object_class_declare_event(camel_object_class, "folder_deleted", NULL);
@@ -210,6 +215,33 @@
 		store->flags |= CAMEL_STORE_FILTER_INBOX;
 }
 
+static gboolean
+store_connect(CamelService *service, CamelException *ex)
+{
+	CamelStore *store = CAMEL_STORE(service);
+	gboolean ok;
+
+	ok = parent_class->connect(service, ex);
+
+	if (ok && store->vtrash == NULL && (store->flags & CAMEL_STORE_VTRASH))
+		store->vtrash = camel_vtrash_folder_new (store, CAMEL_VTRASH_NAME);
+
+	return ok;
+}
+
+static gboolean
+store_disconnect(CamelService *service, gboolean clean, CamelException *ex)
+{
+	CamelStore *store = CAMEL_STORE(service);
+
+	if (store->vtrash) {
+		camel_object_unref((CamelObject *)store->vtrash);
+		store->vtrash = NULL;
+	}
+
+	return parent_class->disconnect(service, clean, ex);
+}
+
 static CamelFolder *
 get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex)
 {
@@ -519,65 +551,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 +580,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 04:56:37
@@ -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);
 	
