summaryrefslogtreecommitdiffstats
path: root/kshowmail/headerfilter.h
blob: c17a6264a1054b1d787ee908fb7b2135be87ce94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// C++ Interface: headerfilter
//
// Description:
//
//
// Author: Ulrich Weigelt <[email protected]>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef HEADERFILTER_H
#define HEADERFILTER_H

//Qt headers
#include <qstring.h>
#include <qptrlist.h>

//KDE headers
#include <kapplication.h>
#include <kdebug.h>
#include <kconfig.h>

//KShowmail headers
#include "constants.h"
#include "types.h"
#include "filteritem.h"
#include "senderlistfilter.h"

/**
 * @brief This is the mail header filter.
 * Call check() with some header datas of the mail to get the configured action for this mail.
 * If the settings was changed by the config GUI you have to call load().
 * @author Ulrich Weigelt <[email protected]>
 */
class HeaderFilter{

  public:

    /**
     * Constructor
     */
    HeaderFilter();

    /**
     * Destructor
     */
    ~HeaderFilter();

    /**
     * Checks the given mail header.
     * @param from Sender
     * @param to Addressee
     * @param size Size
     * @param subject Subject
     * @param header Header
     * @param account Account
     * @param mailboxName contains the mailbox name after call, if filter action is MOVE
     * @return recommend action
     */
    FilterAction_Type check( QString from, QString to, uint size, QString subject, QString header, QString account, QString& mailboxName ) const;

    /**
     * Loads the settings from the application config file.
     */
    void load();

    /**
     * Prints the settings
     */
    void print();

    /**
     * Returns the filter active state.
     * @return TRUE - filter is active
     */
    bool isActive();

  private:

    /**
     * Connector to the configuration file
     */
    KConfig* config;

    /**
     * TRUE - filter is active
     */
    bool active;

    /**
     * Default action, if no filter matches
     */
    FilterAction_Type defaultAction;

    /**
     * mailbox name if default action is MOVE
     */
    QString mailbox;

    /**
     * Number of filter items
     */
    uint numberFilterItems;

    /**
     * Black and White lists
     */
    SenderListFilter senderlist;

    /**
     * This list holds the filter items
     */
    QPtrList<FilterItem> filters;
};

#endif