Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
nsAbWinHelper Class Reference

#include <nsAbWinHelper.h>

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

List of all members.

Public Member Functions

 nsAbWinHelper (void)
virtual ~nsAbWinHelper (void)
BOOL GetFolders (nsMapiEntryArray &aFolders)
BOOL GetCards (const nsMapiEntry &aParent, LPSRestriction aRestriction, nsMapiEntryArray &aCards)
BOOL GetNodes (const nsMapiEntry &aParent, nsMapiEntryArray &aNodes)
BOOL GetCardsCount (const nsMapiEntry &aParent, ULONG &aNbCards)
HRESULT LastError (void) const
BOOL GetPropertyString (const nsMapiEntry &aObject, ULONG aPropertyTag, nsCString &aValue)
BOOL GetPropertyUString (const nsMapiEntry &aObject, ULONG aPropertyTag, nsString &aValue)
BOOL GetPropertiesUString (const nsMapiEntry &aObject, const ULONG *aPropertiesTag, ULONG aNbProperties, nsStringArray &aValues)
BOOL GetPropertyDate (const nsMapiEntry &aObject, ULONG aPropertyTag, WORD &aYear, WORD &aMonth, WORD &aDay)
BOOL GetPropertyLong (const nsMapiEntry &aObject, ULONG aPropertyTag, ULONG &aValue)
BOOL GetPropertyBin (const nsMapiEntry &aObject, ULONG aPropertyTag, nsMapiEntry &aValue)
BOOL TestOpenEntry (const nsMapiEntry &aContainer, const nsMapiEntry &aEntry)
BOOL DeleteEntry (const nsMapiEntry &aContainer, const nsMapiEntry &aEntry)
BOOL SetPropertyUString (const nsMapiEntry &aObject, ULONG aPropertyTag, const PRUnichar *aValue)
BOOL SetPropertiesUString (const nsMapiEntry &aObject, const ULONG *aPropertiesTag, ULONG aNbProperties, nsXPIDLString *aValues)
BOOL SetPropertyDate (const nsMapiEntry &aObject, ULONG aPropertyTag, WORD aYear, WORD aMonth, WORD aDay)
BOOL CreateEntry (const nsMapiEntry &aParent, nsMapiEntry &aNewEntry)
BOOL CreateDistList (const nsMapiEntry &aParent, nsMapiEntry &aNewEntry)
BOOL CopyEntry (const nsMapiEntry &aContainer, const nsMapiEntry &aSource, nsMapiEntry &aTarget)
BOOL GetDefaultContainer (nsMapiEntry &aContainer)
BOOL IsOK (void) const

Protected Member Functions

BOOL GetContents (const nsMapiEntry &aParent, LPSRestriction aRestriction, nsMapiEntry **aList, ULONG &aNbElements, ULONG aMapiType)
BOOL GetMAPIProperties (const nsMapiEntry &aObject, const ULONG *aPropertyTags, ULONG aNbProperties, LPSPropValue &aValues, ULONG &aValueCount)
BOOL SetMAPIProperties (const nsMapiEntry &aObject, ULONG aNbProperties, const LPSPropValue &aValues)
void MyFreeProws (LPSRowSet aSet)
virtual void AllocateBuffer (ULONG aByteCount, LPVOID *aBuffer)=0
virtual void FreeBuffer (LPVOID aBuffer)=0

Protected Attributes

HRESULT mLastError
LPADRBOOK mAddressBook

Static Protected Attributes

static PRUint32 mEntryCounter = 0
static PRLockmMutex = PR_NewLock()

Detailed Description

Definition at line 75 of file nsAbWinHelper.h.


Constructor & Destructor Documentation

Definition at line 283 of file nsAbWinHelper.cpp.

Definition at line 289 of file nsAbWinHelper.cpp.


Member Function Documentation

virtual void nsAbWinHelper::AllocateBuffer ( ULONG  aByteCount,
LPVOID aBuffer 
) [protected, pure virtual]

Implemented in nsMapiAddressBook, and nsWabAddressBook.

Here is the caller graph for this function:

BOOL nsAbWinHelper::CopyEntry ( const nsMapiEntry aContainer,
const nsMapiEntry aSource,
nsMapiEntry aTarget 
)

Definition at line 770 of file nsAbWinHelper.cpp.

{
    nsMapiInterfaceWrapper<LPABCONT> container ;
    ULONG objType = 0 ;

    mLastError = mAddressBook->OpenEntry(aContainer.mByteCount, aContainer.mEntryId,
                                         &IID_IABContainer, MAPI_MODIFY, &objType,
                                         container) ;
    if (HR_FAILED(mLastError)) { 
        PRINTF(("Cannot open container %08x.\n", mLastError)) ;
        return FALSE ;
    }
    nsMapiInterfaceWrapper<LPMAPIPROP> newEntry ;

    mLastError = container->CreateEntry(aSource.mByteCount, aSource.mEntryId,
                                        CREATE_CHECK_DUP_LOOSE, newEntry) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot create new entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    mLastError = newEntry->SaveChanges(KEEP_OPEN_READONLY) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot commit new entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    SPropTagArray property ;
    LPSPropValue value = NULL ;
    ULONG valueCount = 0 ;
    
    property.cValues = 1 ;
    property.aulPropTag [0] = PR_ENTRYID ;
    mLastError = newEntry->GetProps(&property, 0, &valueCount, &value) ;
    if (HR_FAILED(mLastError) || valueCount != 1) {
        PRINTF(("Cannot get entry id %08x.\n", mLastError)) ;
        return FALSE ;
    }
    aTarget.Assign(value->Value.bin.cb, 
                   NS_REINTERPRET_CAST(LPENTRYID, value->Value.bin.lpb)) ;
    FreeBuffer(value) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 706 of file nsAbWinHelper.cpp.

{
    nsMapiInterfaceWrapper<LPABCONT> container ;
    ULONG objType = 0 ;

    mLastError = mAddressBook->OpenEntry(aParent.mByteCount, aParent.mEntryId,
                                         &IID_IABContainer, MAPI_MODIFY, &objType,
                                         container) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot open container %08x.\n", mLastError)) ;
        return FALSE ;
    }
    SPropTagArray property ;
    LPSPropValue value = NULL ;
    ULONG valueCount = 0 ;

    property.cValues = 1 ;
    property.aulPropTag [0] = PR_DEF_CREATE_DL ;
    mLastError = container->GetProps(&property, 0, &valueCount, &value) ;
    if (HR_FAILED(mLastError) || valueCount != 1) {
        PRINTF(("Cannot obtain template %08x.\n", mLastError)) ;
        return FALSE ;
    }
    nsMapiInterfaceWrapper<LPMAPIPROP> newEntry ;

    mLastError = container->CreateEntry(value->Value.bin.cb, 
                                        NS_REINTERPRET_CAST(LPENTRYID, value->Value.bin.lpb),
                                        CREATE_CHECK_DUP_LOOSE,
                                        newEntry) ;
    FreeBuffer(value) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot create new entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    SPropValue displayName ;
    LPSPropProblemArray problems = NULL ;
    nsAutoString tempName ;

    displayName.ulPropTag = PR_DISPLAY_NAME_W ;
    tempName.AssignLiteral("__MailList__") ;
    tempName.AppendInt(mEntryCounter ++) ;
    displayName.Value.lpszW = NS_CONST_CAST(WCHAR *, tempName.get()) ;
    mLastError = newEntry->SetProps(1, &displayName, &problems) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot set temporary name %08x.\n", mLastError)) ;
        return FALSE ;
    }
    mLastError = newEntry->SaveChanges(KEEP_OPEN_READONLY) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot commit new entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    property.aulPropTag [0] = PR_ENTRYID ;
    mLastError = newEntry->GetProps(&property, 0, &valueCount, &value) ;
    if (HR_FAILED(mLastError) || valueCount != 1) {
        PRINTF(("Cannot get entry id %08x.\n", mLastError)) ;
        return FALSE ;
    }
    aNewEntry.Assign(value->Value.bin.cb, 
                     NS_REINTERPRET_CAST(LPENTRYID, value->Value.bin.lpb)) ;
    FreeBuffer(value) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::CreateEntry ( const nsMapiEntry aParent,
nsMapiEntry aNewEntry 
)

Definition at line 643 of file nsAbWinHelper.cpp.

{
    nsMapiInterfaceWrapper<LPABCONT> container ;
    ULONG objType = 0 ;

    mLastError = mAddressBook->OpenEntry(aParent.mByteCount, aParent.mEntryId,
                                         &IID_IABContainer, MAPI_MODIFY, &objType,
                                         container) ;
    if (HR_FAILED(mLastError)) { 
        PRINTF(("Cannot open container %08x.\n", mLastError)) ;
        return FALSE ;
    }
    SPropTagArray property ;
    LPSPropValue value = NULL ;
    ULONG valueCount = 0 ;

    property.cValues = 1 ;
    property.aulPropTag [0] = PR_DEF_CREATE_MAILUSER ;
    mLastError = container->GetProps(&property, 0, &valueCount, &value) ;
    if (HR_FAILED(mLastError) || valueCount != 1) {
        PRINTF(("Cannot obtain template %08x.\n", mLastError)) ;
        return FALSE ;
    }
    nsMapiInterfaceWrapper<LPMAPIPROP> newEntry ;

    mLastError = container->CreateEntry(value->Value.bin.cb, 
                                        NS_REINTERPRET_CAST(LPENTRYID, value->Value.bin.lpb),
                                        CREATE_CHECK_DUP_LOOSE,
                                        newEntry) ;
    FreeBuffer(value) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot create new entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    SPropValue displayName ;
    LPSPropProblemArray problems = NULL ;
    nsAutoString tempName ;

    displayName.ulPropTag = PR_DISPLAY_NAME_W ;
    tempName.AssignLiteral("__MailUser__") ;
    tempName.AppendInt(mEntryCounter ++) ;
    displayName.Value.lpszW = NS_CONST_CAST(WCHAR *, tempName.get()) ;
    mLastError = newEntry->SetProps(1, &displayName, &problems) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot set temporary name %08x.\n", mLastError)) ;
        return FALSE ;
    }
    mLastError = newEntry->SaveChanges(KEEP_OPEN_READONLY) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot commit new entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    property.aulPropTag [0] = PR_ENTRYID ;
    mLastError = newEntry->GetProps(&property, 0, &valueCount, &value) ;
    if (HR_FAILED(mLastError) || valueCount != 1) {
        PRINTF(("Cannot get entry id %08x.\n", mLastError)) ;
        return FALSE ;
    }
    aNewEntry.Assign(value->Value.bin.cb, NS_REINTERPRET_CAST(LPENTRYID, value->Value.bin.lpb)) ;
    FreeBuffer(value) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 533 of file nsAbWinHelper.cpp.

{
    nsMapiInterfaceWrapper<LPABCONT> container ;
    ULONG objType = 0 ;
    SBinary entry ;
    SBinaryArray entryArray ;

    mLastError = mAddressBook->OpenEntry(aContainer.mByteCount, aContainer.mEntryId,
                                         &IID_IABContainer, MAPI_MODIFY, &objType, 
                                         container) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot open container %08x.\n", mLastError)) ;
        return FALSE ;
    }
    entry.cb = aEntry.mByteCount ;
    entry.lpb = NS_REINTERPRET_CAST(LPBYTE, aEntry.mEntryId) ;
    entryArray.cValues = 1 ;
    entryArray.lpbin = &entry ;
    mLastError = container->DeleteEntries(&entryArray, 0) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot delete entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    return TRUE ;
}

Here is the caller graph for this function:

virtual void nsAbWinHelper::FreeBuffer ( LPVOID  aBuffer) [protected, pure virtual]

Implemented in nsMapiAddressBook, and nsWabAddressBook.

Here is the caller graph for this function:

BOOL nsAbWinHelper::GetCards ( const nsMapiEntry aParent,
LPSRestriction  aRestriction,
nsMapiEntryArray aCards 
)

Definition at line 360 of file nsAbWinHelper.cpp.

{
    aCards.CleanUp() ;
    return GetContents(aParent, aRestriction, &aCards.mEntries, aCards.mNbEntries, 0) ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::GetCardsCount ( const nsMapiEntry aParent,
ULONG aNbCards 
)

Definition at line 373 of file nsAbWinHelper.cpp.

{
    aNbCards = 0 ;
    return GetContents(aParent, NULL, NULL, aNbCards, 0) ;
}

Here is the call graph for this function:

BOOL nsAbWinHelper::GetContents ( const nsMapiEntry aParent,
LPSRestriction  aRestriction,
nsMapiEntry **  aList,
ULONG aNbElements,
ULONG  aMapiType 
) [protected]

Definition at line 844 of file nsAbWinHelper.cpp.

{
    if (aList != NULL) { *aList = NULL ; }
    aNbElements = 0 ;
    nsMapiInterfaceWrapper<LPMAPICONTAINER> parent ;
    nsMapiInterfaceWrapper<LPMAPITABLE> contents ;
    ULONG objType = 0 ;
    ULONG rowCount = 0 ;

    mLastError = mAddressBook->OpenEntry(aParent.mByteCount, aParent.mEntryId, 
                                         &IID_IMAPIContainer, 0, &objType, 
                                         parent) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot open parent %08x.\n", mLastError)) ;
        return FALSE ; 
    }
    // Here, flags for WAB and MAPI could be different, so this works
    // only as long as we don't want to use any flag in GetContentsTable
    mLastError = parent->GetContentsTable(0, contents) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot get contents %08x.\n", mLastError)) ;
        return FALSE ; 
    }
    if (aRestriction != NULL) {
        mLastError = contents->Restrict(aRestriction, 0) ;
        if (HR_FAILED(mLastError)) {
            PRINTF(("Cannot set restriction %08x.\n", mLastError)) ;
            return FALSE ;
        }
    }
    mLastError = contents->SetColumns((LPSPropTagArray) &ContentsColumns, 0) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot set columns %08x.\n", mLastError)) ;
        return FALSE ;
    }
    mLastError = contents->GetRowCount(0, &rowCount) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot get result count %08x.\n", mLastError)) ;
        return FALSE ;
    }
    if (aList != NULL) { *aList = new nsMapiEntry [rowCount] ; }
    aNbElements = 0 ;
    do {
        LPSRowSet rowSet = NULL ;
        
        rowCount = 0 ;
        mLastError = contents->QueryRows(1, 0, &rowSet) ;
        if (HR_FAILED(mLastError)) {
            PRINTF(("Cannot query rows %08x.\n", mLastError)) ;
            return FALSE ;
        }
        rowCount = rowSet->cRows ;
        if (rowCount > 0 &&
            (aMapiType == 0 ||
            rowSet->aRow->lpProps[ContentsColumnObjectType].Value.ul == aMapiType)) {
            if (aList != NULL) {
                nsMapiEntry& current = (*aList) [aNbElements] ;
                SPropValue& currentValue = rowSet->aRow->lpProps[ContentsColumnEntryId] ;
                
                current.Assign(currentValue.Value.bin.cb,
                    NS_REINTERPRET_CAST(LPENTRYID, currentValue.Value.bin.lpb)) ;
            }
            ++ aNbElements ;
        }
        MyFreeProws(rowSet) ;
    } while (rowCount > 0) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 813 of file nsAbWinHelper.cpp.

{
    LPENTRYID entryId = NULL ; 
    ULONG byteCount = 0 ;

    mLastError = mAddressBook->GetPAB(&byteCount, &entryId) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot get PAB %08x.\n", mLastError)) ;
        return FALSE ;
    }
    aContainer.Assign(byteCount, entryId) ;
    FreeBuffer(entryId) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 294 of file nsAbWinHelper.cpp.

{
    aFolders.CleanUp() ;
    nsMapiInterfaceWrapper<LPABCONT> rootFolder ;
    nsMapiInterfaceWrapper<LPMAPITABLE> folders ;
    ULONG objType = 0 ;
    ULONG rowCount = 0 ;
    SRestriction restriction ;
    SPropTagArray folderColumns ;

    mLastError = mAddressBook->OpenEntry(0, NULL, NULL, 0, &objType, 
                                         rootFolder) ;
    if (HR_FAILED(mLastError)) { 
        PRINTF(("Cannot open root %08x.\n", mLastError)) ;
        return FALSE ; 
    }
    mLastError = rootFolder->GetHierarchyTable(0, folders) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot get hierarchy %08x.\n", mLastError)) ;
        return FALSE ; 
    }
    // We only take into account modifiable containers, 
    // otherwise, we end up with all the directory services...
    restriction.rt = RES_BITMASK ;
    restriction.res.resBitMask.ulPropTag = PR_CONTAINER_FLAGS ;
    restriction.res.resBitMask.relBMR = BMR_NEZ ;
    restriction.res.resBitMask.ulMask = AB_MODIFIABLE ;
    mLastError = folders->Restrict(&restriction, 0) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot restrict table %08x.\n", mLastError)) ;
    }
    folderColumns.cValues = 1 ;
    folderColumns.aulPropTag [0] = PR_ENTRYID ;
    mLastError = folders->SetColumns(&folderColumns, 0) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot set columns %08x.\n", mLastError)) ;
        return FALSE ;
    }
    mLastError = folders->GetRowCount(0, &rowCount) ;
    if (HR_SUCCEEDED(mLastError)) {
        aFolders.mEntries = new nsMapiEntry [rowCount] ;
        aFolders.mNbEntries = 0 ;
        do {
            LPSRowSet rowSet = NULL ;

            rowCount = 0 ;
            mLastError = folders->QueryRows(1, 0, &rowSet) ;
            if (HR_SUCCEEDED(mLastError)) {
                rowCount = rowSet->cRows ;
                if (rowCount > 0) {
                    nsMapiEntry& current = aFolders.mEntries [aFolders.mNbEntries ++] ;
                    SPropValue& currentValue = rowSet->aRow->lpProps [0] ;
                    
                    current.Assign(currentValue.Value.bin.cb,
                                   NS_REINTERPRET_CAST(LPENTRYID, currentValue.Value.bin.lpb)) ;
                }
                MyFreeProws(rowSet) ;
            }
            else {
                PRINTF(("Cannot query rows %08x.\n", mLastError)) ;
            }
        } while (rowCount > 0) ;
    }
    return HR_SUCCEEDED(mLastError) ;
}

Here is the call graph for this function:

BOOL nsAbWinHelper::GetMAPIProperties ( const nsMapiEntry aObject,
const ULONG aPropertyTags,
ULONG  aNbProperties,
LPSPropValue &  aValues,
ULONG aValueCount 
) [protected]

Definition at line 914 of file nsAbWinHelper.cpp.

{
    nsMapiInterfaceWrapper<LPMAPIPROP> object ;
    ULONG objType = 0 ;
    LPSPropTagArray properties = NULL ;
    ULONG i = 0 ;
    
    mLastError = mAddressBook->OpenEntry(aObject.mByteCount, aObject.mEntryId,
                                         &IID_IMAPIProp, 0, &objType, 
                                         object) ;
    if (HR_FAILED(mLastError)) { 
        PRINTF(("Cannot open entry %08x.\n", mLastError)) ;
        return FALSE ; 
    }
    AllocateBuffer(CbNewSPropTagArray(aNbProperties), 
                   NS_REINTERPRET_CAST(void **, &properties)) ;
    properties->cValues = aNbProperties ;
    for (i = 0 ; i < aNbProperties ; ++ i) {
        properties->aulPropTag [i] = aPropertyTags [i] ;
    }
    mLastError = object->GetProps(properties, 0, &aValueCount, &aValue) ;
    FreeBuffer(properties) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot get props %08x.\n", mLastError)) ;
    }
    return HR_SUCCEEDED(mLastError) ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 367 of file nsAbWinHelper.cpp.

{ 
    aNodes.CleanUp() ;
    return GetContents(aParent, NULL, &aNodes.mEntries, aNodes.mNbEntries, MAPI_DISTLIST) ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::GetPropertiesUString ( const nsMapiEntry aObject,
const ULONG aPropertiesTag,
ULONG  aNbProperties,
nsStringArray &  aValues 
)

Definition at line 420 of file nsAbWinHelper.cpp.

{
    aNames.Clear() ;
    LPSPropValue values = NULL ;
    ULONG valueCount = 0 ;

    if (!GetMAPIProperties(aObject, aPropertyTags, aNbProperties, values, valueCount)) { 
        return FALSE ; 
    }
    if (valueCount == aNbProperties && values != NULL) {
        ULONG i = 0 ;

        for (i = 0 ; i < valueCount ; ++ i) {
            if (PROP_ID(values [i].ulPropTag) == PROP_ID(aPropertyTags [i])) {
                if (PROP_TYPE(values [i].ulPropTag) == PT_STRING8) {
                    nsAutoString temp ;

                    temp.AssignWithConversion (values [i].Value.lpszA) ;
                    aNames.AppendString(temp) ;
                }
                else if (PROP_TYPE(values [i].ulPropTag) == PT_UNICODE) {
                    aNames.AppendString(nsAutoString (values [i].Value.lpszW)) ;
                }
                else {
                    aNames.AppendString(nsAutoString((const PRUnichar *) "")) ;
                }
            }
            else {
                aNames.AppendString(nsAutoString((const PRUnichar *) "")) ;
            }
        }
        FreeBuffer(values) ;
    }
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::GetPropertyBin ( const nsMapiEntry aObject,
ULONG  aPropertyTag,
nsMapiEntry aValue 
)

Definition at line 496 of file nsAbWinHelper.cpp.

{
    aValue.Assign(0, NULL) ;
    LPSPropValue values = NULL ;
    ULONG valueCount = 0 ;

    if (!GetMAPIProperties(aObject, &aPropertyTag, 1, values, valueCount)) { return FALSE ; }
    if (valueCount == 1 && values != NULL && PROP_TYPE(values->ulPropTag) == PT_BINARY) {
        aValue.Assign(values->Value.bin.cb, 
                      NS_REINTERPRET_CAST(LPENTRYID, values->Value.bin.lpb)) ;
    }
    FreeBuffer(values) ;
    return TRUE ;
}

Here is the call graph for this function:

BOOL nsAbWinHelper::GetPropertyDate ( const nsMapiEntry aObject,
ULONG  aPropertyTag,
WORD aYear,
WORD aMonth,
WORD aDay 
)

Definition at line 457 of file nsAbWinHelper.cpp.

{
    aYear = 0 ; 
    aMonth = 0 ;
    aDay = 0 ;
    LPSPropValue values = NULL ;
    ULONG valueCount = 0 ;

    if (!GetMAPIProperties(aObject, &aPropertyTag, 1, values, valueCount)) { return FALSE ; }
    if (valueCount == 1 && values != NULL && PROP_TYPE(values->ulPropTag) == PT_SYSTIME) {
        SYSTEMTIME readableTime ;

        if (FileTimeToSystemTime(&values->Value.ft, &readableTime)) {
            aYear = readableTime.wYear ;
            aMonth = readableTime.wMonth ;
            aDay = readableTime.wDay ;
        }
    }
    FreeBuffer(values) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::GetPropertyLong ( const nsMapiEntry aObject,
ULONG  aPropertyTag,
ULONG aValue 
)

Definition at line 480 of file nsAbWinHelper.cpp.

{
    aValue = 0 ;
    LPSPropValue values = NULL ;
    ULONG valueCount = 0 ;

    if (!GetMAPIProperties(aObject, &aPropertyTag, 1, values, valueCount)) { return FALSE ; }
    if (valueCount == 1 && values != NULL && PROP_TYPE(values->ulPropTag) == PT_LONG) {
        aValue = values->Value.ul ;
    }
    FreeBuffer(values) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::GetPropertyString ( const nsMapiEntry aObject,
ULONG  aPropertyTag,
nsCString aValue 
)

Definition at line 379 of file nsAbWinHelper.cpp.

{
    aName.Truncate() ;
    LPSPropValue values = NULL ;
    ULONG valueCount = 0 ;

    if (!GetMAPIProperties(aObject, &aPropertyTag, 1, values, valueCount)) { return FALSE ; }
    if (valueCount == 1 && values != NULL) {
        if (PROP_TYPE(values->ulPropTag) == PT_STRING8) {
            aName = values->Value.lpszA ;
        }
        else if (PROP_TYPE(values->ulPropTag) == PT_UNICODE) {
            aName.AssignWithConversion(values->Value.lpszW) ;
        }
    }
    FreeBuffer(values) ;
    return TRUE ;
}

Here is the call graph for this function:

BOOL nsAbWinHelper::GetPropertyUString ( const nsMapiEntry aObject,
ULONG  aPropertyTag,
nsString aValue 
)

Definition at line 400 of file nsAbWinHelper.cpp.

{
    aName.Truncate() ;
    LPSPropValue values = NULL ;
    ULONG valueCount = 0 ;

    if (!GetMAPIProperties(aObject, &aPropertyTag, 1, values, valueCount)) { return FALSE ; }
    if (valueCount == 1 && values != NULL) {
        if (PROP_TYPE(values->ulPropTag) == PT_UNICODE) {
            aName = values->Value.lpszW ;
        }
        else if (PROP_TYPE(values->ulPropTag) == PT_STRING8) {
            aName.AssignWithConversion(values->Value.lpszA) ;
        }
    }
    FreeBuffer(values) ;
    return TRUE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::IsOK ( void  ) const [inline]

Definition at line 128 of file nsAbWinHelper.h.

{ return mAddressBook != NULL ; }

Here is the caller graph for this function:

HRESULT nsAbWinHelper::LastError ( void  ) const [inline]

Definition at line 91 of file nsAbWinHelper.h.

{ return mLastError ; }
void nsAbWinHelper::MyFreeProws ( LPSRowSet  aSet) [protected]

Definition at line 977 of file nsAbWinHelper.cpp.

{
    if (aRowset == NULL) { return ; }
    ULONG i = 0 ; 

    for (i = 0 ; i < aRowset->cRows ; ++ i) {
        FreeBuffer(aRowset->aRow [i].lpProps) ;
    }
    FreeBuffer(aRowset) ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::SetMAPIProperties ( const nsMapiEntry aObject,
ULONG  aNbProperties,
const LPSPropValue &  aValues 
) [protected]

Definition at line 944 of file nsAbWinHelper.cpp.

{
    nsMapiInterfaceWrapper<LPMAPIPROP> object ;
    ULONG objType = 0 ;
    LPSPropProblemArray problems = NULL ;

    mLastError = mAddressBook->OpenEntry(aObject.mByteCount, aObject.mEntryId,
                                         &IID_IMAPIProp, MAPI_MODIFY, &objType, 
                                         object) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot open entry %08x.\n", mLastError)) ;
        return FALSE ;
    }
    mLastError = object->SetProps(aNbProperties, aValues, &problems) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot update the object %08x.\n", mLastError)) ;
        return FALSE ;
    }
    if (problems != NULL) {
        for (ULONG i = 0 ; i < problems->cProblem ; ++ i) {
            PRINTF(("Problem %d: index %d code %08x.\n", i, 
                problems->aProblem [i].ulIndex, 
                problems->aProblem [i].scode)) ;
        }
    }
    mLastError = object->SaveChanges(0) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot commit changes %08x.\n", mLastError)) ;
    }
    return HR_SUCCEEDED(mLastError) ;
}

Here is the caller graph for this function:

BOOL nsAbWinHelper::SetPropertiesUString ( const nsMapiEntry aObject,
const ULONG aPropertiesTag,
ULONG  aNbProperties,
nsXPIDLString aValues 
)

Definition at line 580 of file nsAbWinHelper.cpp.

{
    LPSPropValue values = new SPropValue [aNbProperties] ;
    if (!values)
        return FALSE ;

    ULONG i = 0 ;
    ULONG currentValue = 0 ;
    nsCAutoString alternativeValue ;
    BOOL retCode = TRUE ;

    for (i = 0 ; i < aNbProperties ; ++ i) {
        values [currentValue].ulPropTag = aPropertiesTag [i] ;
        if (PROP_TYPE(aPropertiesTag [i]) == PT_UNICODE) {
            values [currentValue ++].Value.lpszW = NS_CONST_CAST(WCHAR *, aValues [i].get()) ;
        }
        else if (PROP_TYPE(aPropertiesTag [i]) == PT_STRING8) {
            alternativeValue.AssignWithConversion(aValues [i].get()) ;
            char *av = nsCRT::strdup(alternativeValue.get()) ;
            if (!av) {
                retCode = FALSE ;
                break ;
            }
            values [currentValue ++].Value.lpszA = av ;
        }
    }
    if (retCode)
        retCode = SetMAPIProperties(aObject, currentValue, values) ;
    for (i = 0 ; i < currentValue ; ++ i) {
        if (PROP_TYPE(aPropertiesTag [i]) == PT_STRING8) {
            nsCRT::free(values [i].Value.lpszA) ;
        }
    }
    delete [] values ;
    return retCode ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::SetPropertyDate ( const nsMapiEntry aObject,
ULONG  aPropertyTag,
WORD  aYear,
WORD  aMonth,
WORD  aDay 
)

Definition at line 618 of file nsAbWinHelper.cpp.

{
    SPropValue value ;
    
    value.ulPropTag = aPropertyTag ;
    if (PROP_TYPE(aPropertyTag) == PT_SYSTIME) {
        SYSTEMTIME readableTime ;

        readableTime.wYear = aYear ;
        readableTime.wMonth = aMonth ;
        readableTime.wDay = aDay ;
        readableTime.wDayOfWeek = 0 ;
        readableTime.wHour = 0 ;
        readableTime.wMinute = 0 ;
        readableTime.wSecond = 0 ;
        readableTime.wMilliseconds = 0 ;
        if (SystemTimeToFileTime(&readableTime, &value.Value.ft)) {
            return SetMAPIProperties(aObject, 1, &value) ;
        }
        return TRUE ;
    }
    return FALSE ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL nsAbWinHelper::SetPropertyUString ( const nsMapiEntry aObject,
ULONG  aPropertyTag,
const PRUnichar aValue 
)

Definition at line 559 of file nsAbWinHelper.cpp.

{
    SPropValue value ;
    nsCAutoString alternativeValue ;

    value.ulPropTag = aPropertyTag ;
    if (PROP_TYPE(aPropertyTag) == PT_UNICODE) {
        value.Value.lpszW = NS_CONST_CAST(WCHAR *, aValue) ;
    }
    else if (PROP_TYPE(aPropertyTag) == PT_STRING8) {
        alternativeValue.AssignWithConversion(aValue) ;
        value.Value.lpszA = NS_CONST_CAST(char *, alternativeValue.get()) ;
    }
    else {
        PRINTF(("Property %08x is not a string.\n", aPropertyTag)) ;
        return TRUE ;
    }
    return SetMAPIProperties(aObject, 1, &value) ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 515 of file nsAbWinHelper.cpp.

{
    nsMapiInterfaceWrapper<LPMAPICONTAINER> container ;
    nsMapiInterfaceWrapper<LPMAPIPROP> subObject ;
    ULONG objType = 0 ;
    
    mLastError = mAddressBook->OpenEntry(aContainer.mByteCount, aContainer.mEntryId,
                                         &IID_IMAPIContainer, 0, &objType, 
                                         container) ;
    if (HR_FAILED(mLastError)) {
        PRINTF(("Cannot open container %08x.\n", mLastError)) ;
        return FALSE ;
    }
    mLastError = container->OpenEntry(aEntry.mByteCount, aEntry.mEntryId,
                                      NULL, 0, &objType, subObject) ;
    return HR_SUCCEEDED(mLastError) ;
}

Member Data Documentation

LPADRBOOK nsAbWinHelper::mAddressBook [protected]

Definition at line 132 of file nsAbWinHelper.h.

PRUint32 nsAbWinHelper::mEntryCounter = 0 [static, protected]

Definition at line 133 of file nsAbWinHelper.h.

Definition at line 131 of file nsAbWinHelper.h.

PRLock * nsAbWinHelper::mMutex = PR_NewLock() [static, protected]

Definition at line 134 of file nsAbWinHelper.h.


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