×
Namespaces

Variants
Actions

Implementing Dialer example in Symbian

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: bharatuppal (24 Jul 2007)
Last edited: hamishwillee (26 Jul 2012)
#include <etel.h>
#include "Dial.h"
#include <Dialer.rsg>
#include <eikmenup.h>
 
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <stringloader.h>
 
// CONSTANTS
_LIT ( KTsyName,"phonetsy.tsy" );
 
 
 
// -----------------------------------------------------------------------------
// CDial class Derived from CActive it is an Active object class that handles
// connection part
// -----------------------------------------------------------------------------
//
class CDial:CActive
{
 
public:
 
static CDial* NewL();
static CDial* NewLC();
~CDial();
void RunL();
void DoCancel();
void DialNumberL(const TDesC& aPhoneNumber);
TBool Dialing;
 
 
private:
CDial();
void ConstructL();
RTelServer server;
RTelServer::TPhoneInfo info;
RPhone phone;
RPhone::TLineInfo lineInfo;
RLine line;
RCall call;
 
 
};
 
 
 
//The Priority given to the active object is EPriorityIdle
CDial::CDial(): CActive(EPriorityIdle)
{
}
 
 
 
 
 
CDial::~CDial()
{
User::LeaveIfError( server.UnloadPhoneModule( KTsyName ) );
server.Close();
 
}
// -----------------------------------------------------------------------------
// CDialerAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CDial::ConstructL()
{
 
Dialing = EFalse;
User::LeaveIfError( server.Connect() );
 
 
//Load in the phone device driver
User::LeaveIfError( server.LoadPhoneModule( KTsyName ) );
 
 
TInt numberPhones;
User::LeaveIfError( server.EnumeratePhones( numberPhones ) );
 
//Check there are available phones
if ( numberPhones < 1 )
{
User::Leave( KErrNotFound );
}
 
//Get info about the first available phone
 
User::LeaveIfError( server.GetPhoneInfo( 0, info ) );
 
 
User::LeaveIfError( phone.Open( server, info.iName ) );
 
 
User::LeaveIfError( phone.GetLineInfo( 0, lineInfo ) );
 
 
 
 
User::LeaveIfError( line.Open( phone, lineInfo.iName ) );
 
TBuf <100> newCallName;
 
 
User::LeaveIfError( call.OpenNewCall( line, newCallName ) );
 
CActiveScheduler::Add(this);
 
}
 
// -----------------------------------------------------------------------------
// CDialerAppUi::DialNumberL()
// Takes care of connection handling.
// -----------------------------------------------------------------------------
//
 
 
void CDial::DialNumberL( const TDesC& aPhoneNumber )
{
//if(Dialing == EFalse)
//{
Dialing = ETrue;
// Using Asynchronous version of Dial Api
call.Dial(iStatus,aPhoneNumber);
 
SetActive();
// }
}
 
void CDial::RunL()
{
 
 
 
if ( iStatus.Int() == KErrGeneral )
{
 
// Display eror
Dialing = EFalse;
 
}
 
Dialing = EFalse;
 
}
 
 
 
void CDial::DoCancel()
{
 
//if (this->IsActive())
// Cancel();
}

Usage of CDialer class

case EDialerDial:
{
_LIT ( KPhoneNumber,"9885306268" );
CDial* iDial;
iDial = CDial::NewL();
#if __WINS__
// Display message // emulator does not support dialing,
break;
#endif
// go ahead with making call on real device.
if(iDial->Dialing == EFalse)
{
iDial->DialNumberL( KPhoneNumber );
}
else
{
_LIT(KNot,"Not Allowed");
// Display message Not Allowed
 
}
 
}
This page was last modified on 26 July 2012, at 02:02.
37 page views in the last 30 days.
×