Beispiel #1
0
NS_IMETHODIMP ImportOutlookAddressImpl::ImportAddressBook(nsIImportABDescriptor *source,
        nsIAddrDatabase *destination,
        nsIImportFieldMap *fieldMap,
        nsISupports *aSupportService,
        PRBool isAddrLocHome,
        PRUnichar **pErrorLog,
        PRUnichar **pSuccessLog,
        PRBool *fatalError)
{
    m_msgCount = 0;
    m_msgTotal = 0;
    NS_PRECONDITION(source != nsnull, "null ptr");
    NS_PRECONDITION(destination != nsnull, "null ptr");
    NS_PRECONDITION(fatalError != nsnull, "null ptr");

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

    nsString  success;
    nsString  error;
    if (!source || !destination || !fatalError) {
        IMPORT_LOG0( "*** Bad param passed to outlook address import\n");
        nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRESS_BADPARAM, error, bundle);
        if (fatalError)
            *fatalError = PR_TRUE;
        ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
        return NS_ERROR_NULL_POINTER;
    }

    nsString name;
    source->GetPreferredName(name);

    PRUint32  id;
    if (NS_FAILED( source->GetIdentifier( &id))) {
        ImportOutlookMailImpl::ReportError( OUTLOOKIMPORT_ADDRESS_BADSOURCEFILE, name, &error);
        ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
        return( NS_ERROR_FAILURE);
    }

    nsresult rv = NS_OK;
    rv = m_address.ImportAddresses( &m_msgCount, &m_msgTotal, name.get(), id, destination, error);
    if (NS_SUCCEEDED( rv) && error.IsEmpty())
        ReportSuccess( name, &success);
    else
        ImportOutlookMailImpl::ReportError( OUTLOOKIMPORT_ADDRESS_CONVERTERROR, name, &error);

    ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
    IMPORT_LOG0( "*** Returning from outlook address import\n");
    return destination->Commit(nsAddrDBCommitType::kLargeCommit);
}