AssertTime(bookmark, kNC_BookmarkAddDate, aAddDate); AssertTime(bookmark, kWEB_LastVisitDate, aLastVisitDate); AssertTime(bookmark, kWEB_LastModifiedDate, aLastModifiedDate);  if ((nsnull != aCharset) && (*aCharset != PRUnichar('\0'))) { nsCOMPtr<nsIRDFLiteral> charsetliteral; if (NS_FAILED(rv = gRDF->GetLiteral(aCharset, getter_AddRefs(charsetliteral)))) { NS_ERROR("unable to create literal for bookmark document charset"); } if (NS_SUCCEEDED(rv)) { rv = mDataSource->Assert(bookmark, kWEB_LastCharset, charsetliteral, PR_TRUE); if (rv != NS_RDF_ASSERTION_ACCEPTED) { NS_ERROR("unable to set bookmark document charset"); } } }  if ((nsnull != aShortcutURL) && (*aShortcutURL != '\0')) { nsCOMPtr<nsIRDFLiteral> shortcutLiteral; if (NS_FAILED(rv = gRDF->GetLiteral(NS_ConvertASCIItoUCS2(aShortcutURL).GetUnicode(), getter_AddRefs(shortcutLiteral)))) { NS_ERROR("unable to get literal for bookmark shortcut URL"); } if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE)) { rv = mDataSource->Assert(bookmark, kNC_ShortcutURL, shortcutLiteral, PR_TRUE);  if (rv != NS_RDF_ASSERTION_ACCEPTED) { NS_ERROR("unable to set bookmark shortcut URL"); } } }   rv = aContainer->AppendElement(bookmark); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add bookmark to container"); return(rv);
nsBookmarksService::AddBookmark(const char *aURI,                                const PRUnichar *aOptionalTitle,                                 PRInt32 bmType,                                const PRUnichar *aCharset){	// XXX Constructing a parser object to do this is bad.	// We need to factor AddBookmark() into its own little	// routine or something.  nsresult rv;	BookmarkParser parser;	parser.Init(nsnull, mInner, mPersonalToolbarName);	nsCOMPtr<nsIRDFContainer> container;	rv = nsComponentManager::CreateInstance(kRDFContainerCID,						nsnull,						NS_GET_IID(nsIRDFContainer),						getter_AddRefs(container));	if (NS_FAILED(rv)) return rv;	// figure out where to add the new bookmark	nsCOMPtr<nsIRDFResource>	bookmarkType = kNC_NewBookmarkFolder;	switch(bmType)	{		case	BOOKMARK_SEARCH_TYPE:		case	BOOKMARK_FIND_TYPE:		bookmarkType = kNC_NewSearchFolder;		break;	}	nsCOMPtr<nsIRDFResource>	newBookmarkFolder;	if (NS_FAILED(rv = getFolderViaHint(bookmarkType, PR_TRUE,			getter_AddRefs(newBookmarkFolder))))		return(rv);	rv = container->Init(mInner, newBookmarkFolder);	if (NS_FAILED(rv)) return(rv);	// convert the current date/time from microseconds (PRTime) to seconds	PRTime		now64 = PR_Now(), million;	LL_I2L(million, PR_USEC_PER_SEC);	LL_DIV(now64, now64, million);	PRInt32		now32;	LL_L2I(now32, now64);	rv = parser.AddBookmark(container, aURI, aOptionalTitle, now32,				0L, 0L, nsnull, kNC_Bookmark, nsnull, aCharset);	if (NS_FAILED(rv)) return(rv);	mDirty = PR_TRUE;	Flush();  return(NS_OK);}