NS_IMETHODIMP ImportEudoraMailImpl::ImportMailbox(nsIImportMailboxDescriptor *pSource, nsIMsgFolder *pDstFolder, PRUnichar **pErrorLog, PRUnichar **pSuccessLog, bool *fatalError) { NS_ENSURE_ARG_POINTER(pSource); NS_ENSURE_ARG_POINTER(pDstFolder); NS_ENSURE_ARG_POINTER(fatalError); nsString success; nsString error; bool abort = false; nsString name; PRUnichar * pName; if (NS_SUCCEEDED(pSource->GetDisplayName(&pName))) { name = pName; NS_Free(pName); } PRUint32 mailSize = 0; pSource->GetSize(&mailSize); if (mailSize == 0) { IMPORT_LOG0("Mailbox size is 0, skipping mailbox.\n"); ReportSuccess(name, 0, &success); SetLogs(success, error, pErrorLog, pSuccessLog); return NS_OK; } nsCOMPtr <nsIFile> inFile; if (NS_FAILED(pSource->GetFile(getter_AddRefs(inFile)))) { ReportError(EUDORAIMPORT_MAILBOX_BADSOURCEFILE, name, &error); SetLogs(success, error, pErrorLog, pSuccessLog); return NS_ERROR_FAILURE; } #ifdef IMPORT_DEBUG nsCString pPath; inFile->GetNativePath(pPath); IMPORT_LOG1("Import mailbox: %s\n", pPath.get()); #endif PRInt32 msgCount = 0; nsresult rv = NS_OK; m_bytes = 0; rv = m_eudora.ImportMailbox( &m_bytes, &abort, name.get(), inFile, pDstFolder, &msgCount); if (NS_SUCCEEDED(rv)) ReportSuccess(name, msgCount, &success); else ReportError(EUDORAIMPORT_MAILBOX_CONVERTERROR, name, &error); SetLogs(success, error, pErrorLog, pSuccessLog); IMPORT_LOG0("*** Returning from eudora mailbox import\n"); return rv; }
NS_IMETHODIMP ImportEudoraMailImpl::ImportMailbox(nsIImportMailboxDescriptor *pSource, nsIFile *pDestination, PRUnichar **pErrorLog, PRUnichar **pSuccessLog, bool *fatalError) { NS_PRECONDITION(pSource != nsnull, "null ptr"); NS_PRECONDITION(pDestination != nsnull, "null ptr"); NS_PRECONDITION(fatalError != nsnull, "null ptr"); nsString success; nsString error; if (!pSource || !pDestination || !fatalError) { IMPORT_LOG0( "*** Bad param passed to eudora mailbox import\n"); nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_BADPARAM, error); if (fatalError) *fatalError = true; SetLogs( success, error, pErrorLog, pSuccessLog); return NS_ERROR_NULL_POINTER; } bool abort = false; nsString name; PRUnichar * pName; if (NS_SUCCEEDED( pSource->GetDisplayName( &pName))) { name = pName; NS_Free( pName); } PRUint32 mailSize = 0; pSource->GetSize( &mailSize); if (mailSize == 0) { IMPORT_LOG0( "Mailbox size is 0, skipping mailbox.\n"); ReportSuccess( name, 0, &success); SetLogs( success, error, pErrorLog, pSuccessLog); return( NS_OK); } nsCOMPtr <nsILocalFile> inFile; if (NS_FAILED(pSource->GetFile( getter_AddRefs(inFile)))) { ReportError( EUDORAIMPORT_MAILBOX_BADSOURCEFILE, name, &error); SetLogs( success, error, pErrorLog, pSuccessLog); return( NS_ERROR_FAILURE); } #ifdef IMPORT_DEBUG nsCString pPath; inFile->GetNativePath(pPath); IMPORT_LOG1( "Import mailbox: %s\n", pPath.get()); #endif PRInt32 msgCount = 0; nsresult rv = NS_OK; m_bytes = 0; rv = m_eudora.ImportMailbox( &m_bytes, &abort, name.get(), inFile, pDestination, &msgCount); if (NS_SUCCEEDED( rv)) ReportSuccess( name, msgCount, &success); else ReportError( EUDORAIMPORT_MAILBOX_CONVERTERROR, name, &error); SetLogs( success, error, pErrorLog, pSuccessLog); IMPORT_LOG0( "*** Returning from eudora mailbox import\n"); return( rv); }