/* -*- Mode: C++; tab-width: 2; 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) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Robert John Churchill      <rjc@netscape.com>
 *
 * 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 ***** */

/*

  The Browser Search service

*/

#include "nsISupports.idl"
#include "nsIRDFDataSource.idl"

interface  nsIUnicodeDecoder;

[scriptable, uuid(1222e6f0-a5e3-11d2-8b7c-00805f8a7db6)]
interface nsILocalSearchService : nsISupports
{
};

[scriptable, uuid(6bd1d803-1c67-11d3-9820-ed1b357eb3c4)]
interface nsIInternetSearchService : nsISupports
{
  // constants set in the whichButtons out param of GetInternetSearchURL() 
  const unsigned short kHaveNext = 1;
  const unsigned short kHavePrev = 2;

  string      GetInternetSearchURL(in string searchEngineURI, in wstring searchStr, in short direction, in unsigned short pageNumber, out unsigned short whichButtons);
  void      RememberLastSearchText(in wstring escapedSearchStr);
  boolean      FindInternetSearchResults(in string url);
  void      Stop();
  void      ClearResults(in boolean flushLastSearchRef);
  void      ClearResultSearchSites();
  nsIRDFDataSource  GetCategoryDataSource();
  void      AddSearchEngine(in string engineURL, in string iconURL,
                         in wstring suggestedTitle, in wstring suggestedCategory);
};

[noscript, uuid(7b171610-80ca-4d33-b16c-4186cd7b7e73)]
interface nsIInternetSearchContext : nsISupports
{
  const unsigned long WEB_SEARCH_CONTEXT      = 1;

  // The download of the .src file for a *new* engine.
  const unsigned long ENGINE_DOWNLOAD_NEW_CONTEXT = 2;

  // The download of the icon file for a new engine.
  const unsigned long ICON_DOWNLOAD_NEW_CONTEXT = 3;

  // The head request to see if we need to update the engine.
  const unsigned long ENGINE_UPDATE_HEAD_CONTEXT = 4;

  // The download of the .src file for an engine update.
  const unsigned long ENGINE_DOWNLOAD_UPDATE_CONTEXT = 5;

  // The download of the icon file for an engine update.
  const unsigned long ICON_DOWNLOAD_UPDATE_CONTEXT = 6;

  // attributes
  readonly attribute unsigned long ContextType;

  // methods
  nsIUnicodeDecoder  GetUnicodeDecoder();
  nsIRDFResource    GetParent();
  nsIRDFResource    GetEngine();
  void      GetHintConst([shared] out wstring buffer);
  void      AppendBytes(in string buffer, in long numBytes);
  void      AppendUnicodeBytes(in wstring buffer, in long numUniBytes);
  long      GetBufferLength();
  void      GetBufferConst([shared] out wstring buffer);
  void      Truncate();
};

%{C++

#define NS_IINTERNETSEARCHDATASOURCECALLBACK_IID \
{ 0x88774583, 0x1edd, 0x11d3, { 0x98, 0x20, 0xbf, 0x1b, 0xe7, 0x7e, 0x61, 0xc4 } }

#define NS_IINTERNETSEARCHDATAOURCE_IID \
{ 0x6bd1d803, 0x1c67, 0x11d3, { 0x98, 0x20, 0xed, 0x1b, 0x35, 0x7e, 0xb3, 0xc4 } }

#define NS_ILOCALSEARCHDATASOURCE_IID \
{ 0x1222e6f0, 0xa5e3, 0x11d2, { 0x8b, 0x7c, 0x00, 0x80, 0x5f, 0x8a, 0x7d, 0xb6 } }

#define NS_LOCALSEARCH_SERVICE_CONTRACTID \
    "@mozilla.org/browser/localsearch-service;1"
#define NS_LOCALSEARCH_DATASOURCE_CONTRACTID \
    "@mozilla.org/rdf/datasource;1?name=localsearch"

#define NS_INTERNETSEARCH_SERVICE_CONTRACTID \
    "@mozilla.org/browser/internetsearch-service;1"
#define NS_INTERNETSEARCH_DATASOURCE_CONTRACTID \
    "@mozilla.org/rdf/datasource;1?name=internetsearch"

%}
