Re: [evolution-patches] 63881 (dragging messages from vfolders)



How about this?

On Wed, 2004-08-25 at 11:43 +0800, Not Zed wrote:
> It would probably make sense for the unmatched folder to be
> initialised explictly somehow, rather than being intialised the first
> time a folder is initialised.  Although at an initial glance i'm not
> sure where this can be done since the evolution root vfolder store is
> setup outside of camel.
> 
> The unmatched folder should really be specific to the vee-store itself
> actually.

I think the attached patch should do what you suggest.

/camel:
camel-vee-folder.h, camel-vee-folder.c: new function
camel_vee_folder_unmatched_setup() to set up unmatched folder from
parent store (refactor existing code in camel_vee_folder_construct,
camel_vee_folder_new).

/mail:
mail-vfolder.h, mail-vfolder.c, mail-component.c: create vfolder store
and call camel_vee_folder_unmatched_setup() before loading accounts
(split vfolder_load_storage into vfolder_create_storage before loading
accounts, vfolder_load_storage after).

Because the vfolder store may not exist and if so
camel_vee_folder_unmatched_setup is not called (vfolder_create_storage
bails out early), camel_vee_folder_construct and camel_vee_folder_new
still check for folder_unmatched and if necessary call
camel_vee_folder_unmatched_setup with the passed-in vfolder store
(generally a vtrash store, I think).

Ed  
--- camel/camel-vee-folder.h	2004/08/27 02:42:30	1.1
+++ camel/camel-vee-folder.h	2004/08/27 02:42:35
@@ -77,6 +77,8 @@ void	     camel_vee_folder_set_expressio
 
 void	     camel_vee_folder_hash_folder	(CamelFolder *folder, char buffer[8]);
 
+void	     camel_vee_folder_unmatched_setup	(CamelStore *parent_store);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
--- camel/camel-vee-folder.c	2004/08/27 02:36:37	1.1
+++ camel/camel-vee-folder.c	2004/08/27 03:11:39
@@ -228,21 +228,37 @@ vee_folder_construct (CamelVeeFolder *vf
 	folder->summary->message_info_size = sizeof(CamelVeeMessageInfo);
 }
 
+/**
+ * camel_vee_folder_unmatched_setup:
+ * @parent_store: the 1 static vfolder store from mail-vfolder.c
+ * 
+ * Setup unmatched folder. Should happen before anything else; however if 
+ * the vfolder store does not exist this will need to be initialised from the
+ * vtrash stores so that things don't fall apart.
+ *
+ * Return value: none.
+ **/
 void
-camel_vee_folder_construct(CamelVeeFolder *vf, CamelStore *parent_store, const char *name, guint32 flags)
+camel_vee_folder_unmatched_setup(CamelStore *parent_store)
 {
 	UNMATCHED_LOCK();
 	
-	/* setup unmatched folder if we haven't yet */
 	if (folder_unmatched == NULL) {
 		unmatched_uids = g_hash_table_new (g_str_hash, g_str_equal);
 		folder_unmatched = (CamelVeeFolder *)camel_object_new (camel_vee_folder_get_type ());
-		d(printf("created foldeer unmatched %p\n", folder_unmatched));
+		d(printf("created folder_unmatched %p\n", folder_unmatched));
 		
 		vee_folder_construct (folder_unmatched, parent_store, CAMEL_UNMATCHED_NAME, CAMEL_STORE_FOLDER_PRIVATE);
 	}
 	
 	UNMATCHED_UNLOCK();
+}
+
+void
+camel_vee_folder_construct(CamelVeeFolder *vf, CamelStore *parent_store, const char *name, guint32 flags)
+{
+	if (folder_unmatched == NULL)
+		camel_vee_folder_unmatched_setup (parent_store);
 	
 	vee_folder_construct (vf, parent_store, name, flags);
 }
@@ -262,18 +278,9 @@ camel_vee_folder_new(CamelStore *parent_
 {
 	CamelVeeFolder *vf;
 	char *tmp;
-
-	UNMATCHED_LOCK();
-
-	/* setup unmatched folder if we haven't yet */
-	if (folder_unmatched == NULL) {
-		unmatched_uids = g_hash_table_new(g_str_hash, g_str_equal);
-		folder_unmatched = vf = (CamelVeeFolder *)camel_object_new(camel_vee_folder_get_type());
-		d(printf("created foldeer unmatched %p\n", folder_unmatched));
-		vee_folder_construct (vf, parent_store, CAMEL_UNMATCHED_NAME, CAMEL_STORE_FOLDER_PRIVATE);
-	}
-
-	UNMATCHED_UNLOCK();
+	
+	if (folder_unmatched == NULL)
+		camel_vee_folder_unmatched_setup (parent_store);
 
 	if (strcmp(name, CAMEL_UNMATCHED_NAME) == 0) {
 		vf = folder_unmatched;
--- mail/mail-vfolder.h	2004/08/27 02:43:15	1.1
+++ mail/mail-vfolder.h	2004/08/27 02:43:29
@@ -9,6 +9,7 @@
 #include "em-vfolder-rule.h"
 #include "filter/filter-part.h"
 
+void vfolder_create_storage(void);
 void vfolder_load_storage(void);
 void vfolder_revert(void);
 
--- mail/mail-vfolder.c	2004/08/27 02:43:45	1.1
+++ mail/mail-vfolder.c	2004/08/27 02:43:49
@@ -846,10 +846,9 @@ store_folder_renamed(CamelObject *o, voi
 }
 
 void
-vfolder_load_storage(void)
+vfolder_create_storage(void)
 {
-	char *user, *storeuri;
-	FilterRule *rule;
+	char *storeuri;
 
 	vfolder_hash = g_hash_table_new(g_str_hash, g_str_equal);
 
@@ -870,6 +869,17 @@ vfolder_load_storage(void)
 	
 	d(printf("got store '%s' = %p\n", storeuri, vfolder_store));
 	mail_component_load_store_by_uri (mail_component_peek (), storeuri, _("VFolders"));
+
+	camel_vee_folder_unmatched_setup (vfolder_store);
+
+	g_free(storeuri);
+}
+
+void
+vfolder_load_storage(void)
+{
+	char *user;
+	FilterRule *rule;
 	
 	/* load our rules */
 	user = g_strdup_printf ("%s/mail/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
@@ -891,8 +901,6 @@ vfolder_load_storage(void)
 		else
 			d(printf("invalid rule (%p) encountered: rule->name is NULL\n", rule));
 	}
-
-	g_free(storeuri);
 }
 
 void
--- mail/mail-component.c	2004/08/27 02:44:58	1.1
+++ mail/mail-component.c	2004/08/27 02:45:06
@@ -312,6 +312,7 @@ mc_startup(MailComponent *mc)
 		return;
 	started = 1;
 
+	vfolder_create_storage();
 	mc_setup_local_store(mc);
 	load_accounts(mc, mail_config_get_accounts());
 	vfolder_load_storage();


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