diff --git a/mailnews/import/eudora/src/nsEudoraImport.cpp b/mailnews/import/eudora/src/nsEudoraImport.cpp index a4dee5388989..bf27106ae978 100644 --- a/mailnews/import/eudora/src/nsEudoraImport.cpp +++ b/mailnews/import/eudora/src/nsEudoraImport.cpp @@ -73,7 +73,7 @@ #include "nsIStringBundle.h" #include "nsEudoraSettings.h" #include "nsReadableUtils.h" - +#include "nsUnicharUtils.h" #if defined(XP_WIN) || defined(XP_OS2) #include "nsEudoraWin32.h" @@ -561,6 +561,11 @@ NS_IMETHODIMP ImportEudoraMailImpl::GetImportProgress( PRUint32 *pDoneSoFar) NS_IMETHODIMP ImportEudoraMailImpl::TranslateFolderName(const nsAString & aFolderName, nsAString & _retval) { + if (aFolderName.Equals(NS_LITERAL_STRING("Out"), nsCaseInsensitiveStringComparator())) + _retval = NS_LITERAL_STRING(kDestUnsentMessagesFolderName); + else if (aFolderName.Equals(NS_LITERAL_STRING("In"), nsCaseInsensitiveStringComparator())) + _retval = NS_LITERAL_STRING(kDestInboxFolderName); + else _retval = aFolderName; return NS_OK; } diff --git a/mailnews/import/eudora/src/nsEudoraSettings.cpp b/mailnews/import/eudora/src/nsEudoraSettings.cpp index 143f204e437f..fa92dbd27c66 100644 --- a/mailnews/import/eudora/src/nsEudoraSettings.cpp +++ b/mailnews/import/eudora/src/nsEudoraSettings.cpp @@ -73,12 +73,10 @@ nsresult nsEudoraSettings::Create(nsIImportSettings** aImport) nsEudoraSettings::nsEudoraSettings() { - m_pLocation = nsnull; } nsEudoraSettings::~nsEudoraSettings() { - NS_IF_RELEASE( m_pLocation); } NS_IMPL_ISUPPORTS1(nsEudoraSettings, nsIImportSettings) @@ -93,29 +91,24 @@ NS_IMETHODIMP nsEudoraSettings::AutoLocate(PRUnichar **description, nsIFileSpec *description = nsnull; *_retval = PR_FALSE; - *location = nsnull; nsresult rv; - if (NS_FAILED( rv = NS_NewFileSpec( location))) - return( rv); + + if (NS_FAILED( rv = NS_NewFileSpec( getter_AddRefs(m_pLocation)))) + return rv; *description = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME); #if defined(XP_WIN) || defined(XP_OS2) - *_retval = nsEudoraWin32::FindSettingsFile( *location); + *_retval = nsEudoraWin32::FindSettingsFile( m_pLocation ); #endif - m_pLocation = *location; - NS_IF_ADDREF( m_pLocation); - - return( NS_OK); + NS_IF_ADDREF(*location = m_pLocation); + return NS_OK; } NS_IMETHODIMP nsEudoraSettings::SetLocation(nsIFileSpec *location) { - NS_IF_RELEASE( m_pLocation); m_pLocation = location; - NS_IF_ADDREF( m_pLocation); - return( NS_OK); } @@ -129,17 +122,15 @@ NS_IMETHODIMP nsEudoraSettings::Import(nsIMsgAccount **localMailAccount, PRBool // Get the settings file if it doesn't exist if (!m_pLocation) { #if defined(XP_WIN) || defined(XP_OS2) - if (NS_SUCCEEDED( rv = NS_NewFileSpec( &m_pLocation))) { + if (NS_SUCCEEDED( rv = NS_NewFileSpec( getter_AddRefs(m_pLocation)))) { if (!nsEudoraWin32::FindSettingsFile( m_pLocation)) { - NS_IF_RELEASE( m_pLocation); m_pLocation = nsnull; } } #endif #if defined(XP_MAC) || defined(XP_MACOSX) - if (NS_SUCCEEDED( rv = NS_NewFileSpec( &m_pLocation))) { + if (NS_SUCCEEDED( rv = NS_NewFileSpec( getter_AddRefs(m_pLocation)))) { if (!nsEudoraMac::FindSettingsFile( m_pLocation)) { - NS_IF_RELEASE( m_pLocation); m_pLocation = nsnull; } } diff --git a/mailnews/import/eudora/src/nsEudoraSettings.h b/mailnews/import/eudora/src/nsEudoraSettings.h index 98ff69f3a3cf..36bd6b39a8d2 100644 --- a/mailnews/import/eudora/src/nsEudoraSettings.h +++ b/mailnews/import/eudora/src/nsEudoraSettings.h @@ -41,6 +41,7 @@ #include "nsIImportSettings.h" #include "nsIFileSpec.h" +#include "nsCOMPtr.h" class nsEudoraSettings : public nsIImportSettings { public: @@ -56,7 +57,7 @@ public: NS_DECL_NSIIMPORTSETTINGS private: - nsIFileSpec * m_pLocation; + nsCOMPtr m_pLocation; }; #endif /* nsEudoraSettings_h___ */ diff --git a/mailnews/import/eudora/src/nsEudoraWin32.cpp b/mailnews/import/eudora/src/nsEudoraWin32.cpp index 773eb829c29c..5c0daa413b5d 100644 --- a/mailnews/import/eudora/src/nsEudoraWin32.cpp +++ b/mailnews/import/eudora/src/nsEudoraWin32.cpp @@ -106,6 +106,7 @@ PRBool nsEudoraWin32::FindMailFolder( nsIFileSpec *pFolder) PRBool nsEudoraWin32::FindEudoraLocation( nsIFileSpec *pFolder, PRBool findIni) { PRBool result = PR_FALSE; + PRBool exists = PR_FALSE; // look in the registry to see where eudora is installed? HKEY sKey; @@ -116,7 +117,30 @@ PRBool nsEudoraWin32::FindEudoraLocation( nsIFileSpec *pFolder, PRBool findIni) nsCString str((const char *)pBytes); delete [] pBytes; + str.CompressWhitespace(); + // Command line is Eudora mailfolder eudora.ini + if (findIni) { + // find the string coming after the last space + PRInt32 index = str.RFind(" "); + if (index != -1) { + index++; // skip the space + nsCString path; + str.Mid( path, index, str.Length() - index); + + pFolder->SetNativePath( path.get()); + pFolder->IsFile( &exists); + if (exists) + result = exists; + else // it may just be the mailbox location....guess that there will be a eudora.ini file there + { + pFolder->AppendRelativeUnixPath("eudora.ini"); + pFolder->IsFile( &exists); + result = exists; + } + } + } // if findIni + else { int idx = -1; if (str.CharAt( 0) == '"') { idx = str.FindChar( '"', 1); @@ -127,19 +151,6 @@ PRBool nsEudoraWin32::FindEudoraLocation( nsIFileSpec *pFolder, PRBool findIni) idx = str.FindChar( ' '); } - if ((idx != -1) && findIni) { - idx++; - while (str.CharAt( idx) == ' ') idx++; - int eIdx = -1; - if (str.CharAt( idx) == '"') { - eIdx = str.FindChar( '"', idx); - } - else { - eIdx = str.FindChar( ' ', idx); - } - idx = eIdx; - } - if (idx != -1) { idx++; while (str.CharAt( idx) == ' ') idx++; @@ -154,32 +165,14 @@ PRBool nsEudoraWin32::FindEudoraLocation( nsIFileSpec *pFolder, PRBool findIni) nsCString path; str.Mid( path, idx, endIdx - idx); - /* - For some reason, long long ago, it was necessary - to clean up the path to Eudora so that it didn't contain - a mix of short file names and long file names. This is - no longer true. - - ConvertPath( path); - - IMPORT_LOG1( "** GetShortPath returned: %s\n", path.get()); - */ - pFolder->SetNativePath( path.get()); - PRBool exists = PR_FALSE; - if (findIni) { - if (NS_SUCCEEDED( pFolder->IsFile( &exists))) { - result = exists; - } - } - else { - if (NS_SUCCEEDED( pFolder->IsDirectory( &exists))) { + + if (NS_SUCCEEDED( pFolder->IsDirectory( &exists))) result = exists; } } } - } - } + } // if pBytes ::RegCloseKey( sKey); } diff --git a/mailnews/import/public/nsIImportMail.idl b/mailnews/import/public/nsIImportMail.idl index 475814dbc24f..44cb870e5afc 100644 --- a/mailnews/import/public/nsIImportMail.idl +++ b/mailnews/import/public/nsIImportMail.idl @@ -126,4 +126,5 @@ interface nsIImportMail : nsISupports #define kDestTrashFolderName "Trash" #define kDestUnsentMessagesFolderName "Unsent Messages" #define kDestSentFolderName "Sent" +#define kDestInboxFolderName "Inbox" %}