#include <capi.h>
Public Member Functions | |
Capi (ostream &debug, unsigned short debug_level, ostream &error, unsigned short DDILength=0, unsigned short DDIBaseLength=0, vector< string > DDIStopNumbers=vector< string >(), unsigned maxLogicalConnection=2, unsigned maxBDataBlocks=7, unsigned maxBDataLen=2048) throw (CapiError, CapiMsgError) | |
Constructor. Registers our App at CAPI and start the communication thread. | |
~Capi () | |
Destructor. Unregister App at CAPI. | |
void | registerApplicationInterface (ApplicationInterface *application_in) |
Register the instance implementing the ApplicationInterface. | |
void | setListenFaxG3 (_cdword Controller=0) throw (CapiMsgError,CapiError) |
Tell capi that we want to _additionally_ listen to Fax G3 calls. | |
void | setListenTelephony (_cdword Controller=0) throw (CapiMsgError,CapiError) |
Tell capi that we want to _additionally_ listen to Telephony calls. | |
string | getInfo (bool verbose=false) |
Static Returns some info about the installed Controllers. | |
Private Member Functions | |
void | unregisterConnection (_cdword plci) |
erase Connection object in connections map | |
void | readProfile () throw (CapiMsgError) |
Get informations about CAPI driver and installed controllers. | |
void | listen_req (_cdword Controller, _cdword InfoMask=0x03FF, _cdword CIPMask=0x1FFF03FF) throw (CapiMsgError) |
Send LISTEN_REQ to CAPI. | |
void | alert_req (_cdword plci) throw (CapiMsgError) |
Send ALERT_REQ to CAPI. | |
void | connect_req (Connection *conn, _cdword Controller, _cword CIPvalue, _cstruct calledPartyNumber, _cstruct callingPartyNumber, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration) throw (CapiMsgError) |
Send CONNECT_REQ to CAPI. | |
void | select_b_protocol_req (_cdword plci, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration) throw (CapiMsgError) |
send SELECT_B_PROTOCOL_REQ to CAPI | |
void | connect_b3_req (_cdword plci) throw (CapiMsgError) |
send CONNECT_B3_REQ to CAPI | |
void | data_b3_req (_cdword ncci, void *Data, _cword DataLength, _cword DataHandle, _cword Flags) throw (CapiMsgError) |
send DATA_B3_REQ to CAPI | |
void | disconnect_b3_req (_cdword ncci, _cstruct ncpi=NULL) throw (CapiMsgError) |
send DISCONNECT_B3_REQ to CAPI | |
void | disconnect_req (_cdword plci, _cstruct Keypadfacility=NULL, _cstruct Useruserdata=NULL, _cstruct Facilitydataarray=NULL) throw (CapiMsgError) |
send DISCONNECT_REQ to CAPI | |
void | facility_req (_cdword address, _cword FacilitySelector, _cstruct FacilityRequestParameter) throw (CapiMsgError) |
send FACILITY_REQ to CAPI | |
void | connect_resp (_cword messageNumber, _cdword plci, _cword reject, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration) throw (CapiMsgError) |
send CONNECT_RESP to CAPI | |
void | connect_active_resp (_cword messageNumber, _cdword plci) throw (CapiMsgError) |
send CONNECT_ACTIVE_RESP to CAPI | |
void | connect_b3_resp (_cword messageNumber, _cdword ncci, _cword reject, _cstruct ncpi) throw (CapiMsgError) |
send CONNECT_B3_RESP to CAPI | |
void | connect_b3_active_resp (_cword messageNumber, _cdword ncci) throw (CapiMsgError) |
send CONNECT_B3_ACTIVE_RESP to CAPI | |
void | data_b3_resp (_cword messageNumber, _cdword ncci, _cword dataHandle) throw (CapiMsgError) |
send DATA_B3_RESP to CAPI | |
void | facility_resp (_cword messageNumber, _cdword address, _cword facilitySelector, _cstruct facilityResponseParameter=NULL) throw (CapiMsgError) |
send FACILITY_RESP to CAPI | |
void | info_resp (_cword messageNumber, _cdword address) throw (CapiMsgError) |
send INFO_RESP to CAPI | |
void | disconnect_resp (_cword messageNumber, _cdword plci) throw (CapiMsgError) |
send DISCONNECT_RESP to CAPI | |
void | disconnect_b3_resp (_cword messageNumber, _cdword ncci) throw (CapiMsgError) |
send DISCONNECT_B3_RESP to CAPI | |
void | readMessage (void) throw (CapiMsgError, CapiError, CapiWrongState, CapiExternalError) |
read Message from CAPI and process it accordingly | |
unsigned short | getApplId (void) |
getApplId returns the application id we got from CAPI | |
virtual void | run (void) |
Thread body - endless loop, will be blocked until message is received and then call readMessage(). | |
string | prefix () |
return a prefix containing this pointer and date for log messages | |
Static Private Member Functions | |
string | describeParamInfo (unsigned int info) |
textual description for Parameter Info | |
Private Attributes | |
short | numControllers |
number of installed controllers, set by readProfile() method | |
string | capiManufacturer |
manufacturer of the general CAPI driver | |
string | capiVersion |
version of the general CAPI driver | |
unsigned short | DDILength |
length of extension number (DDI) when ISDN PtP mode is used (0=PtMP) | |
unsigned short | DDIBaseLength |
base number length for the ISDN interface if PtP mode is used | |
vector< string > | DDIStopNumbers |
list of DDIs shorten than DDILength we'll accept | |
vector< CardProfileT > | profiles |
map< _cdword, Connection * > | connections |
objects, referenced by PLCI (or 0xFACE & messageNum when Connection is in plci_state Connection::P01 | |
_cword | messageNumber |
sequencial message number, must be increased for every sent message | |
_cdword | usedInfoMask |
InfoMask currently used (in last listen_req). | |
_cdword | usedCIPMask |
CIPMask currently used (in last listen_req). | |
unsigned | applId |
containing the ID we got from CAPI after successful registration | |
ApplicationInterface * | application |
pointer to the application object implementing ApplicationInterface | |
ostream & | debug |
stream to write debug info to | |
ostream & | error |
stream for error messages | |
unsigned short | debug_level |
debug level | |
pthread_t | thread_handle |
handle for the created message reading thread | |
Friends | |
void * | capi_exec_handler (void *) |
Thread exec handler for Capi class. |
This class is the main encapsulation to use the CAPI ISDN interface.
There are only a small subset of methods which are of use for the application layer. These are for general purposes like enabling listening to calls and getting some nice formatted info strings.
The biggest amount are shadow methods for nearly all CAPI messages, which do the dumb stuff like increasing message numbers, testing for errors, building message structures and so on. Not each parameter of these is described in every detail here. For more details please have a look in the CAPI 2.0 specification, available from http://www.capi.org
There's also a big message handling routine (readMessage()) which calls special handlers for incoming messages of the CAPI.
A Capi object creates a new thread (with body run()) which waits for incoming messages in an endless loop and hands them to readMessage().
This class only does the general things - for handling single connections see Connection. Connection objects will be automatically created by this class for incoming connections and can be created manually to initiate an outgoing connection.
The application is supposed to create one single object of this class.
To communicate with the application via callback functions, the application must provide an implementation of the ApplicationInterface. The methods of this interface are called when some special events are received.
|
Constructor. Registers our App at CAPI and start the communication thread.
|
|
Destructor. Unregister App at CAPI.
|
|
Send ALERT_REQ to CAPI.
|
|
send CONNECT_ACTIVE_RESP to CAPI
|
|
send CONNECT_B3_ACTIVE_RESP to CAPI
|
|
send CONNECT_B3_REQ to CAPI
|
|
send CONNECT_B3_RESP to CAPI
|
|
Send CONNECT_REQ to CAPI. To be able to see which CONNECT_CONF corresponds to this CONNECT_REQ, the Connection object will be saved in the connections map under a pseudo PLCI (0xFACE & messageNumber). This will be corrected at the moment the CONNECT_CONF is received.
|
|
send CONNECT_RESP to CAPI
|
|
send DATA_B3_REQ to CAPI
|
|
send DATA_B3_RESP to CAPI
|
|
textual description for Parameter Info This method returns an error string for the given info parameter. The strings were taken out of the CAPI 2.0 spec
|
|
send DISCONNECT_B3_REQ to CAPI
|
|
send DISCONNECT_B3_RESP to CAPI
|
|
send DISCONNECT_REQ to CAPI
|
|
send DISCONNECT_RESP to CAPI
|
|
send FACILITY_REQ to CAPI
|
|
send FACILITY_RESP to CAPI
|
|
getApplId returns the application id we got from CAPI
|
|
Static Returns some info about the installed Controllers. The returned string has the following format (UPPERCASE words replaced): "NUM controllers found. CAPI_MANUFACTURER, version VERSION_OF_CAPI/SUBVERSION_OF_CAPI Controller X: CONTROLLER_MANUFACTURER (NUM B channels, SERVICE1, SERVICE2, ..., driver version DRIVER_VERSION/DRIVER_SUBVERSION Controller X+1: CONTROLLER_MANUFACTURER (NUM B channels, SERVICE1, SERVICE2, ..., driver version DRIVER_VERSION/DRIVER_SUBVERSION ..." If verbose is set to false, only the first line is returned. The following services are checked currently and printed as SERVICEX if found: DTMF, SuppServ, transparent, FaxG3, FaxG3ext The method uses values stored by readProfile which must have been called before (constructor does it).
|
|
send INFO_RESP to CAPI
|
|
Send LISTEN_REQ to CAPI.
|
|
return a prefix containing this pointer and date for log messages
|
|
read Message from CAPI and process it accordingly This method handles all incoming messages. It is called by run() and will call special handler methods of Connection mainly. Prints messages for debug purposes.
|
|
Get informations about CAPI driver and installed controllers. Fills the members profiles, capiVersion, capiManufacturer, numControllers
|
|
Register the instance implementing the ApplicationInterface.
|
|
Thread body - endless loop, will be blocked until message is received and then call readMessage().
|
|
send SELECT_B_PROTOCOL_REQ to CAPI
|
|
Tell capi that we want to _additionally_ listen to Fax G3 calls. This method enables listening to fax calls from the analog network (coded as Bearer Capability 3.1kHz audio and from ISDN coded as fax group 3. The previously set listen mask is not cleared, so that the application can call this method after another listen request w/o loosing the other services. It will also check if this controller is able to handle this service and throw an error otherwise.
|
|
Tell capi that we want to _additionally_ listen to Telephony calls. This method enables listening to speech calls from the analog network (coded as Bearer Capability 3.1kHz audio) and from ISDN (coded as Bearer Capability Speech or High Layer Compatibility telephony). The previously set listen mask is not cleared, so that the application can call this method after another listen request w/o loosing the other services. It will also check if this controller is able to handle this service and throw an error otherwise.
|
|
erase Connection object in connections map This method is used by Connection::~Connection() |
|
Thread exec handler for Capi class. This is a handler which will call this->run() for the use in pthread_create(). |
|
pointer to the application object implementing ApplicationInterface
|
|
containing the ID we got from CAPI after successful registration
|
|
manufacturer of the general CAPI driver
|
|
version of the general CAPI driver
|
|
objects, referenced by PLCI (or 0xFACE & messageNum when Connection is in plci_state Connection::P01 containing pointers to the currently active Connection |
|
base number length for the ISDN interface if PtP mode is used
|
|
length of extension number (DDI) when ISDN PtP mode is used (0=PtMP)
|
|
list of DDIs shorten than DDILength we'll accept
|
|
stream to write debug info to
|
|
debug level
|
|
stream for error messages
|
|
sequencial message number, must be increased for every sent message
|
|
number of installed controllers, set by readProfile() method
|
|
vector containing profiles for all found cards (ATTENTION: starts with index 0, while CAPI numbers controllers starting by 1 (sigh) |
|
handle for the created message reading thread
|
|
CIPMask currently used (in last listen_req).
|
|
InfoMask currently used (in last listen_req).
|