|
|
|
date: Sat, 7 Jun 2008 18:22:51 -0400,
group: microsoft.public.win32.programmer.tapi
back
TAPI lineCallback not being invoked through MFC app
Hi,
I'm a relative newbie to TAPI programming. I'm building a MFC based WM6
application for Pocket PC's to handle incoming calls after a fixed number of
rings (preset by the user). My method of performing lineInitialize is as
follows:
1. Main dialog screen shows up and I perform lineInitialize as follows
during the dialog's initialization:
In the main dialog file:
m_hTapi = new TapiConnection();
m_hTapi->Create();
Create()....
lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
m_strAppName, &m_dwNumDevs);
The return value from this is 0 and I know that the line has been
successfully initialized (dwNumDevs comes back with 8).
2. My next step is to wait and observe for the lineCallbackFunc to be
invoked by TAPI for the following event (LINE_LINEDEVSTATE) in order to get
the # of rings.
case LINEDEVSTATE_RINGING:
OutputDebugString(TEXT("Ringing\n"));
if (OpenLineForIncoming())
lineAnswer((HCALL)dwDevice, NULL, 0);
break;
As you can see here, OpenLineForIncoming() opens a line with monitor+owner
privileges so that the call can be answered after a fixed number of rings.
lReturn = lineOpen(m_hLineApp, m_dwDeviceID, &m_hLine, m_dwAPIVersion, 0, 0,
LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, 0, 0);
However, for some reason, the MFC application does not seem to invoke the
lineCallbackFunc at all! Does anyone have any suggestions? Am I supposed to
start a new thread of any sort for the callback function to be invoked
correctly?
date: Sat, 7 Jun 2008 18:22:51 -0400
author: Abhishek Sen
Re: TAPI lineCallback not being invoked through MFC app
A couple of things here.
Firstly, you say that your callback function has not been invoked. But you
not specify a callback function. 6th parameter in lineOpen.
Secondly, you should test your device using a known working TAPI program
such as dialer or TAPI browser. Just to be sure your device works with TAPI
and supports the events you require.
lineGetDevcaps (think that is the one) will give you the capabilities of a
given device.
Angus
"Abhishek Sen" wrote in message
news:#tKXH0OyIHA.2068@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I'm a relative newbie to TAPI programming. I'm building a MFC based WM6
> application for Pocket PC's to handle incoming calls after a fixed number
of
> rings (preset by the user). My method of performing lineInitialize is as
> follows:
>
> 1. Main dialog screen shows up and I perform lineInitialize as follows
> during the dialog's initialization:
>
> In the main dialog file:
> m_hTapi = new TapiConnection();
>
> m_hTapi->Create();
>
> Create()....
> lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
> m_strAppName, &m_dwNumDevs);
>
> The return value from this is 0 and I know that the line has been
> successfully initialized (dwNumDevs comes back with 8).
>
> 2. My next step is to wait and observe for the lineCallbackFunc to be
> invoked by TAPI for the following event (LINE_LINEDEVSTATE) in order to
get
> the # of rings.
>
> case LINEDEVSTATE_RINGING:
> OutputDebugString(TEXT("Ringing\n"));
> if (OpenLineForIncoming())
> lineAnswer((HCALL)dwDevice, NULL, 0);
> break;
>
> As you can see here, OpenLineForIncoming() opens a line with monitor+owner
> privileges so that the call can be answered after a fixed number of rings.
>
> lReturn = lineOpen(m_hLineApp, m_dwDeviceID, &m_hLine, m_dwAPIVersion, 0,
0,
> LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, 0, 0);
>
> However, for some reason, the MFC application does not seem to invoke the
> lineCallbackFunc at all! Does anyone have any suggestions? Am I supposed
to
> start a new thread of any sort for the callback function to be invoked
> correctly?
>
>
date: Sun, 8 Jun 2008 18:31:54 +0100
author: Angus
Re: TAPI lineCallback not being invoked through MFC app
Hi Angus,
Thanks for your response. The callback is being invoked now after adding the function in the call to lineOpen(). In order to retrieve the number of rings, I wait for the
LINE_LINEDEVSTATE events with dwParam1 of LINEDEVSTATE_RINGING. Initially, I was not receiving any LINE_LINEDEVSTATE events but after making the following call after lineOpen()
lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff),
I am now able receive the number of rings, although the number of rings as obtained is pretty sporadic - sometimes I receive 3 rings and no more, sometimes 1 etc. The MAIN problem now is that when I go to answer the call after receiving the LINEDEVSTATE_RINGING event, the lineAnswer() call fails with LINEERR_INVALCALLHANDLE for some reason. The callback function is coming back with an incorrect call handle value and as a result, when I go to deallocate it after the call ends, that fails too because of the invalid call handle. Do you guys have any idea?
Cheers,
Abhi.
"Angus" wrote in message news:uLKyN2YyIHA.5520@TK2MSFTNGP06.phx.gbl...
>A couple of things here.
>
> Firstly, you say that your callback function has not been invoked. But you
> not specify a callback function. 6th parameter in lineOpen.
>
> Secondly, you should test your device using a known working TAPI program
> such as dialer or TAPI browser. Just to be sure your device works with TAPI
> and supports the events you require.
>
> lineGetDevcaps (think that is the one) will give you the capabilities of a
> given device.
>
> Angus
>
>
>
> "Abhishek Sen" wrote in message
> news:#tKXH0OyIHA.2068@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I'm a relative newbie to TAPI programming. I'm building a MFC based WM6
>> application for Pocket PC's to handle incoming calls after a fixed number
> of
>> rings (preset by the user). My method of performing lineInitialize is as
>> follows:
>>
>> 1. Main dialog screen shows up and I perform lineInitialize as follows
>> during the dialog's initialization:
>>
>> In the main dialog file:
>> m_hTapi = new TapiConnection();
>>
>> m_hTapi->Create();
>>
>> Create()....
>> lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
>> m_strAppName, &m_dwNumDevs);
>>
>> The return value from this is 0 and I know that the line has been
>> successfully initialized (dwNumDevs comes back with 8).
>>
>> 2. My next step is to wait and observe for the lineCallbackFunc to be
>> invoked by TAPI for the following event (LINE_LINEDEVSTATE) in order to
> get
>> the # of rings.
>>
>> case LINEDEVSTATE_RINGING:
>> OutputDebugString(TEXT("Ringing\n"));
>> if (OpenLineForIncoming())
>> lineAnswer((HCALL)dwDevice, NULL, 0);
>> break;
>>
>> As you can see here, OpenLineForIncoming() opens a line with monitorꌉ
>> privileges so that the call can be answered after a fixed number of rings.
>>
>> lReturn = lineOpen(m_hLineApp, m_dwDeviceID, &m_hLine, m_dwAPIVersion, 0,
> 0,
>> LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, 0, 0);
>>
>> However, for some reason, the MFC application does not seem to invoke the
>> lineCallbackFunc at all! Does anyone have any suggestions? Am I supposed
> to
>> start a new thread of any sort for the callback function to be invoked
>> correctly?
>>
>>
>
>
date: Sun, 8 Jun 2008 19:23:39 -0400
author: Abhishek Sen
Re: TAPI lineCallback not being invoked through MFC app
Please submit a code snippet. Without code we have no idea what you are doing.
"Abhishek Sen" wrote in message news:#P9hx6byIHA.5832@TK2MSFTNGP02.phx.gbl...
Hi Angus,
Thanks for your response. The callback is being invoked now after adding the function in the call to lineOpen(). In order to retrieve the number of rings, I wait for the
LINE_LINEDEVSTATE events with dwParam1 of LINEDEVSTATE_RINGING. Initially, I was not receiving any LINE_LINEDEVSTATE events but after making the following call after lineOpen()
lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff),
I am now able receive the number of rings, although the number of rings as obtained is pretty sporadic - sometimes I receive 3 rings and no more, sometimes 1 etc. The MAIN problem now is that when I go to answer the call after receiving the LINEDEVSTATE_RINGING event, the lineAnswer() call fails with LINEERR_INVALCALLHANDLE for some reason. The callback function is coming back with an incorrect call handle value and as a result, when I go to deallocate it after the call ends, that fails too because of the invalid call handle. Do you guys have any idea?
Cheers,
Abhi.
"Angus" wrote in message news:uLKyN2YyIHA.5520@TK2MSFTNGP06.phx.gbl...
>A couple of things here.
>
> Firstly, you say that your callback function has not been invoked. But you
> not specify a callback function. 6th parameter in lineOpen.
>
> Secondly, you should test your device using a known working TAPI program
> such as dialer or TAPI browser. Just to be sure your device works with TAPI
> and supports the events you require.
>
> lineGetDevcaps (think that is the one) will give you the capabilities of a
> given device.
>
> Angus
>
>
>
> "Abhishek Sen" wrote in message
> news:#tKXH0OyIHA.2068@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I'm a relative newbie to TAPI programming. I'm building a MFC based WM6
>> application for Pocket PC's to handle incoming calls after a fixed number
> of
>> rings (preset by the user). My method of performing lineInitialize is as
>> follows:
>>
>> 1. Main dialog screen shows up and I perform lineInitialize as follows
>> during the dialog's initialization:
>>
>> In the main dialog file:
>> m_hTapi = new TapiConnection();
>>
>> m_hTapi->Create();
>>
>> Create()....
>> lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
>> m_strAppName, &m_dwNumDevs);
>>
>> The return value from this is 0 and I know that the line has been
>> successfully initialized (dwNumDevs comes back with 8).
>>
>> 2. My next step is to wait and observe for the lineCallbackFunc to be
>> invoked by TAPI for the following event (LINE_LINEDEVSTATE) in order to
> get
>> the # of rings.
>>
>> case LINEDEVSTATE_RINGING:
>> OutputDebugString(TEXT("Ringing\n"));
>> if (OpenLineForIncoming())
>> lineAnswer((HCALL)dwDevice, NULL, 0);
>> break;
>>
>> As you can see here, OpenLineForIncoming() opens a line with monitorꌉ
>> privileges so that the call can be answered after a fixed number of rings.
>>
>> lReturn = lineOpen(m_hLineApp, m_dwDeviceID, &m_hLine, m_dwAPIVersion, 0,
> 0,
>> LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, 0, 0);
>>
>> However, for some reason, the MFC application does not seem to invoke the
>> lineCallbackFunc at all! Does anyone have any suggestions? Am I supposed
> to
>> start a new thread of any sort for the callback function to be invoked
>> correctly?
>>
>>
>
>
date: Mon, 9 Jun 2008 09:12:00 +0100
author: Angus
Re: TAPI lineCallback not being invoked through MFC app
BOOL TapiConnection::InitializeTapi()
{
BOOL bDeleteBuffer = FALSE;
LONG lReturn = 0;
if (m_hLineApp) // If we're already initialized, then initialization succeeds.
return TRUE;
if (m_bInitializing) // If we're in the middle of initializing, then fail, we're not done.
return FALSE;
m_bInitializing = TRUE;
m_strAppName = AfxGetAppName();
do
{
lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc, m_strAppName, &m_dwNumDevs);
if (!m_dwNumDevs)
{
OutputDebugString(TEXT("There are no telephony devices installed.\n"));
m_bInitializing = FALSE;
return FALSE;
}
if (HandleLineErr(lReturn))
continue;
else
{
OutputDebugString(TEXT("lineInitialize unhandled error.\n"));
m_bInitializing = FALSE;
return FALSE;
}
} while (lReturn != ERROR_SUCCESS);
OutputDebugString(TEXT("Tapi initialized.\n"));
m_bInitializing = FALSE;
if (OpenLineForIncoming())
OutputDebugString(TEXT("Line opened.\n"));
else
{
OutputDebugString(TEXT("Line could not be opened.\n"));
return FALSE;
}
return TRUE;
}
BOOL TapiConnection::OpenLineForIncoming()
{
BOOL bRet = TRUE, bDeleteBuffer = FALSE;
LONG lReturn = 0;
LPLINEDEVCAPS lpLineDevCaps = NULL;
if (m_bTapiInUse)
{
OutputDebugString(TEXT("A call is already being handled.\n"));
return FALSE;
}
m_bTapiInUse = TRUE; // We now have a call active. Prevent future calls.
lpLineDevCaps = GetDeviceLine(&m_dwAPIVersion, lpLineDevCaps); // Get the line to use
if (lpLineDevCaps == NULL) // Need to check the DevCaps to make sure this line is usable.
{
OutputDebugString(TEXT("Error on Requested line\n"));
bDeleteBuffer = TRUE;
}
else if (!(lpLineDevCaps->dwBearerModes & LINEBEARERMODE_VOICE ))
{
OutputDebugString(TEXT("The selected line doesn't support VOICE capabilities\n"));
bDeleteBuffer = TRUE;
}
else if (!(lpLineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE)) // Does this line have the capability for interactive voice?
{
OutputDebugString(TEXT("The selected line doesn't support INTERACTIVE VOICE capabilities"));
bDeleteBuffer = TRUE;
}
// Open the Line for an incoming call
if (!bDeleteBuffer)
{
do
{
lReturn = lineOpen(
m_hLineApp,
m_dwDeviceID,
&m_hLine,
m_dwAPIVersion,
0,
(DWORD)lineCallbackFunc,
LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER,
LINEMEDIAMODE_INTERACTIVEVOICE,
0);
if((lReturn == LINEERR_ALLOCATED)||(lReturn == LINEERR_RESOURCEUNAVAIL))
{
HangupCall();
OutputDebugString(TEXT("Line is already in use by a non-TAPI application or by another TAPI Service Provider.\n"));
OpenLineForIncoming();
bDeleteBuffer = TRUE;
}
if (HandleLineErr(lReturn))
continue;
else
{
OutputDebugString(TEXT("Unable to Use Line\n"));
HangupCall();
bDeleteBuffer = TRUE;
}
} while(lReturn != ERROR_SUCCESS);
if ((lReturn = lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff)) < 0)
HandleLineErr(lReturn);
}
if (bDeleteBuffer && lpLineDevCaps)
{
LocalFree(lpLineDevCaps);
bRet = FALSE;
}
return TRUE;
}
switch (dwParam1)
{
case LINEDEVSTATE_RINGING:
OutputDebugString(TEXT("Ringing\n"));
//count;
//if (count == 5)
m_hCall = (HCALL)dwDevice;
if ((lReturn = lineAnswer(m_hCall, NULL, 0)) < 0)
HandleLineErr(lReturn);
break;
After I open the lines with this code, I wait on the lineCallback function for LINE_LINEDEVSTATE with event LINEDEVSTATE_RINGING params. However, the call handle that I receive and try to use when I try to use lineAnswer(m_hCall, NULL, 0); returns with invalid call handle. As a result of this, I can't even deallocate this call using the same call handle. Any suggestions?
"Angus" wrote in message news:eOxfBigyIHA.4912@TK2MSFTNGP03.phx.gbl...
Please submit a code snippet. Without code we have no idea what you are doing.
"Abhishek Sen" wrote in message news:#P9hx6byIHA.5832@TK2MSFTNGP02.phx.gbl...
Hi Angus,
Thanks for your response. The callback is being invoked now after adding the function in the call to lineOpen(). In order to retrieve the number of rings, I wait for the
LINE_LINEDEVSTATE events with dwParam1 of LINEDEVSTATE_RINGING. Initially, I was not receiving any LINE_LINEDEVSTATE events but after making the following call after lineOpen()
lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff),
I am now able receive the number of rings, although the number of rings as obtained is pretty sporadic - sometimes I receive 3 rings and no more, sometimes 1 etc. The MAIN problem now is that when I go to answer the call after receiving the LINEDEVSTATE_RINGING event, the lineAnswer() call fails with LINEERR_INVALCALLHANDLE for some reason. The callback function is coming back with an incorrect call handle value and as a result, when I go to deallocate it after the call ends, that fails too because of the invalid call handle. Do you guys have any idea?
Cheers,
Abhi.
"Angus" wrote in message news:uLKyN2YyIHA.5520@TK2MSFTNGP06.phx.gbl...
>A couple of things here.
>
> Firstly, you say that your callback function has not been invoked. But you
> not specify a callback function. 6th parameter in lineOpen.
>
> Secondly, you should test your device using a known working TAPI program
> such as dialer or TAPI browser. Just to be sure your device works with TAPI
> and supports the events you require.
>
> lineGetDevcaps (think that is the one) will give you the capabilities of a
> given device.
>
> Angus
>
>
>
> "Abhishek Sen" wrote in message
> news:#tKXH0OyIHA.2068@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I'm a relative newbie to TAPI programming. I'm building a MFC based WM6
>> application for Pocket PC's to handle incoming calls after a fixed number
> of
>> rings (preset by the user). My method of performing lineInitialize is as
>> follows:
>>
>> 1. Main dialog screen shows up and I perform lineInitialize as follows
>> during the dialog's initialization:
>>
>> In the main dialog file:
>> m_hTapi = new TapiConnection();
>>
>> m_hTapi->Create();
>>
>> Create()....
>> lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
>> m_strAppName, &m_dwNumDevs);
>>
>> The return value from this is 0 and I know that the line has been
>> successfully initialized (dwNumDevs comes back with 8).
>>
>> 2. My next step is to wait and observe for the lineCallbackFunc to be
>> invoked by TAPI for the following event (LINE_LINEDEVSTATE) in order to
> get
>> the # of rings.
>>
>> case LINEDEVSTATE_RINGING:
>> OutputDebugString(TEXT("Ringing\n"));
>> if (OpenLineForIncoming())
>> lineAnswer((HCALL)dwDevice, NULL, 0);
>> break;
>>
>> As you can see here, OpenLineForIncoming() opens a line with monitorꌉ
>> privileges so that the call can be answered after a fixed number of rings.
>>
>> lReturn = lineOpen(m_hLineApp, m_dwDeviceID, &m_hLine, m_dwAPIVersion, 0,
> 0,
>> LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, 0, 0);
>>
>> However, for some reason, the MFC application does not seem to invoke the
>> lineCallbackFunc at all! Does anyone have any suggestions? Am I supposed
> to
>> start a new thread of any sort for the callback function to be invoked
>> correctly?
>>
>>
>
>
date: Mon, 9 Jun 2008 18:27:37 -0400
author: Abhishek Sen
Re: TAPI lineCallback not being invoked through MFC app
Abhishek,
> m_hCall = (HCALL)dwDevice;
What's this? A device ID is not a call handle!!
Best regards,
Matthias Moetje
-------------------------------------
TAPI WIKI: http://www.tapi.info
-------------------------------------
TERASENS GmbH
Augustenstraße 24
80333 Munich, GERMANY
-------------------------------------
e-mail: moetje at terasens dot com
www: www.terasens.com
-------------------------------------
"Abhishek Sen" wrote in message
news:eSloJAoyIHA.4376@TK2MSFTNGP06.phx.gbl...
BOOL TapiConnection::InitializeTapi()
{
BOOL bDeleteBuffer = FALSE;
LONG lReturn = 0;
if (m_hLineApp) // If we're already initialized, then initialization
succeeds.
return TRUE;
if (m_bInitializing) // If we're in the middle of initializing, then
fail, we're not done.
return FALSE;
m_bInitializing = TRUE;
m_strAppName = AfxGetAppName();
do
{
lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
m_strAppName, &m_dwNumDevs);
if (!m_dwNumDevs)
{
OutputDebugString(TEXT("There are no telephony devices installed.\n"));
m_bInitializing = FALSE;
return FALSE;
}
if (HandleLineErr(lReturn))
continue;
else
{
OutputDebugString(TEXT("lineInitialize unhandled error.\n"));
m_bInitializing = FALSE;
return FALSE;
}
} while (lReturn != ERROR_SUCCESS);
OutputDebugString(TEXT("Tapi initialized.\n"));
m_bInitializing = FALSE;
if (OpenLineForIncoming())
OutputDebugString(TEXT("Line opened.\n"));
else
{
OutputDebugString(TEXT("Line could not be opened.\n"));
return FALSE;
}
return TRUE;
}
BOOL TapiConnection::OpenLineForIncoming()
{
BOOL bRet = TRUE, bDeleteBuffer = FALSE;
LONG lReturn = 0;
LPLINEDEVCAPS lpLineDevCaps = NULL;
if (m_bTapiInUse)
{
OutputDebugString(TEXT("A call is already being handled.\n"));
return FALSE;
}
m_bTapiInUse = TRUE; // We now have a call active. Prevent future
calls.
lpLineDevCaps = GetDeviceLine(&m_dwAPIVersion, lpLineDevCaps); //
Get the line to use
if (lpLineDevCaps == NULL) // Need to check the DevCaps to make sure
this line is usable.
{
OutputDebugString(TEXT("Error on Requested line\n"));
bDeleteBuffer = TRUE;
}
else if (!(lpLineDevCaps->dwBearerModes & LINEBEARERMODE_VOICE ))
{
OutputDebugString(TEXT("The selected line doesn't support VOICE
capabilities\n"));
bDeleteBuffer = TRUE;
}
else if (!(lpLineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE))
// Does this line have the capability for interactive voice?
{
OutputDebugString(TEXT("The selected line doesn't support
INTERACTIVE VOICE capabilities"));
bDeleteBuffer = TRUE;
}
// Open the Line for an incoming call
if (!bDeleteBuffer)
{
do
{
lReturn = lineOpen(
m_hLineApp,
m_dwDeviceID,
&m_hLine,
m_dwAPIVersion,
0,
(DWORD)lineCallbackFunc,
LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER,
LINEMEDIAMODE_INTERACTIVEVOICE,
0);
if((lReturn == LINEERR_ALLOCATED)||(lReturn == LINEERR_RESOURCEUNAVAIL))
{
HangupCall();
OutputDebugString(TEXT("Line is already in use by a non-TAPI application
or by another TAPI Service Provider.\n"));
OpenLineForIncoming();
bDeleteBuffer = TRUE;
}
if (HandleLineErr(lReturn))
continue;
else
{
OutputDebugString(TEXT("Unable to Use Line\n"));
HangupCall();
bDeleteBuffer = TRUE;
}
} while(lReturn != ERROR_SUCCESS);
if ((lReturn = lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff)) <
0)
HandleLineErr(lReturn);
}
if (bDeleteBuffer && lpLineDevCaps)
{
LocalFree(lpLineDevCaps);
bRet = FALSE;
}
return TRUE;
}
switch (dwParam1)
{
case LINEDEVSTATE_RINGING:
OutputDebugString(TEXT("Ringing\n"));
//count++;
//if (count == 5)
m_hCall = (HCALL)dwDevice;
if ((lReturn = lineAnswer(m_hCall, NULL, 0)) < 0)
HandleLineErr(lReturn);
break;
After I open the lines with this code, I wait on the lineCallback function
for LINE_LINEDEVSTATE with event LINEDEVSTATE_RINGING params. However, the
call handle that I receive and try to use when I try to use
lineAnswer(m_hCall, NULL, 0); returns with invalid call handle. As a result
of this, I can't even deallocate this call using the same call handle. Any
suggestions?
"Angus" wrote in message
news:eOxfBigyIHA.4912@TK2MSFTNGP03.phx.gbl...
Please submit a code snippet. Without code we have no idea what you are
doing.
"Abhishek Sen" wrote in message
news:#P9hx6byIHA.5832@TK2MSFTNGP02.phx.gbl...
Hi Angus,
Thanks for your response. The callback is being invoked now after adding the
function in the call to lineOpen(). In order to retrieve the number of
rings, I wait for the
LINE_LINEDEVSTATE events with dwParam1 of LINEDEVSTATE_RINGING. Initially, I
was not receiving any LINE_LINEDEVSTATE events but after making the
following call after lineOpen()
lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff),
I am now able receive the number of rings, although the number of rings as
obtained is pretty sporadic - sometimes I receive 3 rings and no more,
sometimes 1 etc. The MAIN problem now is that when I go to answer the call
after receiving the LINEDEVSTATE_RINGING event, the lineAnswer() call fails
with LINEERR_INVALCALLHANDLE for some reason. The callback function is
coming back with an incorrect call handle value and as a result, when I go
to deallocate it after the call ends, that fails too because of the invalid
call handle. Do you guys have any idea?
Cheers,
Abhi.
"Angus" wrote in message
news:uLKyN2YyIHA.5520@TK2MSFTNGP06.phx.gbl...
>A couple of things here.
>
> Firstly, you say that your callback function has not been invoked. But
> you
> not specify a callback function. 6th parameter in lineOpen.
>
> Secondly, you should test your device using a known working TAPI program
> such as dialer or TAPI browser. Just to be sure your device works with
> TAPI
> and supports the events you require.
>
> lineGetDevcaps (think that is the one) will give you the capabilities of a
> given device.
>
> Angus
>
>
>
> "Abhishek Sen" wrote in message
> news:#tKXH0OyIHA.2068@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I'm a relative newbie to TAPI programming. I'm building a MFC based WM6
>> application for Pocket PC's to handle incoming calls after a fixed number
> of
>> rings (preset by the user). My method of performing lineInitialize is as
>> follows:
>>
>> 1. Main dialog screen shows up and I perform lineInitialize as follows
>> during the dialog's initialization:
>>
>> In the main dialog file:
>> m_hTapi = new TapiConnection();
>>
>> m_hTapi->Create();
>>
>> Create()....
>> lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
>> m_strAppName, &m_dwNumDevs);
>>
>> The return value from this is 0 and I know that the line has been
>> successfully initialized (dwNumDevs comes back with 8).
>>
>> 2. My next step is to wait and observe for the lineCallbackFunc to be
>> invoked by TAPI for the following event (LINE_LINEDEVSTATE) in order to
> get
>> the # of rings.
>>
>> case LINEDEVSTATE_RINGING:
>> OutputDebugString(TEXT("Ringing\n"));
>> if (OpenLineForIncoming())
>> lineAnswer((HCALL)dwDevice, NULL, 0);
>> break;
>>
>> As you can see here, OpenLineForIncoming() opens a line with
>> monitor+owner
>> privileges so that the call can be answered after a fixed number of
>> rings.
>>
>> lReturn = lineOpen(m_hLineApp, m_dwDeviceID, &m_hLine, m_dwAPIVersion, 0,
> 0,
>> LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, 0, 0);
>>
>> However, for some reason, the MFC application does not seem to invoke the
>> lineCallbackFunc at all! Does anyone have any suggestions? Am I supposed
> to
>> start a new thread of any sort for the callback function to be invoked
>> correctly?
>>
>>
>
>
date: Tue, 10 Jun 2008 18:39:43 +0200
author: Matthias Moetje [MVP]
Re: TAPI lineCallback not being invoked through MFC app
Hi Matthias,
Thanks for your reply. I now wait for a
LINECALLSTATE_OFFERING
event and then assign the following:
> m_hCall = (HCALL)dwDevice;
I am now able to answer the call with the correct call handle. Do you know
how I can keep track of the call handles to make sure that if I receive a
call when I'm already in one, I don't overwrite the current call handle,
thereby causing trouble. In addition, for some reason, I only receive 1
LINEDEVSTATE_RINGING event every time a new call comes in. I have no idea
why I'm not receiving these constantly until the caller hangs up or I hang
up. Any ideas?
Cheers.
"Matthias Moetje [MVP]" wrote in message
news:%23gLXUixyIHA.3968@TK2MSFTNGP04.phx.gbl...
> Abhishek,
>
>
>> m_hCall = (HCALL)dwDevice;
>
> What's this? A device ID is not a call handle!!
>
>
> Best regards,
>
> Matthias Moetje
> -------------------------------------
> TAPI WIKI: http://www.tapi.info
> -------------------------------------
> TERASENS GmbH
> Augustenstraße 24
> 80333 Munich, GERMANY
> -------------------------------------
> e-mail: moetje at terasens dot com
> www: www.terasens.com
> -------------------------------------
>
> "Abhishek Sen" wrote in message
> news:eSloJAoyIHA.4376@TK2MSFTNGP06.phx.gbl...
> BOOL TapiConnection::InitializeTapi()
> {
> BOOL bDeleteBuffer = FALSE;
> LONG lReturn = 0;
>
> if (m_hLineApp) // If we're already initialized, then initialization
> succeeds.
> return TRUE;
>
> if (m_bInitializing) // If we're in the middle of initializing, then
> fail, we're not done.
> return FALSE;
>
> m_bInitializing = TRUE;
> m_strAppName = AfxGetAppName();
>
> do
> {
> lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
> m_strAppName, &m_dwNumDevs);
> if (!m_dwNumDevs)
> {
> OutputDebugString(TEXT("There are no telephony devices installed.\n"));
> m_bInitializing = FALSE;
> return FALSE;
> }
> if (HandleLineErr(lReturn))
> continue;
> else
> {
> OutputDebugString(TEXT("lineInitialize unhandled error.\n"));
> m_bInitializing = FALSE;
> return FALSE;
> }
> } while (lReturn != ERROR_SUCCESS);
>
> OutputDebugString(TEXT("Tapi initialized.\n"));
> m_bInitializing = FALSE;
>
> if (OpenLineForIncoming())
> OutputDebugString(TEXT("Line opened.\n"));
> else
> {
> OutputDebugString(TEXT("Line could not be opened.\n"));
> return FALSE;
> }
> return TRUE;
> }
>
>
>
> BOOL TapiConnection::OpenLineForIncoming()
> {
> BOOL bRet = TRUE, bDeleteBuffer = FALSE;
> LONG lReturn = 0;
> LPLINEDEVCAPS lpLineDevCaps = NULL;
>
> if (m_bTapiInUse)
> {
> OutputDebugString(TEXT("A call is already being handled.\n"));
> return FALSE;
> }
> m_bTapiInUse = TRUE; // We now have a call active. Prevent future
> calls.
> lpLineDevCaps = GetDeviceLine(&m_dwAPIVersion, lpLineDevCaps); //
> Get the line to use
>
> if (lpLineDevCaps == NULL) // Need to check the DevCaps to make sure
> this line is usable.
> {
> OutputDebugString(TEXT("Error on Requested line\n"));
> bDeleteBuffer = TRUE;
> }
> else if (!(lpLineDevCaps->dwBearerModes & LINEBEARERMODE_VOICE ))
> {
> OutputDebugString(TEXT("The selected line doesn't support VOICE
> capabilities\n"));
> bDeleteBuffer = TRUE;
> }
> else if (!(lpLineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE))
> // Does this line have the capability for interactive voice?
> {
> OutputDebugString(TEXT("The selected line doesn't support
> INTERACTIVE VOICE capabilities"));
> bDeleteBuffer = TRUE;
> }
>
> // Open the Line for an incoming call
> if (!bDeleteBuffer)
> {
> do
> {
> lReturn = lineOpen(
> m_hLineApp,
> m_dwDeviceID,
> &m_hLine,
> m_dwAPIVersion,
> 0,
> (DWORD)lineCallbackFunc,
> LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER,
> LINEMEDIAMODE_INTERACTIVEVOICE,
> 0);
> if((lReturn == LINEERR_ALLOCATED)||(lReturn == LINEERR_RESOURCEUNAVAIL))
> {
> HangupCall();
> OutputDebugString(TEXT("Line is already in use by a non-TAPI
> application or by another TAPI Service Provider.\n"));
> OpenLineForIncoming();
> bDeleteBuffer = TRUE;
> }
>
> if (HandleLineErr(lReturn))
> continue;
> else
> {
> OutputDebugString(TEXT("Unable to Use Line\n"));
> HangupCall();
> bDeleteBuffer = TRUE;
> }
> } while(lReturn != ERROR_SUCCESS);
>
> if ((lReturn = lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff)) <
> 0)
> HandleLineErr(lReturn);
> }
>
> if (bDeleteBuffer && lpLineDevCaps)
> {
> LocalFree(lpLineDevCaps);
> bRet = FALSE;
> }
>
> return TRUE;
> }
>
>
> switch (dwParam1)
> {
> case LINEDEVSTATE_RINGING:
> OutputDebugString(TEXT("Ringing\n"));
> //count++;
> //if (count == 5)
> m_hCall = (HCALL)dwDevice;
> if ((lReturn = lineAnswer(m_hCall, NULL, 0)) < 0)
> HandleLineErr(lReturn);
> break;
>
>
> After I open the lines with this code, I wait on the lineCallback function
> for LINE_LINEDEVSTATE with event LINEDEVSTATE_RINGING params. However, the
> call handle that I receive and try to use when I try to use
> lineAnswer(m_hCall, NULL, 0); returns with invalid call handle. As a
> result of this, I can't even deallocate this call using the same call
> handle. Any suggestions?
>
>
>
> "Angus" wrote in message
> news:eOxfBigyIHA.4912@TK2MSFTNGP03.phx.gbl...
> Please submit a code snippet. Without code we have no idea what you are
> doing.
>
> "Abhishek Sen" wrote in message
> news:#P9hx6byIHA.5832@TK2MSFTNGP02.phx.gbl...
> Hi Angus,
>
> Thanks for your response. The callback is being invoked now after adding
> the function in the call to lineOpen(). In order to retrieve the number of
> rings, I wait for the
> LINE_LINEDEVSTATE events with dwParam1 of LINEDEVSTATE_RINGING. Initially,
> I was not receiving any LINE_LINEDEVSTATE events but after making the
> following call after lineOpen()
> lineSetStatusMessages(m_hLine, 0x01ffffff, 0x000001ff),
> I am now able receive the number of rings, although the number of rings as
> obtained is pretty sporadic - sometimes I receive 3 rings and no more,
> sometimes 1 etc. The MAIN problem now is that when I go to answer the call
> after receiving the LINEDEVSTATE_RINGING event, the lineAnswer() call
> fails with LINEERR_INVALCALLHANDLE for some reason. The callback function
> is coming back with an incorrect call handle value and as a result, when I
> go to deallocate it after the call ends, that fails too because of the
> invalid call handle. Do you guys have any idea?
> Cheers,
> Abhi.
> "Angus" wrote in message
> news:uLKyN2YyIHA.5520@TK2MSFTNGP06.phx.gbl...
>>A couple of things here.
>>
>> Firstly, you say that your callback function has not been invoked. But
>> you
>> not specify a callback function. 6th parameter in lineOpen.
>>
>> Secondly, you should test your device using a known working TAPI program
>> such as dialer or TAPI browser. Just to be sure your device works with
>> TAPI
>> and supports the events you require.
>>
>> lineGetDevcaps (think that is the one) will give you the capabilities of
>> a
>> given device.
>>
>> Angus
>>
>>
>>
>> "Abhishek Sen" wrote in message
>> news:#tKXH0OyIHA.2068@TK2MSFTNGP05.phx.gbl...
>>> Hi,
>>>
>>> I'm a relative newbie to TAPI programming. I'm building a MFC based WM6
>>> application for Pocket PC's to handle incoming calls after a fixed
>>> number
>> of
>>> rings (preset by the user). My method of performing lineInitialize is as
>>> follows:
>>>
>>> 1. Main dialog screen shows up and I perform lineInitialize as follows
>>> during the dialog's initialization:
>>>
>>> In the main dialog file:
>>> m_hTapi = new TapiConnection();
>>>
>>> m_hTapi->Create();
>>>
>>> Create()....
>>> lReturn = lineInitialize(&m_hLineApp, m_hInst, lineCallbackFunc,
>>> m_strAppName, &m_dwNumDevs);
>>>
>>> The return value from this is 0 and I know that the line has been
>>> successfully initialized (dwNumDevs comes back with 8).
>>>
>>> 2. My next step is to wait and observe for the lineCallbackFunc to be
>>> invoked by TAPI for the following event (LINE_LINEDEVSTATE) in order to
>> get
>>> the # of rings.
>>>
>>> case LINEDEVSTATE_RINGING:
>>> OutputDebugString(TEXT("Ringing\n"));
>>> if (OpenLineForIncoming())
>>> lineAnswer((HCALL)dwDevice, NULL, 0);
>>> break;
>>>
>>> As you can see here, OpenLineForIncoming() opens a line with
>>> monitor+owner
>>> privileges so that the call can be answered after a fixed number of
>>> rings.
>>>
>>> lReturn = lineOpen(m_hLineApp, m_dwDeviceID, &m_hLine, m_dwAPIVersion,
>>> 0,
>> 0,
>>> LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, 0, 0);
>>>
>>> However, for some reason, the MFC application does not seem to invoke
>>> the
>>> lineCallbackFunc at all! Does anyone have any suggestions? Am I supposed
>> to
>>> start a new thread of any sort for the callback function to be invoked
>>> correctly?
>>>
>>>
>>
>>
>
>
date: Tue, 10 Jun 2008 14:39:09 -0400
author: Abhishek Sen
|
|