-
June 3rd, 2004, 08:49 AM
#1
TAPI3 forwarding please Help
Hi Guys,
i'm newbie im Tapi programming and i try to write a programm to forward a call to another address but it's not work and i don'T know why. Can someboy help me here my code...
BOOL
CMyTAPI2::Addr_Cap(ITAddress * pAddress)
{
ITAddressCapabilities * pAddressCaps;
long lType = 0;
BOOL bFoundAddress = FALSE;
HRESULT hr = S_OK;
hr = pAddress->QueryInterface(IID_ITAddressCapabilities, (void**)&pAddressCaps);
hr = pAddressCaps->get_AddressCapability( AC_ADDRESSTYPES, &lType );
//AC_TRANSFERMODES
pAddressCaps->Release();
if ( SUCCEEDED(hr) )
{
// does it support audio?
if ( AddressSupportsMediaType(pAddress, TAPIMEDIATYPE_AUDIO) )
{
//hr = pAddressCaps->get_AddressCapability( AC_TRANSFERMODES, &lType );
if(LINEADDRCAPFLAGS_FWDCONSULT & lType)
{
bFoundAddress = TRUE;
}
}
}
// pAddress->Release();
return bFoundAddress;
}
HRESULT
CMyTAPI2::ForwardTheCall( PWCHAR szAddressToCall,
PWCHAR szAddressCaller,
ITAddress * pAddress
)
{
HRESULT hr;
BSTR pDestAddress, pCallerAddress;
BSTR ppDestinationAddress, ppCallerAddress;
ITForwardInformation *pForwardInfo = NULL;
/*hr = pAddress->CreateForwardInfoObject( &pForwardInfo);
if(FAILED(hr))
{
gpTapiLib->DoMessage( 0, L"Could not CreateForwardInfo.");
}*/
hr = pAddress->get_CurrentForwardInfo( &pForwardInfo);
if(FAILED(hr))
{
gpTapiLib->DoMessage( 0, L"Could not get_CurrentForwardInfo.");
}
pDestAddress = SysAllocString( (unsigned short*)szAddressToCall );
pCallerAddress = SysAllocString( (unsigned short*) szAddressCaller);
hr = pForwardInfo->SetForwardType( LINEFORWARDMODE_UNCOND ,//Forward all calls unconditionally
pDestAddress,
pCallerAddress
);
if(FAILED(hr))
{
gpTapiLib->DoMessage( 0, L"Could not SetForwardType.");
}
hr = pForwardInfo->GetForwardType( LINEFORWARDMODE_UNCOND ,//Forward all calls unconditionally
&ppDestinationAddress,
&ppCallerAddress
);
if(FAILED(hr))
{
gpTapiLib->DoMessage( 0, L"Could not GetForwardType.");
}
SysFreeString(pDestAddress);
SysFreeString(pCallerAddress);
SysFreeString(ppDestinationAddress);
SysFreeString(ppCallerAddress);
if(Addr_Cap(pAddress))
hr = pAddress->Forward(
pForwardInfo,
gpCall);
else
hr = pAddress->Forward(
pForwardInfo,
NULL);
pForwardInfo->Release();
if(hr == S_OK)
{
return S_OK;
}
else if(hr == E_INVALIDARG)
{
gpTapiLib->DoMessage( 0, L"The address does not support forwarding, or pCall does not point to a valid call.");
}
else if(hr == TAPI_E_TIMEOUT)
{
gpTapiLib->DoMessage( 0, L"The operation failed because the TAPI 3 DLL timed it out. The timeout interval is two minutes.");
}
else if(hr == E_POINTER)
{
gpTapiLib->DoMessage( 0, L"The pForwardInfo or pCall parameter is not a valid pointer.");
}
else if(hr == E_OUTOFMEMORY)
{
gpTapiLib->DoMessage( 0, L"Insufficient memory exists to perform the operation.");
}
else if(FAILED(hr))
{
gpTapiLib->DoMessage( 0, L"could not forwarding");
}
return S_OK;
}
thank you in adavance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|