/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Netscape 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/NPL/
 *
 * 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 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 NPL, 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 NPL, 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(5fe70a74-304e-11d3-9be1-00a0c900d445)]

interface nsMsgSearchScope {
  const nsMsgSearchScopeValue offlineMail = 0;
  const nsMsgSearchScopeValue offlineMailFilter = 1;
  const nsMsgSearchScopeValue onlineMail = 2;
  const nsMsgSearchScopeValue onlineMailFilter = 3;
  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;
};

typedef long nsMsgSearchAttribValue;

[scriptable, uuid(68c8710a-304e-11d3-97bf-00a0c900d445)]
interface nsMsgSearchAttrib {
    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 Location = 9;          /* result list only */
    const nsMsgSearchAttribValue MessageKey = 10;        /* message result elems */
	const nsMsgSearchAttribValue AgeInDays = 11; 
    const nsMsgSearchAttribValue FolderInfo = 12;        /* for "view thread context" from result */
    const nsMsgSearchAttribValue Size = 13;
    const nsMsgSearchAttribValue AnyText = 14;
    const nsMsgSearchAttribValue Keywords = 15;

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

	// 33 - 45, reserved for ab / LDAP;
	const nsMsgSearchAttribValue HasAttachmentStatus = 46;
	const nsMsgSearchAttribValue JunkStatus = 47;
    const nsMsgSearchAttribValue Label = 48; /* mail only...can search by label */
    //49 is for showing customize... in ui headers start from 50 onwards up until 99.
	const nsMsgSearchAttribValue OtherHeader = 49;  /* for mail and news. MUST ALWAYS BE LAST attribute since we can have an arbitrary # of these... */
    const nsMsgSearchAttribValue kNumMsgSearchAttributes = 100;      /* must be last attribute */
};

/* NB: If you add elements to this enum, add only to the end, since 
 *     RULES.DAT stores enum values persistently
 */

typedef long nsMsgSearchOpValue;

[scriptable, uuid(82cc4518-304e-11d3-831d-00a0c900d445)]
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 kNumMsgSearchOperators  = 18;     /* 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;
		  PRUint32 age; /* in days */
		  nsIMsgFolder *folder;
		  nsMsgLabelValue label;
		  PRUint32 junkStatus;
    } u;
    char *string;
} nsMsgSearchValue;
%}

[ptr] native nsMsgSearchTerm(nsMsgSearchTerm);

%{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::HasAttachmentStatus))
%}

[ptr] native nsSearchMenuItem(nsSearchMenuItem);

