From: sree.is.free on
Hi,

I am working on developing a Pocket PC application running on
Windows Mobile 6.0. I am using TAPI 2.x.I am having an issue with
LineForward API.When I am calling the LineForward API, I am getting an
error LINEERR_INVALADDRESSID. I am not able to understand why I am
getting this error. I have given below the code that I have written .
Could someone help me out on this. Thanks in advance



CallForwarding(HLINE hLine,LPCTSTR lpszPhoneNum)

lphConsultCall = (HCALL *) malloc(sizeof(HCALL));
memset(lphConsultCall,NULL,sizeof(HCALL))))

// Allocating 50 extra bytes to store the destination address
TotalSize = sizeof(LINEFORWARDLIST) + 50;

lpForwardList = (LINEFORWARDLIST *) malloc(TotalSize);

// set initial values
memset(lpForwardList, 0, TotalSize)

// Total size of the data structure, in bytes which includes the
size
// of destination phoneaddress also.
lpForwardList->dwTotalSize = TotalSize;


// Passing only 1 LINEFORWARD array entry
lpForwardList->dwNumEntries = 1;


//Forward all calls unconditionally, irrespective of their origin
lpForwardList->ForwardList[0].dwForwardMode =
LINEFORWARDMODE_UNCOND;


// Size of Destination Address. Giving a little more space than
required 10 bytes
lpForwardList->ForwardList[0].dwDestAddressSize = 14 *
sizeof(TCHAR);


// Offset where the destination address is stored
lpForwardList->ForwardList[0].dwDestAddressOffset =
sizeof(LINEFORWARDLIST);

// Storing the actual address location
wcsncpy ((LPTSTR)((LPTSTR)lpForwardList + lpForwardList-
>ForwardList[0].dwDestAddressOffset),
(LPTSTR)lpszPhoneNum,
lpForwardList->ForwardList[0].dwDestAddressSize);

// Allocate memory to the structure holding the call parameters
lpCallParams = (LPLINECALLPARAMS)
LocalAlloc (LPTR,
sizeof (LINECALLPARAMS))

// Initialise memory locations to zero
ZeroMemory(lpCallParams, sizeof (LINECALLPARAMS));

dwReturn = lineForward(
hLine, // Device Id
TRUE, // Forward all incoming
calls
0, // Ignored if the 2nd parameter is TRUE
lpForwardList,
0, // Number of rings to be considered as
"No answer"
NULL, // This handle is set to NULL if no
consultation call is created.
NULL // Call paramters
);


CallForwarding is called when the CallBackFunction receives
LINECALLSTATE_OFFERING event

case LINE_CALLSTATE: // review the call state messages
{
switch( dwParam1 )
{
case LINECALLSTATE_OFFERING: // New call is coming
{
lpCallInfo = (LINECALLINFO *)malloc(sizeof(LINECALLINFO) +
1000)
memset( lpCallInfo, 0, sizeof( LINECALLINFO ) + 1000 )
lpCallInfo->dwTotalSize = sizeof( LINECALLINFO ) + 1000;

// Getting more info abt the call
ret = lineGetCallInfo((HCALL)hDevice,lpCallInfo);
ret =
lineSetCallPrivilege( (HCALL)hDevice, LINECALLPRIVILEGE_OWNER );
CallForwarding(lpCallInfo-
>hLine,lpszPhoneNum);
}
}
}