diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-11-01 14:01:55 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-11-01 14:01:55 +0800 |
commit | 2b8a138befe06bfeee85f8b1ccb153013b4f54f6 (patch) | |
tree | 2e332a4e6f4d0bae71fd627fa05a9980cfc847d9 /mail | |
parent | 2dfb2624476858863b56106b394cdc8c3b08dfe3 (diff) | |
download | gsoc2013-evolution-2b8a138befe06bfeee85f8b1ccb153013b4f54f6.tar.gz gsoc2013-evolution-2b8a138befe06bfeee85f8b1ccb153013b4f54f6.tar.zst gsoc2013-evolution-2b8a138befe06bfeee85f8b1ccb153013b4f54f6.zip |
setup filter-on-thread and vfolder-on-thread.
2003-11-01 Jeffrey Stedfast <fejj@ximian.com>
* em-folder-view.c: setup filter-on-thread and vfolder-on-thread.
* mail-autofilter.c (rule_from_message): handle AUTO_THREAD
(rule_match_thread): new function to setup a filter on a msgid
svn path=/trunk/; revision=23158
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 7 | ||||
-rw-r--r-- | mail/em-folder-view.c | 18 | ||||
-rw-r--r-- | mail/mail-autofilter.c | 43 | ||||
-rw-r--r-- | mail/mail-autofilter.h | 1 |
4 files changed, 67 insertions, 2 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 12df9b7510..89794c9e4a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2003-11-01 Jeffrey Stedfast <fejj@ximian.com> + + * em-folder-view.c: setup filter-on-thread and vfolder-on-thread. + + * mail-autofilter.c (rule_from_message): handle AUTO_THREAD + (rule_match_thread): new function to setup a filter on a msgid + 2003-10-31 Not Zed <NotZed@Ximian.com> * mail-config.glade: Rearranged smime config slightly, and added diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 94022c22b1..da015f976e 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -644,11 +644,13 @@ EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_subject, AUTO_SUBJ EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_sender, AUTO_FROM) EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_recipients, AUTO_TO) EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_mlist, AUTO_MLIST) +EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_thread, AUTO_THREAD) EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_subject, AUTO_SUBJECT) EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_sender, AUTO_FROM) EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_recipients, AUTO_TO) EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_mlist, AUTO_MLIST) +EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_thread, AUTO_THREAD) /* TODO: Move some of these to be 'standard' menu's */ @@ -701,13 +703,17 @@ static EMPopupItem emfv_popup_menu[] = { { EM_POPUP_ITEM, "90.filter.00/00.02", N_("VFolder on _Recipients"), G_CALLBACK(emfv_popup_vfolder_recipients), NULL, NULL, EM_POPUP_SELECT_ONE }, { EM_POPUP_ITEM, "90.filter.00/00.03", N_("VFolder on Mailing _List"), G_CALLBACK(emfv_popup_vfolder_mlist), NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST }, - + { EM_POPUP_ITEM, "90.filter.00/00.04", N_("VFolder on Thread"), + G_CALLBACK(emfv_popup_vfolder_thread), NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_THREAD }, + { EM_POPUP_BAR, "90.filter.00/10", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_ONE }, { EM_POPUP_ITEM, "90.filter.00/10.00", N_("Filter on Sub_ject"), G_CALLBACK(emfv_popup_filter_subject), NULL, NULL, EM_POPUP_SELECT_ONE }, { EM_POPUP_ITEM, "90.filter.00/10.01", N_("Filter on Sen_der"), G_CALLBACK(emfv_popup_filter_sender), NULL, NULL, EM_POPUP_SELECT_ONE }, { EM_POPUP_ITEM, "90.filter.00/10.02", N_("Filter on Re_cipients"), G_CALLBACK(emfv_popup_filter_recipients), NULL, NULL, EM_POPUP_SELECT_ONE }, { EM_POPUP_ITEM, "90.filter.00/10.03", N_("Filter on _Mailing List"), G_CALLBACK(emfv_popup_filter_mlist), NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST }, + { EM_POPUP_ITEM, "90.filter.00/10.04", N_("Filter on Thread"), + G_CALLBACK(emfv_popup_filter_thread), NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_THREAD }, }; static void @@ -1096,6 +1102,7 @@ struct _filter_data { int type; char *uri; char *mlist; + char *references; }; static void @@ -1106,6 +1113,7 @@ filter_data_free (struct _filter_data *fdata) if (fdata->folder) camel_object_unref (fdata->folder); g_free (fdata->mlist); + g_free (fdata->references); g_free (fdata); } @@ -1156,6 +1164,7 @@ EMFV_MAP_CALLBACK(emfv_tools_filter_subject, emfv_popup_filter_subject) EMFV_MAP_CALLBACK(emfv_tools_filter_sender, emfv_popup_filter_sender) EMFV_MAP_CALLBACK(emfv_tools_filter_recipient, emfv_popup_filter_recipients) EMFV_MAP_CALLBACK(emfv_tools_filter_mlist, emfv_popup_filter_mlist) +EMFV_MAP_CALLBACK(emfv_tools_filter_thread, emfv_popup_filter_thread) static void vfolder_type_got_message (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *user_data) @@ -1197,6 +1206,7 @@ EMFV_MAP_CALLBACK(emfv_tools_vfolder_subject, emfv_popup_vfolder_subject) EMFV_MAP_CALLBACK(emfv_tools_vfolder_sender, emfv_popup_vfolder_sender) EMFV_MAP_CALLBACK(emfv_tools_vfolder_recipient, emfv_popup_vfolder_recipients) EMFV_MAP_CALLBACK(emfv_tools_vfolder_mlist, emfv_popup_vfolder_mlist) +EMFV_MAP_CALLBACK(emfv_tools_vfolder_thread, emfv_popup_vfolder_thread) /* ********************************************************************** */ @@ -1260,10 +1270,12 @@ static BonoboUIVerb emfv_message_verbs[] = { BONOBO_UI_UNSAFE_VERB ("ToolsFilterRecipient", emfv_tools_filter_recipient), BONOBO_UI_UNSAFE_VERB ("ToolsFilterSender", emfv_tools_filter_sender), BONOBO_UI_UNSAFE_VERB ("ToolsFilterSubject", emfv_tools_filter_subject), + BONOBO_UI_UNSAFE_VERB ("ToolsFilterThread", emfv_tools_filter_thread), BONOBO_UI_UNSAFE_VERB ("ToolsVFolderMailingList", emfv_tools_vfolder_mlist), BONOBO_UI_UNSAFE_VERB ("ToolsVFolderRecipient", emfv_tools_vfolder_recipient), BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSender", emfv_tools_vfolder_sender), BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSubject", emfv_tools_vfolder_subject), + BONOBO_UI_UNSAFE_VERB ("ToolsVFolderThread", emfv_tools_vfolder_thread), BONOBO_UI_UNSAFE_VERB ("ViewLoadImages", emfv_view_load_images), /* ViewHeaders stuff is a radio */ @@ -1357,11 +1369,13 @@ static const EMFolderViewEnable emfv_enable_map[] = { { "ToolsFilterMailingList", EM_POPUP_SELECT_ONE }, { "ToolsFilterRecipient", EM_POPUP_SELECT_ONE }, { "ToolsFilterSender", EM_POPUP_SELECT_ONE }, - { "ToolsFilterSubject", EM_POPUP_SELECT_ONE }, + { "ToolsFilterSubject", EM_POPUP_SELECT_ONE }, + { "ToolsFilterThread", EM_POPUP_SELECT_ONE }, { "ToolsVFolderMailingList", EM_POPUP_SELECT_ONE }, { "ToolsVFolderRecipient", EM_POPUP_SELECT_ONE }, { "ToolsVFolderSender", EM_POPUP_SELECT_ONE }, { "ToolsVFolderSubject", EM_POPUP_SELECT_ONE }, + { "ToolsVFolderThread", EM_POPUP_SELECT_ONE }, { "ViewLoadImages", EM_POPUP_SELECT_ONE }, diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c index 9e98758700..dbf2002a3d 100644 --- a/mail/mail-autofilter.c +++ b/mail/mail-autofilter.c @@ -222,6 +222,25 @@ rule_match_mlist(RuleContext *context, FilterRule *rule, const char *mlist) } static void +rule_match_thread (RuleContext *context, FilterRule *rule, const char *msgid) +{ + FilterElement *element; + FilterPart *part; + + if (msgid[0] == 0) + return; + + part = rule_context_create_part (context, "header"); + filter_rule_add_part (rule, part); + + element = filter_part_find_element (part, "header-type"); + filter_option_set_current ((FilterOption *) element, "contains"); + + element = filter_part_find_element (part, "header"); + filter_input_set_value ((FilterInput *) element, msgid); +} + +static void rule_from_message (FilterRule *rule, RuleContext *context, CamelMimeMessage *msg, int flags) { CamelInternetAddress *addr; @@ -273,6 +292,30 @@ rule_from_message (FilterRule *rule, RuleContext *context, CamelMimeMessage *msg } g_free(mlist); } + if (flags & AUTO_THREAD) { + char *name, *msgid = nULL; + const char *refs = NULL; + + if (!(refs = camel_medium_get_header ((CamelMedium *) msg, "References"))) { + if (!(refs = camel_medium_get_header ((CamelMedium *) msg, "In-Reply-To"))) + msgid = camel_message_get_message_id (msg); + } + + if (refs || msgid) { + struct _camel_header_references *r = NULL; + + if (refs) { + r = camel_header_references_decode (refs); + msgid = r->id; + } + + rule_match_thread (context, rule, msgid); + name = g_strdup_printf (_("Replies to %s"), msgid); + + if (r) + camel_header_references_list_clear (&r); + } + } } FilterRule * diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h index 45f9d15863..a5c2575338 100644 --- a/mail/mail-autofilter.h +++ b/mail/mail-autofilter.h @@ -35,6 +35,7 @@ enum { AUTO_FROM = 2, AUTO_TO = 4, AUTO_MLIST = 8, + AUTO_THREAD = 16, }; FilterRule *vfolder_rule_from_message(VfolderContext *context, CamelMimeMessage *msg, int flags, const char *source); |