Back to index

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

List of all members.

Public Member Functions

 ImportOEMailImpl ()
virtual ~ImportOEMailImpl ()
NS_DECL_ISUPPORTS NS_IMETHOD GetDefaultLocation (nsIFileSpec **location, PRBool *found, PRBool *userVerify)
NS_IMETHOD FindMailboxes (nsIFileSpec *location, nsISupportsArray **_retval)
NS_IMETHOD ImportMailbox (nsIImportMailboxDescriptor *source, nsIFileSpec *destination, PRUnichar **pErrorLog, PRUnichar **pSuccessLog, PRBool *fatalError)
NS_IMETHOD GetImportProgress (PRUint32 *_retval)
NS_IMETHOD TranslateFolderName (const nsAString &aFolderName, nsAString &_retval)
void GetDefaultLocation (out nsIFileSpec location, out boolean found, out boolean userVerify)
nsISupportsArray FindMailboxes (in nsIFileSpec location)
void ImportMailbox (in nsIImportMailboxDescriptor source, in nsIFileSpec destination, out wstring errorLog, out wstring successLog, out boolean fatalError)
unsigned long GetImportProgress ()
AString translateFolderName (in AString aFolderName)

Static Public Member Functions

static nsresult Create (nsIImportMail **aImport)
static void ReportSuccess (nsString &name, PRInt32 count, nsString *pStream)
static void ReportError (PRInt32 errorNum, nsString &name, nsString *pStream)
static void AddLinebreak (nsString *pStream)
static void SetLogs (nsString &success, nsString &error, PRUnichar **pError, PRUnichar **pSuccess)

Private Attributes

PRUint32 m_bytesDone

Detailed Description

Definition at line 85 of file nsOEImport.cpp.


Constructor & Destructor Documentation

Definition at line 343 of file nsOEImport.cpp.

{
}

Here is the caller graph for this function:

Definition at line 348 of file nsOEImport.cpp.

{
}

Member Function Documentation

void ImportOEMailImpl::AddLinebreak ( nsString pStream) [static]

Definition at line 416 of file nsOEImport.cpp.

{
       if (pStream)
              pStream->Append( PRUnichar(nsCRT::LF));
}

Here is the caller graph for this function:

Definition at line 329 of file nsOEImport.cpp.

{
    NS_PRECONDITION(aImport != nsnull, "null ptr");
    if (! aImport)
        return NS_ERROR_NULL_POINTER;

    *aImport = new ImportOEMailImpl();
    if (! *aImport)
        return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(*aImport);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 396 of file nsOEImport.cpp.

{
    NS_PRECONDITION(pLoc != nsnull, "null ptr");
    NS_PRECONDITION(ppArray != nsnull, "null ptr");
    if (!pLoc || !ppArray)
        return NS_ERROR_NULL_POINTER;
       
       PRBool exists = PR_FALSE;
       nsresult rv = pLoc->Exists( &exists);
       if (NS_FAILED( rv) || !exists)
              return( NS_ERROR_FAILURE);

       nsOEScanBoxes scan;
       
       if (!scan.GetMailboxes( pLoc, ppArray))
              *ppArray = nsnull;
       
       return( NS_OK);
}

Here is the call graph for this function:

void nsIImportMail::GetDefaultLocation ( out nsIFileSpec  location,
out boolean  found,
out boolean  userVerify 
) [inherited]

Here is the caller graph for this function:

NS_IMETHODIMP ImportOEMailImpl::GetDefaultLocation ( nsIFileSpec **  location,
PRBool found,
PRBool userVerify 
)

Definition at line 368 of file nsOEImport.cpp.

{
    NS_PRECONDITION(ppLoc != nsnull, "null ptr");
    NS_PRECONDITION(found != nsnull, "null ptr");
    NS_PRECONDITION(userVerify != nsnull, "null ptr");
    if (!ppLoc || !found || !userVerify)
        return NS_ERROR_NULL_POINTER;

       // use scanboxes to find the location.
       nsresult      rv;
       nsIFileSpec * spec;
       if (NS_FAILED( rv = NS_NewFileSpec( &spec)))
              return( rv);
       
       if (nsOEScanBoxes::FindMail( spec)) {
              *found = PR_TRUE;
              *ppLoc = spec;
       }
       else {
              *found = PR_FALSE;
              *ppLoc = nsnull;
              spec->Release();
       }
       *userVerify = PR_TRUE;
       return( NS_OK);
}

Here is the call graph for this function:

Definition at line 540 of file nsOEImport.cpp.

{ 
    NS_PRECONDITION(pDoneSoFar != nsnull, "null ptr");
    if (! pDoneSoFar)
        return NS_ERROR_NULL_POINTER;
       
       *pDoneSoFar = m_bytesDone;
       return( NS_OK);
}
unsigned long nsIImportMail::GetImportProgress ( ) [inherited]

Here is the caller graph for this function:

void nsIImportMail::ImportMailbox ( in nsIImportMailboxDescriptor  source,
in nsIFileSpec  destination,
out wstring  errorLog,
out wstring  successLog,
out boolean  fatalError 
) [inherited]

Here is the caller graph for this function:

NS_IMETHODIMP ImportOEMailImpl::ImportMailbox ( nsIImportMailboxDescriptor source,
nsIFileSpec destination,
PRUnichar **  pErrorLog,
PRUnichar **  pSuccessLog,
PRBool fatalError 
)

Definition at line 461 of file nsOEImport.cpp.

{
  NS_PRECONDITION(pSource != nsnull, "null ptr");
  NS_PRECONDITION(pDestination != nsnull, "null ptr");
  NS_PRECONDITION(fatalError != nsnull, "null ptr");
  
  nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOEStringBundle::GetStringBundleProxy()));
  
  nsString    success;
  nsString    error;
  if (!pSource || !pDestination || !fatalError) {
    nsOEStringBundle::GetStringByID( OEIMPORT_MAILBOX_BADPARAM, error, bundle);
    if (fatalError)
      *fatalError = PR_TRUE;
    SetLogs( success, error, pErrorLog, pSuccessLog);
    return NS_ERROR_NULL_POINTER;
  }
  
  PRBool             abort = PR_FALSE;
  nsString    name;
  nsXPIDLString pName;
  if (NS_SUCCEEDED( pSource->GetDisplayName( getter_Copies(pName)))) {
    name = pName;
  }
  
  PRUint32 mailSize = 0;
  pSource->GetSize( &mailSize);
  if (mailSize == 0) {
    ReportSuccess( name, 0, &success);
    SetLogs( success, error, pErrorLog, pSuccessLog);
    return( NS_OK);
  }
  
  nsIFileSpec *      inFile;
  if (NS_FAILED( pSource->GetFileSpec( &inFile))) {
    ReportError( OEIMPORT_MAILBOX_BADSOURCEFILE, name, &error);
    SetLogs( success, error, pErrorLog, pSuccessLog);          
    return( NS_ERROR_FAILURE);
  }
  
  nsXPIDLCString pPath; 
  inFile->GetNativePath(getter_Copies(pPath));
  IMPORT_LOG1( "Importing Outlook Express mailbox: %s\n", pPath.get());
  
  m_bytesDone = 0;
  PRUint32    msgCount = 0;
  nsresult rv;
  if (nsOE5File::IsLocalMailFile( inFile)) {
    IMPORT_LOG1( "Importing OE5 mailbox: %S!\n", name.get());
    rv = nsOE5File::ImportMailbox( &m_bytesDone, &abort, name, inFile, pDestination, &msgCount);
  }
  else {
    if (CImportMailbox::ImportMailbox( &m_bytesDone, &abort, name, inFile, pDestination, &msgCount)) {
              rv = NS_OK;
    }
    else {
              rv = NS_ERROR_FAILURE;
    }
  }
  
  inFile->Release();
  
  if (NS_SUCCEEDED( rv)) {
    ReportSuccess( name, msgCount, &success);
  }
  else {
    ReportError( OEIMPORT_MAILBOX_CONVERTERROR, name, &error);
  }
  
  SetLogs( success, error, pErrorLog, pSuccessLog);
  
  return( rv);
}

Here is the call graph for this function:

void ImportOEMailImpl::ReportError ( PRInt32  errorNum,
nsString name,
nsString pStream 
) [static]

Definition at line 437 of file nsOEImport.cpp.

{
       if (!pStream)
              return;
       // load the error string
       nsIStringBundle *pBundle = nsOEStringBundle::GetStringBundleProxy();
       PRUnichar *pFmt = nsOEStringBundle::GetStringByID( errorNum, pBundle);
       PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get());
       pStream->Append( pText);
       nsTextFormatter::smprintf_free( pText);
       nsOEStringBundle::FreeString( pFmt);
       AddLinebreak( pStream);
       NS_IF_RELEASE( pBundle);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ImportOEMailImpl::ReportSuccess ( nsString name,
PRInt32  count,
nsString pStream 
) [static]

Definition at line 422 of file nsOEImport.cpp.

{
       if (!pStream)
              return;
       // load the success string
       nsIStringBundle *pBundle = nsOEStringBundle::GetStringBundleProxy();
       PRUnichar *pFmt = nsOEStringBundle::GetStringByID( OEIMPORT_MAILBOX_SUCCESS, pBundle);
       PRUnichar *pText = nsTextFormatter::smprintf( pFmt, name.get(), count);
       pStream->Append( pText);
       nsTextFormatter::smprintf_free( pText);
       nsOEStringBundle::FreeString( pFmt);
       AddLinebreak( pStream);
       NS_IF_RELEASE( pBundle);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ImportOEMailImpl::SetLogs ( nsString success,
nsString error,
PRUnichar **  pError,
PRUnichar **  pSuccess 
) [static]

Definition at line 453 of file nsOEImport.cpp.

{
       if (pError)
              *pError = ToNewUnicode(error);
       if (pSuccess)
              *pSuccess = ToNewUnicode(success);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP ImportOEMailImpl::TranslateFolderName ( const nsAString &  aFolderName,
nsAString &  _retval 
)

Definition at line 354 of file nsOEImport.cpp.

{
    if (aFolderName.Equals(NS_LITERAL_STRING("Deleted Items"), nsCaseInsensitiveStringComparator()))
        _retval = NS_LITERAL_STRING(kDestTrashFolderName);
    else if (aFolderName.Equals(NS_LITERAL_STRING("Sent Items"), nsCaseInsensitiveStringComparator()))
        _retval = NS_LITERAL_STRING(kDestSentFolderName);
    else if (aFolderName.Equals(NS_LITERAL_STRING("Outbox"), nsCaseInsensitiveStringComparator()))
        _retval = NS_LITERAL_STRING(kDestUnsentMessagesFolderName);
    else
        _retval = aFolderName;

    return NS_OK;
}
AString nsIImportMail::translateFolderName ( in AString  aFolderName) [inherited]

Member Data Documentation

Definition at line 120 of file nsOEImport.cpp.


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