1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Seth Spitzer <sspitzer@netscape.com>
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 #include "nsISupports.idl"
40 #include "nsMsgFilterCore.idl"
41 #include "nsIMsgFilter.idl"
42 #include "nsIMsgFilterHitNotify.idl"
43
44 interface nsIOutputStream;
45
46 ///////////////////////////////////////////////////////////////////////////////
47 // The Msg Filter List is an interface designed to make accessing filter lists
48 // easier. Clients typically open a filter list and either enumerate the filters,
49 // or add new filters, or change the order around...
50 //
51 ///////////////////////////////////////////////////////////////////////////////
52
53 typedef long nsMsgFilterFileAttribValue;
54
55 [scriptable, uuid(BC32C05E-4E4E-4F08-BF01-157A0CE71874)]
56 interface nsIMsgFilterList : nsISupports {
57
58 const nsMsgFilterFileAttribValue attribNone = 0;
59 const nsMsgFilterFileAttribValue attribVersion = 1;
60 const nsMsgFilterFileAttribValue attribLogging = 2;
61 const nsMsgFilterFileAttribValue attribName = 3;
62 const nsMsgFilterFileAttribValue attribEnabled = 4;
63 const nsMsgFilterFileAttribValue attribDescription = 5;
64 const nsMsgFilterFileAttribValue attribType = 6;
65 const nsMsgFilterFileAttribValue attribScriptFile = 7;
66 const nsMsgFilterFileAttribValue attribAction = 8;
67 const nsMsgFilterFileAttribValue attribActionValue = 9;
68 const nsMsgFilterFileAttribValue attribCondition = 10;
69
70 attribute nsIMsgFolder folder;
71 readonly attribute short version;
72 readonly attribute ACString arbitraryHeaders;
73 readonly attribute boolean shouldDownloadAllHeaders;
74 readonly attribute unsigned long filterCount;
75 nsIMsgFilter getFilterAt(in unsigned long filterIndex);
76 nsIMsgFilter getFilterNamed(in AString filterName);
77
78 void setFilterAt(in unsigned long filterIndex, in nsIMsgFilter filter);
79 void removeFilter(in nsIMsgFilter filter);
80 void removeFilterAt(in unsigned long filterIndex);
81
82 void moveFilterAt(in unsigned long filterIndex,
83 in nsMsgFilterMotionValue motion);
84 void moveFilter(in nsIMsgFilter filter,
85 in nsMsgFilterMotionValue motion);
86
87 void insertFilterAt(in unsigned long filterIndex, in nsIMsgFilter filter);
88
89 attribute boolean loggingEnabled;
90
91 nsIMsgFilter createFilter(in AString name);
92
93 void saveToFile(in nsIOutputStream stream);
94
95 void parseCondition(in nsIMsgFilter aFilter, in string condition);
96 // this is temporary so that we can save the filterlist to disk
97 // without knowing where the filters were read from intially
98 // (such as the filter list dialog)
99 attribute nsILocalFile defaultFile;
100 void saveToDefaultFile();
101
102
103 // marking noscript because headers is a null-separated list
104 // of strings, which is not scriptable
105 [noscript]
106 void applyFiltersToHdr(in nsMsgFilterTypeType filterType,
107 in nsIMsgDBHdr msgHdr,
108 in nsIMsgFolder folder,
109 in nsIMsgDatabase db,
110 in string headers,
111 //[array, size_is(headerSize)] in string headers,
112 in unsigned long headerSize,
113 in nsIMsgFilterHitNotify listener,
114 in nsIMsgWindow msgWindow,
115 in nsILocalFile aMessageFile);
116
117 // IO routines, used by filter object filing code.
118 void writeIntAttr(in nsMsgFilterFileAttribValue attrib, in long value, in nsIOutputStream stream);
119 void writeStrAttr(in nsMsgFilterFileAttribValue attrib, in string value, in nsIOutputStream stream);
120 void writeWstrAttr(in nsMsgFilterFileAttribValue attrib, in wstring value, in nsIOutputStream stream);
121 void writeBoolAttr(in nsMsgFilterFileAttribValue attrib, in boolean value, in nsIOutputStream stream);
122 boolean matchOrChangeFilterTarget(in ACString oldUri, in ACString newUri, in boolean caseInsensitive);
123
124 // for filter logging
125 attribute nsIOutputStream logStream;
126 readonly attribute ACString logURL;
127 void clearLog();
128 void ensureLogFile();
129 void flushLogIfNecessary();
130 };
131
132
133 /* these longs are all actually of type nsMsgFilterMotionValue */
134 [scriptable, uuid(d067b528-304e-11d3-a0e1-00a0c900d445)]
135 interface nsMsgFilterMotion {
136 const long up = 0;
137 const long down = 1;
138 };