Symbian
Symbian OS Library

FAQ-0778 How should my application listen for outgoing calls being connected?

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: JavaPhone
Created: 03/19/2002 Modified: 04/02/2002
Number: FAQ-0778
Platform: Symbian OS v6.0, Symbian OS v6.1, Symbian OS v7.0

Question:
My application allows users to initiate phone calls. What JTAPI event should I handle to be able to respond to a call being initiated on the phone?

Answer:
The first JTAPI event to occur will be callActive(). You can handle this by defining a CallListener in your UI and adding it to the Call object after it is created but before it is connected.

    However, if you wish to listen for events associated with both incoming and outgoing calls, you may prefer to add a single CallListener to your (unique) Terminal object and handle everything there. But then you will have the problem that, when you call connect() on the Call, the callActive() event generated will not be picked up by your CallListener. This is because, according to the JTAPI state model, the creation of the Connection and TerminalConnection, which link the Call logically with your Terminal, will not have been created until after your call has become active. The first event which, in Symbian's JTAPI implementation, you can guarantee will be picked up by a CallListener on your Terminal will be the terminalConnectionCreated() event on the local TerminalConnection object. You can handle this by adding a suitable TerminalConnectionListener to your Terminal, using the addCallListener(...) method.
    public class MyPhoneApp implements TerminalConnectionListener
    {
    ...
    public MyPhoneApp()
    {
    ...
    try
    {
    JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
    provider = peer.getProvider("EpocGsmMobileProvider");
    Terminal[] terminals = provider.getTerminals();
    origTerminal = (MobileTerminal) terminals[0];
    origTerminal.addCallListener(this);
    makeCallB.setEnabled(true);
    }
    catch(Exception e)
    {
    System.out.println("Can't get a provider");
    }
    ...
    }

    public void terminalConnectionCreated(TerminalConnectionEvent ev)
    {
    //handle outgoing call connection here
    }
    ...
    }