This page was last modified 08:56, 28 March 2008.
CS000863 - Pausing an application on an incoming call
From Forum Nokia Wiki
| ID | CS000863 | Creation date | March 28, 2008 |
| Platform | S60 3rd Edition, MR S60 3rd Edition, FP1 S60 3rd Edition, FP2 Beta | Tested on devices | Nokia E61i Nokia E90 Communicator Nokia N95 8GB Nokia 6220 Classic |
| Category | Symbian C++ | Subcategory | Telephony |
| Keywords (APIs, classes, methods, functions): CActive, CTelephony, CTelephony::TCallStatusV1, CTelephony::TCallStatusV1Pckg, CTelephony::NotifyChange(), CTelephony::TCallStatusV1::iStatus |
Overview
Sometimes an application (such as a game) needs to be paused due to an incoming call. This snippet demonstrates how to observe incoming calls, thus enabling acting on them.
MMP file
The following libraries are required:
LIBRARY etel3rdparty.lib
Header file
#ifndef __TELOBSERVER_H_ #define __TELOBSERVER_H_ #include <e32base.h> #include <Etel3rdParty.h> class CTelObserver : public CActive { public: /** * Symbian OS default constructor */ CTelObserver(); /** * 2nd phase constructor. */ static CTelObserver* NewL(); /** * 2nd phase constructor. */ static CTelObserver* NewLC(); /** * Destructor */ ~CTelObserver(); /** * Starts observing for the incoming calls. */ void StartListening(); private: /** * Symbian 2-phase constructor */ void ConstructL(); /** * From CActive */ void RunL(); /** * From CActive */ TInt RunError(TInt anError); /** * From CActive */ void DoCancel(); private: // Data CTelephony* iTelephony; CTelephony::TCallStatusV1 iCallStatus; CTelephony::TCallStatusV1Pckg iCallStatusPkg; }; #endif /*__TelObserver_H_*/
Source file
#include <e32base.h> #include <Etel3rdParty.h> #include "TelObserver.h" /** * Constructor. Defines the priority for this active object. */ CTelObserver::CTelObserver() : CActive(EPriorityStandard), iCallStatusPkg(iCallStatus) { } /** * 2nd phase constructor. */ CTelObserver* CTelObserver::NewL() { CTelObserver* self = CTelObserver::NewLC(); CleanupStack::Pop(self); return self; } /** * 2nd phase constructor. */ CTelObserver* CTelObserver::NewLC() { CTelObserver* self = new (ELeave) CTelObserver(); CleanupStack::PushL(self); self->ConstructL(); return self; } /** * 2nd phase constructor. */ void CTelObserver::ConstructL() { iTelephony = CTelephony::NewL(); CActiveScheduler::Add(this); } /** * Destructor. */ CTelObserver::~CTelObserver() { Cancel(); if (iTelephony) delete iTelephony; } /** * From CActive. */ void CTelObserver::RunL() { if (iStatus == KErrNone) { CTelephony::TCallStatus status = iCallStatus.iStatus; switch (status) { case CTelephony::EStatusRinging: { // The phone is ringing. Pause the application. // ... break; } default: { // Not interested in other events. break; } } // Start listening for the next call StartListening(); } } /** * From CActive. */ TInt CTelObserver::RunError(TInt anError) { return anError; } /** * From CActive. */ void CTelObserver::DoCancel() { iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel); } /** * Starts observing for the incoming calls. */ void CTelObserver::StartListening() { iTelephony->NotifyChange(iStatus, CTelephony::EVoiceLineStatusChange, iCallStatusPkg); SetActive(); }
Postconditions
When the phone is ringing, the application branches to CTelephony::EStatusRinging in CTelObserver::RunL().
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hangup incoming call | agrauballe | General Symbian C++ | 1 | 2006-04-01 14:54 |
| How to get the Call events in J2ME | krmlkr | Mobile Java General | 1 | 2008-02-15 18:12 |
| how to handle calls.. | sumanthgwn | Symbian Networking & Messaging | 9 | 2006-11-09 10:07 |
| Retrieving the phone number of an incoming call | tgaroui | General Symbian C++ | 8 | 2006-02-06 14:32 |
| Problem using CLogClient | madabusi | General Symbian C++ | 0 | 2006-04-27 07:19 |

