Example #1
0
NS_IMETHODIMP ImportEudoraAddressImpl::GetDefaultLocation(nsIFile **ppLoc, bool *found, bool *userVerify)
{
  NS_PRECONDITION(found != nsnull, "null ptr");
  NS_PRECONDITION(ppLoc != nsnull, "null ptr");
  NS_PRECONDITION(userVerify != nsnull, "null ptr");
  if (! found || !userVerify || !ppLoc)
    return NS_ERROR_NULL_POINTER;

  *ppLoc = nsnull;
  *found = m_eudora.FindAddressFolder(ppLoc);
  *userVerify = true;

  return NS_OK;
}
Example #2
0
NS_IMETHODIMP ImportEudoraMailImpl::GetDefaultLocation( nsIFile **ppLoc, PRBool *found, PRBool *userVerify)
{
  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;

  *ppLoc = nsnull;
  *found = m_eudora.FindMailFolder(ppLoc);
  *userVerify = PR_TRUE;

  return( NS_OK);
}
Example #3
0
NS_IMETHODIMP ImportEudoraAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISupportsArray **ppArray)
{
    NS_PRECONDITION(pLoc != nsnull, "null ptr");
    NS_PRECONDITION(ppArray != nsnull, "null ptr");
    if (!pLoc || !ppArray)
        return NS_ERROR_NULL_POINTER;

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

  rv = m_eudora.FindAddressBooks(pLoc, ppArray);
  if (NS_FAILED(rv) && *ppArray)
    NS_RELEASE(*ppArray);

  return rv;
}
Example #4
0
NS_IMETHODIMP ImportEudoraMailImpl::FindMailboxes( nsIFile *pLoc, nsISupportsArray **ppArray)
{
  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);

  rv = m_eudora.FindMailboxes( pLoc, ppArray);
  if (NS_FAILED( rv) && *ppArray)
  {
    NS_RELEASE( *ppArray);
    *ppArray = nsnull;
  }

  return( rv);
}
Example #5
0
NS_IMETHODIMP
ImportEudoraAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
                                           nsIAddrDatabase *pDestination,
                                           nsIImportFieldMap *fieldMap,
                                           nsISupports *aSupportService,
                                           PRUnichar **pErrorLog,
                                           PRUnichar **pSuccessLog,
                                           bool *fatalError)
{
  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) {
    IMPORT_LOG0("*** Bad param passed to eudora address import\n");
    nsEudoraStringBundle::GetStringByID(EUDORAIMPORT_ADDRESS_BADPARAM, error);
    if (fatalError)
      *fatalError = true;
    ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);
    return NS_ERROR_NULL_POINTER;
  }

  bool abort = false;
  nsString name;
  pSource->GetPreferredName(name);

  PRUint32 addressSize = 0;
  pSource->GetSize(&addressSize);
  if (addressSize == 0) {
    IMPORT_LOG0("Address book size is 0, skipping mailbox.\n");
    ReportSuccess(name, &success);
    ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);
    return NS_OK;
  }


  nsCOMPtr<nsIFile> inFile;
  if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) {
    ImportEudoraMailImpl::ReportError(EUDORAIMPORT_ADDRESS_BADSOURCEFILE, name, &error);
    ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);
    return NS_ERROR_FAILURE;
  }


#ifdef IMPORT_DEBUG
  nsCString path;
  inFile->GetNativePath(path);
  IMPORT_LOG1("Import address book: %s\n", path.get());
#endif


  nsresult rv = NS_OK;

  m_bytes = 0;
  rv = m_eudora.ImportAddresses(&m_bytes, &abort, name.get(), inFile, pDestination, error);

  if (NS_SUCCEEDED(rv) && error.IsEmpty())
    ReportSuccess(name, &success);
  else
    ImportEudoraMailImpl::ReportError(EUDORAIMPORT_ADDRESS_CONVERTERROR, name, &error);

  ImportEudoraMailImpl::SetLogs(success, error, pErrorLog, pSuccessLog);

  IMPORT_LOG0("*** Returning from eudora address import\n");

  return rv;
}
Example #6
0
NS_IMETHODIMP
ImportEudoraMailImpl::ImportMailbox(nsIImportMailboxDescriptor *pSource,
                                    nsIMsgFolder *pDstFolder,
                                    PRUnichar **pErrorLog,
                                    PRUnichar **pSuccessLog,
                                    bool *fatalError)
{
  NS_ENSURE_ARG_POINTER(pSource);
  NS_ENSURE_ARG_POINTER(pDstFolder);
  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)
  {
    IMPORT_LOG0("Mailbox size is 0, skipping mailbox.\n");
    ReportSuccess(name, 0, &success);
    SetLogs(success, error, pErrorLog, pSuccessLog);
    return NS_OK;
  }


  nsCOMPtr <nsIFile>  inFile;
  if (NS_FAILED(pSource->GetFile(getter_AddRefs(inFile))))
  {
    ReportError(EUDORAIMPORT_MAILBOX_BADSOURCEFILE, name, &error);
    SetLogs(success, error, pErrorLog, pSuccessLog);
    return NS_ERROR_FAILURE;
  }

#ifdef IMPORT_DEBUG
  nsCString pPath;
  inFile->GetNativePath(pPath);
  IMPORT_LOG1("Import mailbox: %s\n", pPath.get());
#endif


  PRInt32  msgCount = 0;
  nsresult rv = NS_OK;

  m_bytes = 0;
  rv = m_eudora.ImportMailbox( &m_bytes, &abort, name.get(), inFile, pDstFolder, &msgCount);
  if (NS_SUCCEEDED(rv))
    ReportSuccess(name, msgCount, &success);
  else
    ReportError(EUDORAIMPORT_MAILBOX_CONVERTERROR, name, &error);

  SetLogs(success, error, pErrorLog, pSuccessLog);

  IMPORT_LOG0("*** Returning from eudora mailbox import\n");

  return rv;
}
Example #7
0
NS_IMETHODIMP ImportEudoraMailImpl::ImportMailbox(nsIImportMailboxDescriptor *pSource,
            nsIFile *pDestination,
            PRUnichar **pErrorLog,
            PRUnichar **pSuccessLog,
            bool *fatalError)
{
  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)
  {
    IMPORT_LOG0( "*** Bad param passed to eudora mailbox import\n");
    nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_MAILBOX_BADPARAM, error);
    if (fatalError)
      *fatalError = true;
    SetLogs( success, error, pErrorLog, pSuccessLog);
    return NS_ERROR_NULL_POINTER;
  }

  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)
  {
    IMPORT_LOG0( "Mailbox size is 0, skipping mailbox.\n");
    ReportSuccess( name, 0, &success);
    SetLogs( success, error, pErrorLog, pSuccessLog);
    return( NS_OK);
  }


  nsCOMPtr <nsILocalFile>  inFile;
  if (NS_FAILED(pSource->GetFile( getter_AddRefs(inFile))))
  {
    ReportError( EUDORAIMPORT_MAILBOX_BADSOURCEFILE, name, &error);
    SetLogs( success, error, pErrorLog, pSuccessLog);
    return( NS_ERROR_FAILURE);
  }

#ifdef IMPORT_DEBUG
  nsCString pPath;
  inFile->GetNativePath(pPath);
  IMPORT_LOG1( "Import mailbox: %s\n", pPath.get());
#endif


  PRInt32  msgCount = 0;
  nsresult rv = NS_OK;

  m_bytes = 0;
  rv = m_eudora.ImportMailbox( &m_bytes, &abort, name.get(), inFile, pDestination, &msgCount);
  if (NS_SUCCEEDED( rv))
    ReportSuccess( name, msgCount, &success);
  else
    ReportError( EUDORAIMPORT_MAILBOX_CONVERTERROR, name, &error);

  SetLogs( success, error, pErrorLog, pSuccessLog);

  IMPORT_LOG0( "*** Returning from eudora mailbox import\n");

  return( rv);
}