Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes
CIndexScanner Class Reference
Inheritance diagram for CIndexScanner:
Inheritance graph
[legend]
Collaboration diagram for CIndexScanner:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CIndexScanner (nsString &name, nsIFileSpec *idxFile, nsIFileSpec *mbxFile, nsIFileSpec *dstFile)
 ~CIndexScanner ()
virtual PRBool Initialize (void)
virtual PRBool DoWork (PRBool *pAbort, PRUint32 *pDone, PRUint32 *pCount)
PRBool WasErrorFatal (void)
PRUint32 BytesProcessed (void)

Public Attributes

PRUint32 m_msgCount

Protected Member Functions

virtual void CleanUp (void)
PRBool WriteMailItem (PRUint32 flags, PRUint32 offset, PRUint32 size, PRUint32 *pTotalMsgSize=nsnull)

Protected Attributes

PRUint32m_pDone
nsString m_name
nsIFileSpecm_mbxFile
nsIFileSpecm_dstFile
PRUint8m_pInBuffer
PRUint8m_pOutBuffer
PRUint32 m_bufSz
PRUint32 m_didBytes
PRBool m_fatalError
PRUint32 m_mbxFileSize
PRUint32 m_mbxOffset

Static Protected Attributes

static const char * m_pFromLine = "From - Mon Jan 1 00:00:00 1965\x0D\x0A"

Private Member Functions

PRBool ValidateIdxFile (void)
PRBool GetMailItem (PRUint32 *pFlags, PRUint32 *pOffset, PRUint32 *pSize)

Private Attributes

nsIFileSpecm_idxFile
PRUint32 m_numMessages
PRUint32 m_idxOffset
PRUint32 m_curItemIndex

Detailed Description

Definition at line 88 of file nsOEMailbox.cpp.


Constructor & Destructor Documentation

CIndexScanner::CIndexScanner ( nsString name,
nsIFileSpec idxFile,
nsIFileSpec mbxFile,
nsIFileSpec dstFile 
)

Definition at line 508 of file nsOEMailbox.cpp.

: CMbxScanner( name, mbxFile, dstFile)
{
  m_idxFile = idxFile;
  m_idxFile->AddRef();
  m_curItemIndex = 0;
  m_idxOffset = 0;
}

Definition at line 517 of file nsOEMailbox.cpp.

{
  CleanUp();
  if (m_idxFile)
    m_idxFile->Release();
}

Here is the call graph for this function:


Member Function Documentation

PRUint32 CMbxScanner::BytesProcessed ( void  ) [inline, inherited]

Definition at line 55 of file nsOEMailbox.cpp.

{ return( m_didBytes);}
void CIndexScanner::CleanUp ( void  ) [protected, virtual]

Reimplemented from CMbxScanner.

Definition at line 677 of file nsOEMailbox.cpp.

{
  CMbxScanner::CleanUp();
  m_idxFile->CloseStream(); 
}

Here is the caller graph for this function:

PRBool CIndexScanner::DoWork ( PRBool pAbort,
PRUint32 pDone,
PRUint32 pCount 
) [virtual]

Reimplemented from CMbxScanner.

Definition at line 644 of file nsOEMailbox.cpp.

{
  m_didBytes = 0;
  if (!ValidateIdxFile())
    return( PR_FALSE);
  
  PRBool      failed = PR_FALSE;
  while ((m_curItemIndex < m_numMessages) && !failed && !(*pAbort)) {
    PRUint32  flags, offset, size;
    if (!GetMailItem( &flags, &offset, &size)) {
      CleanUp();
      return( PR_FALSE);
    }
    m_curItemIndex++;
    if (!(flags & kOEDeletedFlag)) {
      if (!WriteMailItem( flags, offset, size))
        failed = PR_TRUE;
      else {
        m_msgCount++;
      }
    }
    m_didBytes += size;
    if (pDone)
      *pDone = m_didBytes;
    if (pCount)
      *pCount = m_msgCount;
  }
  
  CleanUp();
  return( !failed);
}

Here is the call graph for this function:

PRBool CIndexScanner::GetMailItem ( PRUint32 pFlags,
PRUint32 pOffset,
PRUint32 pSize 
) [private]

Definition at line 594 of file nsOEMailbox.cpp.

{
  PRUint32    values[kNumIdxLongsToRead];
  PRInt32            cnt = kNumIdxLongsToRead * sizeof( PRUint32);
  PRInt8 *    pReadTo = (PRInt8 *) values;
  PRInt32            cntRead;
  nsresult    rv;
  
  rv = m_idxFile->Seek( m_idxOffset);
  if (NS_FAILED( rv))
    return( PR_FALSE);
  
  rv = m_idxFile->Read( (char **) &pReadTo, cnt, &cntRead);           
  if (NS_FAILED( rv) || (cntRead != cnt))
    return( PR_FALSE);
              
  if (values[3] != m_idxOffset) {
    IMPORT_LOG2( "Self pointer invalid: m_idxOffset=0x%lx, self=0x%lx\n", m_idxOffset, values[3]);
    return( PR_FALSE);
  }
  
  // So... what do we have here???
#ifdef DEBUG_SUBJECT_AND_FLAGS
  IMPORT_LOG2( "Number: %ld, msg offset: 0x%lx, ", values[2], values[5]);
  IMPORT_LOG2( "msg length: %ld, Flags: 0x%lx\n", values[6], values[0]);
  m_idxFile->seek( m_idxOffset + 212);
  PRUint32    subSz = 0;
  cnt = 4;
  pReadTo = (PRInt8 *) &subSz;
  m_idxFile->Read( (char **) &pReadTo, cnt, &cntRead);
  if ((subSz >= 0) && (subSz < 1024)) {
    char *pSub = new char[subSz + 1];
    m_idxFile->Read( &pSub, subSz, &cntRead);
    pSub[subSz] = 0;
    IMPORT_LOG1( "    Subject: %s\n", pSub);
    delete [] pSub;
  }
#endif
  
  m_idxOffset += values[4];
  m_didBytes += values[4];
  
  *pFlags = values[0];
  *pOffset = values[5];
  *pSize = values[6];
  return( PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from CMbxScanner.

Definition at line 524 of file nsOEMailbox.cpp.

{
  if (!CMbxScanner::Initialize())
    return( PR_FALSE);
  
  
  nsresult    rv = m_idxFile->OpenStreamForReading();
  if (NS_FAILED( rv)) {
    CleanUp();
    return( PR_FALSE);
  }
  
  return( PR_TRUE);
}

Here is the call graph for this function:

Definition at line 539 of file nsOEMailbox.cpp.

{
  PRInt8                    id[4];
  PRInt32                   cnt = 4;
  nsresult           rv;
  PRInt32                   cntRead;
  PRInt8 *           pReadTo;
  
  pReadTo = id;
  rv = m_idxFile->Read( (char **) &pReadTo, cnt, &cntRead);
  if (NS_FAILED( rv) || (cntRead != cnt))
    return( PR_FALSE);
  if ((id[0] != 'J') || (id[1] != 'M') || (id[2] != 'F') || (id[3] != '9'))
    return( PR_FALSE);
  cnt = 4;
  PRUint32           subId;
  pReadTo = (PRInt8 *) &subId;
  rv = m_idxFile->Read( (char **) &pReadTo, cnt, &cntRead);
  if (NS_FAILED( rv) || (cntRead != cnt))
    return( PR_FALSE);
  if (subId != 0x00010004) {
    IMPORT_LOG1( "Idx file subid doesn't match: 0x%lx\n", subId);
    return( PR_FALSE);
  }
  
  pReadTo = (PRInt8 *) &m_numMessages;
  rv = m_idxFile->Read( (char **) &pReadTo, cnt, &cntRead);
  if (NS_FAILED( rv) || (cntRead != cnt))
    return( PR_FALSE);
  
  IMPORT_LOG1( "Idx file num messages: %ld\n", m_numMessages);
  
  m_didBytes += 80;
  m_idxOffset = 80;
  return( PR_TRUE);
}

Here is the caller graph for this function:

PRBool CMbxScanner::WasErrorFatal ( void  ) [inline, inherited]

Definition at line 54 of file nsOEMailbox.cpp.

{ return( m_fatalError);}

Here is the caller graph for this function:

PRBool CMbxScanner::WriteMailItem ( PRUint32  flags,
PRUint32  offset,
PRUint32  size,
PRUint32 pTotalMsgSize = nsnull 
) [protected, inherited]

Definition at line 316 of file nsOEMailbox.cpp.

{
  PRUint32    values[kNumMbxLongsToRead];
  PRInt32            cnt = kNumMbxLongsToRead * sizeof( PRUint32);
  nsresult    rv;
  PRBool             failed = PR_FALSE;
  PRInt32            cntRead;
  PRInt8 *    pChar = (PRInt8 *) values;
  
  rv = m_mbxFile->Seek( offset);
  m_mbxFile->Failed( &failed);
  
  if (NS_FAILED( rv) || failed) {
    IMPORT_LOG1( "Mbx seek error: 0x%lx\n", offset);
    return( PR_FALSE);
  }
  rv = m_mbxFile->Read( (char **) &pChar, cnt, &cntRead);
  if (NS_FAILED( rv) || (cntRead != cnt)) {
    IMPORT_LOG1( "Mbx read error at: 0x%lx\n", offset);
    return( PR_FALSE);
  }
  if (values[0] != 0x7F007F00) {
    IMPORT_LOG2( "Mbx tag field doesn't match: 0x%lx, at offset: 0x%lx\n", values[0], offset);
    return( PR_FALSE);
  }
  if (size && (values[2] != size)) {
    IMPORT_LOG3( "Mbx size doesn't match idx, mbx: %ld, idx: %ld, at offset: 0x%lx\n", values[2], size, offset);
    return( PR_FALSE);
  }
  
  if (pTotalMsgSize != nsnull)
    *pTotalMsgSize = values[2];
  
  // everything looks kosher...
  // the actual message text follows and is values[3] bytes long...
  return( CopyMbxFileBytes(flags,  values[3]));
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

PRUint32 CMbxScanner::m_bufSz [protected, inherited]

Definition at line 77 of file nsOEMailbox.cpp.

Definition at line 108 of file nsOEMailbox.cpp.

PRUint32 CMbxScanner::m_didBytes [protected, inherited]

Definition at line 78 of file nsOEMailbox.cpp.

nsIFileSpec* CMbxScanner::m_dstFile [protected, inherited]

Definition at line 74 of file nsOEMailbox.cpp.

PRBool CMbxScanner::m_fatalError [protected, inherited]

Definition at line 79 of file nsOEMailbox.cpp.

Definition at line 105 of file nsOEMailbox.cpp.

Definition at line 107 of file nsOEMailbox.cpp.

nsIFileSpec* CMbxScanner::m_mbxFile [protected, inherited]

Definition at line 73 of file nsOEMailbox.cpp.

PRUint32 CMbxScanner::m_mbxFileSize [protected, inherited]

Definition at line 80 of file nsOEMailbox.cpp.

PRUint32 CMbxScanner::m_mbxOffset [protected, inherited]

Definition at line 81 of file nsOEMailbox.cpp.

Definition at line 68 of file nsOEMailbox.cpp.

nsString CMbxScanner::m_name [protected, inherited]

Definition at line 72 of file nsOEMailbox.cpp.

Definition at line 106 of file nsOEMailbox.cpp.

PRUint32* CMbxScanner::m_pDone [protected, inherited]

Definition at line 71 of file nsOEMailbox.cpp.

const char * CMbxScanner::m_pFromLine = "From - Mon Jan 1 00:00:00 1965\x0D\x0A" [static, protected, inherited]

Definition at line 83 of file nsOEMailbox.cpp.

PRUint8* CMbxScanner::m_pInBuffer [protected, inherited]

Definition at line 75 of file nsOEMailbox.cpp.

PRUint8* CMbxScanner::m_pOutBuffer [protected, inherited]

Definition at line 76 of file nsOEMailbox.cpp.


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