Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
nsEudoraWin32 Class Reference

#include <nsEudoraWin32.h>

Inheritance diagram for nsEudoraWin32:
Inheritance graph
[legend]
Collaboration diagram for nsEudoraWin32:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsEudoraWin32 ()
 ~nsEudoraWin32 ()
virtual PRBool FindMailFolder (nsIFileSpec *pFolder)
virtual nsresult FindMailboxes (nsIFileSpec *pRoot, nsISupportsArray **ppArray)
virtual nsresult FindTOCFile (nsIFileSpec *pMailFile, nsIFileSpec **pTOCFile, PRBool *pDeleteToc)
virtual nsresult GetAttachmentInfo (const char *pFileName, nsIFileSpec *pSpec, nsCString &mimeType, nsCString &aAttachment)
virtual PRBool FindAddressFolder (nsIFileSpec *pFolder)
virtual nsresult FindAddressBooks (nsIFileSpec *pRoot, nsISupportsArray **ppArray)
nsresult ImportMailbox (PRUint32 *pBytes, PRBool *pAbort, const PRUnichar *pName, nsIFileSpec *pSrc, nsIFileSpec *pDst, PRInt32 *pMsgCount)
nsresult ImportAddresses (PRUint32 *pBytes, PRBool *pAbort, const PRUnichar *pName, nsIFileSpec *pSrc, nsIAddrDatabase *pDb, nsString &errors)

Static Public Member Functions

static PRBool ImportSettings (nsIFileSpec *pIniFile, nsIMsgAccount **localMailAccount)
static PRBool FindSettingsFile (nsIFileSpec *pIniFile)
static PRInt32 IsEudoraFromSeparator (const char *pData, PRInt32 maxLen, nsCString &defaultDate)
static PRBool IsEudoraTag (const char *pChar, PRInt32 maxLen, PRBool &insideEudoraTags, nsCString &bodyType, PRInt32 &tagLength)
static PRInt32 CountQuote (const char *pLine, PRInt32 len)
static PRInt32 CountComment (const char *pLine, PRInt32 len)
static PRInt32 CountAngle (const char *pLine, PRInt32 len)

Protected Member Functions

nsresult CreateTempFile (nsIFileSpec **ppSpec)
nsresult DeleteFile (nsIFileSpec *pSpec)

Private Member Functions

nsresult ScanMailDir (nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
nsresult IterateMailDir (nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
nsresult ScanDescmap (nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, PRInt32 len)
nsresult FoundMailFolder (nsIFileSpec *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
nsresult FoundMailbox (nsIFileSpec *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport)
PRBool FindMimeIniFile (nsIFileSpec *pSpec)
void GetMimeTypeFromExtension (nsCString &ext, nsCString &mimeType)
nsresult FoundAddressBook (nsIFileSpec *spec, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc)
nsresult ScanAddressDir (nsIFileSpec *pDir, nsISupportsArray *pArray, nsIImportService *impSvc)

Static Private Member Functions

static PRBool FindEudoraLocation (nsIFileSpec *pFolder, PRBool findIni=PR_FALSE)
static PRBool BuildPOPAccount (nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount)
static PRBool BuildIMAPAccount (nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount)
static void GetServerAndUserName (const char *pSection, const char *pIni, nsCString &serverName, nsCString &userName, char *pBuff)
static void GetAccountName (const char *pSection, nsString &str)
static void SetIdentities (nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, const char *userName, const char *serverName, char *pBuff)
static void SetSmtpServer (nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser)
static BYTEGetValueBytes (HKEY hKey, const char *pValueName)
static void ConvertPath (nsCString &str)

Private Attributes

PRUint32 m_depth
nsIFileSpecm_mailImportLocation
nsIFileSpecm_addressImportFolder
char * m_pMimeSection

Detailed Description

Definition at line 56 of file nsEudoraWin32.h.


Constructor & Destructor Documentation


Member Function Documentation

PRBool nsEudoraWin32::BuildIMAPAccount ( nsIMsgAccountManager accMgr,
const char *  pSection,
const char *  pIni,
nsIMsgAccount **  ppAccount 
) [static, private]

Definition at line 790 of file nsEudoraWin32.cpp.

{
       char          valBuff[kIniValueSize];
       nsCString     serverName;
       nsCString     userName;
       
       GetServerAndUserName( pSection, pIni, serverName, userName, valBuff);
       
       if (serverName.IsEmpty() || userName.IsEmpty())
              return( PR_FALSE);

       PRBool result = PR_FALSE;

       nsCOMPtr<nsIMsgIncomingServer>     in;
       nsresult rv = accMgr->FindServer( userName.get(), serverName.get(), "imap", getter_AddRefs( in));
       if (NS_FAILED( rv) || (in == nsnull)) {
              // Create the incoming server and an account for it?
              rv = accMgr->CreateIncomingServer( userName.get(), serverName.get(), "imap", getter_AddRefs( in));
              if (NS_SUCCEEDED( rv) && in) {
                     rv = in->SetType( "imap");
                     // rv = in->SetHostName( serverName);
                     // rv = in->SetUsername( userName);
                     
                     IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", serverName.get(), userName.get());
                     
                     nsString      prettyName;
                     GetAccountName( pSection, prettyName);

                     PRUnichar *pretty = ToNewUnicode(prettyName);
                     
                     IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty);

                     rv = in->SetPrettyName( pretty);
                     nsCRT::free( pretty);
                     
                     // We have a server, create an account.
                     nsCOMPtr<nsIMsgAccount>     account;
                     rv = accMgr->CreateAccount( getter_AddRefs( account));
                     if (NS_SUCCEEDED( rv) && account) {
                            rv = account->SetIncomingServer( in);     
                            
                            IMPORT_LOG0( "Created an account and set the IMAP server as the incoming server\n");

                            // Fiddle with the identities
                            SetIdentities(accMgr, account, pSection, pIni, userName.get(), serverName.get(), valBuff);
                            result = PR_TRUE;
                            if (ppAccount)
                                   account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
                     }                           
              }
       }
       else
              result = PR_TRUE;

       return( result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEudoraWin32::BuildPOPAccount ( nsIMsgAccountManager accMgr,
const char *  pSection,
const char *  pIni,
nsIMsgAccount **  ppAccount 
) [static, private]

Definition at line 725 of file nsEudoraWin32.cpp.

{
       if (ppAccount)
              *ppAccount = nsnull;
       
       char          valBuff[kIniValueSize];
       nsCString     serverName;
       nsCString     userName;
       
       GetServerAndUserName( pSection, pIni, serverName, userName, valBuff);
       
       if (serverName.IsEmpty() || userName.IsEmpty())
              return( PR_FALSE);

       PRBool result = PR_FALSE;

       // I now have a user name/server name pair, find out if it already exists?
       nsCOMPtr<nsIMsgIncomingServer>     in;
       nsresult rv = accMgr->FindServer( userName.get(), serverName.get(), "pop3", getter_AddRefs( in));
       if (NS_FAILED( rv) || (in == nsnull)) {
              // Create the incoming server and an account for it?
              rv = accMgr->CreateIncomingServer( userName.get(), serverName.get(), "pop3", getter_AddRefs( in));
              if (NS_SUCCEEDED( rv) && in) {
                     rv = in->SetType( "pop3");
                     // rv = in->SetHostName( serverName);
                     // rv = in->SetUsername( userName);

                     IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", serverName.get(), userName.get());

                     nsString      prettyName;
                     GetAccountName( pSection, prettyName);

                     PRUnichar *pretty = ToNewUnicode(prettyName);
                     IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty);
                     rv = in->SetPrettyName( pretty);
                     nsCRT::free( pretty);
                     
                     // We have a server, create an account.
                     nsCOMPtr<nsIMsgAccount>     account;
                     rv = accMgr->CreateAccount( getter_AddRefs( account));
                     if (NS_SUCCEEDED( rv) && account) {
                            rv = account->SetIncomingServer( in);

                            IMPORT_LOG0( "Created a new account and set the incoming server to the POP3 server.\n");
                                   
        nsCOMPtr<nsIPop3IncomingServer> pop3Server = do_QueryInterface(in, &rv);
        NS_ENSURE_SUCCESS(rv,rv);
        UINT valInt = ::GetPrivateProfileInt(pSection, "LeaveMailOnServer", 0, pIni);
        pop3Server->SetLeaveMessagesOnServer(valInt ? PR_TRUE : PR_FALSE);
                            
                            // Fiddle with the identities
                            SetIdentities(accMgr, account, pSection, pIni, userName.get(), serverName.get(), valBuff);
                            result = PR_TRUE;
                            if (ppAccount)
                                   account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount);
                     }                           
              }
       }
       else
              result = PR_TRUE;
       
       return( result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsEudoraWin32::ConvertPath ( nsCString str) [static, private]

Definition at line 1436 of file nsEudoraWin32.cpp.

{
       nsCString     temp;
       nsCString     path;
       PRInt32              idx = 0;
       PRInt32              start = 0;
       nsCString     search;

       idx = str.FindChar( '\\', idx);
       if ((idx == 2) && (str.CharAt( 1) == ':')) {
              str.Left( path, 3);
              idx++;
              idx = str.FindChar( '\\', idx);
              start = 3;
              if ((idx == -1) && (str.Length() > 3)) {
                     str.Right( temp, str.Length() - start);
                     path.Append( temp);
              }
       }
       
       WIN32_FIND_DATA findFileData;
       while (idx != -1) {
              str.Mid( temp, start, idx - start);
              search = path;
              search.Append( temp);
              HANDLE h = FindFirstFile( search.get(), &findFileData);
              if (h == INVALID_HANDLE_VALUE)
                     return;
              path.Append( findFileData.cFileName);
              idx++;
              start = idx;
              idx = str.FindChar( '\\', idx);
              FindClose( h);
              if (idx != -1)
                     path.Append( '\\');
              else {
                     str.Right( temp, str.Length() - start);
                     path.Append( '\\');
                     path.Append( temp);
              }
       }

       str = path;
}

Here is the call graph for this function:

PRInt32 nsEudoraAddress::CountAngle ( const char *  pLine,
PRInt32  len 
) [static, inherited]

Definition at line 391 of file nsEudoraAddress.cpp.

{
       if (!len)
              return( 0);
              
       PRInt32 cnt = 1;
       pLine++;
       len--;
       
       while (len && (*pLine != '>')) {
              cnt++;
              len--;
              pLine++;
       }
       
       if (len)
              cnt++;
       return( cnt);
}

Here is the caller graph for this function:

PRInt32 nsEudoraAddress::CountComment ( const char *  pLine,
PRInt32  len 
) [static, inherited]

Definition at line 411 of file nsEudoraAddress.cpp.

{
       if (!len)
              return( 0);
       
       PRInt32       cCnt;
       PRInt32 cnt = 1;
       pLine++;
       len--;
       
       while (len && (*pLine != ')')) {
              if (*pLine == '(') {
                     cCnt = CountComment( pLine, len);  
                     cnt += cCnt;
                     pLine += cCnt;
                     len -= cCnt;
              }
              else {
                     cnt++;
                     len--;
                     pLine++;
              }
       }
       
       if (len)
              cnt++;
       return( cnt);
}

Here is the caller graph for this function:

PRInt32 nsEudoraAddress::CountQuote ( const char *  pLine,
PRInt32  len 
) [static, inherited]

Definition at line 370 of file nsEudoraAddress.cpp.

{
       if (!len)
              return( 0);
              
       PRInt32 cnt = 1;
       pLine++;
       len--;
       
       while (len && (*pLine != '"')) {
              cnt++;
              len--;
              pLine++;
       }
       
       if (len)
              cnt++;
       return( cnt);
}

Here is the caller graph for this function:

nsresult nsEudoraMailbox::CreateTempFile ( nsIFileSpec **  ppSpec) [protected, inherited]

Definition at line 119 of file nsEudoraMailbox.cpp.

{
       *ppSpec = nsnull;
       
       nsSpecialSystemDirectory temp(nsSpecialSystemDirectory::OS_TemporaryDirectory);
       
       // nsSpecialSystemDirectory temp(nsSpecialSystemDirectory::Mac_DesktopDirectory);
       
    temp += "impmail.txt";
       temp.MakeUnique();
       nsresult rv = NS_NewFileSpecWithSpec( temp, ppSpec);
    if (NS_SUCCEEDED(rv)) {
              if (*ppSpec)
                     return( NS_OK);
              else
                     return( NS_ERROR_FAILURE);
       }

       return( rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraMailbox::DeleteFile ( nsIFileSpec pSpec) [protected, inherited]

Definition at line 140 of file nsEudoraMailbox.cpp.

{
       PRBool        result;
       nsresult      rv = NS_OK;

       result = PR_FALSE;
       pSpec->IsStreamOpen( &result);
       if (result)
              pSpec->CloseStream();
       result = PR_FALSE;
       pSpec->Exists( &result);
       if (result) {
              result = PR_FALSE;
              pSpec->IsFile( &result);
              if (result) {
                     nsFileSpec    spec;
                     rv = pSpec->GetFileSpec( &spec);
#ifndef DONT_DELETE_EUDORA_TEMP_FILES
                     if (NS_SUCCEEDED( rv))
                            spec.Delete( PR_FALSE);
#endif
              }
       }

       return( rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::FindAddressBooks ( nsIFileSpec pRoot,
nsISupportsArray **  ppArray 
) [virtual]

Reimplemented from nsEudoraAddress.

Definition at line 1187 of file nsEudoraWin32.cpp.

{

       nsCOMPtr<nsIFileSpec>       spec;
       nsresult rv = NS_NewFileSpec( getter_AddRefs( spec));
       if (NS_FAILED( rv))
              return( rv);
       rv = spec->FromFileSpec( pRoot);
       if (NS_FAILED( rv))
              return( rv);

       rv = NS_NewISupportsArray( ppArray);
       if (NS_FAILED( rv)) {
              IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n");
              return( rv);
       }
              
       nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
       if (NS_FAILED( rv))
              return( rv);
       
       NS_IF_RELEASE( m_addressImportFolder);
       m_addressImportFolder = pRoot;
       NS_IF_ADDREF( pRoot);

       
       nsString             displayName;
       nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NICKNAMES_NAME, displayName);

       // First off, get the default nndbase.txt, then scan the default nicknames subdir,
       // then look in the .ini file for additional directories to scan for address books!
       rv = spec->AppendRelativeUnixPath( "nndbase.txt");
       PRBool exists = PR_FALSE;
       PRBool isFile = PR_FALSE;
       if (NS_SUCCEEDED( rv))
              rv = spec->Exists( &exists);
       if (NS_SUCCEEDED( rv) && exists)
              rv = spec->IsFile( &isFile);
       if (exists && isFile) {
              if (NS_FAILED( rv = FoundAddressBook( spec, displayName.get(), *ppArray, impSvc)))
                     return( rv);
       }
       
       // Try the default directory
       rv = spec->FromFileSpec( pRoot);
       if (NS_FAILED( rv))
              return( rv);
       rv = spec->AppendRelativeUnixPath( "Nickname");
       PRBool isDir = PR_FALSE;
       exists = PR_FALSE;
       if (NS_SUCCEEDED( rv))
              rv = spec->Exists( &exists);
       if (NS_SUCCEEDED( rv) && exists)
              rv = spec->IsDirectory( &isDir);
       if (exists && isDir) {
              if (NS_FAILED( rv = ScanAddressDir( spec, *ppArray, impSvc)))
                     return( rv);
       }
       
       // Try the ini file to find other directories!
       rv = spec->FromFileSpec( pRoot);
       if (NS_SUCCEEDED( rv))
              rv = spec->AppendRelativeUnixPath( "eudora.ini");
       exists = PR_FALSE;
       isFile = PR_FALSE;
       if (NS_SUCCEEDED( rv))
              rv = spec->Exists( &exists);
       if (NS_SUCCEEDED( rv) && exists)
              rv = spec->IsFile( &isFile);
       
       if (!isFile || !exists) {
              rv = spec->FromFileSpec( pRoot);
              if (NS_FAILED( rv))
                     return( NS_OK);
              if (!FindMimeIniFile( spec))
                     return( NS_OK);
       }

       char *pName = nsnull;
       spec->GetNativePath( &pName);
       if (!pName)
              return( NS_OK);
       nsCString     fileName(pName);
       nsCRT::free( pName);
       
       // This is the supposed ini file name!
       // Get the extra directories for nicknames and parse it for valid nickname directories
       // to look into...
       char *pBuffer = new char[2048];
       DWORD len = ::GetPrivateProfileString( "Settings", "ExtraNicknameDirs", "", pBuffer, 2048, fileName.get());
       if (len == 2047) {
              // If the value is really that large then don't bother!
              delete [] pBuffer;
              return( NS_OK);
       }
       nsCString     dirs(pBuffer);
       delete [] pBuffer;
       dirs.Trim( kWhitespace);
       PRInt32       idx = 0;
       nsCString     currentDir;
       while ((idx = dirs.FindChar( ';')) != -1) {
              dirs.Left( currentDir, idx);
              currentDir.Trim( kWhitespace);
              if (!currentDir.IsEmpty()) {
                     rv = spec->SetNativePath( currentDir.get());
                     exists = PR_FALSE;
                     isDir = PR_FALSE;
                     if (NS_SUCCEEDED( rv))
                            rv = spec->Exists( &exists);
                     if (NS_SUCCEEDED( rv) && exists)
                            rv = spec->IsDirectory( &isDir);
                     if (exists && isDir) {
                            if (NS_FAILED( rv = ScanAddressDir( spec, *ppArray, impSvc)))
                                   return( rv);
                     }
              }
              dirs.Right( currentDir, dirs.Length() - idx - 1);
              dirs = currentDir;
              dirs.Trim( kWhitespace);
       }
       if (!dirs.IsEmpty()) {
              rv = spec->SetNativePath( dirs.get());
              exists = PR_FALSE;
              isDir = PR_FALSE;
              if (NS_SUCCEEDED( rv))
                     rv = spec->Exists( &exists);
              if (NS_SUCCEEDED( rv) && exists)
                     rv = spec->IsDirectory( &isDir);
              if (exists && isDir) {
                     if (NS_FAILED( rv = ScanAddressDir( spec, *ppArray, impSvc)))
                            return( rv);
              }
       }
       
       return( NS_OK);
}

Here is the call graph for this function:

Reimplemented from nsEudoraAddress.

Definition at line 1180 of file nsEudoraWin32.cpp.

{
       IMPORT_LOG0( "*** Looking for Eudora address folder\n");

       return( FindEudoraLocation( pFolder));
}

Here is the call graph for this function:

PRBool nsEudoraWin32::FindEudoraLocation ( nsIFileSpec pFolder,
PRBool  findIni = PR_FALSE 
) [static, private]

Definition at line 106 of file nsEudoraWin32.cpp.

{
       PRBool result = PR_FALSE;
  PRBool  exists = PR_FALSE;

       // look in the registry to see where eudora is installed?
       HKEY   sKey;
       if (::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Qualcomm\\Eudora\\CommandLine", 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS) {
              // get the value of "Current"
              BYTE *pBytes = GetValueBytes( sKey, "Current");
              if (pBytes) {
                     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);
                            if (idx != -1)
                                   idx++;
                     }
                     else {
                            idx = str.FindChar( ' ');
                     }
                     
                     if (idx != -1) {
                            idx++;
                            while (str.CharAt( idx) == ' ') idx++;
                            int endIdx = -1;
                            if (str.CharAt( idx) == '"') {
                                   endIdx = str.FindChar( '"', idx);
                            }
                            else {
                                   endIdx = str.FindChar( ' ', idx);
                            }
                            if (endIdx != -1) {
                                   nsCString     path;
                                   str.Mid( path, idx, endIdx - idx);                             
                                   
                                   pFolder->SetNativePath( path.get());

                                     if (NS_SUCCEEDED( pFolder->IsDirectory( &exists)))
                                                 result = exists;
                                          }
                                   }
                            }
    } // if pBytes
              ::RegCloseKey( sKey);
       }

       return( result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::FindMailboxes ( nsIFileSpec pRoot,
nsISupportsArray **  ppArray 
) [virtual]

Reimplemented from nsEudoraMailbox.

Definition at line 182 of file nsEudoraWin32.cpp.

{
       nsresult rv = NS_NewISupportsArray( ppArray);
       if (NS_FAILED( rv)) {
              IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n");
              return( rv);
       }
              
       nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
       if (NS_FAILED( rv))
              return( rv);
       
       m_depth = 0;
       NS_IF_RELEASE( m_mailImportLocation);
       m_mailImportLocation = pRoot;
       NS_IF_ADDREF( m_mailImportLocation);

       return( ScanMailDir( pRoot, *ppArray, impSvc));
}

Here is the call graph for this function:

Reimplemented from nsEudoraMailbox.

Definition at line 101 of file nsEudoraWin32.cpp.

{
       return( FindEudoraLocation( pFolder));
}

Here is the call graph for this function:

Definition at line 965 of file nsEudoraWin32.cpp.

{
       nsCOMPtr<nsIDirectoryIterator>     dir;
       nsresult rv = NS_NewDirectoryIterator( getter_AddRefs( dir));
       if (NS_FAILED( rv))
              return( PR_FALSE);

       PRBool exists = PR_FALSE;
       rv = dir->Init( pSpec, PR_TRUE);
       if (NS_FAILED( rv))
              return( PR_FALSE);

       rv = dir->Exists( &exists);
       if (NS_FAILED( rv))
              return( PR_FALSE);
       
       PRBool                             isFile;
       nsCOMPtr<nsIFileSpec>       entry;
       char *                             pName;
       nsCString                          fName;
       nsCString                          ext;
       nsCString                          name;
       PRBool                             found = PR_FALSE;

       while (exists && NS_SUCCEEDED( rv)) {
              rv = dir->GetCurrentSpec( getter_AddRefs( entry));
              if (NS_SUCCEEDED( rv)) {
                     rv = entry->GetLeafName( &pName);
                     if (NS_SUCCEEDED( rv) && pName) {
                            fName = pName;
                            nsCRT::free( pName);
                            if (fName.Length() > 4) {
                                   fName.Right( ext, 4);
                                   fName.Left( name, fName.Length() - 4);
                            }
                            else {
                                   ext.Truncate();
                                   name = fName;
                            }
                            ToLowerCase(ext);
                            if (ext.EqualsLiteral(".ini")) {
                                   isFile = PR_FALSE;
                                   entry->IsFile( &isFile);
                                   if (isFile) {
                                          if (found) {
                                                 // which one of these files is newer?
                                                 PRUint32      modDate1, modDate2;
                                                 entry->GetModDate( &modDate2);
                                                 pSpec->GetModDate( &modDate1);
                                                 if (modDate2 > modDate1)
                                                        pSpec->FromFileSpec( entry);
                                          }
                                          else {
                                                 pSpec->FromFileSpec( entry);
                                                 found = PR_TRUE;
                                          }
                                   }
                            }
                     }                           
              }
              
              rv = dir->Next();
              if (NS_SUCCEEDED( rv))
                     rv = dir->Exists( &exists);
       }
       
       if (found)
              return( PR_TRUE);
       else
              return( PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool nsEudoraWin32::FindSettingsFile ( nsIFileSpec pIniFile) [inline, static]

Definition at line 78 of file nsEudoraWin32.h.

{ return( FindEudoraLocation( pIniFile, PR_TRUE));}

Here is the call graph for this function:

nsresult nsEudoraWin32::FindTOCFile ( nsIFileSpec pMailFile,
nsIFileSpec **  pTOCFile,
PRBool pDeleteToc 
) [virtual]

Reimplemented from nsEudoraMailbox.

Definition at line 515 of file nsEudoraWin32.cpp.

{
       nsresult             rv;
       char   *             pName = nsnull;

       *pDeleteToc = PR_FALSE;
       *ppTOCFile = nsnull;
       rv = pMailFile->GetLeafName( &pName);
       if (NS_FAILED( rv))
              return( rv);
       rv = pMailFile->GetParent( ppTOCFile);
       if (NS_FAILED( rv))
              return( rv);

       nsCString     leaf(pName);
       nsCRT::free( pName);
       nsCString     name;
       if ((leaf.Length() > 4) && (leaf.CharAt( leaf.Length() - 4) == '.'))
              leaf.Left( name, leaf.Length() - 4);
       else
              name = leaf;
       name.Append( ".toc");
       rv = (*ppTOCFile)->AppendRelativeUnixPath( name.get());
       if (NS_FAILED( rv))
              return( rv);

       PRBool exists = PR_FALSE;
       rv = (*ppTOCFile)->Exists( &exists);
       if (NS_FAILED( rv))
              return( rv);
       PRBool isFile = PR_FALSE;
       rv = (*ppTOCFile)->IsFile( &isFile);
       if (NS_FAILED( rv))
              return( rv);
       if (exists && isFile)
              return( NS_OK);
              
       return( NS_ERROR_FAILURE);
}

Here is the call graph for this function:

nsresult nsEudoraWin32::FoundAddressBook ( nsIFileSpec spec,
const PRUnichar pName,
nsISupportsArray pArray,
nsIImportService impSvc 
) [private]

Definition at line 1385 of file nsEudoraWin32.cpp.

{
       nsCOMPtr<nsIImportABDescriptor>    desc;
       nsISupports *                             pInterface;
       nsString                                         name;
       nsresult                                         rv;

       if (pName)
              name = pName;
       else {
              char *pLeaf = nsnull;
              rv = spec->GetLeafName( &pLeaf);
              if (NS_FAILED( rv))
                     return( rv);
              if (!pLeaf)
                     return( NS_ERROR_FAILURE);
              NS_CopyNativeToUnicode(nsDependentCString(pLeaf), name);
              nsCRT::free( pLeaf);
              nsString      tStr;
              name.Right( tStr, 4);
              if (tStr.LowerCaseEqualsLiteral(".txt")) {
                     name.Left( tStr, name.Length() - 4);
                     name = tStr;
              }
       }

       rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc));
       if (NS_SUCCEEDED( rv)) {
              PRUint32 sz = 0;
              spec->GetFileSize( &sz);    
              desc->SetPreferredName( name.get());
              desc->SetSize( sz);
              nsIFileSpec *pSpec = nsnull;
              desc->GetFileSpec( &pSpec);
              if (pSpec) {
                     pSpec->FromFileSpec( spec);
                     NS_RELEASE( pSpec);
              }
              rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
              pArray->AppendElement( pInterface);
              pInterface->Release();
       }
       if (NS_FAILED( rv)) {
              IMPORT_LOG0( "*** Error creating address book descriptor for eudora\n");
              return( rv);
       }

       return( NS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::FoundMailbox ( nsIFileSpec mailFile,
const char *  pName,
nsISupportsArray pArray,
nsIImportService pImport 
) [private]

Definition at line 430 of file nsEudoraWin32.cpp.

{
       nsString                                                       displayName;
       nsCOMPtr<nsIImportMailboxDescriptor>      desc;
       nsISupports *                                           pInterface;

       NS_CopyNativeToUnicode(nsDependentCString(pName), displayName);

#ifdef IMPORT_DEBUG
       char *pPath = nsnull;
       mailFile->GetNativePath( &pPath);
       if (pPath) {
              IMPORT_LOG2( "Found eudora mailbox, %s: %s\n", pPath, pName);
              nsCRT::free( pPath);
       }
       else {
              IMPORT_LOG1( "Found eudora mailbox, %s\n", pName);
       }
       IMPORT_LOG1( "\tm_depth = %d\n", (int)m_depth);
#endif

       nsresult rv = pImport->CreateNewMailboxDescriptor( getter_AddRefs( desc));
       if (NS_SUCCEEDED( rv)) {
              PRUint32             sz = 0;
              mailFile->GetFileSize( &sz);       
              desc->SetDisplayName( displayName.get());
              desc->SetDepth( m_depth);
              desc->SetSize( sz);
              nsIFileSpec *pSpec = nsnull;
              desc->GetFileSpec( &pSpec);
              if (pSpec) {
                     pSpec->FromFileSpec( mailFile);
                     NS_RELEASE( pSpec);
              }
              rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
              pArray->AppendElement( pInterface);
              pInterface->Release();
       }

       return( NS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::FoundMailFolder ( nsIFileSpec mailFolder,
const char *  pName,
nsISupportsArray pArray,
nsIImportService pImport 
) [private]

Definition at line 473 of file nsEudoraWin32.cpp.

{
       nsString                                                       displayName;
       nsCOMPtr<nsIImportMailboxDescriptor>      desc;
       nsISupports *                                           pInterface;

       NS_CopyNativeToUnicode(nsDependentCString(pName), displayName);

#ifdef IMPORT_DEBUG
       char *pPath = nsnull;
       mailFolder->GetNativePath( &pPath);
       if (pPath) {
              IMPORT_LOG2( "Found eudora folder, %s: %s\n", pPath, pName);
              nsCRT::free( pPath);
       }
       else {
              IMPORT_LOG1( "Found eudora folder, %s\n", pName);
       }
       IMPORT_LOG1( "\tm_depth = %d\n", (int)m_depth);
#endif

       nsresult rv = pImport->CreateNewMailboxDescriptor( getter_AddRefs( desc));
       if (NS_SUCCEEDED( rv)) {
              PRUint32             sz = 0;
              desc->SetDisplayName( displayName.get());
              desc->SetDepth( m_depth);
              desc->SetSize( sz);
              nsIFileSpec *pSpec = nsnull;
              desc->GetFileSpec( &pSpec);
              if (pSpec) {
                     pSpec->FromFileSpec( mailFolder);
                     NS_RELEASE( pSpec);
              }
              rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface);
              pArray->AppendElement( pInterface);
              pInterface->Release();
       }

       return( NS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsEudoraWin32::GetAccountName ( const char *  pSection,
nsString str 
) [static, private]

Definition at line 701 of file nsEudoraWin32.cpp.

{
       str.Truncate();

       nsCString     s(pSection);
       
       if (s.Equals(NS_LITERAL_CSTRING("Settings"), nsCaseInsensitiveCStringComparator())) {
              str.AssignLiteral("Eudora ");
              str.AppendWithConversion( pSection);
       }
       else {
              nsCString tStr;
              str.AssignWithConversion(pSection);
              if (s.Length() > 8) {
                     s.Left( tStr, 8); 
                     if (tStr.Equals(NS_LITERAL_CSTRING("Persona-"), nsCaseInsensitiveCStringComparator())) {
                            s.Right( tStr, s.Length() - 8);
                            str.AssignWithConversion(tStr.get());
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::GetAttachmentInfo ( const char *  pFileName,
nsIFileSpec pSpec,
nsCString mimeType,
nsCString aAttachment 
) [virtual]

Reimplemented from nsEudoraMailbox.

Definition at line 916 of file nsEudoraWin32.cpp.

{
       mimeType.Truncate();
       pSpec->SetNativePath( pFileName);
       nsresult      rv;
       PRBool        isFile = PR_FALSE;
       PRBool        exists = PR_FALSE;
       if (NS_FAILED( rv = pSpec->Exists( &exists)))
              return( rv);
       if (NS_FAILED( rv = pSpec->IsFile( &isFile)))
              return( rv);
       if (exists && isFile) {
              char *pLeaf = nsnull;
              pSpec->GetLeafName( &pLeaf);
              if (!pLeaf)
                     return( NS_ERROR_FAILURE);
              nsCString name(pLeaf);
              nsCRT::free( pLeaf);
              if (name.Length() > 4) {
                     nsCString ext;
                     PRInt32 idx = name.RFindChar( '.');
                     if (idx != -1) {
                            name.Right( ext, name.Length() - idx);
                            GetMimeTypeFromExtension( ext, mimeType);
                     }
              }
              if (mimeType.IsEmpty())
                     mimeType = "application/octet-stream";

        // Convert description to unicode.
        nsCOMPtr<nsIImportService> impSvc = do_GetService(NS_IMPORTSERVICE_CONTRACTID);
        NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get import service");
        if (NS_SUCCEEDED(rv)) {
            nsAutoString description;
            rv = impSvc->SystemStringToUnicode(name.get(), description);
            NS_ASSERTION(NS_SUCCEEDED(rv), "failed to convert system string to unicode");
            if (NS_SUCCEEDED(rv))
                aAttachmentName = NS_ConvertUTF16toUTF8(description);
        }

        if (aAttachmentName.IsEmpty())
            aAttachmentName = name;

              return( NS_OK);
       }
       
       return( NS_ERROR_FAILURE);
}

Here is the call graph for this function:

void nsEudoraWin32::GetMimeTypeFromExtension ( nsCString ext,
nsCString mimeType 
) [private]

Definition at line 1038 of file nsEudoraWin32.cpp.

{
       HKEY   sKey;
       if (::RegOpenKeyEx( HKEY_CLASSES_ROOT, ext.get(), 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS) {
              // get the value of "Current"
              BYTE *pBytes = GetValueBytes( sKey, "Content Type");
              if (pBytes) {
                     mimeType = (const char *)pBytes;
                     delete [] pBytes;
              }
              ::RegCloseKey( sKey);
       }

       if (!mimeType.IsEmpty() || !m_mailImportLocation || (ext.Length() > 10))
              return;
       
       // TLR: FIXME: We should/could cache the extension to mime type maps we find
       // and check the cache first before scanning all of eudora's mappings?

       // It's not in the registry, try and find the .ini file for Eudora's private
       // mime type list
       if (!m_pMimeSection) {
              nsIFileSpec *pSpec;
              nsresult rv = NS_NewFileSpec( &pSpec);
              if (NS_FAILED( rv) || !pSpec)
                     return;

              pSpec->FromFileSpec( m_mailImportLocation);

              pSpec->AppendRelativeUnixPath( "eudora.ini");
              PRBool exists = PR_FALSE;
              PRBool isFile = PR_FALSE;
              rv = pSpec->Exists( &exists);
              if (NS_SUCCEEDED( rv))
                     rv = pSpec->IsFile( &isFile);
              
              if (!isFile || !exists) {
                     rv = pSpec->FromFileSpec( m_mailImportLocation);
                     if (NS_FAILED( rv))
                            return;
                     if (!FindMimeIniFile( pSpec))
                            return;
              }

              char *pName = nsnull;
              pSpec->GetNativePath( &pName);
              if (!pName)
                     return;
              nsCString     fileName(pName);
              nsCRT::free( pName);

              // Read the mime map section
              DWORD  size = 1024;
              DWORD  dSize = size - 2;
              while (dSize == (size - 2)) {
                     if (m_pMimeSection)
                            delete [] m_pMimeSection;
                     size += 1024;
                     m_pMimeSection = new char[size];
                     dSize = ::GetPrivateProfileSection( "Mappings", m_pMimeSection, size, fileName.get());
              }
       }

       if (!m_pMimeSection)
              return;
       
       IMPORT_LOG1( "Looking for mime type for extension: %s\n", ext.get());

       // out/in/both=extension,mac creator,mac type,mime type1,mime type2
       const char *pExt = ext.get();
       pExt++;

       char   *      pChar = m_pMimeSection;
       char   *      pStart;
       int                  len;
       nsCString     tStr;
       for(;;) {
              while (*pChar != '=') {
                     if (!(*pChar) && !(*(pChar + 1)))
                            return;
                     pChar++;
              }
              if (*pChar)
                     pChar++;
              pStart = pChar;
              len = 0;
              while (*pChar && (*pChar != ',')) {
                     pChar++;
                     len++;
              }
              if (!*pChar) return;
              tStr.Truncate();
              tStr.Append( pStart, len);
              tStr.Trim( kWhitespace);
              if (!nsCRT::strcasecmp( tStr.get(), pExt)) {
                     // skip the mac creator and type
                     pChar++;
                     while (*pChar && (*pChar != ','))
                            pChar++;
                     if (!*pChar) return;
                     pChar++;
                     while (*pChar && (*pChar != ','))
                            pChar++;
                     if (!*pChar) return;
                     pChar++;
                     // Get the first mime type
                     len = 0;
                     pStart = pChar;
                     while (*pChar && (*pChar != ',')) {
                            pChar++;
                            len++;
                     }
                     if (!*pChar) return;
                     pChar++;
                     if (!len) continue;
                     tStr.Truncate();
                     tStr.Append( pStart, len);
                     tStr.Trim( kWhitespace);
                     if (tStr.IsEmpty()) continue;
                     mimeType.Truncate();
                     mimeType.Append( tStr.get());
                     mimeType.Append( "/");
                     pStart = pChar;
                     len = 0;
                     while (*pChar && (*pChar != 0x0D) && (*pChar != 0x0A)) {
                            pChar++;
                            len++;
                     }
                     if (!len) continue;
                     tStr.Truncate();
                     tStr.Append( pStart, len);
                     tStr.Trim( kWhitespace);
                     if (tStr.IsEmpty()) continue;
                     mimeType.Append( tStr.get());

                     IMPORT_LOG1( "Found Mime Type: %s\n", mimeType.get());

                     return;
              }
       }      
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsEudoraWin32::GetServerAndUserName ( const char *  pSection,
const char *  pIni,
nsCString serverName,
nsCString userName,
char *  pBuff 
) [static, private]

Definition at line 662 of file nsEudoraWin32.cpp.

{
       DWORD         valSize;
       int                  idx;
       nsCString     tStr;

       serverName.Truncate();
       userName.Truncate();

       valSize = ::GetPrivateProfileString( pSection, "PopServer", "", pBuff, kIniValueSize, pIni);
       if (valSize)
              serverName = pBuff;
       else {
              valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
              if (valSize) {
                     serverName = pBuff;
                     idx = serverName.FindChar( '@');
                     if (idx != -1) {
                            serverName.Right( tStr, serverName.Length() - idx - 1);
                            serverName = tStr;
                     }
              }
       }
       valSize = ::GetPrivateProfileString( pSection, "LoginName", "", pBuff, kIniValueSize, pIni);
       if (valSize)
              userName = pBuff;
       else {
              valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
              if (valSize) {
                     userName = pBuff;
                     idx = userName.FindChar( '@');
                     if (idx != -1) {
                            userName.Left( tStr, idx);
                            userName = tStr;
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

BYTE * nsEudoraWin32::GetValueBytes ( HKEY  hKey,
const char *  pValueName 
) [static, private]

Definition at line 66 of file nsEudoraWin32.cpp.

{
       LONG   err;
       DWORD  bufSz;
       LPBYTE pBytes = NULL;

       err = ::RegQueryValueEx( hKey, pValueName, NULL, NULL, NULL, &bufSz); 
       if (err == ERROR_SUCCESS) {
              pBytes = new BYTE[bufSz];
              err = ::RegQueryValueEx( hKey, pValueName, NULL, NULL, pBytes, &bufSz);
              if (err != ERROR_SUCCESS) {
                     delete [] pBytes;
                     pBytes = NULL;
              }
       }

       return( pBytes);
}

Here is the caller graph for this function:

nsresult nsEudoraAddress::ImportAddresses ( PRUint32 pBytes,
PRBool pAbort,
const PRUnichar pName,
nsIFileSpec pSrc,
nsIAddrDatabase pDb,
nsString errors 
) [inherited]

Definition at line 115 of file nsEudoraAddress.cpp.

{
       // Open the source file for reading, read each line and process it!
       
       EmptyAliases();
       
       nsresult rv = pSrc->OpenStreamForReading();
       if (NS_FAILED( rv)) {
              IMPORT_LOG0( "*** Error opening address file for reading\n");
              return( rv);
       }
       
       char *pLine = new char[kEudoraAddressBufferSz];
       PRBool wasTruncated;
       PRBool eof = PR_FALSE;
       rv = pSrc->Eof( &eof);
       if (NS_FAILED( rv)) {
              IMPORT_LOG0( "*** Error checking address file for eof\n");
              pSrc->CloseStream();
              return( rv);
       }
       
       while (!(*pAbort) && !eof && NS_SUCCEEDED( rv)) {
              wasTruncated = PR_FALSE;
              rv = pSrc->ReadLine( &pLine, kEudoraAddressBufferSz, &wasTruncated);
              if (wasTruncated)
                     pLine[kEudoraAddressBufferSz - 1] = 0;
              if (NS_SUCCEEDED( rv)) {
                     PRInt32       len = strlen( pLine);
                     ProcessLine( pLine, len, errors);
                     rv = pSrc->Eof( &eof);
                     if (pBytes)
                            *pBytes += (len / 2);
              }
       }
       
       rv = pSrc->CloseStream();
       
       delete [] pLine;

       if (!eof) {
              IMPORT_LOG0( "*** Error reading the address book, didn't reach the end\n");
              return( NS_ERROR_FAILURE);
       }
       
       // Run through the alias array and make address book entries...
       #ifdef IMPORT_DEBUG
       DumpAliasArray( m_alias);
       #endif
       
       BuildABCards( pBytes, pDb);
       
  rv = pDb->Commit(nsAddrDBCommitType::kLargeCommit);
       return rv;
}

Here is the call graph for this function:

nsresult nsEudoraMailbox::ImportMailbox ( PRUint32 pBytes,
PRBool pAbort,
const PRUnichar pName,
nsIFileSpec pSrc,
nsIFileSpec pDst,
PRInt32 pMsgCount 
) [inherited]

Definition at line 171 of file nsEudoraMailbox.cpp.

{
       nsCOMPtr<nsIFileSpec>       tocFile;
       PRBool                             deleteToc = PR_FALSE;
       nsresult                           rv;
       nsCOMPtr<nsIFileSpec>       mailFile;
       PRBool                             deleteMailFile = PR_FALSE;
       PRUint32                           div = 1;
       PRUint32                           mul = 1;

       if (pMsgCount)
              *pMsgCount = 0;

       rv = pSrc->GetFileSize( &m_mailSize);

       rv = pSrc->OpenStreamForReading();
       if (NS_FAILED( rv))
              return( rv);

       NS_ADDREF( pSrc);

       // First, get the index file for this mailbox
       rv = FindTOCFile( pSrc, getter_AddRefs( tocFile), &deleteToc);
       if (NS_SUCCEEDED( rv) && tocFile) {
              IMPORT_LOG0( "Reading euroda toc file: ");
              DUMP_FILENAME( tocFile, PR_TRUE);

              rv = CreateTempFile( getter_AddRefs( mailFile));
              deleteMailFile = PR_TRUE;
              if (NS_SUCCEEDED( rv)) {
                     // Read the TOC and compact the mailbox file into a temp file
                     rv = tocFile->OpenStreamForReading();
                     if (NS_SUCCEEDED( rv)) {
                            rv = mailFile->OpenStreamForWriting();
                            if (NS_SUCCEEDED( rv)) {
                                   // Read the toc and compact the mailbox into mailFile
                                   rv = CompactMailbox( pBytes, pAbort, pSrc, tocFile, mailFile);
                                   div = 4;
                                   mul = 3;
                            }
                     }
              }
              
              pSrc->CloseStream();

              // clean up
              if (deleteToc) {
                     DeleteFile( tocFile);
              }
              if (NS_SUCCEEDED( rv))
                     rv = mailFile->CloseStream();
              if (NS_FAILED( rv)) {
                     DeleteFile( mailFile);
                     mailFile->FromFileSpec( pSrc);
                     deleteMailFile = PR_FALSE;
                     IMPORT_LOG0( "*** Error compacting mailbox.\n");
              }
              
              IMPORT_LOG0( "Compacted mailbox: "); DUMP_FILENAME( mailFile, PR_TRUE);

              rv = mailFile->OpenStreamForReading();
              if (NS_SUCCEEDED( rv)) {
                     pSrc->Release();
                     mailFile->QueryInterface( NS_GET_IID(nsIFileSpec), (void **)&pSrc);

                     IMPORT_LOG0( "Compacting mailbox was successful\n");
              }
              else {
                     DeleteFile( mailFile);
                     deleteMailFile = PR_FALSE;
                     IMPORT_LOG0( "*** Error accessing compacted mailbox\n");
              }
       }
       
       // So, where we are now, is we have the mail file to import in pSrc
       // It may need deleting if deleteMailFile is PR_TRUE.
       // pSrc must be Released before returning
       
       // The source file contains partially constructed mail messages,
       // and attachments.  We should first investigate if we can use the mailnews msgCompose
       // stuff to do the work for us.  If not we have to scan the mailboxes and do TONS
       // of work to properly reconstruct the message - Eudora is so nice that it strips things
       // like MIME headers, character encoding, and attachments - beautiful!
       
       rv = pSrc->GetFileSize( &m_mailSize);

       nsCOMPtr<nsIFileSpec>       compositionFile;
       SimpleBufferTonyRCopiedOnce               readBuffer;
       SimpleBufferTonyRCopiedOnce               headers;
       SimpleBufferTonyRCopiedOnce               body;
       SimpleBufferTonyRCopiedOnce               copy;
       PRInt32                                   written;
       nsCString                          fromLine(eudoraFromLine);
       
       headers.m_convertCRs = PR_TRUE;
       body.m_convertCRs = PR_TRUE;
       
       copy.Allocate( kCopyBufferSize);
       readBuffer.Allocate( kMailReadBufferSize);
       ReadFileState               state;
       state.offset = 0;
       state.size = m_mailSize;
       state.pFile = pSrc;

       IMPORT_LOG0( "Reading mailbox\n");

       if (NS_SUCCEEDED( rv = NS_NewFileSpec( getter_AddRefs( compositionFile)))) {
              nsEudoraCompose             compose;
    nsCString defaultDate;
    nsCAutoString bodyType;
              
              /*
              IMPORT_LOG0( "Calling compose.SendMessage\n");
              rv = compose.SendMessage( compositionFile);
              if (NS_SUCCEEDED( rv)) {
                     IMPORT_LOG0( "Composed message in file: "); DUMP_FILENAME( compositionFile, PR_TRUE);
              }
              else {
                     IMPORT_LOG0( "*** Error composing message\n");
              }
              */

              IMPORT_LOG0( "Reading first message\n");

    while (!*pAbort && NS_SUCCEEDED( rv = ReadNextMessage( &state, readBuffer, headers, body, defaultDate, bodyType))) {
                     
                     if (pBytes) {
                            *pBytes += (((body.m_writeOffset - 1 + headers.m_writeOffset - 1) / div) * mul);
                     }

      // Unfortunately Eudora stores HTML messages in the sent folder
      // without any content type header at all. If the first line of the message body is <html>
      // then mark the message as html internally...See Bug #258489
      if (body.m_pBuffer && (body.m_writeOffset > strlen(kHTMLTag)) && (strncmp(body.m_pBuffer, kHTMLTag, strlen(kHTMLTag)) == 0 ))
        bodyType = "text/html"; // ignore whatever body type we were given...force html

      compose.SetBody( body.m_pBuffer, body.m_writeOffset - 1, bodyType);
                     compose.SetHeaders( headers.m_pBuffer, headers.m_writeOffset - 1);
                     compose.SetAttachments( &m_attachments);
      compose.SetDefaultDate(defaultDate);

                     rv = compose.SendTheMessage( compositionFile);
                     if (NS_SUCCEEDED( rv)) {
                            /* IMPORT_LOG0( "Composed message in file: "); DUMP_FILENAME( compositionFile, PR_TRUE); */
                            // copy the resulting file into the destination file!
                            rv = compose.CopyComposedMessage( fromLine, compositionFile, pDst, copy);
                            DeleteFile( compositionFile);
                            if (NS_FAILED( rv)) {
                                   IMPORT_LOG0( "*** Error copying composed message to destination mailbox\n");
                                   break;
                            }
                            if (pMsgCount)
                                   (*pMsgCount)++;
                     }
                     else {
                            IMPORT_LOG0( "*** Error composing message, writing raw message\n");
                            rv = WriteFromSep( pDst);
                            
                            rv = pDst->Write( kComposeErrorStr,
                                                               strlen( kComposeErrorStr),
                                                               &written );
                            
                            if (NS_SUCCEEDED( rv))
                                   rv = pDst->Write( headers.m_pBuffer, headers.m_writeOffset - 1, &written);
                            if (NS_SUCCEEDED( rv) && (written == (headers.m_writeOffset - 1)))
                                   rv = pDst->Write( "\x0D\x0A" "\x0D\x0A", 4, &written);
                            if (NS_SUCCEEDED( rv) && (written == 4))
                                   rv = pDst->Write( body.m_pBuffer, body.m_writeOffset - 1, &written);
                            if (NS_SUCCEEDED( rv) && (written == (body.m_writeOffset - 1))) {
                                   rv = pDst->Write( "\x0D\x0A", 2, &written);
                                   if (written != 2)
                                          rv = NS_ERROR_FAILURE;
                            }
                            
                            if (NS_FAILED( rv)) {
                                   IMPORT_LOG0( "*** Error writing to destination mailbox\n");
                                   break;
                            }
                     }

                     if (!readBuffer.m_bytesInBuf && (state.offset >= state.size))
                            break;
              }
              
       }
       else {
              IMPORT_LOG0( "*** Error creating file spec for composition\n");
       }

       if (deleteMailFile)
              DeleteFile( pSrc);
       
       pSrc->Release();

       return( rv);
}

Here is the call graph for this function:

PRBool nsEudoraWin32::ImportSettings ( nsIFileSpec pIniFile,
nsIMsgAccount **  localMailAccount 
) [static]

Definition at line 556 of file nsEudoraWin32.cpp.

{
       PRBool        result = PR_FALSE;
       nsresult      rv;

       nsCOMPtr<nsIMsgAccountManager> accMgr = 
                do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
    if (NS_FAILED(rv)) {
              IMPORT_LOG0( "*** Failed to create a account manager!\n");
              return( PR_FALSE);
       }

       // Eudora info is arranged by key, 1 for the default, then persona's for additional
       // accounts.
       // Start with the first one, then do each persona
       char *pIniPath = nsnull;
       pIniFile->GetNativePath( &pIniPath);
       if (!pIniPath)
              return( PR_FALSE);

       nsCString     iniPath(pIniPath);
       nsCRT::free( pIniPath);
       
       UINT                 valInt;
       SimpleBufferTonyRCopiedOnce section;
       DWORD                sSize;
       DWORD                sOffset = 0;
       DWORD                start;
       nsCString            sectionName("Settings");
       int                         popCount = 0;
       int                         accounts = 0;
       
       DWORD  allocSize = 0;
       do {
              allocSize += 2048;
              section.Allocate( allocSize);
              sSize = ::GetPrivateProfileSection( "Personalities", section.m_pBuffer, allocSize, iniPath.get());
       } while (sSize == (allocSize - 2));
       
       nsIMsgAccount *      pAccount;

       do {
              if (!sectionName.IsEmpty()) {
                     pAccount = nsnull;
                     valInt = ::GetPrivateProfileInt( sectionName.get(), "UsesPOP", 1, iniPath.get());
                     if (valInt) {
                            // This is a POP account
                            if (BuildPOPAccount( accMgr, sectionName.get(), iniPath.get(), &pAccount)) {
                                   accounts++;
                                   popCount++;
                                   if (popCount > 1) {
                                          if (localMailAccount && *localMailAccount) {
                                                 NS_RELEASE( *localMailAccount);
                                                 *localMailAccount = nsnull;
                                          }
                                   }
                                   else {
                                          if (localMailAccount) {
                                                 *localMailAccount = pAccount;
                                                 NS_IF_ADDREF( pAccount);
                                          }                                  
                                   }
                            }
                     }
                     else {
                            valInt = ::GetPrivateProfileInt( sectionName.get(), "UsesIMAP", 0, iniPath.get());
                            if (valInt) {
                                   // This is an IMAP account
                                   if (BuildIMAPAccount( accMgr, sectionName.get(), iniPath.get(), &pAccount)) {
                                          accounts++;
                                   }
                            }
                     }
                     if (pAccount && (sOffset == 0)) {
                            accMgr->SetDefaultAccount( pAccount);
                     }

                     NS_IF_RELEASE( pAccount);
              }
                            
              sectionName.Truncate();
              while ((sOffset < sSize) && (section.m_pBuffer[sOffset] != '='))
                     sOffset++;
              sOffset++;
              start = sOffset;
              while ((sOffset < sSize) && (section.m_pBuffer[sOffset] != 0))
                     sOffset++;
              if (sOffset > start) {
                     sectionName.Append( section.m_pBuffer + start, sOffset - start);
                     sectionName.Trim( kWhitespace);
              }

       } while (sOffset < sSize);

       // Now save the new acct info to pref file.
       rv = accMgr->SaveAccountInfo();
       NS_ASSERTION(NS_SUCCEEDED(rv), "Can't save account info to pref file");


       return( accounts != 0);
}

Here is the call graph for this function:

PRInt32 nsEudoraMailbox::IsEudoraFromSeparator ( const char *  pData,
PRInt32  maxLen,
nsCString defaultDate 
) [static, inherited]

Definition at line 778 of file nsEudoraMailbox.cpp.

{
       if (maxLen < 12)
              return( -1);

       PRInt32              len = 0;
       if ((*pChar != 'F') || (*(pChar + 1) != 'r') || (*(pChar + 2) != 'o') || (*(pChar + 3) != 'm'))
              return( -1);
       pChar += 4;
       len += 4;

       // According to Eudora the next char MUST be a space, and there can only be 1 space 
       // before the return mail address.
       // I'll be nicer and allow any amount of whitespace
       while (((*pChar == ' ') || (*pChar == '\t')) && (len < maxLen)) {
              pChar++;
              len++;
       }
       if (len == maxLen)
              return( -1);
       
       // Determine the length of the line
       PRInt32                     lineLen = len;
       const char *  pTok = pChar;
       while ((lineLen < maxLen) && (*pTok != 0x0D) && (*pTok != 0x0A)) {
              lineLen++;
              pTok++;
       }

       if (len >= lineLen)
              return( -1);

       // Eudora allows the return address to be double quoted or not at all..
       // I'll allow single or double quote, but other than that, just skip
       // the return address until you hit a space char (I allow tab as well)
       char   quote = *pChar;
       if ((quote == '"') || (quote == '\'')) {
              pChar++;
              len++;
              while ((len < lineLen) && (*pChar != quote)) {
                     pChar++;
                     len++;
              }
              if (len == lineLen)
                     return( -1);
              len++;
              pChar++;
       }
       else {
              while ((len < lineLen) && (*pChar != ' ') && (*pChar != '\t')) {
                     pChar++;
                     len++;
              }
       }
       while (((*pChar == ' ') || (*pChar == '\t')) && (len < lineLen)) {
              pChar++;
              len++;
       }
       if (len == lineLen)
              return( -1);
       
       // we've passed the address, now check for the remaining data  
       // Now it gets really funky!
       // In no particular order, with token separators space, tab, comma, newline
       // a - the phrase "remote from", remote must be first, from is optional.  2 froms or 2 remotes fails
       // b - one and only one time value xx:xx or xx:xx:xx
       // c - one and only one day, 1 to 31
       // d - one and only one year, 2 digit anything or 4 digit > 1900
       // e - one and only one weekday, 3 letter abreviation
       // f - one and only one month, 3 letter abreviation
       // 2 allowable "other" tokens
       // to be valid, day, year, month, & tym must exist and other must be less than 3
       
       int           day = 0;
       int           month = 0;
       int           year = 0;
       int           weekDay = 0;
       int           other = 0;
       int           result;
       char   tymStr[9];  // Make it a null terminated string (used in PR_snprintf() call()).
       PRBool tym = PR_FALSE;
       PRBool remote = PR_FALSE;
       PRBool from = PR_FALSE;
       PRInt32       tokLen;
       PRInt32       tokStart;
       PRInt32       num;

       while ((len < lineLen) && (other < 3)) {
              pTok = pChar;
              tokStart = len;
              while ((len < lineLen) && (*pChar != ' ') && (*pChar != '\t') && (*pChar != ',')) {
                     pChar++;
                     len++;
              }
              tokLen = len - tokStart;
              if (tokLen) {
                     num = AsciiToLong( pTok, tokLen);
                     if ((tokLen == 3) && ((result = IsWeekDayStr( pTok)) != 0)) {
                            if (weekDay)
                                   return( -1);
                            weekDay = result;
                     }             
                     else if ((tokLen == 3) && ((result = IsMonthStr( pTok)) != 0)) {
                            if (month)
                                   return( -1);
                            month = result;
                     }
                     else if ((tokLen == 6) && !nsCRT::strncasecmp( pTok, "remote", 6)) {
                            if (remote || from)
                                   return( -1);
                            remote = PR_TRUE;
                     } 
                     else if ((tokLen == 4) && !nsCRT::strncasecmp( pTok, "from", 4)) {
                            if (!remote || from)
                                   return( -1);
                            from = PR_TRUE;
                     }
                     else if ((tokLen == 4) && ((num > 1900) || !nsCRT::strncmp( pTok, "0000", 4))) {
                            if (year)
                                   return( -1);
                            year = (int)num;
                            if (!year)
                                   year = 1900;
                     }
                     else if (!year && day && (tokLen == 2) && (*(pTok + 1) >= '0') && (*(pTok + 1) <= '9')) {
                            if (num < 65)
                                   num += 1900;
                            else
                                   num += 2000;
                             year = (int) num;
                     }
                     else if ((tokLen <= 2) && (*pTok >= '0') && (*pTok <= '9')) {
                            day = (int) num;
                            if ((day < 1) || (day > 31))
                                   day = 1;
                     }
                     else if ((tokLen >= 5) && (pTok[2] == ':') && ((tokLen == 5) || ((tokLen == 8) && (pTok[5] == ':')))) {
                            // looks like the tym...
                            for (result = 0; result < (int)tokLen; result++) {
                                   if ((result != 2) && (result != 5)) {
                                          if ((pTok[result] < '0') || (pTok[result] > '9')) {
                                                 break;
                                          }
                                   }
                            }
                            if (result == tokLen) {
                                   if (tym)
                                          return( -1);
                                   tym = PR_TRUE;
                                   // for future use, get the time value
                                   memcpy( tymStr, pTok, tokLen);
                                   if (tokLen == 5) {
                                          tymStr[5] = ':';
                                          tymStr[6] = '0';
                                          tymStr[7] = '0';
                                   }
          tymStr[8] = 0;
                            }
                            else {
                                   other++;
                            }
                     }
                     else
                            other++;
              }      
              // Skip the space chars...
              while ((len < lineLen) && ((*pChar == ' ') || (*pChar == '\t') || (*pChar == ','))) {
                     pChar++;
                     len++;
              }
       } // end while (len < lineLen) token loop
       
       // Now let's see what we found on the line
       if (day && year && month && tym && (other < 3)) {
              // Now we need to make sure the next line
              // isn't blank!
              while (len < lineLen) {
                     len++;
                     pChar++;
              }
              if (len == maxLen)
                     return( -1);
              
              if (*pChar == 0x0D) {
                     len++;
                     pChar++;
                     if (*pChar == 0x0A) {
                            len++;
                            pChar++;
                     }
              }
              else if (*pChar == 0x0A) {
                     len++;
                     pChar++;
              }
              else
                     return( -1);
              if (len >= maxLen)
                     return( -1);

              while (len < maxLen) {
                     if ((*pChar == 0x0D) || (*pChar == 0x0A))
                            return( -1);
                     if ((*pChar != ' ') && (*pChar != '\t'))
                            break;
                     pChar++;
                     len++;
              }

              // Whew!, the next line isn't blank.
    // Generate the default date header in case the date header is missing when we
    // write out headers later. The header looks like "Date: Tue, 5 Feb 2002 23:05:04"
    char date_header_str[DATE_STR_LEN];
    PR_snprintf(date_header_str, DATE_STR_LEN, "Date: %s, %2d %s %4d %s", eudoraWeekDays[weekDay-1], day, eudoraMonths[month-1], year, tymStr);
    defaultDate.Assign(date_header_str);

              return( lineLen);
       }
       
       return( -1);

}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEudoraMailbox::IsEudoraTag ( const char *  pChar,
PRInt32  maxLen,
PRBool insideEudoraTags,
nsCString bodyType,
PRInt32 tagLength 
) [static, inherited]

Definition at line 757 of file nsEudoraMailbox.cpp.

{
       PRInt32       idx = 0;
       while ((tagLength = eudoraTagLen[idx]) != 0) {
              if (maxLen >= tagLength && !nsCRT::strncmp( eudoraTag[idx], pChar, tagLength)) {
                     insideEudoraTags = (pChar[1] != '/');
                     bodyType = TagContentType[idx];
                     return PR_TRUE;
              }
              idx++;
       }

       return PR_FALSE;
}

Here is the caller graph for this function:

nsresult nsEudoraWin32::IterateMailDir ( nsIFileSpec pFolder,
nsISupportsArray pArray,
nsIImportService pImport 
) [private]

Definition at line 243 of file nsEudoraWin32.cpp.

{
       nsCOMPtr<nsIDirectoryIterator>     dir;
       nsresult rv = NS_NewDirectoryIterator( getter_AddRefs( dir));
       if (NS_FAILED( rv))
              return( rv);

       PRBool exists = PR_FALSE;
       rv = dir->Init( pFolder, PR_TRUE);
       if (NS_FAILED( rv))
              return( rv);

       rv = dir->Exists( &exists);
       if (NS_FAILED( rv))
              return( rv);
       
       PRBool                             isFolder;
       PRBool                             isFile;
       nsCOMPtr<nsIFileSpec>       entry;
       char *                             pName;
       nsCString                          fName;
       nsCString                          ext;
       nsCString                          name;

       while (exists && NS_SUCCEEDED( rv)) {
              rv = dir->GetCurrentSpec( getter_AddRefs( entry));
              if (NS_SUCCEEDED( rv)) {
                     rv = entry->GetLeafName( &pName);
                     if (NS_SUCCEEDED( rv) && pName) {
                            fName = pName;
                            nsCRT::free( pName);
                            if (fName.Length() > 4) {
                                   fName.Right( ext, 4);
                                   fName.Left( name, fName.Length() - 4);
                            }
                            else {
                                   ext.Truncate();
                                   name = fName;
                            }
                            ToLowerCase(ext);
                            if (ext.EqualsLiteral(".fol")) {
                                   isFolder = PR_FALSE;
                                   entry->IsDirectory( &isFolder);
                                   if (isFolder) {
                                          // add the folder
                                          rv = FoundMailFolder( entry, name.get(), pArray, pImport);
                                          if (NS_SUCCEEDED( rv)) {
                                                 rv = ScanMailDir( entry, pArray, pImport);
                                                 if (NS_FAILED( rv)) {
                                                        IMPORT_LOG0( "*** Error scanning mail directory\n");
                                                 }
                                          }
                                   }
                            }
                            else if (ext.EqualsLiteral(".mbx")) {
                                   isFile = PR_FALSE;
                                   entry->IsFile( &isFile);
                                   if (isFile) {
                                          rv = FoundMailbox( entry, name.get(), pArray, pImport);
                                   }
                            }
                     }                           
              }

              rv = dir->Next();
              if (NS_SUCCEEDED( rv))
                     rv = dir->Exists( &exists);
       }

       return( rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::ScanAddressDir ( nsIFileSpec pDir,
nsISupportsArray pArray,
nsIImportService impSvc 
) [private]

Definition at line 1325 of file nsEudoraWin32.cpp.

{
       nsCOMPtr<nsIDirectoryIterator>     dir;
       nsresult rv = NS_NewDirectoryIterator( getter_AddRefs( dir));
       if (NS_FAILED( rv))
              return( rv);

       PRBool exists = PR_FALSE;
       rv = dir->Init( pDir, PR_TRUE);
       if (NS_FAILED( rv))
              return( rv);

       rv = dir->Exists( &exists);
       if (NS_FAILED( rv))
              return( rv);
       
       PRBool                             isFile;
       nsCOMPtr<nsIFileSpec>       entry;
       char *                             pName;
       nsCString                          fName;
       nsCString                          ext;
       nsCString                          name;

       while (exists && NS_SUCCEEDED( rv)) {
              rv = dir->GetCurrentSpec( getter_AddRefs( entry));
              if (NS_SUCCEEDED( rv)) {
                     rv = entry->GetLeafName( &pName);
                     if (NS_SUCCEEDED( rv) && pName) {
                            fName = pName;
                            nsCRT::free( pName);
                            if (fName.Length() > 4) {
                                   fName.Right( ext, 4);
                                   fName.Left( name, fName.Length() - 4);
                            }
                            else {
                                   ext.Truncate();
                                   name = fName;
                            }
                            ToLowerCase(ext);
                            if (ext.EqualsLiteral(".txt")) {
                                   isFile = PR_FALSE;
                                   entry->IsFile( &isFile);
                                   if (isFile) {
                                          rv = FoundAddressBook( entry, nsnull, pArray, impSvc);
                                          if (NS_FAILED( rv))
                                                 return( rv);
                                   }
                            }
                     }                           
              }
              
              rv = dir->Next();
              if (NS_SUCCEEDED( rv))
                     rv = dir->Exists( &exists);
       }

       return( rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::ScanDescmap ( nsIFileSpec pFolder,
nsISupportsArray pArray,
nsIImportService pImport,
const char *  pData,
PRInt32  len 
) [private]

Definition at line 315 of file nsEudoraWin32.cpp.

{
       // use this to find stuff in the directory.

       nsCOMPtr<nsIFileSpec>       entry;
       nsresult                           rv;

       if (NS_FAILED( rv = NS_NewFileSpec( getter_AddRefs( entry))))
              return( rv);
       
       // format is Name,FileName,Type,Flag?
       //     Type = M or S for mailbox
       //             = F for folder

       PRInt32                     fieldLen;
       PRInt32                     pos = 0;
       const char *  pStart;
       nsCString            name;
       nsCString            fName;
       nsCString            type;
       nsCString            flag;
       PRBool               isFile;
       PRBool               isFolder;
       while (pos < len) {
              pStart = pData;
              fieldLen = 0;
              while ((pos < len) && (*pData != ',')) {
                     pos++;
                     pData++;
                     fieldLen++;
              }
              name.Truncate();
              if (fieldLen)
                     name.Append( pStart, fieldLen);
              name.Trim( kWhitespace);
              pos++;
              pData++;
              pStart = pData;
              fieldLen = 0;
              while ((pos < len) && (*pData != ',')) {
                     pos++;
                     pData++;
                     fieldLen++;
              }
              fName.Truncate();
              if (fieldLen)
                     fName.Append( pStart, fieldLen);
                // Descmap file name is written without any extraneous white space - i.e.
                // if there's whitespace present it's intentional and important. Don't
                // strip whitespace from the fName.
              pos++;
              pData++;
              pStart = pData;
              fieldLen = 0;
              while ((pos < len) && (*pData != ',')) {
                     pos++;
                     pData++;
                     fieldLen++;
              }
              type.Truncate();
              if (fieldLen)
                     type.Append( pStart, fieldLen);           
              type.Trim( kWhitespace);
              pos++;
              pData++;
              pStart = pData;
              fieldLen = 0;
              while ((pos < len) && (*pData != 0x0D) && (*pData != 0x0A) && (*pData != ',')) {
                     pos++;
                     pData++;
                     fieldLen++;
              }
              flag.Truncate();
              if (fieldLen)
                     flag.Append( pStart, fieldLen);           
              flag.Trim( kWhitespace);
              while ((pos < len) && ((*pData == 0x0D) || (*pData == 0x0A))) {
                     pos++;
                     pData++;
              }

              IMPORT_LOG2( "name: %s, fName: %s\n", name.get(), fName.get());

              if (!fName.IsEmpty() && !name.IsEmpty() && (type.Length() == 1)) {
                     entry->FromFileSpec( pFolder);
                     rv = entry->AppendRelativeUnixPath( fName.get());
                     if (NS_SUCCEEDED( rv)) {
                            if (type.CharAt( 0) == 'F') {
                                   isFolder = PR_FALSE;
                                   entry->IsDirectory( &isFolder);
                                   if (isFolder) {
                                          rv = FoundMailFolder( entry, name.get(), pArray, pImport);
                                          if (NS_SUCCEEDED( rv)) {
                                                 rv = ScanMailDir( entry, pArray, pImport);
                                                 if (NS_FAILED( rv)) {
                                                        IMPORT_LOG0( "*** Error scanning mail directory\n");
                                                 }
                                          }
                                   }
                            }
                            else if ((type.CharAt( 0) == 'M') || (type.CharAt( 0) == 'S')) {
                                   isFile = PR_FALSE;
                                   entry->IsFile( &isFile);
                                   if (isFile) {
                                          FoundMailbox( entry, name.get(), pArray, pImport);
                                   }
                            }
                     }
              }
       }

       return( NS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsEudoraWin32::ScanMailDir ( nsIFileSpec pFolder,
nsISupportsArray pArray,
nsIImportService pImport 
) [private]

Definition at line 203 of file nsEudoraWin32.cpp.

{
       PRBool                             exists = PR_FALSE;
       PRBool                             isFile = PR_FALSE;
       char *                             pContents = nsnull;
       PRInt32                                   len = 0;
       nsCOMPtr<nsIFileSpec>       descMap;
       nsresult                           rv;

       if (NS_FAILED( rv = NS_NewFileSpec( getter_AddRefs( descMap))))
              return( rv);

       m_depth++;

       descMap->FromFileSpec( pFolder);
       rv = descMap->AppendRelativeUnixPath( "descmap.pce");
       if (NS_SUCCEEDED( rv))
              rv = descMap->IsFile( &isFile);
       if (NS_SUCCEEDED( rv))
              rv = descMap->Exists( &exists);
       if (NS_SUCCEEDED( rv) && exists && isFile) {
              rv = descMap->GetFileContents( &pContents);
              if (NS_SUCCEEDED( rv) && pContents) {
                     len = strlen( pContents);   
                     if (NS_SUCCEEDED( rv))
                            rv = ScanDescmap( pFolder, pArray, pImport, pContents, len);
                     nsCRT::free( pContents);
              }
              else
                     rv = NS_ERROR_FAILURE;
       }

       if (NS_FAILED( rv) || !isFile || !exists)
              rv = IterateMailDir( pFolder, pArray, pImport);
       
       m_depth--;

       return( rv);                
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsEudoraWin32::SetIdentities ( nsIMsgAccountManager accMgr,
nsIMsgAccount acc,
const char *  pSection,
const char *  pIniFile,
const char *  userName,
const char *  serverName,
char *  pBuff 
) [static, private]

Definition at line 847 of file nsEudoraWin32.cpp.

{
       nsCAutoString realName;
       nsCAutoString email;
       nsCAutoString server;
       DWORD         valSize;
       nsresult      rv;

       valSize = ::GetPrivateProfileString( pSection, "RealName", "", pBuff, kIniValueSize, pIniFile);
       if (valSize)
              realName = pBuff;
       valSize = ::GetPrivateProfileString( pSection, "SMTPServer", "", pBuff, kIniValueSize, pIniFile);
       if (valSize)
              server = pBuff;
       valSize = ::GetPrivateProfileString( pSection, "ReturnAddress", "", pBuff, kIniValueSize, pIniFile);
       if (valSize)
              email = pBuff;
       
       nsCOMPtr<nsIMsgIdentity>    id;
       rv = accMgr->CreateIdentity( getter_AddRefs( id));
       if (id) {
              nsAutoString fullName; 
              fullName.AssignWithConversion(realName.get());
              id->SetFullName( fullName.get());
              id->SetIdentityName( fullName.get());
              if (email.IsEmpty()) {
                     email = userName;
                     email += "@";
                     email += serverName;
              }
              id->SetEmail(email.get());
              acc->AddIdentity( id);

              IMPORT_LOG0( "Created identity and added to the account\n");
              IMPORT_LOG1( "\tname: %s\n", realName.get());
              IMPORT_LOG1( "\temail: %s\n", email.get());
       }

       SetSmtpServer( accMgr, acc, server.get(), userName);
              
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsEudoraWin32::SetSmtpServer ( nsIMsgAccountManager pMgr,
nsIMsgAccount pAcc,
const char *  pServer,
const char *  pUser 
) [static, private]

Definition at line 890 of file nsEudoraWin32.cpp.

{
       nsresult      rv;
       
       nsCOMPtr<nsISmtpService> smtpService(do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv)); 
       if (NS_SUCCEEDED(rv) && smtpService) {
              nsCOMPtr<nsISmtpServer>            foundServer;
       
              rv = smtpService->FindServer( pUser, pServer, getter_AddRefs( foundServer));
              if (NS_SUCCEEDED( rv) && foundServer) {
                     IMPORT_LOG1( "SMTP server already exists: %s\n", pServer);
                     return;
              }
              nsCOMPtr<nsISmtpServer>            smtpServer;
              
              rv = smtpService->CreateSmtpServer( getter_AddRefs( smtpServer));
              if (NS_SUCCEEDED( rv) && smtpServer) {
                     smtpServer->SetHostname( pServer);
                     if (pUser)
                            smtpServer->SetUsername( pUser);

                     IMPORT_LOG1( "Created new SMTP server: %s\n", pServer);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 110 of file nsEudoraWin32.h.

Definition at line 108 of file nsEudoraWin32.h.

Definition at line 109 of file nsEudoraWin32.h.

Definition at line 111 of file nsEudoraWin32.h.


The documentation for this class was generated from the following files: