Back to index

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

#include <nsComm4xMailImport.h>

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

List of all members.

Public Member Functions

 ImportComm4xMailImpl ()
virtual ~ImportComm4xMailImpl ()
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 ReportStatus (PRInt32 errorNum, nsString &name, nsString *pStream)
nsresult Initialize ()
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 void SetLogs (nsString &success, nsString &error, PRUnichar **pError, PRUnichar **pSuccess)

Private Attributes

nsComm4xMail m_mail
PRUint32 m_bytesDone
nsCOMPtr< nsIStringBundlem_pBundleProxy

Detailed Description

Definition at line 78 of file nsComm4xMailImport.h.


Constructor & Destructor Documentation

Definition at line 187 of file nsComm4xMailImport.cpp.

Definition at line 210 of file nsComm4xMailImport.cpp.

{
}

Member Function Documentation

Here is the caller graph for this function:

Definition at line 231 of file nsComm4xMailImport.cpp.

{
    NS_ENSURE_ARG_POINTER(pLoc);
    NS_ENSURE_ARG_POINTER(ppArray);

    PRBool exists = PR_FALSE;
    nsresult rv = pLoc->Exists(&exists);
    if (NS_FAILED(rv) || !exists)
        return NS_ERROR_FAILURE;

    // find mail boxes
    rv = m_mail.FindMailboxes(pLoc, ppArray);

    if (NS_FAILED(rv) && *ppArray) {
        NS_RELEASE(*ppArray);
        *ppArray = nsnull;
    }

    return rv;
}

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 ImportComm4xMailImpl::GetDefaultLocation ( nsIFileSpec **  location,
PRBool found,
PRBool userVerify 
)

Definition at line 218 of file nsComm4xMailImport.cpp.

{
    NS_ENSURE_ARG_POINTER(found);
    NS_ENSURE_ARG_POINTER(ppLoc);
    NS_ENSURE_ARG_POINTER(userVerify);
    
    *ppLoc = nsnull;
    *found = PR_FALSE;
    *userVerify = PR_TRUE; 
    return NS_OK;  
}

Definition at line 355 of file nsComm4xMailImport.cpp.

{ 
    NS_ENSURE_ARG_POINTER(pDoneSoFar);

    *pDoneSoFar = m_bytesDone;
    return NS_OK;
}
unsigned long nsIImportMail::GetImportProgress ( ) [inherited]

Here is the caller graph for this function:

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

Definition at line 273 of file nsComm4xMailImport.cpp.

{
    NS_PRECONDITION(pSource != nsnull, "null ptr");
    NS_PRECONDITION(pDestination != nsnull, "null ptr");
    NS_PRECONDITION(fatalError != nsnull, "null ptr");
    
    nsString    success;
    nsString    error;
    if (!pSource || !pDestination || !fatalError) {
        nsXPIDLString errorString;
        m_pBundleProxy->GetStringFromID(COMM4XMAILIMPORT_MAILBOX_BADPARAM, getter_Copies(errorString));
        error = errorString;
        if (fatalError)
            *fatalError = PR_TRUE;
        SetLogs(success, error, pErrorLog, pSuccessLog);
        return NS_ERROR_NULL_POINTER;
    }
      
    nsString    name;
    PRUnichar *    pName;
    if (NS_SUCCEEDED(pSource->GetDisplayName(&pName))) {
        name.Adopt(pName);
    }
    
    PRUint32 mailSize = 0;
    pSource->GetSize(&mailSize);
    if (mailSize == 0) {
        ReportStatus(COMM4XMAILIMPORT_MAILBOX_SUCCESS, name, &success);
        SetLogs(success, error, pErrorLog, pSuccessLog);
        return NS_OK;
    }
    
    PRUint32 index = 0;
    pSource->GetIdentifier(&index);
    nsresult rv = NS_OK;

    m_bytesDone = 0;

    // copy files from 4.x to here.
    nsCOMPtr <nsIFileSpec> inFile;
    if (NS_FAILED(pSource->GetFileSpec(getter_AddRefs(inFile)))) {
        ReportStatus(COMM4XMAILIMPORT_MAILBOX_CONVERTERROR, name, &error);
        SetLogs(success, error, pErrorLog, pSuccessLog);
        return NS_ERROR_FAILURE;
    }

    nsXPIDLCString pSrcPath, pDestPath;;
    inFile->GetNativePath(getter_Copies(pSrcPath));
    pDestination ->GetNativePath(getter_Copies(pDestPath));
    IMPORT_LOG2("ImportComm4xMailImpl::ImportMailbox: Copying folder from '%s' to '%s'.", pSrcPath.get(), pDestPath.get());

    nsCOMPtr <nsIFileSpec> parent;
    if (NS_FAILED (pDestination->GetParent(getter_AddRefs(parent))))
    {
        ReportStatus( COMM4XMAILIMPORT_MAILBOX_CONVERTERROR, name, &error);
        SetLogs( success, error, pErrorLog, pSuccessLog);
        return( NS_ERROR_FAILURE);
    }
    PRBool exists = PR_FALSE;
    pDestination->Exists(&exists);
    if (exists)
        rv = pDestination->Delete(PR_FALSE);
    rv = inFile->CopyToDir(parent);
      
    if (NS_SUCCEEDED(rv)) {
        m_bytesDone = mailSize;
        ReportStatus(COMM4XMAILIMPORT_MAILBOX_SUCCESS, name, &success);
    }
    else {
        ReportStatus(COMM4XMAILIMPORT_MAILBOX_CONVERTERROR, name, &error);
    }

    SetLogs(success, error, pErrorLog, pSuccessLog);

    return rv;
}

Here is the call 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:

Definition at line 192 of file nsComm4xMailImport.cpp.

{
    nsCOMPtr <nsIStringBundleService> pBundleService;
    nsresult rv;
    nsCOMPtr <nsIStringBundle>  pBundle;

    pBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv) && (pBundleService))
        pBundleService->CreateBundle(COMM4XMAIL_MSGS_URL, getter_AddRefs(pBundle));

    nsCOMPtr<nsIProxyObjectManager> proxyMgr(do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv));
    if (NS_SUCCEEDED(rv)) {
        rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIStringBundle),
                                          pBundle, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(m_pBundleProxy));
    }
    return rv;
}

Here is the call graph for this function:

void ImportComm4xMailImpl::ReportStatus ( PRInt32  errorNum,
nsString name,
nsString pStream 
)

Definition at line 252 of file nsComm4xMailImport.cpp.

{
    if (!pStream) return;
    nsXPIDLString statusStr;
    const PRUnichar * fmtStr = name.get();
    nsresult rv = m_pBundleProxy->FormatStringFromID(errorNum, &fmtStr, 1, getter_Copies(statusStr));
    if (NS_SUCCEEDED (rv)) {
        pStream->Append (statusStr.get());
        pStream->Append( PRUnichar(nsCRT::LF));
    }
    
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 265 of file nsComm4xMailImport.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 ImportComm4xMailImpl::TranslateFolderName ( const nsAString &  aFolderName,
nsAString &  _retval 
)

Definition at line 363 of file nsComm4xMailImport.cpp.

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

Member Data Documentation

Definition at line 111 of file nsComm4xMailImport.h.

Definition at line 110 of file nsComm4xMailImport.h.

Definition at line 112 of file nsComm4xMailImport.h.


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