[evolution/wip/gsettings] Build vfolder rules with CamelFolders instead of folder URIs.



commit b73fe7218fedc76c1f5860c02315eac957669167
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue May 3 14:07:50 2011 -0400

    Build vfolder rules with CamelFolders instead of folder URIs.

 mail/e-mail-reader-utils.c |    8 +-------
 mail/e-mail-reader.c       |   12 ++++++------
 mail/mail-autofilter.c     |   19 +++++++++++++++----
 mail/mail-autofilter.h     |    4 ++--
 mail/mail-vfolder.c        |   14 ++++++++------
 mail/mail-vfolder.h        |    6 +++---
 6 files changed, 35 insertions(+), 28 deletions(-)
---
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 5953f64..cb3eef5 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -578,17 +578,15 @@ mail_reader_create_vfolder_cb (CamelFolder *folder,
 {
 	struct {
 		EMailSession *session;
-		gchar *uri;
 		gint type;
 	} *vfolder_data = user_data;
 
 	if (message != NULL)
 		vfolder_gui_add_from_message (
 			vfolder_data->session, message,
-			vfolder_data->type, vfolder_data->uri);
+			vfolder_data->type, folder);
 
 	g_object_unref (vfolder_data->session);
-	g_free (vfolder_data->uri);
 	g_free (vfolder_data);
 }
 
@@ -599,12 +597,10 @@ e_mail_reader_create_vfolder_from_selected (EMailReader *reader,
 	EMailBackend *backend;
 	EMailSession *session;
 	CamelFolder *folder;
-	const gchar *folder_uri;
 	GPtrArray *uids;
 
 	struct {
 		EMailSession *session;
-		gchar *uri;
 		gint type;
 	} *vfolder_data;
 
@@ -614,13 +610,11 @@ e_mail_reader_create_vfolder_from_selected (EMailReader *reader,
 	session = e_mail_backend_get_session (backend);
 
 	folder = e_mail_reader_get_folder (reader);
-	folder_uri = e_mail_reader_get_folder_uri (reader);
 	uids = e_mail_reader_get_selected_uids (reader);
 
 	if (uids->len == 1) {
 		vfolder_data = g_malloc (sizeof (*vfolder_data));
 		vfolder_data->session = g_object_ref (session);
-		vfolder_data->uri = g_strdup (folder_uri);
 		vfolder_data->type = vfolder_type;
 
 		mail_get_message (
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index ad596bb..21d5341 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -1798,13 +1798,13 @@ action_search_folder_recipient_cb (GtkAction *action,
 	EMailSession *session;
 	EMFormatHTML *formatter;
 	EWebView *web_view;
+	CamelFolder *folder;
 	CamelURL *curl;
-	const gchar *folder_uri;
 	const gchar *uri;
 
 	/* This action is defined in EMailDisplay. */
 
-	folder_uri = e_mail_reader_get_folder_uri (reader);
+	folder = e_mail_reader_get_folder (reader);
 	formatter = e_mail_reader_get_formatter (reader);
 
 	web_view = em_format_html_get_web_view (formatter);
@@ -1824,7 +1824,7 @@ action_search_folder_recipient_cb (GtkAction *action,
 		inet_addr = camel_internet_address_new ();
 		camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
 		vfolder_gui_add_from_address (
-			session, inet_addr, AUTO_TO, folder_uri);
+			session, inet_addr, AUTO_TO, folder);
 		g_object_unref (inet_addr);
 	}
 
@@ -1839,13 +1839,13 @@ action_search_folder_sender_cb (GtkAction *action,
 	EMailSession *session;
 	EMFormatHTML *formatter;
 	EWebView *web_view;
+	CamelFolder *folder;
 	CamelURL *curl;
-	const gchar *folder_uri;
 	const gchar *uri;
 
 	/* This action is defined in EMailDisplay. */
 
-	folder_uri = e_mail_reader_get_folder_uri (reader);
+	folder = e_mail_reader_get_folder (reader);
 	formatter = e_mail_reader_get_formatter (reader);
 
 	web_view = em_format_html_get_web_view (formatter);
@@ -1865,7 +1865,7 @@ action_search_folder_sender_cb (GtkAction *action,
 		inet_addr = camel_internet_address_new ();
 		camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
 		vfolder_gui_add_from_address (
-			session, inet_addr, AUTO_FROM, folder_uri);
+			session, inet_addr, AUTO_FROM, folder);
 		g_object_unref (inet_addr);
 	}
 
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 2055480..7c6a5c1 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -30,6 +30,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 
+#include "e-mail-folder-utils.h"
 #include "e-mail-session.h"
 #include "mail-vfolder.h"
 #include "mail-autofilter.h"
@@ -312,17 +313,22 @@ EFilterRule *
 em_vfolder_rule_from_message (EMVFolderContext *context,
                               CamelMimeMessage *msg,
                               gint flags,
-                              const gchar *source)
+                              CamelFolder *folder)
 {
 	EFilterRule *rule;
 	EMailSession *session;
-	gchar *euri = em_uri_from_camel (source);
+	gchar *uri, *euri;
+
+	uri = e_mail_folder_uri_from_folder (folder);
+	euri = em_uri_from_camel (uri);
 
 	session = em_vfolder_context_get_session (context);
 
 	rule = em_vfolder_rule_new (session);
 	em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), euri);
 	rule_from_message (rule, E_RULE_CONTEXT (context), msg, flags);
+
+	g_free (uri);
 	g_free (euri);
 
 	return rule;
@@ -332,17 +338,22 @@ EFilterRule *
 em_vfolder_rule_from_address (EMVFolderContext *context,
                               CamelInternetAddress *addr,
                               gint flags,
-                              const gchar *source)
+                              CamelFolder *folder)
 {
 	EFilterRule *rule;
 	EMailSession *session;
-	gchar *euri = em_uri_from_camel (source);
+	gchar *uri, *euri;
+
+	uri = e_mail_folder_uri_from_folder (folder);
+	euri = em_uri_from_camel (uri);
 
 	session = em_vfolder_context_get_session (context);
 
 	rule = em_vfolder_rule_new (session);
 	em_vfolder_rule_add_source (EM_VFOLDER_RULE (rule), euri);
 	rule_from_address (rule, E_RULE_CONTEXT (context), addr, flags);
+
+	g_free (uri);
 	g_free (euri);
 
 	return rule;
diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h
index 7967023..7c5c23a 100644
--- a/mail/mail-autofilter.h
+++ b/mail/mail-autofilter.h
@@ -41,14 +41,14 @@ enum {
 EFilterRule *	em_vfolder_rule_from_message	(EMVFolderContext *context,
 						 CamelMimeMessage *msg,
 						 gint flags,
-						 const gchar *source);
+						 CamelFolder *folder);
 EFilterRule *	filter_rule_from_message	(EMFilterContext *context,
 						 CamelMimeMessage *msg,
 						 gint flags);
 EFilterRule *	em_vfolder_rule_from_address	(EMVFolderContext *context,
 						 CamelInternetAddress *addr,
 						 gint flags,
-						 const gchar *source);
+						 CamelFolder *folder);
 
 /* easiest place to put this */
 void		filter_gui_add_from_message	(EMailSession *session,
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 0f98528..6958e82 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -1448,15 +1448,16 @@ vfolder_gui_add_rule (EMVFolderRule *rule)
 
 void
 vfolder_gui_add_from_message (EMailSession *session,
-                              CamelMimeMessage *msg,
+                              CamelMimeMessage *message,
                               gint flags,
-                              const gchar *source)
+                              CamelFolder *folder)
 {
 	EMVFolderRule *rule;
 
-	g_return_if_fail (msg != NULL);
+	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
-	rule = (EMVFolderRule*)em_vfolder_rule_from_message (context, msg, flags, source);
+	rule = (EMVFolderRule*) em_vfolder_rule_from_message (
+		context, message, flags, folder);
 	vfolder_gui_add_rule (rule);
 }
 
@@ -1464,13 +1465,14 @@ void
 vfolder_gui_add_from_address (EMailSession *session,
                               CamelInternetAddress *addr,
                               gint flags,
-                              const gchar *source)
+                              CamelFolder *folder)
 {
 	EMVFolderRule *rule;
 
 	g_return_if_fail (addr != NULL);
 
-	rule = (EMVFolderRule*)em_vfolder_rule_from_address (context, addr, flags, source);
+	rule = (EMVFolderRule*)em_vfolder_rule_from_address (
+		context, addr, flags, folder);
 	vfolder_gui_add_rule (rule);
 }
 
diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h
index 91aae4d..d1cdb37 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -40,13 +40,13 @@ EFilterRule *	vfolder_clone_rule		(EMailSession *session,
 						 EFilterRule *in);
 void		vfolder_gui_add_rule		(EMVFolderRule *rule);
 void		vfolder_gui_add_from_message	(EMailSession *session,
-						 CamelMimeMessage *msg,
+						 CamelMimeMessage *message,
 						 gint flags,
-						 const gchar *source);
+						 CamelFolder *folder);
 void		vfolder_gui_add_from_address	(EMailSession *session,
 						 CamelInternetAddress *addr,
 						 gint flags,
-						 const gchar *source);
+						 CamelFolder *folder);
 
 GList *		mail_vfolder_get_sources_local	(void);
 GList *		mail_vfolder_get_sources_remote	(void);



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