Call the dialing method under Symbian
When developing a phone book application, you often need to call the recipient's phone number directly.
So, how can I use code to dial my mobile phone on the Symbian s60 platform?
The following code may help you:
Add the header file:
# Include <Etel. h> // For dial operatons
To add the following content to the MPs file:
Library Etel. Lib // For dial operations
Tbool cmcappui: dialtel (tdesc & telnum ){
_ Partition (kphone_drv, "phonetsy. tsy ");
// Create a connection to the Tel Server
Rtelserver server;
Cleanupclosepushl (server );
User: leaveiferror (server. Connect ());
// Load in the phone device driver
User: leaveiferror (server. loadphonemodule (kphone_drv ));
// Find the number of phones available from the Tel Server
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
Rtelserver: tphoneinfo Info;
User: leaveiferror (server. getphoneinfo (0, Info ));
// Use this info to open a connection to the phone, the phone is identified by its name
Rphone phone;
Cleanupclosepushl (phone );
User: leaveiferror (phone. Open (server, info. INAME ));
// Get info about the first line from the phone
Rphone: tlineinfo lineinfo;
User: leaveiferror (phone. getlineinfo (0, lineinfo ));
// Use this to open a line
Rline;
Cleanupclosepushl (line );
User: leaveiferror (line. Open (phone, lineinfo. INAME ));
// Open a new call on this line
Tbuf <100> newcallname;
Rcall call;
Cleanupclosepushl (CALL );
User: leaveiferror (call. opennewcall (line, newcallname ));
// Newcallname will now contain the name of the call
User: leaveiferror (call. Dial (telnum ));
// Close the phone, line and call connections and remove them from the cleanup Stack
// Note: this does not hang up the call
Cleanupstack: popanddestroy (3); // phone, line, call
// Unload the phone device driver
User: leaveiferror (server. unloadphonemodule (kphone_drv ));
// Close the connection to the Tel server and remove it from the cleanup Stack
Cleanupstack: popanddestroy (& server );
Return etrue;
}
This code is very useful and has been tested on multiple s60 real machines.