The following is a dial-up section.Code(From the Nokia example), although there are not many codes, it is worth learning in many places, such as the use and cleaning of R classes, server/client mechanism, parameter transfer mechanism, and encoding style; comment style and so on.
Before reading the code, familiarize yourself with the Etel structure in Symbian OS C ++ and its core classes rtelserver, rphone, rline, and rcall.
The following is the code:
Void dialnumberl (const tdesc & aphonenumber)
{
// 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 (ktsyname ));
// 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 (aphonenumber ));
// 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 (ktsyname ));
// Close the connection to the Tel server and remove it from the cleanup Stack
Cleanupstack: popanddestroy (& server );
}//