/* -*- 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):
 *
 *   Kent James <kent@caspia.com>
 *
 * 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;
interface nsIMsgFilterCustomAction;

[scriptable, uuid(190A2A18-D245-473a-A402-9F0814598C7F)]
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 ACString targetFolderUri;

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

  attribute long junkScore; 

  attribute AUTF8String strValue;

  // action id if type is Custom
  attribute ACString customId;

  // custom action associated with customId
  // (which must be set prior to reading this attribute)
  readonly attribute nsIMsgFilterCustomAction customAction;
  
};

[scriptable, uuid(346C8CC6-35EA-4F44-B348-94E84D7C03E0)]
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 AString filterName;
    attribute ACString filterDesc;
    attribute ACString 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 ACString arbitraryHeader);

    void GetTerm(in long termIndex,
                 out nsMsgSearchAttribValue attrib,
                 out nsMsgSearchOpValue op,
                 out nsIMsgSearchValue value, // bad! using shared structure
                 out boolean BooleanAND,
                 out ACString 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;
};

