/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 "MailNewsTypes2.idl"
#include "nsIMsgFolder.idl"

interface nsIMsgHeaderParser;

%{C++
#include "nsIMsgHeaderParser.h"
%}
interface nsIMsgDatabase;
interface nsIMsgDBHdr;

[scriptable, uuid(6e893e59-af98-4f62-a326-0f00f32147cd)]

interface nsMsgSearchScope {
  const nsMsgSearchScopeValue offlineMail = 0;
  const nsMsgSearchScopeValue offlineMailFilter = 1;
  const nsMsgSearchScopeValue onlineMail = 2;
  const nsMsgSearchScopeValue onlineMailFilter = 3;
  /// offline news, base table, no body or junk
  const nsMsgSearchScopeValue localNews = 4;
  const nsMsgSearchScopeValue news = 5;
  const nsMsgSearchScopeValue newsEx = 6;
  const nsMsgSearchScopeValue LDAP = 7;
  const nsMsgSearchScopeValue LocalAB = 8;
  const nsMsgSearchScopeValue allSearchableGroups = 9;
  const nsMsgSearchScopeValue newsFilter = 10;
  const nsMsgSearchScopeValue LocalABAnd = 11;
  const nsMsgSearchScopeValue LDAPAnd = 12;
  // IMAP and NEWS, searched using local headers
  const nsMsgSearchScopeValue onlineManual = 13;
  /// local news + junk
  const nsMsgSearchScopeValue localNewsJunk = 14;
  /// local news + body
  const nsMsgSearchScopeValue localNewsBody = 15;
  /// local news + junk + body
  const nsMsgSearchScopeValue localNewsJunkBody = 16;
};

typedef long nsMsgSearchAttribValue;

/**
 * Definitions of search attribute types. The numerical order
 * from here will also be used to determine the order that the
 * attributes display in the filter editor.
 */
[scriptable, uuid(a83ca7e8-4591-4111-8fb8-fd76ac73c866)]
interface nsMsgSearchAttrib {
    const nsMsgSearchAttribValue Custom = -2;  /* a custom term, see nsIMsgSearchCustomTerm */
    const nsMsgSearchAttribValue Default = -1;
    const nsMsgSearchAttribValue Subject = 0;  /* mail and news */
    const nsMsgSearchAttribValue Sender = 1;
    const nsMsgSearchAttribValue Body = 2;
    const nsMsgSearchAttribValue Date = 3;

    const nsMsgSearchAttribValue Priority = 4;      /* mail only */
    const nsMsgSearchAttribValue MsgStatus = 5;
    const nsMsgSearchAttribValue To = 6;
    const nsMsgSearchAttribValue CC = 7;
    const nsMsgSearchAttribValue ToOrCC = 8;
    const nsMsgSearchAttribValue AllAddresses = 9;

    const nsMsgSearchAttribValue Location = 10;          /* result list only */
    const nsMsgSearchAttribValue MessageKey = 11;        /* message result elems */
    const nsMsgSearchAttribValue AgeInDays = 12;
    const nsMsgSearchAttribValue FolderInfo = 13;        /* for "view thread context" from result */
    const nsMsgSearchAttribValue Size = 14;
    const nsMsgSearchAttribValue AnyText = 15;
    const nsMsgSearchAttribValue Keywords = 16; // keywords are the internal representation of tags.

    const nsMsgSearchAttribValue Name = 17;
    const nsMsgSearchAttribValue DisplayName = 18;
    const nsMsgSearchAttribValue Nickname = 19;
    const nsMsgSearchAttribValue ScreenName = 20;
    const nsMsgSearchAttribValue Email = 21;
    const nsMsgSearchAttribValue AdditionalEmail = 22;
    const nsMsgSearchAttribValue PhoneNumber = 23;
    const nsMsgSearchAttribValue WorkPhone = 24;
    const nsMsgSearchAttribValue HomePhone = 25;
    const nsMsgSearchAttribValue Fax = 26;
    const nsMsgSearchAttribValue Pager = 27;
    const nsMsgSearchAttribValue Mobile = 28;
    const nsMsgSearchAttribValue City = 29;
    const nsMsgSearchAttribValue Street = 30;
    const nsMsgSearchAttribValue Title = 31;
    const nsMsgSearchAttribValue Organization = 32;
    const nsMsgSearchAttribValue Department = 33;

    // 34 - 43, reserved for ab / LDAP;
    const nsMsgSearchAttribValue HasAttachmentStatus = 44;
    const nsMsgSearchAttribValue JunkStatus = 45;
    const nsMsgSearchAttribValue JunkPercent = 46;
    const nsMsgSearchAttribValue JunkScoreOrigin = 47;
    const nsMsgSearchAttribValue Label = 48; /* mail only...can search by label */
    const nsMsgSearchAttribValue HdrProperty = 49; // uses nsIMsgSearchTerm::hdrProperty
    const nsMsgSearchAttribValue FolderFlag = 50; // uses nsIMsgSearchTerm::status
    const nsMsgSearchAttribValue Uint32HdrProperty = 51; // uses nsIMsgSearchTerm::hdrProperty

    // 52 is for showing customize - in ui headers start from 53 onwards up until 99.

     /** OtherHeader MUST ALWAYS BE LAST attribute since 
       * we can have an arbitrary # of these. The number can be changed,
       * however, because we never persist AttribValues as integers.
      */
    const nsMsgSearchAttribValue OtherHeader = 52; 
    // must be last attribute
    const nsMsgSearchAttribValue kNumMsgSearchAttributes = 100;
};

typedef long nsMsgSearchOpValue;

[scriptable, uuid(9160b196-6fcb-4eba-aaaf-6c806c4ee420)]
interface nsMsgSearchOp {
    const nsMsgSearchOpValue Contains = 0; /* for text attributes      */
    const nsMsgSearchOpValue DoesntContain = 1;
    const nsMsgSearchOpValue Is = 2; /* is and isn't also apply to some non-text attrs */
    const nsMsgSearchOpValue Isnt = 3;
    const nsMsgSearchOpValue IsEmpty = 4;

    const nsMsgSearchOpValue IsBefore = 5; /* for date attributes              */
    const nsMsgSearchOpValue IsAfter = 6;

    const nsMsgSearchOpValue IsHigherThan = 7; /* for priority. Is also applies  */
    const nsMsgSearchOpValue IsLowerThan = 8;

    const nsMsgSearchOpValue BeginsWith = 9;
    const nsMsgSearchOpValue EndsWith = 10;

    const nsMsgSearchOpValue SoundsLike = 11; /* for LDAP phoenetic matching      */
    const nsMsgSearchOpValue LdapDwim = 12; /* Do What I Mean for simple search */

    const nsMsgSearchOpValue IsGreaterThan = 13;
    const nsMsgSearchOpValue IsLessThan = 14;

    const nsMsgSearchOpValue NameCompletion = 15; /* Name Completion operator...as the name implies =) */
    const nsMsgSearchOpValue IsInAB = 16;
    const nsMsgSearchOpValue IsntInAB = 17;
    const nsMsgSearchOpValue IsntEmpty = 18; /* primarily for tags */
    const nsMsgSearchOpValue Matches = 19; /* generic term for use by custom terms */
    const nsMsgSearchOpValue DoesntMatch = 20; /* generic term for use by custom terms */
    const nsMsgSearchOpValue kNumMsgSearchOperators  = 21;     /* must be last operator */
};

typedef long nsMsgSearchWidgetValue;

/* FEs use this to help build the search dialog box */
[scriptable,uuid(903dd2e8-304e-11d3-92e6-00a0c900d445)]
interface nsMsgSearchWidget {
    const nsMsgSearchWidgetValue Text = 0;
    const nsMsgSearchWidgetValue Date = 1;
    const nsMsgSearchWidgetValue Menu = 2;
  const nsMsgSearchWidgetValue Int = 3;          /* added to account for age in days which requires an integer field */
    const nsMsgSearchWidgetValue None = 4;
};

typedef long nsMsgSearchTypeValue;


/* Used to specify type of search to be performed */
[scriptable,uuid(964b7f32-304e-11d3-ae13-00a0c900d445)]
interface nsMsgSearchType {
  const nsMsgSearchTypeValue None = 0;
  const nsMsgSearchTypeValue RootDSE = 1;
  const nsMsgSearchTypeValue Normal = 2;
  const nsMsgSearchTypeValue LdapVLV = 3;
  const nsMsgSearchTypeValue NameCompletion = 4;
};

typedef long nsMsgSearchBooleanOperator;

[scriptable, uuid(a37f3f4a-304e-11d3-8f94-00a0c900d445)]
interface nsMsgSearchBooleanOp {
    const nsMsgSearchBooleanOperator BooleanOR = 0;
    const nsMsgSearchBooleanOperator BooleanAND = 1;
};

/* Use this to specify the value of a search term */

[ptr] native nsMsgSearchValue(nsMsgSearchValue);

%{C++
typedef struct nsMsgSearchValue
{
    nsMsgSearchAttribValue attribute;
    union
    {
      nsMsgPriorityValue priority;
      PRTime date;
      PRUint32 msgStatus; /* see MSG_FLAG in msgcom.h */
      PRUint32 size;
      nsMsgKey key;
      PRInt32 age; /* in days */
      nsIMsgFolder *folder;
      nsMsgLabelValue label;
      PRUint32 junkStatus;
      PRUint32 junkPercent;
    } u;
    char *string;
} nsMsgSearchValue;
%}

[ptr] native nsMsgSearchTerm(nsMsgSearchTerm);

// Please note the ! at the start of this macro, which means the macro
// needs to enumerate the non-string attributes.
%{C++
#define IS_STRING_ATTRIBUTE(_a) \
(!(_a == nsMsgSearchAttrib::Priority || _a == nsMsgSearchAttrib::Date || \
   _a == nsMsgSearchAttrib::MsgStatus || _a == nsMsgSearchAttrib::MessageKey || \
   _a == nsMsgSearchAttrib::Size || _a == nsMsgSearchAttrib::AgeInDays || \
   _a == nsMsgSearchAttrib::FolderInfo || _a == nsMsgSearchAttrib::Location || \
   _a == nsMsgSearchAttrib::Label || _a == nsMsgSearchAttrib::JunkStatus || \
   _a == nsMsgSearchAttrib::FolderFlag || _a == nsMsgSearchAttrib::Uint32HdrProperty || \
   _a == nsMsgSearchAttrib::JunkPercent || _a == nsMsgSearchAttrib::HasAttachmentStatus))
%}

[ptr] native nsSearchMenuItem(nsSearchMenuItem);

