From e4809cc17c76f6de76772f267c2abb2d404759a4 Mon Sep 17 00:00:00 2001 From: "sgehani%netscape.com" Date: Thu, 28 Jun 2001 01:27:35 +0000 Subject: [PATCH] Add a dropdown to choose searchengine when in basic mode in the search sidebar panel. b = 86483 r = matt sr = alecf git-svn-id: svn://10.0.0.236/trunk@98118 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libpref/src/init/all.js | 3 + .../resources/locale/en-US/search-panel.dtd | 1 + .../search/resources/search-panel.js | 157 +++++++++++- .../search/resources/search-panel.xul | 19 ++ .../search/src/nsInternetSearchService.cpp | 75 +++--- .../search/src/nsInternetSearchService.h | 225 +++++++++--------- 6 files changed, 333 insertions(+), 147 deletions(-) diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index 6d6513608ec..f620ee09b5d 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -100,6 +100,9 @@ pref("browser.search.opensidebarsearchpanel", true); pref("browser.search.last_search_category", "NC:SearchCategory?category=urn:search:category:1"); pref("browser.search.mode", 0); pref("browser.search.powermode", 0); +// basic search popup constraint: minimum sherlock plugin version displayed +// (note: must be a string representation of a float or it'll default to 0.0) +pref("browser.search.basic.min_ver", "0.0"); pref("browser.urlbar.autocomplete.enabled", true); pref("browser.urlbar.clickSelectsAll",false); diff --git a/mozilla/xpfe/components/search/resources/locale/en-US/search-panel.dtd b/mozilla/xpfe/components/search/resources/locale/en-US/search-panel.dtd index 039a71a02ca..f5c53255141 100755 --- a/mozilla/xpfe/components/search/resources/locale/en-US/search-panel.dtd +++ b/mozilla/xpfe/components/search/resources/locale/en-US/search-panel.dtd @@ -24,6 +24,7 @@ + diff --git a/mozilla/xpfe/components/search/resources/search-panel.js b/mozilla/xpfe/components/search/resources/search-panel.js index be5761475f7..3f696132fa8 100644 --- a/mozilla/xpfe/components/search/resources/search-panel.js +++ b/mozilla/xpfe/components/search/resources/search-panel.js @@ -39,6 +39,21 @@ const nsIRDFDataSource = Components.interfaces.nsIRDFDataSource; const nsIRDFRemoteDataSource = Components.interfaces.nsIRDFRemoteDataSource; const nsIInternetSearchService = Components.interfaces.nsIInternetSearchService; +const DEBUG = false; + +var debug; +if (!DEBUG) +{ + debug = function(msg) {}; +} +else +{ + debug = function(msg) + { + dump("\t ^^^ search-panel.js: " + msg + "\n"); + }; +} + var rootNode; var textArc; var modeArc; @@ -118,18 +133,135 @@ function rememberSearchText(target) switchTab(0); } +function getIndexToSelect(haveDefault, defaultEngine, enginePopup) +{ + if (haveDefault) + { + // iterate over constrained engine list for a default engine match + for (var i = 0; i < enginePopup.childNodes.length; ++i) + { + if (enginePopup.childNodes[i].id == defaultEngine) + { + // found match with default engine! + return i; + } + } + } + + return 0; // default to first engine at index '0' +} + +function getMinVer() +{ + var minVerStr = nsPreferences. + copyUnicharPref("browser.search.basic.min_ver"); + var minVer = parseFloat(minVerStr); + if (isNaN(minVer)) + minVer = 0; // no pref or not a number so default to min ver 0.0 + + debug("Float value of minVer = " + minVer); + return minVer; +} + +/** + * Constrain the list of engines to only those that + * contain ver >= browser.search.basic.min_ver pref + * value to be displayed in the basic popup list of + * engines. + */ +function constrainBasicList() +{ + debug("constrainBasicList"); + + var basicEngineMenu = document.getElementById("basicEngineMenu"); + if (!basicEngineMenu) + { + debug("Ack! basicEngineList is empty!"); + return; + } + + var basicEngines = basicEngineMenu.childNodes[1]; + var len = basicEngines.childNodes.length; + var currDesc; + var currVer; + var haveDefault = false; + + debug("Found " + len + " sherlock plugins."); + var defaultEngine = nsPreferences. + copyUnicharPref("browser.search.defaultengine"); + + // we constrain the basic list to all engines with ver >= minVer + var minVer = getMinVer(); + + for (var i = 0; i < len; ++i) + { + currDesc = basicEngines.childNodes[i].getAttribute("desc"); + debug("Engine[" + i + "] = " + currDesc); + + // make sure we leave the default engine (check if we already have + // the default to avoid duplicates) + if (basicEngines.childNodes[i].id == defaultEngine && !haveDefault) + { + haveDefault = true; + } + else + { + // remove if not a basic engine + currVer = basicEngines.childNodes[i].getAttribute("ver"); + if (!currVer || isNaN(parseFloat(currVer))) + { + // missing version attr or not a number: default to ver 1.0 + currVer = 1; + } + debug("Version of " + (currDesc ? currDesc : "") + + " is: " + currVer); + + if (parseFloat(currVer) < minVer) + { + try + { + basicEngines.removeChild(basicEngines.childNodes[i]); + --i; + --len; + } + catch (ex) + { + debug("Exception: Couldn't remove " + currDesc + + " from engine list!"); + } + } + } + } + + // mark selected engine + var selected = getIndexToSelect(haveDefault, defaultEngine, basicEngines); + basicEngineMenu.selectedItem = basicEngines.childNodes[selected]; +} + function updateSearchMode() { - var searchMode = nsPreferences.getIntPref("browser.search.mode", 0); + debug("updateSearchMode"); + + var searchMode = nsPreferences.getIntPref("browser.search.mode"); var categoryBox = document.getElementById("categoryBox"); - if (!searchMode) { + var basicBox = document.getElementById("basicBox"); + + debug("search mode is " + searchMode); + if (searchMode == 0) + { categoryBox.setAttribute("collapsed", "true"); + basicBox.removeAttribute("collapsed"); switchTab(0); + + constrainBasicList(); } - else { + else + { categoryBox.removeAttribute("collapsed"); + basicBox.setAttribute("collapsed", "true"); switchTab(1); } + return searchMode; } @@ -244,10 +376,13 @@ function SearchPanelStartup() loadEngines(lastCategoryName); // if we have search results, show them, otherwise show engines - if (haveSearchResults() || updateSearchMode() == 0) - switchTab(0); - else - switchTab(1); + if (updateSearchMode() != 0) + { + if (haveSearchResults()) + switchTab(0); + else + switchTab(1); + } focusTextBox(); } @@ -537,6 +672,14 @@ function doSearch() } } } + else + { + var basicEngines = document.getElementById("basicEngineMenu"); + var engineURIs = []; + engineURIs[0] = basicEngines.selectedItem.id; + debug("basic mode URI = " + engineURIs[0]); + } + if (!gStopButtonText) gStopButtonText = searchBundle.getString("stopButtonText"); diff --git a/mozilla/xpfe/components/search/resources/search-panel.xul b/mozilla/xpfe/components/search/resources/search-panel.xul index 0cb822d4bc7..8c55c0047b5 100644 --- a/mozilla/xpfe/components/search/resources/search-panel.xul +++ b/mozilla/xpfe/components/search/resources/search-panel.xul @@ -58,6 +58,25 @@ disabled="true" oncommand="doSearch();"/> + + + + + + + + diff --git a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp index fd3b1fc2edf..e1b50c4eaab 100755 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp @@ -334,8 +334,9 @@ nsIRDFResource *InternetSearchDataSource::kNC_Title; nsIRDFResource *InternetSearchDataSource::kNC_Data; nsIRDFResource *InternetSearchDataSource::kNC_Name; nsIRDFResource *InternetSearchDataSource::kNC_Description; -nsIRDFResource *InternetSearchDataSource::kNC_actionButton; -nsIRDFResource *InternetSearchDataSource::kNC_actionBar; +nsIRDFResource *InternetSearchDataSource::kNC_Version; +nsIRDFResource *InternetSearchDataSource::kNC_actionButton; +nsIRDFResource *InternetSearchDataSource::kNC_actionBar; nsIRDFResource *InternetSearchDataSource::kNC_LastText; nsIRDFResource *InternetSearchDataSource::kNC_URL; nsIRDFResource *InternetSearchDataSource::kRDF_InstanceOf; @@ -400,8 +401,9 @@ InternetSearchDataSource::InternetSearchDataSource(void) gRDFService->GetResource(NC_NAMESPACE_URI "data", &kNC_Data); gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name); gRDFService->GetResource(NC_NAMESPACE_URI "Description", &kNC_Description); - gRDFService->GetResource(NC_NAMESPACE_URI "actionButton", &kNC_actionButton); - gRDFService->GetResource(NC_NAMESPACE_URI "actionBar", &kNC_actionBar); + gRDFService->GetResource(NC_NAMESPACE_URI "Version", &kNC_Version); + gRDFService->GetResource(NC_NAMESPACE_URI "actionButton", &kNC_actionButton); + gRDFService->GetResource(NC_NAMESPACE_URI "actionBar", &kNC_actionBar); gRDFService->GetResource(NC_NAMESPACE_URI "LastText", &kNC_LastText); gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL); gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_InstanceOf); @@ -464,8 +466,9 @@ InternetSearchDataSource::~InternetSearchDataSource (void) NS_IF_RELEASE(kNC_Data); NS_IF_RELEASE(kNC_Name); NS_IF_RELEASE(kNC_Description); - NS_IF_RELEASE(kNC_actionButton); - NS_IF_RELEASE(kNC_actionBar); + NS_IF_RELEASE(kNC_Version); + NS_IF_RELEASE(kNC_actionButton); + NS_IF_RELEASE(kNC_actionBar); NS_IF_RELEASE(kNC_LastText); NS_IF_RELEASE(kNC_URL); NS_IF_RELEASE(kRDF_InstanceOf); @@ -3123,29 +3126,39 @@ InternetSearchDataSource::updateDataHintsInGraph(nsIRDFResource *engine, const P } } - - nsAutoString buttonValue; - if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionButton", buttonValue))) + // save/update version of search engine (if specified) + nsAutoString versionValue; + if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "version", versionValue))) { - nsCOMPtr descLiteral; - if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(buttonValue.GetUnicode(), - getter_AddRefs(descLiteral)))) - { - rv = updateAtom(mInner, engine, kNC_actionButton, descLiteral, nsnull); - } - } + nsCOMPtr versionLiteral; + if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(versionValue.GetUnicode(), + getter_AddRefs(versionLiteral)))) + { + rv = updateAtom(mInner, engine, kNC_Version, versionLiteral, nsnull); + } + } + nsAutoString buttonValue; + if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionButton", buttonValue))) + { + nsCOMPtr buttonLiteral; + if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(buttonValue.GetUnicode(), + getter_AddRefs(buttonLiteral)))) + { + rv = updateAtom(mInner, engine, kNC_actionButton, buttonLiteral, nsnull); + } + } - nsAutoString barValue; - if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionBar", barValue))) - { - nsCOMPtr descLiteral; - if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(barValue.GetUnicode(), - getter_AddRefs(descLiteral)))) - { - rv = updateAtom(mInner, engine, kNC_actionBar, descLiteral, nsnull); - } - } + nsAutoString barValue; + if (NS_SUCCEEDED(rv = GetData(dataUni, "search", 0, "actionBar", barValue))) + { + nsCOMPtr barLiteral; + if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(barValue.GetUnicode(), + getter_AddRefs(barLiteral)))) + { + rv = updateAtom(mInner, engine, kNC_actionBar, barLiteral, nsnull); + } + } PRBool updatePrivateFiles = PR_FALSE; @@ -5049,8 +5062,14 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRD nsAutoString site(hrefStr); -#ifdef DEBUG_SEARCH_OUTPUT - printf("HREF: '%s'\n", href); +#ifdef DEBUG_SEARCH_OUTPUT + char *hrefCStr = hrefStr.ToNewCString(); + if (hrefCStr) + { + printf("HREF: '%s'\n", hrefCStr); + nsCRT::free(hrefCStr); + hrefCStr = nsnull; + } #endif nsCOMPtr res; diff --git a/mozilla/xpfe/components/search/src/nsInternetSearchService.h b/mozilla/xpfe/components/search/src/nsInternetSearchService.h index 54d644cd45b..cd629045139 100644 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.h +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.h @@ -39,135 +39,136 @@ class InternetSearchDataSource : public nsIInternetSearchService, - public nsIRDFDataSource, + public nsIRDFDataSource, public nsIStreamListener, public nsIObserver, - public nsSupportsWeakReference + public nsSupportsWeakReference { private: - static PRInt32 gRefCnt; - static PRBool mEngineListBuilt; + static PRInt32 gRefCnt; + static PRBool mEngineListBuilt; - // pseudo-constants - static nsIRDFResource *kNC_SearchResult; - static nsIRDFResource *kNC_SearchEngineRoot; - static nsIRDFResource *kNC_LastSearchRoot; - static nsIRDFResource *kNC_LastSearchMode; - static nsIRDFResource *kNC_SearchCategoryRoot; - static nsIRDFResource *kNC_SearchResultsSitesRoot; - static nsIRDFResource *kNC_FilterSearchURLsRoot; - static nsIRDFResource *kNC_FilterSearchSitesRoot; - static nsIRDFResource *kNC_SearchType; - static nsIRDFResource *kNC_Ref; - static nsIRDFResource *kNC_Child; - static nsIRDFResource *kNC_Title; - static nsIRDFResource *kNC_Data; - static nsIRDFResource *kNC_Name; - static nsIRDFResource *kNC_Description; - static nsIRDFResource *kNC_actionButton; - static nsIRDFResource *kNC_actionBar; - static nsIRDFResource *kNC_LastText; - static nsIRDFResource *kNC_URL; - static nsIRDFResource *kRDF_InstanceOf; - static nsIRDFResource *kRDF_type; - static nsIRDFResource *kNC_loading; - static nsIRDFResource *kNC_HTML; - static nsIRDFResource *kNC_Icon; - static nsIRDFResource *kNC_StatusIcon; - static nsIRDFResource *kNC_Banner; - static nsIRDFResource *kNC_Site; - static nsIRDFResource *kNC_Relevance; - static nsIRDFResource *kNC_Date; - static nsIRDFResource *kNC_RelevanceSort; - static nsIRDFResource *kNC_PageRank; - static nsIRDFResource *kNC_Engine; - static nsIRDFResource *kNC_Price; - static nsIRDFResource *kNC_PriceSort; - static nsIRDFResource *kNC_Availability; - static nsIRDFResource *kNC_BookmarkSeparator; - static nsIRDFResource *kNC_Update; - static nsIRDFResource *kNC_UpdateIcon; - static nsIRDFResource *kNC_UpdateCheckDays; - static nsIRDFResource *kWEB_LastPingDate; - static nsIRDFResource *kWEB_LastPingModDate; - static nsIRDFResource *kWEB_LastPingContentLen; + // pseudo-constants + static nsIRDFResource *kNC_SearchResult; + static nsIRDFResource *kNC_SearchEngineRoot; + static nsIRDFResource *kNC_LastSearchRoot; + static nsIRDFResource *kNC_LastSearchMode; + static nsIRDFResource *kNC_SearchCategoryRoot; + static nsIRDFResource *kNC_SearchResultsSitesRoot; + static nsIRDFResource *kNC_FilterSearchURLsRoot; + static nsIRDFResource *kNC_FilterSearchSitesRoot; + static nsIRDFResource *kNC_SearchType; + static nsIRDFResource *kNC_Ref; + static nsIRDFResource *kNC_Child; + static nsIRDFResource *kNC_Title; + static nsIRDFResource *kNC_Data; + static nsIRDFResource *kNC_Name; + static nsIRDFResource *kNC_Description; + static nsIRDFResource *kNC_Version; + static nsIRDFResource *kNC_actionButton; + static nsIRDFResource *kNC_actionBar; + static nsIRDFResource *kNC_LastText; + static nsIRDFResource *kNC_URL; + static nsIRDFResource *kRDF_InstanceOf; + static nsIRDFResource *kRDF_type; + static nsIRDFResource *kNC_loading; + static nsIRDFResource *kNC_HTML; + static nsIRDFResource *kNC_Icon; + static nsIRDFResource *kNC_StatusIcon; + static nsIRDFResource *kNC_Banner; + static nsIRDFResource *kNC_Site; + static nsIRDFResource *kNC_Relevance; + static nsIRDFResource *kNC_Date; + static nsIRDFResource *kNC_RelevanceSort; + static nsIRDFResource *kNC_PageRank; + static nsIRDFResource *kNC_Engine; + static nsIRDFResource *kNC_Price; + static nsIRDFResource *kNC_PriceSort; + static nsIRDFResource *kNC_Availability; + static nsIRDFResource *kNC_BookmarkSeparator; + static nsIRDFResource *kNC_Update; + static nsIRDFResource *kNC_UpdateIcon; + static nsIRDFResource *kNC_UpdateCheckDays; + static nsIRDFResource *kWEB_LastPingDate; + static nsIRDFResource *kWEB_LastPingModDate; + static nsIRDFResource *kWEB_LastPingContentLen; - static nsIRDFResource *kNC_SearchCommand_AddToBookmarks; - static nsIRDFResource *kNC_SearchCommand_FilterResult; - static nsIRDFResource *kNC_SearchCommand_FilterSite; - static nsIRDFResource *kNC_SearchCommand_ClearFilters; + static nsIRDFResource *kNC_SearchCommand_AddToBookmarks; + static nsIRDFResource *kNC_SearchCommand_FilterResult; + static nsIRDFResource *kNC_SearchCommand_FilterSite; + static nsIRDFResource *kNC_SearchCommand_ClearFilters; - static nsIRDFLiteral *kTrueLiteral; + static nsIRDFLiteral *kTrueLiteral; protected: - static nsIRDFDataSource *mInner; - static nsCOMPtr mLocalstore; - static nsCOMPtr mUpdateArray; - nsCOMPtr mTimer; - static nsCOMPtr mBackgroundLoadGroup; - static nsCOMPtr mLoadGroup; - static nsCOMPtr categoryDataSource; - static nsCOMPtr prefs; - PRBool busySchedule; - nsCOMPtr busyResource; - nsString mQueryEncodingStr; + static nsIRDFDataSource *mInner; + static nsCOMPtr mLocalstore; + static nsCOMPtr mUpdateArray; + nsCOMPtr mTimer; + static nsCOMPtr mBackgroundLoadGroup; + static nsCOMPtr mLoadGroup; + static nsCOMPtr categoryDataSource; + static nsCOMPtr prefs; + PRBool busySchedule; + nsCOMPtr busyResource; + nsString mQueryEncodingStr; -friend int PR_CALLBACK searchModePrefCallback(const char *pref, void *aClosure); +friend int PR_CALLBACK searchModePrefCallback(const char *pref, void *aClosure); - // helper methods - nsresult GetSearchEngineToPing(nsIRDFResource **theResource, nsCString &updateURL); - PRBool isEngineURI(nsIRDFResource* aResource); - PRBool isSearchURI(nsIRDFResource* aResource); - PRBool isSearchCategoryURI(nsIRDFResource* aResource); - PRBool isSearchCategoryEngineURI(nsIRDFResource* aResource); - PRBool isSearchCategoryEngineBasenameURI(nsIRDFNode *aResource); - PRBool isSearchCommand(nsIRDFResource* aResource); - nsresult resolveSearchCategoryEngineURI(nsIRDFResource *source, nsIRDFResource **trueEngine); - nsresult BeginSearchRequest(nsIRDFResource *source, PRBool doNetworkRequest); - nsresult FindData(nsIRDFResource *engine, nsIRDFLiteral **data); - nsresult updateDataHintsInGraph(nsIRDFResource *engine, const PRUnichar *data); - nsresult updateAtom(nsIRDFDataSource *db, nsIRDFResource *src, nsIRDFResource *prop, nsIRDFNode *newValue, PRBool *dirtyFlag); - nsresult validateEngine(nsIRDFResource *engine); - nsresult DoSearch(nsIRDFResource *source, nsIRDFResource *engine, const nsString &fullURL, const nsString &text); - nsresult MapEncoding(const nsString &numericEncoding, nsString &stringEncoding); - nsresult SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon, const PRUnichar *hint, const PRUnichar *data, PRBool checkMacFileType); - nsresult GetSearchEngineList(nsIFile *spec, PRBool checkMacFileType); - nsresult GetCategoryList(); - nsresult GetSearchFolder(nsIFile **spec); - nsresult ReadFileContents(const nsFileSpec &baseFilename, nsString & sourceContents); - nsresult GetData(const PRUnichar *data, const char *sectionToFind, PRUint32 sectionNum, const char *attribToFind, nsString &value); - nsresult GetNumInterpretSections(const PRUnichar *data, PRUint32 &numInterpretSections); - nsresult GetInputs(const PRUnichar *data, nsString &userVar, const nsString &text, nsString &input); - nsresult GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult); - nsresult validateEngineNow(nsIRDFResource *engine); - nsresult webSearchFinalize(nsIChannel *channel, nsIInternetSearchContext *context); - nsresult ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRDFResource *engine, const PRUnichar *htmlPage); - nsresult SetHint(nsIRDFResource *mParent, nsIRDFResource *hintRes); - nsresult ConvertEntities(nsString &str, PRBool removeHTMLFlag = PR_TRUE, PRBool removeCRLFsFlag = PR_TRUE, PRBool trimWhiteSpaceFlag = PR_TRUE); - nsresult saveContents(nsIChannel* channel, nsIInternetSearchContext *context, PRUint32 contextType); - char * getSearchURI(nsIRDFResource *src); - nsresult addToBookmarks(nsIRDFResource *src); - nsresult filterResult(nsIRDFResource *src); - nsresult filterSite(nsIRDFResource *src); - nsresult clearFilters(void); - PRBool isSearchResultFiltered(const nsString &href); + // helper methods + nsresult GetSearchEngineToPing(nsIRDFResource **theResource, nsCString &updateURL); + PRBool isEngineURI(nsIRDFResource* aResource); + PRBool isSearchURI(nsIRDFResource* aResource); + PRBool isSearchCategoryURI(nsIRDFResource* aResource); + PRBool isSearchCategoryEngineURI(nsIRDFResource* aResource); + PRBool isSearchCategoryEngineBasenameURI(nsIRDFNode *aResource); + PRBool isSearchCommand(nsIRDFResource* aResource); + nsresult resolveSearchCategoryEngineURI(nsIRDFResource *source, nsIRDFResource **trueEngine); + nsresult BeginSearchRequest(nsIRDFResource *source, PRBool doNetworkRequest); + nsresult FindData(nsIRDFResource *engine, nsIRDFLiteral **data); + nsresult updateDataHintsInGraph(nsIRDFResource *engine, const PRUnichar *data); + nsresult updateAtom(nsIRDFDataSource *db, nsIRDFResource *src, nsIRDFResource *prop, nsIRDFNode *newValue, PRBool *dirtyFlag); + nsresult validateEngine(nsIRDFResource *engine); + nsresult DoSearch(nsIRDFResource *source, nsIRDFResource *engine, const nsString &fullURL, const nsString &text); + nsresult MapEncoding(const nsString &numericEncoding, nsString &stringEncoding); + nsresult SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon, const PRUnichar *hint, const PRUnichar *data, PRBool checkMacFileType); + nsresult GetSearchEngineList(nsIFile *spec, PRBool checkMacFileType); + nsresult GetCategoryList(); + nsresult GetSearchFolder(nsIFile **spec); + nsresult ReadFileContents(const nsFileSpec &baseFilename, nsString & sourceContents); + nsresult GetData(const PRUnichar *data, const char *sectionToFind, PRUint32 sectionNum, const char *attribToFind, nsString &value); + nsresult GetNumInterpretSections(const PRUnichar *data, PRUint32 &numInterpretSections); + nsresult GetInputs(const PRUnichar *data, nsString &userVar, const nsString &text, nsString &input); + nsresult GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult); + nsresult validateEngineNow(nsIRDFResource *engine); + nsresult webSearchFinalize(nsIChannel *channel, nsIInternetSearchContext *context); + nsresult ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRDFResource *engine, const PRUnichar *htmlPage); + nsresult SetHint(nsIRDFResource *mParent, nsIRDFResource *hintRes); + nsresult ConvertEntities(nsString &str, PRBool removeHTMLFlag = PR_TRUE, PRBool removeCRLFsFlag = PR_TRUE, PRBool trimWhiteSpaceFlag = PR_TRUE); + nsresult saveContents(nsIChannel* channel, nsIInternetSearchContext *context, PRUint32 contextType); + char * getSearchURI(nsIRDFResource *src); + nsresult addToBookmarks(nsIRDFResource *src); + nsresult filterResult(nsIRDFResource *src); + nsresult filterSite(nsIRDFResource *src); + nsresult clearFilters(void); + PRBool isSearchResultFiltered(const nsString &href); -static void FireTimer(nsITimer* aTimer, void* aClosure); +static void FireTimer(nsITimer* aTimer, void* aClosure); public: - NS_DECL_ISUPPORTS - NS_DECL_NSIINTERNETSEARCHSERVICE - NS_DECL_NSIREQUESTOBSERVER - NS_DECL_NSISTREAMLISTENER - NS_DECL_NSIRDFDATASOURCE - NS_DECL_NSIOBSERVER + NS_DECL_ISUPPORTS + NS_DECL_NSIINTERNETSEARCHSERVICE + NS_DECL_NSIREQUESTOBSERVER + NS_DECL_NSISTREAMLISTENER + NS_DECL_NSIRDFDATASOURCE + NS_DECL_NSIOBSERVER - InternetSearchDataSource(void); - virtual ~InternetSearchDataSource(void); - NS_METHOD Init(); - NS_METHOD DeferredInit(); + InternetSearchDataSource(void); + virtual ~InternetSearchDataSource(void); + NS_METHOD Init(); + NS_METHOD DeferredInit(); }; #endif // nsinternetsearchdatasource__h____