تابعی که میٰبینید، یک شماره میگیرد و به آن زنگ میزند. (شماره تلفن به صورت واصف گرفته میشود.) البته برنامه زنگ زدن خود سیستم را صدا میزند. موقع برقرار تماس، برنامه شما به پشت صفحه میرود و پس از اتمام مکالمه، برنامه دوباره ظاهر میشود.
توضیحات داخل کد موجود است.
_LIT(KTsyName, “phonetsy.tsy”);
void DialNumberL(const TDesC& aPhoneNumber)
{
//Create a connection to the tel server
RtelServer server;
CleanupClosePushL(server);
User::LeaverIfError(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 of the phone
Rphone::TLineInfo lineInfo;
User::LEaveIfError(phone.GetLineInfo(0, lineInfo));
//Use this to open a line
Rline line;
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);
//Unload the phone device driver
User::LeaveIfError(server.UnloadPhoneModule(KTsyName));
//Close the connection to the tel server and remove it from
//cleanup stack
CleanupStack::PopAndDestroy(&server);
}
منبع: Sampleهای SDK
