nsSaveAsListener::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
nsSaveMsgListener::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
nsSaveAsListener::OnStopRunningUrl(nsIURI* url, nsresult exitCode){  nsresult rv = exitCode;  PRBool killSelf = PR_TRUE;  if (m_fileSpec)  {    m_fileSpec->Flush();    m_fileSpec->CloseStream();    if (NS_FAILED(rv)) goto done;    if (m_templateUri) { // ** save as template goes here        NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);        if (NS_FAILED(rv)) goto done;        nsCOMPtr<nsIRDFResource> res;        rv = rdf->GetResource(m_templateUri, getter_AddRefs(res));        if (NS_FAILED(rv)) goto done;        nsCOMPtr<nsIMsgFolder> templateFolder;        templateFolder = do_QueryInterface(res, &rv);        if (NS_FAILED(rv)) goto done;        NS_WITH_SERVICE(nsIMsgCopyService, copyService, kMsgCopyServiceCID, &rv);        if (NS_FAILED(rv)) goto done;        rv = copyService->CopyFileMessage(m_fileSpec, templateFolder, nsnull,                                          PR_TRUE, this, nsnull);        killSelf = PR_FALSE;    }  }done:  if (NS_FAILED(rv))  {    if (m_fileSpec)    {      nsFileSpec realSpec;      m_fileSpec->GetFileSpec(&realSpec);      realSpec.Delete(PR_FALSE);    }    if (m_messenger)    {        m_messenger->Alert("saveMessageFailed");    }  }  if (killSelf)      Release(); // no more work needs to be done; kill ourself  return rv;}