diff --git a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp index 8dd6c286f48..18eda334b26 100755 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp @@ -62,6 +62,7 @@ #include "nsIInputStream.h" #include "nsIBookmarksService.h" #include "nsIHTTPHeader.h" +#include "nsIStringBundle.h" #ifdef XP_MAC #include @@ -79,8 +80,9 @@ -#define POSTHEADER_PREFIX "Content-type: application/x-www-form-urlencoded\r\nContent-Length: " -#define POSTHEADER_SUFFIX "\r\n\r\n" +#define POSTHEADER_PREFIX "Content-type: application/x-www-form-urlencoded\r\nContent-Length: " +#define POSTHEADER_SUFFIX "\r\n\r\n" +#define SEARCH_PROPERTIES "chrome://communicator/locale/search/search-panel.properties" @@ -550,7 +552,7 @@ InternetSearchDataSource::GetSearchEngineToPing(nsIRDFResource **theEngine, nsCS mUpdateArray->RemoveElementAt(0); if (isupports) { - nsCOMPtr aRes = do_QueryInterface(isupports); + nsCOMPtr aRes (do_QueryInterface(isupports)); if (aRes) { if (isSearchCategoryEngineURI(aRes)) @@ -573,7 +575,7 @@ InternetSearchDataSource::GetSearchEngineToPing(nsIRDFResource **theEngine, nsCS if (NS_SUCCEEDED(rv = mInner->GetTarget(aRes, kNC_Update, PR_TRUE, getter_AddRefs(aNode))) && (rv != NS_RDF_NO_VALUE)) { - nsCOMPtr aLiteral = do_QueryInterface(aNode); + nsCOMPtr aLiteral (do_QueryInterface(aNode)); if (aLiteral) { const PRUnichar *updateUni = nsnull; @@ -623,7 +625,7 @@ InternetSearchDataSource::FireTimer(nsITimer* aTimer, void* aClosure) channel->SetLoadAttributes(nsIChannel::FORCE_VALIDATION | nsIChannel::VALIDATE_ALWAYS); - nsCOMPtr httpChannel = do_QueryInterface(channel); + nsCOMPtr httpChannel (do_QueryInterface(channel)); if (!httpChannel) return; // rjc says: just check "HEAD" info for whether a search file has changed @@ -737,7 +739,7 @@ InternetSearchDataSource::isSearchCategoryEngineBasenameURI(nsIRDFNode *r) { PRBool isSearchCategoryEngineBasenameURIFlag = PR_FALSE; - nsCOMPtr aRes = do_QueryInterface(r); + nsCOMPtr aRes (do_QueryInterface(r)); if (aRes) { const char *uri = nsnull; @@ -750,7 +752,7 @@ InternetSearchDataSource::isSearchCategoryEngineBasenameURI(nsIRDFNode *r) } else { - nsCOMPtr aLit = do_QueryInterface(r); + nsCOMPtr aLit (do_QueryInterface(r)); if (aLit) { const PRUnichar *uriUni = nsnull; @@ -1038,28 +1040,41 @@ InternetSearchDataSource::GetTarget(nsIRDFResource *source, if (isSearchCommand(source) && (property == kNC_Name)) { - // XXX localize: put static strings into a string bundle - nsAutoString name; - if (source == kNC_SearchCommand_AddToBookmarks) - name.AssignWithConversion("Add to bookmarks"); - else if (source == kNC_SearchCommand_FilterResult) - name.AssignWithConversion("Exclude this URL from future searches"); - else if (source == kNC_SearchCommand_FilterSite) - name.AssignWithConversion("Exclude this domain from future searches"); - else if (source == kNC_SearchCommand_ClearFilters) - name.AssignWithConversion("Clear all search filters"); + nsresult rv; + nsCOMPtr + stringService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv)); - if (name.Length() > 0) - { - *target = nsnull; - nsCOMPtr literal; - if (NS_FAILED(rv = gRDFService->GetLiteral(name.GetUnicode(), getter_AddRefs(literal)))) - return(rv); - *target = literal; - NS_IF_ADDREF(*target); - return(rv); - } - } + if (NS_SUCCEEDED(rv) && stringService) { + + nsCOMPtr bundle; + rv = stringService->CreateBundle(SEARCH_PROPERTIES, nsnull, getter_AddRefs(bundle)); + if (NS_SUCCEEDED(rv) && bundle) { + + nsXPIDLString valUni; + nsAutoString name; + + if (source == kNC_SearchCommand_AddToBookmarks) + name = NS_LITERAL_STRING("addtobookmarks"); + else if (source == kNC_SearchCommand_FilterResult) + name = NS_LITERAL_STRING("excludeurl"); + else if (source == kNC_SearchCommand_FilterSite) + name = NS_LITERAL_STRING("excludedomain"); + else if (source == kNC_SearchCommand_ClearFilters) + name = NS_LITERAL_STRING("clearfilters"); + + rv = bundle->GetStringFromName(name.GetUnicode(), getter_Copies(valUni)); + if (NS_SUCCEEDED(rv) && valUni && *valUni) { + *target = nsnull; + nsCOMPtr literal; + if (NS_FAILED(rv = gRDFService->GetLiteral(valUni, getter_AddRefs(literal)))) + return rv; + *target = literal; + NS_IF_ADDREF(*target); + return rv; + } + } + } + } if (isEngineURI(source)) { @@ -1180,7 +1195,7 @@ InternetSearchDataSource::GetCategoryList() ds = nsnull; if (!categoryDataSource) return(NS_ERROR_UNEXPECTED); - nsCOMPtr remoteCategoryDataSource = do_QueryInterface(categoryDataSource); + nsCOMPtr remoteCategoryDataSource (do_QueryInterface(categoryDataSource)); if (!remoteCategoryDataSource) return(NS_ERROR_UNEXPECTED); // get search.rdf @@ -1228,7 +1243,7 @@ InternetSearchDataSource::GetCategoryList() rv = categoryDataSource->GetTarget(kNC_SearchCategoryRoot, aCategoryOrdinal, PR_TRUE, getter_AddRefs(aCategoryNode)); if (NS_FAILED(rv)) break; - nsCOMPtr aCategoryRes = do_QueryInterface(aCategoryNode); + nsCOMPtr aCategoryRes (do_QueryInterface(aCategoryNode)); if (!aCategoryRes) break; const char *catResURI = nsnull; aCategoryRes->GetValueConst(&catResURI); @@ -1266,7 +1281,7 @@ InternetSearchDataSource::GetCategoryList() rv = categoryDataSource->GetTarget(searchCategoryRes, aEngineOrdinal, PR_TRUE, getter_AddRefs(aEngineNode)); if (NS_FAILED(rv)) break; - nsCOMPtr aEngineRes = do_QueryInterface(aEngineNode); + nsCOMPtr aEngineRes (do_QueryInterface(aEngineNode)); if (!aEngineRes) break; if (isSearchCategoryEngineURI(aEngineRes)) @@ -1680,7 +1695,7 @@ InternetSearchDataSource::GetAllCmds(nsIRDFResource* source, nsCOMPtr datasource; if (NS_SUCCEEDED(rv = gRDFService->GetDataSource("rdf:bookmarks", getter_AddRefs(datasource)))) { - nsCOMPtr bookmarks = do_QueryInterface(datasource); + nsCOMPtr bookmarks (do_QueryInterface(datasource)); if (bookmarks) { char *uri = getSearchURI(source); @@ -1759,7 +1774,7 @@ InternetSearchDataSource::getSearchURI(nsIRDFResource *src) nsCOMPtr srcNode; if (NS_SUCCEEDED(rv = mInner->GetTarget(src, kNC_URL, PR_TRUE, getter_AddRefs(srcNode)))) { - nsCOMPtr urlLiteral = do_QueryInterface(srcNode); + nsCOMPtr urlLiteral (do_QueryInterface(srcNode)); if (urlLiteral) { const PRUnichar *uriUni = nsnull; @@ -1800,7 +1815,7 @@ InternetSearchDataSource::addToBookmarks(nsIRDFResource *src) nsCOMPtr datasource; if (NS_SUCCEEDED(rv = gRDFService->GetDataSource("rdf:bookmarks", getter_AddRefs(datasource)))) { - nsCOMPtr bookmarks = do_QueryInterface(datasource); + nsCOMPtr bookmarks (do_QueryInterface(datasource)); if (bookmarks) { char *uri = getSearchURI(src); @@ -1848,7 +1863,7 @@ InternetSearchDataSource::filterResult(nsIRDFResource *aResource) mLocalstore->Assert(kNC_FilterSearchURLsRoot, kNC_Child, urlLiteral, PR_TRUE); // flush localstore - nsCOMPtr remoteLocalStore = do_QueryInterface(mLocalstore); + nsCOMPtr remoteLocalStore (do_QueryInterface(mLocalstore)); if (remoteLocalStore) { remoteLocalStore->Flush(); @@ -1866,7 +1881,7 @@ InternetSearchDataSource::filterResult(nsIRDFResource *aResource) nsCOMPtr anonArc; if (NS_FAILED(anonArcs->GetNext(getter_AddRefs(anonArc)))) break; - nsCOMPtr anonChild = do_QueryInterface(anonArc); + nsCOMPtr anonChild (do_QueryInterface(anonArc)); if (!anonChild) continue; PRBool isSearchResult = PR_FALSE; @@ -1925,7 +1940,7 @@ InternetSearchDataSource::filterSite(nsIRDFResource *aResource) mLocalstore->Assert(kNC_FilterSearchSitesRoot, kNC_Child, urlLiteral, PR_TRUE); // flush localstore - nsCOMPtr remoteLocalStore = do_QueryInterface(mLocalstore); + nsCOMPtr remoteLocalStore (do_QueryInterface(mLocalstore)); if (remoteLocalStore) { remoteLocalStore->Flush(); @@ -1969,7 +1984,7 @@ InternetSearchDataSource::filterSite(nsIRDFResource *aResource) { nsCOMPtr element = array->ElementAt(loop); if (!element) break; - nsCOMPtr aSearchRoot = do_QueryInterface(element); + nsCOMPtr aSearchRoot (do_QueryInterface(element)); if (!aSearchRoot) break; if (NS_SUCCEEDED(rv = mInner->GetTargets(aSearchRoot, kNC_Child, @@ -2035,7 +2050,7 @@ InternetSearchDataSource::clearFilters(void) if (NS_FAILED(arcs->GetNext(getter_AddRefs(arc)))) break; - nsCOMPtr filterURL = do_QueryInterface(arc); + nsCOMPtr filterURL (do_QueryInterface(arc)); if (!filterURL) continue; mLocalstore->Unassert(kNC_FilterSearchURLsRoot, kNC_Child, filterURL); @@ -2054,7 +2069,7 @@ InternetSearchDataSource::clearFilters(void) if (NS_FAILED(arcs->GetNext(getter_AddRefs(arc)))) break; - nsCOMPtr filterSiteLiteral = do_QueryInterface(arc); + nsCOMPtr filterSiteLiteral (do_QueryInterface(arc)); if (!filterSiteLiteral) continue; mLocalstore->Unassert(kNC_FilterSearchSitesRoot, kNC_Child, filterSiteLiteral); @@ -2062,7 +2077,7 @@ InternetSearchDataSource::clearFilters(void) } // flush localstore - nsCOMPtr remoteLocalStore = do_QueryInterface(mLocalstore); + nsCOMPtr remoteLocalStore (do_QueryInterface(mLocalstore)); if (remoteLocalStore) { remoteLocalStore->Flush(); @@ -2136,7 +2151,7 @@ InternetSearchDataSource::DoCommand(nsISupportsArray/**/* aSourc { nsCOMPtr aSource = aSources->ElementAt(loop); if (!aSource) return(NS_ERROR_NULL_POINTER); - nsCOMPtr src = do_QueryInterface(aSource); + nsCOMPtr src (do_QueryInterface(aSource)); if (!src) return(NS_ERROR_NO_INTERFACE); if (aCommand == kNC_SearchCommand_AddToBookmarks) @@ -2709,7 +2724,7 @@ InternetSearchDataSource::ClearResults(PRBool flushLastSearchRef) nsCOMPtr arc; if (NS_FAILED(arcs->GetNext(getter_AddRefs(arc)))) break; - nsCOMPtr child = do_QueryInterface(arc); + nsCOMPtr child (do_QueryInterface(arc)); if (child) { mInner->Unassert(kNC_LastSearchRoot, kNC_Child, child); @@ -2724,7 +2739,7 @@ InternetSearchDataSource::ClearResults(PRBool flushLastSearchRef) if (NS_SUCCEEDED(rv = mInner->GetTarget(kNC_LastSearchRoot, kNC_Ref, PR_TRUE, getter_AddRefs(lastTarget))) && (rv != NS_RDF_NO_VALUE)) { - nsCOMPtr lastLiteral = do_QueryInterface(lastTarget); + nsCOMPtr lastLiteral (do_QueryInterface(lastTarget)); if (lastLiteral) { rv = mInner->Unassert(kNC_LastSearchRoot, kNC_Ref, lastLiteral); @@ -2756,7 +2771,7 @@ InternetSearchDataSource::ClearResultSearchSites(void) nsCOMPtr arc; if (NS_FAILED(arcs->GetNext(getter_AddRefs(arc)))) break; - nsCOMPtr child = do_QueryInterface(arc); + nsCOMPtr child (do_QueryInterface(arc)); if (child) { mInner->Unassert(kNC_SearchResultsSitesRoot, kNC_Child, child); @@ -2811,7 +2826,7 @@ InternetSearchDataSource::Stop() nsCOMPtr isupports; if (NS_FAILED(rv = requests->GetNext(getter_AddRefs(isupports)))) break; - nsCOMPtr request = do_QueryInterface(isupports); + nsCOMPtr request (do_QueryInterface(isupports)); if (!request) continue; request->Cancel(NS_BINDING_ABORTED); } @@ -2832,7 +2847,7 @@ InternetSearchDataSource::Stop() nsCOMPtr arc; if (NS_FAILED(arcs->GetNext(getter_AddRefs(arc)))) break; - nsCOMPtr src = do_QueryInterface(arc); + nsCOMPtr src (do_QueryInterface(arc)); if (src) { mInner->Unassert(src, kNC_loading, kTrueLiteral); @@ -3005,7 +3020,7 @@ InternetSearchDataSource::FindData(nsIRDFResource *engine, nsIRDFLiteral **dataL if (NS_SUCCEEDED((rv = mInner->GetTarget(engine, kNC_Data, PR_TRUE, getter_AddRefs(dataTarget)))) && (dataTarget)) { - nsCOMPtr aLiteral = do_QueryInterface(dataTarget); + nsCOMPtr aLiteral (do_QueryInterface(dataTarget)); if (!aLiteral) return(NS_ERROR_UNEXPECTED); *dataLit = aLiteral; @@ -3315,7 +3330,7 @@ InternetSearchDataSource::validateEngine(nsIRDFResource *engine) nsCOMPtr updateCheckDaysNode; rv = mInner->GetTarget(engine, kNC_UpdateCheckDays, PR_TRUE, getter_AddRefs(updateCheckDaysNode)); if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE)) return(rv); - nsCOMPtr updateCheckDaysLiteral = do_QueryInterface(updateCheckDaysNode); + nsCOMPtr updateCheckDaysLiteral (do_QueryInterface(updateCheckDaysNode)); PRInt32 updateCheckDays; updateCheckDaysLiteral->GetValue(&updateCheckDays); // convert updateCheckDays from days to seconds; @@ -3351,7 +3366,7 @@ InternetSearchDataSource::validateEngine(nsIRDFResource *engine) } // get last validate date/time - nsCOMPtr lastCheckLiteral = do_QueryInterface(aNode); + nsCOMPtr lastCheckLiteral (do_QueryInterface(aNode)); if (!lastCheckLiteral) return(NS_ERROR_UNEXPECTED); const PRUnichar *lastCheckUni = nsnull; lastCheckLiteral->GetValueConst(&lastCheckUni); @@ -3522,7 +3537,7 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin { // send a "MultiSearch" header - nsCOMPtr httpMultiChannel = do_QueryInterface(channel); + nsCOMPtr httpMultiChannel (do_QueryInterface(channel)); if (httpMultiChannel) { nsCOMPtr multiSearchAtom = getter_AddRefs(NS_NewAtom("MultiSearch")); @@ -3537,7 +3552,7 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin if (methodStr.EqualsIgnoreCase("post")) { - nsCOMPtr httpChannel = do_QueryInterface(channel); + nsCOMPtr httpChannel (do_QueryInterface(channel)); if (httpChannel) { nsCOMPtr postAtom = getter_AddRefs(NS_NewAtom("POST")); @@ -4304,7 +4319,7 @@ InternetSearchDataSource::OnDataAvailable(nsIRequest *request, nsISupports *ctxt nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { if (!ctxt) return(NS_ERROR_NO_INTERFACE); - nsCOMPtr context = do_QueryInterface(ctxt); + nsCOMPtr context (do_QueryInterface(ctxt)); if (!context) return(NS_ERROR_NO_INTERFACE); nsresult rv = NS_OK; @@ -4398,9 +4413,8 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt, { if (!mInner) return(NS_OK); - nsCOMPtr channel = do_QueryInterface(request); - - nsCOMPtr context = do_QueryInterface(ctxt); + nsCOMPtr channel (do_QueryInterface(request)); + nsCOMPtr context (do_QueryInterface(ctxt)); if (!ctxt) return(NS_ERROR_NO_INTERFACE); nsresult rv; @@ -4415,7 +4429,7 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt, else if (contextType == nsIInternetSearchContext::ENGINE_DOWNLOAD_CONTEXT || contextType == nsIInternetSearchContext::ICON_DOWNLOAD_CONTEXT) { - nsCOMPtr httpChannel = do_QueryInterface(channel); + nsCOMPtr httpChannel (do_QueryInterface(channel)); if (!httpChannel) return(NS_ERROR_UNEXPECTED); // check HTTP status to ensure success @@ -4442,7 +4456,7 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt, busyResource = nsnull; // we only have HTTP "HEAD" information when doing updates - nsCOMPtr httpChannel = do_QueryInterface(channel); + nsCOMPtr httpChannel (do_QueryInterface(channel)); if (!httpChannel) return(NS_ERROR_UNEXPECTED); // check HTTP status to ensure success @@ -4463,7 +4477,7 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt, { nsCOMPtr item; enumerator->GetNext(getter_AddRefs(item)); - nsCOMPtr header = do_QueryInterface(item); + nsCOMPtr header (do_QueryInterface(item)); NS_ASSERTION(header, "InternetSearchDataSource::OnStopRequest - Bad HTTP header."); if (!header) return(NS_ERROR_UNEXPECTED); @@ -4572,7 +4586,7 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt, if (NS_SUCCEEDED(rv = mInner->GetTarget(theEngine, kNC_Update, PR_TRUE, getter_AddRefs(aNode))) && (rv != NS_RDF_NO_VALUE)) { - nsCOMPtr aLiteral = do_QueryInterface(aNode); + nsCOMPtr aLiteral (do_QueryInterface(aNode)); if (aLiteral) { const PRUnichar *updateUni = nsnull; @@ -4589,7 +4603,7 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt, if (NS_SUCCEEDED(rv = mInner->GetTarget(theEngine, kNC_UpdateIcon, PR_TRUE, getter_AddRefs(aNode))) && (rv != NS_RDF_NO_VALUE)) { - nsCOMPtr aIconLiteral = do_QueryInterface(aNode); + nsCOMPtr aIconLiteral (do_QueryInterface(aNode)); if (aIconLiteral) { const PRUnichar *updateIconUni = nsnull; @@ -4644,7 +4658,7 @@ InternetSearchDataSource::validateEngineNow(nsIRDFResource *engine) updateAtom(mLocalstore, engine, kWEB_LastPingDate, nowLiteral, nsnull); // flush localstore - nsCOMPtr remoteLocalStore = do_QueryInterface(mLocalstore); + nsCOMPtr remoteLocalStore (do_QueryInterface(mLocalstore)); if (remoteLocalStore) { remoteLocalStore->Flush(); @@ -4737,7 +4751,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRD { return(rv); } - nsCOMPtr dataLiteral = do_QueryInterface(dataNode); + nsCOMPtr dataLiteral (do_QueryInterface(dataNode)); if (!dataLiteral) return(NS_ERROR_NULL_POINTER); const PRUnichar *dataUni = nsnull;