remove selective download
[claws.git] / src / filtering.c
index e851a8be21c0ab17404bb57c0cb342e13ad4a703..5640ad6f5017505e42865d27d1f83b7e396aaf01 100644 (file)
@@ -29,7 +29,7 @@
 #include "procheader.h"
 #include "matcher.h"
 #include "filtering.h"
-#include "prefs.h"
+#include "prefs_gtk.h"
 #include "compose.h"
 
 #define PREFSBUFSIZE           1024
@@ -57,6 +57,11 @@ FilteringAction * filteringaction_new(int type, int account_id,
 
        action = g_new0(FilteringAction, 1);
 
+       /* NOTE:
+        * if type is MATCHACTION_CHANGE_SCORE, account_id = (-1, 0, 1) and
+        * labelcolor = the score value change
+        */
+
        action->type = type;
        action->account_id = account_id;
        if (destination) {
@@ -262,6 +267,17 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
                }
                return TRUE;
 
+       case MATCHACTION_CHANGE_SCORE:
+               /* NOTE:
+                * action->account_id is 0 if just assignment, -1 if decrement
+                * and 1 if increment by action->labelcolor 
+                * action->labelcolor has the score value change
+                */
+               info->score = action->account_id ==  1 ? info->score + action->labelcolor
+                           : action->account_id == -1 ? info->score - action->labelcolor
+                           : action->labelcolor; 
+               return TRUE;
+
        default:
                break;
        }
@@ -279,7 +295,7 @@ static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info)
        gchar    buf[50];
 
        if (FALSE == (result = filteringaction_apply(filtering->action, info))) {
-               g_warning(_("action %s could not be applied")
+               g_warning("action %s could not be applied"
                filteringaction_to_string(buf, sizeof buf, filtering->action));
        }
        return result;
@@ -314,7 +330,7 @@ static void filter_msginfo(GSList * filtering_list, FolderItem *inbox,
        gboolean applied;
        
        if (info == NULL) {
-               g_warning(_("msginfo is not set"));
+               g_warning("msginfo is not set");
                return;
        }
        
@@ -386,14 +402,14 @@ void filter_message(GSList *filtering_list, FolderItem *inbox,
        FolderItem *item = folder_get_default_processing();
 
        if (item == NULL) {
-               g_warning(_("folderitem not set"));
+               g_warning("folderitem not set");
                return;
        }
 
        filename = folder_item_fetch_msg(item, msgnum);
 
        if (filename == NULL) {
-               g_warning(_("filename is not set"));
+               g_warning("filename is not set");
                return;
        }
 
@@ -402,7 +418,7 @@ void filter_message(GSList *filtering_list, FolderItem *inbox,
        g_free(filename);
 
        if (msginfo == NULL) {
-               g_warning(_("could not get info for %s"), filename);
+               g_warning("could not get info for %s", filename);
                return;
        }
 
@@ -416,7 +432,7 @@ void filter_message(GSList *filtering_list, FolderItem *inbox,
 
 gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action)
 {
-       gchar *command_str;
+       const gchar *command_str;
 
        command_str = get_matchparser_tab_str(action->type);
 
@@ -447,9 +463,6 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_COLOR:
                g_snprintf(dest, destlen, "%s %d", command_str, action->labelcolor);
                return dest;  
-       case MATCHACTION_DELETE_ON_SERVER:
-               g_snprintf(dest, destlen, "%s", command_str);
-               return dest;
        default:
                return NULL;
        }