if (schedule.Find(nsAutoString("icon"), PR_TRUE, 0) >= 0) {
if (schedule.Find(NS_ConvertASCIItoUCS2("icon"), PR_TRUE, 0) >= 0) { nsAutoString		statusStr; statusStr.AssignWithConversion("new");
nsBookmarksService::OnStopRequest(nsIChannel* channel, nsISupports *ctxt,					nsresult status, const PRUnichar *errorMsg) {	nsresult		rv;	const char		*uri = nsnull;	if (NS_SUCCEEDED(rv = busyResource->GetValueConst(&uri)) && (uri))	{#ifdef	DEBUG_BOOKMARK_PING_OUTPUT		printf("Finished polling '%s'\n", uri);#endif	}	nsCOMPtr<nsIHTTPChannel>	httpChannel = do_QueryInterface(channel);	if (httpChannel)	{		nsAutoString			eTagValue, lastModValue, contentLengthValue;		nsCOMPtr<nsISimpleEnumerator>	enumerator;		if (NS_SUCCEEDED(rv = httpChannel->GetResponseHeaderEnumerator(getter_AddRefs(enumerator))))		{			PRBool			bMoreHeaders;			while (NS_SUCCEEDED(rv = enumerator->HasMoreElements(&bMoreHeaders))				&& (bMoreHeaders == PR_TRUE))			{				nsCOMPtr<nsISupports>   item;				enumerator->GetNext(getter_AddRefs(item));				nsCOMPtr<nsIHTTPHeader>	header = do_QueryInterface(item);				NS_ASSERTION(header, "nsBookmarksService::OnStopRequest - Bad HTTP header.");				if (header)				{					nsCOMPtr<nsIAtom>       headerAtom;					header->GetField(getter_AddRefs(headerAtom));					nsAutoString		headerStr;					headerAtom->ToString(headerStr);					char	*val = nsnull;										if (headerStr.EqualsIgnoreCase("eTag"))					{						header->GetValue(&val);						if (val)						{							eTagValue = val;							nsCRT::free(val);						}					}					else if (headerStr.EqualsIgnoreCase("Last-Modified"))					{						header->GetValue(&val);						if (val)						{							lastModValue = val;							nsCRT::free(val);						}					}					else if (headerStr.EqualsIgnoreCase("Content-Length"))					{						header->GetValue(&val);						if (val)						{							contentLengthValue = val;							nsCRT::free(val);						}					}				}			}		}		PRBool		changedFlag = PR_FALSE;		PRUint32	respStatus;		if (NS_SUCCEEDED(rv = httpChannel->GetResponseStatus(&respStatus)))		{			if ((respStatus >= 200) && (respStatus <= 299))			{				if (eTagValue.Length() > 0)				{#ifdef	DEBUG_BOOKMARK_PING_OUTPUT					const char *eTagVal = nsCAutoString(eTagValue);					printf("eTag: '%s'\n", eTagVal);#endif					nsCOMPtr<nsIRDFNode>	currentETagNode;					if (NS_SUCCEEDED(rv = mInner->GetTarget(busyResource, kWEB_LastPingETag,						PR_TRUE, getter_AddRefs(currentETagNode))) && (rv != NS_RDF_NO_VALUE))					{						nsCOMPtr<nsIRDFLiteral>	currentETagLit = do_QueryInterface(currentETagNode);						if (currentETagLit)						{							const PRUnichar	*currentETagStr = nsnull;							currentETagLit->GetValueConst(&currentETagStr);							if ((currentETagStr) && (!eTagValue.EqualsIgnoreCase(currentETagStr)))							{								changedFlag = PR_TRUE;							}							nsCOMPtr<nsIRDFLiteral>	newETagLiteral;							if (NS_SUCCEEDED(rv = gRDF->GetLiteral(eTagValue.GetUnicode(),								getter_AddRefs(newETagLiteral))))							{								rv = mInner->Change(busyResource, kWEB_LastPingETag,									currentETagNode, newETagLiteral);							}						}					}					else					{						nsCOMPtr<nsIRDFLiteral>	newETagLiteral;						if (NS_SUCCEEDED(rv = gRDF->GetLiteral(eTagValue.GetUnicode(),							getter_AddRefs(newETagLiteral))))						{							rv = mInner->Assert(busyResource, kWEB_LastPingETag,								newETagLiteral, PR_TRUE);						}					}				}			}		}		if ((changedFlag == PR_FALSE) && (lastModValue.Length() > 0))		{#ifdef	DEBUG_BOOKMARK_PING_OUTPUT			const char *lastModVal = nsCAutoString(lastModValue);			printf("Last-Modified: '%s'\n", lastModVal);#endif			nsCOMPtr<nsIRDFNode>	currentLastModNode;			if (NS_SUCCEEDED(rv = mInner->GetTarget(busyResource, kWEB_LastPingModDate,				PR_TRUE, getter_AddRefs(currentLastModNode))) && (rv != NS_RDF_NO_VALUE))			{				nsCOMPtr<nsIRDFLiteral>	currentLastModLit = do_QueryInterface(currentLastModNode);				if (currentLastModLit)				{					const PRUnichar	*currentLastModStr = nsnull;					currentLastModLit->GetValueConst(&currentLastModStr);					if ((currentLastModStr) && (!lastModValue.EqualsIgnoreCase(currentLastModStr)))					{						changedFlag = PR_TRUE;					}					nsCOMPtr<nsIRDFLiteral>	newLastModLiteral;					if (NS_SUCCEEDED(rv = gRDF->GetLiteral(lastModValue.GetUnicode(),						getter_AddRefs(newLastModLiteral))))					{						rv = mInner->Change(busyResource, kWEB_LastPingModDate,							currentLastModNode, newLastModLiteral);					}				}			}			else			{				nsCOMPtr<nsIRDFLiteral>	newLastModLiteral;				if (NS_SUCCEEDED(rv = gRDF->GetLiteral(lastModValue.GetUnicode(),					getter_AddRefs(newLastModLiteral))))				{					rv = mInner->Assert(busyResource, kWEB_LastPingModDate,						newLastModLiteral, PR_TRUE);				}			}		}		if ((changedFlag == PR_FALSE) && (contentLengthValue.Length() > 0))		{#ifdef	DEBUG_BOOKMARK_PING_OUTPUT			const char *contentLengthVal = nsCAutoString(contentLengthValue);			printf("Content-Length: '%s'\n", contentLengthVal);#endif			nsCOMPtr<nsIRDFNode>	currentContentLengthNode;			if (NS_SUCCEEDED(rv = mInner->GetTarget(busyResource, kWEB_LastPingContentLen,				PR_TRUE, getter_AddRefs(currentContentLengthNode))) && (rv != NS_RDF_NO_VALUE))			{				nsCOMPtr<nsIRDFLiteral>	currentContentLengthLit = do_QueryInterface(currentContentLengthNode);				if (currentContentLengthLit)				{					const PRUnichar	*currentContentLengthStr = nsnull;					currentContentLengthLit->GetValueConst(&currentContentLengthStr);					if ((currentContentLengthStr) && (!contentLengthValue.EqualsIgnoreCase(currentContentLengthStr)))					{						changedFlag = PR_TRUE;					}					nsCOMPtr<nsIRDFLiteral>	newContentLengthLiteral;					if (NS_SUCCEEDED(rv = gRDF->GetLiteral(contentLengthValue.GetUnicode(),						getter_AddRefs(newContentLengthLiteral))))					{						rv = mInner->Change(busyResource, kWEB_LastPingContentLen,							currentContentLengthNode, newContentLengthLiteral);					}				}			}			else			{				nsCOMPtr<nsIRDFLiteral>	newContentLengthLiteral;				if (NS_SUCCEEDED(rv = gRDF->GetLiteral(contentLengthValue.GetUnicode(),					getter_AddRefs(newContentLengthLiteral))))				{					rv = mInner->Assert(busyResource, kWEB_LastPingContentLen,						newContentLengthLiteral, PR_TRUE);				}			}		}		// update last poll date		nsCOMPtr<nsIRDFDate>	dateLiteral;		if (NS_SUCCEEDED(rv = gRDF->GetDateLiteral(PR_Now(), getter_AddRefs(dateLiteral))))		{			nsCOMPtr<nsIRDFNode>	lastPingNode;			if (NS_SUCCEEDED(rv = mInner->GetTarget(busyResource, kWEB_LastPingDate, PR_TRUE,				getter_AddRefs(lastPingNode))) && (rv != NS_RDF_NO_VALUE))			{				rv = mInner->Change(busyResource, kWEB_LastPingDate, lastPingNode, dateLiteral);			}			else			{				rv = mInner->Assert(busyResource, kWEB_LastPingDate, dateLiteral, PR_TRUE);			}			NS_ASSERTION(rv == NS_RDF_ASSERTION_ACCEPTED, "unable to assert new time");			mDirty = PR_TRUE;		}		else		{			NS_ERROR("unable to get date literal for now");		}		// If its changed, set the appropriate info		if (changedFlag == PR_TRUE)		{#ifdef	DEBUG_BOOKMARK_PING_OUTPUT			printf("URL has changed!\n\n");#endif			nsAutoString		schedule;			nsCOMPtr<nsIRDFNode>	scheduleNode;			if (NS_SUCCEEDED(rv = mInner->GetTarget(busyResource, kWEB_Schedule, PR_TRUE,				getter_AddRefs(scheduleNode))) && (rv != NS_RDF_NO_VALUE))			{				nsCOMPtr<nsIRDFLiteral>	scheduleLiteral = do_QueryInterface(scheduleNode);				if (scheduleLiteral)				{					const PRUnichar		*scheduleUni = nsnull;					if (NS_SUCCEEDED(rv = scheduleLiteral->GetValueConst(&scheduleUni))						&& (scheduleUni))					{						schedule = scheduleUni;					}				}			}			// update icon?			if (schedule.Find(nsAutoString("icon"), PR_TRUE, 0) >= 0)			{				nsCOMPtr<nsIRDFLiteral>	statusLiteral;				if (NS_SUCCEEDED(rv = gRDF->GetLiteral(nsAutoString("new").GetUnicode(), getter_AddRefs(statusLiteral))))				{					nsCOMPtr<nsIRDFNode>	currentStatusNode;					if (NS_SUCCEEDED(rv = mInner->GetTarget(busyResource, kWEB_Status, PR_TRUE,						getter_AddRefs(currentStatusNode))) && (rv != NS_RDF_NO_VALUE))					{						rv = mInner->Change(busyResource, kWEB_Status, currentStatusNode, statusLiteral);					}					else					{						rv = mInner->Assert(busyResource, kWEB_Status, statusLiteral, PR_TRUE);					}					NS_ASSERTION(rv == NS_RDF_ASSERTION_ACCEPTED, "unable to assert changed status");				}			}						// play a sound?			if (schedule.Find(nsAutoString("sound"), PR_TRUE, 0) >= 0)			{/*				nsCOMPtr<nsISound>	soundInterface;				rv = nsComponentManager::CreateInstance(kSoundCID,						nsnull, NS_GET_IID(nsISound),						getter_AddRefs(soundInterface));				if (NS_SUCCEEDED(rv))				{					// XXX for the moment, just beep					soundInterface->Beep();				}*/			}						PRBool		openURLFlag = PR_FALSE;			// show an alert?			if (schedule.Find(nsAutoString("alert"), PR_TRUE, 0) >= 0)			{				NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);				if (NS_SUCCEEDED(rv))				{					nsAutoString	promptStr;					getLocaleString("WebPageUpdated", promptStr);					if (promptStr.Length() > 0)	promptStr += "\n\n";					nsCOMPtr<nsIRDFNode>	nameNode;					if (NS_SUCCEEDED(mInner->GetTarget(busyResource, kNC_Name,						PR_TRUE, getter_AddRefs(nameNode))))					{						nsCOMPtr<nsIRDFLiteral>	nameLiteral = do_QueryInterface(nameNode);						if (nameLiteral)						{							const PRUnichar	*nameUni = nsnull;							if (NS_SUCCEEDED(rv = nameLiteral->GetValueConst(&nameUni))								&& (nameUni))							{								nsAutoString	info;								getLocaleString("WebPageTitle", info);								promptStr += info;								promptStr += " ";								promptStr += nameUni;								promptStr += "\n";								getLocaleString("WebPageURL", info);								promptStr += info;								promptStr += " ";							}						}					}					promptStr += uri;										nsAutoString	temp;					getLocaleString("WebPageAskDisplay", temp);					if (temp.Length() > 0)					{						promptStr += "\n\n";						promptStr += temp;					}					nsAutoString	stopOption;					getLocaleString("WebPageAskStopOption", stopOption);					PRBool		stopCheckingFlag = PR_FALSE;					rv = dialog->ConfirmCheck(promptStr.GetUnicode(), stopOption.GetUnicode(),						&stopCheckingFlag, &openURLFlag);					if (NS_FAILED(rv))					{						openURLFlag = PR_FALSE;						stopCheckingFlag = PR_FALSE;					}					if (stopCheckingFlag == PR_TRUE)					{#ifdef	DEBUG_BOOKMARK_PING_OUTPUT						printf("\nStop checking this URL.\n");#endif						rv = mInner->Unassert(busyResource, kWEB_Schedule, scheduleNode);						NS_ASSERTION(NS_SUCCEEDED(rv), "unable to unassert kWEB_Schedule");					}				}			}						// open the URL in a new window?			if ((openURLFlag == PR_TRUE) ||				(schedule.Find(nsAutoString("open"), PR_TRUE, 0) >= 0))			{				NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);				if (NS_SUCCEEDED(rv))				{					// get a parent window for the new browser window					nsCOMPtr<nsIWebShellWindow>	parent;					appShell->GetHiddenWindow(getter_AddRefs(parent));					// convert it to a DOMWindow					nsCOMPtr<nsIWebShell>	webshell;					if (parent)					{						parent->GetWebShell(*getter_AddRefs(webshell));					}					nsCOMPtr<nsIDOMWindow>	domParent;					if (webshell)					{						parent->ConvertWebShellToDOMWindow(webshell, getter_AddRefs(domParent));					}					nsCOMPtr<nsIScriptGlobalObject>	sgo;					if (domParent)					{						// extract its JS context and create JS-flavor arguments						sgo = do_QueryInterface(domParent);					}					nsCOMPtr<nsIScriptContext>	context;					if (sgo)					{						sgo->GetContext(getter_AddRefs(context));					}					if (context)					{						JSContext *jsContext = (JSContext*)context->GetNativeContext();						if (jsContext)						{							void	*stackPtr;							jsval	*argv = JS_PushArguments(jsContext, &stackPtr, "s", uri);							if (argv)							{					                        // open the window					                        nsIDOMWindow	*newWindow;					                        domParent->Open(jsContext, argv, 1, &newWindow);					                        JS_PopArguments(jsContext, stackPtr);							}						}					}				}			}		}#ifdef	DEBUG_BOOKMARK_PING_OUTPUT		else		{			printf("URL has not changed status.\n\n");		}#endif	}	busyResource = null_nsCOMPtr();	busySchedule = PR_FALSE;	return(NS_OK);}