2007-03-04 [colin] 2.8.0cvs17
authorColin Leroy <colin@colino.net>
Sun, 4 Mar 2007 20:46:01 +0000 (20:46 +0000)
committerColin Leroy <colin@colino.net>
Sun, 4 Mar 2007 20:46:01 +0000 (20:46 +0000)
* src/filtering.c
* src/matcher.c
* src/matcher.h
* src/matcher_parser_parse.y
* src/prefs_filtering_action.c
Add 'Mark as spam' and 'Mark as ham' filtering
actions. Fixes bug 1138.

ChangeLog
PATCHSETS
configure.ac
src/filtering.c
src/matcher.c
src/matcher.h
src/matcher_parser_parse.y
src/prefs_filtering_action.c

index 48b21bc..55970af 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-03-04 [colin]     2.8.0cvs17
+
+       * src/filtering.c
+       * src/matcher.c
+       * src/matcher.h
+       * src/matcher_parser_parse.y
+       * src/prefs_filtering_action.c
+               Add 'Mark as spam' and 'Mark as ham' filtering
+               actions. Fixes bug 1138.
+
 2007-03-04 [colin]     2.8.0cvs16
 
        * src/imap.c
index be1dab6..b86983b 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.27.2.31 -r 1.27.2.32 src/addr_compl.c;  ) > 2.8.0cvs14.patchset
 ( cvs diff -u -r 1.27.2.32 -r 1.27.2.33 src/addr_compl.c;  ) > 2.8.0cvs15.patchset
 ( cvs diff -u -r 1.179.2.157 -r 1.179.2.158 src/imap.c;  ) > 2.8.0cvs16.patchset
+( cvs diff -u -r 1.60.2.25 -r 1.60.2.26 src/filtering.c;  cvs diff -u -r 1.75.2.36 -r 1.75.2.37 src/matcher.c;  cvs diff -u -r 1.39.2.10 -r 1.39.2.11 src/matcher.h;  cvs diff -u -r 1.25.2.25 -r 1.25.2.26 src/matcher_parser_parse.y;  cvs diff -u -r 1.1.4.34 -r 1.1.4.35 src/prefs_filtering_action.c;  ) > 2.8.0cvs17.patchset
index 675f4e2..82252bd 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=16
+EXTRA_VERSION=17
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 2f018e1..ba7eca9 100644 (file)
@@ -326,6 +326,19 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
                procmsg_msginfo_set_flags(info, MSG_UNREAD | MSG_NEW, 0);
                return TRUE;
        
+       case MATCHACTION_MARK_AS_SPAM:
+               procmsg_spam_learner_learn(info, NULL, TRUE);
+               procmsg_msginfo_change_flags(info, MSG_SPAM, 0, MSG_NEW|MSG_UNREAD, 0);
+               if (procmsg_spam_get_folder(info)) {
+                       info->is_move = TRUE;
+                       info->to_filter_folder = procmsg_spam_get_folder(info);
+               }
+               return TRUE;
+
+       case MATCHACTION_MARK_AS_HAM:
+               procmsg_spam_learner_learn(info, NULL, FALSE);
+               return TRUE;
+       
        case MATCHACTION_COLOR:
                procmsg_msginfo_unset_flags(info, MSG_CLABEL_FLAG_MASK, 0); 
                procmsg_msginfo_set_flags(info, MSG_COLORLABEL_TO_FLAGS(action->labelcolor), 0);
@@ -490,6 +503,7 @@ static gboolean filtering_is_final_action(FilteringAction *filtering_action)
        case MATCHACTION_MOVE:
        case MATCHACTION_DELETE:
        case MATCHACTION_STOP:
+       case MATCHACTION_MARK_AS_SPAM:
                return TRUE; /* MsgInfo invalid for message */
        default:
                return FALSE;
@@ -567,6 +581,8 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_UNLOCK:
        case MATCHACTION_MARK_AS_READ:
        case MATCHACTION_MARK_AS_UNREAD:
+       case MATCHACTION_MARK_AS_SPAM:
+       case MATCHACTION_MARK_AS_HAM:
        case MATCHACTION_STOP:
        case MATCHACTION_HIDE:
        case MATCHACTION_IGNORE:
index 0bab1b0..cf73a5b 100644 (file)
@@ -141,6 +141,8 @@ static const MatchParser matchparser_tab[] = {
        {MATCHACTION_UNLOCK, "unlock"},
        {MATCHACTION_MARK_AS_READ, "mark_as_read"},
        {MATCHACTION_MARK_AS_UNREAD, "mark_as_unread"},
+       {MATCHACTION_MARK_AS_SPAM, "mark_as_spam"},
+       {MATCHACTION_MARK_AS_HAM, "mark_as_ham"},
        {MATCHACTION_FORWARD, "forward"},
        {MATCHACTION_FORWARD_AS_ATTACHMENT, "forward_as_attachment"},
        {MATCHACTION_EXECUTE, "execute"},
index 119d285..55998b3 100644 (file)
@@ -121,6 +121,8 @@ enum {
        MA_(UNLOCK),
        MA_(MARK_AS_READ),
        MA_(MARK_AS_UNREAD),
+       MA_(MARK_AS_SPAM),
+       MA_(MARK_AS_HAM),
        MA_(FORWARD),
        MA_(FORWARD_AS_ATTACHMENT),
        MA_(COLOR),
index d0a3b64..69184e9 100644 (file)
@@ -323,6 +323,7 @@ int matcher_parserwrap(void)
 %token MATCHER_LOCK MATCHER_UNLOCK
 %token MATCHER_EXECUTE
 %token MATCHER_MARK_AS_READ  MATCHER_MARK_AS_UNREAD  MATCHER_FORWARD
+%token MATCHER_MARK_AS_SPAM MATCHER_MARK_AS_HAM
 %token MATCHER_FORWARD_AS_ATTACHMENT  MATCHER_EOL
 %token MATCHER_OR MATCHER_AND  
 %token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT 
@@ -1172,6 +1173,20 @@ MATCHER_EXECUTE MATCHER_STRING
        action_type = MATCHACTION_MARK_AS_UNREAD;
        action = filteringaction_new(action_type, 0, NULL, 0, 0);
 }
+| MATCHER_MARK_AS_SPAM
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MARK_AS_SPAM;
+       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+}
+| MATCHER_MARK_AS_HAM
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MARK_AS_HAM;
+       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+}
 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
 {
        gchar *destination = NULL;
index c87e5c8..f627edc 100644 (file)
@@ -130,6 +130,8 @@ typedef enum Action_ {
        ACTION_UNLOCK,
        ACTION_MARK_AS_READ,
        ACTION_MARK_AS_UNREAD,
+       ACTION_MARK_AS_SPAM,
+       ACTION_MARK_AS_HAM,
        ACTION_FORWARD,
        ACTION_FORWARD_AS_ATTACHMENT,
        ACTION_REDIRECT,
@@ -156,6 +158,8 @@ static struct {
        { N_("Unlock"),                 ACTION_UNLOCK   },
        { N_("Mark as read"),           ACTION_MARK_AS_READ },
        { N_("Mark as unread"),         ACTION_MARK_AS_UNREAD },
+       { N_("Mark as spam"),           ACTION_MARK_AS_SPAM },
+       { N_("Mark as ham"),            ACTION_MARK_AS_HAM },
        { N_("Forward"),                ACTION_FORWARD  },
        { N_("Forward as attachment"),  ACTION_FORWARD_AS_ATTACHMENT },
        { N_("Redirect"),               ACTION_REDIRECT },
@@ -737,6 +741,10 @@ static gint prefs_filtering_action_get_matching_from_action(Action action_id)
                return MATCHACTION_MARK_AS_READ;
        case ACTION_MARK_AS_UNREAD:
                return MATCHACTION_MARK_AS_UNREAD;
+       case ACTION_MARK_AS_SPAM:
+               return MATCHACTION_MARK_AS_SPAM;
+       case ACTION_MARK_AS_HAM:
+               return MATCHACTION_MARK_AS_HAM;
        case ACTION_FORWARD:
                return MATCHACTION_FORWARD;
        case ACTION_FORWARD_AS_ATTACHMENT:
@@ -840,6 +848,8 @@ static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
         case ACTION_UNLOCK:
         case ACTION_MARK_AS_READ:
         case ACTION_MARK_AS_UNREAD:
+        case ACTION_MARK_AS_SPAM:
+        case ACTION_MARK_AS_HAM:
        default:
                break;
        }
@@ -1221,6 +1231,8 @@ static void prefs_filtering_action_type_select(GtkList *list,
        case ACTION_UNLOCK:
        case ACTION_MARK_AS_READ:
        case ACTION_MARK_AS_UNREAD:
+       case ACTION_MARK_AS_SPAM:
+       case ACTION_MARK_AS_HAM:
         case ACTION_STOP:
         case ACTION_HIDE:
        case ACTION_IGNORE:
@@ -1500,6 +1512,14 @@ static gboolean prefs_filtering_actions_selected
                gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
                                     ACTION_MARK_AS_UNREAD);
                break;
+       case MATCHACTION_MARK_AS_SPAM:
+               gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
+                                    ACTION_MARK_AS_SPAM);
+               break;
+       case MATCHACTION_MARK_AS_HAM:
+               gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
+                                    ACTION_MARK_AS_HAM);
+               break;
        case MATCHACTION_FORWARD:
                list_id = get_list_id_from_account_id(action->account_id);
                gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),