--- camel-private.h.110	2007-03-20 16:57:11.000000000 +0000
+++ camel-private.h	2007-03-20 16:55:21.000000000 +0000
@@ -41,6 +41,7 @@ extern "C" {
 struct _CamelFolderPrivate {
 	GStaticRecMutex lock;
 	GStaticMutex change_lock;
+	int filter_thread;
 	/* must require the 'change_lock' to access this */
 	int frozen;
 	struct _CamelFolderChangeInfo *changed_frozen; /* queues changed events */
--- camel-folder.h.110	2007-03-20 16:57:40.000000000 +0000
+++ camel-folder.h	2007-03-20 16:50:34.000000000 +0000
@@ -195,6 +195,7 @@ typedef struct {
 	void     (*freeze)    (CamelFolder *folder);
 	void     (*thaw)      (CamelFolder *folder);
 	gboolean (*is_frozen) (CamelFolder *folder);
+	int      (*get_filter_thread) (CamelFolder *folder);
 } CamelFolderClass;
 
 /* Standard Camel function */
@@ -314,6 +315,7 @@ void               camel_folder_rename  
 void               camel_folder_freeze                (CamelFolder *folder);
 void               camel_folder_thaw                  (CamelFolder *folder);
 gboolean           camel_folder_is_frozen             (CamelFolder *folder);
+int                camel_folder_get_filter_thread     (CamelFolder *folder);
 
 /* For use by subclasses (for free_{uids,summary,subfolder_names}) */
 void camel_folder_free_nop     (CamelFolder *folder, GPtrArray *array);
--- camel-folder.c.110	2007-03-20 16:57:40.000000000 +0000
+++ camel-folder.c	2007-03-20 16:50:34.000000000 +0000
@@ -108,6 +108,7 @@ static void            folder_rename    
 static void            freeze                (CamelFolder *folder);
 static void            thaw                  (CamelFolder *folder);
 static gboolean        is_frozen             (CamelFolder *folder);
+static int             get_filter_thread     (CamelFolder *folder);
 
 static gboolean        folder_changed        (CamelObject *object,
 					      gpointer event_data);
@@ -152,6 +153,7 @@ camel_folder_class_init (CamelFolderClas
 	camel_folder_class->freeze = freeze;
 	camel_folder_class->thaw = thaw;
 	camel_folder_class->is_frozen = is_frozen;
+	camel_folder_class->get_filter_thread = get_filter_thread;
 
 	/* virtual method overload */
 	camel_object_class->getv = folder_getv;
@@ -170,6 +172,7 @@ camel_folder_init (gpointer object, gpoi
 
 	folder->priv = g_malloc0(sizeof(*folder->priv));
 	folder->priv->frozen = 0;
+	folder->priv->filter_thread = 0;
 	folder->priv->changed_frozen = camel_folder_change_info_new();
 	g_static_rec_mutex_init(&folder->priv->lock);
 	g_static_mutex_init(&folder->priv->change_lock);
@@ -1622,6 +1625,27 @@ camel_folder_is_frozen (CamelFolder *fol
 	return CF_CLASS (folder)->is_frozen (folder);
 }
 
+static int
+get_filter_thread (CamelFolder *folder)
+{
+        return folder->priv->filter_thread;
+}
+
+
+/**
+ * camel_folder_get_filter_thread:
+ * @folder: a #CamelFolder object
+ *
+ * Returns the thread id of the filtering running on the folder
+ **/
+int
+camel_folder_get_filter_thread (CamelFolder *folder)
+{
+        g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
+
+	return CF_CLASS (folder)->get_filter_thread (folder);
+}
+
 struct _folder_filter_msg {
 	CamelSessionThreadMsg msg;
 
@@ -1738,6 +1762,7 @@ filter_free(CamelSession *session, Camel
 	if (m->notjunk)
 		camel_folder_free_deep(m->folder, m->notjunk);
 
+	m->folder->priv->filter_thread = 0;
 	camel_folder_thaw(m->folder);
 	camel_object_unref(m->folder);
 }
@@ -1828,7 +1853,7 @@ folder_changed (CamelObject *obj, gpoint
 		camel_folder_freeze(folder);
 		msg->driver = driver;
 		camel_exception_init(&msg->ex);
-		camel_session_thread_queue(session, &msg->msg, 0);
+		folder->priv->filter_thread = camel_session_thread_queue(session, &msg->msg, 0);
 	}
 
 	return TRUE;
