Back to index

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

#include <MozABPCManager.h>

List of all members.

Public Member Functions

 MozABPCManager ()
 ~MozABPCManager ()
long GetPCABList (DWORD *pCategoryCount, LONG **pCategoryIndexList, CPString ***pCategoryNameList, CPString ***pCategoryURLList, BOOL **pDirFlags)
long SynchronizePCAB (LONG categoryIndex, LONG categoryId, CPString &categoryName, DWORD updatedPalmRecCount, CPalmRecord **updatedPalmRecList, DWORD *pUpdatedPCRecList, CPalmRecord ***updatedPCRecList)
long AddRecords (BOOL replaceExisting, LONG categoryIndex, CPString &categoryName, DWORD updatedPalmRecCount, CPalmRecord **updatedPalmRecList)
long LoadAllRecords (CPString &ABName, DWORD *pPCRecListCount, CPalmRecord ***pPCRecList)
long NotifySyncDone (BOOL success, LONG catIndex=-1, DWORD newRecCount=0, DWORD *newRecIDList=NULL)
long UpdatePCABSyncInfo (LONG categoryIndex, CPString &categoryName)
long DeletePCAB (LONG categoryIndex, CPString &categoryName, CPString &categoryUrl)
long RenamePCAB (LONG categoryIndex, CPString &categoryName, CPString &categoryUrl)
bool PCABDeleted (CPString &abName)

Static Public Attributes

static BOOL gUseHomeAddress
static BOOL gPreferHomePhone

Private Member Functions

BOOL InitMozPalmSyncInstance (IPalmSync **aRetValue)

Detailed Description

Definition at line 47 of file MozABPCManager.h.


Constructor & Destructor Documentation

Definition at line 50 of file MozABPCManager.h.

{ }

Definition at line 51 of file MozABPCManager.h.

{ }

Member Function Documentation

long MozABPCManager::AddRecords ( BOOL  replaceExisting,
LONG  categoryIndex,
CPString &  categoryName,
DWORD  updatedPalmRecCount,
CPalmRecord **  updatedPalmRecList 
)

Definition at line 233 of file MozABPCManager.cpp.

{
    long        retval = 0;
    IPalmSync     *pNsPalmSync = NULL;

    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    CMozABConduitRecord ** tempMozABConduitRecList = new CMozABConduitRecord*[updatedPalmRecCount];
    nsABCOMCardStruct * palmCardList = new nsABCOMCardStruct[updatedPalmRecCount];
    if(palmCardList) 
    {
        for(DWORD i=0; i<updatedPalmRecCount; i++) 
        {
            if(*updatedPalmRecList) 
            {
                CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(**updatedPalmRecList);
                memcpy(&palmCardList[i], &pConduitRecord->m_nsCard, sizeof(nsABCOMCardStruct));
                tempMozABConduitRecList[i]=pConduitRecord;
            }
            updatedPalmRecList++;
        }
        // get the ABList
        HRESULT hres = pNsPalmSync->nsAddAllABRecords(FALSE, replaceExisting, categoryIndex, categoryName.GetBuffer(0),
                                                updatedPalmRecCount, palmCardList);
        if (hres != S_OK)
            retval = (long) hres;
    }
    else
        retval = GEN_ERR_LOW_MEMORY;

        delete palmCardList;
    if(tempMozABConduitRecList) 
    {

        for(DWORD i=0; i<updatedPalmRecCount; i++)
            delete tempMozABConduitRecList[i];
        delete tempMozABConduitRecList;
    }
    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long MozABPCManager::DeletePCAB ( LONG  categoryIndex,
CPString &  categoryName,
CPString &  categoryUrl 
)

Definition at line 360 of file MozABPCManager.cpp.

{
    IPalmSync     *pNsPalmSync = NULL;
    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    HRESULT hres = pNsPalmSync->nsDeleteAB(FALSE, categoryIndex, categoryName, categoryUrl);
    long retval = (long) hres;

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long MozABPCManager::GetPCABList ( DWORD pCategoryCount,
LONG **  pCategoryIndexList,
CPString ***  pCategoryNameList,
CPString ***  pCategoryURLList,
BOOL **  pDirFlags 
)

Definition at line 97 of file MozABPCManager.cpp.

{
    lpnsMozABDesc mozABNameList=NULL;

    short  dwMozABCount=0;
    long retval = 0;
    IPalmSync *pNsPalmSync = NULL;

    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    // get the ABList
    HRESULT hres = pNsPalmSync->nsGetABList(FALSE, &dwMozABCount, 
                                        &mozABNameList, pCategoryIndexList, pDirFlags);
    if (hres != S_OK) {
        retval = (long) hres;
        return retval;
    }

    *pCategoryCount = dwMozABCount;

    CPString ** abNameList = (CPString **) malloc(sizeof(CPString *) * dwMozABCount);
    if (!abNameList) {
        free(mozABNameList);
        return GEN_ERR_LOW_MEMORY;
    }
    memset(abNameList, 0, sizeof(CPString *) * dwMozABCount);
    *pCategoryNameList = abNameList;

    CPString ** abUrlList = (CPString **) malloc(sizeof(CPString *) * dwMozABCount);
    if (!abUrlList) {
        free(mozABNameList);
        free(abNameList);
        return GEN_ERR_LOW_MEMORY;
    }
    memset(abUrlList, 0, sizeof(CPString *) * dwMozABCount);
    *pCategoryUrlList = abUrlList;

    for (int i=0; i < dwMozABCount; i++) {
        CPString * pABName = new CPString((LPCTSTR) mozABNameList[i].lpszABName);
        if (pABName)
            *abNameList = pABName;
        else
            return GEN_ERR_LOW_MEMORY;
        CoTaskMemFree(mozABNameList[i].lpszABName);
        abNameList++;

        CPString * pABUrl = new CPString((LPCTSTR) mozABNameList[i].lpszABUrl);
        if (pABUrl)
            *abUrlList = pABUrl;
        else
            return GEN_ERR_LOW_MEMORY;
        CoTaskMemFree(mozABNameList[i].lpszABUrl);
        abUrlList++;
    }
    
    CoTaskMemFree(mozABNameList);
    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 61 of file MozABPCManager.cpp.

{
    // Check wehther this thread has a valid Interface
    // by looking into thread-specific-data variable

    *aRetValue = (IPalmSync *)TlsGetValue(tId);

    // Check whether the pointer actually resolves to
    // a valid method call; otherwise mozilla is not running

    if ((*aRetValue) && (*aRetValue)->IsValid() == S_OK)
         return TRUE;

    HRESULT hRes = ::CoInitialize(NULL) ;

    hRes = ::CoCreateInstance(CLSID_CPalmSyncImp, NULL, CLSCTX_LOCAL_SERVER,
                                         IID_IPalmSync, (LPVOID *)aRetValue);

    if (hRes == S_OK)
        if (TlsSetValue(tId, (LPVOID)(*aRetValue)))
        {
            (*aRetValue)->nsUseABHomeAddressForPalmAddress(&gUseHomeAddress);
            (*aRetValue)->nsPreferABHomePhoneForPalmPhone(&gPreferHomePhone);
            return TRUE;
        }

    // Either CoCreate or TlsSetValue failed; so return FALSE

    if ((*aRetValue))
        (*aRetValue)->Release();

    ::CoUninitialize();
    return FALSE;
}

Here is the caller graph for this function:

long MozABPCManager::LoadAllRecords ( CPString &  ABName,
DWORD pPCRecListCount,
CPalmRecord ***  pPCRecList 
)

Definition at line 290 of file MozABPCManager.cpp.

{
    lpnsABCOMCardStruct mozCardList=NULL; // freed by MSCOM/Mozilla.
    int       dwMozCardCount=0;
    long        retval = 0;
    IPalmSync     *pNsPalmSync = NULL;

    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    // get the ABList
    HRESULT hres = pNsPalmSync->nsGetAllABCards(FALSE, -1, ABName.GetBuffer(0),
                                            &dwMozCardCount, &mozCardList);
    if (hres == S_OK && mozCardList) {
        *pPCRecListCount = dwMozCardCount;
        CPalmRecord ** mozRecordList = (CPalmRecord **) malloc(sizeof(CPalmRecord *) * dwMozCardCount);
        *pPCRecList = mozRecordList;
        if (mozRecordList) {
            memset(mozRecordList, 0, sizeof(CPalmRecord *) * dwMozCardCount);
            for (int i=0; i < dwMozCardCount; i++) {
                CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(mozCardList[i]);
                CPalmRecord * pMozRecord = new CPalmRecord;
                pConduitRecord->ConvertToGeneric(*pMozRecord);
                *mozRecordList = pMozRecord;
                mozRecordList++;
                delete pConduitRecord;
                CMozABConduitRecord::CleanUpABCOMCardStruct(&mozCardList[i]);
            }
        }
        else
            retval = GEN_ERR_LOW_MEMORY;
        CoTaskMemFree(mozCardList);
    }
    else
        retval = (long) hres;
    
    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long MozABPCManager::NotifySyncDone ( BOOL  success,
LONG  catIndex = -1,
DWORD  newRecCount = 0,
DWORD newRecIDList = NULL 
)

Definition at line 330 of file MozABPCManager.cpp.

{
    IPalmSync     *pNsPalmSync = NULL;
    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    // MS COM Proxy stub Dll will not accept NULL for this address
    if(!newRecIDList)
        newRecIDList = &newRecCount;

    HRESULT hres = pNsPalmSync->nsAckSyncDone(success, catIndex, newRecCount, newRecIDList);
    long retval = (long) hres;

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool MozABPCManager::PCABDeleted ( CPString &  abName)

Definition at line 277 of file MozABPCManager.cpp.

{
    IPalmSync     *pNsPalmSync = NULL;
    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return false;
    BOOL abDeleted;
    HRESULT hres = pNsPalmSync->nsGetABDeleted(ABName.GetBuffer(0), &abDeleted);
    return (hres == S_OK) ? abDeleted : false; // assume false;

}

Here is the call graph for this function:

Here is the caller graph for this function:

long MozABPCManager::RenamePCAB ( LONG  categoryIndex,
CPString &  categoryName,
CPString &  categoryUrl 
)

Definition at line 373 of file MozABPCManager.cpp.

{
    IPalmSync     *pNsPalmSync = NULL;
    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    HRESULT hres = pNsPalmSync->nsRenameAB(FALSE, categoryIndex, categoryName, categoryUrl);
    return (long) hres;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long MozABPCManager::SynchronizePCAB ( LONG  categoryIndex,
LONG  categoryId,
CPString &  categoryName,
DWORD  updatedPalmRecCount,
CPalmRecord **  updatedPalmRecList,
DWORD pUpdatedPCRecList,
CPalmRecord ***  updatedPCRecList 
)

Definition at line 159 of file MozABPCManager.cpp.

{
    lpnsABCOMCardStruct mozCardList=NULL;  // freed by MSCOM/Mozilla.
    int       dwMozCardCount=0;
    long        retval = 0;
    IPalmSync     *pNsPalmSync = NULL;

    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    CMozABConduitRecord ** tempMozABConduitRecList = new CMozABConduitRecord*[updatedPalmRecCount];
    nsABCOMCardStruct * palmCardList = new nsABCOMCardStruct[updatedPalmRecCount];
    if(palmCardList)
    {
        for(DWORD i=0; i<updatedPalmRecCount; i++) 
        {
            if(*updatedPalmRecList)
            {
                CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(**updatedPalmRecList);
                memcpy(&palmCardList[i], &pConduitRecord->m_nsCard, sizeof(nsABCOMCardStruct));
                tempMozABConduitRecList[i]=pConduitRecord;
            }
            updatedPalmRecList++;
        }
        // synchronize and get the updated cards in MozAB
        HRESULT hres = pNsPalmSync->nsSynchronizeAB(FALSE, categoryIndex, categoryId, categoryName.GetBuffer(0),
                                                updatedPalmRecCount, palmCardList,
                                                &dwMozCardCount, &mozCardList);
        if(hres == S_OK && mozCardList) 
        {
            *pUpdatedPCRecListCount = dwMozCardCount;
            CPalmRecord ** mozRecordList = (CPalmRecord **) malloc(sizeof(CPalmRecord *) * dwMozCardCount);
            *updatedPCRecList = mozRecordList;
            if (mozRecordList) 
            {
                memset(mozRecordList, 0, sizeof(CPalmRecord *) * dwMozCardCount);
                int i=0;
                for (i=0; i < dwMozCardCount; i++) 
                {
                    CMozABConduitRecord * pConduitRecord = new CMozABConduitRecord(mozCardList[i]);
                    CPalmRecord * pMozRecord = new CPalmRecord;
                    pConduitRecord->ConvertToGeneric(*pMozRecord);
                    *mozRecordList = pMozRecord;
                    mozRecordList++;
                    delete pConduitRecord;
                    CMozABConduitRecord::CleanUpABCOMCardStruct(&mozCardList[i]);
                }
            }
            else
                retval = GEN_ERR_LOW_MEMORY;
            CoTaskMemFree(mozCardList);
        }
        else
            retval = (long) hres;
    }
    else
        retval = GEN_ERR_LOW_MEMORY;


        delete palmCardList;
    if(tempMozABConduitRecList) 
    {
        for(DWORD j=0; j<updatedPalmRecCount; j++)
            delete tempMozABConduitRecList[j];
        delete tempMozABConduitRecList;
    }

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long MozABPCManager::UpdatePCABSyncInfo ( LONG  categoryIndex,
CPString &  categoryName 
)

Definition at line 347 of file MozABPCManager.cpp.

{
    IPalmSync     *pNsPalmSync = NULL;
    // get the interface 
    if (!InitMozPalmSyncInstance(&pNsPalmSync))
        return GEN_ERR_NOT_SUPPORTED;

    HRESULT hres = pNsPalmSync->nsUpdateABSyncInfo(FALSE, categoryIndex, categoryName);
    long retval = (long) hres;

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 81 of file MozABPCManager.h.

Definition at line 80 of file MozABPCManager.h.


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