nsCOMPtr<nsIRDFResource>	mEngine; if (NS_FAILED(rv = context->GetEngine(getter_AddRefs(mEngine))))	return(rv); if (!mEngine)	return(NS_ERROR_NO_INTERFACE);
if (contextType == nsIInternetSearchContext::WEB_SEARCH_CONTEXT) {  rv = webSearchFinalize(channel, context); } else if (contextType == nsIInternetSearchContext::ENGINE_DOWNLOAD_CONTEXT || contextType == nsIInternetSearchContext::ICON_DOWNLOAD_CONTEXT) { nsCOMPtr<nsIHttpChannel> httpChannel (do_QueryInterface(channel)); if (!httpChannel)	return(NS_ERROR_UNEXPECTED);
InternetSearchDataSource::OnStopRequest(nsIChannel* channel, nsISupports *ctxt,					nsresult status, const PRUnichar *errorMsg) {	if (!mInner)	return(NS_OK);	if (mConnections)	{		mConnections->RemoveElement(channel);	}	nsCOMPtr<nsIInternetSearchContext>	context = do_QueryInterface(ctxt);	if (!ctxt)	return(NS_ERROR_NO_INTERFACE);	nsresult			rv;	nsCOMPtr<nsIRDFResource>	mParent;	if (NS_FAILED(rv = context->GetParent(getter_AddRefs(mParent))))	return(rv);//	Note: mParent can be null//	if (!mParent)	return(NS_ERROR_NO_INTERFACE);	nsCOMPtr<nsIRDFResource>	mEngine;	if (NS_FAILED(rv = context->GetEngine(getter_AddRefs(mEngine))))	return(rv);	if (!mEngine)	return(NS_ERROR_NO_INTERFACE);	nsCOMPtr<nsIURI> aURL;	rv = channel->GetURI(getter_AddRefs(aURL));	if (NS_FAILED(rv)) return rv;	nsCOMPtr<nsIRDFLiteral>	trueLiteral;	if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(nsAutoString("true").GetUnicode(), getter_AddRefs(trueLiteral))))	{		mInner->Unassert(mEngine, kNC_loading, trueLiteral);		if (mConnections)		{			PRUint32	count=0;			mConnections->Count(&count);			if (count <= 1)			{				if (mParent)				{					mInner->Unassert(mParent, kNC_loading, trueLiteral);				}			}		}	}	// copy the engine's icon reference (if it has one) onto the result node	nsCOMPtr<nsIRDFNode>		engineIconStatusNode = nsnull;	mInner->GetTarget(mEngine, kNC_Icon, PR_TRUE, getter_AddRefs(engineIconStatusNode));	if (engineIconStatusNode)	{		rv = mInner->Assert(mEngine, kNC_StatusIcon, engineIconStatusNode, PR_TRUE);	}	PRUnichar	*uniBuf = nsnull;	if (NS_FAILED(rv = context->GetBuffer(&uniBuf)))	return(rv);	if (!uniBuf)	return(NS_ERROR_UNEXPECTED);	nsAutoString	htmlResults(uniBuf);	if (htmlResults.Length() < 1)	{#ifdef	DEBUG_SEARCH_OUTPUT		printf(" *** InternetSearchDataSourceCallback::OnStopRequest:  no data.\n\n");#endif		return(NS_OK);	}	if (NS_FAILED(rv = context->Truncate()))	return(rv);	if (mParent)	{		// save HTML result page for this engine		const PRUnichar	*htmlUni = htmlResults.GetUnicode();		if (htmlUni)		{			nsCOMPtr<nsIRDFLiteral>	htmlLiteral;			if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(htmlUni, getter_AddRefs(htmlLiteral))))			{				rv = mInner->Assert(mEngine, kNC_HTML, htmlLiteral, PR_TRUE);			}		}	}	PRUint32	numResults = 0;	rv = ParseHTML(aURL, mParent, mEngine, htmlResults, PR_FALSE, numResults);	if (NS_SUCCEEDED(rv) && (!mParent) && (numResults == 0))	{		rv = ParseHTML(aURL, mParent, mEngine, htmlResults, PR_TRUE, numResults);	}	return(NS_OK);}