merge of scoring and filtering.
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Thu, 4 Dec 2003 02:50:42 +0000 (02:50 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Thu, 4 Dec 2003 02:50:42 +0000 (02:50 +0000)
26 files changed:
ChangeLog.claws
configure.ac
src/Makefile.am
src/filtering.c
src/filtering.h
src/folder.c
src/folder_item_prefs.c
src/folder_item_prefs.h
src/folderview.c
src/main.c
src/mainwindow.c
src/matcher.c
src/matcher.h
src/matcher_parser.h
src/matcher_parser_parse.y
src/prefs_filtering.c
src/prefs_filtering.h
src/prefs_filtering_action.c
src/prefs_folder_item.c
src/prefs_scoring.c [deleted file]
src/prefs_scoring.h [deleted file]
src/procmsg.c
src/procmsg.h
src/scoring.c [deleted file]
src/scoring.h [deleted file]
src/summaryview.c

index 1ef72dc..11e4c48 100644 (file)
@@ -1,3 +1,53 @@
+2003-12-03 [hoa]       0.9.7claws17
+
+       * src/Makefile.am
+               compilation of scoring.[ch] and prefs_scoring.[ch]
+               is removed.
+       
+       * src/filtering.[ch]
+       * src/folder.c
+       * src/folder_item_prefs.[ch]
+       * src/folderview.c
+       * src/main.c
+       * src/mainwindow.c
+       * src/matcher.[ch]
+       * src/matcher_parser.h
+       * src/matcher_parser_parse.y
+       * src/prefs_filtering.[ch]
+       * src/prefs_filtering_action.c
+       * src/prefs_folder_item.c
+       * src/prefs_scoring.[ch]              * REMOVED FILES *
+       * src/procmsg.[ch]
+       * src/scoring.[ch]                    * REMOVED FILES *
+       * src/summaryview.c
+               merged scoring and filtering.
+               
+               Note : compatibility is kept by parsing score such as 
+                 add_score. To get the behaviour of older scoring 
+                 system, you have to define some equivalent rule :
+                 "score_lower -9999 hide"
+                 "score_greater -9999 mark"
+                 
+                 To define global rules, you have to define them 
+                 in the new global processing rules.
+                 The variable that kept the list filtering rules 
+                 was "global_processing" and has been renamed into 
+                 "filtering_rules".
+                 "global_processing" variable is now the name 
+                 of the variable that keeps the list of global 
+                 processing rules.
+                 In the configuration file, "[global]" section is 
+                 now for the global processing rules (which includes
+                 score things and new global processing rules).
+                 New "[filtering]" section is for the filtering rules.
+                 
+                 Before running with this version, during testing 
+                 phase, ** MAKE A BACKUP ** of your matcherrc file.
+                 Then, you have to make the following changes :
+                 - leave all scoring rules in "[global]" section.
+                 - move all other rules of "[global]" section to
+                     a new section named "[filtering]".
+
 2003-12-03 [christoph] 0.9.7claws16
 
        * src/procmime.c
index 1afdc13..bed47f3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=7
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=16
+EXTRA_VERSION=17
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 934e67e..337cba8 100644 (file)
@@ -89,7 +89,6 @@ sylpheed_SOURCES = \
        prefs_fonts.c \
        prefs_gtk.c \
        prefs_matcher.c \
-       prefs_scoring.c \
        prefs_spelling.c \
        prefs_summary_column.c \
        prefs_template.c \
@@ -103,7 +102,6 @@ sylpheed_SOURCES = \
        quote_fmt_parse.y \
        recv.c \
        rfc2015.c \
-       scoring.c \
        select-keys.c \
        send_message.c \
        setup.c \
@@ -216,7 +214,6 @@ sylpheedinclude_HEADERS = \
        prefs_fonts.h \
        prefs_gtk.h \
        prefs_matcher.h \
-       prefs_scoring.h \
        prefs_spelling.h \
        prefs_summary_column.h \
        prefs_template.h \
@@ -230,7 +227,6 @@ sylpheedinclude_HEADERS = \
        quote_fmt_parse.h \
        recv.h \
        rfc2015.h \
-       scoring.h \
        select-keys.h \
        send_message.h \
        setup.h \
index 4ffdab3..22369ec 100644 (file)
@@ -35,6 +35,7 @@
 #define PREFSBUFSIZE           1024
 
 GSList * global_processing = NULL;
+GSList * filtering_rules = NULL;
 
 static gboolean filtering_is_final_action(FilteringAction *filtering_action);
 
@@ -301,7 +302,11 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
                return TRUE;
 
        case MATCHACTION_STOP:
-                break;
+                return TRUE;
+
+       case MATCHACTION_HIDE:
+                info->hidden = TRUE;
+                return TRUE;
 
        default:
                break;
@@ -429,6 +434,7 @@ gchar *filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *act
        case MATCHACTION_MARK_AS_READ:
        case MATCHACTION_MARK_AS_UNREAD:
        case MATCHACTION_STOP:
+       case MATCHACTION_HIDE:
                g_snprintf(dest, destlen, "%s", command_str);
                return dest;
 
@@ -542,6 +548,8 @@ void prefs_filtering_clear(void)
                                prefs_filtering_free_func, NULL);
        }
 
+       prefs_filtering_free(filtering_rules);
+       filtering_rules = NULL;
        prefs_filtering_free(global_processing);
        global_processing = NULL;
 }
index 8f1f0c0..c6381d4 100644 (file)
@@ -74,6 +74,7 @@ void prefs_filtering_free(GSList *prefs_filtering);
 
 FilteringProp * filteringprop_copy(FilteringProp *src);
 
+extern GSList * filtering_rules;
 extern GSList * global_processing;
 
 #endif
index f84c1b8..d6d261f 100644 (file)
@@ -43,7 +43,6 @@
 #include "prefs_gtk.h"
 #include "account.h"
 #include "filtering.h"
-#include "scoring.h"
 #include "procheader.h"
 #include "hooks.h"
 #include "log.h"
@@ -511,7 +510,6 @@ void folder_tree_destroy(Folder *folder)
 
        node = folder->node;
        
-       prefs_scoring_clear_folder(folder);
        prefs_filtering_clear_folder(folder);
 
        if (node != NULL) {
@@ -2878,7 +2876,17 @@ void folder_item_apply_processing(FolderItem *item)
                MsgInfo * msginfo;
 
                msginfo = (MsgInfo *) cur->data;
+                
+                /* reset parameters that can be modified by processing */
+                msginfo->hidden = 0;
+                msginfo->score = 0;
+                
+                /* apply global rules */
+               filter_message_by_msginfo(global_processing, msginfo);
+                
+                /* apply rules of the folder */
                filter_message_by_msginfo(processing_list, msginfo);
+                
                procmsg_msginfo_free(msginfo);
        }
        g_slist_free(mlist);
index 47fdece..a0de0de 100644 (file)
@@ -31,7 +31,6 @@
 #include "utils.h"
 #include "prefs_gtk.h"
 #include "filtering.h"
-#include "prefs_scoring.h"
 #include "folder_item_prefs.h"
 
 FolderItemPrefs tmp_prefs;
@@ -53,10 +52,12 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        /*{"enable_thread", "TRUE", &tmp_prefs.enable_thread, P_BOOL,
         NULL, NULL, NULL},*/
+#if 0
        {"hide_score", "-9999", &tmp_prefs.kill_score, P_INT,
         NULL, NULL, NULL},
        {"important_score", "1", &tmp_prefs.important_score, P_INT,
         NULL, NULL, NULL},
+#endif
        /* MIGRATION */  
        {"request_return_receipt", "", &tmp_prefs.request_return_receipt, P_BOOL,
         NULL, NULL, NULL},
@@ -164,8 +165,6 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->sort_by_subject = FALSE;
        prefs->sort_by_score = FALSE;
        prefs->sort_descending = FALSE;
-       prefs->kill_score = -9999;
-       prefs->important_score = 9999;
 
        prefs->request_return_receipt = FALSE;
        prefs->enable_default_to = FALSE;
@@ -186,7 +185,6 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->color = 0;
 
         prefs->enable_processing = TRUE;
-       prefs->scoring = NULL;
        prefs->processing = NULL;
        return prefs;
 }
@@ -206,8 +204,6 @@ void folder_item_prefs_free(FolderItemPrefs * prefs)
                g_free(prefs->default_to);
        if (prefs->default_reply_to) 
                g_free(prefs->default_reply_to);
-       if (prefs->scoring != NULL)
-               prefs_scoring_free(prefs->scoring);
        g_free(prefs);
 }
 
@@ -242,19 +238,9 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.sort_by_score                 = src->prefs->sort_by_score;
        tmp_prefs.sort_descending               = src->prefs->sort_descending;
        tmp_prefs.enable_thread                 = src->prefs->enable_thread;
-       tmp_prefs.kill_score                    = src->prefs->kill_score;
-       tmp_prefs.important_score               = src->prefs->important_score;
         tmp_prefs.enable_processing             = src->prefs->enable_processing;
 
        prefs_matcher_read_config();
-       for (tmp = src->prefs->scoring; tmp != NULL && tmp->data != NULL;) {
-               ScoringProp *prop = (ScoringProp *)tmp->data;
-               
-               tmp_scor_list = g_slist_append(tmp_scor_list,
-                                          scoringprop_copy(prop));
-               tmp = tmp->next;
-       }
-       tmp_prefs.scoring                       = tmp_scor_list;
 
        for (tmp = src->prefs->processing; tmp != NULL && tmp->data != NULL;) {
                FilteringProp *prop = (FilteringProp *)tmp->data;
index dd8252c..8fe1117 100644 (file)
@@ -41,11 +41,7 @@ struct _FolderItemPrefs {
 
        gboolean enable_thread;
 
-       gint kill_score;
-       gint important_score;
-
         int enable_processing;
-       GSList * scoring;
        GSList * processing;
 
        gboolean request_return_receipt;
index 0576793..ad91e16 100644 (file)
@@ -55,7 +55,6 @@
 #include "prefs_common.h"
 #include "prefs_account.h"
 #include "prefs_filtering.h"
-#include "prefs_scoring.h"
 #include "prefs_folder_item.h"
 #include "account.h"
 #include "folder.h"
@@ -273,8 +272,6 @@ gboolean folderview_update_folder    (gpointer          source,
 gboolean folderview_update_item                 (gpointer          source,
                                          gpointer          data);
 
-static void folderview_scoring_cb(FolderView *folderview, guint action,
-                                 GtkWidget *widget);
 static void folderview_processing_cb(FolderView *folderview, guint action,
                                     GtkWidget *widget);
 static void folderview_move_to(FolderView *folderview, FolderItem *from_folder,
@@ -315,7 +312,6 @@ static GtkItemFactoryEntry folderview_mail_popup_entries[] =
        {N_("/_Search folder..."),      NULL, folderview_search_cb, 0, NULL},
        {N_("/_Properties..."),         NULL, folderview_property_cb, 0, NULL},
        {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
-       {N_("/S_coring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
 static GtkItemFactoryEntry folderview_imap_popup_entries[] =
@@ -336,7 +332,6 @@ static GtkItemFactoryEntry folderview_imap_popup_entries[] =
        {N_("/_Search folder..."),      NULL, folderview_search_cb, 0, NULL},
        {N_("/_Properties..."),         NULL, folderview_property_cb, 0, NULL},
        {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
-       {N_("/S_coring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
 static GtkItemFactoryEntry folderview_news_popup_entries[] =
@@ -355,7 +350,6 @@ static GtkItemFactoryEntry folderview_news_popup_entries[] =
        {N_("/_Search folder..."),      NULL, folderview_search_cb, 0, NULL},
        {N_("/_Properties..."),         NULL, folderview_property_cb, 0, NULL},
        {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
-       {N_("/S_coring..."),            NULL, folderview_scoring_cb, 0, NULL}
 };
 
 GtkTargetEntry folderview_drag_types[] =
@@ -2614,21 +2608,6 @@ static gint folderview_compare_name(gconstpointer a, gconstpointer b)
        return strcmp2(g_basename(item->path), name);
 }
 
-static void folderview_scoring_cb(FolderView *folderview, guint action,
-                                  GtkWidget *widget)
-{
-       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
-       FolderItem *item;
-
-       if (!folderview->selected) return;
-
-       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
-
-       prefs_scoring_open(item);
-}
-
 static void folderview_processing_cb(FolderView *folderview, guint action,
                                     GtkWidget *widget)
 {
@@ -2641,7 +2620,7 @@ static void folderview_processing_cb(FolderView *folderview, guint action,
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
 
-       prefs_filtering_open(item, NULL, NULL);
+       prefs_filtering_open(&item->prefs->processing, NULL, NULL);
 }
 
 void folderview_set_target_folder_color(gint color_op) 
index 554162e..bc48b2a 100644 (file)
@@ -53,7 +53,6 @@
 #include "prefs_actions.h"
 #include "prefs_fonts.h"
 #include "prefs_spelling.h"
-#include "scoring.h"
 #include "prefs_display_header.h"
 #include "account.h"
 #include "procmsg.h"
@@ -292,7 +291,6 @@ int main(int argc, char *argv[])
        folder_set_missing_folders();
        folderview_set(folderview);
 
-       /* prefs_scoring_read_config(); */
        prefs_matcher_read_config();
 
        /* make one all-folder processing before using sylpheed */
index d68ba0c..fe65d04 100644 (file)
@@ -62,7 +62,6 @@
 #include "prefs_common.h"
 #include "prefs_actions.h"
 #include "prefs_filtering.h"
-#include "prefs_scoring.h"
 #include "prefs_account.h"
 #include "prefs_summary_column.h"
 #include "prefs_template.h"
@@ -87,6 +86,7 @@
 #include "hooks.h"
 #include "progressindicator.h"
 #include "localfolder.h"
+#include "filtering.h"
 
 #define AC_LABEL_WIDTH 240
 
@@ -356,9 +356,11 @@ static void prefs_actions_open_cb  (MainWindow     *mainwin,
 static void prefs_account_open_cb      (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
-static void prefs_scoring_open_cb      (MainWindow     *mainwin,
+
+static void prefs_processing_open_cb   (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
+
 static void prefs_filtering_open_cb    (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
@@ -689,8 +691,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Configuration/---"),             NULL, NULL, 0, "<Separator>"},
        {N_("/_Configuration/_Common preferences..."),
                                                NULL, prefs_common_open_cb, 0, NULL},
-       {N_("/_Configuration/_Scoring..."),
-                                               NULL, prefs_scoring_open_cb, 0, NULL},
+       {N_("/_Configuration/Processing..."),
+                                               NULL, prefs_processing_open_cb, 0, NULL},
        {N_("/_Configuration/_Filtering..."),
                                                NULL, prefs_filtering_open_cb, 0, NULL},
        {N_("/_Configuration/_Templates..."),   NULL, prefs_template_open_cb, 0, NULL},
@@ -2674,16 +2676,16 @@ static void prefs_common_open_cb(MainWindow *mainwin, guint action,
        prefs_common_open();
 }
 
-static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
+static void prefs_processing_open_cb(MainWindow *mainwin, guint action,
                                  GtkWidget *widget)
 {
-       prefs_scoring_open(NULL);
+       prefs_filtering_open(&global_processing, NULL, NULL);
 }
 
 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
                                    GtkWidget *widget)
 {
-       prefs_filtering_open(NULL, NULL, NULL);
+       prefs_filtering_open(&filtering_rules, NULL, NULL);
 }
 
 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
index 5c1bbc5..437fc02 100644 (file)
@@ -110,7 +110,7 @@ static const MatchParser matchparser_tab[] = {
        {MATCHTYPE_REGEXP, "regexp"},
 
        /* actions */
-       {MATCHACTION_SCORE, "score"},
+       {MATCHACTION_SCORE, "score"},    /* for backward compatibility */
        {MATCHACTION_MOVE, "move"},
        {MATCHACTION_COPY, "copy"},
        {MATCHACTION_DELETE, "delete"},
@@ -128,6 +128,7 @@ static const MatchParser matchparser_tab[] = {
        {MATCHACTION_ADD_SCORE, "add_score"},
        {MATCHACTION_SET_SCORE, "set_score"},
        {MATCHACTION_STOP, "stop"},
+       {MATCHACTION_HIDE, "hide"},
 };
 
 /*!
@@ -1365,31 +1366,6 @@ gchar *matching_build_command(const gchar *cmd, MsgInfo *info)
 
 /* ************************************************************ */
 
-/*!
- *\brief       Write scoring list to file
- *
- *\param       fp File
- *\param       prefs_scoring List of scoring conditions
- */
-static void prefs_scoring_write(FILE *fp, GSList *prefs_scoring)
-{
-       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);
-       }
-}
 
 /*!
  *\brief       Write filtering list to file
@@ -1434,33 +1410,20 @@ 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 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;
-       }
+        item = node->data;
+        /* prevent warning */
+        if (item->path == NULL)
+                return FALSE;
+        id = folder_item_get_identifier(item);
+        if (id == NULL)
+                return FALSE;
+        prefs_filtering = item->prefs->processing;
 
-       if (prefs_filtering != NULL || prefs_scoring != NULL) {
+       if (prefs_filtering != NULL) {
                fprintf(fp, "[%s]\n", id);
-
                prefs_filtering_write(fp, prefs_filtering);
-               prefs_scoring_write(fp, prefs_scoring);
-
                fputc('\n', fp);
        }
 
@@ -1485,7 +1448,16 @@ static void prefs_matcher_save(FILE *fp)
                g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
                                prefs_matcher_write_func, fp);
        }
-       prefs_matcher_write_func(NULL, fp);
+        
+        /* global rules */
+        fprintf(fp, "[global]\n");
+        prefs_filtering_write(fp, global_processing);
+        fputc('\n', fp);
+        
+        /* filtering rules */
+        fprintf(fp, "[filtering]\n");
+        prefs_filtering_write(fp, filtering_rules);
+        fputc('\n', fp);
 }
 
 /*!
@@ -1529,7 +1501,6 @@ void prefs_matcher_read_config(void)
        FILE *f;
 
        create_matchparser_hashtab();
-       prefs_scoring_clear();
        prefs_filtering_clear();
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MATCHER_RC, NULL);
index eb0fab9..d75bfa3 100644 (file)
@@ -27,6 +27,7 @@
 
 /* constants generated by yacc */
 #if !defined(YYBISON) && !defined(MATCHER_ALL)
+#       include "matcher_parser_lex.h"
 #      include "matcher_parser_parse.h"
 #endif
 
@@ -122,6 +123,7 @@ enum {
        MA_(ADD_SCORE),
        MA_(SET_SCORE),
        MA_(STOP),
+       MA_(HIDE),
        /* boolean operations */
        MB_(OR),
        MB_(AND)
index f9bd43a..7032870 100644 (file)
@@ -21,7 +21,6 @@
 #define MATCHER_PARSER_H
 
 #include "filtering.h"
-#include "scoring.h"
 #include <glib.h>
 
 extern FILE *matcher_parserin;
@@ -34,7 +33,6 @@ int matcher_parserparse                       (void);
 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);
 GSList *matcher_parser_get_action_list(gchar *str);
 
 #endif
index 9e4c51e..b96fa24 100644 (file)
@@ -27,7 +27,6 @@
 #include "intl.h"
 #include "utils.h"
 #include "filtering.h"
-#include "scoring.h"
 #include "matcher.h"
 #include "matcher_parser.h"
 #include "matcher_parser_lex.h"
@@ -50,20 +49,14 @@ static GSList *action_list = NULL;
 static FilteringAction *action = NULL;
 
 static FilteringProp *filtering;
-static ScoringProp *scoring = NULL;
 
-static GSList **prefs_scoring = NULL;
 static GSList **prefs_filtering = NULL;
 
-#if 0
-static int matcher_parser_dialog = 0;
-#endif
-
 enum {
         MATCHER_PARSE_NONE,
         MATCHER_PARSE_NO_EOL,
         MATCHER_PARSE_CONDITION,
-        MATCHER_PARSE_FILTERING_OR_SCORING,
+        MATCHER_PARSE_FILTERING_ACTION,
 };
 
 static int matcher_parse_op = MATCHER_PARSE_NONE;
@@ -76,6 +69,9 @@ void matcher_parser_start_parsing(FILE *f)
        matcher_parserrestart(f);
        matcher_parserparse();
 }
+
+void * matcher_parser_scan_string(const char * str);
  
 FilteringProp *matcher_parser_get_filtering(gchar *str)
 {
@@ -87,7 +83,7 @@ FilteringProp *matcher_parser_get_filtering(gchar *str)
        matcher_parse_op = MATCHER_PARSE_NO_EOL;
        matcher_parserrestart(NULL);
         matcher_parser_init();
-       bufstate = matcher_parser_scan_string(str);
+       bufstate = matcher_parser_scan_string((const char *) str);
         matcher_parser_switch_to_buffer(bufstate);
        if (matcher_parserparse() != 0)
                filtering = NULL;
@@ -96,25 +92,6 @@ FilteringProp *matcher_parser_get_filtering(gchar *str)
        return filtering;
 }
 
-ScoringProp *matcher_parser_get_scoring(gchar *str)
-{
-       void *bufstate;
-
-       /* bad coding to enable the sub-grammar matching
-          in yacc */
-       matcher_parserlineno = 1;
-       matcher_parse_op = MATCHER_PARSE_NO_EOL;
-       matcher_parserrestart(NULL);
-        matcher_parser_init();
-       bufstate = matcher_parser_scan_string(str);
-        matcher_parser_switch_to_buffer(bufstate);
-       if (matcher_parserparse() != 0)
-               scoring = NULL;
-       matcher_parse_op = MATCHER_PARSE_NONE;
-       matcher_parser_delete_buffer(bufstate);
-       return scoring;
-}
-
 static gboolean check_quote_symetry(gchar *str)
 {
        gchar *walk;
@@ -168,7 +145,7 @@ GSList *matcher_parser_get_action_list(gchar *str)
        /* bad coding to enable the sub-grammar matching
           in yacc */
        matcher_parserlineno = 1;
-       matcher_parse_op = MATCHER_PARSE_FILTERING_OR_SCORING;
+       matcher_parse_op = MATCHER_PARSE_FILTERING_ACTION;
        matcher_parserrestart(NULL);
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
@@ -216,7 +193,7 @@ void matcher_parsererror(char *str)
                matchers_list = NULL;
        }
        cond = NULL;
-       g_warning("scoring / filtering parsing: %i: %s\n",
+       g_warning("filtering parsing: %i: %s\n",
                  matcher_parserlineno, str);
        error = 1;
 }
@@ -247,7 +224,8 @@ int matcher_parserwrap(void)
 %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
-%token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK MATCHER_LOCK MATCHER_UNLOCK
+%token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK
+%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  
@@ -258,7 +236,7 @@ int matcher_parserwrap(void)
 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
 %token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
 %token MATCHER_ADD_SCORE MATCHER_SET_SCORE
-%token MATCHER_STOP
+%token MATCHER_STOP MATCHER_HIDE
 
 %start file
 
@@ -271,7 +249,6 @@ int matcher_parserwrap(void)
 file:
 {
        if (matcher_parse_op == MATCHER_PARSE_NONE) {
-               prefs_scoring = &global_scoring;
                prefs_filtering = &global_processing;
        }
 }
@@ -301,15 +278,16 @@ MATCHER_SECTION MATCHER_EOL
 
        if (matcher_parse_op == MATCHER_PARSE_NONE) {
                if (!strcmp(folder, "global")) {
-                       prefs_scoring = &global_scoring;
                        prefs_filtering = &global_processing;
-               } else {
+                }
+               else if (!strcmp(folder, "filtering")) {
+                        prefs_filtering = &filtering_rules;
+               }
+                else {
                        item = folder_find_item_from_identifier(folder);
                        if (item != NULL) {
-                               prefs_scoring = &item->prefs->scoring;
                                prefs_filtering = &item->prefs->processing;
                        } else {
-                               prefs_scoring = NULL;
                                prefs_filtering = NULL;
                        }
                }
@@ -318,8 +296,8 @@ MATCHER_SECTION MATCHER_EOL
 ;
 
 instruction:
-condition filtering_or_scoring MATCHER_EOL
-| condition filtering_or_scoring
+condition filtering MATCHER_EOL
+| condition filtering
 {
        if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
                YYACCEPT;
@@ -339,7 +317,7 @@ condition filtering_or_scoring MATCHER_EOL
 }
 | filtering_action_list
 {
-       if (matcher_parse_op == MATCHER_PARSE_FILTERING_OR_SCORING)
+       if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
                YYACCEPT;
        else {
                matcher_parsererror("parse error");
@@ -349,29 +327,19 @@ condition filtering_or_scoring MATCHER_EOL
 | MATCHER_EOL
 ;
 
-filtering_or_scoring:
+filtering:
 filtering_action_list
 {
        filtering = filteringprop_new(cond, action_list);
        cond = NULL;
        action_list = NULL;
-       if ((matcher_parse_op == MATCHER_PARSE_NONE) && (prefs_filtering != NULL)) {
+       if ((matcher_parse_op == MATCHER_PARSE_NONE) &&
+            (prefs_filtering != NULL)) {
                *prefs_filtering = g_slist_append(*prefs_filtering,
                                                  filtering);
                filtering = NULL;
        }
 }
-| scoring_rule
-{
-       scoring = scoringprop_new(cond, score);
-       cond = NULL;
-       score = 0;
-       if ((matcher_parse_op == MATCHER_PARSE_NONE)
-            && (prefs_scoring != NULL)) {
-               *prefs_scoring = g_slist_append(*prefs_scoring, scoring);
-               scoring = NULL;
-       }
-}
 ;
 
 filtering_action_list:
@@ -1022,6 +990,15 @@ MATCHER_EXECUTE MATCHER_STRING
        action = filteringaction_new(MATCHACTION_ADD_SCORE, 0,
                                     NULL, 0, score);
 }
+/* backward compatibility */
+| MATCHER_SCORE MATCHER_INTEGER
+{
+        gint score = 0;
+        
+        score = strtol($2, NULL, 10);
+       action = filteringaction_new(MATCHACTION_ADD_SCORE, 0,
+                                    NULL, 0, score);
+}
 | MATCHER_SET_SCORE MATCHER_INTEGER
 {
         gint score = 0;
@@ -1030,15 +1007,12 @@ MATCHER_EXECUTE MATCHER_STRING
        action = filteringaction_new(MATCHACTION_SET_SCORE, 0,
                                     NULL, 0, score);
 }
-| MATCHER_STOP
+| MATCHER_HIDE
 {
-       action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0);
+       action = filteringaction_new(MATCHACTION_HIDE, 0, NULL, 0, 0);
 }
-;
-
-scoring_rule:
-MATCHER_SCORE MATCHER_INTEGER
+| MATCHER_STOP
 {
-       score = strtol($2, NULL, 0);
+       action = filteringaction_new(MATCHACTION_STOP, 0, NULL, 0, 0);
 }
 ;
index 1b7b3f8..afb344a 100644 (file)
@@ -101,27 +101,9 @@ static void prefs_filtering_reset_dialog   (void);
 static gboolean prefs_filtering_rename_path_func(GNode *node, gpointer data);
 static gboolean prefs_filtering_delete_path_func(GNode *node, gpointer data);
 
-static FolderItem * cur_item = NULL; /* folder (if dialog opened for processing) */
-
-typedef enum Action_ {
-       ACTION_MOVE,
-       ACTION_COPY,
-       ACTION_DELETE,
-       ACTION_MARK,
-       ACTION_UNMARK,
-       ACTION_LOCK,
-       ACTION_UNLOCK,
-       ACTION_MARK_AS_READ,
-       ACTION_MARK_AS_UNREAD,
-       ACTION_FORWARD,
-       ACTION_FORWARD_AS_ATTACHMENT,
-       ACTION_REDIRECT,
-       ACTION_EXECUTE,
-       ACTION_COLOR,
-       /* add other action constants */
-} Action;
-
-void prefs_filtering_open(FolderItem * item,
+static GSList ** p_processing_list = NULL;
+
+void prefs_filtering_open(GSList ** p_processing,
                          const gchar *header,
                          const gchar *key)
 {
@@ -139,9 +121,10 @@ void prefs_filtering_open(FolderItem * item,
        manage_window_set_transient(GTK_WINDOW(filtering.window));
        gtk_widget_grab_focus(filtering.ok_btn);
 
-       cur_item = item;
-
        esckey = matcher_escape_str(key);
+
+        p_processing_list = p_processing;
+        
        prefs_filtering_set_dialog(header, esckey);
        g_free(esckey);
 
@@ -592,10 +575,7 @@ static void prefs_filtering_set_dialog(const gchar *header, const gchar *key)
        row = gtk_clist_append(clist, cond_str);
        gtk_clist_set_row_data(clist, row, NULL);
 
-       if (cur_item == NULL)
-               prefs_filtering = global_processing;
-       else
-               prefs_filtering = cur_item->prefs->processing;
+        prefs_filtering = * p_processing_list;
 
        for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur)) {
                FilteringProp * prop = (FilteringProp *) cur->data;
@@ -636,10 +616,7 @@ static void prefs_filtering_set_list(void)
        gchar * filtering_str;
        GSList * prefs_filtering;
 
-       if (cur_item == NULL)
-               prefs_filtering = global_processing;
-       else
-               prefs_filtering = cur_item->prefs->processing;
+        prefs_filtering = * p_processing_list;
 
        for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur))
                filteringprop_free((FilteringProp *) cur->data);
@@ -657,10 +634,7 @@ static void prefs_filtering_set_list(void)
                row++;
        }
 
-       if (cur_item == NULL)
-               global_processing = prefs_filtering;
-       else
-               cur_item->prefs->processing = prefs_filtering;
+        * p_processing_list = prefs_filtering;
 }
 
 static gint prefs_filtering_clist_set_row(gint row, FilteringProp * prop)
index 8055d14..a4183ba 100644 (file)
@@ -38,9 +38,10 @@ typedef enum
 
 #include "folder.h"
 
-void prefs_filtering_open              (FolderItem * item,
-                                        const gchar    *header,
-                                        const gchar    *key);
+void prefs_filtering_open(GSList ** p_processing,
+                          const gchar *header,
+                          const gchar *key);
+
 void prefs_filtering_rename_path       (const gchar    *old_path,
                                         const gchar    *new_path);
 void prefs_filtering_delete_path       (const gchar    *path);
index d24db9f..02e6c76 100644 (file)
@@ -121,6 +121,7 @@ typedef enum Action_ {
        ACTION_COLOR,
        ACTION_ADD_SCORE,
        ACTION_SET_SCORE,
+       ACTION_HIDE,
        ACTION_STOP,
        /* add other action constants */
 } Action;
@@ -145,6 +146,7 @@ static struct {
        { N_("Color"),                  ACTION_COLOR    },
        { N_("(In/de)crease score"),    ACTION_ADD_SCORE},
        { N_("Set score"),              ACTION_SET_SCORE},
+       { N_("Hide"),                   ACTION_HIDE     },
        { N_("Stop filter"),            ACTION_STOP     },
 };
 
@@ -708,6 +710,8 @@ static gint prefs_filtering_action_get_matching_from_action(Action action_id)
                return MATCHACTION_EXECUTE;
        case ACTION_COLOR:
                return MATCHACTION_COLOR;
+       case ACTION_HIDE:
+               return MATCHACTION_HIDE;
        case ACTION_STOP:
                return MATCHACTION_STOP;
        case ACTION_ADD_SCORE:
@@ -785,6 +789,7 @@ static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
                 score = strtol(score_str, NULL, 10);
                 break;
        case ACTION_STOP:
+       case ACTION_HIDE:
         case ACTION_DELETE:
         case ACTION_MARK:
         case ACTION_UNMARK:
@@ -1025,6 +1030,10 @@ static void prefs_filtering_action_select(GtkCList *clist,
                gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
                                     ACTION_STOP);
                break;
+       case MATCHACTION_HIDE:
+               gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
+                                    ACTION_HIDE);
+               break;
        }
 }
 
@@ -1236,6 +1245,7 @@ static void prefs_filtering_action_type_select(GtkList *list,
        case ACTION_MARK_AS_READ:
        case ACTION_MARK_AS_UNREAD:
         case ACTION_STOP:
+        case ACTION_HIDE:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
index dabfd25..6f3d6f0 100644 (file)
@@ -38,7 +38,6 @@
 #include "utils.h"
 #include "addr_compl.h"
 #include "prefs_common.h"
-#include "prefs_scoring.h"
 #include "gtkutils.h"
 #include "filtering.h"
 #include "folder_item_prefs.h"
diff --git a/src/prefs_scoring.c b/src/prefs_scoring.c
deleted file mode 100644 (file)
index d39d387..0000000
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
- *
- * 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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include "defs.h"
-
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "intl.h"
-#include "main.h"
-#include "prefs_gtk.h"
-#include "prefs_matcher.h"
-#include "prefs_scoring.h"
-#include "prefs_common.h"
-#include "mainwindow.h"
-#include "foldersel.h"
-#include "manage_window.h"
-#include "inc.h"
-#include "utils.h"
-#include "gtkutils.h"
-#include "alertpanel.h"
-#include "folder.h"
-#include "scoring.h"
-
-#include "matcher_parser.h"
-
-static struct Scoring {
-       GtkWidget *window;
-
-       GtkWidget *ok_btn;
-       GtkWidget *cond_entry;
-       GtkWidget *score_entry;
-       GtkWidget *kill_score_label;
-       GtkWidget *kill_score_entry;
-       GtkWidget *important_score_entry;
-
-       GtkWidget *cond_clist;
-} scoring;
-
-/*
-   parameter name, default value, pointer to the prefs variable, data type,
-   pointer to the widget pointer,
-   pointer to the function for data setting,
-   pointer to the function for widget setting
- */
-
-/* widget creating functions */
-static void prefs_scoring_create               (void);
-
-static void prefs_scoring_set_dialog   (ScoringProp * prop);
-static void prefs_scoring_set_list     (void);
-
-/* callback functions */
-/* static void prefs_scoring_select_dest_cb    (void); */
-static void prefs_scoring_register_cb  (void);
-static void prefs_scoring_substitute_cb        (void);
-static void prefs_scoring_delete_cb    (void);
-static void prefs_scoring_up           (void);
-static void prefs_scoring_down         (void);
-static void prefs_scoring_select               (GtkCList       *clist,
-                                        gint            row,
-                                        gint            column,
-                                        GdkEvent       *event);
-
-static gint prefs_scoring_deleted      (GtkWidget      *widget,
-                                        GdkEventAny    *event,
-                                        gpointer        data);
-static void prefs_scoring_key_pressed  (GtkWidget      *widget,
-                                        GdkEventKey    *event,
-                                        gpointer        data);
-static void prefs_scoring_cancel               (void);
-static void prefs_scoring_ok           (void);
-
-static void prefs_scoring_condition_define     (void);
-static gint prefs_scoring_clist_set_row(gint row, ScoringProp * prop);
-static void prefs_scoring_select_set_dialog(ScoringProp * prop);
-static void prefs_scoring_reset_dialog(void);
-
-
-static FolderItem * cur_item = NULL;
-static gint cur_important_score;
-static gint cur_kill_score;
-
-void prefs_scoring_open(FolderItem * item)
-{
-       if (prefs_rc_is_readonly(SCORING_RC))
-               return;
-
-       inc_lock();
-
-       if (!scoring.window) {
-               prefs_scoring_create();
-       }
-
-       manage_window_set_transient(GTK_WINDOW(scoring.window));
-       gtk_widget_grab_focus(scoring.ok_btn);
-
-       cur_item = item;
-
-       prefs_scoring_set_dialog(NULL);
-
-       gtk_widget_show(scoring.window);
-}
-
-void prefs_scoring_open_with_scoring(ScoringProp * prop)
-{
-       inc_lock();
-
-       if (!scoring.window) {
-               prefs_scoring_create();
-       }
-
-       manage_window_set_transient(GTK_WINDOW(scoring.window));
-       gtk_widget_grab_focus(scoring.ok_btn);
-
-       prefs_scoring_set_dialog(prop);
-
-       gtk_widget_show(scoring.window);
-}
-
-static void prefs_scoring_create(void)
-{
-       GtkWidget *window;
-       GtkWidget *vbox;
-       GtkWidget *ok_btn;
-       GtkWidget *cancel_btn;
-       GtkWidget *confirm_area;
-
-       GtkWidget *vbox1;
-       GtkWidget *hbox1;
-       GtkWidget *reg_hbox;
-       GtkWidget *arrow;
-       GtkWidget *btn_hbox;
-
-       GtkWidget *cond_label;
-       GtkWidget *cond_entry;
-       GtkWidget *cond_btn;
-       GtkWidget *score_label;
-       GtkWidget *score_entry;
-
-       GtkWidget *reg_btn;
-       GtkWidget *subst_btn;
-       GtkWidget *del_btn;
-
-       GtkWidget *cond_hbox;
-       GtkWidget *cond_scrolledwin;
-       GtkWidget *cond_clist;
-
-       GtkWidget *btn_vbox;
-       GtkWidget *up_btn;
-       GtkWidget *down_btn;
-
-       GtkWidget *important_score_entry;
-       GtkWidget *kill_score_entry;
-       GtkWidget *kill_score_label;
-
-       gchar *title[1];
-
-       debug_print("Creating scoring configuration window...\n");
-
-       window = gtk_window_new (GTK_WINDOW_DIALOG);
-       gtk_container_set_border_width (GTK_CONTAINER (window), 8);
-       gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal (GTK_WINDOW (window), TRUE);
-       gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
-
-       vbox = gtk_vbox_new (FALSE, 6);
-       gtk_widget_show (vbox);
-       gtk_container_add (GTK_CONTAINER (window), vbox);
-
-       gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
-                               &cancel_btn, _("Cancel"), NULL, NULL);
-       gtk_widget_show (confirm_area);
-       gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
-       gtk_widget_grab_default (ok_btn);
-
-       gtk_window_set_title (GTK_WINDOW(window),
-                             _("Scoring configuration"));
-       gtk_signal_connect (GTK_OBJECT(window), "delete_event",
-                           GTK_SIGNAL_FUNC(prefs_scoring_deleted), NULL);
-       gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
-                           GTK_SIGNAL_FUNC(prefs_scoring_key_pressed), NULL);
-       MANAGE_WINDOW_SIGNALS_CONNECT (window);
-       gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_scoring_ok), NULL);
-       gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_scoring_cancel), NULL);
-
-       vbox1 = gtk_vbox_new (FALSE, VSPACING);
-       gtk_widget_show (vbox1);
-       gtk_box_pack_start (GTK_BOX (vbox), vbox1, TRUE, TRUE, 0);
-       gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
-
-       cond_label = gtk_label_new (_("Condition"));
-       gtk_widget_show (cond_label);
-       gtk_misc_set_alignment (GTK_MISC (cond_label), 0, 0.5);
-       gtk_box_pack_start (GTK_BOX (vbox1), cond_label, FALSE, FALSE, 0);
-
-       hbox1 = gtk_hbox_new (FALSE, VSPACING);
-       gtk_widget_show (vbox1);
-       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
-       gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
-
-       cond_entry = gtk_entry_new ();
-       gtk_widget_show (cond_entry);
-       gtk_widget_set_usize (cond_entry, 300, -1);
-       gtk_box_pack_start (GTK_BOX (hbox1), cond_entry, TRUE, TRUE, 0);
-
-       cond_btn = gtk_button_new_with_label (_("Define ..."));
-       gtk_widget_show (cond_btn);
-       gtk_box_pack_start (GTK_BOX (hbox1), cond_btn, FALSE, FALSE, 0);
-       gtk_signal_connect (GTK_OBJECT (cond_btn), "clicked",
-                           GTK_SIGNAL_FUNC (prefs_scoring_condition_define),
-                           NULL);
-
-       hbox1 = gtk_hbox_new (FALSE, VSPACING);
-       gtk_widget_show (vbox1);
-       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
-       gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
-
-       score_label = gtk_label_new (_("Score"));
-       gtk_widget_show (score_label);
-       gtk_misc_set_alignment (GTK_MISC (score_label), 0, 0.5);
-       gtk_box_pack_start (GTK_BOX (hbox1), score_label, FALSE, FALSE, 0);
-
-       score_entry = gtk_entry_new ();
-       gtk_widget_show (score_entry);
-       gtk_widget_set_usize (score_entry, 50, -1);
-       gtk_box_pack_start (GTK_BOX (hbox1), score_entry, FALSE, FALSE, 0);
-
-       /* register / substitute / delete */
-
-       reg_hbox = gtk_hbox_new (FALSE, 4);
-       gtk_widget_show (reg_hbox);
-       gtk_box_pack_start (GTK_BOX (vbox1), reg_hbox, FALSE, FALSE, 0);
-
-       arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
-       gtk_widget_show (arrow);
-       gtk_box_pack_start (GTK_BOX (reg_hbox), arrow, FALSE, FALSE, 0);
-       gtk_widget_set_usize (arrow, -1, 16);
-
-       btn_hbox = gtk_hbox_new (TRUE, 4);
-       gtk_widget_show (btn_hbox);
-       gtk_box_pack_start (GTK_BOX (reg_hbox), btn_hbox, FALSE, FALSE, 0);
-
-       reg_btn = gtk_button_new_with_label (_("Add"));
-       gtk_widget_show (reg_btn);
-       gtk_box_pack_start (GTK_BOX (btn_hbox), reg_btn, FALSE, TRUE, 0);
-       gtk_signal_connect (GTK_OBJECT (reg_btn), "clicked",
-                           GTK_SIGNAL_FUNC (prefs_scoring_register_cb), NULL);
-
-       subst_btn = gtk_button_new_with_label (_("  Replace  "));
-       gtk_widget_show (subst_btn);
-       gtk_box_pack_start (GTK_BOX (btn_hbox), subst_btn, FALSE, TRUE, 0);
-       gtk_signal_connect (GTK_OBJECT (subst_btn), "clicked",
-                           GTK_SIGNAL_FUNC (prefs_scoring_substitute_cb),
-                           NULL);
-
-       del_btn = gtk_button_new_with_label (_("Delete"));
-       gtk_widget_show (del_btn);
-       gtk_box_pack_start (GTK_BOX (btn_hbox), del_btn, FALSE, TRUE, 0);
-       gtk_signal_connect (GTK_OBJECT (del_btn), "clicked",
-                           GTK_SIGNAL_FUNC (prefs_scoring_delete_cb), NULL);
-
-       cond_hbox = gtk_hbox_new (FALSE, 8);
-       gtk_widget_show (cond_hbox);
-       gtk_box_pack_start (GTK_BOX (vbox1), cond_hbox, TRUE, TRUE, 0);
-
-       cond_scrolledwin = gtk_scrolled_window_new (NULL, NULL);
-       gtk_widget_show (cond_scrolledwin);
-       gtk_widget_set_usize (cond_scrolledwin, -1, 150);
-       gtk_box_pack_start (GTK_BOX (cond_hbox), cond_scrolledwin,
-                           TRUE, TRUE, 0);
-       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (cond_scrolledwin),
-                                       GTK_POLICY_AUTOMATIC,
-                                       GTK_POLICY_AUTOMATIC);
-
-       title[0] = _("Current scoring rules");
-       cond_clist = gtk_clist_new_with_titles(1, title);
-       gtk_widget_show (cond_clist);
-       gtk_container_add (GTK_CONTAINER (cond_scrolledwin), cond_clist);
-       gtk_clist_set_column_width (GTK_CLIST (cond_clist), 0, 80);
-       gtk_clist_set_selection_mode (GTK_CLIST (cond_clist),
-                                     GTK_SELECTION_BROWSE);
-       GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (cond_clist)->column[0].button,
-                               GTK_CAN_FOCUS);
-       gtk_signal_connect (GTK_OBJECT (cond_clist), "select_row",
-                           GTK_SIGNAL_FUNC (prefs_scoring_select), NULL);
-
-       btn_vbox = gtk_vbox_new (FALSE, 8);
-       gtk_widget_show (btn_vbox);
-       gtk_box_pack_start (GTK_BOX (cond_hbox), btn_vbox, FALSE, FALSE, 0);
-
-       up_btn = gtk_button_new_with_label (_("Up"));
-       gtk_widget_show (up_btn);
-       gtk_box_pack_start (GTK_BOX (btn_vbox), up_btn, FALSE, FALSE, 0);
-       gtk_signal_connect (GTK_OBJECT (up_btn), "clicked",
-                           GTK_SIGNAL_FUNC (prefs_scoring_up), NULL);
-
-       down_btn = gtk_button_new_with_label (_("Down"));
-       gtk_widget_show (down_btn);
-       gtk_box_pack_start (GTK_BOX (btn_vbox), down_btn, FALSE, FALSE, 0);
-       gtk_signal_connect (GTK_OBJECT (down_btn), "clicked",
-                           GTK_SIGNAL_FUNC (prefs_scoring_down), NULL);
-
-       hbox1 = gtk_hbox_new (FALSE, 8);
-       gtk_widget_show (hbox1);
-       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);
-
-       kill_score_label = gtk_label_new (_("Hide score"));
-       gtk_widget_show (kill_score_label);
-       gtk_misc_set_alignment (GTK_MISC (kill_score_label), 0, 0.5);
-       gtk_box_pack_start (GTK_BOX (hbox1), kill_score_label,
-                           FALSE, FALSE, 0);
-
-       kill_score_entry = gtk_entry_new ();
-       gtk_widget_show (kill_score_entry);
-       gtk_widget_set_usize (kill_score_entry, 50, -1);
-       gtk_box_pack_start (GTK_BOX (hbox1), kill_score_entry,
-                           FALSE, FALSE, 0);
-
-       score_label = gtk_label_new (_("Important score"));
-       gtk_widget_show (score_label);
-       gtk_misc_set_alignment (GTK_MISC (score_label), 0, 0.5);
-       gtk_box_pack_start (GTK_BOX (hbox1), score_label, FALSE, FALSE, 0);
-
-       important_score_entry = gtk_entry_new ();
-       gtk_widget_show (important_score_entry);
-       gtk_widget_set_usize (important_score_entry, 50, -1);
-       gtk_box_pack_start (GTK_BOX (hbox1), important_score_entry,
-                           FALSE, FALSE, 0);
-
-       gtk_widget_show_all(window);
-
-       scoring.window    = window;
-       scoring.ok_btn = ok_btn;
-
-       scoring.cond_entry = cond_entry;
-       scoring.score_entry = score_entry;
-       scoring.kill_score_entry = kill_score_entry;
-       scoring.kill_score_label = kill_score_label;
-       scoring.important_score_entry = important_score_entry;
-
-       scoring.cond_clist   = cond_clist;
-}
-
-static void prefs_scoring_set_dialog(ScoringProp * cond)
-{
-       GtkCList *clist = GTK_CLIST(scoring.cond_clist);
-       GSList *cur;
-       GSList * prefs_scoring;
-       gchar * score_str;
-
-       if (cond == NULL)
-               prefs_scoring_reset_dialog();
-       else
-               prefs_scoring_select_set_dialog(cond);
-
-       gtk_clist_freeze(clist);
-       gtk_clist_clear(clist);
-
-       prefs_scoring_clist_set_row(-1, NULL);
-       if (cur_item == NULL) {
-               prefs_scoring = global_scoring;
-               cur_kill_score = prefs_common.kill_score;
-               cur_important_score = prefs_common.important_score;
-               gtk_widget_show(scoring.kill_score_label);
-               gtk_widget_show(scoring.kill_score_entry);
-       } else {
-               prefs_scoring = cur_item->prefs->scoring;
-               cur_kill_score = cur_item->prefs->kill_score;
-               cur_important_score = cur_item->prefs->important_score;
-       }
-
-       for(cur = prefs_scoring ; cur != NULL ;
-           cur = g_slist_next(cur)) {
-               ScoringProp * prop = (ScoringProp *) cur->data;
-               
-               prefs_scoring_clist_set_row(-1, prop);
-       }
-
-       score_str = itos(cur_kill_score);
-       gtk_entry_set_text(GTK_ENTRY(scoring.kill_score_entry),
-                          score_str);
-       score_str = itos(cur_important_score);
-       gtk_entry_set_text(GTK_ENTRY(scoring.important_score_entry),
-                          score_str);
-
-       gtk_clist_thaw(clist);
-}
-
-static void prefs_scoring_reset_dialog(void)
-{
-       gtk_entry_set_text(GTK_ENTRY(scoring.cond_entry), "");
-       gtk_entry_set_text(GTK_ENTRY(scoring.score_entry), "");
-}
-
-static void prefs_scoring_set_list(void)
-{
-       gint row = 1;
-       ScoringProp *prop;
-       GSList * cur;
-       gchar * scoring_str;
-       GSList * prefs_scoring;
-
-       if (cur_item == NULL)
-               prefs_scoring = global_scoring;
-       else
-               prefs_scoring = cur_item->prefs->scoring;
-
-       for(cur = prefs_scoring ; cur != NULL ;
-           cur = g_slist_next(cur))
-               scoringprop_free((ScoringProp *) cur->data);
-       g_slist_free(prefs_scoring);
-       prefs_scoring = NULL;
-
-       while (gtk_clist_get_text(GTK_CLIST(scoring.cond_clist),
-                                 row, 0, &scoring_str)) {
-               if (strcmp(scoring_str, _("(New)")) != 0) {
-                       prop = matcher_parser_get_scoring(scoring_str);
-                       if (prop != NULL)
-                               prefs_scoring = g_slist_append(prefs_scoring,
-                                                              prop);
-               }
-               row++;
-       }
-
-       cur_kill_score = atoi(gtk_entry_get_text(GTK_ENTRY(scoring.kill_score_entry)));
-       cur_important_score = atoi(gtk_entry_get_text(GTK_ENTRY(scoring.important_score_entry)));
-
-       if (cur_item == NULL) {
-               global_scoring = prefs_scoring;
-               prefs_common.kill_score = cur_kill_score;
-               prefs_common.important_score = cur_important_score;
-       }
-       else {
-               cur_item->prefs->scoring = prefs_scoring;
-               cur_item->prefs->kill_score = cur_kill_score;
-               cur_item->prefs->important_score = cur_important_score;
-       }
-}
-
-static gint prefs_scoring_clist_set_row(gint row, ScoringProp * prop)
-{
-       GtkCList *clist = GTK_CLIST(scoring.cond_clist);
-       gchar * str;
-       gchar *cond_str[1];
-
-       if (prop == NULL) {
-               cond_str[0] = _("(New)");
-               return gtk_clist_append(clist, cond_str);
-       }
-
-       str = scoringprop_to_string(prop);
-       if (str == NULL) {
-               return -1;
-       }
-       cond_str[0] = str;
-
-       if (row < 0)
-               row = gtk_clist_append(clist, cond_str);
-       else
-               gtk_clist_set_text(clist, row, 0, cond_str[0]);
-       g_free(str);
-
-       return row;
-}
-
-static void prefs_scoring_condition_define_done(MatcherList * matchers)
-{
-       gchar * str;
-
-       if (matchers == NULL)
-               return;
-
-       str = matcherlist_to_string(matchers);
-
-       if (str != NULL) {
-               gtk_entry_set_text(GTK_ENTRY(scoring.cond_entry), str);
-               g_free(str);
-       }
-}
-
-static void prefs_scoring_condition_define(void)
-{
-       gchar * cond_str;
-       MatcherList * matchers = NULL;
-
-       cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
-
-       if (*cond_str != '\0') {
-               matchers = matcher_parser_get_cond(cond_str);
-               if (matchers == NULL)
-                       alertpanel_error(_("Match string is not valid."));
-       }
-
-       prefs_matcher_open(matchers, prefs_scoring_condition_define_done);
-
-       if (matchers != NULL)
-               matcherlist_free(matchers);
-}
-
-
-/* register / substitute delete buttons */
-
-static void prefs_scoring_register_cb(void)
-{
-       MatcherList * cond;
-       gchar * cond_str;
-       gchar * score_str;
-       ScoringProp * prop;
-       gint score;
-
-       cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
-       if (*cond_str == '\0') {
-               alertpanel_error(_("Condition string is empty."));
-               return;
-       }
-
-       score_str = gtk_entry_get_text(GTK_ENTRY(scoring.score_entry));
-       if (*score_str == '\0') {
-               alertpanel_error(_("Score is not set."));
-               return;
-       }
-
-       score = atoi(score_str);
-       cond = matcher_parser_get_cond(cond_str);
-
-       if (cond == NULL) {
-               alertpanel_error(_("Condition string is not valid."));
-               return;
-       }
-
-       prop = scoringprop_new(cond, score);
-
-       prefs_scoring_clist_set_row(-1, prop);
-
-       scoringprop_free(prop);
-
-       prefs_scoring_reset_dialog();
-}
-
-static void prefs_scoring_substitute_cb(void)
-{
-       GtkCList *clist = GTK_CLIST(scoring.cond_clist);
-       gint row;
-       MatcherList * cond;
-       gchar * cond_str;
-       gchar * score_str;
-       ScoringProp * prop;
-       gint score;
-
-       if (!clist->selection) return;
-
-       row = GPOINTER_TO_INT(clist->selection->data);
-       if (row == 0) return;
-
-       cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
-       if (*cond_str == '\0') {
-               alertpanel_error(_("Condition string is empty."));
-               return;
-       }
-
-       score_str = gtk_entry_get_text(GTK_ENTRY(scoring.score_entry));
-       if (*score_str == '\0') {
-               alertpanel_error(_("Score is not set."));
-               return;
-       }
-
-       score = atoi(score_str);
-       cond = matcher_parser_get_cond(cond_str);
-
-       if (cond == NULL) {
-               alertpanel_error(_("Condition string is not valid."));
-               return;
-       }
-
-       prop = scoringprop_new(cond, score);
-
-       prefs_scoring_clist_set_row(row, prop);
-
-       scoringprop_free(prop);
-
-       prefs_scoring_reset_dialog();
-}
-
-static void prefs_scoring_delete_cb(void)
-{
-       GtkCList *clist = GTK_CLIST(scoring.cond_clist);
-       gint row;
-
-       if (!clist->selection) return;
-       row = GPOINTER_TO_INT(clist->selection->data);
-       if (row == 0) return;
-
-       if (alertpanel(_("Delete rule"),
-                      _("Do you really want to delete this rule?"),
-                      _("Yes"), _("No"), NULL) == G_ALERTALTERNATE)
-               return;
-
-       gtk_clist_remove(clist, row);
-}
-
-static void prefs_scoring_up(void)
-{
-       GtkCList *clist = GTK_CLIST(scoring.cond_clist);
-       gint row;
-
-       if (!clist->selection) return;
-
-       row = GPOINTER_TO_INT(clist->selection->data);
-       if (row > 1) {
-               gtk_clist_row_move(clist, row, row - 1);
-               if(gtk_clist_row_is_visible(clist, row - 1) != GTK_VISIBILITY_FULL) {
-                       gtk_clist_moveto(clist, row - 1, 0, 0, 0);
-               } 
-       }
-}
-
-static void prefs_scoring_down(void)
-{
-       GtkCList *clist = GTK_CLIST(scoring.cond_clist);
-       gint row;
-
-       if (!clist->selection) return;
-
-       row = GPOINTER_TO_INT(clist->selection->data);
-       if (row > 0 && row < clist->rows - 1) {
-               gtk_clist_row_move(clist, row, row + 1);
-               if(gtk_clist_row_is_visible(clist, row + 1) != GTK_VISIBILITY_FULL) {
-                       gtk_clist_moveto(clist, row + 1, 0, 1, 0);
-               } 
-       }
-}
-
-static void prefs_scoring_select_set_dialog(ScoringProp * prop)
-{
-       gchar * matcher_str;
-       gchar * score_str;
-
-       if (prop == NULL)
-               return;
-
-       matcher_str = matcherlist_to_string(prop->matchers);
-       if (matcher_str == NULL) {
-               scoringprop_free(prop);
-               return;
-       }
-
-       score_str = itos(prop->score);
-
-       gtk_entry_set_text(GTK_ENTRY(scoring.cond_entry), matcher_str);
-       gtk_entry_set_text(GTK_ENTRY(scoring.score_entry), score_str);
-
-       g_free(matcher_str);
-}
-
-static void prefs_scoring_select(GtkCList *clist, gint row, gint column,
-                               GdkEvent *event)
-{
-       ScoringProp * prop;
-
-       gchar * scoring_str;
-
-       if (row == 0) {
-               prefs_scoring_reset_dialog();
-               return;
-       }
-
-        if (!gtk_clist_get_text(GTK_CLIST(scoring.cond_clist),
-                               row, 0, &scoring_str))
-               return;
-
-       prop = matcher_parser_get_scoring(scoring_str);
-       if (prop == NULL)
-               return;
-
-       prefs_scoring_select_set_dialog(prop);
-
-       scoringprop_free(prop);
-}
-
-static gint prefs_scoring_deleted(GtkWidget *widget, GdkEventAny *event,
-                                gpointer data)
-{
-       prefs_scoring_cancel();
-       return TRUE;
-}
-
-static void prefs_scoring_key_pressed(GtkWidget *widget, GdkEventKey *event,
-                                    gpointer data)
-{
-       if (event && event->keyval == GDK_Escape)
-               prefs_scoring_cancel();
-}
-
-static void prefs_scoring_ok(void)
-{
-       MatcherList * cond;
-       gchar * cond_str;
-       gchar * score_str;
-       gchar * scoring_str;
-       gchar * str;
-       ScoringProp * prop;
-       gint score;
-       gint row = 1;
-        AlertValue val;
-
-       cond_str = gtk_entry_get_text(GTK_ENTRY(scoring.cond_entry));
-       score_str = gtk_entry_get_text(GTK_ENTRY(scoring.score_entry));
-       if (*cond_str != '\0' && *score_str != '\0') {
-               score = atoi(score_str);
-               cond = matcher_parser_get_cond(cond_str);
-
-               if (cond == NULL) {
-                       prefs_common_save_config();
-                       prefs_scoring_set_list();
-                       prefs_matcher_write_config();
-                       if (cur_item != NULL)
-                               folder_item_prefs_save_config(cur_item);
-                       gtk_widget_hide(scoring.window);
-                       inc_unlock();
-                       return;
-               }
-               prop = scoringprop_new(cond, score);
-               str = scoringprop_to_string(prop);
-               while (gtk_clist_get_text(GTK_CLIST(scoring.cond_clist),
-                                 row, 0, &scoring_str)) {
-                       if (strcmp(scoring_str, str) == 0) break;
-                       row++;
-               }
-                if (strcmp(scoring_str, str) != 0) {
-                        val = alertpanel(_("Entry not saved"),
-                                 _("The entry was not saved\nHave you really finished?"),
-                                 _("Yes"), _("No"), NULL);
-                        if (G_ALERTDEFAULT != val) {
-                                g_free(str);
-                                return;
-                        }
-                }
-               g_free(str);
-       }
-       prefs_common_save_config();
-       prefs_scoring_set_list();
-       prefs_matcher_write_config();
-       if (cur_item != NULL)
-               folder_item_prefs_save_config(cur_item);
-       gtk_widget_hide(scoring.window);
-       inc_unlock();
-}
-
-static void prefs_scoring_cancel(void)
-{
-       prefs_matcher_read_config();
-       gtk_widget_hide(scoring.window);
-       inc_unlock();
-}
diff --git a/src/prefs_scoring.h b/src/prefs_scoring.h
deleted file mode 100644 (file)
index 92d6dea..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
- *
- * 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
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PREFS_SCORING_H__
-#define __PREFS_SCORING_H__
-
-#include "scoring.h"
-
-/*
-void prefs_scoring_read_config (void);
-void prefs_scoring_write_config        (void);
-*/
-void prefs_scoring_open(FolderItem * item);
-     /*
-void prefs_scoring_open                (void);
-     */
-void prefs_scoring_open_with_scoring(ScoringProp * prop);
-
-#endif /* __PREFS_SCORING_H__ */
index c941a99..f673cb8 100644 (file)
@@ -1505,8 +1505,8 @@ gboolean procmsg_msginfo_filter(MsgInfo *msginfo)
                return TRUE;
 
        /* filter if enabled in prefs or move to inbox if not */
-       if((global_processing != NULL) &&
-          filter_message_by_msginfo(global_processing, msginfo))
+       if((filtering_rules != NULL) &&
+          filter_message_by_msginfo(filtering_rules, msginfo))
                return TRUE;
 
        return FALSE;
index e5d7854..4168115 100644 (file)
@@ -202,6 +202,8 @@ struct _MsgInfo
        /* used only for encrypted messages */
        gchar *plaintext_file;
        guint decryption_failed : 1;
+        
+        gint hidden;
 };
 
 struct _MsgFileInfo
diff --git a/src/scoring.c b/src/scoring.c
deleted file mode 100644 (file)
index 4252798..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdio.h>
-#include "defs.h"
-#include "intl.h"
-#include "utils.h"
-#include "scoring.h"
-
-#define PREFSBUFSIZE           1024
-
-
-GSList * global_scoring = NULL;
-
-ScoringProp * scoringprop_new(MatcherList * matchers, int score)
-{
-       ScoringProp * scoring;
-
-       scoring = g_new0(ScoringProp, 1);
-       scoring->matchers = matchers;
-       scoring->score = score;
-
-       return scoring;
-}
-
-ScoringProp * scoringprop_copy(ScoringProp *src)
-{
-       ScoringProp * new;
-       GSList *tmp;
-       
-       new = g_new0(ScoringProp, 1);
-       new->matchers = g_new0(MatcherList, 1);
-       for (tmp = src->matchers->matchers; tmp != NULL && tmp->data != NULL;) {
-               MatcherProp *matcher = (MatcherProp *)tmp->data;
-               
-               new->matchers->matchers = g_slist_append(new->matchers->matchers,
-                                                  matcherprop_copy(matcher));
-               tmp = tmp->next;
-       }
-       new->matchers->bool_and = src->matchers->bool_and;
-       new->score = src->score;
-
-       return new;
-}
-
-void scoringprop_free(ScoringProp * prop)
-{
-       g_return_if_fail(prop);
-       matcherlist_free(prop->matchers);
-       g_free(prop);
-}
-
-gint scoringprop_score_message(ScoringProp * scoring, MsgInfo * info)
-{
-       if (matcherlist_match(scoring->matchers, info))
-               return scoring->score;
-       else
-               return 0;
-}
-
-gint score_message(GSList * scoring_list, MsgInfo * info)
-{
-       gint score = 0;
-       gint add_score;
-       GSList * l;
-
-       for(l = scoring_list ; l != NULL ; l = g_slist_next(l)) {
-               ScoringProp * scoring = (ScoringProp *) l->data;
-               
-               add_score = (scoringprop_score_message(scoring, info));
-               if (add_score == MAX_SCORE || add_score == MIN_SCORE) {
-                       score = add_score;
-                       break;
-               }
-               score += add_score;
-       }
-       return score;
-}
-
-/*
-  syntax for scoring config
-
-  file ~/.sylpheed/scoringrc
-
-  header "x-mailing" match "toto" score -10
-  subject match "regexp" & to regexp "regexp" score 50
-  subject match "regexp" | to regexpcase "regexp" | age_sup 5 score 30
-
-  if score is = MIN_SCORE (-999), no more match is done in the list
-  if score is = MAX_SCORE (-999), no more match is done in the list
- */
-
-
-gchar * scoringprop_to_string(ScoringProp * prop)
-{
-       gchar * list_str;
-       gchar * score_str;
-       gchar * scoring_str;
-
-       list_str = matcherlist_to_string(prop->matchers);
-
-       if (list_str == NULL)
-               return NULL;
-
-       score_str = itos(prop->score);
-       scoring_str = g_strconcat(list_str, " score ", score_str, NULL);
-       g_free(list_str);
-
-       return scoring_str;
-}
-
-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(void)
-{
-       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;
-}
-
-/*!
- *\brief       Clear up scoring for folder
- */
-void prefs_scoring_clear_folder(Folder *folder)
-{
-       g_return_if_fail(folder);
-       g_return_if_fail(folder->node);
-       g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
-                       prefs_scoring_free_func, NULL);
-}
diff --git a/src/scoring.h b/src/scoring.h
deleted file mode 100644 (file)
index 9bf88e3..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef SCORING_H
-
-#define SCORING_H
-
-#include <glib.h>
-#include "matcher.h"
-#include "procmsg.h"
-
-#define MAX_SCORE 9999
-#define MIN_SCORE -9999
-
-struct _ScoringProp {
-       MatcherList * matchers;
-       int score;
-};
-
-typedef struct _ScoringProp ScoringProp;
-
-extern GSList * global_scoring;
-extern gint global_kill_score;
-extern gint global_important_score;
-
-ScoringProp * scoringprop_new(MatcherList * matchers, int score);
-void scoringprop_free(ScoringProp * prop);
-gint scoringprop_score_message(ScoringProp * scoring, MsgInfo * info);
-
-ScoringProp * scoringprop_parse(gchar ** str);
-ScoringProp * scoringprop_copy(ScoringProp *src);
-
-gint score_message(GSList * scoring_list, MsgInfo * info);
-
-void prefs_scoring_write_config(void);
-void prefs_scoring_read_config(void);
-gchar * scoringprop_to_string(ScoringProp * prop);
-
-void prefs_scoring_clear(void);
-void prefs_scoring_clear_folder(Folder *folder);
-
-void prefs_scoring_free(GSList * prefs_scoring);
-
-#endif
index 1ed6bd7..35eaed7 100644 (file)
@@ -74,7 +74,6 @@
 #include "imap.h"
 #include "addressbook.h"
 #include "addr_compl.h"
-#include "scoring.h"
 #include "folder_item_prefs.h"
 #include "filtering.h"
 #include "string_match.h"
@@ -814,6 +813,7 @@ void summary_init(SummaryView *summaryview)
 
 }
 
+#if 0
 GtkCTreeNode * summary_find_next_important_score(SummaryView *summaryview,
                                                 GtkCTreeNode *current_node)
 {
@@ -875,6 +875,7 @@ GtkCTreeNode * summary_find_prev_important_score(SummaryView *summaryview,
        else
                return best_node;
 }
+#endif
 
 #define CURRENTLY_DISPLAYED(m) \
 ( (m->msgnum == displayed_msgnum) \
@@ -890,6 +891,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        guint selected_msgnum = 0;
        guint displayed_msgnum = 0;
        GSList *cur;
+        GSList *not_killed;
 
        if (summary_is_locked(summaryview)) return FALSE;
 
@@ -975,19 +977,6 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        BY OTHER PROGRAMS TO THE FOLDER
 */
        mlist = folder_item_get_msg_list(item);
-#if 0
-       summary_processing(summaryview, mlist);
-#endif
-       for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
-               MsgInfo * msginfo = (MsgInfo *) cur->data;
-
-               msginfo->score = score_message(global_scoring, msginfo);
-               if (msginfo->score != MAX_SCORE &&
-                   msginfo->score != MIN_SCORE) {
-                       msginfo->score += score_message(item->prefs->scoring,
-                                                       msginfo);
-               }
-       }
 
        if (summaryview->folder_item->hide_read_msgs) {
                GSList *not_killed;
@@ -1073,7 +1062,8 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                g_slist_free(mlist);
                mlist = not_killed;
        }
-       
+
+#if 0  
        if ((global_scoring || item->prefs->scoring)) {
                GSList *not_killed;
                gint kill_score;
@@ -1093,6 +1083,18 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                g_slist_free(mlist);
                mlist = not_killed;
        }
+#endif
+        not_killed = NULL;
+        for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
+                MsgInfo * msginfo = (MsgInfo *) cur->data;
+                
+                if (!msginfo->hidden)
+                        not_killed = g_slist_prepend(not_killed, msginfo);
+                else
+                        procmsg_msginfo_free(msginfo);
+        }
+        g_slist_free(mlist);
+        mlist = not_killed;
 
        STATUSBAR_POP(summaryview->mainwin);
 
@@ -1130,10 +1132,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                }
        } else {
                /* select first unread message */
+#if 0
                if (summaryview->sort_key == SORT_BY_SCORE)
                        node = summary_find_next_important_score(summaryview,
                                                                 NULL);
                else
+#endif
                node = summary_find_next_flagged_msg(summaryview, NULL,
                                                     MSG_UNREAD, FALSE);
                if (node == NULL && GTK_CLIST(ctree)->row_list != NULL) {
@@ -2713,6 +2717,7 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
                }
                        gtk_ctree_node_set_foreground
                                (ctree, row, &summaryview->color_marked);
+#if 0
        } else if ((global_scoring ||
                  summaryview->folder_item->prefs->scoring) &&
                 (msginfo->score >= summaryview->important_score) &&
@@ -2720,6 +2725,7 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
                gtk_ctree_node_set_text(ctree, row, S_COL_MARK, "!");
                gtk_ctree_node_set_foreground(ctree, row,
                                              &summaryview->color_important);
+#endif
        } else {
                gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MARK], NULL);
        }
@@ -3946,7 +3952,7 @@ void summary_collapse_threads(SummaryView *summaryview)
 
 void summary_filter(SummaryView *summaryview)
 {
-       if (!global_processing) {
+       if (!filtering_rules) {
                alertpanel_error(_("No filter rules defined."));
                return;
        }
@@ -3961,7 +3967,7 @@ void summary_filter(SummaryView *summaryview)
 
        gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
 
-       if (global_processing == NULL) {
+       if (filtering_rules == NULL) {
                gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
                                        GTK_CTREE_FUNC(summary_filter_func),
                                        summaryview);
@@ -3994,7 +4000,7 @@ void summary_filter(SummaryView *summaryview)
         * CLAWS: summary_show() only valid after having a lock. ideally
         * we want the lock to be context aware...  
         */
-       if (global_processing) {
+       if (filtering_rules) {
                summary_show(summaryview, summaryview->folder_item);
        }               
 }
@@ -4004,7 +4010,7 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
 {
        MsgInfo *msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
-       filter_message_by_msginfo(global_processing, msginfo);
+       filter_message_by_msginfo(filtering_rules, msginfo);
 }
 
 void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
@@ -5303,6 +5309,7 @@ void summary_set_prefs_from_folderitem(SummaryView *summaryview, FolderItem *ite
        summaryview->thread_collapsed = item->thread_collapsed;
 
        /* Scoring */
+#if 0
        if (global_scoring || item->prefs->scoring) {
                summaryview->important_score = prefs_common.important_score;
                if (item->prefs->important_score >
@@ -5310,6 +5317,7 @@ void summary_set_prefs_from_folderitem(SummaryView *summaryview, FolderItem *ite
                        summaryview->important_score =
                                item->prefs->important_score;
        }
+#endif
 }
 
 void summary_save_prefs_to_folderitem(SummaryView *summaryview, FolderItem *item)