对于程序中如何实现拨打电话,
参考了两种方式。
其一(貌似是2rd中的形式):http://www.sf.org.cn/Article/symbiandev/200603/17333
- C/C++ code
#include <etel.h> // for dial operatons //LIBRARY etel.lib // for dial operationsTBool CMcAppUi::dialTel(TDesC & telNum) { _LIT(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 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(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 ; }
这段代码我加到程序中,
试着用点击菜单项后的响应来实现,
但是在菜单停在那一段时间后,
什么都没发生,
没有出现拨打电话相关的任何事件。
(也想在真机上试,但是没有证书,程序安装后无法执行)
另外一种来源于http://wiki.forum.nokia.com/index.php/Make_call_with_CTelephony。
把上面这个类原封不动地拷贝了,
然后再我的试验程序里加入CCallDialer这个对象,
也是通过一个菜单乡响应通过
void CMyView::HandleMenuItemSelectL()
{
iCallDialer = new (ELeave)CCallDialer(*this);
iCallDialer->ConstructL(phoneNumber);
}
void CMyContainer::CallDialedL(TInt aError)
{
delete iCallDialer;
iCallDialer = NULL;
TBuf<32> error;
error.AppendNum(aError);
iEikonEnv->InfoMsg(error);
}
实验拨打电话的功能,
依然不能拨打电话,
通过上面的InfoMsg报出了-4这个错误,
查了半天也不知道是怎么回事。
如果我把 iCallDialer = new (ELeave)CCallDialer(*this); iCallDialer->ConstructL(phoneNumber);
放到CMyContainer的ConstructL里,则报出-16的错误。
麻烦哪位有经验的朋友帮忙给看看吧,
感激不尽。
BTW:
最近做个项目,
时间紧,
S60上的开发又是刚刚接触,
碰到了太多问题,
经常来论坛上请教,
希望前辈们多多帮助,
谢谢。
------解决方案--------------------------------------------------------
有没有加能力呀?