Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
nsOEScanBoxes Class Reference

#include <nsOEScanBoxes.h>

Collaboration diagram for nsOEScanBoxes:
Collaboration graph
[legend]

List of all members.

Classes

struct  MailboxEntry

Public Member Functions

 nsOEScanBoxes ()
 ~nsOEScanBoxes ()
PRBool GetMailboxes (nsIFileSpec *pWhere, nsISupportsArray **pArray)

Static Public Member Functions

static PRBool FindMail (nsIFileSpec *pWhere)

Private Member Functions

void Reset (void)
PRBool FindMailBoxes (nsIFileSpec *descFile)
PRBool Find50MailBoxes (nsIFileSpec *descFile)
void ScanMailboxDir (nsIFileSpec *srcDir)
PRBool Scan50MailboxDir (nsIFileSpec *srcDir)
MailboxEntryGetIndexEntry (PRUint32 index)
void AddChildEntry (MailboxEntry *pEntry, PRUint32 rootIndex)
MailboxEntryNewMailboxEntry (PRUint32 id, PRUint32 parent, const char *prettyName, char *pFileName)
void ProcessPendingChildEntries (PRUint32 parent, PRUint32 rootIndex, nsVoidArray &childArray)
void RemoveProcessedChildEntries ()
PRBool ReadLong (nsIFileSpec *stream, PRInt32 &val, PRUint32 offset)
PRBool ReadLong (nsIFileSpec *stream, PRUint32 &val, PRUint32 offset)
PRBool ReadString (nsIFileSpec *stream, nsString &str, PRUint32 offset)
PRBool ReadString (nsIFileSpec *stream, nsCString &str, PRUint32 offset)
PRUint32 CountMailboxes (MailboxEntry *pBox)
void BuildMailboxList (MailboxEntry *pBox, nsIFileSpec *root, PRInt32 depth, nsISupportsArray *pArray)
PRBool GetMailboxList (nsIFileSpec *root, nsISupportsArray **pArray)

Static Private Member Functions

static PRBool Find50Mail (nsIFileSpec *pWhere)

Private Attributes

MailboxEntrym_pFirst
nsVoidArray m_entryArray
nsVoidArray m_pendingChildArray
nsCOMPtr< nsIImportServicemService

Detailed Description

Definition at line 49 of file nsOEScanBoxes.h.


Class Documentation

struct nsOEScanBoxes::MailboxEntry

Definition at line 60 of file nsOEScanBoxes.h.

Collaboration diagram for nsOEScanBoxes::MailboxEntry:
Class Members
PRInt32 child
nsCString fileName
PRUint32 index
nsString mailName
PRUint32 parent
PRBool processed
PRInt32 sibling
PRInt32 type

Constructor & Destructor Documentation

Definition at line 59 of file nsOEScanBoxes.cpp.

Definition at line 64 of file nsOEScanBoxes.cpp.

{
       int i, max;
  MailboxEntry *pEntry;
       for (i = 0, max = m_entryArray.Count(); i < max; i++) {
              pEntry = (MailboxEntry *) m_entryArray.ElementAt( i);
              delete pEntry;
       }
  // Now free the unprocessed child entries (ie, those without parents for some reason).
  for (i = 0, max = m_pendingChildArray.Count(); i < max; i++)
  {
    pEntry = (MailboxEntry *) m_pendingChildArray.ElementAt(i);
    if (!pEntry->processed)
      delete pEntry;
  }
}

Member Function Documentation

void nsOEScanBoxes::AddChildEntry ( MailboxEntry pEntry,
PRUint32  rootIndex 
) [private]

Definition at line 516 of file nsOEScanBoxes.cpp.

{
       if (!m_pFirst) {
              if (pEntry->parent == rootIndex) {
                     m_pFirst = pEntry;
                     m_entryArray.AppendElement( pEntry);
              }
              else {
                     delete pEntry;
              }
              return;
       }
       
       MailboxEntry *       pParent = nsnull;
       MailboxEntry *       pSibling = nsnull;
       if (pEntry->parent == rootIndex) {
              pSibling = m_pFirst;
       }
       else {
              pParent = GetIndexEntry( pEntry->parent);
       }
       
       if (!pParent && !pSibling) {
              delete pEntry;
              return;
       }

       if (pParent && (pParent->child == 0)) {
              pParent->child = pEntry->index;
              m_entryArray.AppendElement( pEntry);
              return;
       }
       
       if (!pSibling)
              pSibling = GetIndexEntry( pParent->child);

       while (pSibling && (pSibling->sibling != -1)) {
              pSibling = GetIndexEntry( pSibling->sibling);
       }

       if (!pSibling) {
              delete pEntry;
              return;
       }

       pSibling->sibling = pEntry->index;
       m_entryArray.AppendElement( pEntry);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsOEScanBoxes::BuildMailboxList ( MailboxEntry pBox,
nsIFileSpec root,
PRInt32  depth,
nsISupportsArray pArray 
) [private]

Definition at line 745 of file nsOEScanBoxes.cpp.

{
       if (pBox == nsnull) {
              if (m_pFirst != nsnull) {
                     pBox = m_pFirst;
                     
                     IMPORT_LOG0( "Assigning start of mailbox list to m_pFirst\n");
              }
              else {
                     if (m_entryArray.Count() > 0) {
                            pBox = (MailboxEntry *) m_entryArray.ElementAt( 0);
       
                            IMPORT_LOG0( "Assigning start of mailbox list to entry at index 0\n");
                     }
              }
              
              if (pBox == nsnull) {
                     IMPORT_LOG0( "ERROR ASSIGNING STARTING MAILBOX\n");
              }
              
       }
       
       nsresult                                         rv;
       nsIFileSpec *                             file;
       MailboxEntry *                                   pChild;
       nsIImportMailboxDescriptor *       pID;
       nsISupports *                             pInterface;
       PRUint32                                         size;
       
       nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
       if (NS_FAILED( rv))
              return;
       
       while (pBox) {
              rv = impSvc->CreateNewMailboxDescriptor( &pID);
              if (NS_SUCCEEDED( rv)) {
                     pID->SetDepth( depth);
                     pID->SetIdentifier( pBox->index);
                     pID->SetDisplayName( (PRUnichar *)pBox->mailName.get());
                     if (!pBox->fileName.IsEmpty()) {
                            pID->GetFileSpec( &file);
                            file->FromFileSpec( root);
                            file->AppendRelativeUnixPath( pBox->fileName.get());
                            size = 0;
                            file->GetFileSize( &size);
                            pID->SetSize( size);
                            file->Release();
                     }
                     rv = pID->QueryInterface( kISupportsIID, (void **) &pInterface);
                     pArray->AppendElement( pInterface);
                     pInterface->Release();
                     pID->Release();
              }
              
              if (pBox->child) {
                     pChild = GetIndexEntry( pBox->child);
                     if (pChild != nsnull)
                            BuildMailboxList( pChild, root, depth + 1, pArray);
              }
              if (pBox->sibling != -1) {
                     pBox = GetIndexEntry( pBox->sibling);
              }
              else
                     pBox = nsnull;
       }
       
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 702 of file nsOEScanBoxes.cpp.

{
       if (pBox == nsnull) {
              if (m_pFirst != nsnull)
                     pBox = m_pFirst;
              else {
                     if (m_entryArray.Count() > 0)
                            pBox = (MailboxEntry *) m_entryArray.ElementAt( 0);
              }
       }
       PRUint32             count = 0;
       
       MailboxEntry *       pChild;
       while (pBox) {
              count++;
              if (pBox->child) {
                     pChild = GetIndexEntry( pBox->child);
                     if (pChild != nsnull)
                            count += CountMailboxes( pChild);
              }
              if (pBox->sibling != -1) {
                     pBox = GetIndexEntry( pBox->sibling);
              }
              else
                     pBox = nsnull;
       }
       
       return( count);
}

Here is the call graph for this function:

PRBool nsOEScanBoxes::Find50Mail ( nsIFileSpec pWhere) [static, private]

Definition at line 90 of file nsOEScanBoxes.cpp.

{
       nsresult      rv;
       PRBool        success = PR_FALSE;
       HKEY          sKey;

       if (::RegOpenKeyEx( HKEY_CURRENT_USER, "Identities", 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS) {
              BYTE * pBytes = nsOERegUtil::GetValueBytes( sKey, "Default User ID");
              ::RegCloseKey( sKey);
              if (pBytes) {
                     nsCString     key( "Identities\\");
                     key += (const char *)pBytes;
                     nsOERegUtil::FreeValueBytes( pBytes);
                     key += "\\Software\\Microsoft\\Outlook Express\\5.0";
                     if (::RegOpenKeyEx( HKEY_CURRENT_USER, key.get(), 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS) {
                            pBytes = nsOERegUtil::GetValueBytes( sKey, "Store Root");
                            if (pBytes) {
                                   pWhere->SetNativePath((char *)pBytes);
                                   
                                   IMPORT_LOG1( "Setting native path: %s\n", pBytes);

                                   nsOERegUtil::FreeValueBytes( pBytes);
                                   PRBool isDir = PR_FALSE;
                                   rv = pWhere->IsDirectory( &isDir);
                                   if (isDir && NS_SUCCEEDED( rv))
                                          success = PR_TRUE;
                            }
                            ::RegCloseKey( sKey);
                     }
              }
       }
       
       return( success);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 308 of file nsOEScanBoxes.cpp.

{
       Reset();
       
       nsresult      rv;
       PRBool        isFile = PR_FALSE;
       
       rv = descFile->IsFile( &isFile);
       if (NS_FAILED( rv) || !isFile)
              return( PR_FALSE);
       
       rv = descFile->OpenStreamForReading();    
       if (NS_FAILED( rv))
              return( PR_FALSE);

       IMPORT_LOG0( "Reading the folders.dbx file\n");
       
       PRUint32 *           pIndex;
       PRUint32             indexSize = 0;
       if (!nsOE5File::ReadIndex( descFile, &pIndex, &indexSize)) {
              IMPORT_LOG0( "*** NOT USING FOLDERS.DBX!!!\n");
              return( PR_FALSE);
       }
       
       PRUint32      marker;
       PRUint32      size;
       char   *      pBytes;
       PRInt32              cntRead;
       PRInt32              recordId;
       PRInt32              strOffset;

       PRUint8              tag;
       PRUint32      data;
       PRInt32              dataOffset;
       
       PRUint32             id;
       PRUint32             parent;
       PRUint32             numMessages;
       char *               pFileName;
       char *               pDataSource;

       MailboxEntry *       pEntry;
       MailboxEntry *       pLastEntry = nsnull;

       PRUint32      localStoreId = 0;

       for (PRUint32 i = 0; i < indexSize; i++) {
              if (!ReadLong( descFile, marker, pIndex[i])) continue;
              if (marker != pIndex[i]) continue;
              if (!ReadLong( descFile, size, pIndex[i] + 4)) continue;
              size += 4;
              pBytes = new char[size];
              rv = descFile->Read( &pBytes, size, &cntRead);
              if (NS_FAILED( rv) || ((PRUint32)cntRead != size)) {
                     delete [] pBytes;
                     continue;
              }
              recordId = pBytes[2];
              strOffset = (recordId * 4) + 4;
              if (recordId == 4)
                     strOffset += 4;
              
              id = 0;
              parent = 0;
              numMessages = 0;
              pFileName = nsnull;
              pDataSource = nsnull;
              dataOffset = 4;
              while (dataOffset < strOffset) {
                     tag = (PRUint8) pBytes[dataOffset];

      data = 0; // make sure all bytes are 0 before copying 3 bytes over.
                     memcpy( &data, &(pBytes[dataOffset + 1]), 3);
                     switch( tag) {
                            case 0x80: // id record
                                   id = data;
                            break;        
                            case 0x81:    // parent id
                                   parent = data;
                            break;
                            case 0x87:    // number of messages in this mailbox
                                   numMessages = data;
                            break;
                            case 0x03:    // file name for this mailbox
                                   if (((PRUint32)strOffset + data) < size)
                                          pFileName = (char *)(pBytes + strOffset + data);
                            break;
                            case 0x05:    // data source for this record (this is not a mailbox!)
                                   if (((PRUint32)strOffset + data) < size)
                                          pDataSource = (char *) (pBytes + strOffset + data);
                            break;
                     }
                     dataOffset += 4;
              }
              
              // now build an entry if necessary!
              if (pDataSource) {
                     if (!nsCRT::strcasecmp( pDataSource, "LocalStore"))
      {
                            localStoreId = id;   
        // See if we have any child folders that need to be added/processed for this top level parent.
        ProcessPendingChildEntries(localStoreId, localStoreId, m_pendingChildArray);
        // Clean up the pending list.
        RemoveProcessedChildEntries();
      }
              }
              else if (id && localStoreId && parent) {
                     // veryify that this mailbox is in the local store
                     data = parent;
                     while (data && (data != localStoreId)) {
                            pEntry = GetIndexEntry( data);
                            if (pEntry)
                                   data = pEntry->parent;
                            else
                                   data = 0;
                     }
                     if (data == localStoreId) {
                            // Create an entry for this bugger
        pEntry = NewMailboxEntry(id, parent, (const char *) (pBytes + strOffset), pFileName);
        if (pEntry)
        {
                              AddChildEntry( pEntry, localStoreId);
          pEntry->processed =  PR_TRUE;
          // See if we have any child folders that need to be added/processed.
          ProcessPendingChildEntries(id, localStoreId, m_pendingChildArray);
          // Clean up the pending list.
          RemoveProcessedChildEntries();
        }
                     }
      else
      {
        // Put this folder into child array and process it when its parent shows up.
        pEntry = NewMailboxEntry(id, parent, (const char *) (pBytes + strOffset), pFileName);
        if (pEntry)
          m_pendingChildArray.AppendElement(pEntry);
      }
              }
    else if (pFileName)
    {
      // Put this folder into child array and process it when its parent shows up.
      // For some reason, it's likely that child folders come before their parents.
      pEntry = NewMailboxEntry(id, parent, (const char *) (pBytes + strOffset), pFileName);
      if (pEntry)
        m_pendingChildArray.AppendElement(pEntry);
    }

              delete [] pBytes;
       }
       

       delete [] pIndex;

       if (m_entryArray.Count())
              return( PR_TRUE);
       else
              return( PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsOEScanBoxes::FindMail ( nsIFileSpec pWhere) [static]

Definition at line 125 of file nsOEScanBoxes.cpp.

{
       nsresult      rv;
       PRBool        success = PR_FALSE;
       HKEY          sKey;
       
       if (Find50Mail( pWhere))
              return( PR_TRUE);

       if (::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Outlook Express", 0, KEY_QUERY_VALUE, &sKey) == ERROR_SUCCESS) {
              LPBYTE pBytes = nsOERegUtil::GetValueBytes( sKey, "Store Root");
              if (pBytes) {
                     pWhere->SetNativePath((char *)pBytes);
                     pWhere->AppendRelativeUnixPath( "Mail");
                     PRBool isDir = PR_FALSE;
                     rv = pWhere->IsDirectory( &isDir);
                     if (isDir && NS_SUCCEEDED( rv))
                            success = PR_TRUE;
                     delete [] pBytes;
              }
              ::RegCloseKey( sKey);              
       }
       
       return( success);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsOEScanBoxes::FindMailBoxes ( nsIFileSpec descFile) [private]

Definition at line 223 of file nsOEScanBoxes.cpp.

{
       Reset();
       
       nsresult      rv;
       PRBool        isFile = PR_FALSE;
       
       rv = descFile->IsFile( &isFile);
       if (NS_FAILED( rv) || !isFile)
              return( PR_FALSE);
       
       rv = descFile->OpenStreamForReading();    
       if (NS_FAILED( rv))
              return( PR_FALSE);

       IMPORT_LOG0( "Reading the folders.nch file\n");
       
       PRUint32             curRec;
       if (!ReadLong( descFile, curRec, 20)) {
              return( PR_FALSE);
       }

       // Now for each record
       PRBool               done = PR_FALSE;
       PRUint32             equal;
       PRUint32             size;
       PRUint32             previous;
       PRUint32             next;
       MailboxEntry *       pEntry;
       PRBool               failed;
       nsCString            ext;
       nsCString            mbxExt( ".mbx");
       
       while (!done) {
              
              if (!ReadLong( descFile, equal, curRec)) return( PR_FALSE);
              if (curRec != equal) {
                     IMPORT_LOG1( "Record start invalid: %ld\n", curRec);
                     break;
              }
              if (!ReadLong( descFile, size, curRec + 4)) return( PR_FALSE);
              if (!ReadLong( descFile, previous, curRec + 8)) return( PR_FALSE);
              if (!ReadLong( descFile, next, curRec + 12)) return( PR_FALSE);
              failed = PR_FALSE;
              pEntry = new MailboxEntry;
              if (!ReadLong( descFile, pEntry->index, curRec + 16)) failed = PR_TRUE;
              if (!ReadString( descFile, pEntry->mailName, curRec + 20)) failed = PR_TRUE;
              if (!ReadString( descFile, pEntry->fileName, curRec + 279)) failed = PR_TRUE;
              if (!ReadLong( descFile, pEntry->parent, curRec + 539)) failed = PR_TRUE;
              if (!ReadLong( descFile, pEntry->child, curRec + 543)) failed = PR_TRUE;
              if (!ReadLong( descFile, pEntry->sibling, curRec + 547)) failed = PR_TRUE;
              if (!ReadLong( descFile, pEntry->type, curRec + 551)) failed = PR_TRUE;
              if (failed) {
                     delete pEntry;
                     return( PR_FALSE);
              }

              #ifdef _TRACE_MAILBOX_ENTRIES
              IMPORT_LOG0( "------------\n");
              IMPORT_LOG2( "    Offset: %lx, index: %ld\n", curRec, pEntry->index);
              IMPORT_LOG2( "      previous: %lx, next: %lx\n", previous, next);
              IMPORT_LOG2( "      Name: %S, File: %s\n", (PRUnichar *) pEntry->mailName, (const char *) pEntry->fileName);
              IMPORT_LOG3( "      Parent: %ld, Child: %ld, Sibling: %ld\n", pEntry->parent, pEntry->child, pEntry->sibling);
              #endif
              
              pEntry->fileName.Right( ext, 4);
              if (!ext.Equals(mbxExt))
                     pEntry->fileName.Append( ".mbx");         
              
              m_entryArray.AppendElement( pEntry);

              curRec = next;
              if (!next)
                     done = PR_TRUE;
       }
       
       MailboxEntry *pZero = GetIndexEntry( 0);
       if (pZero)
              m_pFirst = GetIndexEntry( pZero->child);
       
       IMPORT_LOG1( "Read the folders.nch file, found %ld mailboxes\n", (long) m_entryArray.Count());
       
       return( PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 815 of file nsOEScanBoxes.cpp.

{
       PRInt32 max = m_entryArray.Count();
       for (PRInt32 i = 0; i < max; i++) {
              MailboxEntry *pEntry = (MailboxEntry *) m_entryArray.ElementAt( i);
              if (pEntry->index == index)
                     return( pEntry);
       }

       return( nsnull);
}

Here is the caller graph for this function:

Definition at line 151 of file nsOEScanBoxes.cpp.

{
       char *path = nsnull;
       pWhere->GetNSPRPath( &path);
       if (path) {
              IMPORT_LOG1( "Looking for mail in: %s\n", path);
              nsCRT::free( path);
       }
       else {
              pWhere->GetLeafName( &path);
              if (path) {
                     IMPORT_LOG1( "Looking for mail in: %s\n", path);
                     nsCRT::free( path);
              }
              else {
                     IMPORT_LOG0( "Unable to get info about where to look for mail\n");
              }
       }
       
       nsIFileSpec   *where;
       if (NS_FAILED( NS_NewFileSpec( &where)))
              return( PR_FALSE);
       where->FromFileSpec( pWhere);

       // 1. Look for 5.0 folders.dbx
       // 2. Look for 3.x & 4.x folders.nch
       // 3. Look for 5.0 *.dbx mailboxes
       // 4. Look for 3.x & 4.x *.mbx mailboxes
       
       PRBool result;

       where->AppendRelativeUnixPath( "folders.dbx");
       if (Find50MailBoxes( where)) {
              where->CloseStream();
              result = GetMailboxList( pWhere, pArray);
       }
       else {
              // 2. Look for 4.x mailboxes
              where->FromFileSpec( pWhere);
              where->AppendRelativeUnixPath( "folders.nch");
       
              if (FindMailBoxes( where)) {
                     where->CloseStream();
                     result = GetMailboxList( pWhere, pArray);
              }
              else {
                     // 3 & 4, look for the specific mailbox files.
                     where->CloseStream();
                     where->FromFileSpec( pWhere);
                     ScanMailboxDir( where);
                     result = GetMailboxList( pWhere, pArray);
              }
       }
              
       where->Release();
       return( result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsOEScanBoxes::GetMailboxList ( nsIFileSpec root,
nsISupportsArray **  pArray 
) [private]

Definition at line 732 of file nsOEScanBoxes.cpp.

{      
       nsresult rv = NS_NewISupportsArray( pArray);
       if (NS_FAILED( rv)) {
              IMPORT_LOG0( "FAILED to allocate the nsISupportsArray\n");
              return( PR_FALSE);
       }
       
       BuildMailboxList( nsnull, root, 1, *pArray);
       
       return( PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsOEScanBoxes::MailboxEntry * nsOEScanBoxes::NewMailboxEntry ( PRUint32  id,
PRUint32  parent,
const char *  prettyName,
char *  pFileName 
) [private]

Definition at line 466 of file nsOEScanBoxes.cpp.

{
  MailboxEntry *pEntry = new MailboxEntry();
  if (!pEntry)
    return nsnull;

  pEntry->index = id;
  pEntry->parent = parent;
  pEntry->child = 0;
  pEntry->type = 0;
  pEntry->sibling = -1;
  pEntry->processed =  PR_FALSE;
  NS_CopyNativeToUnicode(nsDependentCString(prettyName), pEntry->mailName);
  if (pFileName)
         pEntry->fileName = pFileName;
  return pEntry;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsOEScanBoxes::ProcessPendingChildEntries ( PRUint32  parent,
PRUint32  rootIndex,
nsVoidArray childArray 
) [private]

Definition at line 484 of file nsOEScanBoxes.cpp.

{
  PRInt32 i, max;
  MailboxEntry *pEntry;
  for (i = 0, max = childArray.Count(); i < max; i++)
  {
    pEntry = (MailboxEntry *) childArray.ElementAt(i);
    if ((!pEntry->processed) && (pEntry->parent == parent))
    {
      AddChildEntry(pEntry, rootIndex);
      pEntry->processed =  PR_TRUE; // indicate it's been processed.
      // See if there are unprocessed child folders for this child in the
      // array as well (ie, both child and grand-child are on the list).
      ProcessPendingChildEntries(pEntry->index, rootIndex, childArray);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsOEScanBoxes::ReadLong ( nsIFileSpec stream,
PRInt32 val,
PRUint32  offset 
) [private]

Definition at line 832 of file nsOEScanBoxes.cpp.

{
       nsresult      rv;
       rv = stream->Seek( offset);
       if (NS_FAILED( rv))
              return( PR_FALSE);
       
       PRInt32       cntRead;
       char * pReadTo = (char *)&val;
       rv = stream->Read( &pReadTo, sizeof( val), &cntRead);
       
       if (NS_FAILED( rv) || (cntRead != sizeof( val)))
              return( PR_FALSE);
       return( PR_TRUE);
}

Here is the caller graph for this function:

PRBool nsOEScanBoxes::ReadLong ( nsIFileSpec stream,
PRUint32 val,
PRUint32  offset 
) [private]

Definition at line 848 of file nsOEScanBoxes.cpp.

{
       nsresult      rv;
       rv = stream->Seek( offset);
       if (NS_FAILED( rv))
              return( PR_FALSE);
       
       PRInt32       cntRead;
       char * pReadTo = (char *)&val;
       rv = stream->Read( &pReadTo, sizeof( val), &cntRead);
       
       if (NS_FAILED( rv) || (cntRead != sizeof( val)))
              return( PR_FALSE);
       return( PR_TRUE);
}
PRBool nsOEScanBoxes::ReadString ( nsIFileSpec stream,
nsString str,
PRUint32  offset 
) [private]

Definition at line 869 of file nsOEScanBoxes.cpp.

{
       
       nsresult      rv;
       rv = stream->Seek( offset);
       if (NS_FAILED( rv))
              return( PR_FALSE);
              

       PRInt32       cntRead;
       char   buffer[kOutlookExpressStringLength];
       char * pReadTo = buffer;
       rv = stream->Read( &pReadTo, kOutlookExpressStringLength, &cntRead);
       
       if (NS_FAILED( rv) || (cntRead != kOutlookExpressStringLength))
              return( PR_FALSE);
       buffer[kOutlookExpressStringLength - 1] = 0;
       str.AssignWithConversion(buffer);
       return( PR_TRUE);
}

Here is the caller graph for this function:

PRBool nsOEScanBoxes::ReadString ( nsIFileSpec stream,
nsCString str,
PRUint32  offset 
) [private]

Definition at line 890 of file nsOEScanBoxes.cpp.

{
       
       nsresult      rv;
       rv = stream->Seek( offset);
       if (NS_FAILED( rv))
              return( PR_FALSE);
              

       PRInt32       cntRead;
       char   buffer[kOutlookExpressStringLength];
       char * pReadTo = buffer;
       rv = stream->Read( &pReadTo, kOutlookExpressStringLength, &cntRead);
       
       if (NS_FAILED( rv) || (cntRead != kOutlookExpressStringLength))
              return( PR_FALSE);
       buffer[kOutlookExpressStringLength - 1] = 0;
       str = buffer;
       return( PR_TRUE);
}

Definition at line 502 of file nsOEScanBoxes.cpp.

{
  // Remove already processed entries from the pending list. Note that these entries are also
  // on 'm_entryArray' list so we don't want to deallocate the space for the entries now.
  MailboxEntry * pEntry;
  PRInt32 i;
  for (i = m_pendingChildArray.Count()-1; i >= 0; i--)
  {
    pEntry = (MailboxEntry *) m_pendingChildArray.ElementAt(i);
    if (pEntry->processed)
      m_pendingChildArray.RemoveElementAt(i);
  }
}

Here is the caller graph for this function:

void nsOEScanBoxes::Reset ( void  ) [private]

Definition at line 211 of file nsOEScanBoxes.cpp.

{
       int max = m_entryArray.Count();
       for (int i = 0; i < max; i++) {
              MailboxEntry *pEntry = (MailboxEntry *) m_entryArray.ElementAt( i);
              delete pEntry;
       }
       m_entryArray.Clear();
       m_pFirst = nsnull;
}

Here is the caller graph for this function:

Definition at line 565 of file nsOEScanBoxes.cpp.

{
       Reset();

       MailboxEntry *       pEntry;       
       PRInt32                     index = 1;
       char *               pLeaf;
       PRUint32             sLen;
       
       nsIFileSpec *               spec;
       nsIDirectoryIterator *      iter;
       
       if (NS_FAILED( NS_NewDirectoryIterator( &iter)))
              return( PR_FALSE);
       if (NS_FAILED( iter->Init( srcDir, PR_TRUE))) {
              iter->Release();
              return( PR_FALSE);
       }

       nsresult      rv;
       PRBool        exists = PR_FALSE;
       PRBool        isFile;
       
       rv = iter->Exists( &exists);
       while (NS_SUCCEEDED( rv) && exists) {
           // do something with i.Spec()
           rv = iter->GetCurrentSpec( &spec);
           if (NS_SUCCEEDED( rv)) {
              isFile = PR_FALSE;
              rv = spec->IsFile( &isFile);
                     if (NS_SUCCEEDED( rv) && isFile) {
                            pLeaf = nsnull;
                            rv = spec->GetLeafName( &pLeaf);
                            if (NS_SUCCEEDED( rv) && pLeaf && 
                                   ((sLen = strlen( pLeaf)) > 4) && 
                                   (!nsCRT::strcasecmp( pLeaf + sLen - 3, "dbx"))) {
                                   // This is a *.dbx file in the mail directory
                                   if (nsOE5File::IsLocalMailFile( spec)) {
                                          pEntry = new MailboxEntry;
                                          pEntry->index = index;
                                          index++;
                                          pEntry->parent = 0;
                                          pEntry->child = 0;
                                          pEntry->sibling = index;
                                          pEntry->type = -1;
                                          pEntry->fileName = pLeaf;
                                          pLeaf[sLen - 4] = 0;
                                          NS_CopyNativeToUnicode(nsDependentCString(pLeaf), pEntry->mailName);
                                          m_entryArray.AppendElement( pEntry);                           
                                   }
                            }
                            if (pLeaf)
                                   nsCRT::free( pLeaf);
                     }
              }
              rv = iter->Next();    
              exists = PR_FALSE;
              rv = iter->Exists( &exists);
       }
       
       if (m_entryArray.Count() > 0) {
              pEntry = (MailboxEntry *)m_entryArray.ElementAt( m_entryArray.Count() - 1);
              pEntry->sibling = -1;
              return( PR_TRUE);
       }

       return( PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 635 of file nsOEScanBoxes.cpp.

{
       if (Scan50MailboxDir( srcDir))
              return;

       Reset();

       MailboxEntry *       pEntry;       
       PRInt32                     index = 1;
       char *               pLeaf;
       PRUint32             sLen;
       
       nsIFileSpec *               spec;
       nsIDirectoryIterator *      iter;
       
       if (NS_FAILED( NS_NewDirectoryIterator( &iter)))
              return;
       if (NS_FAILED( iter->Init( srcDir, PR_TRUE))) {
              iter->Release();
              return;
       }
       nsresult      rv;
       PRBool        exists = PR_FALSE;
       PRBool        isFile;
       
       rv = iter->Exists( &exists);
       while (NS_SUCCEEDED( rv) && exists) {
           // do something with i.Spec()
           rv = iter->GetCurrentSpec( &spec);
           if (NS_SUCCEEDED( rv)) {
              isFile = PR_FALSE;
              rv = spec->IsFile( &isFile);
                     if (NS_SUCCEEDED( rv) && isFile) {
                            pLeaf = nsnull;
                            rv = spec->GetLeafName( &pLeaf);
                            if (NS_SUCCEEDED( rv) && pLeaf && 
                                   ((sLen = strlen( pLeaf)) > 4) && 
                                   (!nsCRT::strcasecmp( pLeaf + sLen - 3, "mbx"))) {
                                   // This is a *.mbx file in the mail directory
                                   pEntry = new MailboxEntry;
                                   pEntry->index = index;
                                   index++;
                                   pEntry->parent = 0;
                                   pEntry->child = 0;
                                   pEntry->sibling = index;
                                   pEntry->type = -1;
                                   pEntry->fileName = pLeaf;
                                   pLeaf[sLen - 4] = 0;
                                   NS_CopyNativeToUnicode(nsDependentCString(pLeaf), pEntry->mailName);
                                   m_entryArray.AppendElement( pEntry);                           
                            }
                            if (pLeaf)
                                   nsCRT::free( pLeaf);
                     }
              }
              rv = iter->Next();    
              exists = PR_FALSE;
              rv = iter->Exists( &exists);
       }
       
       if (m_entryArray.Count() > 0) {
              pEntry = (MailboxEntry *)m_entryArray.ElementAt( m_entryArray.Count() - 1);
              pEntry->sibling = -1;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 99 of file nsOEScanBoxes.h.

Definition at line 100 of file nsOEScanBoxes.h.

Definition at line 98 of file nsOEScanBoxes.h.

Definition at line 102 of file nsOEScanBoxes.h.


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