Namespaces
Variants
Actions

Get Caller Number

Jump to: navigation, search
Article Metadata

Article
Created: ivey (15 Mar 2007)
Last edited: hamishwillee (08 May 2013)

Below is the code illustarating how to get the remote party's telephone number. It is different for S60 3rd Edition and previous versions.

Pre S60 3rd Edition

Hearders Required:

#include <etel.h> 
#include <etelmm.h>

Library required:

LIBRARY   etel.lib

Source Code:

void GetRemotePartyPhoneNumberL(TDes& aPhoneNumber)
{
RTelServer etel;
 
// Connect to ETel server
User::LeaveIfError(etel.Connect());
CleanupClosePushL(etel);
 
// Load phone module. This is just to be on the safe side
// because it should have been loaded already
_LIT(KTsyName, "phonetsy.tsy");
User::LeaveIfError(etel.LoadPhoneModule(KTsyName));
 
RTelServer::TPhoneInfo phoneInfo;
 
// Get phone info. We need phone's name to open a phone
const TInt KPhoneIndex = 0;
User::LeaveIfError(etel.GetPhoneInfo(KPhoneIndex, phoneInfo));
 
RPhone phone;
 
// Open the phone
User::LeaveIfError(phone.Open(etel, phoneInfo.iName));
CleanupClosePushL(phone);
 
RPhone::TLineInfo lineInfo;
 
// Get line info. We need line's name to open it
const TInt KLineIndex = 0;
User::LeaveIfError(phone.GetLineInfo(KLineIndex, lineInfo));
 
RLine line;
 
// Open the line
User::LeaveIfError(line.Open(phone, lineInfo.iName));
CleanupClosePushL(line);
 
RLine::TCallInfo callInfo;
 
// Get call info. We need call's name to open it and get the info we need
const TInt KCallIndex = 0;
User::LeaveIfError(line.GetCallInfo(KCallIndex, callInfo));
 
RMobileCall call;
 
// Open the call
User::LeaveIfError(call.OpenExistingCall(line, callInfo.iCallName));
CleanupClosePushL(call);
 
RMobileCall::TMobileCallInfoV1 mobCallInfo;
RMobileCall::TMobileCallInfoV1Pckg mobCallInfoPckg(mobCallInfo);
 
// Get the call's info
User::LeaveIfError(call.GetMobileCallInfo(mobCallInfoPckg));
 
// We successfully got the call's info.
// Now copy the remote party's phone number to the target descriptor
aPhoneNumber.Copy(mobCallInfoPckg().iRemoteParty.iRemoteNumber.iTelNumber);
 
// Close all handles
CleanupStack::PopAndDestroy(4); // call, line, phone, etel
}

For S60 3rd edition

S60 3rd Edition

Hearders Required:

#include <Etel3rdParty.h>

Library required:

LIBRARY   Etel3rdParty.lib

Source:

void GetRemotePartyPhoneNumberL(TDes& aPhoneNumber)
{
// Create a CTelephony object
CTelephony* telephony = CTelephony::NewLC();
 
CTelephony::TCallInfoV1 callInfoV1;
CTelephony::TCallInfoV1Pckg callInfoV1Pckg(callInfoV1);
 
CTelephony::TCallSelectionV1 callSelectionV1;
CTelephony::TCallSelectionV1Pckg callSelectionV1Pckg(callSelectionV1);
 
CTelephony::TRemotePartyInfoV1 remotePartyInfoV1;
CTelephony::TRemotePartyInfoV1Pckg remotePartyInfoV1Pckg(remotePartyInfoV1);
 
callSelectionV1.iLine = CTelephony::EVoiceLine;
callSelectionV1.iSelect = CTelephony::EInProgressCall;
 
// Get the call info
User::LeaveIfError(telephony->GetCallInfo(callSelectionV1Pckg,
callInfoV1Pckg, remotePartyInfoV1Pckg));
// Copy the remote party's phone number to the target descriptor
aPhoneNumber.Copy(remotePartyInfoV1Pckg().iRemoteNumber.iTelNumber);
 
CleanupStack::PopAndDestroy(); // telephony
}
This page was last modified on 8 May 2013, at 02:56.
106 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved