blob: 077baa2ffd4cacf7152f487e817ac68ba745d063 (
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
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _nsMsgFilter_H_
#define _nsMsgFilter_H_
#include "nscore.h"
#include "nsISupports.h"
#include "nsIMsgFilter.h"
#include "nsIMsgSearchScopeTerm.h"
#include "nsMsgSearchBoolExpression.h"
#include "nsIDateTimeFormat.h"
#include "nsIMsgFilterCustomAction.h"
class nsMsgRuleAction : public nsIMsgRuleAction
{
public:
NS_DECL_ISUPPORTS
nsMsgRuleAction();
NS_DECL_NSIMSGRULEACTION
private:
virtual ~nsMsgRuleAction();
nsMsgRuleActionType m_type;
// this used to be a union - why bother?
nsMsgPriorityValue m_priority; /* priority to set rule to */
nsMsgLabelValue m_label; /* label to set rule to */
nsCString m_folderUri;
int32_t m_junkScore; /* junk score (or arbitrary int value?) */
// arbitrary string value. Currently, email address to forward to
nsCString m_strValue;
nsCString m_customId;
nsCOMPtr<nsIMsgFilterCustomAction> m_customAction;
} ;
class nsMsgFilter : public nsIMsgFilter
{
public:
NS_DECL_ISUPPORTS
nsMsgFilter();
NS_DECL_NSIMSGFILTER
nsMsgFilterTypeType GetType() {return m_type;}
void SetType(nsMsgFilterTypeType type) {m_type = type;}
bool GetEnabled() {return m_enabled;}
void SetFilterScript(nsCString *filterName);
bool IsScript() {return (m_type &
(nsMsgFilterType::InboxJavaScript |
nsMsgFilterType::NewsJavaScript)) != 0;}
// filing routines.
nsresult SaveRule(nsIOutputStream *aStream);
int16_t GetVersion();
#ifdef DEBUG
void Dump();
#endif
nsresult ConvertMoveOrCopyToFolderValue(nsIMsgRuleAction *filterAction, nsCString &relativePath);
static const char *GetActionStr(nsMsgRuleActionType action);
static nsresult GetActionFilingStr(nsMsgRuleActionType action, nsCString &actionStr);
static nsMsgRuleActionType GetActionForFilingStr(nsCString &actionStr);
protected:
/*
* Reporting function for filtering success/failure.
* Logging has to be enabled for the message to appear.
*/
nsresult LogRuleHitGeneric(nsIMsgRuleAction *aFilterAction,
nsIMsgDBHdr *aMsgHdr,
nsresult aRcode,
const char *aErrmsg);
virtual ~nsMsgFilter();
nsMsgFilterTypeType m_type;
nsString m_filterName;
nsCString m_scriptFileName; // iff this filter is a script.
nsCString m_description;
nsCString m_unparsedBuffer;
bool m_enabled;
bool m_temporary;
bool m_unparseable;
nsIMsgFilterList *m_filterList; /* owning filter list */
nsCOMPtr<nsISupportsArray> m_termList; /* linked list of criteria terms */
nsCOMPtr<nsIMsgSearchScopeTerm> m_scope; /* default for mail rules is inbox, but news rules could
have a newsgroup - LDAP would be invalid */
nsTArray<nsCOMPtr<nsIMsgRuleAction> > m_actionList;
nsMsgSearchBoolExpression *m_expressionTree;
nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
};
#endif
|