Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 Member Functions

 CallModule (Connection *connection, int timeout=-1, bool DTMF_exit=false)
 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,CapiError)
 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 Member Functions

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
bool abort
 set this for hard exit because connection is lost, causes CapiWrongState to be throwed in mainLoop
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. It is triggered by mainLoop().

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
 

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

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, 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 DisconnectModule.

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,CapiError) [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:
CapiWrongState Something is tried in a wrong connection state. This usually means our call was finished (raised directly).
CapiMsgError A CAPI function hasn't succeeded for some reason (not thrown by CallModule, but may be thrown in subclasses).
CapiError Some internal error has occured (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)

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

bool CallModule::abort [protected]
 

set this for hard exit because connection is lost, causes CapiWrongState to be throwed in mainLoop

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 Sun Nov 28 14:37:44 2004 for CapiSuite by doxygen 1.3.8