1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is mozilla.org code.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2002
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 * Dan Mosedale <dmose@netscape.com> (Original Author)
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 #include "nsISupports.idl"
41 #include "MailNewsTypes2.idl"
42
43 interface nsIMsgFilterHitNotify;
44 interface nsIMsgWindow;
45 interface nsIMsgDBHdr;
46 interface nsIStreamListener;
47
48 /**
49 * This interface is still very much under development, and is not yet stable.
50 */
51
52 [scriptable, uuid(e2e56690-a676-11d6-80c9-00008646b737)]
53 interface nsIMsgFilterPlugin : nsISupports
54 {
55 /**
56 * Do any necessary cleanup: flush and close any open files, etc.
57 */
58 void shutdown();
59
60 /**
61 * Some protocols (ie IMAP) can, as an optimization, avoid
62 * downloading all message header lines. If your plugin doesn't need
63 * any more than the minimal set, it can return false for this attribute.
64 */
65 readonly attribute boolean shouldDownloadAllHeaders;
66
67 };
68
69 /**
70 * Inform a listener of a message's classification aClassification, which
71 * can be one of 3 values: UNCLASSIFIED, GOOD, or JUNK.
72 * Pass the indicator aJunkPercent, where 0 is not junk,
73 * 100 is junk, and intermediate values represent varying uncertainty.
74 */
75 [scriptable, uuid(b15a0f9c-df07-4af0-9ba8-80dca68ac35d)]
76 interface nsIJunkMailClassificationListener : nsISupports
77 {
78 void onMessageClassified(in string aMsgURI,
79 in nsMsgJunkStatus aClassification,
80 in PRUint32 aJunkPercent);
81
82 };
83
84 [scriptable, uuid(caf3d467-d57c-11d6-96a9-00039310a47a)]
85 interface nsIJunkMailPlugin : nsIMsgFilterPlugin
86 {
87 /**
88 * Message classifications.
89 */
90 const nsMsgJunkStatus UNCLASSIFIED = 0;
91 const nsMsgJunkStatus GOOD = 1;
92 const nsMsgJunkStatus JUNK = 2;
93
94 /**
95 * Message junk score constants. Junkscore can only be on of these two
96 * values (or not set).
97 */
98 const nsMsgJunkScore IS_SPAM_SCORE = 100; // junk
99 const nsMsgJunkScore IS_HAM_SCORE = 0; // not junk
100
101 /**
102 * Given a message URI, determine what its current classification is
103 * according to the current training set.
104 */
105 void classifyMessage(in string aMsgURI, in nsIMsgWindow aMsgWindow,
106 in nsIJunkMailClassificationListener aListener);
107
108 void classifyMessages(in unsigned long aCount,
109 [array, size_is(aCount)] in string aMsgURIs,
110 in nsIMsgWindow aMsgWindow,
111 in nsIJunkMailClassificationListener aListener);
112
113 /**
114 * Called when a user forces the classification of a message. Should
115 * cause the training set to be updated appropriately.
116 *
117 * @arg aMsgURI URI of the message to be classified
118 * @arg aOldUserClassification Was it previous manually classified
119 * by the user? If so, how?
120 * @arg aNewClassification New manual classification.
121 * @arg aListener Callback
122 */
123 void setMessageClassification(
124 in string aMsgURI, in nsMsgJunkStatus aOldUserClassification,
125 in nsMsgJunkStatus aNewClassification,
126 in nsIMsgWindow aMsgWindow,
127 in nsIJunkMailClassificationListener aListener);
128
129 readonly attribute boolean userHasClassified;
130
131 /** Removes the training file and clears out any in memory training tokens.
132 User must retrain after doing this.
133 **/
134 void resetTrainingData();
135 };