⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tapiaddr.cpp

📁 基于Tapi 3.0的软电话源代码
💻 CPP
字号:
//------------------------------------------------------------------------------------
//  Copyright (c) 2002 Avaya Global SME Solutions 
//------------------------------------------------------------------------------------
//  Project name: TAPI 3 Test Harness
//  Module file : TAPIAddr.cpp
//  Compiler    : Visual C++ 6.0
//------------------------------------------------------------------------------------
//  Description : In this module CTAPIAddr class is implemented, Map container of addresses 
//                is created as well. Map container is indexed by dialable address and contains 
//                pointer to ITAddress interface. CTAPIAddr keeps registration number for the
//                address. This number is given when some address are registred to receive 
//                event notification (on ITTAPI::RegisterCallNotifications). We need that for 
//                unregistration (done in destructor).
//------------------------------------------------------------------------------------

#include "stdafx.h"
#include "tapi3app.h"
#include "TAPIConn.h"
#include "TAPIAddr.h"

// initialization of static member at file scope
CMap<CString, CString&, CTAPIAddr*, CTAPIAddr*> CTAPIAddr::m_TAPIAddrMap;

int CTAPIAddr::GetAddrCount()
{
	return m_TAPIAddrMap.GetCount();
}

CTAPIAddr* CTAPIAddr::GetAddrAt(int Index)
{
	if (Index >=0  && Index < CTAPIAddr::GetAddrCount())
	{
		CString sKey;
		CTAPIAddr* pAddr;
		POSITION pos = m_TAPIAddrMap.GetStartPosition();
		do
		{
			m_TAPIAddrMap.GetNextAssoc(pos, sKey, pAddr);
			Index--;
		} while (Index >= 0);
		return pAddr;
	}
	return NULL;
}

void CTAPIAddr::AddToAddrMap(CString Addr, CTAPIAddr *pAddr)
{
	pAddr->AddRef();
	m_TAPIAddrMap.SetAt(Addr, pAddr);					
}

CTAPIAddr* CTAPIAddr::GetFromAddrMap(CString& s)
{
	CTAPIAddr* pAddr;
	if (m_TAPIAddrMap.Lookup(s, pAddr))
	{
		pAddr->AddRef();
		return pAddr;
	}
	return NULL;
}

void CTAPIAddr::ReleaseAddrMap()
{
	DWORD r;
	POSITION pos = m_TAPIAddrMap.GetStartPosition();
	while (pos != NULL)
	{
		CString sKey;
		CTAPIAddr* pAddr;
		
		m_TAPIAddrMap.GetNextAssoc(pos, sKey, pAddr);
		if (pAddr) r = pAddr->Release();
	}
	m_TAPIAddrMap.RemoveAll();
}

// Construction/Destruction
CTAPIAddr::CTAPIAddr(ITTAPI* pTAPI,
					 BSTR& DisplayAddr, 
					 BSTR& DialableAddr, 
					 long& SupportedMedia,
					 long& UnRegister,
					 ITAddress* pAddr)
{


	m_sDisplayAddr = CString(DisplayAddr);
	m_sDialableAddr = CString(DialableAddr);
	m_lSupportedMedia = SupportedMedia;
	m_lUnRegister = UnRegister;

	m_pTAPIAddr = pAddr;
	m_pTAPIAddr->AddRef();

	m_pTAPI = pTAPI;
	m_pTAPI->AddRef();
}

CTAPIAddr::~CTAPIAddr()
{
	HRESULT hr;
	ULONG r;

	// Unregister the call notification
	if (m_lUnRegister)
	{
		hr = m_pTAPI->UnregisterNotifications(m_lUnRegister);
		if (hr != S_OK)
		{
			PRINT_INIT(-1, 0, "Failed to unregister call notification for address %s, hr=%x", m_sDisplayAddr, hr);
		}
	}

	// Release the address
	if ((r = m_pTAPIAddr->Release()) > 1)
	{	
		PRINT_INIT(-1, 0, "Unable to release TAPI address %s, Ref=%x", m_sDisplayAddr, r);
	}
	else
	{
		PRINT_INIT(-1, 0, "%s closed and released.", m_sDisplayAddr);
	}

	// Release the TAPI handle
	m_pTAPI->Release();
	
} 

ITAddress* CTAPIAddr::GetITAddress() 
{ 
	if (m_pTAPIAddr != NULL) m_pTAPIAddr->AddRef();
	return m_pTAPIAddr; 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -