Fix a memory leak in matcherrc rule parsing.
[claws.git] / src / matcher_parser_parse.y
index c001713c30216284a84fb542e43a2d3a2bb73266..20dc91e0cf281acfd3da18c7aeeb22967b760f4e 100644 (file)
@@ -1,11 +1,11 @@
 %{
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (c) 2001-2007 by Hiroyuki Yamamoto & The Claws Mail Team
+ * Copyright (c) 2001-2014 by Hiroyuki Yamamoto & The Claws Mail Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -14,8 +14,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #include "defs.h"
@@ -28,9 +28,8 @@
 #include "matcher.h"
 #include "matcher_parser.h"
 #include "matcher_parser_lex.h"
-#include "procmsg.h"
-
-#define MAX_COLORLABELS (MSG_CLABEL_7 - MSG_CLABEL_NONE)
+#include "colorlabel.h"
+#include "folder_item_prefs.h"
 
 static gint error = 0;
 static gint bool_op = 0;
@@ -48,6 +47,7 @@ static MatcherList *cond;
 static GSList *action_list = NULL;
 static FilteringAction *action = NULL;
 static gboolean matcher_is_fast = TRUE;
+static gboolean disable_warnings = FALSE;
 
 static FilteringProp *filtering;
 
@@ -73,10 +73,17 @@ void matcher_parserrestart(FILE *input_file);
 void matcher_parser_init(void);
 void matcher_parser_switch_to_buffer(void * new_buffer);
 void matcher_parser_delete_buffer(void * b);
+void matcher_parserpop_buffer_state(void);
 int matcher_parserlex(void);
 
+void matcher_parser_disable_warnings(const gboolean disable)
+{
+       disable_warnings = disable;
+}
+
 void matcher_parser_start_parsing(FILE *f)
 {
+       matcher_parserlineno = 1;
        matcher_parserrestart(f);
        account_id = 0;
        matcher_parserparse();
@@ -101,6 +108,7 @@ FilteringProp *matcher_parser_get_filtering(gchar *str)
        matcher_parserlineno = 1;
        matcher_parse_op = MATCHER_PARSE_NO_EOL;
        matcher_parserrestart(NULL);
+       matcher_parserpop_buffer_state();
         matcher_parser_init();
        bufstate = matcher_parser_scan_string((const char *) tmp_str);
         matcher_parser_switch_to_buffer(bufstate);
@@ -145,6 +153,7 @@ MatcherList *matcher_parser_get_name(gchar *str)
        matcher_parserlineno = 1;
        matcher_parse_op = MATCHER_PARSE_NAME;
        matcher_parserrestart(NULL);
+       matcher_parserpop_buffer_state();
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
@@ -167,6 +176,7 @@ MatcherList *matcher_parser_get_enabled(gchar *str)
        matcher_parserlineno = 1;
        matcher_parse_op = MATCHER_PARSE_ENABLED;
        matcher_parserrestart(NULL);
+       matcher_parserpop_buffer_state();
        matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
@@ -189,6 +199,7 @@ MatcherList *matcher_parser_get_account(gchar *str)
        matcher_parserlineno = 1;
        matcher_parse_op = MATCHER_PARSE_ACCOUNT;
        matcher_parserrestart(NULL);
+       matcher_parserpop_buffer_state();
        matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
@@ -212,6 +223,7 @@ MatcherList *matcher_parser_get_cond(gchar *str, gboolean *is_fast)
        matcher_parserlineno = 1;
        matcher_parse_op = MATCHER_PARSE_CONDITION;
        matcher_parserrestart(NULL);
+       matcher_parserpop_buffer_state();
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
@@ -236,6 +248,7 @@ GSList *matcher_parser_get_action_list(gchar *str)
        matcher_parserlineno = 1;
        matcher_parse_op = MATCHER_PARSE_FILTERING_ACTION;
        matcher_parserrestart(NULL);
+       matcher_parserpop_buffer_state();
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
@@ -282,8 +295,9 @@ void matcher_parsererror(char *str)
                matchers_list = NULL;
        }
        cond = NULL;
-       g_warning("filtering parsing: %i: %s\n",
-                 matcher_parserlineno, str);
+       if (!disable_warnings)
+               g_warning("filtering parsing: %i: %s",
+                       matcher_parserlineno, str);
        error = 1;
 }
 
@@ -305,10 +319,13 @@ int matcher_parserwrap(void)
 %token MATCHER_FROM  MATCHER_NOT_FROM  MATCHER_TO  MATCHER_NOT_TO
 %token MATCHER_CC  MATCHER_NOT_CC  MATCHER_TO_OR_CC  MATCHER_NOT_TO_AND_NOT_CC
 %token MATCHER_AGE_GREATER  MATCHER_AGE_LOWER  MATCHER_NEWSGROUPS
+%token MATCHER_AGE_GREATER_HOURS  MATCHER_AGE_LOWER_HOURS
 %token MATCHER_NOT_NEWSGROUPS  MATCHER_INREPLYTO  MATCHER_NOT_INREPLYTO
+%token MATCHER_MESSAGEID MATCHER_NOT_MESSAGEID
 %token MATCHER_REFERENCES  MATCHER_NOT_REFERENCES  MATCHER_SCORE_GREATER
 %token MATCHER_SCORE_LOWER  MATCHER_HEADER  MATCHER_NOT_HEADER
 %token MATCHER_HEADERS_PART  MATCHER_NOT_HEADERS_PART  MATCHER_MESSAGE
+%token MATCHER_HEADERS_CONT  MATCHER_NOT_HEADERS_CONT
 %token MATCHER_NOT_MESSAGE  MATCHER_BODY_PART  MATCHER_NOT_BODY_PART
 %token MATCHER_TEST  MATCHER_NOT_TEST  MATCHER_MATCHCASE  MATCHER_MATCH
 %token MATCHER_REGEXPCASE  MATCHER_REGEXP  MATCHER_SCORE  MATCHER_MOVE
@@ -317,7 +334,8 @@ 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_FORWARD_AS_ATTACHMENT  MATCHER_EOL  MATCHER_STRING  
+%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 
 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
@@ -325,8 +343,15 @@ int matcher_parserwrap(void)
 %token MATCHER_PARTIAL MATCHER_NOT_PARTIAL
 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
+%token MATCHER_WATCH_THREAD MATCHER_NOT_WATCH_THREAD
 %token MATCHER_CHANGE_SCORE MATCHER_SET_SCORE
-%token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE
+%token MATCHER_ADD_TO_ADDRESSBOOK
+%token MATCHER_STOP MATCHER_HIDE MATCHER_IGNORE MATCHER_WATCH
+%token MATCHER_SPAM MATCHER_NOT_SPAM
+%token MATCHER_HAS_ATTACHMENT MATCHER_HAS_NO_ATTACHMENT
+%token MATCHER_SIGNED MATCHER_NOT_SIGNED
+%token MATCHER_TAG MATCHER_NOT_TAG MATCHER_SET_TAG MATCHER_UNSET_TAG
+%token MATCHER_TAGGED MATCHER_NOT_TAGGED MATCHER_CLEAR_TAGS
 
 %start file
 
@@ -512,6 +537,9 @@ filtering_action_list
                *prefs_filtering = g_slist_append(*prefs_filtering,
                                                  filtering);
                filtering = NULL;
+       } else {
+               filteringprop_free(filtering);
+               filtering = NULL;
        }
 }
 ;
@@ -685,6 +713,48 @@ MATCHER_ALL
        criteria = MATCHCRITERIA_NOT_LOCKED;
        prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
 }
+| MATCHER_SPAM
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_SPAM;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_SPAM 
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_SPAM;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_HAS_ATTACHMENT
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_HAS_ATTACHMENT;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_HAS_NO_ATTACHMENT
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_HAS_NO_ATTACHMENT;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_SIGNED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_SIGNED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_SIGNED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_SIGNED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
 | MATCHER_PARTIAL
 {
        gint criteria = 0;
@@ -707,7 +777,7 @@ MATCHER_ALL
        criteria = MATCHCRITERIA_COLORLABEL;
        value = strtol($2, NULL, 10);
        if (value < 0) value = 0;
-       else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
+       else if (value > COLORLABELS) value = COLORLABELS;
        prop = matcherprop_new(criteria, NULL, 0, NULL, value);
 }
 | MATCHER_NOT_COLORLABEL MATCHER_INTEGER
@@ -718,7 +788,7 @@ MATCHER_ALL
        criteria = MATCHCRITERIA_NOT_COLORLABEL;
        value = strtol($2, NULL, 0);
        if (value < 0) value = 0;
-       else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
+       else if (value > COLORLABELS) value = COLORLABELS;
        prop = matcherprop_new(criteria, NULL, 0, NULL, value);
 }
 | MATCHER_IGNORE_THREAD
@@ -735,6 +805,20 @@ MATCHER_ALL
        criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
        prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
 }
+| MATCHER_WATCH_THREAD
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_WATCH_THREAD;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_WATCH_THREAD
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_WATCH_THREAD;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
 | MATCHER_SUBJECT match_type MATCHER_STRING
 {
        gint criteria = 0;
@@ -825,6 +909,38 @@ MATCHER_ALL
        expr = $3;
        prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
 }
+| MATCHER_TAG match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar *expr = NULL;
+
+       criteria = MATCHCRITERIA_TAG;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_TAG match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar *expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_TAG;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_TAGGED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_TAGGED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_TAGGED
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_TAGGED;
+       prop = matcherprop_new(criteria, NULL, 0, NULL, 0);
+}
 | MATCHER_AGE_GREATER MATCHER_INTEGER
 {
        gint criteria = 0;
@@ -843,6 +959,24 @@ MATCHER_ALL
        value = strtol($2, NULL, 0);
        prop = matcherprop_new(criteria, NULL, 0, NULL, value);
 }
+| MATCHER_AGE_GREATER_HOURS MATCHER_INTEGER
+{
+       gint criteria = 0;
+       gint value = 0;
+
+       criteria = MATCHCRITERIA_AGE_GREATER_HOURS;
+       value = strtol($2, NULL, 0);
+       prop = matcherprop_new(criteria, NULL, 0, NULL, value);
+}
+| MATCHER_AGE_LOWER_HOURS MATCHER_INTEGER
+{
+       gint criteria = 0;
+       gint value = 0;
+
+       criteria = MATCHCRITERIA_AGE_LOWER_HOURS;
+       value = strtol($2, NULL, 0);
+       prop = matcherprop_new(criteria, NULL, 0, NULL, value);
+}
 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
 {
        gint criteria = 0;
@@ -861,6 +995,24 @@ MATCHER_ALL
        expr = $3;
        prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
 }
+| MATCHER_MESSAGEID match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar *expr = NULL;
+
+       criteria = MATCHCRITERIA_MESSAGEID;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_MESSAGEID match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar *expr = NULL;
+
+       criteria = MATCHCRITERIA_NOT_MESSAGEID;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
 | MATCHER_INREPLYTO match_type MATCHER_STRING
 {
        gint criteria = 0;
@@ -992,6 +1144,24 @@ MATCHER_ALL
        expr = $3;
        prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
 }
+| MATCHER_HEADERS_CONT match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar *expr = NULL;
+       matcher_is_fast = FALSE;
+       criteria = MATCHCRITERIA_HEADERS_CONT;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
+| MATCHER_NOT_HEADERS_CONT match_type MATCHER_STRING
+{
+       gint criteria = 0;
+       gchar *expr = NULL;
+       matcher_is_fast = FALSE;
+       criteria = MATCHCRITERIA_NOT_HEADERS_CONT;
+       expr = $3;
+       prop = matcherprop_new(criteria, NULL, match_type, expr, 0);
+}
 | MATCHER_FOUND_IN_ADDRESSBOOK MATCHER_STRING
 {
        header = g_strdup($2);
@@ -1061,7 +1231,7 @@ MATCHER_ALL
        matcher_is_fast = FALSE;
        criteria = MATCHCRITERIA_TEST;
        expr = $2;
-       prop = matcherprop_new(criteria, NULL, 0, expr, 0);
+       prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
 }
 | MATCHER_NOT_TEST MATCHER_STRING
 {
@@ -1070,7 +1240,7 @@ MATCHER_ALL
        matcher_is_fast = FALSE;
        criteria = MATCHCRITERIA_NOT_TEST;
        expr = $2;
-       prop = matcherprop_new(criteria, NULL, 0, expr, 0);
+       prop = matcherprop_new(criteria, NULL, MATCHTYPE_MATCH, expr, 0);
 }
 ;
 
@@ -1082,7 +1252,7 @@ MATCHER_EXECUTE MATCHER_STRING
 
        action_type = MATCHACTION_EXECUTE;
        cmd = $2;
-       action = filteringaction_new(action_type, 0, cmd, 0, 0);
+       action = filteringaction_new(action_type, 0, cmd, 0, 0, NULL);
 }
 | MATCHER_MOVE MATCHER_STRING
 {
@@ -1091,7 +1261,32 @@ MATCHER_EXECUTE MATCHER_STRING
 
        action_type = MATCHACTION_MOVE;
        destination = $2;
-       action = filteringaction_new(action_type, 0, destination, 0, 0);
+       action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
+}
+| MATCHER_SET_TAG MATCHER_STRING
+{
+       gchar *destination = NULL;
+       gint action_type = 0;
+
+       action_type = MATCHACTION_SET_TAG;
+       destination = $2;
+       action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
+}
+| MATCHER_UNSET_TAG MATCHER_STRING
+{
+       gchar *destination = NULL;
+       gint action_type = 0;
+
+       action_type = MATCHACTION_UNSET_TAG;
+       destination = $2;
+       action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
+}
+| MATCHER_CLEAR_TAGS
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_CLEAR_TAGS;
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_COPY MATCHER_STRING
 {
@@ -1100,56 +1295,70 @@ MATCHER_EXECUTE MATCHER_STRING
 
        action_type = MATCHACTION_COPY;
        destination = $2;
-       action = filteringaction_new(action_type, 0, destination, 0, 0);
+       action = filteringaction_new(action_type, 0, destination, 0, 0, NULL);
 }
 | MATCHER_DELETE
 {
        gint action_type = 0;
 
        action_type = MATCHACTION_DELETE;
-       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_MARK
 {
        gint action_type = 0;
 
        action_type = MATCHACTION_MARK;
-       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_UNMARK
 {
        gint action_type = 0;
 
        action_type = MATCHACTION_UNMARK;
-       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_LOCK
 {
        gint action_type = 0;
 
        action_type = MATCHACTION_LOCK;
-       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_UNLOCK
 {
        gint action_type = 0;
 
        action_type = MATCHACTION_UNLOCK;
-       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_MARK_AS_READ
 {
        gint action_type = 0;
 
        action_type = MATCHACTION_MARK_AS_READ;
-       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_MARK_AS_UNREAD
 {
        gint action_type = 0;
 
        action_type = MATCHACTION_MARK_AS_UNREAD;
-       action = filteringaction_new(action_type, 0, NULL, 0, 0);
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
+}
+| MATCHER_MARK_AS_SPAM
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MARK_AS_SPAM;
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
+}
+| MATCHER_MARK_AS_HAM
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_MARK_AS_HAM;
+       action = filteringaction_new(action_type, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
 {
@@ -1161,7 +1370,7 @@ MATCHER_EXECUTE MATCHER_STRING
        account_id = strtol($2, NULL, 10);
        destination = $3;
        action = filteringaction_new(action_type,
-            account_id, destination, 0, 0);
+            account_id, destination, 0, 0, NULL);
 }
 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
 {
@@ -1173,7 +1382,7 @@ MATCHER_EXECUTE MATCHER_STRING
        account_id = strtol($2, NULL, 10);
        destination = $3;
        action = filteringaction_new(action_type,
-            account_id, destination, 0, 0);
+            account_id, destination, 0, 0, NULL);
 }
 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
 {
@@ -1185,7 +1394,7 @@ MATCHER_EXECUTE MATCHER_STRING
        account_id = strtol($2, NULL, 10);
        destination = $3;
        action = filteringaction_new(action_type,
-            account_id, destination, 0, 0);
+            account_id, destination, 0, 0, NULL);
 }
 | MATCHER_COLOR MATCHER_INTEGER
 {
@@ -1194,7 +1403,7 @@ MATCHER_EXECUTE MATCHER_STRING
 
        action_type = MATCHACTION_COLOR;
        color = strtol($2, NULL, 10);
-       action = filteringaction_new(action_type, 0, NULL, color, 0);
+       action = filteringaction_new(action_type, 0, NULL, color, 0, NULL);
 }
 | MATCHER_CHANGE_SCORE MATCHER_INTEGER
 {
@@ -1202,7 +1411,7 @@ MATCHER_EXECUTE MATCHER_STRING
         
         score = strtol($2, NULL, 10);
        action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
-                                    NULL, 0, score);
+                                    NULL, 0, score, NULL);
 }
 /* backward compatibility */
 | MATCHER_SCORE MATCHER_INTEGER
@@ -1211,7 +1420,7 @@ MATCHER_EXECUTE MATCHER_STRING
         
         score = strtol($2, NULL, 10);
        action = filteringaction_new(MATCHACTION_CHANGE_SCORE, 0,
-                                    NULL, 0, score);
+                                    NULL, 0, score, NULL);
 }
 | MATCHER_SET_SCORE MATCHER_INTEGER
 {
@@ -1219,18 +1428,35 @@ MATCHER_EXECUTE MATCHER_STRING
         
         score = strtol($2, NULL, 10);
        action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
-                                    NULL, 0, score);
+                                    NULL, 0, score, NULL);
 }
 | MATCHER_HIDE
 {
-       action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0);
+       action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0, NULL);
 }
 | MATCHER_IGNORE
 {
-       action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0);
+       action = filteringaction_new(MATCHACTION_IGNORE, 0, NULL, 0, 0, NULL);
+}
+| MATCHER_WATCH
+{
+       action = filteringaction_new(MATCHACTION_WATCH, 0, NULL, 0, 0, NULL);
+}
+| MATCHER_ADD_TO_ADDRESSBOOK MATCHER_STRING
+{
+       header = g_strdup($2);
+} MATCHER_STRING
+{
+       gchar *addressbook = NULL;
+       gint action_type = 0;
+
+       action_type = MATCHACTION_ADD_TO_ADDRESSBOOK;
+       addressbook = $2;
+       action = filteringaction_new(action_type, 0, addressbook, 0, 0, header);
+       g_free(header);
 }
 | MATCHER_STOP
 {
-       action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0);
+       action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0, NULL);
 }
 ;