/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 2002
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Dan Mosedale <dmose@netscape.com> (Original Author)
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"
#include "MailNewsTypes2.idl"

interface nsIMsgFilterHitNotify;
interface nsIMsgWindow;
interface nsIMsgDBHdr;
interface nsIStreamListener;

/**
 * This interface is still very much under development, and is not yet stable.
 */

[scriptable, uuid(e2e56690-a676-11d6-80c9-00008646b737)]
interface nsIMsgFilterPlugin : nsISupports
{
    /**
     * Do any necessary cleanup: flush and close any open files, etc.
     */
    void shutdown();

    /**
     * Some protocols (ie IMAP) can, as an optimization, avoid
     * downloading all message header lines.  If your plugin doesn't need
     * any more than the minimal set, it can return false for this attribute.
     */     
    readonly attribute boolean shouldDownloadAllHeaders;

};

/**
 * Rather than passing low level details about scores and such, abstract
 * this away by informing a listener of a message's classification, which
 * can be one of 3 values:  UNCLASSIFIED, GOOD, or JUNK.
 */
[scriptable, uuid(0243f3d6-d583-11d6-898a-00039310a47a)]
interface nsIJunkMailClassificationListener : nsISupports
{
    void onMessageClassified(in string aMsgURI, in nsMsgJunkStatus aClassification);
};

[scriptable, uuid(caf3d467-d57c-11d6-96a9-00039310a47a)]
interface nsIJunkMailPlugin : nsIMsgFilterPlugin
{
    /**
     * Message classifications.
     */
    const nsMsgJunkStatus UNCLASSIFIED = 0;
    const nsMsgJunkStatus GOOD = 1;
    const nsMsgJunkStatus JUNK = 2;

    /**
     * Given a message URI, determine what its current classification is
     * according to the current training set.
     */
    void classifyMessage(in string aMsgURI, in nsIMsgWindow aMsgWindow,
                         in nsIJunkMailClassificationListener aListener);

    void classifyMessages(in unsigned long aCount,
                          [array, size_is(aCount)] in string aMsgURIs,
                          in nsIMsgWindow aMsgWindow,
                          in nsIJunkMailClassificationListener aListener);
    
    /**
     * Called when a user forces the classification of a message. Should
     * cause the training set to be updated appropriately.
     *
     * @arg aMsgURI                     URI of the message to be classified
     * @arg aOldUserClassification      Was it previous manually classified 
     *                                  by the user?  If so, how?
     * @arg aNewClassification          New manual classification.
     * @arg aListener                   Callback
     */
    void setMessageClassification(
        in string aMsgURI, in nsMsgJunkStatus aOldUserClassification,
        in nsMsgJunkStatus aNewClassification,
        in nsIMsgWindow aMsgWindow,
        in nsIJunkMailClassificationListener aListener);

    readonly attribute boolean userHasClassified;
 
    /** Removes the training file and clears out any in memory training tokens. 
        User must retrain after doing this.
    **/
    void resetTrainingData();
};
