6.2 telephone —電話服務(wù)
這個(gè)模塊提供了使用電話的api
因?yàn)樵O(shè)備用戶也可以手動(dòng)明確的掛起電話,所以這會(huì)影響到當(dāng)前的通話狀態(tài)。補(bǔ)充,使用這個(gè)模塊在模擬器上不會(huì)有效果因?yàn)椴荒艿玫酵ㄔ挕?br />
此telephone模塊有下列函數(shù)。
dial(number)
撥打number指定的號(hào)碼,number 是一個(gè)字符串,例如 u'+358501234567' 此處'+'表示國際前綴,'358'為國家代號(hào),'50'為移動(dòng)網(wǎng)絡(luò)代號(hào)(或地區(qū)代碼) '1234567'為用戶電話。如果有一個(gè)進(jìn)行中的通話早于在python中的撥號(hào),那么先前的通話被掛斷然后新的通話被建立。
hang_up()
嘗試掛起調(diào)用此函數(shù)進(jìn)程中的一個(gè)被dial 函數(shù)建立的通話。如果通話已經(jīng)完成,拋出 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 模塊提供消息服務(wù)api。目前,messaging 模塊有函數(shù):
The messaging module offers APIs to messaging services. Currently, the messaging module has functions:
sms_send(number, msg, [encoding=’7bit’, callback=None, name=”” ])
發(fā)送一個(gè)主體為文字(unicode 編碼)的SMS 消息到指定電話號(hào)碼(為字符串)
Sends an SMS message with body text msg 4 (Unicode)to telephone number number (string).
可選參數(shù) encoding被用來定義消息編碼。
The optional parameter encoding is used to define encoding in the message. The parameter values can be ’7bit’, ’8bit’ or ’UCS2’.
可選參數(shù)callback 根據(jù)當(dāng)前發(fā)送操作狀態(tài)被執(zhí)行??捎玫臓顟B(tài)定義在messaging 模塊的數(shù)據(jù)成員中。如果前一次發(fā)送請(qǐng)求正在進(jìn)行,再執(zhí)行另外一次發(fā)送, 將拋出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 發(fā)送函數(shù)將阻塞直到隊(duì)列中的消息被刪除或發(fā)生發(fā)送錯(cuò)誤。
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 .
可選參數(shù)name在消息成功發(fā)送到號(hào)碼后 ,將顯示在發(fā)件箱中,表示接受消息者名稱。如果參數(shù)沒有提供,那么接受者電話號(hào)碼將被顯示在 發(fā)件箱中。
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 閱讀(329)
評(píng)論(1) 編輯 收藏