随笔 - 67  文章 - 79  trackbacks - 0
<2009年3月>
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(1)

随笔档案

文章档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜

6.2 telephone —电话服务
这个模块提供了使用电话的api
因为设备用户也可以手动明确的挂起电话,所以这会影响到当前的通话状态。补充,使用这个模块在模拟器上不会有效果因为不能得到通话。
此telephone模块有下列函数。

dial(number)
     拨打number指定的号码,number 是一个字符串,例如 u'+358501234567' 此处'+'表示国际前缀,'358'为国家代号,'50'为移动网络代号(或地区代码) '1234567'为用户电话。如果有一个进行中的通话早于在python中的拨号,那么先前的通话被挂断然后新的通话被建立。

hang_up()
   尝试挂起调用此函数进程中的一个被dial 函数建立的通话。如果通话已经完成,抛出 SymbianError: KErrNotReady


Note: The following functions and data items are available from S60 3rd Edition onwards (inclusive).
incoming call()
     Wait for incoming call, returns immediately. If a call arrives, answer can be called to answer the call. Without the invocation of function incoming call, the function answer has no effect.
answer()
     Answers an incoming call - see also incoming call.
call state(callable)
     The callable will be called when there are changes in the telephone line (lines) in the device. The argument for the call is a tuple with first item the possible new state and the second item, the possible incoming call number as a Unicode string.
     The possible states in the tuple are defined as telephone module constants.

messaging 模块提供消息服务api。目前,messaging 模块有函数:
The messaging module offers APIs to messaging services. Currently, the messaging module has functions:

sms_send(number, msg, [encoding=’7bit’, callback=None, name=”” ])
       发送一个主体为文字(unicode 编码)的SMS 消息到指定电话号码(为字符串)
       Sends an SMS message with body text msg 4 (Unicode)to telephone number number (string).
      可选参数 encoding被用来定义消息编码。
       The optional parameter encoding is used to define encoding in the message. The parameter values  can be ’7bit’, ’8bit’ or ’UCS2’.
       可选参数callback 根据当前发送操作状态被执行。可用的状态定义在messaging 模块的数据成员中。如果前一次发送请求正在进行,再执行另外一次发送, 将抛出RuntimeError
       The optional parameter callback is invoked with the current status of the send operation as parameter. The possible states are data items in the module messaging. Invoking another send while a previous send request is ongoing will result in RuntimeError being raised.
       如果callback 没有提供,sms 发送函数将阻塞直到队列中的消息被删除或发生发送错误。
       If the callback is not given, the sms send function will block until the message in the queue is either deleted or the sending has failed5 .
     可选参数name在消息成功发送到号码后 ,将显示在发件箱中,表示接受消息者名称。如果参数没有提供,那么接受者电话号码将被显示在 发件箱中。
       The optional parameter name will be shown in the sent item message entry as recipient’s name after successfully sending message to number . If this parameter is not specified, then the recipient’s phone number will be shown in the sent item message entry6 .


example:

>>> import messaging
>>>
>>> def cb(state):
...   if state==messaging.ESent:
...     print "**Message was sent**"
...   if state==messaging.ESendFailed:
...     print "**Something went wrong - Truly sorry for this**"
...
>>> messaging.sms_send("1234567", "Hello from PyS60!", ’7bit’, cb, "Mary")
>>> **Message was sent** # This is printed from the callback


mms_send(number, msg, [attachment=None ])
       Note: Available from S60 3.0 onwards (inclusive).
       Sends an MMS message with body text msg (Unicode) to telephone number number (string). The
       optional parameter attachment is full path to e.g. image file attached to the message.


posted on 2009-03-16 15:32 zarra 阅读(321) 评论(1)  编辑  收藏

FeedBack:
# re: pys60 文档 简单翻译[未登录] 2009-03-17 18:21 apple
好牛啊,连这个都被你研究出来了~~~~~~~~  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: