aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-05 07:54:55 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-05 07:54:55 +0000
commit11776e5a524745b01ac145439ac2892a29bd0826 (patch)
tree233db0a019b3b533581f611edb9802a80d664279
parent51f886e4c8b44242b10c057a1af70f66f28bb2e6 (diff)
moved procmsg.c::procmsg_get_filter_keyword() to filter.c::filter_get_keyword_from_msg().
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@547 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog10
-rw-r--r--ChangeLog.ja10
-rw-r--r--src/filter.c103
-rw-r--r--src/filter.h14
-rw-r--r--src/mainwindow.c10
-rw-r--r--src/messageview.c13
-rw-r--r--src/prefs_filter.h9
-rw-r--r--src/procmsg.c102
-rw-r--r--src/procmsg.h5
-rw-r--r--src/summaryview.c4
-rw-r--r--src/summaryview.h4
11 files changed, 152 insertions, 132 deletions
diff --git a/ChangeLog b/ChangeLog
index 7b5e5663..f3bb1d24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2005-09-05
+ * src/messageview.c
+ src/procmsg.[ch]
+ src/filter.[ch]
+ src/summaryview.[ch]
+ src/mainwindow.c
+ src/prefs_filter.h: moved procmsg.c::procmsg_get_filter_keyword()
+ to filter.c::filter_get_keyword_from_msg().
+
+2005-09-05
+
* libsylph/utils.[ch]
src/inc.c
src/main.c
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 34a6c870..2154a8d4 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,15 @@
2005-09-05
+ * src/messageview.c
+ src/procmsg.[ch]
+ src/filter.[ch]
+ src/summaryview.[ch]
+ src/mainwindow.c
+ src/prefs_filter.h: procmsg.c::procmsg_get_filter_keyword() を
+ filter.c::filter_get_keyword_from_msg() に移動。
+
+2005-09-05
+
* libsylph/utils.[ch]
src/inc.c
src/main.c
diff --git a/src/filter.c b/src/filter.c
index 8d85b95c..efc2fa02 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -34,8 +34,9 @@
#endif
#include <time.h>
-#include "procheader.h"
#include "filter.h"
+#include "procmsg.h"
+#include "procheader.h"
#include "folder.h"
#include "utils.h"
#include "xml.h"
@@ -1261,6 +1262,106 @@ void filter_rule_match_type_str_to_enum(const gchar *match_type,
}
}
+void filter_get_keyword_from_msg(MsgInfo *msginfo, gchar **header, gchar **key,
+ FilterCreateType type)
+{
+ static HeaderEntry hentry[] = {{"List-Id:", NULL, TRUE},
+ {"X-ML-Name:", NULL, TRUE},
+ {"X-List:", NULL, TRUE},
+ {"X-Mailing-list:", NULL, TRUE},
+ {"X-Sequence:", NULL, TRUE},
+ {NULL, NULL, FALSE}};
+ enum
+ {
+ H_LIST_ID = 0,
+ H_X_ML_NAME = 1,
+ H_X_LIST = 2,
+ H_X_MAILING_LIST = 3,
+ H_X_SEQUENCE = 4
+ };
+
+ FILE *fp;
+
+ g_return_if_fail(msginfo != NULL);
+ g_return_if_fail(header != NULL);
+ g_return_if_fail(key != NULL);
+
+ *header = NULL;
+ *key = NULL;
+
+ switch (type) {
+ case FLT_BY_NONE:
+ return;
+ case FLT_BY_AUTO:
+ if ((fp = procmsg_open_message(msginfo)) == NULL)
+ return;
+ procheader_get_header_fields(fp, hentry);
+ fclose(fp);
+
+#define SET_FILTER_KEY(hstr, idx) \
+{ \
+ *header = g_strdup(hstr); \
+ *key = hentry[idx].body; \
+ hentry[idx].body = NULL; \
+}
+
+ if (hentry[H_LIST_ID].body != NULL) {
+ SET_FILTER_KEY("List-Id", H_LIST_ID);
+ extract_list_id_str(*key);
+ } else if (hentry[H_X_ML_NAME].body != NULL) {
+ SET_FILTER_KEY("X-ML-Name", H_X_ML_NAME);
+ } else if (hentry[H_X_LIST].body != NULL) {
+ SET_FILTER_KEY("X-List", H_X_LIST);
+ } else if (hentry[H_X_MAILING_LIST].body != NULL) {
+ SET_FILTER_KEY("X-Mailing-list", H_X_MAILING_LIST);
+ } else if (hentry[H_X_SEQUENCE].body != NULL) {
+ gchar *p;
+
+ SET_FILTER_KEY("X-Sequence", H_X_SEQUENCE);
+ p = *key;
+ while (*p != '\0') {
+ while (*p != '\0' && !g_ascii_isspace(*p)) p++;
+ while (g_ascii_isspace(*p)) p++;
+ if (g_ascii_isdigit(*p)) {
+ *p = '\0';
+ break;
+ }
+ }
+ g_strstrip(*key);
+ } else if (msginfo->subject) {
+ *header = g_strdup("Subject");
+ *key = g_strdup(msginfo->subject);
+ }
+
+#undef SET_FILTER_KEY
+
+ g_free(hentry[H_LIST_ID].body);
+ hentry[H_LIST_ID].body = NULL;
+ g_free(hentry[H_X_ML_NAME].body);
+ hentry[H_X_ML_NAME].body = NULL;
+ g_free(hentry[H_X_LIST].body);
+ hentry[H_X_LIST].body = NULL;
+ g_free(hentry[H_X_MAILING_LIST].body);
+ hentry[H_X_MAILING_LIST].body = NULL;
+
+ break;
+ case FLT_BY_FROM:
+ *header = g_strdup("From");
+ *key = g_strdup(msginfo->from);
+ break;
+ case FLT_BY_TO:
+ *header = g_strdup("To");
+ *key = g_strdup(msginfo->to);
+ break;
+ case FLT_BY_SUBJECT:
+ *header = g_strdup("Subject");
+ *key = g_strdup(msginfo->subject);
+ break;
+ default:
+ break;
+ }
+}
+
void filter_rule_list_free(GSList *fltlist)
{
GSList *cur;
diff --git a/src/filter.h b/src/filter.h
index 0001dcd6..dc38047e 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -87,6 +87,15 @@ typedef enum
FLT_ACTION_NONE
} FilterActionType;
+typedef enum
+{
+ FLT_BY_NONE,
+ FLT_BY_AUTO,
+ FLT_BY_FROM,
+ FLT_BY_TO,
+ FLT_BY_SUBJECT
+} FilterCreateType;
+
#define FLT_IS_NOT_MATCH(flag) ((flag & FLT_NOT_MATCH) != 0)
#define FLT_IS_CASE_SENS(flag) ((flag & FLT_CASE_SENS) != 0)
@@ -191,6 +200,11 @@ void filter_rule_match_type_str_to_enum (const gchar *type_str,
FilterMatchType *type,
FilterMatchFlag *flag);
+void filter_get_keyword_from_msg (MsgInfo *msginfo,
+ gchar **header,
+ gchar **key,
+ FilterCreateType type);
+
void filter_rule_list_free (GSList *fltlist);
void filter_rule_free (FilterRule *rule);
void filter_cond_list_free (GSList *cond_list);
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 92c79be0..14e7e0e9 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -728,13 +728,13 @@ static GtkItemFactoryEntry mainwin_entries[] =
NULL, filter_cb, 1, NULL},
{N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
{N_("/_Tools/_Create filter rule/_Automatically"),
- NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
+ NULL, create_filter_cb, FLT_BY_AUTO, NULL},
{N_("/_Tools/_Create filter rule/by _From"),
- NULL, create_filter_cb, FILTER_BY_FROM, NULL},
+ NULL, create_filter_cb, FLT_BY_FROM, NULL},
{N_("/_Tools/_Create filter rule/by _To"),
- NULL, create_filter_cb, FILTER_BY_TO, NULL},
+ NULL, create_filter_cb, FLT_BY_TO, NULL},
{N_("/_Tools/_Create filter rule/by _Subject"),
- NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
+ NULL, create_filter_cb, FLT_BY_SUBJECT, NULL},
{N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Tools/Filter _junk mails in folder"),
NULL, filter_junk_cb, 0, NULL},
@@ -3204,7 +3204,7 @@ static void select_thread_cb(MainWindow *mainwin, guint action,
static void create_filter_cb(MainWindow *mainwin, guint action,
GtkWidget *widget)
{
- summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
+ summary_filter_open(mainwin->summaryview, (FilterCreateType)action);
}
static void prefs_common_open_cb(MainWindow *mainwin, guint action,
diff --git a/src/messageview.c b/src/messageview.c
index 20502142..f5c0a47a 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -58,6 +58,7 @@
#include "prefs_common.h"
#include "prefs_account.h"
#include "prefs_filter.h"
+#include "filter.h"
#include "gtkutils.h"
#include "utils.h"
#include "rfc2015.h"
@@ -261,13 +262,13 @@ static GtkItemFactoryEntry msgview_entries[] =
{N_("/_Tools/_Create filter rule"),
NULL, NULL, 0, "<Branch>"},
{N_("/_Tools/_Create filter rule/_Automatically"),
- NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
+ NULL, create_filter_cb, FLT_BY_AUTO, NULL},
{N_("/_Tools/_Create filter rule/by _From"),
- NULL, create_filter_cb, FILTER_BY_FROM, NULL},
+ NULL, create_filter_cb, FLT_BY_FROM, NULL},
{N_("/_Tools/_Create filter rule/by _To"),
- NULL, create_filter_cb, FILTER_BY_TO, NULL},
+ NULL, create_filter_cb, FLT_BY_TO, NULL},
{N_("/_Tools/_Create filter rule/by _Subject"),
- NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
+ NULL, create_filter_cb, FLT_BY_SUBJECT, NULL},
{N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
@@ -899,8 +900,8 @@ static void create_filter_cb(gpointer data, guint action, GtkWidget *widget)
if (!messageview->msginfo) return;
- procmsg_get_filter_keyword(messageview->msginfo, &header, &key,
- (PrefsFilterType)action);
+ filter_get_keyword_from_msg(messageview->msginfo, &header, &key,
+ (FilterCreateType)action);
prefs_filter_open(messageview->msginfo, header);
g_free(header);
diff --git a/src/prefs_filter.h b/src/prefs_filter.h
index d41a9883..85a1c5f6 100644
--- a/src/prefs_filter.h
+++ b/src/prefs_filter.h
@@ -26,15 +26,6 @@
#include <glib.h>
-typedef enum
-{
- FILTER_BY_NONE,
- FILTER_BY_AUTO,
- FILTER_BY_FROM,
- FILTER_BY_TO,
- FILTER_BY_SUBJECT
-} PrefsFilterType;
-
#include "procmsg.h"
void prefs_filter_open (MsgInfo *msginfo,
diff --git a/src/procmsg.c b/src/procmsg.c
index 560c0478..0ecae5b4 100644
--- a/src/procmsg.c
+++ b/src/procmsg.c
@@ -30,8 +30,6 @@
#include "account.h"
#include "procmime.h"
#include "prefs_common.h"
-#include "prefs_filter.h"
-#include "filter.h"
#include "folder.h"
#include "codeconv.h"
#if USE_GPGME
@@ -1114,106 +1112,6 @@ gboolean procmsg_msg_exist(MsgInfo *msginfo)
return ret;
}
-void procmsg_get_filter_keyword(MsgInfo *msginfo, gchar **header, gchar **key,
- PrefsFilterType type)
-{
- static HeaderEntry hentry[] = {{"List-Id:", NULL, TRUE},
- {"X-ML-Name:", NULL, TRUE},
- {"X-List:", NULL, TRUE},
- {"X-Mailing-list:", NULL, TRUE},
- {"X-Sequence:", NULL, TRUE},
- {NULL, NULL, FALSE}};
- enum
- {
- H_LIST_ID = 0,
- H_X_ML_NAME = 1,
- H_X_LIST = 2,
- H_X_MAILING_LIST = 3,
- H_X_SEQUENCE = 4
- };
-
- FILE *fp;
-
- g_return_if_fail(msginfo != NULL);
- g_return_if_fail(header != NULL);
- g_return_if_fail(key != NULL);
-
- *header = NULL;
- *key = NULL;
-
- switch (type) {
- case FILTER_BY_NONE:
- return;
- case FILTER_BY_AUTO:
- if ((fp = procmsg_open_message(msginfo)) == NULL)
- return;
- procheader_get_header_fields(fp, hentry);
- fclose(fp);
-
-#define SET_FILTER_KEY(hstr, idx) \
-{ \
- *header = g_strdup(hstr); \
- *key = hentry[idx].body; \
- hentry[idx].body = NULL; \
-}
-
- if (hentry[H_LIST_ID].body != NULL) {
- SET_FILTER_KEY("List-Id", H_LIST_ID);
- extract_list_id_str(*key);
- } else if (hentry[H_X_ML_NAME].body != NULL) {
- SET_FILTER_KEY("X-ML-Name", H_X_ML_NAME);
- } else if (hentry[H_X_LIST].body != NULL) {
- SET_FILTER_KEY("X-List", H_X_LIST);
- } else if (hentry[H_X_MAILING_LIST].body != NULL) {
- SET_FILTER_KEY("X-Mailing-list", H_X_MAILING_LIST);
- } else if (hentry[H_X_SEQUENCE].body != NULL) {
- gchar *p;
-
- SET_FILTER_KEY("X-Sequence", H_X_SEQUENCE);
- p = *key;
- while (*p != '\0') {
- while (*p != '\0' && !g_ascii_isspace(*p)) p++;
- while (g_ascii_isspace(*p)) p++;
- if (g_ascii_isdigit(*p)) {
- *p = '\0';
- break;
- }
- }
- g_strstrip(*key);
- } else if (msginfo->subject) {
- *header = g_strdup("Subject");
- *key = g_strdup(msginfo->subject);
- }
-
-#undef SET_FILTER_KEY
-
- g_free(hentry[H_LIST_ID].body);
- hentry[H_LIST_ID].body = NULL;
- g_free(hentry[H_X_ML_NAME].body);
- hentry[H_X_ML_NAME].body = NULL;
- g_free(hentry[H_X_LIST].body);
- hentry[H_X_LIST].body = NULL;
- g_free(hentry[H_X_MAILING_LIST].body);
- hentry[H_X_MAILING_LIST].body = NULL;
-
- break;
- case FILTER_BY_FROM:
- *header = g_strdup("From");
- *key = g_strdup(msginfo->from);
- break;
- case FILTER_BY_TO:
- *header = g_strdup("To");
- *key = g_strdup(msginfo->to);
- break;
- case FILTER_BY_SUBJECT:
- *header = g_strdup("Subject");
- *key = g_strdup(msginfo->subject);
- break;
- default:
- break;
- }
-}
-
void procmsg_empty_trash(FolderItem *trash)
{
if (trash && trash->total > 0) {
diff --git a/src/procmsg.h b/src/procmsg.h
index 4aa389b2..9e6d45b8 100644
--- a/src/procmsg.h
+++ b/src/procmsg.h
@@ -262,11 +262,6 @@ FILE *procmsg_open_message_decrypted (MsgInfo *msginfo,
#endif
gboolean procmsg_msg_exist (MsgInfo *msginfo);
-void procmsg_get_filter_keyword (MsgInfo *msginfo,
- gchar **header,
- gchar **key,
- PrefsFilterType type);
-
void procmsg_empty_trash (FolderItem *trash);
void procmsg_empty_all_trash (void);
diff --git a/src/summaryview.c b/src/summaryview.c
index 6e83b6fe..da018bb9 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -3752,7 +3752,7 @@ void summary_filter_junk(SummaryView *summaryview, gboolean selected_only)
selected_only);
}
-void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
+void summary_filter_open(SummaryView *summaryview, FilterCreateType type)
{
GtkTreeIter iter;
MsgInfo *msginfo = NULL;
@@ -3768,7 +3768,7 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
GET_MSG_INFO(msginfo, &iter);
if (!msginfo) return;
- procmsg_get_filter_keyword(msginfo, &header, &key, type);
+ filter_get_keyword_from_msg(msginfo, &header, &key, type);
prefs_filter_open(msginfo, header);
g_free(header);
diff --git a/src/summaryview.h b/src/summaryview.h
index 20737671..d2ba350c 100644
--- a/src/summaryview.h
+++ b/src/summaryview.h
@@ -37,7 +37,7 @@ typedef struct _SummaryColumnState SummaryColumnState;
#include "headerview.h"
#include "messageview.h"
#include "compose.h"
-#include "prefs_filter.h"
+#include "filter.h"
#include "folder.h"
typedef enum
@@ -172,7 +172,7 @@ void summary_collapse_threads (SummaryView *summaryview);
void summary_filter (SummaryView *summaryview,
gboolean selected_only);
void summary_filter_open (SummaryView *summaryview,
- PrefsFilterType type);
+ FilterCreateType type);
void summary_filter_junk (SummaryView *summaryview,
gboolean selected_only);