File: filter.h

package info (click to toggle)
aethera 0.9.3-7
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,588 kB
  • ctags: 7,282
  • sloc: cpp: 64,544; sh: 9,913; perl: 1,756; makefile: 1,680; python: 258
file content (96 lines) | stat: -rw-r--r-- 1,533 bytes parent folder | download
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
#ifndef FILTER_H
#define FILTER_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define ACTIONS_COUNT 5

#include <qstringlist.h>

#include <kconfig.h>

class IndexClass;
class MessageDevice;
class MessageClass;

class FilterRule
{
friend class Filter;
public:
  FilterRule(QString &field, QString &function, QString &context );
  ~FilterRule();

  bool match( MessageDevice* );

  bool match( MessageClass* );

protected:
  bool matchList( QStringList );

  QString m_field;
  QString m_function;
  QString m_context;
};


class FilterAction
{
friend class Filter;
public:
  FilterAction( QString &action, QString &param );
  ~FilterAction();

  bool apply( IndexClass*, MessageDevice*, bool useForwardActions = true );

  QString messageFolder();

private:
  QString m_action;
  QString m_param;

  // "execute" action stuff

};



class Filter
{
public:
  Filter( KConfig *config, QString group, int id );
  ~Filter();

  bool match( MessageDevice*  );

  /** apply filter actions to message,
   *  dosn't check if message much to filter, use @match for this.
   */
  void apply( IndexClass*, MessageDevice*, bool useForwardActions );

  /** return folder for message ( if "forward" action present )
   *  or QString::NULL
   */
  QString messageFolder( MessageClass* );

  void readConfig( KConfig *config, QString group, int id );

protected:

  bool match( MessageClass*  );

  FilterRule *rule1, *rule2;
  QString ruleLogic; // "ignore", "and", "or" , "unless"

  FilterAction *actions[ ACTIONS_COUNT ];

};


#endif