Statistics
| Branch: | Tag: | Revision:

root / lib / filters / bayes-filter.c @ 4012ec30

History | View | Annotate | Download (1.25 KB)

1
#include <glib.h>
2

    
3
#include "filter.h"
4
#include "bayes-filter.h"
5

    
6

    
7
static XFilterStatus xfilter_bayes_func(XFilter *filter, const XMessageData *data)
8
{
9
        return XF_NOJUNK;
10
}
11

    
12
XFilter *xfilter_bayes_new(void)
13
{
14
        XFilter *filter;
15

    
16
        filter = xfilter_new(XF_TEST, "bayes-test");
17
        xfilter_set_test_filter_func(X_TEST_FILTER(filter), xfilter_bayes_func);
18

    
19
        return filter;
20
}
21

    
22

    
23
static XFilterStatus xfilter_bayes_learn_func(XFilter *filter, const XMessageData *data, XMessageData **retdata)
24
{
25
        const char *type;
26

    
27
        *retdata = NULL;
28

    
29
        type = xfilter_message_data_get_mime_type(data);
30
        if (!type || g_strncasecmp(type, "text/", 5) != 0)
31
                return XF_UNSUPPORTED_TYPE;
32

    
33
        g_print("learning message\n");
34

    
35
        return XF_NONE;
36
}
37

    
38
XFilter *xfilter_bayes_learn_new(void)
39
{
40
        XFilter *filter;
41

    
42
        filter = xfilter_new(XF_CONTENT, "bayes-learn");
43
        xfilter_set_content_filter_func(X_CONTENT_FILTER(filter), xfilter_bayes_learn_func);
44

    
45
        return filter;
46
}
47

    
48

    
49
int xfilter_bayes_get_learn_status(XFilterBayesLearnStatus *status)
50
{
51
        g_return_val_if_fail(status != NULL, -1);
52

    
53
        status->junk_words = 0;
54
        status->nojunk_words = 0;
55
        status->junk_learned_num = 0;
56
        status->nojunk_learned_num = 0;
57

    
58
        return 0;
59
}
60

    
61
int xfilter_bayes_reset_learn_count(void)
62
{
63
        return 0;
64
}
65

    
66
int xfilter_bayes_reset_all(void)
67
{
68
        return 0;
69
}