2007-07-02 [colin] 2.10.0cvs1
[claws.git] / src / filtering.c
index e8b0737f602ba04d3b2c57bacbbac18fbea20853..e8b5d3e939eaf6f1b5afedc572e5b68144c16c3f 100644 (file)
@@ -36,6 +36,7 @@
 #include "prefs_common.h"
 #include "addrbook.h"
 #include "addr_compl.h"
+#include "tags.h"
 #include "log.h"
 
 #define PREFSBUFSIZE           1024
@@ -310,6 +311,22 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
                info->to_filter_folder = dest_folder;
                return TRUE;
 
+       case MATCHACTION_SET_TAG:
+       case MATCHACTION_UNSET_TAG:
+               val = tags_get_id_for_str(action->destination);
+               if (val == -1) {
+                       debug_print("*** tag '%s' not found\n",
+                               action->destination ?action->destination :"");
+                       return FALSE;
+               }
+               
+               procmsg_msginfo_update_tags(info, (action->type == MATCHACTION_SET_TAG), val);
+               return TRUE;
+
+       case MATCHACTION_CLEAR_TAGS:
+               procmsg_msginfo_clear_tags(info);
+               return TRUE;
+
        case MATCHACTION_DELETE:
                if (folder_item_remove_msg(info->folder, info->msgnum) == -1)
                        return FALSE;
@@ -875,6 +892,8 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_MOVE:
        case MATCHACTION_COPY:
        case MATCHACTION_EXECUTE:
+       case MATCHACTION_SET_TAG:
+       case MATCHACTION_UNSET_TAG:
                quoted_dest = matcher_quote_str(action->destination);
                g_snprintf(dest, destlen, "%s \"%s\"", command_str, quoted_dest);
                g_free(quoted_dest);
@@ -892,6 +911,7 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_STOP:
        case MATCHACTION_HIDE:
        case MATCHACTION_IGNORE:
+       case MATCHACTION_CLEAR_TAGS:
                g_snprintf(dest, destlen, "%s", command_str);
                return dest;