Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 08:05, 15 October 2007.

Implementing Dialer example in Symbian

From Forum Nokia Wiki

#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
                           
    }
		
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
Approach to a Symbian-signed game... iWannaMakeGames General Symbian C++ 0 2005-09-06 21:49
Implementing a waiting Dialog vasilak General Symbian C++ 2 2003-10-01 12:21
Making a call in Series 60 phones elon General Symbian C++ 1 2003-03-27 08:19
connectivity between nokia6310i and toshiba satelite 4080xcdt laptop gardnerma PC Suite API and PC Connectivity SDK 1 2002-07-15 06:49
Implement CallsMonitor example in a CServer2 app. utongbullet General Symbian C++ 16 2008-02-11 03:35
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX