Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to get my own phone number using Symbian C++

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleCompatibility
Platform(s):
S60 1st Edition
Article
Created: kcomex (02 Apr 2007)
Last edited: hamishwillee (03 May 2013)


Contents

From Symbian OS v7 onwards

Developers should use the CTelephony API where possible. This is the "official" Symbian OS 3rd party telephony API. It provides access to: IMEI, IMSI and numbers, Network availability and change notification, Network and location identification, Battery and signal strength notification.

Symbian OS v6.1 to Symbian OS v8

You can alternatively use the Mobinfo API File:Mobinfo-1.01-Signed.zip. This API provides access to everything that CTelephony does, and additionally provides an API to access the "own phone number".


Symbian OS 7.0 (and later)

Developers with access to the source can access the internal telephony APIs as shown below

How to get my own phone number (eventually)

void RMobileONStore::Read(TRequestStatus& aReqStatus, TDes8& aEntry)

This API is being used to get the own phone number:

// Requirement: etel server, tsy, have been opened and initialized

 TBool isSupported = EFalse;
User::LeaveIfError(telServer.IsSupportedByModule(tsyName, KETelFuncMobileOwnNumberStore, isSupported));
 
if (isSupported != EFalse)
{
console->Printf(_L("Own number store is supported.\n"));
}
else
{
User::Leave(KErrNotSupported);
}
 
TInt numPhones=0;
telServer.EnumeratePhones(numPhones);
 
for (TInt i=0; i<numPhones; i++)
{
TRequestStatus status;
RTelServer::TPhoneInfo info;
telServer.GetPhoneInfo(i, info);
 
RMobilePhone phone;
User::LeaveIfError(phone.Open(telServer, info.iName));
CleanupClosePushL(phone);
 
RMobileONStore ownNumberStore;
User::LeaveIfError(ownNumberStore.Open(phone));
CleanupClosePushL(ownNumberStore);
 
// Check if there is own number entry stored.
RMobileONStore::TMobileONStoreInfoV1 ownStoreInfo;
RMobileONStore::TMobileONStoreInfoV1Pckg ownStoreInfoPckg(ownStoreInfo);
 
ownNumberStore.GetInfo(status, ownStoreInfoPckg);
User::WaitForRequest(status);
 
if(status.Int() == KErrNone)
{
CheckCapabilities(ownStoreInfo.iCaps);
 
if(ownStoreInfo.iUsedEntries < 1)
{
console->Printf(_L("No entry found.\n"));
User::Leave(KErrNotFound);
}
}
else
{
User::Leave(status.Int());
}
 
// Read the own number entry
status = KRequestPending;
RMobileONStore::TMobileONEntryV1 ownNumberEntry;
ownNumberEntry.iIndex = 1;
RMobileONStore::TMobileONEntryV1Pckg ownNumberEntryPckg(ownNumberEntry);
 
ownNumberStore.Read(status,ownNumberEntryPckg);
User::WaitForRequest(status);
 
if (status.Int() == KErrNone)
{
console->Printf(_L("\nOwn number = %S"), &ownNumberEntry.iNumber.iTelNumber);
}
else
{
console->Printf(_L("\nNO Own number: error %d"), status);
}
 
CleanupStack::PopAndDestroy(2); // i-th phone & ownNumberStore;
}


Alternatively, you may be able to use a helper class CRetrieveMobilePhoneONList if the target device supports KCapsWholeStore capability. The following code snippet illustrates an example usage.

 #include <mmretrieve.h>
 
// Precondition server, phone module and phone have been opened
 
RMobileONStore ownNumberStore;
User::LeaveIfError(store.Open(phone));
CleanupClosePushL(ownNumberStore);
 
RMobilePhoneBookStore::TMobilePhoneBookInfoV1 storeInfo;
RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg storeInfoPckg(storeInfo);
store.GetInfo(status,storeInfoPckg);
User::WaitForRequest(status);
 
if(status == KErrNone)
{
if(storeInfo.iCaps & RMobilePhoneStore::KCapsWholeStore)
{
console->Printf(_L("KCapsWholeStore supported"));
}
else if (storeInfo.iCaps & RMobilePhoneStore::KCapsIndividualEntry )
{
console->Printf(_L("KCapsIndividualEntry supported"));
}
}
 
CRetrieveMobilePhoneONList* retrieve;
retrieve=CRetrieveMobilePhoneONList::NewL(ownNumberStore);
 
retrieve->Start(status);
User::WaitForRequest(status);
 
CMobilePhoneONList* onList=NULL;
TInt error=KErrNone;
TRAP(error, onList=retrieve->RetrieveListL();)
 
TInt numOfEntry = 0;
if (error == KErrNone)
{
numOfEntry = onList->Enumerate();
}
 
RMobileONStore::TMobileONEntryV1 entry;
for (TInt index=0; index < numOfEntry ; index++)
{
error = KErrNone;
TRAP(error, entry = onList->GetEntryL(index))
if (error == KErrNone)
{
console->Printf(_L("Own Number %S\n"), entry.iNumber.iTelNumber);
}
else
{
console->Printf(_L("Read error!!"));
}
}
 
//Close the phone and the mobileStore and remove them from the cleanup stack
CleanupStack::PopAndDestroy(2);
This page was last modified on 3 May 2013, at 06:55.
80 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×