Archived:How to use telephone module

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Created: Rafael T. (25 Oct 2008)
Last edited: hamishwillee (28 Jun 2012)

PySymbian provides a default module for controlling calls: the telephone module.

Available Functions


Dials the number set in number . number is a string, for example u’+358501234567’ where ’+’ is the international prefix, ’358’ is the country code, ’50’ is the mobile network code (or the area code), and ’1234567’ is the subscriber number. If there is an ongoing phone call prior to calling dial from Python, then the earlier call is put on hold and a new call is established. Calling dial multiple times when, for example, the first call has been answered and a line has been established results in subsequent calls not being connected.

hang up()

Hangs up if a call initiated by dial is in process. If this call has already been finished, SymbianError: KErrNotReady is raised.

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.


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.

The following data items for state information are available in telephone:

EStatusUnknown: Indicates that the status is unknown.

EStatusIdle: Idle line status (no active calls).

EStatusDialling: Call dialling status.

EStatusRinging: Call ringing status.

EStatusAnswering: Call answering status.

EStatusConnecting: Call connecting status.

EStatusConnected: Call connected status.

EStatusReconnectPending: Call is undergoing temporary channel loss and it may or may not be reconnected.

EStatusDisconnecting: Call disconnecting status.

EStatusHold: Call on hold.

EStatusTransferring: Call is transferring.

EStatusTransferAlerting: Call in transfer is alerting the remote party.

Call States

import appuifw, telephone
CALL_STATE = {telephone.EStatusUnknown: "unknown",
telephone.EStatusIdle: "idle",
telephone.EStatusDialling: "dialing",
telephone.EStatusRinging: "ringing",
telephone.EStatusAnswering: "answering",
telephone.EStatusConnecting: "connecting",
telephone.EStatusConnected: "connected",
telephone.EStatusReconnectPending: "reconnect pending",
telephone.EStatusDisconnecting: "disconnecting",
telephone.EStatusHold: "hold",
telephone.EStatusTransferring: "transferring",
telephone.EStatusTransferAlerting: "transfer alerting"};
def handle_call(callstate):
print "Current call state: "+CALL_STATE[callstate]
if callstate == telephone.EStatusRinging:
# Do something ...
elif callstate == telephone.EStatusAnswering:
# Do something ...
elif callstate == telephone.EStatusDisconnecting:
# Do something ...
# this is aplied to all states ...
def quit():
appuifw.app.exit_key_handler = quit
appuifw.app.title = u"Call States"
telephone.incoming_call() # waits for an incoming call
telephone.call_state(handle_call) # connects to handle_call for status handling

Functions Usage

import appuifw, telephone
#Calls the number given by the user in the query
number = appuifw.query(u"Enter the number","number")
#Hang up the call (only when initialized by telephone.dial()
#Waits for an incoming call
#Answers the incoming call

This article was written by Rafael T.

This page was last modified on 28 June 2012, at 09:26.
39 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.