nsCOMPtr<nsISupportsArray>  cmdArray; nsresult            rv; rv = NS_NewISupportsArray(getter_AddRefs(cmdArray)); if (NS_FAILED(rv))  return rv;
nsCOMPtr<nsISupportsArray>	cmdArray; nsresult			rv; rv = NS_NewISupportsArray(getter_AddRefs(cmdArray)); if (NS_FAILED(rv))	return(rv);
nsBookmarksService::GetAllCmds(nsIRDFResource* source,                   nsISimpleEnumerator/*<nsIRDFResource>*/** commands){    nsCOMPtr<nsISupportsArray>  cmdArray;    nsresult            rv;    rv = NS_NewISupportsArray(getter_AddRefs(cmdArray));    if (NS_FAILED(rv))  return rv;    // determine type    nsCOMPtr<nsIRDFNode> nodeType;    GetSynthesizedType(source, getter_AddRefs(nodeType));    PRBool  isBookmark, isBookmarkFolder, isBookmarkSeparator;    isBookmark = (nodeType == kNC_Bookmark) ? PR_TRUE : PR_FALSE;    isBookmarkFolder = (nodeType == kNC_Folder) ? PR_TRUE : PR_FALSE;    isBookmarkSeparator = (nodeType == kNC_BookmarkSeparator) ? PR_TRUE : PR_FALSE;    if (isBookmark || isBookmarkFolder || isBookmarkSeparator)    {        cmdArray->AppendElement(kNC_BookmarkCommand_NewBookmark);        cmdArray->AppendElement(kNC_BookmarkCommand_NewFolder);        cmdArray->AppendElement(kNC_BookmarkCommand_NewSeparator);        cmdArray->AppendElement(kNC_BookmarkSeparator);    }    if (isBookmark)    {        cmdArray->AppendElement(kNC_BookmarkCommand_DeleteBookmark);    }    if (isBookmarkFolder && (source != kNC_BookmarksRoot) && (source != kNC_IEFavoritesRoot))    {        cmdArray->AppendElement(kNC_BookmarkCommand_DeleteBookmarkFolder);    }    if (isBookmarkSeparator)    {        cmdArray->AppendElement(kNC_BookmarkCommand_DeleteBookmarkSeparator);    }    if (isBookmarkFolder)    {        nsCOMPtr<nsIRDFResource>    newBookmarkFolder, personalToolbarFolder, newSearchFolder;        getFolderViaHint(kNC_NewBookmarkFolder, PR_FALSE, getter_AddRefs(newBookmarkFolder));        getFolderViaHint(kNC_PersonalToolbarFolder, PR_FALSE, getter_AddRefs(personalToolbarFolder));        getFolderViaHint(kNC_NewSearchFolder, PR_FALSE, getter_AddRefs(newSearchFolder));        cmdArray->AppendElement(kNC_BookmarkSeparator);        if (source != newBookmarkFolder.get())      cmdArray->AppendElement(kNC_BookmarkCommand_SetNewBookmarkFolder);        if (source != newSearchFolder.get())        cmdArray->AppendElement(kNC_BookmarkCommand_SetNewSearchFolder);        if (source != personalToolbarFolder.get())  cmdArray->AppendElement(kNC_BookmarkCommand_SetPersonalToolbarFolder);    }    // always append a separator last (due to aggregation of commands from multiple datasources)    cmdArray->AppendElement(kNC_BookmarkSeparator);    nsISimpleEnumerator     *result = new nsArrayEnumerator(cmdArray);    if (!result)        return NS_ERROR_OUT_OF_MEMORY;    NS_ADDREF(result);    *commands = result;    return NS_OK;}