Bug 537872 - Import Eudora mail code isn't 64-bit compatible; Patch by Ben Frisch, complete by Makoto Kato r=Standard8
authorBen Frisch <bfrisch@gmail.com>
Sat, 26 Mar 2011 16:50:47 +0000
changeset 7442 c2d8974cb702c0762324e522462e66901e7590ae
parent 7441 746ecc2acac14da4b987c51fc65319bf2019591c
child 7443 c0bb2d32c1935e70d259b41c6c823d16ccb61f23
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs537872
Bug 537872 - Import Eudora mail code isn't 64-bit compatible; Patch by Ben Frisch, complete by Makoto Kato r=Standard8
mail/components/build/nsMailComps.cpp
mail/components/migration/content/migration.xul
mailnews/import/Makefile.in
mailnews/import/build/Makefile.in
mailnews/import/build/nsImportModule.cpp
mailnews/import/eudora/src/nsEudoraMac.cpp
mailnews/import/eudora/src/nsEudoraMac.h
--- a/mail/components/build/nsMailComps.cpp
+++ b/mail/components/build/nsMailComps.cpp
@@ -83,20 +83,18 @@ NS_DEFINE_NAMED_CID(NS_OEXPRESSPROFILEMI
 NS_DEFINE_NAMED_CID(NS_OUTLOOKPROFILEMIGRATOR_CID);
 NS_DEFINE_NAMED_CID(NS_MAILWININTEGRATION_CID);
 #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 NS_DEFINE_NAMED_CID(NS_MAILWINSEARCHHELPER_CID);
 #endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #endif // !XP_WIN32
 
 #if defined (XP_WIN32) || defined (XP_MACOSX)
-#ifndef __LP64__
 NS_DEFINE_NAMED_CID(NS_EUDORAPROFILEMIGRATOR_CID);
 #endif
-#endif
 
 #ifdef MOZ_WIDGET_GTK2
 NS_DEFINE_NAMED_CID(NS_MAILGNOMEINTEGRATION_CID);
 #endif
 
 #ifdef XP_MACOSX
 NS_DEFINE_NAMED_CID(NS_MAILMACINTEGRATION_CID);
 #endif
@@ -108,20 +106,18 @@ const mozilla::Module::CIDEntry kMailCID
   { &kNS_OEXPRESSPROFILEMIGRATOR_CID, false, NULL, nsOEProfileMigratorConstructor },
   { &kNS_OUTLOOKPROFILEMIGRATOR_CID, false, NULL, nsOutlookProfileMigratorConstructor },
   { &kNS_MAILWININTEGRATION_CID, false, NULL, nsWindowsShellServiceConstructor },
 #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   { &kNS_MAILWINSEARCHHELPER_CID, false, NULL, nsMailWinSearchHelperConstructor },
 #endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #endif // !XP_WIN32
 #if defined (XP_WIN32) || defined (XP_MACOSX)
-#ifndef __LP64__
   { &kNS_EUDORAPROFILEMIGRATOR_CID, false, NULL, nsEudoraProfileMigratorConstructor },
 #endif
-#endif
 #ifdef MOZ_WIDGET_GTK2
   { &kNS_MAILGNOMEINTEGRATION_CID, false, NULL, nsMailGNOMEIntegrationConstructor },
 #endif
 #ifdef XP_MACOSX
   { &kNS_MAILMACINTEGRATION_CID, false, NULL, nsMailMacIntegrationConstructor },
 #endif
   { NULL }
 };
@@ -133,20 +129,18 @@ const mozilla::Module::ContractIDEntry k
   { NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "oexpress", &kNS_OEXPRESSPROFILEMIGRATOR_CID },
   { NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "outlook", &kNS_OUTLOOKPROFILEMIGRATOR_CID },
   { "@mozilla.org/mail/shell-service;1", &kNS_MAILWININTEGRATION_CID },
 #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   { "@mozilla.org/mail/windows-search-helper;1", &kNS_MAILWINSEARCHHELPER_CID },
 #endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #endif // !XP_WIN32
 #if defined (XP_WIN32) || defined (XP_MACOSX)
-#ifndef __LP64__
   { NS_MAILPROFILEMIGRATOR_CONTRACTID_PREFIX "eudora", &kNS_EUDORAPROFILEMIGRATOR_CID },
 #endif
-#endif
 #ifdef MOZ_WIDGET_GTK2
   { "@mozilla.org/mail/shell-service;1", &kNS_MAILGNOMEINTEGRATION_CID },
 #endif
 #ifdef XP_MACOSX
   { "@mozilla.org/mail/shell-service;1", &kNS_MAILMACINTEGRATION_CID },
 #endif
   { NULL }
 };
--- a/mail/components/migration/content/migration.xul
+++ b/mail/components/migration/content/migration.xul
@@ -69,22 +69,19 @@
 
 #ifdef XP_WIN
       <radio id="oexpress"  label="&importFromOExpress.label;"  accesskey="&importFromOExpress.accesskey;"/>
       <radio id="outlook"   label="&importFromOutlook.label;"   accesskey="&importFromOutlook.accesskey;"/>
 #endif
 
 #ifdef XP_UNIX
 #ifdef XP_MACOSX
-#ifndef __LP64__
-      <!-- eudora import disabled on Mac 64 bit due to bug 537872 -->
       <radio id="eudora"    label="&importFromEudora.label;"    accesskey="&importFromEudora.accesskey;"/>
 #endif
 #endif
-#endif
 
 #ifdef XP_WIN
       <radio id="eudora"    label="&importFromEudora.label;"    accesskey="&importFromEudora.accesskey;"/>
 #endif
       
       <radio id="nothing"   label="&importFromNothing.label;"   accesskey="&importFromNothing.accesskey;" hidden="true"/>
     </radiogroup>
   </wizardpage>
--- a/mailnews/import/Makefile.in
+++ b/mailnews/import/Makefile.in
@@ -42,23 +42,18 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= import
 
 PARALLEL_DIRS	= public src text/src vcard/src comm4x/public comm4x/src
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-ifeq (x86_64,$(OS_TEST))
-# Compilation of eudora disabled for now, see bug 537872
-PARALLEL_DIRS   += applemail/src
-else
 PARALLEL_DIRS	+= eudora/src applemail/src
 endif
-endif
 
 ifeq ($(OS_ARCH),WINNT)
 PARALLEL_DIRS	+= eudora/src
 ifndef GNU_CC
 PARALLEL_DIRS	+= oexpress outlook/src winlivemail
 endif
 endif
 
--- a/mailnews/import/build/Makefile.in
+++ b/mailnews/import/build/Makefile.in
@@ -59,19 +59,17 @@ CPPSRCS		=  nsImportModule.cpp
 SHARED_LIBRARY_LIBS = \
 		../src/$(LIB_PREFIX)import_s.$(LIB_SUFFIX) \
 		../text/src/$(LIB_PREFIX)imptext_s.$(LIB_SUFFIX) \
 		../vcard/src/$(LIB_PREFIX)impvcard_s.$(LIB_SUFFIX) \
 		../comm4x/src/$(LIB_PREFIX)imp4mail_s.$(LIB_SUFFIX) \
 		$(NULL)
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-ifneq (x86_64,$(OS_TEST))
 SHARED_LIBRARY_LIBS += ../eudora/src/$(LIB_PREFIX)impEudra_s.$(LIB_SUFFIX)
-endif
 SHARED_LIBRARY_LIBS += ../applemail/src/$(LIB_PREFIX)applmail_s.$(LIB_SUFFIX)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 SHARED_LIBRARY_LIBS += ../eudora/src/$(LIB_PREFIX)impEudra_s.$(LIB_SUFFIX)
 
 ifndef GNU_CC
 SHARED_LIBRARY_LIBS += ../oexpress/$(LIB_PREFIX)importOE_s.$(LIB_SUFFIX)
--- a/mailnews/import/build/nsImportModule.cpp
+++ b/mailnews/import/build/nsImportModule.cpp
@@ -132,20 +132,18 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsVCardIm
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsComm4xMailImport)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ImportComm4xMailImpl, Initialize)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsComm4xProfile)
 
 ////////////////////////////////////////////////////////////////////////////////
 // eudora import factories
 ////////////////////////////////////////////////////////////////////////////////
 #if defined(XP_WIN) || defined(XP_MACOSX)
-#ifndef __LP64__
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsEudoraImport)
 #endif
-#endif
 
 ////////////////////////////////////////////////////////////////////////////////
 // apple mail import factories
 ////////////////////////////////////////////////////////////////////////////////
 #if defined(XP_MACOSX)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppleMailImportModule)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAppleMailImportMail, Initialize)
 #endif
@@ -161,20 +159,18 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWMImpor
 
 static const mozilla::Module::CategoryEntry kMailNewsImportCategories[] = {
   // XXX These CIDs should match the explicit CIDs defined in the header files,
   // or be changed so that they are contract IDs (with appropraite code updates)
   { "mailnewsimport", "{A5991D01-ADA7-11d3-A9C2-00A0CC26DA63}", NS_IMPORT_ADDRESS_STR },
   { "mailnewsimport", "{0eb034a3-964a-4e2f-92eb-cc55d9ae9dd2}", NS_IMPORT_ADDRESS_STR },
   { "mailnewsimport", "{647cc990-2bdb-11d6-92a0-0010a4b26cda}", kComm4xMailSupportsString},
 #if defined(XP_WIN) || defined(XP_MACOSX)
-#ifndef  __LP64__
   { "mailnewsimport", "{c8448da0-8f83-11d3-a206-00a0cc26da63}", kEudoraSupportsString },
 #endif
-#endif
 #ifdef XP_WIN
   { "mailnewsimport", "{42bc82bc-8e9f-4597-8b6e-e529daaf3af1}", kWMSupportsString },
   { "mailnewsimport", "{1DB469A0-8B00-11d3-A206-00A0CC26DA63}", kOutlookSupportsString },
   { "mailnewsimport", "{be0bc880-1742-11d3-a206-00a0cc26da63}", kOESupportsString },
 #endif
 #if defined(XP_MACOSX)
   { "mailnewsimport", "{6d3f101c-70ec-4e04-b68d-9908d1aeddf3}", kAppleMailSupportsString },
 #endif
@@ -185,20 +181,18 @@ const mozilla::Module::CIDEntry kMailNew
   { &kNS_IMPORTSERVICE_CID, false, NULL, nsImportServiceConstructor },
   { &kNS_IMPORTMIMEENCODE_CID, false, NULL, nsIImportMimeEncodeImplConstructor },
   { &kNS_TEXTIMPORT_CID, false, NULL, nsTextImportConstructor },
   { &kNS_VCARDIMPORT_CID, false, NULL, nsVCardImportConstructor },
   { &kNS_COMM4XMAILIMPORT_CID, false, NULL, nsComm4xMailImportConstructor },
   { &kNS_COMM4XMAILIMPL_CID, false, NULL, ImportComm4xMailImplConstructor },
   { &kNS_ICOMM4XPROFILE_CID, false, NULL, nsComm4xProfileConstructor },
 #if defined(XP_WIN) || defined(XP_MACOSX)
-#ifndef  __LP64__
   { &kNS_EUDORAIMPORT_CID, false, NULL, nsEudoraImportConstructor },
 #endif
-#endif
 #if defined(XP_MACOSX)
   { &kNS_APPLEMAILIMPORT_CID, false, NULL, nsAppleMailImportModuleConstructor },
   { &kNS_APPLEMAILIMPL_CID, false, NULL, nsAppleMailImportMailConstructor },
 #endif
 
 #ifdef XP_WIN
   { &kNS_OEIMPORT_CID, false, NULL, nsOEImportConstructor },
   { &kNS_WMIMPORT_CID, false, NULL, nsWMImportConstructor },
@@ -211,20 +205,18 @@ const mozilla::Module::ContractIDEntry k
   { NS_IMPORTSERVICE_CONTRACTID, &kNS_IMPORTSERVICE_CID },
   { "@mozilla.org/import/import-mimeencode;1", &kNS_IMPORTMIMEENCODE_CID },
   { "@mozilla.org/import/import-text;1", &kNS_TEXTIMPORT_CID },
   { "@mozilla.org/import/import-vcard;1", &kNS_VCARDIMPORT_CID },
   { "@mozilla.org/import/import-comm4xMail;1", &kNS_COMM4XMAILIMPORT_CID },
   { NS_COMM4XMAILIMPL_CONTRACTID, &kNS_COMM4XMAILIMPL_CID },
   { NS_ICOMM4XPROFILE_CONTRACTID, &kNS_ICOMM4XPROFILE_CID },
 #if defined(XP_WIN) || defined(XP_MACOSX)
-#ifndef __LP64__
   { "@mozilla.org/import/import-eudora;1", &kNS_EUDORAIMPORT_CID },
 #endif
-#endif
 #if defined(XP_MACOSX)
   { "@mozilla.org/import/import-applemail;1", &kNS_APPLEMAILIMPORT_CID },
   { NS_APPLEMAILIMPL_CONTRACTID, &kNS_APPLEMAILIMPL_CID },
 #endif
 
 #ifdef XP_WIN
   { "@mozilla.org/import/import-oe;1", &kNS_OEIMPORT_CID },
   { "@mozilla.org/import/import-wm;1", &kNS_WMIMPORT_CID },
@@ -232,20 +224,18 @@ const mozilla::Module::ContractIDEntry k
 #endif
   { NULL }
 };
 
 
 static void importModuleDtor()
 {
 #if defined(XP_WIN) || defined(XP_MACOSX)
-#ifndef __LP64__
     nsEudoraStringBundle::Cleanup();
 #endif
-#endif
 
 #ifdef XP_WIN
 
     nsOEStringBundle::Cleanup();
     nsWMStringBundle::Cleanup();
     nsOutlookStringBundle::Cleanup();
 
 #endif
--- a/mailnews/import/eudora/src/nsEudoraMac.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMac.cpp
@@ -19,16 +19,17 @@
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Pierre Phaneuf <pp@ludusdesign.com>
  *   Jeff Beckley <beckley@qualcomm.com>
  *   Steve Dorner <sdorner@qualcomm.com>
+ *   Ben Frisch <bfrisch@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -58,18 +59,16 @@
 #include "nsIPop3IncomingServer.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsNetUtil.h"
 #include "EudoraDebugLog.h"
 
 #include "nsILocalFileMac.h"
 
-#include <Carbon/Carbon.h>
-
 static NS_DEFINE_IID(kISupportsIID,      NS_ISUPPORTS_IID);
 
 static const char *  kWhitespace = "\b\t\r\n ";
 
 nsEudoraMac::nsEudoraMac()
 {
 }
 
@@ -425,27 +424,27 @@ nsresult nsEudoraMac::FoundMailFolder( n
     pInterface->Release();
   }
 
   return( NS_OK);
 }
 
 PRBool nsEudoraMac::CreateTocFromResource( nsIFile *pMail, nsIFile **pToc)
 {
-  short resFile = -1;
+  ResFileRefNum resFile = -1;
 
   {
     nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(pMail);
 
-    FSSpec fsSpec;
-    nsresult rv = macFile->GetFSSpec(&fsSpec);
+    FSRef fsRef;
+    nsresult rv = macFile->GetFSRef(&fsRef);
     if (NS_FAILED(rv))
       return PR_FALSE;
 
-    resFile = FSpOpenResFile( &fsSpec, fsRdPerm);
+    resFile = FSOpenResFile( &fsRef, fsRdPerm);
   }
 
   if (resFile == -1)
     return( PR_FALSE);
   Handle  resH = nil;
   short max = Count1Resources( 'TOCF');
   if (max)
     resH = Get1IndResource( 'TOCF', 1);
@@ -533,16 +532,43 @@ nsresult nsEudoraMac::FindTOCFile( nsIFi
   if (CreateTocFromResource( pMailFile, ppTOCFile))
   {
     *pDeleteToc = PR_TRUE;
     return( NS_OK);
   }
   return( NS_ERROR_FAILURE);
 }
 
+// GetIndString isn't supported on 64-bit Mac OS X
+// This code is emulation for GetIndString.
+static StringPtr GetStringFromHandle(Handle aResource,
+                                     ResourceIndex aId)
+{
+  if (!aResource)
+    return nsnull;
+
+  PRUint8 *data = *(PRUint8**)aResource;
+  PRUint16 count = *(PRUint16*)data;
+#if defined(IS_LITTLE_ENDIAN)
+  count = count << 8 | count >> 8;
+#endif
+
+  // First 2 bytes are the count of string that this resource has.
+  if (count < aId)
+    return nsnull;
+
+  // skip count
+  data += 2;
+
+  // looking for data.  data is in order
+  while (--aId > 0)
+    data = data + (*(PRUint8*)data) + 1;
+
+  return data;
+}
 
 // Strings returned:
 //  1 - smtp server
 //  2 - pop account user name
 //  3 - the pop server
 //  4 - Return address
 //  5 - Full name
 //  6 - Leave mail on server
@@ -562,58 +588,54 @@ nsresult nsEudoraMac::FindTOCFile( nsIFi
 #define kLeaveMailOnServerID  18
 
 
 PRBool nsEudoraMac::GetSettingsFromResource( nsIFile *pSettings, short resId, nsCString **pStrs, PRBool *pIMAP)
 {
   nsresult rv;
   *pIMAP = PR_FALSE;
   // Get settings from the resources...
-  short resFile = -1;
+  ResFileRefNum resFile = -1;
   {
     nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(pSettings, &rv);
     if (NS_FAILED(rv))
       return PR_FALSE;
 
-    FSSpec fsSpec;
-    rv = macFile->GetFSSpec(&fsSpec);
+    FSRef fsRef;
+    rv = macFile->GetFSRef(&fsRef);
     if (NS_FAILED(rv))
       return PR_FALSE;
 
-    resFile = FSpOpenResFile( &fsSpec, fsRdPerm);
+    resFile = FSOpenResFile( &fsRef, fsRdPerm);
   }
   if (resFile == -1)
     return( PR_FALSE);
 
+  UseResFile(resFile);
+
   // smtp server, STR# 1000, 4
   Handle  resH = Get1Resource( 'STR#', resId /* 1000 */);
   int    idx;
   if (resH)
   {
-    ReleaseResource( resH);
     StringPtr  pStr[5];
     StringPtr   theStr;
-    short    i;
-    for (i = 0; i < 5; i++)
-    {
-      pStr[i] = (StringPtr) new PRUint8[256];
-      (pStr[i])[0] = 0;
-    }
-    GetIndString( pStr[0], resId /* 1000 */, kSmtpServerID);
-    GetIndString( pStr[1], resId, kEmailAddressID); // user name@pop server
-    GetIndString( pStr[2], resId, kReturnAddressID);
-    GetIndString( pStr[3], resId, kFullNameID);
-    GetIndString( pStr[4], resId, kLeaveMailOnServerID);
-    CloseResFile( resFile);
+
+    // Cannot use GetIndString due to 64-bit support
+    pStr[0] = GetStringFromHandle(resH, kSmtpServerID);
+    pStr[1] = GetStringFromHandle(resH, kEmailAddressID);
+    pStr[2] = GetStringFromHandle(resH, kReturnAddressID);
+    pStr[3] = GetStringFromHandle(resH, kFullNameID);
+    pStr[4] = GetStringFromHandle(resH, kLeaveMailOnServerID);
 
     theStr = pStr[0];
-    if (*theStr)
+    if (theStr && *theStr)
       pStrs[0]->Append( (const char *) (theStr + 1), *theStr);
     theStr = pStr[1];
-    if (*theStr)
+    if (theStr && *theStr)
     {
       idx = 1;
       while (idx <= *theStr)
       {
         if (theStr[idx] == '@')
           break;
         else
           idx++;
@@ -628,31 +650,32 @@ PRBool nsEudoraMac::GetSettingsFromResou
       }
       else
         idx = 0;
       theStr[idx] = theStr[0] - idx;
       if (theStr[idx])
         pStrs[2]->Append( (const char *) (theStr + idx + 1), *(theStr + idx));
     }
     theStr = pStr[2];
-    if ( *theStr)
+    if (theStr && *theStr)
       pStrs[3]->Append( (const char *) (theStr + 1), *theStr);
     theStr = pStr[3];
-    if ( *theStr)
+    if (theStr && *theStr)
       pStrs[4]->Append( (const char *) (theStr + 1), *theStr);
     theStr = pStr[4];
-    if ( *theStr)
+    if (theStr && *theStr)
     {
       if (theStr[1] == 'y')
         *(pStrs[5]) = "Y";
       else
         *(pStrs[5]) = "N";
     }
-    for (i = 0; i < 5; i++)
-      delete pStr[i];
+
+    ReleaseResource(resH);
+    CloseResFile( resFile);
 
     return( PR_TRUE);
   }
   else
   {
     CloseResFile( resFile);
     return( PR_FALSE);
   }
@@ -1000,18 +1023,18 @@ nsresult nsEudoraMac::GetAttachmentInfo(
   nsCString  typeStr;
   nsCString  creatStr;
 
   creatStr.Append( (const char *)&creator, 4);
   typeStr.Append( (const char *)&type, 4);
   IMPORT_LOG3( "\tAttachment type: %s, creator: %s, fileNum: %ld\n", typeStr.get(), creatStr.get(), fNum);
   IMPORT_LOG1( "\tAttachment file name: %s\n", str.get());
 #endif
-  FSSpec  spec;
-  memset( &spec, 0, sizeof( spec));
+  FSRef  fsRef;
+  memset( &fsRef, 0, sizeof( fsRef));
   {
     nsresult rv;
     nsCOMPtr <nsILocalFile> pLocalFile = do_QueryInterface(pFile, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     pLocalFile->InitWithNativePath(str);
     if (NS_FAILED(rv))
     {
       IMPORT_LOG0("\tfailed to set native path\n");
@@ -1022,44 +1045,41 @@ nsresult nsEudoraMac::GetAttachmentInfo(
 
     nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(pFile, &rv);
     if (NS_FAILED(rv))
     {
       IMPORT_LOG0("\tfailed to get local mac file\n");
       return rv;
     }
 
-    rv = macFile->GetFSSpec(&spec);
+    rv = macFile->GetFSRef(&fsRef);
     if (NS_FAILED(rv))
     {
-      IMPORT_LOG0("\tfailed to get FSSpec\n");
+      IMPORT_LOG0("\tfailed to get FSRef\n");
       return rv;
     }
   }
 
-  if (HasResourceFork(&spec))
+  if (HasResourceFork(&fsRef))
     mimeType = "application/applefile";
   else
     mimeType = "application/octet-stream";
 
   IMPORT_LOG1( "\tMimeType: %s\n", mimeType.get());
 
   return( NS_OK);
 }
 
-PRBool nsEudoraMac::HasResourceFork(FSSpec *fsSpec)
+PRBool nsEudoraMac::HasResourceFork(FSRef *fsRef)
 {
-  FSRef fsRef;
-  if (::FSpMakeFSRef(fsSpec, &fsRef) == noErr)
-  {
-    FSCatalogInfo catalogInfo;
-    OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoRsrcSizes, &catalogInfo, nsnull, nsnull, nsnull);
-    return (err == noErr && catalogInfo.rsrcLogicalSize != 0);
-  }
-  return PR_FALSE;
+  FSCatalogInfo catalogInfo;
+  OSErr err = FSGetCatalogInfo(fsRef,
+                               kFSCatInfoDataSizes + kFSCatInfoRsrcSizes,
+                               &catalogInfo, nsnull, nsnull, nsnull);
+  return (err == noErr && catalogInfo.rsrcLogicalSize != 0);
 }
 
 
 #define    kNumBadFolderNames    7
 const char *cBadFolderNames[kNumBadFolderNames] =
 {
   "Attachments Folder",
   "Eudora Items",
--- a/mailnews/import/eudora/src/nsEudoraMac.h
+++ b/mailnews/import/eudora/src/nsEudoraMac.h
@@ -42,16 +42,18 @@
 
 #include "nscore.h"
 #include "nsString.h"
 #include "nsIFile.h"
 #include "nsISupportsArray.h"
 #include "nsEudoraMailbox.h"
 #include "nsEudoraAddress.h"
 
+#include <CoreServices/CoreServices.h>
+
 class nsIImportService;
 class nsIMsgAccountManager;
 class nsIMsgAccount;
 
 
 class nsEudoraMac : public nsEudoraMailbox, public nsEudoraAddress {
 public:
   nsEudoraMac();
@@ -102,14 +104,14 @@ private:
   static void    SetIdentities( nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *userName, const char *serverName, nsCString **pStrs);
   static void    SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser);
   static PRBool  GetSettingsFromResource( nsIFile *pSettings, short resId, nsCString **pStrs, PRBool *pIMAP);
 
 
 private:
   PRUint32 m_depth;
   nsCOMPtr <nsILocalFile> m_mailImportLocation;
-  PRBool HasResourceFork(FSSpec *fsSpec);
+  PRBool HasResourceFork(FSRef *fsRef);
 };
 
 
 #endif /* nsEudoraMac_h__ */