Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

CallModule Class Reference

Base class for all call handling modules. More...

#include <callmodule.h>

Inheritance diagram for CallModule:

CallInterface AudioReceive AudioSend CallOutgoing ConnectModule DisconnectModule FaxReceive FaxSend ReadDTMF Switch2FaxG3 List of all members.

Public Methods

 CallModule (Connection *connection, int timeout=-1, bool DTMF_exit=false, bool checkConnection=true) throw (CapiWrongState)
 Constructor. Register this module at the according Connection object.

 ~CallModule ()
 Destructor. Deregister this module at the according Connection object.

virtual void mainLoop () throw (CapiWrongState,CapiMsgError,CapiExternalError)
 Waits in busy loop until the module is completed.

virtual void transmissionComplete (void)
 empty here.

virtual void alerting (void)
 empty here.

virtual void callConnected (void)
 empty here.

virtual void callDisconnectedLogical (void)
 abort current modul if logical connection is lost.

virtual void callDisconnectedPhysical (void)
 abort current module if physical connection is lost.

virtual void gotDTMF (void)
 finish current module if DTMF is received.

virtual void dataIn (unsigned char *data, unsigned length)
 empty here.


Protected Methods

virtual long getTime ()
 get the current time in # of seconds sinc 1/1/1970

void resetTimer (int new_timeout)
 restart the timer with new timeout value


Protected Attributes

bool DTMF_exit
 if set to true, we will finish when we receive a DTMF signal

bool finish
 set this if the module should exit nicely for any reason

Connectionconn
 reference to the according Connection object

long exit_time
 time when the timeout should occur

int timeout
 timeout period in seconds


Detailed Description

Base class for all call handling modules.

This class implements the CallInterface. It is the base class for all special call handling modules like FaxReceive/FaxSend, AudioReceive/ AudioSend, etc. It contains basic code for registering with the according Connection object, realizing exits because of timeouts, received DTMF and call clearing from the other party.

The general usage is: create a CallModule object, then run mainLoop(). mainLoop() will exit if necessary.

To be able to recognize call clearing of the other party, the CapiWrongState exception is used. The call state will be checked ONLY at the beginning of the module execution - if it is down, an exception will be thrown by assureConnection(). If a subclass doesn't want this, it should overwrite assureConnection() with an empty implementation.

Sub classes will mainly overwrite mainLoop() and the other signals they need for their tasks.

If you don't change the semantics in the sub classes, the module will terminate when at least one of the following events occurs:

Author:
Gernot Hillier


Constructor & Destructor Documentation

CallModule::CallModule Connection   connection,
int    timeout = -1,
bool    DTMF_exit = false,
bool    checkConnection = true
throw (CapiWrongState)
 

Constructor. Register this module at the according Connection object.

Parameters:
connection  reference to Connection object
timeout  timeout for this module in seconds (only considered in mainLoop!), -1=infinite (default)
DTMF_exit  if this is set to true, then the current module is exited if we receive a DTMF tone
assure  connection is up at beginning
Exceptions:
CapiWrongState  thrown if connection checking was enabled and connection is not up

CallModule::~CallModule  
 

Destructor. Deregister this module at the according Connection object.


Member Function Documentation

void CallModule::alerting void    [virtual]
 

empty here.

empty function to overwrite if necessary

Implements CallInterface.

Reimplemented in CallOutgoing.

void CallModule::callConnected void    [virtual]
 

empty here.

empty function to overwrite if necessary

Implements CallInterface.

Reimplemented in CallOutgoing, ConnectModule, and Switch2FaxG3.

void CallModule::callDisconnectedLogical void    [virtual]
 

abort current modul if logical connection is lost.

will abort currently running module. May be overwritten with complete new behaviour if needed.

Implements CallInterface.

Reimplemented in DisconnectModule, ReadDTMF, and Switch2FaxG3.

void CallModule::callDisconnectedPhysical void    [virtual]
 

abort current module if physical connection is lost.

will abort currently running module. Only overwrite if you know what you do!

Implements CallInterface.

Reimplemented in ReadDTMF.

void CallModule::dataIn unsigned char *    data,
unsigned    length
[virtual]
 

empty here.

empty function to overwrite if necessary

Implements CallInterface.

Reimplemented in AudioReceive.

long CallModule::getTime   [protected, virtual]
 

get the current time in # of seconds sinc 1/1/1970

void CallModule::gotDTMF void    [virtual]
 

finish current module if DTMF is received.

finish current module if DTMF_exit was enabled

Implements CallInterface.

Reimplemented in ReadDTMF.

void CallModule::mainLoop   throw (CapiWrongState,CapiMsgError,CapiExternalError) [virtual]
 

Waits in busy loop until the module is completed.

Waits in a busy loop (sleeping 100 msecs between each iteration) until a DTMF signal is reached (if enabled) or the timeout is reached (if enabled).

This method will likely be overwritten in each sub class. You can call CallModule::mainLoop() there to implement busy loops.

Exceptions:
CapiMsgError  A CAPI function hasn't succeeded for some reason (not thrown by CallModule, but may be thrown in subclasses).
CapiExternalError  A given command didn't succeed for a reason not caused by the CAPI (not thrown by CallModule, but may be thrown in subclasses)
CapiWrongState  Not thrown here, but sub classes may throw it

Reimplemented in AudioReceive, AudioSend, CallOutgoing, ConnectModule, DisconnectModule, FaxReceive, FaxSend, ReadDTMF, and Switch2FaxG3.

void CallModule::resetTimer int    new_timeout [protected]
 

restart the timer with new timeout value

void CallModule::transmissionComplete void    [virtual]
 

empty here.

empty function to overwrite if necessary

Implements CallInterface.

Reimplemented in AudioSend, FaxReceive, and FaxSend.


Member Data Documentation

Connection* CallModule::conn [protected]
 

reference to the according Connection object

bool CallModule::DTMF_exit [protected]
 

if set to true, we will finish when we receive a DTMF signal

long CallModule::exit_time [protected]
 

time when the timeout should occur

bool CallModule::finish [protected]
 

set this if the module should exit nicely for any reason

int CallModule::timeout [protected]
 

timeout period in seconds


The documentation for this class was generated from the following files:
Generated on Mon Jan 5 12:20:00 2004 for CapiSuite by doxygen1.2.18