WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章手机编程Symbian程序开发在C++下实现的程序拨号代码

在C++下实现的程序拨号代码
作者:csdn  来源:csdn  发布时间:2006-11-30 22:13:39

呵呵,下面是一段拨号代码(摘自Nokia的例子),代码虽然不多,但很多地方都值得学习,例如:对R类的使用,清理;server/client机制;参数传递机制;编码风格;注释风格等等自己体会吧。

 在阅读代码之前请熟悉Symbian OS C++中的ETel结构,以及它的核心类RTelServer,RPhone,RLine,RCall.

下面是代码内容:

 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 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);//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);
 }   //end

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码