TAPI 2.0: phone methods not working
- From: mgregoire.m5t@xxxxxxxxx
- Date: Thu, 10 Jul 2008 09:28:17 -0700 (PDT)
Hello,
I am currently adding the feature to receive incoming phone calls to a
software application that I created. My application is running on
Windows Mobile 5, it is developed in C++ and TAPI 2.0 is used. I
already implemented my solution using line methods (lineInitializedEx,
lineOpen, lineAnswer) and events (LINEINITIALIZEEXOPTION_USEEVENT).
When I'm receiving a phone call, when receiving LINE_APPNEWCALL, I'm
looking for cprog.exe (Default phone dialer on WM5) and I'm killing it
so that way, only my application is managing the call. So far,
everything is working fine.
But, I need to control the volume, gain and trigger ring sound in my
application so I thought that using phone methods instead
(phoneInitializedEx, phoneOpen...) looks like a better solution for me
since these methods are already implemented. I changed my calls to
phone methods and I'm not receiving events anymore. I'm setting my
PHONEINITIALIZEEXPARAMS object with dwOptions =
PHONEINITIALIZEEXOPTION_USEEVENT and all my phoneMethods
(phoneInitializeEx, phoneNegociateAPIVersion, phoneGetDevCaps,
phoneOpen and phoneSetStatusMessages) calls returns 0, but I never
receive any events while waiting for WaitForSingleObject, only
WAIT_TIMEOUT. I really don't know why it doesn't work since everything
is fine with line methods.
Anyway, here is a sample of what I'm doing. Please bear in mind that
in order to minimise code spaces in this email, I'm using multiple
validations in the same method and:
- HPHONEAPP m_hPhoneApp and HANDLE m_hPhoneEvent are members of my
CPhone class.
- CPhone::ActivateEventsThread() starts a thread to manage TAPI events
and CPhone::EventsTread() is its thread entry.
- CPhone::ManageEvents() is used to handle received TAPI events.
void CPhone::InitializeTapi()
{
DWORD dwNumDevs = 0;
DWORD dwAPIVersion = 0x00020000;
DWORD dwAPIVersionNegociated = 0;
PHONEINITIALIZEEXPARAMS stPhoneInitializeExParams;
memset(&stPhoneInitializeExParams, 0,
sizeof(PHONEINITIALIZEEXPARAMS));
stPhoneInitializeExParams.dwTotalSize =
sizeof(PHONEINITIALIZEEXPARAMS);
stPhoneInitializeExParams.dwOptions =
PHONEINITIALIZEEXOPTION_USEEVENT;
LONG lRes = phoneInitializeEx(&m_hPhoneApp, NULL, NULL, NULL,
&dwNumDevs, &dwAPIVersion, &stPhoneInitializeExParams);
if (lRes == 0)
{
m_hPhoneEvent = stPhoneInitializeExParams.Handles.hEvent;
PHONEEXTENSIONID stPhoneExtensionId;
lRes = phoneNegotiateAPIVersion(m_hPhoneApp, 0, 0,
dwAPIVersion, &dwAPIVersionNegociated, &stPhoneExtensionId);
if (lRes == 0)
{
LPPHONECAPS lpPhoneCaps =
static_cast<LPPHONECAPS>(LocalAlloc(LPTR, 4096));
lpPhoneCaps->dwTotalSize = 4096;
lRes = phoneGetDevCaps(m_hPhoneApp, 0,
dwAPIVersionNegociated, 0, lpPhoneCaps);
if (lRes == 0)
{
HPHONE hPhone;
lRes = phoneOpen(m_hPhoneApp, 0, &hPhone,
dwAPIVersionNegociated, 0, 0, PHONEPRIVILEGE_OWNER);
if (lRes == 0)
{
lRes = phoneSetStatusMessages(hPhone, lpPhoneCaps-
dwPhoneStates, 0, 0);
ActivateEventsThread();
}
}
LocalFree(lpPhoneCaps);
lpPhoneCaps = NULL;
}
}
}
void CPhone::EventsThread()
{
PHONEMESSAGE phoneMsg;
while (!m_ShuttingDown)
{
switch (WaitForSingleObject(m_hPhoneEvent, 10))
{
case WAIT_OBJECT_0:
phoneGetMessage(m_hPhoneApp, &phoneMsg, 0);
ManageEvents(phoneMsg);
break;
default:
continue;
}
}
}
I think that this code should work. The same logic is used with line
methods and it's working. As I said, all calls to phone methods are
returning 0 and the thread to receive TAPI events is started and is
waiting for events. I'm clueless to what is not working. Any hints on
what is wrong?
.
- Follow-Ups:
- Re: TAPI 2.0: phone methods not working
- From: Andreas Marschall [MVP TAPI]
- Re: TAPI 2.0: phone methods not working
- Prev by Date: Re: TSP is not getting Started after installation
- Next by Date: Re: TAPI 2.0: phone methods not working
- Previous by thread: TSP is not getting Started after installation
- Next by thread: Re: TAPI 2.0: phone methods not working
- Index(es):