aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMichael Zucci <zucchi@src.gnome.org>2001-02-23 08:31:23 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-02-23 08:31:23 +0800
commit5c9c2f33b943c9996eac380d5534b80ce5402360 (patch)
tree37ef566693cd72537b0109d35df2974df9901033 /mail
parente761e875b2e79d5ec37c2e6d0ea09d8ed284389c (diff)
downloadgsoc2013-evolution-5c9c2f33b943c9996eac380d5534b80ce5402360.tar
gsoc2013-evolution-5c9c2f33b943c9996eac380d5534b80ce5402360.tar.gz
gsoc2013-evolution-5c9c2f33b943c9996eac380d5534b80ce5402360.tar.bz2
gsoc2013-evolution-5c9c2f33b943c9996eac380d5534b80ce5402360.tar.lz
gsoc2013-evolution-5c9c2f33b943c9996eac380d5534b80ce5402360.tar.xz
gsoc2013-evolution-5c9c2f33b943c9996eac380d5534b80ce5402360.tar.zst
gsoc2013-evolution-5c9c2f33b943c9996eac380d5534b80ce5402360.zip
vfolder/filter on mailing list. Doesn't acutally work right yet.
* mail-vfolder.c (vfolder_gui_add_from_mlist): Rule to add mlist vfolder. * mail-autofilter.c (filter_gui_add_for_mailing_list): Removed. (rule_from_mlist): Build a generic match rule from an mlist. (vfolder_rule_from_mlist): Setup the vfolder rule for an mlist. (filter_rule_from_mlist): Setup a filter rule fro an mlist. (filter_gui_add_from_mlist): GUI thingy to do the work. * folder-browser.c (on_right_click): Added vfolder on mailing list to filter menu. (on_right_click): Use header_raw_check_mailign_list instead of mlist magic to get the mailing list name. (filter_mlist): Changed to use new add_from_mlist() call. (vfolder_mlist): New function for vfolder from mlist. svn path=/trunk/; revision=8358
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/folder-browser.c50
-rw-r--r--mail/folder-browser.h1
-rw-r--r--mail/mail-autofilter.c84
-rw-r--r--mail/mail-autofilter.h8
-rw-r--r--mail/mail-vfolder.c11
-rw-r--r--mail/mail-vfolder.h1
7 files changed, 114 insertions, 57 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 4863495dac..2c5040faaa 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,21 @@
2001-02-23 Not Zed <NotZed@Ximian.com>
+ * mail-vfolder.c (vfolder_gui_add_from_mlist): Rule to add mlist
+ vfolder.
+
+ * mail-autofilter.c (filter_gui_add_for_mailing_list): Removed.
+ (rule_from_mlist): Build a generic match rule from an mlist.
+ (vfolder_rule_from_mlist): Setup the vfolder rule for an mlist.
+ (filter_rule_from_mlist): Setup a filter rule fro an mlist.
+ (filter_gui_add_from_mlist): GUI thingy to do the work.
+
+ * folder-browser.c (on_right_click): Added vfolder on mailing list
+ to filter menu.
+ (on_right_click): Use header_raw_check_mailign_list instead of
+ mlist magic to get the mailing list name.
+ (filter_mlist): Changed to use new add_from_mlist() call.
+ (vfolder_mlist): New function for vfolder from mlist.
+
* mail-send-recv.c (build_dialogue): Only allow downloading if the
source is enabled at this time.
(mail_autoreceive_setup): Check for enabled sources before setting
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index b8a7624d92..296a9ba30a 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -496,6 +496,20 @@ vfolder_recipient (GtkWidget *w, FolderBrowser *fb)
}
void
+vfolder_mlist (GtkWidget *w, FolderBrowser *fb)
+{
+ char *name;
+
+ g_return_if_fail (fb->mail_display->current_message != NULL);
+
+ name = header_raw_check_mailing_list(&((CamelMimePart *)fb->mail_display->current_message)->headers);
+ if (name) {
+ vfolder_gui_add_from_mlist(fb->mail_display->current_message, name, fb->uri);
+ g_free(name);
+ }
+}
+
+void
filter_subject (GtkWidget *w, FolderBrowser *fb)
{
filter_gui_add_from_message (fb->mail_display->current_message, AUTO_SUBJECT);
@@ -517,19 +531,14 @@ void
filter_mlist (GtkWidget *w, FolderBrowser *fb)
{
char *name;
- char *header_value;
- const char *header_name;
-
+
g_return_if_fail (fb->mail_display->current_message != NULL);
- name = mail_mlist_magic_detect_list (fb->mail_display->current_message, &header_name, &header_value);
- if (name == NULL)
- return;
-
- filter_gui_add_for_mailing_list (fb->mail_display->current_message, name, header_name, header_value);
-
- g_free (name);
- g_free (header_value);
+ name = header_raw_check_mailing_list(&((CamelMimePart *)fb->mail_display->current_message)->headers);
+ if (name) {
+ filter_gui_add_from_mlist(name);
+ g_free(name);
+ }
}
void
@@ -648,14 +657,17 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
CamelMessageInfo *info;
GPtrArray *uids;
int enable_mask = 0;
- int last_item, i;
+ int i;
char *mailing_list_name = NULL;
char *subject_match = NULL, *from_match = NULL;
+#define MLIST_VFOLDER (3)
+#define MLIST_FILTER (8)
EPopupMenu filter_menu[] = {
{ _("VFolder on Subject"), NULL, GTK_SIGNAL_FUNC (vfolder_subject), NULL, 2 },
{ _("VFolder on Sender"), NULL, GTK_SIGNAL_FUNC (vfolder_sender), NULL, 2 },
{ _("VFolder on Recipients"), NULL, GTK_SIGNAL_FUNC (vfolder_recipient), NULL, 2 },
+ { _("VFolder on Mailing List"), NULL, GTK_SIGNAL_FUNC (vfolder_mlist), NULL, 66 },
{ "", NULL, GTK_SIGNAL_FUNC (NULL), NULL, 0 },
{ _("Filter on Subject"), NULL, GTK_SIGNAL_FUNC (filter_subject), NULL, 2 },
{ _("Filter on Sender"), NULL, GTK_SIGNAL_FUNC (filter_sender), NULL, 2 },
@@ -692,8 +704,6 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
{ NULL, NULL, NULL, NULL, 0 }
};
- last_item = (sizeof (filter_menu) / sizeof (*filter_menu)) - 2;
-
if (fb->reconfigure) {
enable_mask = 0;
goto display_menu;
@@ -709,7 +719,7 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
const char *subject, *real, *addr;
const CamelInternetAddress *from;
- mailing_list_name = mail_mlist_magic_detect_list (fb->mail_display->current_message, NULL, NULL);
+ mailing_list_name = header_raw_check_mailing_list(&((CamelMimePart *)fb->mail_display->current_message)->headers);
if ((subject = camel_mime_message_get_subject(fb->mail_display->current_message))
&& (subject = strip_re(subject))
@@ -774,16 +784,18 @@ display_menu:
/* generate the "Filter on Mailing List menu item name */
if (mailing_list_name == NULL) {
enable_mask |= 64;
- filter_menu[last_item].name = g_strdup (_("Filter on Mailing List"));
+ filter_menu[MLIST_FILTER].name = g_strdup (_("Filter on Mailing List"));
+ filter_menu[MLIST_VFOLDER].name = g_strdup (_("VFolder on Mailing List"));
} else {
- filter_menu[last_item].name = g_strdup_printf (_("Filter on Mailing List (%s)"),
- mailing_list_name);
+ filter_menu[MLIST_FILTER].name = g_strdup_printf (_("Filter on Mailing List (%s)"), mailing_list_name);
+ filter_menu[MLIST_VFOLDER].name = g_strdup_printf (_("VFolder on Mailing List (%s)"), mailing_list_name);
g_free(mailing_list_name);
}
e_popup_menu_run (menu, event, enable_mask, 0, fb);
- g_free(filter_menu[last_item].name);
+ g_free(filter_menu[MLIST_FILTER].name);
+ g_free(filter_menu[MLIST_VFOLDER].name);
return TRUE;
}
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index d6df42f4e4..04ddaae110 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -85,6 +85,7 @@ void folder_browser_clear_search (FolderBrowser *fb);
void vfolder_subject (GtkWidget *w, FolderBrowser *fb);
void vfolder_sender (GtkWidget *w, FolderBrowser *fb);
void vfolder_recipient (GtkWidget *w, FolderBrowser *fb);
+void vfolder_mlist (GtkWidget *w, FolderBrowser *fb);
void filter_subject (GtkWidget *w, FolderBrowser *fb);
void filter_sender (GtkWidget *w, FolderBrowser *fb);
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 8dea249bb2..ca38085ebf 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -265,6 +265,52 @@ filter_rule_from_message(FilterContext *context, CamelMimeMessage *msg, int flag
return (FilterRule *)rule;
}
+static void
+rule_from_mlist(FilterRule *rule, RuleContext *context, const char *mlist)
+{
+ FilterPart *part;
+ FilterElement *element;
+ char *rule_name;
+
+ part = rule_context_create_part(context, "mlist");
+ filter_rule_add_part(rule, part);
+
+ element = filter_part_find_element(part, "mlist-type");
+ filter_option_set_current((FilterOption *)element, "is");
+
+ element = filter_part_find_element (part, "mlist");
+ filter_input_set_value((FilterInput *)element, mlist);
+
+ rule_name = g_strdup_printf(_("%s mailing list"), mlist);
+ filter_rule_set_name((FilterRule *) rule, rule_name);
+ g_free (rule_name);
+}
+
+FilterRule *
+vfolder_rule_from_mlist(VfolderContext *context, const char *mlist, const char *source)
+{
+ VfolderRule *rule;
+
+ rule = vfolder_rule_new ();
+ vfolder_rule_add_source (rule, source);
+ rule_from_mlist((FilterRule *)rule, (RuleContext *)context, mlist);
+
+ return (FilterRule *)rule;
+}
+
+FilterRule *
+filter_rule_from_mlist(FilterContext *context, const char *mlist)
+{
+ FilterFilter *rule;
+
+ rule = filter_filter_new ();
+ rule_from_mlist((FilterRule *)rule, (RuleContext *)context, mlist);
+
+ /* should we define the default action? */
+
+ return (FilterRule *)rule;
+}
+
void
filter_gui_add_from_message (CamelMimeMessage *msg, int flags)
{
@@ -290,50 +336,22 @@ filter_gui_add_from_message (CamelMimeMessage *msg, int flags)
}
void
-filter_gui_add_for_mailing_list (CamelMimeMessage *msg,
- const char *list_name,
- const char *header_name,
- const char *header_value)
+filter_gui_add_from_mlist (const char *mlist)
{
FilterContext *fc;
- FilterRule *rule;
- FilterPart *part;
- FilterElement *element;
char *userrules, *systemrules;
- char *rule_name;
+ FilterRule *rule;
extern char *evolution_dir;
-
- g_return_if_fail (msg != NULL);
- g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg));
- g_return_if_fail (list_name != NULL);
- g_return_if_fail (header_name != NULL);
- g_return_if_fail (header_value != NULL);
-
+
fc = filter_context_new ();
userrules = g_strdup_printf ("%s/filters.xml", evolution_dir);
systemrules = g_strdup_printf ("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
rule_context_load ((RuleContext *)fc, systemrules, userrules);
+ rule = filter_rule_from_mlist(fc, mlist);
- rule = (FilterRule *) filter_filter_new ();
-
- part = rule_context_create_part ((RuleContext *)fc, "header");
- filter_rule_add_part ((FilterRule *)rule, part);
-
- element = filter_part_find_element (part, "header-field");
- filter_input_set_value ((FilterInput *)element, header_name);
-
- element = filter_part_find_element (part, "header-type");
- filter_option_set_current ((FilterOption *)element, "is");
-
- element = filter_part_find_element (part, "word");
- filter_input_set_value ((FilterInput *)element, header_value);
-
- rule_name = g_strdup_printf (_("%s mailing list"), list_name);
- filter_rule_set_name ((FilterRule *) rule, rule_name);
- g_free (rule_name);
+ filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
rule_context_add_rule_gui ((RuleContext *)fc, rule, _("Add Filter Rule"), userrules);
-
g_free (userrules);
g_free (systemrules);
gtk_object_unref (GTK_OBJECT (fc));
diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h
index 5787b74c7c..ab36b68d33 100644
--- a/mail/mail-autofilter.h
+++ b/mail/mail-autofilter.h
@@ -39,15 +39,13 @@ enum {
FilterRule *vfolder_rule_from_message(VfolderContext *context, CamelMimeMessage *msg, int flags, const char *source);
FilterRule *filter_rule_from_message(FilterContext *context, CamelMimeMessage *msg, int flags);
+FilterRule *vfolder_rule_from_mlist(VfolderContext *context, const char *mlist, const char *source);
+FilterRule *filter_rule_from_mlist(FilterContext *context, const char *mlist);
/* easiest place to put this */
void filter_gui_add_from_message (CamelMimeMessage *msg,
int flags);
-
-void filter_gui_add_for_mailing_list (CamelMimeMessage *msg,
- const char *list_name,
- const char *header_name,
- const char *header_value);
+void filter_gui_add_from_mlist (const char *mlist);
#endif
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 6426979f36..cb5be64207 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -344,6 +344,17 @@ vfolder_gui_add_from_message(CamelMimeMessage *msg, int flags, const char *sourc
vfolder_gui_add_rule(rule);
}
+void
+vfolder_gui_add_from_mlist(CamelMimeMessage *msg, const char *mlist, const char *source)
+{
+ VfolderRule *rule;
+
+ g_return_if_fail (msg != NULL);
+
+ rule = (VfolderRule*)vfolder_rule_from_mlist(context, mlist, source);
+ vfolder_gui_add_rule(rule);
+}
+
EvolutionStorage *
mail_vfolder_get_vfolder_storage (void)
{
diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h
index dc2d995d43..c76e532b0c 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -20,6 +20,7 @@ void vfolder_edit(void);
FilterPart *vfolder_create_part(const char *name);
void vfolder_gui_add_rule(VfolderRule *rule);
void vfolder_gui_add_from_message(CamelMimeMessage *msg, int flags, const char *source);
+void vfolder_gui_add_from_mlist(CamelMimeMessage *msg, const char *mlist, const char *source);
EvolutionStorage *mail_vfolder_get_vfolder_storage (void);