////////////////////////////////////////////////////////////////////////////
// CallNotification.h : Declaration of the CCallNotification object
//
////////////////////////////////////////////////////////////////////////////
#ifndef __CALLNOTIFICATION_H__
#define __CALLNOTIFICATION_H__
/////////////////////////////////////////////////////////////////////////////
// CCallNotification
class CCallNotification : public ITCallNotification
{
private:
DWORD m_dwRefCount;
ITAddress * m_pAddress;
public:
// CCallNotification implements ITCallNotification
// Declare ITCallNotification methods here
HRESULT STDMETHODCALLTYPE CallEventNotification(
ITAddress * pAddress,
CALL_EVENT_TYPE type,
IDispatch * pEvent
);
// other COM stuff:
public:
// constructor
CCallNotification(){}
// destructor
~CCallNotification(){}
// initialization function
// this stuff could also be done in the
// constructor
HRESULT Initialize( ITAddress * pAddress )
{
m_dwRefCount = 1;
m_pAddress = pAddress;
m_pAddress->AddRef();
return S_OK;
}
void Shutdown()
{
if (NULL != m_pAddress)
{
m_pAddress->Release();
}
}
// IUnknown implementation
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject)
{
if (iid == IID_ITCallNotification)
{
m_dwRefCount++;
*ppvObject = (void *)this;
return S_OK;
}
if (iid == IID_IUnknown)
{
m_dwRefCount++;
*ppvObject = (void *)this;
return S_OK;
}
return S_FALSE;
}
ULONG STDMETHODCALLTYPE AddRef()
{
m_dwRefCount++;
return m_dwRefCount;
}
ULONG STDMETHODCALLTYPE Release()
{
ULONG l;
l = m_dwRefCount--;
if ( 0 == m_dwRefCount)
{
delete this;
}
return l;
}
};
#endif //__CALLNOTIFICATION_H__