rv = dstFolderElement->GetResource(getter_AddRefs(dstResource)); if(NS_FAILED(rv)) return rv;  rv = srcFolderElement->GetResource(getter_AddRefs(srcResource)); if(NS_FAILED(rv)) return rv;  srcFolder = do_QueryInterface(srcResource); if(!srcFolder) return NS_ERROR_NO_INTERFACE;  rv =ConvertDOMListToResourceArray(messages, getter_AddRefs(argumentArray)); if(NS_FAILED(rv)) return rv;  nsCOMPtr<nsISupports> srcFolderSupports(do_QueryInterface(srcFolder)); if(srcFolderSupports) argumentArray->InsertElementAt(srcFolderSupports, 0);  rv = NS_NewISupportsArray(getter_AddRefs(folderArray)); if(NS_FAILED(rv)) { return NS_ERROR_OUT_OF_MEMORY; }  folderArray->AppendElement(dstResource);  rv = DoCommand(database, isMove ? (char *)NC_RDF_MOVE : (char *)NC_RDF_COPY, folderArray, argumentArray); return rv;  #else nsresult rv;  if(!srcFolderElement || !dstFolderElement || !messages) return NS_ERROR_NULL_POINTER;  nsCOMPtr<nsIRDFResource> srcResource, dstResource; nsCOMPtr<nsICopyMessageListener> dstFolder; nsCOMPtr<nsIMsgFolder> srcFolder; nsCOMPtr<nsISupportsArray> resourceArray;  rv = dstFolderElement->GetResource(getter_AddRefs(dstResource)); if(NS_FAILED(rv)) return rv;  dstFolder = do_QueryInterface(dstResource); if(!dstFolder) return NS_ERROR_NO_INTERFACE;  rv = srcFolderElement->GetResource(getter_AddRefs(srcResource)); if(NS_FAILED(rv)) return rv;  srcFolder = do_QueryInterface(srcResource); if(!srcFolder) return NS_ERROR_NO_INTERFACE;  rv =ConvertDOMListToResourceArray(messages, getter_AddRefs(resourceArray)); if(NS_FAILED(rv)) return rv;      PRUint32 cnt; rv = resourceArray->Count(&cnt); if (NS_SUCCEEDED(rv) && cnt > 0) { nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(resourceArray->ElementAt(0)); nsCOMPtr<nsIRDFResource> firstMessage(do_QueryInterface(msgSupports)); char *uri; firstMessage->GetValue(&uri); nsCOMPtr<nsICopyMessageStreamListener> copyStreamListener; rv = nsComponentManager::CreateInstance(kCopyMessageStreamListenerCID, NULL, nsCOMTypeInfo<nsICopyMessageStreamListener>::GetIID(), getter_AddRefs(copyStreamListener)); if(NS_FAILED(rv)) return rv;  rv = copyStreamListener->Init(srcFolder, dstFolder, nsnull); if(NS_FAILED(rv)) return rv; nsIMsgMessageService * messageService = nsnull; rv = GetMessageServiceFromURI(uri, &messageService);  if (NS_SUCCEEDED(rv) && messageService) { nsIURI * url = nsnull; nsCOMPtr<nsIStreamListener> streamListener(do_QueryInterface(copyStreamListener)); if(!streamListener) return NS_ERROR_NO_INTERFACE; messageService->CopyMessage(uri, streamListener, isMove, nsnull, &url); ReleaseMessageServiceFromURI(uri, messageService); }  }  return rv; #endif
nsMessenger::CopyMessages(nsIRDFCompositeDataSource *database, nsIDOMXULElement *srcFolderElement,						  nsIDOMXULElement *dstFolderElement, nsIDOMNodeList *messages, PRBool isMove){#if 1	nsresult rv;	if(!srcFolderElement || !dstFolderElement || !messages)		return NS_ERROR_NULL_POINTER;	nsCOMPtr<nsIRDFResource> srcResource, dstResource;	nsCOMPtr<nsIMsgFolder> srcFolder;	nsCOMPtr<nsISupportsArray> argumentArray;	nsCOMPtr<nsISupportsArray> folderArray;	rv = dstFolderElement->GetResource(getter_AddRefs(dstResource));	if(NS_FAILED(rv))		return rv;	rv = srcFolderElement->GetResource(getter_AddRefs(srcResource));	if(NS_FAILED(rv))		return rv;	srcFolder = do_QueryInterface(srcResource);	if(!srcFolder)		return NS_ERROR_NO_INTERFACE;	rv =ConvertDOMListToResourceArray(messages, getter_AddRefs(argumentArray));	if(NS_FAILED(rv))		return rv;	nsCOMPtr<nsISupports> srcFolderSupports(do_QueryInterface(srcFolder));	if(srcFolderSupports)		argumentArray->InsertElementAt(srcFolderSupports, 0);	rv = NS_NewISupportsArray(getter_AddRefs(folderArray));	if(NS_FAILED(rv))	{		return NS_ERROR_OUT_OF_MEMORY;	}	folderArray->AppendElement(dstResource);		rv = DoCommand(database, isMove ? (char *)NC_RDF_MOVE : (char *)NC_RDF_COPY, folderArray, argumentArray);	return rv;#else	nsresult rv;	if(!srcFolderElement || !dstFolderElement || !messages)		return NS_ERROR_NULL_POINTER;	nsCOMPtr<nsIRDFResource> srcResource, dstResource;	nsCOMPtr<nsICopyMessageListener> dstFolder;	nsCOMPtr<nsIMsgFolder> srcFolder;	nsCOMPtr<nsISupportsArray> resourceArray;	rv = dstFolderElement->GetResource(getter_AddRefs(dstResource));	if(NS_FAILED(rv))		return rv;	dstFolder = do_QueryInterface(dstResource);	if(!dstFolder)		return NS_ERROR_NO_INTERFACE;	rv = srcFolderElement->GetResource(getter_AddRefs(srcResource));	if(NS_FAILED(rv))		return rv;	srcFolder = do_QueryInterface(srcResource);	if(!srcFolder)		return NS_ERROR_NO_INTERFACE;	rv =ConvertDOMListToResourceArray(messages, getter_AddRefs(resourceArray));	if(NS_FAILED(rv))		return rv;	//Call the mailbox service to copy first message.  In the future we should call CopyMessages.	//And even more in the future we need to distinguish between the different types of URI's, i.e.	//local, imap, and news, and call the appropriate copy function.	PRUint32 cnt;    rv = resourceArray->Count(&cnt);    if (NS_SUCCEEDED(rv) && cnt > 0)	{		nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(resourceArray->ElementAt(0));		nsCOMPtr<nsIRDFResource> firstMessage(do_QueryInterface(msgSupports));		char *uri;		firstMessage->GetValue(&uri);		nsCOMPtr<nsICopyMessageStreamListener> copyStreamListener; 		rv = nsComponentManager::CreateInstance(kCopyMessageStreamListenerCID, NULL,												nsCOMTypeInfo<nsICopyMessageStreamListener>::GetIID(),												getter_AddRefs(copyStreamListener)); 		if(NS_FAILED(rv))			return rv;		rv = copyStreamListener->Init(srcFolder, dstFolder, nsnull);		if(NS_FAILED(rv))			return rv;		nsIMsgMessageService * messageService = nsnull;		rv = GetMessageServiceFromURI(uri, &messageService);		if (NS_SUCCEEDED(rv) && messageService)		{			nsIURI * url = nsnull;			nsCOMPtr<nsIStreamListener> streamListener(do_QueryInterface(copyStreamListener));			if(!streamListener)				return NS_ERROR_NO_INTERFACE;			messageService->CopyMessage(uri, streamListener, isMove, nsnull, &url);			ReleaseMessageServiceFromURI(uri, messageService);		}	}	return rv;#endif}