https://wiki.mozilla.org/api.php?action=feedcontributions&user=-dt-&feedformat=atomMozillaWiki - User contributions [en]2024-03-28T23:36:05ZUser contributionsMediaWiki 1.27.4https://wiki.mozilla.org/index.php?title=Search_Service:API&diff=28012Search Service:API2006-06-18T17:03:18Z<p>-dt-: /* nsISearchEngine */</p>
<hr />
<div>This is the proposed API for the the new Firefox search service. It is not yet final. Please comment on the discussion page or in the bug itself.<br />
<br />
=nsISearchSubmission=<br />
interface nsISearchSubmission : nsISupports<br />
{<br />
/**<br />
* The POST data associated with a search submission, wrapped in a MIME<br />
* input stream. May be null.<br />
*/<br />
readonly attribute nsIInputStream postData;<br />
<br />
/**<br />
* The URI to submit a search to.<br />
*/<br />
readonly attribute nsIURI uri;<br />
};<br />
<br />
=nsISearchEngine=<br />
interface nsISearchEngine : nsISupports<br />
{<br />
/**<br />
* Gets a nsISearchSubmission object that contains information about what to<br />
* send to the search engine, including the URI and postData, if applicable. <br />
* @param data<br />
* Data to add to the submission object.<br />
* i.e. the search terms.<br />
* @param responseType<br />
* The MIME type that we'd like to receive in response<br />
* to this submission. If null, will default to "text/html".<br />
* @returns A nsISearchSubmission object that contains information about what<br />
* to send to the search engine.<br />
*/<br />
nsISearchSubmission getSubmission(in AString data, in AString responseType);<br />
<br />
/**<br />
* Adds a parameter to the search engine's submission data. This should only<br />
* be called on engine's created via addEngineWithDetails.<br />
* @param name<br />
* The parameter's name. Must not be null.<br />
* @param value<br />
* The value to pass. If value is "{searchTerms}", it will be<br />
* substituted with the user-entered data when retrieving the<br />
* submission. Must not be null.<br />
*<br />
* @throws NS_ERROR_FAILURE if the search engine is read-only.<br />
* @throws NS_ERROR_INVALID_ARG if name or value are null.<br />
*/<br />
void addParam(in AString name, in AString value);<br />
<br />
/**<br />
* Supported search engine types.<br />
*/<br />
const unsigned long TYPE_MOZSEARCH = 1;<br />
const unsigned long TYPE_SHERLOCK = 2;<br />
const unsigned long TYPE_OPENSEARCH = 3;<br />
<br />
/**<br />
* Supported search engine data types.<br />
*/<br />
const unsigned long DATA_XML = 1;<br />
const unsigned long DATA_TEXT = 2;<br />
<br />
/**<br />
* The shortcut alias of the engine. This is a unique identifier.<br />
*/<br />
attribute AString alias;<br />
<br />
/**<br />
* Whether the engine should be hidden from the user.<br />
*/<br />
attribute boolean hidden;<br />
<br />
/**<br />
* A nsIURI corresponding to the engine's icon, stored locally. May be null.<br />
*/<br />
readonly attribute nsIURI iconURI;<br />
<br />
/**<br />
* A string corresponding to the engine icon's URL. This will return<br />
* iconURI.spec, or an empty string if the engine has no iconURI.<br />
*/<br />
readonly attribute AString iconURL;<br />
<br />
/**<br />
* The display name of the search engine. This is a unique identifier.<br />
*/<br />
readonly attribute AString name;<br />
<br />
/**<br />
* The search engine type.<br />
*/<br />
readonly attribute long type;<br />
<br />
/**<br />
* A URL string pointing to the engine's search form.<br />
*/<br />
readonly attribute AString searchForm;<br />
<br />
};<br />
<br />
=nsIBrowserSearchService=<br />
interface nsISearchService : nsISupports<br />
{<br />
/**<br />
* Adds a new search engine from the file at the supplied URI.<br />
* @param engineURL the URL to the search engine's description file.<br />
* @param type an integer representing the plugin file format. Must be one<br />
* of the supported search engine data types defined above.<br />
* @param iconURL the URL to an icon file to be used as the search engine's<br />
* icon.<br />
*<br />
* @throws NS_ERROR_FAILURE if the type is invalid, or if the description<br />
* file cannot be successfully loaded.<br />
*/<br />
void addEngine(in AString engineURL, in long type, in AString iconURL);<br />
<br />
/**<br />
* Adds a new search engine.<br />
* @param name<br />
* The search engine's name. Must be unique. Must not be null.<br />
* @param iconURI<br />
* Optional: A URL string pointing to the icon to be used to represent<br />
* the engine.<br />
* @param alias<br />
* Optional: A unique shortcut that can be used to retrieve the<br />
* search engine.<br />
* @param description<br />
* Optional: a description of the search engine.<br />
* @param method<br />
* The HTTP request method used when submitting a search query.<br />
* Must be a case insensitive value of either "get" or "post".<br />
* @param url<br />
* The URL to which search queries should be sent.<br />
* Must not be null.<br />
*/<br />
void addEngineWithDetails(in AString name,<br />
in AString iconURL,<br />
in AString alias,<br />
in AString description,<br />
in AString method,<br />
in AString url);<br />
<br />
/**<br />
* Returns an engine with the specified alias.<br />
* @param alias<br />
* The search engine's alias.<br />
* @returns The corresponding nsISearchEngine object, or null if it doesn't<br />
* exist.<br />
*/<br />
nsISearchEngine getEngineByAlias(in AString alias);<br />
<br />
/**<br />
* Returns an engine with the specified name.<br />
* @param aEngineName<br />
* The name of the engine.<br />
* @returns The corresponding nsISearchEngine object, or null if it doesn't<br />
* exist.<br />
*/<br />
nsISearchEngine getEngineByName(in AString aEngineName);<br />
<br />
/**<br />
* Returns an array of all installed search engines.<br />
* @returns an array of nsISearchEngine objects.<br />
*/<br />
void getEngines(<br />
out unsigned long engineCount, <br />
[retval, array, size_is(engineCount)] out nsISearchEngine engines);<br />
<br />
/**<br />
* Returns an array of all installed search engines whose hidden attribute is<br />
* false.<br />
*<br />
* @returns an array of nsISearchEngine objects.<br />
*/<br />
void getVisibleEngines(<br />
out unsigned long engineCount, <br />
[retval, array, size_is(engineCount)] out nsISearchEngine engines);<br />
<br />
/**<br />
* Removes the search engine. If the search engine is installed in a global<br />
* location, this will just hide the engine. If the engine is in the user's<br />
* profile directory, it will be removed from disk.<br />
*<br />
* @param engine<br />
* The engine to remove.<br />
*/<br />
void removeEngine(in nsISearchEngine engine);<br />
<br />
/**<br />
* The default search engine.<br />
*/<br />
readonly attribute nsISearchEngine defaultEngine;<br />
<br />
/**<br />
* The currently active search engine.<br />
*/<br />
attribute nsISearchEngine currentEngine; <br />
<br />
};</div>-dt-