new matcher parser / bounce fix / rrr fixed
This commit is contained in:
parent
9693b18feb
commit
788289df17
25 changed files with 1079 additions and 771 deletions
|
@ -1,3 +1,36 @@
|
|||
2001-11-15 [hoa] 0.6.5claws15
|
||||
|
||||
* src/compose.c
|
||||
fix bounce, mails we received couln't be bounced to ourself.
|
||||
|
||||
* src/defs.h
|
||||
* src/filtering.[ch]
|
||||
* src/matcher.[ch]
|
||||
* src/matcher_parser.h
|
||||
* src/matcher_parser_lex.l
|
||||
* src/matcher_parser_parse.y
|
||||
* src/inc.c
|
||||
* src/main.c
|
||||
* src/mbox.c
|
||||
* src/prefs_filtering.[ch]
|
||||
* src/mainwindow.c
|
||||
* src/prefs_matcher.c
|
||||
* src/prefs_scoring.c
|
||||
* src/scoring.[ch]
|
||||
* src/summaryview.c
|
||||
new matcher/filter/score configuration file parser
|
||||
one unique configuration file => ~/.sylpheed/matcherrc
|
||||
import in currently automatic, then save are made
|
||||
in this new file.
|
||||
one filter per folder and one global filter
|
||||
(filter of a folder will be used as folder processing)
|
||||
|
||||
* src/folder.c
|
||||
fix a bug in folder_item_get_identifier
|
||||
|
||||
* src/messageview.c
|
||||
receive receipt return are fixed.
|
||||
|
||||
2001-11-14 [alfons] 0.6.5claws14
|
||||
|
||||
* src/session.h
|
||||
|
|
|
@ -8,7 +8,7 @@ MINOR_VERSION=6
|
|||
MICRO_VERSION=5
|
||||
INTERFACE_AGE=0
|
||||
BINARY_AGE=0
|
||||
EXTRA_VERSION=claws14
|
||||
EXTRA_VERSION=claws15
|
||||
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
|
||||
|
||||
dnl
|
||||
|
|
|
@ -119,12 +119,17 @@ sylpheed_SOURCES = \
|
|||
mbox_folder.c mbox_folder.h \
|
||||
quote_fmt_lex.l quote_fmt_lex.h \
|
||||
quote_fmt_parse.y quote_fmt.h \
|
||||
gtkspell.c gtkspell.h gtkxtext.h
|
||||
gtkspell.c gtkspell.h gtkxtext.h \
|
||||
matcher_parser_lex.l matcher_parser_lex.h \
|
||||
matcher_parser_parse.y matcher_parser.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
quote_fmt_lex.c \
|
||||
quote_fmt_parse.c \
|
||||
quote_fmt_parse.h
|
||||
quote_fmt_parse.h \
|
||||
matcher_parser_lex.c \
|
||||
matcher_parser_parse.c \
|
||||
matcher_parser_parse.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
quote_fmt_parse.h \
|
||||
|
|
|
@ -2772,6 +2772,12 @@ static gint compose_bounce_write_to_file(Compose *compose, const gchar *file)
|
|||
}
|
||||
|
||||
while (procheader_get_unfolded_line(buf, sizeof(buf), fp)) {
|
||||
/* should filter returnpath, delivered-to */
|
||||
if ((g_strncasecmp(buf, "Return-Path:",
|
||||
strlen("Return-Path:")) == 0)
|
||||
|| (g_strncasecmp(buf, "Delivered-To:",
|
||||
strlen("Delivered-To:")) == 0))
|
||||
continue;
|
||||
if (fputs(buf, fdest) == -1)
|
||||
goto error;
|
||||
if (fputs("\n", fdest) == -1)
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#define FOLDERITEM_RC "folderitemrc"
|
||||
#define SCORING_RC "scoringrc"
|
||||
#define FILTERING_RC "filteringrc"
|
||||
#define MATCHER_RC "matcherrc"
|
||||
#define MENU_RC "menurc"
|
||||
#define COMMAND_HISTORY "command_history"
|
||||
#define TEMPLATE_DIR "templates"
|
||||
|
|
182
src/filtering.c
182
src/filtering.c
|
@ -50,7 +50,7 @@
|
|||
|
||||
#define PREFSBUFSIZE 1024
|
||||
|
||||
GSList * prefs_filtering = NULL;
|
||||
GSList * global_processing = NULL;
|
||||
|
||||
FilteringAction * filteringaction_new(int type, int account_id,
|
||||
gchar * destination,
|
||||
|
@ -75,6 +75,7 @@ void filteringaction_free(FilteringAction * action)
|
|||
g_free(action);
|
||||
}
|
||||
|
||||
/*
|
||||
FilteringAction * filteringaction_parse(gchar ** str)
|
||||
{
|
||||
FilteringAction * action;
|
||||
|
@ -89,27 +90,27 @@ FilteringAction * filteringaction_parse(gchar ** str)
|
|||
key = matcher_parse_keyword(&tmp);
|
||||
|
||||
switch (key) {
|
||||
case MATCHING_ACTION_MOVE:
|
||||
case MATCHING_ACTION_COPY:
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHACTION_MOVE:
|
||||
case MATCHACTION_COPY:
|
||||
case MATCHACTION_EXECUTE:
|
||||
destination = matcher_parse_str(&tmp);
|
||||
if (tmp == NULL) {
|
||||
* str = NULL;
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
case MATCHING_ACTION_DELETE:
|
||||
case MATCHACTION_DELETE:
|
||||
break;
|
||||
case MATCHING_ACTION_MARK:
|
||||
case MATCHACTION_MARK:
|
||||
break;
|
||||
case MATCHING_ACTION_MARK_AS_READ:
|
||||
case MATCHACTION_MARK_AS_READ:
|
||||
break;
|
||||
case MATCHING_ACTION_UNMARK:
|
||||
case MATCHACTION_UNMARK:
|
||||
break;
|
||||
case MATCHING_ACTION_MARK_AS_UNREAD:
|
||||
case MATCHACTION_MARK_AS_UNREAD:
|
||||
break;
|
||||
case MATCHING_ACTION_FORWARD:
|
||||
case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
|
||||
case MATCHACTION_FORWARD:
|
||||
case MATCHACTION_FORWARD_AS_ATTACHMENT:
|
||||
account_id = matcher_parse_number(&tmp);
|
||||
if (tmp == NULL) {
|
||||
* str = NULL;
|
||||
|
@ -123,7 +124,7 @@ FilteringAction * filteringaction_parse(gchar ** str)
|
|||
}
|
||||
|
||||
break;
|
||||
case MATCHING_ACTION_COLOR:
|
||||
case MATCHACTION_COLOR:
|
||||
labelcolor = matcher_parse_number(&tmp);
|
||||
if (tmp == NULL) {
|
||||
*str = NULL;
|
||||
|
@ -177,7 +178,7 @@ FilteringProp * filteringprop_parse(gchar ** str)
|
|||
* str = tmp;
|
||||
return filtering;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
FilteringProp * filteringprop_new(MatcherList * matchers,
|
||||
FilteringAction * action)
|
||||
|
@ -421,7 +422,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
gchar * cmd;
|
||||
|
||||
switch(action->type) {
|
||||
case MATCHING_ACTION_MOVE:
|
||||
case MATCHACTION_MOVE:
|
||||
dest_folder =
|
||||
folder_find_item_from_identifier(action->destination);
|
||||
if (!dest_folder)
|
||||
|
@ -455,7 +456,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
}
|
||||
return TRUE;
|
||||
|
||||
case MATCHING_ACTION_COPY:
|
||||
case MATCHACTION_COPY:
|
||||
dest_folder =
|
||||
folder_find_item_from_identifier(action->destination);
|
||||
|
||||
|
@ -481,7 +482,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
|
||||
return TRUE;
|
||||
|
||||
case MATCHING_ACTION_DELETE:
|
||||
case MATCHACTION_DELETE:
|
||||
if (folder_item_remove_msg(info->folder, info->msgnum) == -1)
|
||||
return FALSE;
|
||||
|
||||
|
@ -494,7 +495,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
|
||||
return TRUE;
|
||||
|
||||
case MATCHING_ACTION_MARK:
|
||||
case MATCHACTION_MARK:
|
||||
MSG_SET_PERM_FLAGS(info->flags, MSG_MARKED);
|
||||
debug_print("*** MARKING message %d, in folder %s, \"%s\"\n",
|
||||
info->msgnum, info->folder->name,
|
||||
|
@ -505,7 +506,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
|
||||
return TRUE;
|
||||
|
||||
case MATCHING_ACTION_UNMARK:
|
||||
case MATCHACTION_UNMARK:
|
||||
MSG_UNSET_PERM_FLAGS(info->flags, MSG_MARKED);
|
||||
filteringaction_update_mark(info);
|
||||
|
||||
|
@ -513,7 +514,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
|
||||
return TRUE;
|
||||
|
||||
case MATCHING_ACTION_MARK_AS_READ:
|
||||
case MATCHACTION_MARK_AS_READ:
|
||||
MSG_UNSET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
|
||||
filteringaction_update_mark(info);
|
||||
|
||||
|
@ -521,7 +522,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
|
||||
return TRUE;
|
||||
|
||||
case MATCHING_ACTION_MARK_AS_UNREAD:
|
||||
case MATCHACTION_MARK_AS_UNREAD:
|
||||
MSG_SET_PERM_FLAGS(info->flags, MSG_UNREAD | MSG_NEW);
|
||||
filteringaction_update_mark(info);
|
||||
|
||||
|
@ -529,7 +530,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
|
||||
return TRUE;
|
||||
|
||||
case MATCHING_ACTION_FORWARD:
|
||||
case MATCHACTION_FORWARD:
|
||||
|
||||
account = account_find_from_id(action->account_id);
|
||||
compose = compose_forward(account, info, FALSE);
|
||||
|
@ -549,7 +550,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
gtk_widget_destroy(compose->window);
|
||||
return FALSE;
|
||||
|
||||
case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
|
||||
case MATCHACTION_FORWARD_AS_ATTACHMENT:
|
||||
|
||||
account = account_find_from_id(action->account_id);
|
||||
compose = compose_forward(account, info, TRUE);
|
||||
|
@ -569,7 +570,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
|
|||
gtk_widget_destroy(compose->window);
|
||||
return FALSE;
|
||||
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHACTION_EXECUTE:
|
||||
|
||||
cmd = matching_build_command(action->destination, info);
|
||||
if (cmd == NULL)
|
||||
|
@ -622,17 +623,17 @@ static gboolean filteringprop_apply(FilteringProp * filtering, MsgInfo * info,
|
|||
g_free(action_str);
|
||||
|
||||
switch(filtering->action->type) {
|
||||
case MATCHING_ACTION_MOVE:
|
||||
case MATCHING_ACTION_DELETE:
|
||||
case MATCHACTION_MOVE:
|
||||
case MATCHACTION_DELETE:
|
||||
return TRUE; /* MsgInfo invalid for message */
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHING_ACTION_COPY:
|
||||
case MATCHING_ACTION_MARK:
|
||||
case MATCHING_ACTION_MARK_AS_READ:
|
||||
case MATCHING_ACTION_UNMARK:
|
||||
case MATCHING_ACTION_MARK_AS_UNREAD:
|
||||
case MATCHING_ACTION_FORWARD:
|
||||
case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
|
||||
case MATCHACTION_EXECUTE:
|
||||
case MATCHACTION_COPY:
|
||||
case MATCHACTION_MARK:
|
||||
case MATCHACTION_MARK_AS_READ:
|
||||
case MATCHACTION_UNMARK:
|
||||
case MATCHACTION_MARK_AS_UNREAD:
|
||||
case MATCHACTION_FORWARD:
|
||||
case MATCHACTION_FORWARD_AS_ATTACHMENT:
|
||||
return FALSE; /* MsgInfo still valid for message */
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -674,8 +675,8 @@ void filter_msginfo_move_or_delete(GSList * filtering_list, MsgInfo * info,
|
|||
FilteringProp * filtering = (FilteringProp *) l->data;
|
||||
|
||||
switch (filtering->action->type) {
|
||||
case MATCHING_ACTION_MOVE:
|
||||
case MATCHING_ACTION_DELETE:
|
||||
case MATCHACTION_MOVE:
|
||||
case MATCHACTION_DELETE:
|
||||
if (filteringprop_apply(filtering, info, folder_table))
|
||||
return;
|
||||
}
|
||||
|
@ -820,7 +821,7 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
MsgFlags markflags = { 0, 0 };
|
||||
|
||||
/* use the global prefs_filtering list */
|
||||
GSList * list = prefs_filtering;
|
||||
GSList * list = global_processing;
|
||||
|
||||
/* things we get after having added a message to a folder */
|
||||
FolderItem *dest_folder;
|
||||
|
@ -863,31 +864,31 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
for (ma_tail = &ma_head, stop = FALSE; ma_tail->action && !stop; ma_tail = ma_tail->next) {
|
||||
switch (ma_tail->action->type) {
|
||||
|
||||
case MATCHING_ACTION_MARK:
|
||||
case MATCHACTION_MARK:
|
||||
MSG_SET_PERM_FLAGS(markflags, MSG_MARKED);
|
||||
break;
|
||||
|
||||
case MATCHING_ACTION_UNMARK:
|
||||
case MATCHACTION_UNMARK:
|
||||
MSG_UNSET_PERM_FLAGS(markflags, MSG_MARKED);
|
||||
break;
|
||||
|
||||
case MATCHING_ACTION_MARK_AS_READ:
|
||||
case MATCHACTION_MARK_AS_READ:
|
||||
MSG_UNSET_PERM_FLAGS(markflags, MSG_UNREAD);
|
||||
break;
|
||||
|
||||
case MATCHING_ACTION_MARK_AS_UNREAD:
|
||||
case MATCHACTION_MARK_AS_UNREAD:
|
||||
MSG_SET_PERM_FLAGS(markflags, MSG_UNREAD);
|
||||
break;
|
||||
|
||||
case MATCHING_ACTION_COLOR:
|
||||
case MATCHACTION_COLOR:
|
||||
MSG_SET_COLORLABEL_VALUE(markflags, ma_tail->action->labelcolor);
|
||||
break;
|
||||
|
||||
/* UNCONTINUABLE */
|
||||
case MATCHING_ACTION_FORWARD:
|
||||
case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
|
||||
case MATCHING_ACTION_MOVE:
|
||||
case MATCHING_ACTION_DELETE:
|
||||
case MATCHACTION_FORWARD:
|
||||
case MATCHACTION_FORWARD_AS_ATTACHMENT:
|
||||
case MATCHACTION_MOVE:
|
||||
case MATCHACTION_DELETE:
|
||||
stop = TRUE;
|
||||
break;
|
||||
|
||||
|
@ -918,7 +919,7 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
|
||||
/* C O N T I N U A B L E */
|
||||
|
||||
if (MATCHING_ACTION_COPY == ACTION) {
|
||||
if (MATCHACTION_COPY == ACTION) {
|
||||
debug_print("*** performing copy\n");
|
||||
copy_to_inbox_too = TRUE;
|
||||
if (!prepare_destination(ma_tail->action->destination, &dest_folder, folder_table)) {
|
||||
|
@ -933,7 +934,7 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
flags = msginfo->flags.perm_flags | markflags.perm_flags;
|
||||
add_mark(dest_folder, msgnum, flags);
|
||||
}
|
||||
else if (MATCHING_EXECUTE == ACTION) {
|
||||
else if (MATCHACTION_EXECUTE == ACTION) {
|
||||
debug_print("*** performing exec\n");
|
||||
copy_to_inbox_too = TRUE;
|
||||
|
||||
|
@ -949,8 +950,8 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
|
||||
/* U N C O N T I N U A B L E */
|
||||
|
||||
else if (MATCHING_ACTION_FORWARD == ACTION
|
||||
|| MATCHING_ACTION_FORWARD_AS_ATTACHMENT == ACTION) {
|
||||
else if (MATCHACTION_FORWARD == ACTION
|
||||
|| MATCHACTION_FORWARD_AS_ATTACHMENT == ACTION) {
|
||||
debug_print("*** performing forward\n");
|
||||
|
||||
/* forwarding messages is complicated because there's currently no
|
||||
|
@ -978,7 +979,7 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
|
||||
/* do the compose_XXX stuff */
|
||||
account = account_find_from_id(ma_tail->action->account_id);
|
||||
compose = compose_forward(account, fwd_msg, ACTION == MATCHING_ACTION_FORWARD ? FALSE : TRUE);
|
||||
compose = compose_forward(account, fwd_msg, ACTION == MATCHACTION_FORWARD ? FALSE : TRUE);
|
||||
if (compose->account->protocol == A_NNTP)
|
||||
compose_entry_append(compose, ma_tail->action->destination,
|
||||
COMPOSE_NEWSGROUPS);
|
||||
|
@ -993,7 +994,7 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
gtk_widget_destroy(compose->window);
|
||||
break;
|
||||
}
|
||||
else if (MATCHING_ACTION_DELETE == ACTION) {
|
||||
else if (MATCHACTION_DELETE == ACTION) {
|
||||
debug_print("*** performing delete\n");
|
||||
copy_to_inbox_too = FALSE;
|
||||
|
||||
|
@ -1010,7 +1011,7 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder,
|
|||
}
|
||||
break;
|
||||
}
|
||||
else if (MATCHING_ACTION_MOVE == ACTION) {
|
||||
else if (MATCHACTION_MOVE == ACTION) {
|
||||
debug_print("*** performing move\n");
|
||||
copy_to_inbox_too = FALSE;
|
||||
|
||||
|
@ -1090,10 +1091,14 @@ void filter_incoming_message(FolderItem *default_folder, const gchar *file_name,
|
|||
procmsg_msginfo_free(msginfo);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void prefs_filtering_read_config(void)
|
||||
{
|
||||
|
||||
gchar *rcpath;
|
||||
FILE *fp;
|
||||
gchar buf[PREFSBUFSIZE];
|
||||
|
@ -1109,8 +1114,9 @@ void prefs_filtering_read_config(void)
|
|||
return;
|
||||
}
|
||||
g_free(rcpath);
|
||||
|
||||
*/
|
||||
/* remove all filtering */
|
||||
/*
|
||||
while (prefs_filtering != NULL) {
|
||||
FilteringProp * filtering =
|
||||
(FilteringProp *) prefs_filtering->data;
|
||||
|
@ -1133,7 +1139,9 @@ void prefs_filtering_read_config(void)
|
|||
filtering);
|
||||
}
|
||||
else {
|
||||
*/
|
||||
/* debug */
|
||||
/*
|
||||
g_warning(_("syntax error : %s\n"), buf);
|
||||
}
|
||||
}
|
||||
|
@ -1141,6 +1149,7 @@ void prefs_filtering_read_config(void)
|
|||
|
||||
fclose(fp);
|
||||
}
|
||||
*/
|
||||
|
||||
gchar * filteringaction_to_string(FilteringAction * action)
|
||||
{
|
||||
|
@ -1158,27 +1167,27 @@ gchar * filteringaction_to_string(FilteringAction * action)
|
|||
return NULL;
|
||||
|
||||
switch(action->type) {
|
||||
case MATCHING_ACTION_MOVE:
|
||||
case MATCHING_ACTION_COPY:
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHACTION_MOVE:
|
||||
case MATCHACTION_COPY:
|
||||
case MATCHACTION_EXECUTE:
|
||||
return g_strconcat(command_str, " \"", action->destination,
|
||||
"\"", NULL);
|
||||
|
||||
case MATCHING_ACTION_DELETE:
|
||||
case MATCHING_ACTION_MARK:
|
||||
case MATCHING_ACTION_UNMARK:
|
||||
case MATCHING_ACTION_MARK_AS_READ:
|
||||
case MATCHING_ACTION_MARK_AS_UNREAD:
|
||||
case MATCHACTION_DELETE:
|
||||
case MATCHACTION_MARK:
|
||||
case MATCHACTION_UNMARK:
|
||||
case MATCHACTION_MARK_AS_READ:
|
||||
case MATCHACTION_MARK_AS_UNREAD:
|
||||
return g_strdup(command_str);
|
||||
break;
|
||||
|
||||
case MATCHING_ACTION_FORWARD:
|
||||
case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
|
||||
case MATCHACTION_FORWARD:
|
||||
case MATCHACTION_FORWARD_AS_ATTACHMENT:
|
||||
account_id_str = itos(action->account_id);
|
||||
return g_strconcat(command_str, " ", account_id_str,
|
||||
" \"", action->destination, "\"", NULL);
|
||||
|
||||
case MATCHING_ACTION_COLOR:
|
||||
case MATCHACTION_COLOR:
|
||||
labelcolor_str = itos(action->labelcolor);
|
||||
return g_strconcat(command_str, " ", labelcolor_str, NULL);
|
||||
|
||||
|
@ -1214,6 +1223,7 @@ gchar * filteringprop_to_string(FilteringProp * prop)
|
|||
|
||||
void prefs_filtering_write_config(void)
|
||||
{
|
||||
/*
|
||||
gchar *rcpath;
|
||||
PrefFile *pfile;
|
||||
GSList *cur;
|
||||
|
@ -1229,7 +1239,7 @@ void prefs_filtering_write_config(void)
|
|||
return;
|
||||
}
|
||||
|
||||
for (cur = prefs_filtering; cur != NULL; cur = cur->next) {
|
||||
for (cur = global_processing; cur != NULL; cur = cur->next) {
|
||||
gchar *filtering_str;
|
||||
|
||||
prop = (FilteringProp *) cur->data;
|
||||
|
@ -1252,4 +1262,44 @@ void prefs_filtering_write_config(void)
|
|||
g_warning(_("failed to write configuration to file\n"));
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void prefs_filtering_free(GSList * prefs_filtering)
|
||||
{
|
||||
while (prefs_filtering != NULL) {
|
||||
FilteringProp * filtering = (FilteringProp *)
|
||||
prefs_filtering->data;
|
||||
filteringprop_free(filtering);
|
||||
prefs_filtering = g_slist_remove(prefs_filtering, filtering);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean prefs_filtering_free_func(GNode *node, gpointer data)
|
||||
{
|
||||
FolderItem *item = node->data;
|
||||
|
||||
if(!item->prefs)
|
||||
return FALSE;
|
||||
|
||||
prefs_filtering_free(item->prefs->processing);
|
||||
item->prefs->processing = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void prefs_filtering_clear()
|
||||
{
|
||||
GList * cur;
|
||||
|
||||
for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
|
||||
Folder *folder;
|
||||
|
||||
folder = (Folder *) cur->data;
|
||||
g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
|
||||
prefs_filtering_free_func, NULL);
|
||||
}
|
||||
|
||||
prefs_filtering_free(global_processing);
|
||||
global_processing = NULL;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ struct _FilteringProp {
|
|||
|
||||
typedef struct _FilteringProp FilteringProp;
|
||||
|
||||
extern GSList * prefs_filtering;
|
||||
/* extern GSList * prefs_filtering; */
|
||||
|
||||
|
||||
FilteringAction * filteringaction_new(int type, int account_id,
|
||||
|
@ -71,4 +71,9 @@ void prefs_filtering_write_config(void);
|
|||
void prefs_filtering_read_config(void);
|
||||
gchar * filteringprop_to_string(FilteringProp * prop);
|
||||
|
||||
void prefs_filtering_clear();
|
||||
void prefs_filtering_free(GSList * prefs_filtering);
|
||||
|
||||
extern GSList * global_processing;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1427,7 +1427,7 @@ gchar * folder_item_get_identifier(FolderItem * item)
|
|||
gchar * id;
|
||||
gchar * folder_str;
|
||||
|
||||
g_return_if_fail(item->path != NULL);
|
||||
g_return_val_if_fail(item->path != NULL, NULL);
|
||||
|
||||
folder_str = folder_get_identifier(item->folder);
|
||||
id = g_strconcat(folder_str, "/", item->path, NULL);
|
||||
|
|
|
@ -910,7 +910,7 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (prefs_filtering == NULL) {
|
||||
if (global_processing == NULL) {
|
||||
/* old filtering */
|
||||
if (state->ac_prefs->filter_on_recv) {
|
||||
dropfolder =
|
||||
|
@ -935,7 +935,7 @@ gint inc_drop_message(const gchar *file, Pop3State *state)
|
|||
GINT_TO_POINTER(1));
|
||||
}
|
||||
|
||||
if (prefs_filtering == NULL || !state->ac_prefs->filter_on_recv) {
|
||||
if (global_processing == NULL || !state->ac_prefs->filter_on_recv) {
|
||||
if ((msgnum = folder_item_add_msg(dropfolder, file, TRUE)) < 0) {
|
||||
unlink(file);
|
||||
return -1;
|
||||
|
|
|
@ -248,7 +248,7 @@ int main(int argc, char *argv[])
|
|||
prefs_filter_write_config();
|
||||
prefs_display_header_read_config();
|
||||
prefs_display_header_write_config();
|
||||
prefs_filtering_read_config();
|
||||
/* prefs_filtering_read_config(); */
|
||||
addressbook_read_file();
|
||||
|
||||
gtkut_widget_init();
|
||||
|
@ -278,7 +278,8 @@ int main(int argc, char *argv[])
|
|||
account_set_missing_folder();
|
||||
folderview_set(folderview);
|
||||
|
||||
prefs_scoring_read_config();
|
||||
/* prefs_scoring_read_config(); */
|
||||
prefs_matcher_read_config();
|
||||
|
||||
addressbook_read_file();
|
||||
|
||||
|
|
|
@ -2727,7 +2727,7 @@ static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
|
|||
static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
prefs_filtering_open();
|
||||
prefs_filtering_open(NULL);
|
||||
}
|
||||
|
||||
static void prefs_template_open_cb(MainWindow *mainwin, guint action,
|
||||
|
|
653
src/matcher.c
653
src/matcher.c
|
@ -34,6 +34,8 @@
|
|||
#include "procheader.h"
|
||||
#include "matcher.h"
|
||||
#include "intl.h"
|
||||
#include "matcher_parser.h"
|
||||
#include "prefs.h"
|
||||
|
||||
struct _MatchParser {
|
||||
gint id;
|
||||
|
@ -44,76 +46,75 @@ typedef struct _MatchParser MatchParser;
|
|||
|
||||
static MatchParser matchparser_tab[] = {
|
||||
/* msginfo flags */
|
||||
{MATCHING_ALL, "all"},
|
||||
{MATCHING_UNREAD, "unread"},
|
||||
{MATCHING_NOT_UNREAD, "~unread"},
|
||||
{MATCHING_NEW, "new"},
|
||||
{MATCHING_NOT_NEW, "~new"},
|
||||
{MATCHING_MARKED, "marked"},
|
||||
{MATCHING_NOT_MARKED, "~marked"},
|
||||
{MATCHING_DELETED, "deleted"},
|
||||
{MATCHING_NOT_DELETED, "~deleted"},
|
||||
{MATCHING_REPLIED, "replied"},
|
||||
{MATCHING_NOT_REPLIED, "~replied"},
|
||||
{MATCHING_FORWARDED, "forwarded"},
|
||||
{MATCHING_NOT_FORWARDED, "~forwarded"},
|
||||
{MATCHCRITERIA_ALL, "all"},
|
||||
{MATCHCRITERIA_UNREAD, "unread"},
|
||||
{MATCHCRITERIA_NOT_UNREAD, "~unread"},
|
||||
{MATCHCRITERIA_NEW, "new"},
|
||||
{MATCHCRITERIA_NOT_NEW, "~new"},
|
||||
{MATCHCRITERIA_MARKED, "marked"},
|
||||
{MATCHCRITERIA_NOT_MARKED, "~marked"},
|
||||
{MATCHCRITERIA_DELETED, "deleted"},
|
||||
{MATCHCRITERIA_NOT_DELETED, "~deleted"},
|
||||
{MATCHCRITERIA_REPLIED, "replied"},
|
||||
{MATCHCRITERIA_NOT_REPLIED, "~replied"},
|
||||
{MATCHCRITERIA_FORWARDED, "forwarded"},
|
||||
{MATCHCRITERIA_NOT_FORWARDED, "~forwarded"},
|
||||
|
||||
/* msginfo headers */
|
||||
{MATCHING_SUBJECT, "subject"},
|
||||
{MATCHING_NOT_SUBJECT, "~subject"},
|
||||
{MATCHING_FROM, "from"},
|
||||
{MATCHING_NOT_FROM, "~from"},
|
||||
{MATCHING_TO, "to"},
|
||||
{MATCHING_NOT_TO, "~to"},
|
||||
{MATCHING_CC, "cc"},
|
||||
{MATCHING_NOT_CC, "~cc"},
|
||||
{MATCHING_TO_OR_CC, "to_or_cc"},
|
||||
{MATCHING_NOT_TO_AND_NOT_CC, "~to_or_cc"},
|
||||
{MATCHING_AGE_GREATER, "age_greater"},
|
||||
{MATCHING_AGE_LOWER, "age_lower"},
|
||||
{MATCHING_NEWSGROUPS, "newsgroups"},
|
||||
{MATCHING_NOT_NEWSGROUPS, "~newsgroups"},
|
||||
{MATCHING_INREPLYTO, "inreplyto"},
|
||||
{MATCHING_NOT_INREPLYTO, "~inreplyto"},
|
||||
{MATCHING_REFERENCES, "references"},
|
||||
{MATCHING_NOT_REFERENCES, "~references"},
|
||||
{MATCHING_SCORE_GREATER, "score_greater"},
|
||||
{MATCHING_SCORE_LOWER, "score_lower"},
|
||||
{MATCHING_SCORE_EQUAL, "score_equal"},
|
||||
{MATCHCRITERIA_SUBJECT, "subject"},
|
||||
{MATCHCRITERIA_NOT_SUBJECT, "~subject"},
|
||||
{MATCHCRITERIA_FROM, "from"},
|
||||
{MATCHCRITERIA_NOT_FROM, "~from"},
|
||||
{MATCHCRITERIA_TO, "to"},
|
||||
{MATCHCRITERIA_NOT_TO, "~to"},
|
||||
{MATCHCRITERIA_CC, "cc"},
|
||||
{MATCHCRITERIA_NOT_CC, "~cc"},
|
||||
{MATCHCRITERIA_TO_OR_CC, "to_or_cc"},
|
||||
{MATCHCRITERIA_NOT_TO_AND_NOT_CC, "~to_or_cc"},
|
||||
{MATCHCRITERIA_AGE_GREATER, "age_greater"},
|
||||
{MATCHCRITERIA_AGE_LOWER, "age_lower"},
|
||||
{MATCHCRITERIA_NEWSGROUPS, "newsgroups"},
|
||||
{MATCHCRITERIA_NOT_NEWSGROUPS, "~newsgroups"},
|
||||
{MATCHCRITERIA_INREPLYTO, "inreplyto"},
|
||||
{MATCHCRITERIA_NOT_INREPLYTO, "~inreplyto"},
|
||||
{MATCHCRITERIA_REFERENCES, "references"},
|
||||
{MATCHCRITERIA_NOT_REFERENCES, "~references"},
|
||||
{MATCHCRITERIA_SCORE_GREATER, "score_greater"},
|
||||
{MATCHCRITERIA_SCORE_LOWER, "score_lower"},
|
||||
{MATCHCRITERIA_SCORE_EQUAL, "score_equal"},
|
||||
|
||||
/* content have to be read */
|
||||
{MATCHING_HEADER, "header"},
|
||||
{MATCHING_NOT_HEADER, "~header"},
|
||||
{MATCHING_HEADERS_PART, "headers_part"},
|
||||
{MATCHING_NOT_HEADERS_PART, "~headers_part"},
|
||||
{MATCHING_MESSAGE, "message"},
|
||||
{MATCHING_NOT_MESSAGE, "~message"},
|
||||
{MATCHING_BODY_PART, "body_part"},
|
||||
{MATCHING_NOT_BODY_PART, "~body_part"},
|
||||
{MATCHING_EXECUTE, "execute"},
|
||||
{MATCHING_NOT_EXECUTE, "~execute"},
|
||||
{MATCHCRITERIA_HEADER, "header"},
|
||||
{MATCHCRITERIA_NOT_HEADER, "~header"},
|
||||
{MATCHCRITERIA_HEADERS_PART, "headers_part"},
|
||||
{MATCHCRITERIA_NOT_HEADERS_PART, "~headers_part"},
|
||||
{MATCHCRITERIA_MESSAGE, "message"},
|
||||
{MATCHCRITERIA_NOT_MESSAGE, "~message"},
|
||||
{MATCHCRITERIA_BODY_PART, "body_part"},
|
||||
{MATCHCRITERIA_NOT_BODY_PART, "~body_part"},
|
||||
{MATCHCRITERIA_EXECUTE, "execute"},
|
||||
{MATCHCRITERIA_NOT_EXECUTE, "~execute"},
|
||||
|
||||
/* match type */
|
||||
{MATCHING_MATCHCASE, "matchcase"},
|
||||
{MATCHING_MATCH, "match"},
|
||||
{MATCHING_REGEXPCASE, "regexpcase"},
|
||||
{MATCHING_REGEXP, "regexp"},
|
||||
{MATCHTYPE_MATCHCASE, "matchcase"},
|
||||
{MATCHTYPE_MATCH, "match"},
|
||||
{MATCHTYPE_REGEXPCASE, "regexpcase"},
|
||||
{MATCHTYPE_REGEXP, "regexp"},
|
||||
|
||||
/* actions */
|
||||
{MATCHING_SCORE, "score"},
|
||||
|
||||
/* actions */
|
||||
{MATCHING_ACTION_MOVE, "move"},
|
||||
{MATCHING_ACTION_COPY, "copy"},
|
||||
{MATCHING_ACTION_DELETE, "delete"},
|
||||
{MATCHING_ACTION_MARK, "mark"},
|
||||
{MATCHING_ACTION_UNMARK, "unmark"},
|
||||
{MATCHING_ACTION_MARK_AS_READ, "mark_as_read"},
|
||||
{MATCHING_ACTION_MARK_AS_UNREAD, "mark_as_unread"},
|
||||
{MATCHING_ACTION_FORWARD, "forward"},
|
||||
{MATCHING_ACTION_FORWARD_AS_ATTACHMENT, "forward_as_attachment"},
|
||||
{MATCHING_ACTION_COLOR, "color"}
|
||||
/* {MATCHING_EXECUTE, "execute"}, */
|
||||
{MATCHACTION_SCORE, "score"},
|
||||
{MATCHACTION_MOVE, "move"},
|
||||
{MATCHACTION_COPY, "copy"},
|
||||
{MATCHACTION_DELETE, "delete"},
|
||||
{MATCHACTION_MARK, "mark"},
|
||||
{MATCHACTION_UNMARK, "unmark"},
|
||||
{MATCHACTION_MARK_AS_READ, "mark_as_read"},
|
||||
{MATCHACTION_MARK_AS_UNREAD, "mark_as_unread"},
|
||||
{MATCHACTION_FORWARD, "forward"},
|
||||
{MATCHACTION_FORWARD_AS_ATTACHMENT, "forward_as_attachment"},
|
||||
{MATCHACTION_EXECUTE, "execute"},
|
||||
{MATCHACTION_COLOR, "color"},
|
||||
{MATCHACTION_BOUNCE, "bounce"}
|
||||
};
|
||||
|
||||
gchar * get_matchparser_tab_str(gint id)
|
||||
|
@ -138,6 +139,7 @@ gchar * get_matchparser_tab_str(gint id)
|
|||
subject match "regexp" | to regexpcase "regexp" | age_sup 5
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static gboolean matcher_is_blank(gchar ch);
|
||||
|
||||
/* ******************* parser *********************** */
|
||||
|
@ -167,11 +169,11 @@ MatcherProp * matcherprop_parse(gchar ** str)
|
|||
}
|
||||
|
||||
switch (key) {
|
||||
case MATCHING_AGE_LOWER:
|
||||
case MATCHING_AGE_GREATER:
|
||||
case MATCHING_SCORE_LOWER:
|
||||
case MATCHING_SCORE_GREATER:
|
||||
case MATCHING_SCORE_EQUAL:
|
||||
case MATCHCRITERIA_AGE_LOWER:
|
||||
case MATCHCRITERIA_AGE_GREATER:
|
||||
case MATCHCRITERIA_SCORE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_GREATER:
|
||||
case MATCHCRITERIA_SCORE_EQUAL:
|
||||
value = matcher_parse_number(&tmp);
|
||||
if (tmp == NULL) {
|
||||
* str = NULL;
|
||||
|
@ -183,51 +185,51 @@ MatcherProp * matcherprop_parse(gchar ** str)
|
|||
|
||||
return prop;
|
||||
|
||||
case MATCHING_ALL:
|
||||
case MATCHING_UNREAD:
|
||||
case MATCHING_NOT_UNREAD:
|
||||
case MATCHING_NEW:
|
||||
case MATCHING_NOT_NEW:
|
||||
case MATCHING_MARKED:
|
||||
case MATCHING_NOT_MARKED:
|
||||
case MATCHING_DELETED:
|
||||
case MATCHING_NOT_DELETED:
|
||||
case MATCHING_REPLIED:
|
||||
case MATCHING_NOT_REPLIED:
|
||||
case MATCHING_FORWARDED:
|
||||
case MATCHING_NOT_FORWARDED:
|
||||
case MATCHCRITERIA_ALL:
|
||||
case MATCHCRITERIA_UNREAD:
|
||||
case MATCHCRITERIA_NOT_UNREAD:
|
||||
case MATCHCRITERIA_NEW:
|
||||
case MATCHCRITERIA_NOT_NEW:
|
||||
case MATCHCRITERIA_MARKED:
|
||||
case MATCHCRITERIA_NOT_MARKED:
|
||||
case MATCHCRITERIA_DELETED:
|
||||
case MATCHCRITERIA_NOT_DELETED:
|
||||
case MATCHCRITERIA_REPLIED:
|
||||
case MATCHCRITERIA_NOT_REPLIED:
|
||||
case MATCHCRITERIA_FORWARDED:
|
||||
case MATCHCRITERIA_NOT_FORWARDED:
|
||||
prop = matcherprop_new(key, NULL, 0, NULL, 0);
|
||||
*str = tmp;
|
||||
|
||||
return prop;
|
||||
|
||||
case MATCHING_SUBJECT:
|
||||
case MATCHING_NOT_SUBJECT:
|
||||
case MATCHING_FROM:
|
||||
case MATCHING_NOT_FROM:
|
||||
case MATCHING_TO:
|
||||
case MATCHING_NOT_TO:
|
||||
case MATCHING_CC:
|
||||
case MATCHING_NOT_CC:
|
||||
case MATCHING_TO_OR_CC:
|
||||
case MATCHING_NOT_TO_AND_NOT_CC:
|
||||
case MATCHING_NEWSGROUPS:
|
||||
case MATCHING_NOT_NEWSGROUPS:
|
||||
case MATCHING_INREPLYTO:
|
||||
case MATCHING_NOT_REFERENCES:
|
||||
case MATCHING_REFERENCES:
|
||||
case MATCHING_NOT_INREPLYTO:
|
||||
case MATCHING_MESSAGE:
|
||||
case MATCHING_NOT_MESSAGE:
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHING_NOT_EXECUTE:
|
||||
case MATCHING_HEADERS_PART:
|
||||
case MATCHING_NOT_HEADERS_PART:
|
||||
case MATCHING_BODY_PART:
|
||||
case MATCHING_NOT_BODY_PART:
|
||||
case MATCHING_HEADER:
|
||||
case MATCHING_NOT_HEADER:
|
||||
if ((key == MATCHING_HEADER) || (key == MATCHING_NOT_HEADER)) {
|
||||
case MATCHCRITERIA_SUBJECT:
|
||||
case MATCHCRITERIA_NOT_SUBJECT:
|
||||
case MATCHCRITERIA_FROM:
|
||||
case MATCHCRITERIA_NOT_FROM:
|
||||
case MATCHCRITERIA_TO:
|
||||
case MATCHCRITERIA_NOT_TO:
|
||||
case MATCHCRITERIA_CC:
|
||||
case MATCHCRITERIA_NOT_CC:
|
||||
case MATCHCRITERIA_TO_OR_CC:
|
||||
case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
|
||||
case MATCHCRITERIA_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NOT_NEWSGROUPS:
|
||||
case MATCHCRITERIA_INREPLYTO:
|
||||
case MATCHCRITERIA_NOT_REFERENCES:
|
||||
case MATCHCRITERIA_REFERENCES:
|
||||
case MATCHCRITERIA_NOT_INREPLYTO:
|
||||
case MATCHCRITERIA_MESSAGE:
|
||||
case MATCHCRITERIA_NOT_MESSAGE:
|
||||
case MATCHCRITERIA_EXECUTE:
|
||||
case MATCHCRITERIA_NOT_EXECUTE:
|
||||
case MATCHCRITERIA_HEADERS_PART:
|
||||
case MATCHCRITERIA_NOT_HEADERS_PART:
|
||||
case MATCHCRITERIA_BODY_PART:
|
||||
case MATCHCRITERIA_NOT_BODY_PART:
|
||||
case MATCHCRITERIA_HEADER:
|
||||
case MATCHCRITERIA_NOT_HEADER:
|
||||
if ((key == MATCHCRITERIA_HEADER) || (key == MATCHCRITERIA_NOT_HEADER)) {
|
||||
header = matcher_parse_str(&tmp);
|
||||
if (tmp == NULL) {
|
||||
* str = NULL;
|
||||
|
@ -244,8 +246,8 @@ MatcherProp * matcherprop_parse(gchar ** str)
|
|||
}
|
||||
|
||||
switch(match) {
|
||||
case MATCHING_REGEXP:
|
||||
case MATCHING_REGEXPCASE:
|
||||
case MATCHCRITERIA_REGEXP:
|
||||
case MATCHCRITERIA_REGEXPCASE:
|
||||
expr = matcher_parse_regexp(&tmp);
|
||||
if (tmp == NULL) {
|
||||
if (header)
|
||||
|
@ -258,8 +260,8 @@ MatcherProp * matcherprop_parse(gchar ** str)
|
|||
g_free(expr);
|
||||
|
||||
return prop;
|
||||
case MATCHING_MATCH:
|
||||
case MATCHING_MATCHCASE:
|
||||
case MATCHCRITERIA_MATCH:
|
||||
case MATCHCRITERIA_MATCHCASE:
|
||||
expr = matcher_parse_str(&tmp);
|
||||
if (tmp == NULL) {
|
||||
if (header)
|
||||
|
@ -409,11 +411,13 @@ gchar * matcher_parse_regexp(gchar ** str)
|
|||
*str += p - dup + 2;
|
||||
return g_strdup(start);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* matcher_parse_str() - parses a string until it hits a
|
||||
* terminating \". to unescape characters use \. The string
|
||||
* should not be used directly: matcher_unescape_str()
|
||||
* returns a string that can be used directly. */
|
||||
#if 0
|
||||
gchar * matcher_parse_str(gchar ** str)
|
||||
{
|
||||
gchar * p;
|
||||
|
@ -450,6 +454,7 @@ gchar * matcher_parse_str(gchar ** str)
|
|||
*str += dest - dup + 2;
|
||||
return g_strdup(start);
|
||||
}
|
||||
#endif
|
||||
|
||||
gchar *matcher_unescape_str(gchar *str)
|
||||
{
|
||||
|
@ -534,13 +539,13 @@ static gboolean matcherprop_string_match(MatcherProp * prop, gchar * str)
|
|||
return FALSE;
|
||||
|
||||
switch(prop->matchtype) {
|
||||
case MATCHING_REGEXPCASE:
|
||||
case MATCHING_REGEXP:
|
||||
case MATCHTYPE_REGEXPCASE:
|
||||
case MATCHTYPE_REGEXP:
|
||||
if (!prop->preg && (prop->error == 0)) {
|
||||
prop->preg = g_new0(regex_t, 1);
|
||||
if (regcomp(prop->preg, prop->expr,
|
||||
REG_NOSUB | REG_EXTENDED
|
||||
| ((prop->matchtype == MATCHING_REGEXPCASE)
|
||||
| ((prop->matchtype == MATCHTYPE_REGEXPCASE)
|
||||
? REG_ICASE : 0)) != 0) {
|
||||
prop->error = 1;
|
||||
g_free(prop->preg);
|
||||
|
@ -554,10 +559,10 @@ static gboolean matcherprop_string_match(MatcherProp * prop, gchar * str)
|
|||
else
|
||||
return FALSE;
|
||||
|
||||
case MATCHING_MATCH:
|
||||
case MATCHTYPE_MATCH:
|
||||
return (strstr(str, prop->expr) != NULL);
|
||||
|
||||
case MATCHING_MATCHCASE:
|
||||
case MATCHTYPE_MATCHCASE:
|
||||
str2 = alloca(strlen(prop->expr) + 1);
|
||||
strcpy(str2, prop->expr);
|
||||
g_strup(str2);
|
||||
|
@ -590,81 +595,81 @@ gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info)
|
|||
time_t t;
|
||||
|
||||
switch(prop->criteria) {
|
||||
case MATCHING_ALL:
|
||||
case MATCHCRITERIA_ALL:
|
||||
return 1;
|
||||
case MATCHING_UNREAD:
|
||||
case MATCHCRITERIA_UNREAD:
|
||||
return MSG_IS_UNREAD(info->flags);
|
||||
case MATCHING_NOT_UNREAD:
|
||||
case MATCHCRITERIA_NOT_UNREAD:
|
||||
return !MSG_IS_UNREAD(info->flags);
|
||||
case MATCHING_NEW:
|
||||
case MATCHCRITERIA_NEW:
|
||||
return MSG_IS_NEW(info->flags);
|
||||
case MATCHING_NOT_NEW:
|
||||
case MATCHCRITERIA_NOT_NEW:
|
||||
return !MSG_IS_NEW(info->flags);
|
||||
case MATCHING_MARKED:
|
||||
case MATCHCRITERIA_MARKED:
|
||||
return MSG_IS_MARKED(info->flags);
|
||||
case MATCHING_NOT_MARKED:
|
||||
case MATCHCRITERIA_NOT_MARKED:
|
||||
return !MSG_IS_MARKED(info->flags);
|
||||
case MATCHING_DELETED:
|
||||
case MATCHCRITERIA_DELETED:
|
||||
return MSG_IS_DELETED(info->flags);
|
||||
case MATCHING_NOT_DELETED:
|
||||
case MATCHCRITERIA_NOT_DELETED:
|
||||
return !MSG_IS_DELETED(info->flags);
|
||||
case MATCHING_REPLIED:
|
||||
case MATCHCRITERIA_REPLIED:
|
||||
return MSG_IS_REPLIED(info->flags);
|
||||
case MATCHING_NOT_REPLIED:
|
||||
case MATCHCRITERIA_NOT_REPLIED:
|
||||
return !MSG_IS_REPLIED(info->flags);
|
||||
case MATCHING_FORWARDED:
|
||||
case MATCHCRITERIA_FORWARDED:
|
||||
return MSG_IS_FORWARDED(info->flags);
|
||||
case MATCHING_NOT_FORWARDED:
|
||||
case MATCHCRITERIA_NOT_FORWARDED:
|
||||
return !MSG_IS_FORWARDED(info->flags);
|
||||
case MATCHING_SUBJECT:
|
||||
case MATCHCRITERIA_SUBJECT:
|
||||
return matcherprop_string_match(prop, info->subject);
|
||||
case MATCHING_NOT_SUBJECT:
|
||||
case MATCHCRITERIA_NOT_SUBJECT:
|
||||
return !matcherprop_string_match(prop, info->subject);
|
||||
case MATCHING_FROM:
|
||||
case MATCHCRITERIA_FROM:
|
||||
return matcherprop_string_match(prop, info->from);
|
||||
case MATCHING_NOT_FROM:
|
||||
case MATCHCRITERIA_NOT_FROM:
|
||||
return !matcherprop_string_match(prop, info->from);
|
||||
case MATCHING_TO:
|
||||
case MATCHCRITERIA_TO:
|
||||
return matcherprop_string_match(prop, info->to);
|
||||
case MATCHING_NOT_TO:
|
||||
case MATCHCRITERIA_NOT_TO:
|
||||
return !matcherprop_string_match(prop, info->to);
|
||||
case MATCHING_CC:
|
||||
case MATCHCRITERIA_CC:
|
||||
return matcherprop_string_match(prop, info->cc);
|
||||
case MATCHING_NOT_CC:
|
||||
case MATCHCRITERIA_NOT_CC:
|
||||
return !matcherprop_string_match(prop, info->cc);
|
||||
case MATCHING_TO_OR_CC:
|
||||
case MATCHCRITERIA_TO_OR_CC:
|
||||
return matcherprop_string_match(prop, info->to)
|
||||
|| matcherprop_string_match(prop, info->cc);
|
||||
case MATCHING_NOT_TO_AND_NOT_CC:
|
||||
case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
|
||||
return !(matcherprop_string_match(prop, info->to)
|
||||
|| matcherprop_string_match(prop, info->cc));
|
||||
case MATCHING_AGE_GREATER:
|
||||
case MATCHCRITERIA_AGE_GREATER:
|
||||
t = time(NULL);
|
||||
return ((t - info->date_t) / (60 * 60 * 24)) >= prop->value;
|
||||
case MATCHING_AGE_LOWER:
|
||||
case MATCHCRITERIA_AGE_LOWER:
|
||||
t = time(NULL);
|
||||
return ((t - info->date_t) / (60 * 60 * 24)) <= prop->value;
|
||||
case MATCHING_SCORE_GREATER:
|
||||
case MATCHCRITERIA_SCORE_GREATER:
|
||||
return info->score >= prop->value;
|
||||
case MATCHING_SCORE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_LOWER:
|
||||
return info->score <= prop->value;
|
||||
case MATCHING_SCORE_EQUAL:
|
||||
case MATCHCRITERIA_SCORE_EQUAL:
|
||||
return info->score == prop->value;
|
||||
case MATCHING_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NEWSGROUPS:
|
||||
return matcherprop_string_match(prop, info->newsgroups);
|
||||
case MATCHING_NOT_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NOT_NEWSGROUPS:
|
||||
return !matcherprop_string_match(prop, info->newsgroups);
|
||||
case MATCHING_INREPLYTO:
|
||||
case MATCHCRITERIA_INREPLYTO:
|
||||
return matcherprop_string_match(prop, info->inreplyto);
|
||||
case MATCHING_NOT_INREPLYTO:
|
||||
case MATCHCRITERIA_NOT_INREPLYTO:
|
||||
return !matcherprop_string_match(prop, info->inreplyto);
|
||||
case MATCHING_REFERENCES:
|
||||
case MATCHCRITERIA_REFERENCES:
|
||||
return matcherprop_string_match(prop, info->references);
|
||||
case MATCHING_NOT_REFERENCES:
|
||||
case MATCHCRITERIA_NOT_REFERENCES:
|
||||
return !matcherprop_string_match(prop, info->references);
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHCRITERIA_EXECUTE:
|
||||
return matcherprop_match_execute(prop, info);
|
||||
case MATCHING_NOT_EXECUTE:
|
||||
case MATCHCRITERIA_NOT_EXECUTE:
|
||||
return !matcherprop_match_execute(prop, info);
|
||||
default:
|
||||
return 0;
|
||||
|
@ -676,6 +681,7 @@ gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info)
|
|||
|
||||
/* parse for a list of conditions */
|
||||
|
||||
/*
|
||||
MatcherList * matcherlist_parse(gchar ** str)
|
||||
{
|
||||
gchar * tmp;
|
||||
|
@ -728,6 +734,7 @@ MatcherList * matcherlist_parse(gchar ** str)
|
|||
|
||||
return cond;
|
||||
}
|
||||
*/
|
||||
|
||||
MatcherList * matcherlist_new(GSList * matchers, gboolean bool_and)
|
||||
{
|
||||
|
@ -775,14 +782,14 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
|
|||
Header *header;
|
||||
|
||||
switch(matcher->criteria) {
|
||||
case MATCHING_HEADER:
|
||||
case MATCHING_NOT_HEADER:
|
||||
case MATCHCRITERIA_HEADER:
|
||||
case MATCHCRITERIA_NOT_HEADER:
|
||||
header = procheader_parse_header(buf);
|
||||
if (!header)
|
||||
return FALSE;
|
||||
if (procheader_headername_equal(header->name,
|
||||
matcher->header)) {
|
||||
if (matcher->criteria == MATCHING_HEADER)
|
||||
if (matcher->criteria == MATCHCRITERIA_HEADER)
|
||||
result = matcherprop_string_match(matcher, header->body);
|
||||
else
|
||||
result = !matcherprop_string_match(matcher, header->body);
|
||||
|
@ -793,11 +800,11 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
|
|||
procheader_header_free(header);
|
||||
}
|
||||
break;
|
||||
case MATCHING_HEADERS_PART:
|
||||
case MATCHING_MESSAGE:
|
||||
case MATCHCRITERIA_HEADERS_PART:
|
||||
case MATCHCRITERIA_MESSAGE:
|
||||
return matcherprop_string_match(matcher, buf);
|
||||
case MATCHING_NOT_MESSAGE:
|
||||
case MATCHING_NOT_HEADERS_PART:
|
||||
case MATCHCRITERIA_NOT_MESSAGE:
|
||||
case MATCHCRITERIA_NOT_HEADERS_PART:
|
||||
return !matcherprop_string_match(matcher, buf);
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -811,10 +818,10 @@ static gboolean matcherprop_match_one_header(MatcherProp * matcher,
|
|||
static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
|
||||
{
|
||||
switch(matcher->criteria) {
|
||||
case MATCHING_HEADER:
|
||||
case MATCHING_NOT_HEADER:
|
||||
case MATCHING_HEADERS_PART:
|
||||
case MATCHING_NOT_HEADERS_PART:
|
||||
case MATCHCRITERIA_HEADER:
|
||||
case MATCHCRITERIA_NOT_HEADER:
|
||||
case MATCHCRITERIA_HEADERS_PART:
|
||||
case MATCHCRITERIA_NOT_HEADERS_PART:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -824,8 +831,8 @@ static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
|
|||
static gboolean matcherprop_criteria_message(MatcherProp * matcher)
|
||||
{
|
||||
switch(matcher->criteria) {
|
||||
case MATCHING_MESSAGE:
|
||||
case MATCHING_NOT_MESSAGE:
|
||||
case MATCHCRITERIA_MESSAGE:
|
||||
case MATCHCRITERIA_NOT_MESSAGE:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -887,8 +894,8 @@ static gboolean matcherlist_match_headers(MatcherList * matchers, FILE * fp)
|
|||
static gboolean matcherprop_criteria_body(MatcherProp * matcher)
|
||||
{
|
||||
switch(matcher->criteria) {
|
||||
case MATCHING_BODY_PART:
|
||||
case MATCHING_NOT_BODY_PART:
|
||||
case MATCHCRITERIA_BODY_PART:
|
||||
case MATCHCRITERIA_NOT_BODY_PART:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -903,11 +910,11 @@ static gboolean matcherprop_criteria_body(MatcherProp * matcher)
|
|||
static gboolean matcherprop_match_line(MatcherProp * matcher, gchar * line)
|
||||
{
|
||||
switch(matcher->criteria) {
|
||||
case MATCHING_BODY_PART:
|
||||
case MATCHING_MESSAGE:
|
||||
case MATCHCRITERIA_BODY_PART:
|
||||
case MATCHCRITERIA_MESSAGE:
|
||||
return matcherprop_string_match(matcher, line);
|
||||
case MATCHING_NOT_BODY_PART:
|
||||
case MATCHING_NOT_MESSAGE:
|
||||
case MATCHCRITERIA_NOT_BODY_PART:
|
||||
case MATCHCRITERIA_NOT_MESSAGE:
|
||||
return !matcherprop_string_match(matcher, line);
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -1059,42 +1066,42 @@ gboolean matcherlist_match(MatcherList * matchers, MsgInfo * info)
|
|||
MatcherProp * matcher = (MatcherProp *) l->data;
|
||||
|
||||
switch(matcher->criteria) {
|
||||
case MATCHING_ALL:
|
||||
case MATCHING_UNREAD:
|
||||
case MATCHING_NOT_UNREAD:
|
||||
case MATCHING_NEW:
|
||||
case MATCHING_NOT_NEW:
|
||||
case MATCHING_MARKED:
|
||||
case MATCHING_NOT_MARKED:
|
||||
case MATCHING_DELETED:
|
||||
case MATCHING_NOT_DELETED:
|
||||
case MATCHING_REPLIED:
|
||||
case MATCHING_NOT_REPLIED:
|
||||
case MATCHING_FORWARDED:
|
||||
case MATCHING_NOT_FORWARDED:
|
||||
case MATCHING_SUBJECT:
|
||||
case MATCHING_NOT_SUBJECT:
|
||||
case MATCHING_FROM:
|
||||
case MATCHING_NOT_FROM:
|
||||
case MATCHING_TO:
|
||||
case MATCHING_NOT_TO:
|
||||
case MATCHING_CC:
|
||||
case MATCHING_NOT_CC:
|
||||
case MATCHING_TO_OR_CC:
|
||||
case MATCHING_NOT_TO_AND_NOT_CC:
|
||||
case MATCHING_AGE_GREATER:
|
||||
case MATCHING_AGE_LOWER:
|
||||
case MATCHING_NEWSGROUPS:
|
||||
case MATCHING_NOT_NEWSGROUPS:
|
||||
case MATCHING_INREPLYTO:
|
||||
case MATCHING_NOT_INREPLYTO:
|
||||
case MATCHING_REFERENCES:
|
||||
case MATCHING_NOT_REFERENCES:
|
||||
case MATCHING_SCORE_GREATER:
|
||||
case MATCHING_SCORE_LOWER:
|
||||
case MATCHING_SCORE_EQUAL:
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHING_NOT_EXECUTE:
|
||||
case MATCHCRITERIA_ALL:
|
||||
case MATCHCRITERIA_UNREAD:
|
||||
case MATCHCRITERIA_NOT_UNREAD:
|
||||
case MATCHCRITERIA_NEW:
|
||||
case MATCHCRITERIA_NOT_NEW:
|
||||
case MATCHCRITERIA_MARKED:
|
||||
case MATCHCRITERIA_NOT_MARKED:
|
||||
case MATCHCRITERIA_DELETED:
|
||||
case MATCHCRITERIA_NOT_DELETED:
|
||||
case MATCHCRITERIA_REPLIED:
|
||||
case MATCHCRITERIA_NOT_REPLIED:
|
||||
case MATCHCRITERIA_FORWARDED:
|
||||
case MATCHCRITERIA_NOT_FORWARDED:
|
||||
case MATCHCRITERIA_SUBJECT:
|
||||
case MATCHCRITERIA_NOT_SUBJECT:
|
||||
case MATCHCRITERIA_FROM:
|
||||
case MATCHCRITERIA_NOT_FROM:
|
||||
case MATCHCRITERIA_TO:
|
||||
case MATCHCRITERIA_NOT_TO:
|
||||
case MATCHCRITERIA_CC:
|
||||
case MATCHCRITERIA_NOT_CC:
|
||||
case MATCHCRITERIA_TO_OR_CC:
|
||||
case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
|
||||
case MATCHCRITERIA_AGE_GREATER:
|
||||
case MATCHCRITERIA_AGE_LOWER:
|
||||
case MATCHCRITERIA_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NOT_NEWSGROUPS:
|
||||
case MATCHCRITERIA_INREPLYTO:
|
||||
case MATCHCRITERIA_NOT_INREPLYTO:
|
||||
case MATCHCRITERIA_REFERENCES:
|
||||
case MATCHCRITERIA_NOT_REFERENCES:
|
||||
case MATCHCRITERIA_SCORE_GREATER:
|
||||
case MATCHCRITERIA_SCORE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_EQUAL:
|
||||
case MATCHCRITERIA_EXECUTE:
|
||||
case MATCHCRITERIA_NOT_EXECUTE:
|
||||
if (matcherprop_match(matcher, info)) {
|
||||
if (!matchers->bool_and) {
|
||||
return TRUE;
|
||||
|
@ -1133,16 +1140,16 @@ static void matcherprop_print(MatcherProp * matcher)
|
|||
}
|
||||
|
||||
switch (matcher->matchtype) {
|
||||
case MATCHING_MATCH:
|
||||
case MATCHCRITERIA_MATCH:
|
||||
printf("match\n");
|
||||
break;
|
||||
case MATCHING_REGEXP:
|
||||
case MATCHCRITERIA_REGEXP:
|
||||
printf("regexp\n");
|
||||
break;
|
||||
case MATCHING_MATCHCASE:
|
||||
case MATCHCRITERIA_MATCHCASE:
|
||||
printf("matchcase\n");
|
||||
break;
|
||||
case MATCHING_REGEXPCASE:
|
||||
case MATCHCRITERIA_REGEXPCASE:
|
||||
printf("regexpcase\n");
|
||||
break;
|
||||
}
|
||||
|
@ -1184,26 +1191,26 @@ gchar * matcherprop_to_string(MatcherProp * matcher)
|
|||
return NULL;
|
||||
|
||||
switch(matcher->criteria) {
|
||||
case MATCHING_AGE_GREATER:
|
||||
case MATCHING_AGE_LOWER:
|
||||
case MATCHING_SCORE_GREATER:
|
||||
case MATCHING_SCORE_LOWER:
|
||||
case MATCHING_SCORE_EQUAL:
|
||||
case MATCHCRITERIA_AGE_GREATER:
|
||||
case MATCHCRITERIA_AGE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_GREATER:
|
||||
case MATCHCRITERIA_SCORE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_EQUAL:
|
||||
return g_strdup_printf("%s %i", criteria_str, matcher->value);
|
||||
break;
|
||||
case MATCHING_ALL:
|
||||
case MATCHING_UNREAD:
|
||||
case MATCHING_NOT_UNREAD:
|
||||
case MATCHING_NEW:
|
||||
case MATCHING_NOT_NEW:
|
||||
case MATCHING_MARKED:
|
||||
case MATCHING_NOT_MARKED:
|
||||
case MATCHING_DELETED:
|
||||
case MATCHING_NOT_DELETED:
|
||||
case MATCHING_REPLIED:
|
||||
case MATCHING_NOT_REPLIED:
|
||||
case MATCHING_FORWARDED:
|
||||
case MATCHING_NOT_FORWARDED:
|
||||
case MATCHCRITERIA_ALL:
|
||||
case MATCHCRITERIA_UNREAD:
|
||||
case MATCHCRITERIA_NOT_UNREAD:
|
||||
case MATCHCRITERIA_NEW:
|
||||
case MATCHCRITERIA_NOT_NEW:
|
||||
case MATCHCRITERIA_MARKED:
|
||||
case MATCHCRITERIA_NOT_MARKED:
|
||||
case MATCHCRITERIA_DELETED:
|
||||
case MATCHCRITERIA_NOT_DELETED:
|
||||
case MATCHCRITERIA_REPLIED:
|
||||
case MATCHCRITERIA_NOT_REPLIED:
|
||||
case MATCHCRITERIA_FORWARDED:
|
||||
case MATCHCRITERIA_NOT_FORWARDED:
|
||||
return g_strdup(criteria_str);
|
||||
}
|
||||
|
||||
|
@ -1218,8 +1225,8 @@ gchar * matcherprop_to_string(MatcherProp * matcher)
|
|||
return NULL;
|
||||
|
||||
switch (matcher->matchtype) {
|
||||
case MATCHING_MATCH:
|
||||
case MATCHING_MATCHCASE:
|
||||
case MATCHTYPE_MATCH:
|
||||
case MATCHTYPE_MATCHCASE:
|
||||
count = 0;
|
||||
for(p = matcher->expr; *p != 0 ; p++)
|
||||
if (*p == '\"') count ++;
|
||||
|
@ -1250,8 +1257,8 @@ gchar * matcherprop_to_string(MatcherProp * matcher)
|
|||
|
||||
break;
|
||||
|
||||
case MATCHING_REGEXP:
|
||||
case MATCHING_REGEXPCASE:
|
||||
case MATCHTYPE_REGEXP:
|
||||
case MATCHTYPE_REGEXPCASE:
|
||||
|
||||
if (matcher->header)
|
||||
matcher_str =
|
||||
|
@ -1469,12 +1476,182 @@ gchar * matching_build_command(gchar * cmd, MsgInfo * info)
|
|||
}
|
||||
|
||||
|
||||
/* ************************************************************ */
|
||||
/* ************************************************************ */
|
||||
/* ************************************************************ */
|
||||
/* ************************************************************ */
|
||||
/* ************************************************************ */
|
||||
|
||||
/*
|
||||
static void matcher_parse (gchar * str)
|
||||
|
||||
static void prefs_scoring_write(FILE * fp, GSList * prefs_scoring)
|
||||
{
|
||||
matcher_parser_scan_string(str);
|
||||
matcher_parserparse();
|
||||
GSList * cur;
|
||||
|
||||
for (cur = prefs_scoring; cur != NULL; cur = cur->next) {
|
||||
gchar *scoring_str;
|
||||
ScoringProp * prop;
|
||||
|
||||
prop = (ScoringProp *) cur->data;
|
||||
scoring_str = scoringprop_to_string(prop);
|
||||
if (fputs(scoring_str, fp) == EOF ||
|
||||
fputc('\n', fp) == EOF) {
|
||||
FILE_OP_ERROR("scoring config", "fputs || fputc");
|
||||
g_free(scoring_str);
|
||||
return;
|
||||
}
|
||||
g_free(scoring_str);
|
||||
}
|
||||
}
|
||||
|
||||
static void prefs_filtering_write(FILE * fp, GSList * prefs_scoring)
|
||||
{
|
||||
GSList * cur;
|
||||
|
||||
for (cur = prefs_scoring; cur != NULL; cur = cur->next) {
|
||||
gchar *filtering_str;
|
||||
FilteringProp * prop;
|
||||
|
||||
prop = (FilteringProp *) cur->data;
|
||||
filtering_str = filteringprop_to_string(prop);
|
||||
|
||||
if (fputs(filtering_str, fp) == EOF ||
|
||||
fputc('\n', fp) == EOF) {
|
||||
FILE_OP_ERROR("filtering config", "fputs || fputc");
|
||||
g_free(filtering_str);
|
||||
return;
|
||||
}
|
||||
g_free(filtering_str);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean prefs_matcher_write_func(GNode *node, gpointer data)
|
||||
{
|
||||
FolderItem *item;
|
||||
FILE * fp = data;
|
||||
gchar * id;
|
||||
GSList * prefs_scoring;
|
||||
GSList * prefs_filtering;
|
||||
|
||||
if (node != NULL) {
|
||||
item = node->data;
|
||||
/* prevent from the warning */
|
||||
if (item->path == NULL)
|
||||
return FALSE;
|
||||
id = folder_item_get_identifier(item);
|
||||
if (id == NULL)
|
||||
return FALSE;
|
||||
prefs_scoring = item->prefs->scoring;
|
||||
prefs_filtering = item->prefs->processing;
|
||||
}
|
||||
else {
|
||||
item = NULL;
|
||||
id = g_strdup("global"); /* because it is g_freed */
|
||||
prefs_scoring = global_scoring;
|
||||
prefs_filtering = global_processing;
|
||||
}
|
||||
|
||||
if (prefs_filtering != NULL || prefs_scoring != NULL) {
|
||||
fprintf(fp, "[%s]\n", id);
|
||||
|
||||
prefs_filtering_write(fp, prefs_filtering);
|
||||
prefs_scoring_write(fp, prefs_scoring);
|
||||
|
||||
fputc('\n', fp);
|
||||
}
|
||||
|
||||
g_free(id);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void prefs_matcher_save(FILE * fp)
|
||||
{
|
||||
GList * cur;
|
||||
|
||||
for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
|
||||
Folder *folder;
|
||||
|
||||
folder = (Folder *) cur->data;
|
||||
g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
|
||||
prefs_matcher_write_func, fp);
|
||||
}
|
||||
prefs_matcher_write_func(NULL, fp);
|
||||
}
|
||||
|
||||
|
||||
void prefs_matcher_write_config(void)
|
||||
{
|
||||
gchar *rcpath;
|
||||
PrefFile *pfile;
|
||||
GSList *cur;
|
||||
ScoringProp * prop;
|
||||
|
||||
debug_print(_("Writing matcher configuration...\n"));
|
||||
|
||||
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
|
||||
MATCHER_RC, NULL);
|
||||
|
||||
if ((pfile = prefs_write_open(rcpath)) == NULL) {
|
||||
g_warning(_("failed to write configuration to file\n"));
|
||||
g_free(rcpath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
prefs_matcher_save(pfile->fp);
|
||||
|
||||
g_free(rcpath);
|
||||
|
||||
if (prefs_write_close(pfile) < 0) {
|
||||
g_warning(_("failed to write configuration to file\n"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ******************************************************************* */
|
||||
|
||||
void prefs_matcher_read_config(void)
|
||||
{
|
||||
gchar * rcpath;
|
||||
FILE * f;
|
||||
|
||||
prefs_scoring_clear();
|
||||
prefs_filtering_clear();
|
||||
|
||||
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MATCHER_RC, NULL);
|
||||
f = fopen(rcpath, "r");
|
||||
g_free(rcpath);
|
||||
|
||||
if (f != NULL)
|
||||
matcher_parser_start_parsing(f);
|
||||
else {
|
||||
/* previous version compatibily */
|
||||
|
||||
printf("reading filtering\n");
|
||||
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
|
||||
FILTERING_RC, NULL);
|
||||
f = fopen(rcpath, "r");
|
||||
g_free(rcpath);
|
||||
|
||||
if (f != NULL) {
|
||||
matcher_parser_start_parsing(f);
|
||||
fclose(matcher_parserin);
|
||||
}
|
||||
|
||||
printf("reading scoring\n");
|
||||
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
|
||||
SCORING_RC, NULL);
|
||||
f = fopen(rcpath, "r");
|
||||
g_free(rcpath);
|
||||
|
||||
if (f != NULL) {
|
||||
matcher_parser_start_parsing(f);
|
||||
fclose(matcher_parserin);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,77 @@
|
|||
#include <glib.h>
|
||||
#include "procmsg.h"
|
||||
|
||||
struct _MatcherProp {
|
||||
int matchtype;
|
||||
int criteria;
|
||||
gchar * header;
|
||||
gchar * expr;
|
||||
int value;
|
||||
regex_t * preg;
|
||||
int error;
|
||||
gboolean result;
|
||||
};
|
||||
|
||||
typedef struct _MatcherProp MatcherProp;
|
||||
|
||||
struct _MatcherList {
|
||||
GSList * matchers;
|
||||
gboolean bool_and;
|
||||
};
|
||||
|
||||
typedef struct _MatcherList MatcherList;
|
||||
|
||||
|
||||
enum {
|
||||
/* match */
|
||||
MATCHCRITERIA_ALL,
|
||||
MATCHCRITERIA_UNREAD, MATCHCRITERIA_NOT_UNREAD,
|
||||
MATCHCRITERIA_NEW, MATCHCRITERIA_NOT_NEW,
|
||||
MATCHCRITERIA_MARKED, MATCHCRITERIA_NOT_MARKED,
|
||||
MATCHCRITERIA_DELETED, MATCHCRITERIA_NOT_DELETED,
|
||||
MATCHCRITERIA_REPLIED, MATCHCRITERIA_NOT_REPLIED,
|
||||
MATCHCRITERIA_FORWARDED, MATCHCRITERIA_NOT_FORWARDED,
|
||||
MATCHCRITERIA_SUBJECT, MATCHCRITERIA_NOT_SUBJECT,
|
||||
MATCHCRITERIA_FROM, MATCHCRITERIA_NOT_FROM,
|
||||
MATCHCRITERIA_TO, MATCHCRITERIA_NOT_TO,
|
||||
MATCHCRITERIA_CC, MATCHCRITERIA_NOT_CC,
|
||||
MATCHCRITERIA_TO_OR_CC, MATCHCRITERIA_NOT_TO_AND_NOT_CC,
|
||||
MATCHCRITERIA_AGE_GREATER, MATCHCRITERIA_AGE_LOWER,
|
||||
MATCHCRITERIA_NEWSGROUPS, MATCHCRITERIA_NOT_NEWSGROUPS,
|
||||
MATCHCRITERIA_INREPLYTO, MATCHCRITERIA_NOT_INREPLYTO,
|
||||
MATCHCRITERIA_REFERENCES, MATCHCRITERIA_NOT_REFERENCES,
|
||||
MATCHCRITERIA_SCORE_GREATER, MATCHCRITERIA_SCORE_LOWER,
|
||||
MATCHCRITERIA_HEADER, MATCHCRITERIA_NOT_HEADER,
|
||||
MATCHCRITERIA_HEADERS_PART, MATCHCRITERIA_NOT_HEADERS_PART,
|
||||
MATCHCRITERIA_MESSAGE, MATCHCRITERIA_NOT_MESSAGE,
|
||||
MATCHCRITERIA_BODY_PART, MATCHCRITERIA_NOT_BODY_PART,
|
||||
MATCHCRITERIA_EXECUTE, MATCHCRITERIA_NOT_EXECUTE,
|
||||
MATCHCRITERIA_SCORE_EQUAL,
|
||||
/* match type */
|
||||
MATCHTYPE_MATCHCASE,
|
||||
MATCHTYPE_MATCH,
|
||||
MATCHTYPE_REGEXPCASE,
|
||||
MATCHTYPE_REGEXP,
|
||||
/* actions */
|
||||
MATCHACTION_SCORE,
|
||||
MATCHACTION_EXECUTE,
|
||||
MATCHACTION_MOVE,
|
||||
MATCHACTION_COPY,
|
||||
MATCHACTION_DELETE,
|
||||
MATCHACTION_MARK,
|
||||
MATCHACTION_UNMARK,
|
||||
MATCHACTION_MARK_AS_READ,
|
||||
MATCHACTION_MARK_AS_UNREAD,
|
||||
MATCHACTION_FORWARD,
|
||||
MATCHACTION_FORWARD_AS_ATTACHMENT,
|
||||
MATCHACTION_COLOR,
|
||||
MATCHACTION_BOUNCE,
|
||||
/* boolean operations */
|
||||
MATCHERBOOL_OR,
|
||||
MATCHERBOOL_AND,
|
||||
};
|
||||
|
||||
#if 0
|
||||
enum {
|
||||
/* msginfo flags */
|
||||
MATCHING_ALL,
|
||||
|
@ -79,26 +150,7 @@ enum {
|
|||
MATCHING_MATCHCASE,
|
||||
MATCHING_REGEXPCASE
|
||||
};
|
||||
|
||||
struct _MatcherProp {
|
||||
int matchtype;
|
||||
int criteria;
|
||||
gchar * header;
|
||||
gchar * expr;
|
||||
int value;
|
||||
regex_t * preg;
|
||||
int error;
|
||||
gboolean result;
|
||||
};
|
||||
|
||||
typedef struct _MatcherProp MatcherProp;
|
||||
|
||||
struct _MatcherList {
|
||||
GSList * matchers;
|
||||
gboolean bool_and;
|
||||
};
|
||||
|
||||
typedef struct _MatcherList MatcherList;
|
||||
#endif
|
||||
|
||||
gchar * get_matchparser_tab_str(gint id);
|
||||
MatcherProp * matcherprop_new(gint criteria, gchar * header,
|
||||
|
@ -125,4 +177,9 @@ gchar * matcherprop_to_string(MatcherProp * matcher);
|
|||
gchar * matcherlist_to_string(MatcherList * matchers);
|
||||
gchar * matching_build_command(gchar * cmd, MsgInfo * info);
|
||||
|
||||
|
||||
void prefs_matcher_read_config(void);
|
||||
void prefs_matcher_write_config(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,66 +6,20 @@
|
|||
#include "scoring.h"
|
||||
#include <glib.h>
|
||||
|
||||
#define MATCHER_BUF_SIZE 16384
|
||||
|
||||
enum {
|
||||
MATCHTYPE_MATCH,
|
||||
MATCHTYPE_MATCHCASE,
|
||||
MATCHTYPE_REGEXP,
|
||||
MATCHTYPE_REGEXPCASE
|
||||
};
|
||||
|
||||
enum {
|
||||
MATCHCRITERIA_ALL,
|
||||
MATCHCRITERIA_UNREAD, MATCHCRITERIA_NOT_UNREAD,
|
||||
MATCHCRITERIA_NEW, MATCHCRITERIA_NOT_NEW,
|
||||
MATCHCRITERIA_MARKED, MATCHCRITERIA_NOT_MARKED,
|
||||
MATCHCRITERIA_DELETED, MATCHCRITERIA_NOT_DELETED,
|
||||
MATCHCRITERIA_REPLIED, MATCHCRITERIA_NOT_REPLIED,
|
||||
MATCHCRITERIA_FORWARDED, MATCHCRITERIA_NOT_FORWARDED,
|
||||
MATCHCRITERIA_SUBJECT, MATCHCRITERIA_NOT_SUBJECT,
|
||||
MATCHCRITERIA_FROM, MATCHCRITERIA_NOT_FROM,
|
||||
MATCHCRITERIA_TO, MATCHCRITERIA_NOT_TO,
|
||||
MATCHCRITERIA_CC, MATCHCRITERIA_NOT_CC,
|
||||
MATCHCRITERIA_TO_OR_CC, MATCHCRITERIA_NOT_TO_AND_NOT_CC,
|
||||
MATCHCRITERIA_AGE_GREATER, MATCHCRITERIA_AGE_LOWER,
|
||||
MATCHCRITERIA_NEWSGROUPS, MATCHCRITERIA_NOT_NEWSGROUPS,
|
||||
MATCHCRITERIA_INREPLYTO, MATCHCRITERIA_NOT_INREPLYTO,
|
||||
MATCHCRITERIA_REFERENCES, MATCHCRITERIA_NOT_REFERENCES,
|
||||
MATCHCRITERIA_SCORE_GREATER, MATCHCRITERIA_SCORE_LOWER,
|
||||
MATCHCRITERIA_HEADER, MATCHCRITERIA_NOT_HEADER,
|
||||
MATCHCRITERIA_HEADERS_PART, MATCHCRITERIA_NOT_HEADERS_PART,
|
||||
MATCHCRITERIA_MESSAGE, MATCHCRITERIA_NOT_MESSAGE,
|
||||
MATCHCRITERIA_BODY_PART, MATCHCRITERIA_NOT_BODY_PART,
|
||||
MATCHCRITERIA_EXECUTE, MATCHCRITERIA_NOT_EXECUTE
|
||||
};
|
||||
|
||||
enum {
|
||||
MATCHACTION_SCORE,
|
||||
MATCHACTION_EXECUTE,
|
||||
MATCHACTION_MOVE,
|
||||
MATCHACTION_COPY,
|
||||
MATCHACTION_DELETE,
|
||||
MATCHACTION_MARK,
|
||||
MATCHACTION_UNMARK,
|
||||
MATCHACTION_MARK_AS_READ,
|
||||
MATCHACTION_MARK_AS_UNREAD,
|
||||
MATCHACTION_FORWARD,
|
||||
MATCHACTION_FORWARD_AS_ATTACHMENT
|
||||
};
|
||||
|
||||
enum {
|
||||
MATCHERBOOL_OR,
|
||||
MATCHERBOOL_AND,
|
||||
};
|
||||
// #define MATCHER_BUF_SIZE 16384
|
||||
|
||||
extern FILE *matcher_parserin;
|
||||
extern int matcher_parserlineno;
|
||||
|
||||
|
||||
void matcher_parser_start_parsing(FILE * f);
|
||||
int matcher_parserparse(void);
|
||||
/* void matcher_parser_init();*/
|
||||
|
||||
MatcherList * matcher_parser_get_cond(gchar * str);
|
||||
MatcherProp * matcher_parser_get_prop(gchar * str);
|
||||
FilteringProp * matcher_parser_get_filtering(gchar * str);
|
||||
ScoringProp * matcher_parser_get_scoring(gchar * str);
|
||||
/* void matcher_parser_read_config(); */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,7 @@ static void add_char(char ch)
|
|||
"~references" return MATCHER_NOT_REFERENCES;
|
||||
"score_greater" return MATCHER_SCORE_GREATER;
|
||||
"score_lower" return MATCHER_SCORE_LOWER;
|
||||
"score_equal" return MATCHER_SCORE_EQUAL;
|
||||
"header" return MATCHER_HEADER;
|
||||
"~header" return MATCHER_NOT_HEADER;
|
||||
"headers_part" return MATCHER_HEADERS_PART;
|
||||
|
@ -81,6 +82,8 @@ static void add_char(char ch)
|
|||
"mark_as_unread" return MATCHER_MARK_AS_UNREAD;
|
||||
"forward" return MATCHER_FORWARD;
|
||||
"forward_as_attachment" return MATCHER_FORWARD_AS_ATTACHMENT;
|
||||
"color" return MATCHER_COLOR;
|
||||
"bounce" return MATCHER_BOUNCE;
|
||||
[ \t]+
|
||||
"\n" return MATCHER_EOL;
|
||||
"&" return MATCHER_AND;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "matcher_parser_lex.h"
|
||||
#include "intl.h"
|
||||
#include <glib.h>
|
||||
#include "defs.h"
|
||||
#include "utils.h"
|
||||
|
||||
static gint error = 0;
|
||||
static gint bool_op = 0;
|
||||
|
@ -28,14 +30,28 @@ static GSList ** prefs_filtering = NULL;
|
|||
|
||||
static int matcher_parser_dialog = 0;
|
||||
|
||||
|
||||
/* ******************************************************************** */
|
||||
|
||||
|
||||
|
||||
void matcher_parser_start_parsing(FILE * f)
|
||||
{
|
||||
matcher_parserrestart(f);
|
||||
matcher_parserparse();
|
||||
}
|
||||
|
||||
FilteringProp * matcher_parser_get_filtering(gchar * str)
|
||||
{
|
||||
void * bufstate;
|
||||
|
||||
/* bad coding to enable the sub-grammar matching
|
||||
in yacc */
|
||||
matcher_parserlineno = 1;
|
||||
matcher_parser_dialog = 1;
|
||||
bufstate = matcher_parser_scan_string(str);
|
||||
matcher_parserparse();
|
||||
if (matcher_parserparse() != 0)
|
||||
filtering = NULL;
|
||||
matcher_parser_dialog = 0;
|
||||
matcher_parser_delete_buffer(bufstate);
|
||||
return filtering;
|
||||
|
@ -45,10 +61,13 @@ ScoringProp * matcher_parser_get_scoring(gchar * str)
|
|||
{
|
||||
void * bufstate;
|
||||
|
||||
/* bad coding to enable the sub-grammar matching
|
||||
in yacc */
|
||||
matcher_parserlineno = 1;
|
||||
matcher_parser_dialog = 1;
|
||||
bufstate = matcher_parser_scan_string(str);
|
||||
matcher_parserparse();
|
||||
if (matcher_parserparse() != 0)
|
||||
scoring = NULL;
|
||||
matcher_parser_dialog = 0;
|
||||
matcher_parser_delete_buffer(bufstate);
|
||||
return scoring;
|
||||
|
@ -58,6 +77,8 @@ MatcherList * matcher_parser_get_cond(gchar * str)
|
|||
{
|
||||
void * bufstate;
|
||||
|
||||
/* bad coding to enable the sub-grammar matching
|
||||
in yacc */
|
||||
matcher_parserlineno = 1;
|
||||
matcher_parser_dialog = 1;
|
||||
bufstate = matcher_parser_scan_string(str);
|
||||
|
@ -87,6 +108,8 @@ MatcherProp * matcher_parser_get_prop(gchar * str)
|
|||
|
||||
g_slist_free(list->matchers);
|
||||
g_free(list);
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
void matcher_parsererror(char * str)
|
||||
|
@ -137,6 +160,7 @@ int matcher_parserwrap(void)
|
|||
%token MATCHER_MARK_AS_READ MATCHER_MARK_AS_UNREAD MATCHER_FORWARD
|
||||
%token MATCHER_FORWARD_AS_ATTACHMENT MATCHER_EOL MATCHER_STRING
|
||||
%token MATCHER_OR MATCHER_AND
|
||||
%token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_BOUNCE
|
||||
|
||||
%start file
|
||||
|
||||
|
@ -150,7 +174,7 @@ file:
|
|||
{
|
||||
if (!matcher_parser_dialog) {
|
||||
prefs_scoring = &global_scoring;
|
||||
prefs_filtering = &global_filtering;
|
||||
prefs_filtering = &global_processing;
|
||||
}
|
||||
}
|
||||
file_line_list;
|
||||
|
@ -164,7 +188,10 @@ file_line_list
|
|||
file_line:
|
||||
section_notification
|
||||
| instruction
|
||||
;
|
||||
| error MATCHER_EOL
|
||||
{
|
||||
yyerrok;
|
||||
};
|
||||
|
||||
section_notification:
|
||||
MATCHER_SECTION MATCHER_EOL
|
||||
|
@ -176,7 +203,7 @@ MATCHER_SECTION MATCHER_EOL
|
|||
item = folder_find_item_from_identifier(folder);
|
||||
if (item == NULL) {
|
||||
prefs_scoring = &global_scoring;
|
||||
prefs_filtering = &global_scoring;
|
||||
prefs_filtering = &global_processing;
|
||||
}
|
||||
else {
|
||||
prefs_scoring = &item->prefs->scoring;
|
||||
|
@ -192,12 +219,27 @@ condition end_instr_opt
|
|||
;
|
||||
|
||||
end_instr_opt:
|
||||
filtering_or_scoring MATCHER_EOL
|
||||
filtering_or_scoring end_action
|
||||
|
|
||||
{
|
||||
if (!matcher_parser_dialog) {
|
||||
yyerror("parse error");
|
||||
return 1;
|
||||
if (matcher_parser_dialog)
|
||||
YYACCEPT;
|
||||
else {
|
||||
matcher_parsererror("parse error");
|
||||
YYERROR;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
end_action:
|
||||
MATCHER_EOL
|
||||
|
|
||||
{
|
||||
if (matcher_parser_dialog)
|
||||
YYACCEPT;
|
||||
else {
|
||||
matcher_parsererror("parse error");
|
||||
YYERROR;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
@ -548,6 +590,15 @@ MATCHER_ALL
|
|||
value = atoi($2);
|
||||
prop = matcherprop_new(criteria, NULL, 0, NULL, value);
|
||||
}
|
||||
| MATCHER_SCORE_EQUAL MATCHER_INTEGER
|
||||
{
|
||||
gint criteria = 0;
|
||||
gint value = 0;
|
||||
|
||||
criteria = MATCHCRITERIA_SCORE_EQUAL;
|
||||
value = atoi($2);
|
||||
prop = matcherprop_new(criteria, NULL, 0, NULL, value);
|
||||
}
|
||||
| MATCHER_HEADER MATCHER_STRING
|
||||
{
|
||||
header = g_strdup($2);
|
||||
|
@ -656,7 +707,7 @@ MATCHER_EXECUTE MATCHER_STRING
|
|||
|
||||
action_type = MATCHACTION_EXECUTE;
|
||||
cmd = $2;
|
||||
action = filteringaction_new(action_type, 0, cmd);
|
||||
action = filteringaction_new(action_type, 0, cmd, 0);
|
||||
}
|
||||
| MATCHER_MOVE MATCHER_STRING
|
||||
{
|
||||
|
@ -665,7 +716,7 @@ MATCHER_EXECUTE MATCHER_STRING
|
|||
|
||||
action_type = MATCHACTION_MOVE;
|
||||
destination = $2;
|
||||
action = filteringaction_new(action_type, 0, destination);
|
||||
action = filteringaction_new(action_type, 0, destination, 0);
|
||||
}
|
||||
| MATCHER_COPY MATCHER_STRING
|
||||
{
|
||||
|
@ -674,42 +725,42 @@ MATCHER_EXECUTE MATCHER_STRING
|
|||
|
||||
action_type = MATCHACTION_COPY;
|
||||
destination = $2;
|
||||
action = filteringaction_new(action_type, 0, destination);
|
||||
action = filteringaction_new(action_type, 0, destination, 0);
|
||||
}
|
||||
| MATCHER_DELETE
|
||||
{
|
||||
gint action_type = 0;
|
||||
|
||||
action_type = MATCHACTION_DELETE;
|
||||
action = filteringaction_new(action_type, 0, NULL);
|
||||
action = filteringaction_new(action_type, 0, NULL, 0);
|
||||
}
|
||||
| MATCHER_MARK
|
||||
{
|
||||
gint action_type = 0;
|
||||
|
||||
action_type = MATCHACTION_MARK;
|
||||
action = filteringaction_new(action_type, 0, NULL);
|
||||
action = filteringaction_new(action_type, 0, NULL, 0);
|
||||
}
|
||||
| MATCHER_UNMARK
|
||||
{
|
||||
gint action_type = 0;
|
||||
|
||||
action_type = MATCHACTION_UNMARK;
|
||||
action = filteringaction_new(action_type, 0, NULL);
|
||||
action = filteringaction_new(action_type, 0, NULL, 0);
|
||||
}
|
||||
| MATCHER_MARK_AS_READ
|
||||
{
|
||||
gint action_type = 0;
|
||||
|
||||
action_type = MATCHACTION_MARK_AS_READ;
|
||||
action = filteringaction_new(action_type, 0, NULL);
|
||||
action = filteringaction_new(action_type, 0, NULL, 0);
|
||||
}
|
||||
| MATCHER_MARK_AS_UNREAD
|
||||
{
|
||||
gint action_type = 0;
|
||||
|
||||
action_type = MATCHACTION_MARK_AS_UNREAD;
|
||||
action = filteringaction_new(action_type, 0, NULL);
|
||||
action = filteringaction_new(action_type, 0, NULL, 0);
|
||||
}
|
||||
| MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
|
||||
{
|
||||
|
@ -720,7 +771,7 @@ MATCHER_EXECUTE MATCHER_STRING
|
|||
action_type = MATCHACTION_FORWARD;
|
||||
account_id = $2;
|
||||
destination = $3;
|
||||
action = filteringaction_new(action_type, account_id, destination);
|
||||
action = filteringaction_new(action_type, account_id, destination, 0);
|
||||
}
|
||||
| MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
|
||||
{
|
||||
|
@ -731,7 +782,16 @@ MATCHER_EXECUTE MATCHER_STRING
|
|||
action_type = MATCHACTION_FORWARD_AS_ATTACHMENT;
|
||||
account_id = $2;
|
||||
destination = $3;
|
||||
action = filteringaction_new(action_type, account_id, destination);
|
||||
action = filteringaction_new(action_type, account_id, destination, 0);
|
||||
}
|
||||
| MATCHER_COLOR MATCHER_INTEGER
|
||||
{
|
||||
gint action_type = 0;
|
||||
gint color = 0;
|
||||
|
||||
action_type = MATCHACTION_COLOR;
|
||||
color = atoi($2);
|
||||
action = filteringaction_new(action_type, 0, NULL, color);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, GHashTable *folder_table)
|
|||
}
|
||||
|
||||
if (folder_table) {
|
||||
if (prefs_filtering == NULL) {
|
||||
if (global_processing == NULL) {
|
||||
/* old filtering */
|
||||
dropfolder = filter_get_dest_folder
|
||||
(prefs_common.fltlist, tmp_file);
|
||||
|
@ -225,7 +225,7 @@ gint proc_mbox(FolderItem *dest, const gchar *mbox, GHashTable *folder_table)
|
|||
dropfolder = dest;
|
||||
|
||||
/* old filtering */
|
||||
if (prefs_filtering == NULL || folder_table == NULL) {
|
||||
if (global_processing == NULL || folder_table == NULL) {
|
||||
if ((msgnum = folder_item_add_msg(dropfolder, tmp_file, TRUE)) < 0) {
|
||||
fclose(mbox_fp);
|
||||
unlink(tmp_file);
|
||||
|
|
|
@ -436,7 +436,7 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo)
|
|||
if (prefs_common.return_receipt
|
||||
&& (tmpmsginfo->dispositionnotificationto
|
||||
|| tmpmsginfo->returnreceiptto)
|
||||
&& (MSG_IS_UNREAD(tmpmsginfo->flags))) {
|
||||
&& (MSG_IS_UNREAD(msginfo->flags))) {
|
||||
gint ok;
|
||||
|
||||
if (alertpanel(_("Return Receipt"), _("Send return receipt ?"),
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
#include "addr_compl.h"
|
||||
#include "colorlabel.h"
|
||||
|
||||
#include "matcher_parser.h"
|
||||
|
||||
static struct Filtering {
|
||||
GtkWidget *window;
|
||||
|
||||
|
@ -112,6 +114,8 @@ static void prefs_filtering_action_selection_changed(GtkList *list,
|
|||
|
||||
static void prefs_filtering_reset_dialog(void);
|
||||
|
||||
static FolderItem * cur_item = NULL;
|
||||
|
||||
enum {
|
||||
ACTION_MOVE = 0,
|
||||
ACTION_COPY = 1,
|
||||
|
@ -181,27 +185,27 @@ static gint prefs_filtering_get_matching_from_action(gint action_id)
|
|||
{
|
||||
switch(action_id) {
|
||||
case ACTION_MOVE:
|
||||
return MATCHING_ACTION_MOVE;
|
||||
return MATCHACTION_MOVE;
|
||||
case ACTION_COPY:
|
||||
return MATCHING_ACTION_COPY;
|
||||
return MATCHACTION_COPY;
|
||||
case ACTION_DELETE:
|
||||
return MATCHING_ACTION_DELETE;
|
||||
return MATCHACTION_DELETE;
|
||||
case ACTION_MARK:
|
||||
return MATCHING_ACTION_MARK;
|
||||
return MATCHACTION_MARK;
|
||||
case ACTION_UNMARK:
|
||||
return MATCHING_ACTION_UNMARK;
|
||||
return MATCHACTION_UNMARK;
|
||||
case ACTION_MARK_AS_READ:
|
||||
return MATCHING_ACTION_MARK_AS_READ;
|
||||
return MATCHACTION_MARK_AS_READ;
|
||||
case ACTION_MARK_AS_UNREAD:
|
||||
return MATCHING_ACTION_MARK_AS_UNREAD;
|
||||
return MATCHACTION_MARK_AS_UNREAD;
|
||||
case ACTION_FORWARD:
|
||||
return MATCHING_ACTION_FORWARD;
|
||||
return MATCHACTION_FORWARD;
|
||||
case ACTION_FORWARD_AS_ATTACHMENT:
|
||||
return MATCHING_ACTION_FORWARD_AS_ATTACHMENT;
|
||||
return MATCHACTION_FORWARD_AS_ATTACHMENT;
|
||||
case ACTION_EXECUTE:
|
||||
return MATCHING_EXECUTE;
|
||||
return MATCHACTION_EXECUTE;
|
||||
case ACTION_COLOR:
|
||||
return MATCHING_ACTION_COLOR;
|
||||
return MATCHACTION_COLOR;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -221,7 +225,7 @@ static gchar * action_text [] = {
|
|||
N_("Color")
|
||||
};
|
||||
|
||||
void prefs_filtering_open(void)
|
||||
void prefs_filtering_open(FolderItem * item)
|
||||
{
|
||||
if (prefs_rc_is_readonly(FILTERING_RC))
|
||||
return;
|
||||
|
@ -235,6 +239,8 @@ void prefs_filtering_open(void)
|
|||
manage_window_set_transient(GTK_WINDOW(filtering.window));
|
||||
gtk_widget_grab_focus(filtering.ok_btn);
|
||||
|
||||
cur_item = item;
|
||||
|
||||
prefs_filtering_set_dialog();
|
||||
|
||||
gtk_widget_show(filtering.window);
|
||||
|
@ -601,11 +607,18 @@ static void prefs_filtering_set_dialog(void)
|
|||
{
|
||||
GtkCList *clist = GTK_CLIST(filtering.cond_clist);
|
||||
GSList *cur;
|
||||
GSList * prefs_filtering;
|
||||
|
||||
gtk_clist_freeze(clist);
|
||||
gtk_clist_clear(clist);
|
||||
|
||||
prefs_filtering_clist_set_row(-1, NULL);
|
||||
|
||||
if (cur_item == NULL)
|
||||
prefs_filtering = global_processing;
|
||||
else
|
||||
prefs_filtering = cur_item->prefs->processing;
|
||||
|
||||
for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur)) {
|
||||
FilteringProp * prop = (FilteringProp *) cur->data;
|
||||
|
||||
|
@ -633,6 +646,12 @@ static void prefs_filtering_set_list(void)
|
|||
GSList * cur;
|
||||
gchar * filtering_str;
|
||||
gchar * tmp;
|
||||
GSList * prefs_filtering;
|
||||
|
||||
if (cur_item == NULL)
|
||||
prefs_filtering = global_processing;
|
||||
else
|
||||
prefs_filtering = cur_item->prefs->processing;
|
||||
|
||||
for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur))
|
||||
filteringprop_free((FilteringProp *) cur->data);
|
||||
|
@ -642,14 +661,19 @@ static void prefs_filtering_set_list(void)
|
|||
while (gtk_clist_get_text(GTK_CLIST(filtering.cond_clist),
|
||||
row, 0, &filtering_str)) {
|
||||
if (strcmp(filtering_str, _("(New)")) != 0) {
|
||||
tmp = filtering_str;
|
||||
prop = filteringprop_parse(&tmp);
|
||||
/* tmp = filtering_str; */
|
||||
prop = matcher_parser_get_filtering(filtering_str);
|
||||
if (prop != NULL)
|
||||
prefs_filtering = g_slist_append(prefs_filtering,
|
||||
prop);
|
||||
prefs_filtering =
|
||||
g_slist_append(prefs_filtering, prop);
|
||||
}
|
||||
row++;
|
||||
}
|
||||
|
||||
if (cur_item == NULL)
|
||||
global_processing = prefs_filtering;
|
||||
else
|
||||
cur_item->prefs->processing = prefs_filtering;
|
||||
}
|
||||
|
||||
static gint prefs_filtering_clist_set_row(gint row, FilteringProp * prop)
|
||||
|
@ -703,9 +727,9 @@ static void prefs_filtering_condition_define(void)
|
|||
if (*cond_str != '\0') {
|
||||
gchar * tmp;
|
||||
|
||||
tmp = cond_str;
|
||||
matchers = matcherlist_parse(&tmp);
|
||||
if (tmp == NULL)
|
||||
/* tmp = cond_str; */
|
||||
matchers = matcher_parser_get_cond(cond_str);
|
||||
if (matchers == NULL)
|
||||
alertpanel_error(_("Match string is not valid."));
|
||||
}
|
||||
|
||||
|
@ -768,10 +792,10 @@ static FilteringProp * prefs_filtering_dialog_to_filtering(void)
|
|||
|
||||
action = filteringaction_new(action_type, account_id, destination, labelcolor);
|
||||
|
||||
tmp = cond_str;
|
||||
cond = matcherlist_parse(&tmp);
|
||||
/* tmp = cond_str; */
|
||||
cond = matcher_parser_get_cond(cond_str);
|
||||
|
||||
if (tmp == NULL) {
|
||||
if (cond == NULL) {
|
||||
alertpanel_error(_("Match string is not valid."));
|
||||
filteringaction_free(action);
|
||||
return NULL;
|
||||
|
@ -892,53 +916,53 @@ static void prefs_filtering_select_set(FilteringProp * prop)
|
|||
gtk_entry_set_text(GTK_ENTRY(filtering.dest_entry), "");
|
||||
|
||||
switch(action->type) {
|
||||
case MATCHING_ACTION_MOVE:
|
||||
case MATCHACTION_MOVE:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_MOVE);
|
||||
break;
|
||||
case MATCHING_ACTION_COPY:
|
||||
case MATCHACTION_COPY:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_COPY);
|
||||
break;
|
||||
case MATCHING_ACTION_DELETE:
|
||||
case MATCHACTION_DELETE:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_DELETE);
|
||||
break;
|
||||
case MATCHING_ACTION_MARK:
|
||||
case MATCHACTION_MARK:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_MARK);
|
||||
break;
|
||||
case MATCHING_ACTION_UNMARK:
|
||||
case MATCHACTION_UNMARK:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_UNMARK);
|
||||
break;
|
||||
case MATCHING_ACTION_MARK_AS_READ:
|
||||
case MATCHACTION_MARK_AS_READ:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_MARK_AS_READ);
|
||||
break;
|
||||
case MATCHING_ACTION_MARK_AS_UNREAD:
|
||||
case MATCHACTION_MARK_AS_UNREAD:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_MARK_AS_UNREAD);
|
||||
break;
|
||||
case MATCHING_ACTION_FORWARD:
|
||||
case MATCHACTION_FORWARD:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_FORWARD);
|
||||
list_id = get_list_id_from_account_id(action->account_id);
|
||||
gtk_list_select_item(GTK_LIST(filtering.account_list),
|
||||
list_id);
|
||||
break;
|
||||
case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
|
||||
case MATCHACTION_FORWARD_AS_ATTACHMENT:
|
||||
list_id = get_list_id_from_account_id(action->account_id);
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_FORWARD_AS_ATTACHMENT);
|
||||
gtk_list_select_item(GTK_LIST(filtering.account_list),
|
||||
list_id);
|
||||
break;
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHACTION_EXECUTE:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_EXECUTE);
|
||||
break;
|
||||
case MATCHING_ACTION_COLOR:
|
||||
case MATCHACTION_COLOR:
|
||||
gtk_list_select_item(GTK_LIST(filtering.action_list),
|
||||
ACTION_COLOR);
|
||||
gtk_option_menu_set_history(GTK_OPTION_MENU(filtering.color_optmenu), action->labelcolor);
|
||||
|
@ -964,9 +988,9 @@ static void prefs_filtering_select(GtkCList *clist, gint row, gint column,
|
|||
row, 0, &filtering_str))
|
||||
return;
|
||||
|
||||
tmp = filtering_str;
|
||||
prop = filteringprop_parse(&tmp);
|
||||
if (tmp == NULL)
|
||||
/* tmp = filtering_str; */
|
||||
prop = matcher_parser_get_filtering(filtering_str);
|
||||
if (prop == NULL)
|
||||
return;
|
||||
|
||||
prefs_filtering_select_set(prop);
|
||||
|
@ -1160,12 +1184,18 @@ static void prefs_filtering_key_pressed(GtkWidget *widget, GdkEventKey *event,
|
|||
static void prefs_filtering_ok(void)
|
||||
{
|
||||
prefs_filtering_set_list();
|
||||
/*
|
||||
prefs_filtering_write_config();
|
||||
*/
|
||||
prefs_matcher_write_config();
|
||||
prefs_filtering_close();
|
||||
}
|
||||
|
||||
static void prefs_filtering_cancel(void)
|
||||
{
|
||||
/*
|
||||
prefs_filtering_read_config();
|
||||
*/
|
||||
prefs_matcher_read_config();
|
||||
prefs_filtering_close();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
void prefs_scoring_read_config (void);
|
||||
void prefs_scoring_write_config (void);
|
||||
*/
|
||||
void prefs_filtering_open (void);
|
||||
void prefs_filtering_open(FolderItem * item);
|
||||
|
||||
#endif /* __PREFS_FILTERING_H__ */
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "alertpanel.h"
|
||||
#include "folder.h"
|
||||
|
||||
#include "matcher_parser.h"
|
||||
|
||||
static struct Matcher {
|
||||
GtkWidget *window;
|
||||
|
||||
|
@ -679,10 +681,10 @@ static MatcherList * prefs_matcher_get_list(void)
|
|||
row, 0, &matcher_str)) {
|
||||
|
||||
if (strcmp(matcher_str, _("(New)")) != 0) {
|
||||
tmp = matcher_str;
|
||||
prop = matcherprop_parse(&tmp);
|
||||
/* tmp = matcher_str; */
|
||||
prop = matcher_parser_get_prop(matcher_str);
|
||||
|
||||
if (tmp == NULL)
|
||||
if (prop == NULL)
|
||||
break;
|
||||
|
||||
matcher_list = g_slist_append(matcher_list, prop);
|
||||
|
@ -700,76 +702,76 @@ static MatcherList * prefs_matcher_get_list(void)
|
|||
static gint prefs_matcher_get_criteria_from_matching(gint matching_id)
|
||||
{
|
||||
switch(matching_id) {
|
||||
case MATCHING_ALL:
|
||||
case MATCHCRITERIA_ALL:
|
||||
return CRITERIA_ALL;
|
||||
case MATCHING_NOT_UNREAD:
|
||||
case MATCHING_UNREAD:
|
||||
case MATCHCRITERIA_NOT_UNREAD:
|
||||
case MATCHCRITERIA_UNREAD:
|
||||
return CRITERIA_UNREAD;
|
||||
case MATCHING_NOT_NEW:
|
||||
case MATCHING_NEW:
|
||||
case MATCHCRITERIA_NOT_NEW:
|
||||
case MATCHCRITERIA_NEW:
|
||||
return CRITERIA_NEW;
|
||||
case MATCHING_NOT_MARKED:
|
||||
case MATCHING_MARKED:
|
||||
case MATCHCRITERIA_NOT_MARKED:
|
||||
case MATCHCRITERIA_MARKED:
|
||||
return CRITERIA_MARKED;
|
||||
case MATCHING_NOT_DELETED:
|
||||
case MATCHING_DELETED:
|
||||
case MATCHCRITERIA_NOT_DELETED:
|
||||
case MATCHCRITERIA_DELETED:
|
||||
return CRITERIA_DELETED;
|
||||
break;
|
||||
case MATCHING_NOT_REPLIED:
|
||||
case MATCHING_REPLIED:
|
||||
case MATCHCRITERIA_NOT_REPLIED:
|
||||
case MATCHCRITERIA_REPLIED:
|
||||
return CRITERIA_REPLIED;
|
||||
case MATCHING_NOT_FORWARDED:
|
||||
case MATCHING_FORWARDED:
|
||||
case MATCHCRITERIA_NOT_FORWARDED:
|
||||
case MATCHCRITERIA_FORWARDED:
|
||||
return CRITERIA_FORWARDED;
|
||||
case MATCHING_NOT_SUBJECT:
|
||||
case MATCHING_SUBJECT:
|
||||
case MATCHCRITERIA_NOT_SUBJECT:
|
||||
case MATCHCRITERIA_SUBJECT:
|
||||
return CRITERIA_SUBJECT;
|
||||
case MATCHING_NOT_FROM:
|
||||
case MATCHING_FROM:
|
||||
case MATCHCRITERIA_NOT_FROM:
|
||||
case MATCHCRITERIA_FROM:
|
||||
return CRITERIA_FROM;
|
||||
case MATCHING_NOT_TO:
|
||||
case MATCHING_TO:
|
||||
case MATCHCRITERIA_NOT_TO:
|
||||
case MATCHCRITERIA_TO:
|
||||
return CRITERIA_TO;
|
||||
case MATCHING_NOT_CC:
|
||||
case MATCHING_CC:
|
||||
case MATCHCRITERIA_NOT_CC:
|
||||
case MATCHCRITERIA_CC:
|
||||
return CRITERIA_CC;
|
||||
case MATCHING_NOT_NEWSGROUPS:
|
||||
case MATCHING_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NOT_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NEWSGROUPS:
|
||||
return CRITERIA_NEWSGROUPS;
|
||||
case MATCHING_NOT_INREPLYTO:
|
||||
case MATCHING_INREPLYTO:
|
||||
case MATCHCRITERIA_NOT_INREPLYTO:
|
||||
case MATCHCRITERIA_INREPLYTO:
|
||||
return CRITERIA_INREPLYTO;
|
||||
case MATCHING_NOT_REFERENCES:
|
||||
case MATCHING_REFERENCES:
|
||||
case MATCHCRITERIA_NOT_REFERENCES:
|
||||
case MATCHCRITERIA_REFERENCES:
|
||||
return CRITERIA_REFERENCES;
|
||||
case MATCHING_NOT_TO_AND_NOT_CC:
|
||||
case MATCHING_TO_OR_CC:
|
||||
case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
|
||||
case MATCHCRITERIA_TO_OR_CC:
|
||||
return CRITERIA_TO_OR_CC;
|
||||
case MATCHING_NOT_BODY_PART:
|
||||
case MATCHING_BODY_PART:
|
||||
case MATCHCRITERIA_NOT_BODY_PART:
|
||||
case MATCHCRITERIA_BODY_PART:
|
||||
return CRITERIA_BODY_PART;
|
||||
case MATCHING_NOT_MESSAGE:
|
||||
case MATCHING_MESSAGE:
|
||||
case MATCHCRITERIA_NOT_MESSAGE:
|
||||
case MATCHCRITERIA_MESSAGE:
|
||||
return CRITERIA_MESSAGE;
|
||||
break;
|
||||
case MATCHING_NOT_HEADERS_PART:
|
||||
case MATCHING_HEADERS_PART:
|
||||
case MATCHCRITERIA_NOT_HEADERS_PART:
|
||||
case MATCHCRITERIA_HEADERS_PART:
|
||||
return CRITERIA_HEADERS_PART;
|
||||
case MATCHING_NOT_HEADER:
|
||||
case MATCHING_HEADER:
|
||||
case MATCHCRITERIA_NOT_HEADER:
|
||||
case MATCHCRITERIA_HEADER:
|
||||
return CRITERIA_HEADER;
|
||||
case MATCHING_AGE_GREATER:
|
||||
case MATCHCRITERIA_AGE_GREATER:
|
||||
return CRITERIA_AGE_GREATER;
|
||||
case MATCHING_AGE_LOWER:
|
||||
case MATCHCRITERIA_AGE_LOWER:
|
||||
return CRITERIA_AGE_LOWER;
|
||||
case MATCHING_SCORE_GREATER:
|
||||
case MATCHCRITERIA_SCORE_GREATER:
|
||||
return CRITERIA_SCORE_GREATER;
|
||||
case MATCHING_SCORE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_LOWER:
|
||||
return CRITERIA_SCORE_LOWER;
|
||||
case MATCHING_SCORE_EQUAL:
|
||||
case MATCHCRITERIA_SCORE_EQUAL:
|
||||
return CRITERIA_SCORE_EQUAL;
|
||||
case MATCHING_NOT_EXECUTE:
|
||||
case MATCHING_EXECUTE:
|
||||
case MATCHCRITERIA_NOT_EXECUTE:
|
||||
case MATCHCRITERIA_EXECUTE:
|
||||
return CRITERIA_EXECUTE;
|
||||
break;
|
||||
default:
|
||||
|
@ -781,55 +783,55 @@ static gint prefs_matcher_get_matching_from_criteria(gint criteria_id)
|
|||
{
|
||||
switch (criteria_id) {
|
||||
case CRITERIA_ALL:
|
||||
return MATCHING_ALL;
|
||||
return MATCHCRITERIA_ALL;
|
||||
case CRITERIA_UNREAD:
|
||||
return MATCHING_UNREAD;
|
||||
return MATCHCRITERIA_UNREAD;
|
||||
case CRITERIA_NEW:
|
||||
return MATCHING_NEW;
|
||||
return MATCHCRITERIA_NEW;
|
||||
case CRITERIA_MARKED:
|
||||
return MATCHING_MARKED;
|
||||
return MATCHCRITERIA_MARKED;
|
||||
case CRITERIA_DELETED:
|
||||
return MATCHING_DELETED;
|
||||
return MATCHCRITERIA_DELETED;
|
||||
case CRITERIA_REPLIED:
|
||||
return MATCHING_REPLIED;
|
||||
return MATCHCRITERIA_REPLIED;
|
||||
case CRITERIA_FORWARDED:
|
||||
return MATCHING_FORWARDED;
|
||||
return MATCHCRITERIA_FORWARDED;
|
||||
case CRITERIA_SUBJECT:
|
||||
return MATCHING_SUBJECT;
|
||||
return MATCHCRITERIA_SUBJECT;
|
||||
case CRITERIA_FROM:
|
||||
return MATCHING_FROM;
|
||||
return MATCHCRITERIA_FROM;
|
||||
case CRITERIA_TO:
|
||||
return MATCHING_TO;
|
||||
return MATCHCRITERIA_TO;
|
||||
case CRITERIA_CC:
|
||||
return MATCHING_CC;
|
||||
return MATCHCRITERIA_CC;
|
||||
case CRITERIA_TO_OR_CC:
|
||||
return MATCHING_TO_OR_CC;
|
||||
return MATCHCRITERIA_TO_OR_CC;
|
||||
case CRITERIA_NEWSGROUPS:
|
||||
return MATCHING_NEWSGROUPS;
|
||||
return MATCHCRITERIA_NEWSGROUPS;
|
||||
case CRITERIA_INREPLYTO:
|
||||
return MATCHING_INREPLYTO;
|
||||
return MATCHCRITERIA_INREPLYTO;
|
||||
case CRITERIA_REFERENCES:
|
||||
return MATCHING_REFERENCES;
|
||||
return MATCHCRITERIA_REFERENCES;
|
||||
case CRITERIA_AGE_GREATER:
|
||||
return MATCHING_AGE_GREATER;
|
||||
return MATCHCRITERIA_AGE_GREATER;
|
||||
case CRITERIA_AGE_LOWER:
|
||||
return MATCHING_AGE_LOWER;
|
||||
return MATCHCRITERIA_AGE_LOWER;
|
||||
case CRITERIA_SCORE_GREATER:
|
||||
return MATCHING_SCORE_GREATER;
|
||||
return MATCHCRITERIA_SCORE_GREATER;
|
||||
case CRITERIA_SCORE_LOWER:
|
||||
return MATCHING_SCORE_LOWER;
|
||||
return MATCHCRITERIA_SCORE_LOWER;
|
||||
case CRITERIA_SCORE_EQUAL:
|
||||
return MATCHING_SCORE_EQUAL;
|
||||
return MATCHCRITERIA_SCORE_EQUAL;
|
||||
case CRITERIA_HEADER:
|
||||
return MATCHING_HEADER;
|
||||
return MATCHCRITERIA_HEADER;
|
||||
case CRITERIA_HEADERS_PART:
|
||||
return MATCHING_HEADERS_PART;
|
||||
return MATCHCRITERIA_HEADERS_PART;
|
||||
case CRITERIA_BODY_PART:
|
||||
return MATCHING_BODY_PART;
|
||||
return MATCHCRITERIA_BODY_PART;
|
||||
case CRITERIA_MESSAGE:
|
||||
return MATCHING_MESSAGE;
|
||||
return MATCHCRITERIA_MESSAGE;
|
||||
case CRITERIA_EXECUTE:
|
||||
return MATCHING_EXECUTE;
|
||||
return MATCHCRITERIA_EXECUTE;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -838,44 +840,44 @@ static gint prefs_matcher_get_matching_from_criteria(gint criteria_id)
|
|||
static gint prefs_matcher_not_criteria(gint matcher_criteria)
|
||||
{
|
||||
switch(matcher_criteria) {
|
||||
case MATCHING_UNREAD:
|
||||
return MATCHING_NOT_UNREAD;
|
||||
case MATCHING_NEW:
|
||||
return MATCHING_NOT_NEW;
|
||||
case MATCHING_MARKED:
|
||||
return MATCHING_NOT_MARKED;
|
||||
case MATCHING_DELETED:
|
||||
return MATCHING_NOT_DELETED;
|
||||
case MATCHING_REPLIED:
|
||||
return MATCHING_NOT_REPLIED;
|
||||
case MATCHING_FORWARDED:
|
||||
return MATCHING_NOT_FORWARDED;
|
||||
case MATCHING_SUBJECT:
|
||||
return MATCHING_NOT_SUBJECT;
|
||||
case MATCHING_FROM:
|
||||
return MATCHING_NOT_FROM;
|
||||
case MATCHING_TO:
|
||||
return MATCHING_NOT_TO;
|
||||
case MATCHING_CC:
|
||||
return MATCHING_NOT_CC;
|
||||
case MATCHING_TO_OR_CC:
|
||||
return MATCHING_NOT_TO_AND_NOT_CC;
|
||||
case MATCHING_NEWSGROUPS:
|
||||
return MATCHING_NOT_NEWSGROUPS;
|
||||
case MATCHING_INREPLYTO:
|
||||
return MATCHING_NOT_INREPLYTO;
|
||||
case MATCHING_REFERENCES:
|
||||
return MATCHING_NOT_REFERENCES;
|
||||
case MATCHING_HEADER:
|
||||
return MATCHING_NOT_HEADER;
|
||||
case MATCHING_HEADERS_PART:
|
||||
return MATCHING_NOT_HEADERS_PART;
|
||||
case MATCHING_MESSAGE:
|
||||
return MATCHING_NOT_MESSAGE;
|
||||
case MATCHING_EXECUTE:
|
||||
return MATCHING_NOT_EXECUTE;
|
||||
case MATCHING_BODY_PART:
|
||||
return MATCHING_NOT_BODY_PART;
|
||||
case MATCHCRITERIA_UNREAD:
|
||||
return MATCHCRITERIA_NOT_UNREAD;
|
||||
case MATCHCRITERIA_NEW:
|
||||
return MATCHCRITERIA_NOT_NEW;
|
||||
case MATCHCRITERIA_MARKED:
|
||||
return MATCHCRITERIA_NOT_MARKED;
|
||||
case MATCHCRITERIA_DELETED:
|
||||
return MATCHCRITERIA_NOT_DELETED;
|
||||
case MATCHCRITERIA_REPLIED:
|
||||
return MATCHCRITERIA_NOT_REPLIED;
|
||||
case MATCHCRITERIA_FORWARDED:
|
||||
return MATCHCRITERIA_NOT_FORWARDED;
|
||||
case MATCHCRITERIA_SUBJECT:
|
||||
return MATCHCRITERIA_NOT_SUBJECT;
|
||||
case MATCHCRITERIA_FROM:
|
||||
return MATCHCRITERIA_NOT_FROM;
|
||||
case MATCHCRITERIA_TO:
|
||||
return MATCHCRITERIA_NOT_TO;
|
||||
case MATCHCRITERIA_CC:
|
||||
return MATCHCRITERIA_NOT_CC;
|
||||
case MATCHCRITERIA_TO_OR_CC:
|
||||
return MATCHCRITERIA_NOT_TO_AND_NOT_CC;
|
||||
case MATCHCRITERIA_NEWSGROUPS:
|
||||
return MATCHCRITERIA_NOT_NEWSGROUPS;
|
||||
case MATCHCRITERIA_INREPLYTO:
|
||||
return MATCHCRITERIA_NOT_INREPLYTO;
|
||||
case MATCHCRITERIA_REFERENCES:
|
||||
return MATCHCRITERIA_NOT_REFERENCES;
|
||||
case MATCHCRITERIA_HEADER:
|
||||
return MATCHCRITERIA_NOT_HEADER;
|
||||
case MATCHCRITERIA_HEADERS_PART:
|
||||
return MATCHCRITERIA_NOT_HEADERS_PART;
|
||||
case MATCHCRITERIA_MESSAGE:
|
||||
return MATCHCRITERIA_NOT_MESSAGE;
|
||||
case MATCHCRITERIA_EXECUTE:
|
||||
return MATCHCRITERIA_NOT_EXECUTE;
|
||||
case MATCHCRITERIA_BODY_PART:
|
||||
return MATCHCRITERIA_NOT_BODY_PART;
|
||||
default:
|
||||
return matcher_criteria;
|
||||
}
|
||||
|
@ -938,15 +940,15 @@ static MatcherProp * prefs_matcher_dialog_to_matcher()
|
|||
|
||||
if (use_regexp) {
|
||||
if (case_sensitive)
|
||||
matchtype = MATCHING_REGEXP;
|
||||
matchtype = MATCHTYPE_REGEXP;
|
||||
else
|
||||
matchtype = MATCHING_REGEXPCASE;
|
||||
matchtype = MATCHTYPE_REGEXPCASE;
|
||||
}
|
||||
else {
|
||||
if (case_sensitive)
|
||||
matchtype = MATCHING_MATCH;
|
||||
matchtype = MATCHTYPE_MATCH;
|
||||
else
|
||||
matchtype = MATCHING_MATCHCASE;
|
||||
matchtype = MATCHTYPE_MATCHCASE;
|
||||
}
|
||||
|
||||
header = NULL;
|
||||
|
@ -1131,9 +1133,9 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
|
|||
return;
|
||||
}
|
||||
|
||||
tmp = matcher_str;
|
||||
prop = matcherprop_parse(&tmp);
|
||||
if (tmp == NULL)
|
||||
// tmp = matcher_str;
|
||||
prop = matcher_parser_get_prop(matcher_str);
|
||||
if (prop == NULL)
|
||||
return;
|
||||
|
||||
criteria = prefs_matcher_get_criteria_from_matching(prop->criteria);
|
||||
|
@ -1142,67 +1144,67 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
|
|||
criteria);
|
||||
|
||||
switch(prop->criteria) {
|
||||
case MATCHING_NOT_UNREAD:
|
||||
case MATCHING_NOT_NEW:
|
||||
case MATCHING_NOT_MARKED:
|
||||
case MATCHING_NOT_DELETED:
|
||||
case MATCHING_NOT_REPLIED:
|
||||
case MATCHING_NOT_FORWARDED:
|
||||
case MATCHING_NOT_SUBJECT:
|
||||
case MATCHING_NOT_FROM:
|
||||
case MATCHING_NOT_TO:
|
||||
case MATCHING_NOT_CC:
|
||||
case MATCHING_NOT_NEWSGROUPS:
|
||||
case MATCHING_NOT_INREPLYTO:
|
||||
case MATCHING_NOT_REFERENCES:
|
||||
case MATCHING_NOT_TO_AND_NOT_CC:
|
||||
case MATCHING_NOT_BODY_PART:
|
||||
case MATCHING_NOT_MESSAGE:
|
||||
case MATCHING_NOT_HEADERS_PART:
|
||||
case MATCHING_NOT_HEADER:
|
||||
case MATCHCRITERIA_NOT_UNREAD:
|
||||
case MATCHCRITERIA_NOT_NEW:
|
||||
case MATCHCRITERIA_NOT_MARKED:
|
||||
case MATCHCRITERIA_NOT_DELETED:
|
||||
case MATCHCRITERIA_NOT_REPLIED:
|
||||
case MATCHCRITERIA_NOT_FORWARDED:
|
||||
case MATCHCRITERIA_NOT_SUBJECT:
|
||||
case MATCHCRITERIA_NOT_FROM:
|
||||
case MATCHCRITERIA_NOT_TO:
|
||||
case MATCHCRITERIA_NOT_CC:
|
||||
case MATCHCRITERIA_NOT_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NOT_INREPLYTO:
|
||||
case MATCHCRITERIA_NOT_REFERENCES:
|
||||
case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
|
||||
case MATCHCRITERIA_NOT_BODY_PART:
|
||||
case MATCHCRITERIA_NOT_MESSAGE:
|
||||
case MATCHCRITERIA_NOT_HEADERS_PART:
|
||||
case MATCHCRITERIA_NOT_HEADER:
|
||||
negative_cond = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(prop->criteria) {
|
||||
case MATCHING_ALL:
|
||||
case MATCHCRITERIA_ALL:
|
||||
break;
|
||||
|
||||
case MATCHING_NOT_SUBJECT:
|
||||
case MATCHING_NOT_FROM:
|
||||
case MATCHING_NOT_TO:
|
||||
case MATCHING_NOT_CC:
|
||||
case MATCHING_NOT_TO_AND_NOT_CC:
|
||||
case MATCHING_NOT_NEWSGROUPS:
|
||||
case MATCHING_NOT_INREPLYTO:
|
||||
case MATCHING_NOT_REFERENCES:
|
||||
case MATCHING_NOT_HEADERS_PART:
|
||||
case MATCHING_NOT_BODY_PART:
|
||||
case MATCHING_NOT_MESSAGE:
|
||||
case MATCHING_SUBJECT:
|
||||
case MATCHING_FROM:
|
||||
case MATCHING_TO:
|
||||
case MATCHING_CC:
|
||||
case MATCHING_TO_OR_CC:
|
||||
case MATCHING_NEWSGROUPS:
|
||||
case MATCHING_INREPLYTO:
|
||||
case MATCHING_REFERENCES:
|
||||
case MATCHING_HEADERS_PART:
|
||||
case MATCHING_BODY_PART:
|
||||
case MATCHING_MESSAGE:
|
||||
case MATCHCRITERIA_NOT_SUBJECT:
|
||||
case MATCHCRITERIA_NOT_FROM:
|
||||
case MATCHCRITERIA_NOT_TO:
|
||||
case MATCHCRITERIA_NOT_CC:
|
||||
case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
|
||||
case MATCHCRITERIA_NOT_NEWSGROUPS:
|
||||
case MATCHCRITERIA_NOT_INREPLYTO:
|
||||
case MATCHCRITERIA_NOT_REFERENCES:
|
||||
case MATCHCRITERIA_NOT_HEADERS_PART:
|
||||
case MATCHCRITERIA_NOT_BODY_PART:
|
||||
case MATCHCRITERIA_NOT_MESSAGE:
|
||||
case MATCHCRITERIA_SUBJECT:
|
||||
case MATCHCRITERIA_FROM:
|
||||
case MATCHCRITERIA_TO:
|
||||
case MATCHCRITERIA_CC:
|
||||
case MATCHCRITERIA_TO_OR_CC:
|
||||
case MATCHCRITERIA_NEWSGROUPS:
|
||||
case MATCHCRITERIA_INREPLYTO:
|
||||
case MATCHCRITERIA_REFERENCES:
|
||||
case MATCHCRITERIA_HEADERS_PART:
|
||||
case MATCHCRITERIA_BODY_PART:
|
||||
case MATCHCRITERIA_MESSAGE:
|
||||
gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), prop->expr);
|
||||
break;
|
||||
|
||||
case MATCHING_AGE_GREATER:
|
||||
case MATCHING_AGE_LOWER:
|
||||
case MATCHING_SCORE_GREATER:
|
||||
case MATCHING_SCORE_LOWER:
|
||||
case MATCHING_SCORE_EQUAL:
|
||||
case MATCHCRITERIA_AGE_GREATER:
|
||||
case MATCHCRITERIA_AGE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_GREATER:
|
||||
case MATCHCRITERIA_SCORE_LOWER:
|
||||
case MATCHCRITERIA_SCORE_EQUAL:
|
||||
gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), itos(prop->value));
|
||||
break;
|
||||
|
||||
case MATCHING_NOT_HEADER:
|
||||
case MATCHING_HEADER:
|
||||
case MATCHCRITERIA_NOT_HEADER:
|
||||
case MATCHCRITERIA_HEADER:
|
||||
gtk_entry_set_text(GTK_ENTRY(matcher.header_entry), prop->header);
|
||||
gtk_entry_set_text(GTK_ENTRY(matcher.value_entry), prop->expr);
|
||||
break;
|
||||
|
@ -1214,22 +1216,22 @@ static void prefs_matcher_select(GtkCList *clist, gint row, gint column,
|
|||
gtk_list_select_item(GTK_LIST(matcher.predicate_list), 0);
|
||||
|
||||
switch(prop->matchtype) {
|
||||
case MATCHING_MATCH:
|
||||
case MATCHTYPE_MATCH:
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), FALSE);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), TRUE);
|
||||
break;
|
||||
|
||||
case MATCHING_MATCHCASE:
|
||||
case MATCHTYPE_MATCHCASE:
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), FALSE);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), FALSE);
|
||||
break;
|
||||
|
||||
case MATCHING_REGEXP:
|
||||
case MATCHTYPE_REGEXP:
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), TRUE);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), TRUE);
|
||||
break;
|
||||
|
||||
case MATCHING_REGEXPCASE:
|
||||
case MATCHTYPE_REGEXPCASE:
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.regexp_chkbtn), TRUE);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(matcher.case_chkbtn), FALSE);
|
||||
break;
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#include "folder.h"
|
||||
#include "scoring.h"
|
||||
|
||||
#include "matcher_parser.h"
|
||||
|
||||
static struct Scoring {
|
||||
GtkWidget *window;
|
||||
|
||||
|
@ -452,8 +454,8 @@ static void prefs_scoring_set_list(void)
|
|||
while (gtk_clist_get_text(GTK_CLIST(scoring.cond_clist),
|
||||
row, 0, &scoring_str)) {
|
||||
if (strcmp(scoring_str, _("(New)")) != 0) {
|
||||
tmp = scoring_str;
|
||||
prop = scoringprop_parse(&tmp);
|
||||
/* tmp = scoring_str; */
|
||||
prop = matcher_parser_get_scoring(scoring_str);
|
||||
if (prop != NULL)
|
||||
prefs_scoring = g_slist_append(prefs_scoring,
|
||||
prop);
|
||||
|
@ -527,9 +529,9 @@ static void prefs_scoring_condition_define(void)
|
|||
if (*cond_str != '\0') {
|
||||
gchar * tmp;
|
||||
|
||||
tmp = cond_str;
|
||||
matchers = matcherlist_parse(&tmp);
|
||||
if (tmp == NULL)
|
||||
/* tmp = cond_str; */
|
||||
matchers = matcher_parser_get_cond(cond_str);
|
||||
if (matchers == NULL)
|
||||
alertpanel_error(_("Match string is not valid."));
|
||||
}
|
||||
|
||||
|
@ -564,10 +566,10 @@ static void prefs_scoring_register_cb(void)
|
|||
}
|
||||
|
||||
score = atoi(score_str);
|
||||
tmp = cond_str;
|
||||
cond = matcherlist_parse(&tmp);
|
||||
/* tmp = cond_str; */
|
||||
cond = matcher_parser_get_cond(cond_str);
|
||||
|
||||
if (tmp == NULL) {
|
||||
if (cond == NULL) {
|
||||
alertpanel_error(_("Match string is not valid."));
|
||||
return;
|
||||
}
|
||||
|
@ -610,10 +612,10 @@ static void prefs_scoring_substitute_cb(void)
|
|||
}
|
||||
|
||||
score = atoi(score_str);
|
||||
tmp = cond_str;
|
||||
cond = matcherlist_parse(&tmp);
|
||||
/* tmp = cond_str; */
|
||||
cond = matcher_parser_get_cond(cond_str);
|
||||
|
||||
if (tmp == NULL) {
|
||||
if (cond == NULL) {
|
||||
alertpanel_error(_("Match string is not valid."));
|
||||
return;
|
||||
}
|
||||
|
@ -715,9 +717,9 @@ static void prefs_scoring_select(GtkCList *clist, gint row, gint column,
|
|||
row, 0, &scoring_str))
|
||||
return;
|
||||
|
||||
tmp = scoring_str;
|
||||
prop = scoringprop_parse(&tmp);
|
||||
if (tmp == NULL)
|
||||
/* tmp = scoring_str; */
|
||||
prop = matcher_parser_get_scoring(scoring_str);
|
||||
if (prop == NULL)
|
||||
return;
|
||||
|
||||
prefs_scoring_select_set_dialog(prop);
|
||||
|
@ -741,8 +743,9 @@ static void prefs_scoring_key_pressed(GtkWidget *widget, GdkEventKey *event,
|
|||
|
||||
static void prefs_scoring_ok(void)
|
||||
{
|
||||
prefs_common_save_config();
|
||||
prefs_scoring_set_list();
|
||||
prefs_scoring_write_config();
|
||||
prefs_matcher_write_config();
|
||||
if (cur_item != NULL)
|
||||
prefs_folder_item_save_config(cur_item);
|
||||
gtk_widget_hide(scoring.window);
|
||||
|
@ -750,6 +753,6 @@ static void prefs_scoring_ok(void)
|
|||
|
||||
static void prefs_scoring_cancel(void)
|
||||
{
|
||||
prefs_scoring_read_config();
|
||||
prefs_matcher_read_config();
|
||||
gtk_widget_hide(scoring.window);
|
||||
}
|
||||
|
|
179
src/scoring.c
179
src/scoring.c
|
@ -15,8 +15,9 @@
|
|||
#define PREFSBUFSIZE 1024
|
||||
|
||||
|
||||
GSList * global_scoring;
|
||||
GSList * global_scoring = NULL;
|
||||
|
||||
#if 0
|
||||
ScoringProp * scoringprop_parse(gchar ** str)
|
||||
{
|
||||
gchar * tmp;
|
||||
|
@ -41,7 +42,7 @@ ScoringProp * scoringprop_parse(gchar ** str)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (key != MATCHING_SCORE) {
|
||||
if (key != MATCHACTION_SCORE) {
|
||||
matcherlist_free(matchers);
|
||||
* str = NULL;
|
||||
return NULL;
|
||||
|
@ -60,7 +61,7 @@ ScoringProp * scoringprop_parse(gchar ** str)
|
|||
* str = tmp;
|
||||
return scoring;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ScoringProp * scoringprop_new(MatcherList * matchers, int score)
|
||||
{
|
||||
|
@ -138,52 +139,6 @@ static void scoringprop_print(ScoringProp * prop)
|
|||
if score is = MAX_SCORE (-999), no more match is done in the list
|
||||
*/
|
||||
|
||||
/*
|
||||
void prefs_scoring_read_config(void)
|
||||
{
|
||||
gchar *rcpath;
|
||||
FILE *fp;
|
||||
gchar buf[PREFSBUFSIZE];
|
||||
|
||||
debug_print(_("Reading headers configuration...\n"));
|
||||
|
||||
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, SCORING_RC, NULL);
|
||||
if ((fp = fopen(rcpath, "r")) == NULL) {
|
||||
if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
|
||||
g_free(rcpath);
|
||||
prefs_scoring = NULL;
|
||||
return;
|
||||
}
|
||||
g_free(rcpath);
|
||||
|
||||
while (prefs_scoring != NULL) {
|
||||
ScoringProp * scoring = (ScoringProp *) prefs_scoring->data;
|
||||
scoringprop_free(scoring);
|
||||
prefs_scoring = g_slist_remove(prefs_scoring, scoring);
|
||||
}
|
||||
|
||||
while (fgets(buf, sizeof(buf), fp) != NULL) {
|
||||
ScoringProp * scoring;
|
||||
gchar * tmp;
|
||||
|
||||
g_strchomp(buf);
|
||||
|
||||
if ((*buf != '#') && (*buf != '\0')) {
|
||||
tmp = buf;
|
||||
scoring = scoringprop_parse(&tmp);
|
||||
if (tmp != NULL) {
|
||||
prefs_scoring = g_slist_append(prefs_scoring,
|
||||
scoring);
|
||||
}
|
||||
else {
|
||||
g_warning(_("syntax error : %s\n"), buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
*/
|
||||
|
||||
gchar * scoringprop_to_string(ScoringProp * prop)
|
||||
{
|
||||
|
@ -203,89 +158,10 @@ gchar * scoringprop_to_string(ScoringProp * prop)
|
|||
return scoring_str;
|
||||
}
|
||||
|
||||
/*
|
||||
void prefs_scoring_write_config(void)
|
||||
{
|
||||
gchar *rcpath;
|
||||
PrefFile *pfile;
|
||||
GSList *cur;
|
||||
ScoringProp * prop;
|
||||
|
||||
debug_print(_("Writing scoring configuration...\n"));
|
||||
|
||||
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, SCORING_RC, NULL);
|
||||
|
||||
if ((pfile = prefs_write_open(rcpath)) == NULL) {
|
||||
g_warning(_("failed to write configuration to file\n"));
|
||||
g_free(rcpath);
|
||||
return;
|
||||
}
|
||||
|
||||
for (cur = prefs_scoring; cur != NULL; cur = cur->next) {
|
||||
gchar *scoring_str;
|
||||
|
||||
prop = (ScoringProp *) cur->data;
|
||||
scoring_str = scoringprop_to_string(prop);
|
||||
if (fputs(scoring_str, pfile->fp) == EOF ||
|
||||
fputc('\n', pfile->fp) == EOF) {
|
||||
FILE_OP_ERROR(rcpath, "fputs || fputc");
|
||||
prefs_write_close_revert(pfile);
|
||||
g_free(rcpath);
|
||||
g_free(scoring_str);
|
||||
return;
|
||||
}
|
||||
g_free(scoring_str);
|
||||
}
|
||||
|
||||
g_free(rcpath);
|
||||
|
||||
if (prefs_write_close(pfile) < 0) {
|
||||
g_warning(_("failed to write configuration to file\n"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void prefs_scoring_free(GSList * prefs_scoring)
|
||||
{
|
||||
while (prefs_scoring != NULL) {
|
||||
ScoringProp * scoring = (ScoringProp *) prefs_scoring->data;
|
||||
scoringprop_free(scoring);
|
||||
prefs_scoring = g_slist_remove(prefs_scoring, scoring);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean prefs_scoring_free_func(GNode *node, gpointer data)
|
||||
{
|
||||
FolderItem *item = node->data;
|
||||
|
||||
if(!item->prefs)
|
||||
return FALSE;
|
||||
|
||||
prefs_scoring_free(item->prefs->scoring);
|
||||
item->prefs->scoring = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void prefs_scoring_clear()
|
||||
{
|
||||
GList * cur;
|
||||
|
||||
for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
|
||||
Folder *folder;
|
||||
|
||||
folder = (Folder *) cur->data;
|
||||
g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
|
||||
prefs_scoring_free_func, NULL);
|
||||
}
|
||||
|
||||
prefs_scoring_free(global_scoring);
|
||||
global_scoring = NULL;
|
||||
}
|
||||
|
||||
void prefs_scoring_read_config(void)
|
||||
{
|
||||
/*
|
||||
gchar *rcpath;
|
||||
FILE *fp;
|
||||
gchar buf[PREFSBUFSIZE];
|
||||
|
@ -343,7 +219,6 @@ void prefs_scoring_read_config(void)
|
|||
scoring);
|
||||
}
|
||||
else {
|
||||
/* debug */
|
||||
g_warning(_("syntax error : %s\n"), buf);
|
||||
}
|
||||
}
|
||||
|
@ -355,8 +230,10 @@ void prefs_scoring_read_config(void)
|
|||
item->prefs->scoring = prefs_scoring;
|
||||
|
||||
fclose(fp);
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
static void prefs_scoring_write(FILE * fp, GSList * prefs_scoring)
|
||||
{
|
||||
GSList * cur;
|
||||
|
@ -412,7 +289,9 @@ static void prefs_scoring_save(FILE * fp)
|
|||
prefs_scoring_write_func, fp);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void prefs_scoring_write_config(void)
|
||||
{
|
||||
gchar *rcpath;
|
||||
|
@ -440,3 +319,43 @@ void prefs_scoring_write_config(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void prefs_scoring_free(GSList * prefs_scoring)
|
||||
{
|
||||
while (prefs_scoring != NULL) {
|
||||
ScoringProp * scoring = (ScoringProp *) prefs_scoring->data;
|
||||
scoringprop_free(scoring);
|
||||
prefs_scoring = g_slist_remove(prefs_scoring, scoring);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean prefs_scoring_free_func(GNode *node, gpointer data)
|
||||
{
|
||||
FolderItem *item = node->data;
|
||||
|
||||
if(!item->prefs)
|
||||
return FALSE;
|
||||
|
||||
prefs_scoring_free(item->prefs->scoring);
|
||||
item->prefs->scoring = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void prefs_scoring_clear()
|
||||
{
|
||||
GList * cur;
|
||||
|
||||
for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
|
||||
Folder *folder;
|
||||
|
||||
folder = (Folder *) cur->data;
|
||||
g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
|
||||
prefs_scoring_free_func, NULL);
|
||||
}
|
||||
|
||||
prefs_scoring_free(global_scoring);
|
||||
global_scoring = NULL;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ void prefs_scoring_write_config(void);
|
|||
void prefs_scoring_read_config(void);
|
||||
gchar * scoringprop_to_string(ScoringProp * prop);
|
||||
|
||||
void prefs_scoring_clear();
|
||||
void prefs_scoring_free(GSList * prefs_scoring);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2219,13 +2219,6 @@ static void summary_display_msg(SummaryView *summaryview, GtkCTreeNode *row,
|
|||
summaryview->newmsgs--;
|
||||
if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
|
||||
summaryview->unread--;
|
||||
if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
|
||||
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
|
||||
CHANGE_FLAGS(msginfo);
|
||||
summary_set_row_marks(summaryview, row);
|
||||
gtk_clist_thaw(GTK_CLIST(ctree));
|
||||
summary_status_show(summaryview);
|
||||
}
|
||||
|
||||
if (new_window) {
|
||||
MessageView *msgview;
|
||||
|
@ -2249,6 +2242,14 @@ static void summary_display_msg(SummaryView *summaryview, GtkCTreeNode *row,
|
|||
gtkut_ctree_node_move_if_on_the_edge(ctree, row);
|
||||
}
|
||||
|
||||
if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
|
||||
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
|
||||
CHANGE_FLAGS(msginfo);
|
||||
summary_set_row_marks(summaryview, row);
|
||||
gtk_clist_thaw(GTK_CLIST(ctree));
|
||||
summary_status_show(summaryview);
|
||||
}
|
||||
|
||||
if (GTK_WIDGET_VISIBLE(summaryview->headerwin->window))
|
||||
header_window_show(summaryview->headerwin, msginfo);
|
||||
|
||||
|
@ -3499,7 +3500,7 @@ static void summary_unthread_for_exec_func(GtkCTree *ctree, GtkCTreeNode *node,
|
|||
|
||||
void summary_filter(SummaryView *summaryview)
|
||||
{
|
||||
if (!prefs_common.fltlist && !prefs_filtering) {
|
||||
if (!prefs_common.fltlist && !global_processing) {
|
||||
alertpanel_error(_("No filter rules defined."));
|
||||
return;
|
||||
}
|
||||
|
@ -3512,7 +3513,7 @@ void summary_filter(SummaryView *summaryview)
|
|||
|
||||
gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
|
||||
|
||||
if (prefs_filtering == NULL) {
|
||||
if (global_processing == NULL) {
|
||||
gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
|
||||
GTK_CTREE_FUNC(summary_filter_func),
|
||||
summaryview);
|
||||
|
@ -3559,7 +3560,7 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
|
|||
gchar *file;
|
||||
FolderItem *dest;
|
||||
|
||||
if (prefs_filtering == NULL) {
|
||||
if (global_processing == NULL) {
|
||||
/* old filtering */
|
||||
file = procmsg_get_message_file_path(msginfo);
|
||||
dest = filter_get_dest_folder(prefs_common.fltlist, file);
|
||||
|
@ -3570,7 +3571,7 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
|
|||
summary_move_row_to(summaryview, node, dest);
|
||||
}
|
||||
else
|
||||
filter_msginfo_move_or_delete(prefs_filtering, msginfo,
|
||||
filter_msginfo_move_or_delete(global_processing, msginfo,
|
||||
summaryview->folder_table);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue