/* -*- Mode: IDL; 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) 1999
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * 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 "nsMsgFilterCore.idl"
#include "nsIMsgSearchScopeTerm.idl"
#include "nsIMsgSearchValue.idl"
#include "nsIMsgSearchTerm.idl"
#include "nsISupportsArray.idl"

interface nsOutputStream;

[scriptable, uuid(09aa663b-ab04-457d-9557-319e4cc7884e)]
interface nsIMsgRuleAction : nsISupports {

  attribute nsMsgRuleActionType type;

  // target priority.. throws an exception if the action is not priority
  attribute nsMsgPriorityValue priority;

  // target folder.. throws an exception if the action is not move to folder
  attribute string targetFolderUri;

  // target label. throws an exception if the action is not label
  attribute nsMsgLabelValue label;

  attribute long junkScore; 

  attribute string strValue;

};

[scriptable, uuid(605db0f8-04a1-11d3-a50a-0060b0fc04b7)]
interface nsIMsgFilter : nsISupports {
    attribute nsMsgFilterTypeType filterType;
    /**
     * some filters are "temporary".  For example, the filters we create when the user
     * filters return receipts to the Sent folder.
     * we don't show temporary filters in the UI
     * and we don't write them to disk.
     */
    attribute boolean temporary;
    attribute boolean enabled;
    attribute wstring filterName;
    attribute string filterDesc;
    attribute string unparsedBuffer; //holds the entire filter if we don't know how to handle it
    attribute boolean unparseable;  //whether we could parse the filter or not

    readonly attribute nsIMsgFilterList filterList; // owning filter list
    
    void AddTerm(in nsMsgSearchAttribValue attrib,
                 in nsMsgSearchOpValue op,
                 in nsIMsgSearchValue value,
                 in boolean BooleanAND,
                 in string arbitraryHeader);

    void GetTerm(in long termIndex,
                 out nsMsgSearchAttribValue attrib,
                 out nsMsgSearchOpValue op,
                 out nsIMsgSearchValue value, // bad! using shared structure
                 out boolean BooleanAND,
                 out string arbitraryHeader);

    void appendTerm(in nsIMsgSearchTerm term);

    nsIMsgSearchTerm createTerm();

    attribute nsISupportsArray searchTerms;

    attribute nsIMsgSearchScopeTerm scope;

    // marking noscript because "headers" is actually a null-separated
    // list of headers, which is not scriptable
    [noscript] void MatchHdr(in nsIMsgDBHdr msgHdr, in nsIMsgFolder folder,
                  in nsIMsgDatabase db,
                  in string headers,
                  //                  [array, size_is(headerSize)] in string headers,
                  in unsigned long headerSize, out boolean result);

    void logRuleHit(in nsIMsgRuleAction aFilterAction, in nsIMsgDBHdr aHeader);
    nsIMsgRuleAction createAction();

    nsIMsgRuleAction getActionAt(in long aIndex);

    void appendAction(in nsIMsgRuleAction action);

    void clearActionList();
    void getSortedActionList(in nsISupportsArray actionList);  //will return an action list with moveAction (if present) as last one.
    readonly attribute nsISupportsArray actionList;
};

