if (src == kNC_BookmarksRoot) { argParent = src; } else { nsCOMPtr<nsIRDFNode>	aNode; if (NS_FAILED(rv = getArgumentN(aArguments, kNC_Parent, parentArgIndex, getter_AddRefs(aNode)))) return(rv); argParent = do_QueryInterface(aNode); if (!argParent)	return(NS_ERROR_NO_INTERFACE); } nsCOMPtr<nsIRDFContainer>	container; if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContainerCID, nsnull, NS_GET_IID(nsIRDFContainer), getter_AddRefs(container)))) return(rv); if (NS_FAILED(rv = container->Init(mInner, argParent))) return(rv);
if (aRelativeNode == kNC_BookmarksRoot) rParent = aRelativeNode; else { nsCOMPtr<nsIRDFNode> parentNode; rv = getArgumentN(aArguments, kNC_Parent, kParentArgumentIndex, getter_AddRefs(parentNode)); if (NS_FAILED(rv)) return rv; rParent = do_QueryInterface(parentNode, &rv); if (NS_FAILED(rv)) return rv; }
nsBookmarksService::insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex, nsIRDFResource *objType){	nsresult			rv;	PRInt32				srcIndex = 0;	nsCOMPtr<nsIRDFResource>	argParent;	if (src == kNC_BookmarksRoot)	{		argParent = src;	}	else	{		nsCOMPtr<nsIRDFNode>	aNode;		if (NS_FAILED(rv = getArgumentN(aArguments, kNC_Parent,				parentArgIndex, getter_AddRefs(aNode))))			return(rv);		argParent = do_QueryInterface(aNode);		if (!argParent)	return(NS_ERROR_NO_INTERFACE);	}	nsCOMPtr<nsIRDFContainer>	container;	if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContainerCID, nsnull,			NS_GET_IID(nsIRDFContainer), getter_AddRefs(container))))		return(rv);	if (NS_FAILED(rv = container->Init(mInner, argParent)))		return(rv);	if (src != kNC_BookmarksRoot)	{		if (NS_FAILED(rv = container->IndexOf(src, &srcIndex)))			return(rv);	}	nsAutoString			newName;	if ((objType == kNC_Bookmark) || (objType == kNC_Folder))	{		nsCOMPtr<nsIRDFNode>	nameNode;		if (NS_SUCCEEDED(rv = getArgumentN(aArguments, kNC_Name, parentArgIndex, getter_AddRefs(nameNode))))		{			nsCOMPtr<nsIRDFLiteral>	nameLiteral = do_QueryInterface(nameNode);			if (nameLiteral)			{				const	PRUnichar	*nameUni = nsnull;				nameLiteral->GetValueConst(&nameUni);				if (nameUni)				{					newName = nameUni;				}			}		}	}	if (newName.Length() == 0)	{		// get a default name		if (objType == kNC_Bookmark)	getLocaleString("NewBookmark", newName);		else if (objType == kNC_Folder)	getLocaleString("NewFolder", newName);	}	nsCOMPtr<nsIRDFResource>	newElement;	if (objType == kNC_Bookmark)	{		nsCOMPtr<nsIRDFNode>	bookmarkNode;		if (NS_SUCCEEDED(rv = getArgumentN(aArguments, kNC_URL, parentArgIndex, getter_AddRefs(bookmarkNode))))		{			nsCOMPtr<nsIRDFLiteral>	bookmarkURLLiteral = do_QueryInterface(bookmarkNode);			if (!bookmarkURLLiteral)	return(NS_ERROR_NO_INTERFACE);			const	PRUnichar	*urlUni = nsnull;			bookmarkURLLiteral->GetValueConst(&urlUni);			if (urlUni)			{				rv = gRDF->GetUnicodeResource(urlUni, getter_AddRefs(newElement));				if (NS_FAILED(rv))	return(rv);			}		}	}	if (!newElement)	{		if (NS_FAILED(rv = BookmarkParser::CreateAnonymousResource(&newElement)))			return(rv);	}	if (objType == kNC_Folder)	{		if (NS_FAILED(rv = gRDFC->MakeSeq(mInner, newElement, nsnull)))			return(rv);	}	if (newName.Length() > 0)	{		nsCOMPtr<nsIRDFLiteral>	nameLiteral;		if (NS_FAILED(rv = gRDF->GetLiteral(newName.GetUnicode(), getter_AddRefs(nameLiteral))))			return(rv);		if (NS_FAILED(rv = mInner->Assert(newElement, kNC_Name, nameLiteral, PR_TRUE)))			return(rv);	}	if (NS_FAILED(rv = mInner->Assert(newElement, kRDF_type, objType, PR_TRUE)))		return(rv);	// convert the current date/time from microseconds (PRTime) to seconds	nsCOMPtr<nsIRDFDate>	dateLiteral;	if (NS_FAILED(rv = gRDF->GetDateLiteral(PR_Now(), getter_AddRefs(dateLiteral))))		return(rv);	if (NS_FAILED(rv = mInner->Assert(newElement, kNC_BookmarkAddDate, dateLiteral, PR_TRUE)))		return(rv);	if (NS_FAILED(rv = container->InsertElementAt(newElement, ((srcIndex == 0) ? 1 : srcIndex), PR_TRUE)))		return(rv);	return(rv);}