9 #include "procheader.h"
15 #define PREFSBUFSIZE 1024
18 GSList * global_scoring = NULL;
20 ScoringProp * scoringprop_new(MatcherList * matchers, int score)
22 ScoringProp * scoring;
24 scoring = g_new0(ScoringProp, 1);
25 scoring->matchers = matchers;
26 scoring->score = score;
31 void scoringprop_free(ScoringProp * prop)
33 matcherlist_free(prop->matchers);
37 gint scoringprop_score_message(ScoringProp * scoring, MsgInfo * info)
39 if (matcherlist_match(scoring->matchers, info))
40 return scoring->score;
45 gint score_message(GSList * scoring_list, MsgInfo * info)
51 for(l = scoring_list ; l != NULL ; l = g_slist_next(l)) {
52 ScoringProp * scoring = (ScoringProp *) l->data;
54 add_score = (scoringprop_score_message(scoring, info));
55 if (add_score == MAX_SCORE || add_score == MIN_SCORE) {
65 syntax for scoring config
67 file ~/.sylpheed/scoringrc
69 header "x-mailing" match "toto" score -10
70 subject match "regexp" & to regexp "regexp" score 50
71 subject match "regexp" | to regexpcase "regexp" | age_sup 5 score 30
73 if score is = MIN_SCORE (-999), no more match is done in the list
74 if score is = MAX_SCORE (-999), no more match is done in the list
78 gchar * scoringprop_to_string(ScoringProp * prop)
84 list_str = matcherlist_to_string(prop->matchers);
89 score_str = itos(prop->score);
90 scoring_str = g_strconcat(list_str, " score ", score_str, NULL);
96 void prefs_scoring_free(GSList * prefs_scoring)
98 while (prefs_scoring != NULL) {
99 ScoringProp * scoring = (ScoringProp *) prefs_scoring->data;
100 scoringprop_free(scoring);
101 prefs_scoring = g_slist_remove(prefs_scoring, scoring);
105 static gboolean prefs_scoring_free_func(GNode *node, gpointer data)
107 FolderItem *item = node->data;
112 prefs_scoring_free(item->prefs->scoring);
113 item->prefs->scoring = NULL;
118 void prefs_scoring_clear()
122 for (cur = folder_get_list() ; cur != NULL ; cur = g_list_next(cur)) {
125 folder = (Folder *) cur->data;
126 g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
127 prefs_scoring_free_func, NULL);
130 prefs_scoring_free(global_scoring);
131 global_scoring = NULL;