Two days ago, I added a dialing function in the program and started to use it directly from the Nokia SDK example. I did not study it carefully, so I encountered two problems. The first is that the white screen appears during the call, and the second is that the program exits when the second call is made.
The first problem. Later, with the help of Steven, I learned from the Symbian Technology Group that it should be called in asynchronous mode, that is, AO, and the source code in the example cannot be copied. I used cleanupstack to call rtelserver, rphone, rline and rcall are destroyed. In that case, the istatus status cannot be returned, resulting in a program error.
The second question. When you call the second call, if you do not close the above R class objects, you can directly connect or open and exit the program directly. Obviously, the solution is to close the four R-class objects related to the call. File solution.
Blame yourself for being impetuous and not careful; even if the source code examples are ready-made, you must carefully understand them. Lessons!
The following shows the key code:
/////////////////////// Header file mydial. h
Class cmydial: Public cactive
{
Public:
Static cmydial * newl ();
Static cmydial * newlc ();
Cmydial ();
Virtual ~ Cmydial ();
Protected:
Void constructl ();
Public:
// From cactive:
Virtual void runl ();
Virtual void docancel ();
Public: // new functions:
Void dialnumberl (const tdesc & aphonenumber );
PRIVATE:
Trequeststatus istatus;
Rtelserver iServer;
Rphone iPhone;
Rline iline;
Rcall iCall;
};
/////////////////////// Key method of mydial. cpp in the CPP file:
Void cmydial: dialnumberl (const tdesc & aphonenumber)
{
# If _ wins __
Return;
# Endif
Cancel ();
ICall. Close ();
Iline. Close ();
IPhone. Close ();
IServer. Close ();
// Create a connection to the Tel iServer
User: leaveiferror (iServer. Connect ());
// Load in the iPhone Device Driver
User: leaveiferror (iServer. loadphonemodule (ktsyname ));
// Find the number of phones available from the Tel iServer
Tint numberphones;
User: leaveiferror (iServer. enumeratephones (numberphones ));
// Check there are available phones
If (numberphones <1)
{
User: Leave (kerrnotfound );
}
// Get info about the first available iPhone
Rtelserver: tphoneinfo Info;
User: leaveiferror (iServer. getphoneinfo (0, Info ));
// Use this info to open a connection to the iPhone, the iPhone is identified by its name
User: leaveiferror (iPhone. Open (iServer, info. INAME ));
// Get info about the first iline from the iPhone
Rphone: tlineinfo lineinfo;
User: leaveiferror (iPhone. getlineinfo (0, lineinfo ));
// Use this to open a iline
User: leaveiferror (iline. Open (iPhone, lineinfo. INAME ));
// Open a new iCall on this iline
Tbuf <100> newcallname;
User: leaveiferror (iCall. opennewcall (iline, newcallname ));
// Newcallname will now contain the name of the iCall
// User: leaveiferror (iCall. Dial (aphonenumber ));
ICall. Dial (istatus, aphonenumber );
Setactive ();
// Unload the iPhone Device Driver
User: leaveiferror (iServer. unloadphonemodule (ktsyname ));
}