Beispiel #1
0
NS_IMETHODIMP ImportOutlookMailImpl::ImportMailbox(  nsIImportMailboxDescriptor *pSource,
        nsIFile *pDestination,
        PRUnichar **pErrorLog,
        PRUnichar **pSuccessLog,
        PRBool *fatalError)
{
    NS_PRECONDITION(pSource != nsnull, "null ptr");
    NS_PRECONDITION(pDestination != nsnull, "null ptr");
    NS_PRECONDITION(fatalError != nsnull, "null ptr");

    nsCOMPtr<nsIStringBundle>  bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));

    nsString  success;
    nsString  error;
    if (!pSource || !pDestination || !fatalError) {
        nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_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;
    PRUnichar *  pName;
    if (NS_SUCCEEDED( pSource->GetDisplayName( &pName))) {
        name = pName;
        NS_Free( pName);
    }

    PRUint32 mailSize = 0;
    pSource->GetSize( &mailSize);
    if (mailSize == 0) {
        ReportSuccess( name, 0, &success);
        SetLogs( success, error, pErrorLog, pSuccessLog);
        return( NS_OK);
    }

    PRUint32 index = 0;
    pSource->GetIdentifier( &index);
    PRInt32  msgCount = 0;
    nsresult rv = NS_OK;

    m_bytesDone = 0;

    rv = m_mail.ImportMailbox( &m_bytesDone, &abort, (PRInt32)index, name.get(), pDestination, &msgCount);

    if (NS_SUCCEEDED( rv))
        ReportSuccess( name, msgCount, &success);
    else
        ReportError( OUTLOOKIMPORT_MAILBOX_CONVERTERROR, name, &error);

    SetLogs( success, error, pErrorLog, pSuccessLog);

    return( rv);
}
Beispiel #2
0
NS_IMETHODIMP
ImportOutlookMailImpl::ImportMailbox(nsIImportMailboxDescriptor *pSource,
                                     nsIMsgFolder *dstFolder,
                                     PRUnichar **pErrorLog,
                                     PRUnichar **pSuccessLog,
                                     bool *fatalError)
{
  NS_ENSURE_ARG_POINTER(pSource);
  NS_ENSURE_ARG_POINTER(dstFolder);
  NS_ENSURE_ARG_POINTER(fatalError);

  nsString  success;
  nsString  error;
  bool abort = false;
  nsString name;
  PRUnichar *pName;
  if (NS_SUCCEEDED( pSource->GetDisplayName( &pName))) {
    name = pName;
    NS_Free( pName);
 }

  PRUint32 mailSize = 0;
  pSource->GetSize(&mailSize);
  if (mailSize == 0) {
    ReportSuccess(name, 0, &success);
    SetLogs(success, error, pErrorLog, pSuccessLog);
    return NS_OK;
  }

  PRUint32 index = 0;
  pSource->GetIdentifier(&index);
  PRInt32  msgCount = 0;
  nsresult rv = NS_OK;

  m_bytesDone = 0;

  rv = m_mail.ImportMailbox(&m_bytesDone, &abort, (PRInt32)index, name.get(),
                            dstFolder, &msgCount);

  if (NS_SUCCEEDED(rv))
    ReportSuccess(name, msgCount, &success);
  else
    ReportError(OUTLOOKIMPORT_MAILBOX_CONVERTERROR, name, &error);

  SetLogs(success, error, pErrorLog, pSuccessLog);

  return rv;
}