1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include "nsMsgSearchCore.idl"
6
7/**
8 * describes a custom term added to a message search or filter
9 */
10[scriptable,uuid(925DB5AA-21AF-494c-8652-984BC7BAD13A)]
11interface nsIMsgSearchCustomTerm : nsISupports
12{
13  /**
14   * globally unique string to identify this search term.
15   * recommended form: ExtensionName@example.com#TermName
16   * Commas and quotes are not allowed, the id must not
17   * parse to an integer, and names of standard search
18   * attributes in SearchAttribEntryTable in nsMsgSearchTerm.cpp
19   * are not allowed.
20   */
21  readonly attribute ACString id;
22
23  /// name to display in term list. This should be localized. */
24  readonly attribute AString name;
25
26  /// Does this term need the message body?
27  readonly attribute boolean needsBody;
28
29  /**
30   * Is this custom term enabled?
31   *
32   * @param scope          search scope (nsMsgSearchScope)
33   * @param op             search operator (nsMsgSearchOp). If null, determine
34   *                       if term is available for any operator.
35   *
36   * @return               true if enabled
37   */
38  boolean getEnabled(in nsMsgSearchScopeValue scope,
39                     in nsMsgSearchOpValue op);
40
41  /**
42   * Is this custom term available?
43   *
44   * @param scope          search scope (nsMsgSearchScope)
45   * @param op             search operator (nsMsgSearchOp). If null, determine
46   *                       if term is available for any operator.
47   *
48   * @return               true if available
49   */
50  boolean getAvailable(in nsMsgSearchScopeValue scope,
51                       in nsMsgSearchOpValue op);
52
53  /**
54   * List the valid operators for this term.
55   *
56   * @param scope          search scope (nsMsgSearchScope)
57   *
58   * @return               array of operators
59   */
60  Array<nsMsgSearchOpValue> getAvailableOperators(in nsMsgSearchScopeValue scope);
61
62  /**
63   * Apply the custom search term to a message
64   *
65   * @param msgHdr       header database reference representing the message
66   * @param searchValue  user-set value to use in the search
67   * @param searchOp     search operator (Contains, IsHigherThan, etc.)
68   *
69   * @return             true if the term matches the message, else false
70   */
71
72  boolean match(in nsIMsgDBHdr msgHdr,
73                in AUTF8String searchValue,
74                in nsMsgSearchOpValue searchOp);
75};
76