Developers guide

Chapter 22: Wireless Wide-Area Networking
Receiving A Phone Call
224 Psion Teklogix Mobile Devices SDK Developers Guide
22.12.6 Receiving A Phone Call
The VoiceCallManager object is responsible for answering incoming phone calls through the lis-
tener that was registered during initialization—see “Initializing Voice Over WWAN” on page 217
for details. An incoming call generates an incoming call event that is processed by the
VoiceCallManager object.
Terminology is different in C++ and C#.
The following example shows how to receive incoming phone calls:
1. Play a ring tone.
2. Ask if the user wants to answer the call—includes displaying the caller ID of the incom-
ing phone call.
3. Either activate the incoming call or reject it.
Example 22.18 Answering a Phone Call in C++
class MyVoiceCallManagerListener : public VoiceCallManager::Listener
{
public:
// OnIncomingCallEvent
//
// Description:
// This method is invoked by a VoiceCallManager object when there is an incomi
ng
// voice call (including waiting calls). A MessageBox is then displayed askin
gthe
// user if the call should be answered. The new status is displayed in the ev
ent
// window in the dialog.
//
// Parameters:
// incomingCall - The new incoming call.
void OnIncomingCallEvent(VoiceCall incomingCall)
{
//
// Instantiate a new VoiceCall object, and register a listner.
// The listener is responsible for determining when/how to
// free up this memory.
//
VoiceCall *newCall = new VoiceCall(incomingCall);
newCall->RegisterListener(*callStatus);
try
{
try
{
// Play a ring tone to notify the user of an incoming call.
// From PsionTeklogix::Sound namespace.
PlayRepeatingWave(std::wstring(L"\\windows\\ring.wav"), 3000 );
}
catch(std::runtime_error ex)
{
/* unable to play the ringtone, does the file exist? */
}
// Ask the user if they want to answer the call.
WCHAR messageBuffer[1024];
wsprintf(messageBuffer,
L"Answer incoming call from: \"%s\"?\r\nPress NO to reject the call.",