- support ALERTING notification (to know when it's ringing on the other side)

- cosmetical fixes in capi.cpp


git-svn-id: https://svn.ibp.de/svn/capisuite/trunk/capisuite@93 4ebea2bb-67d4-0310-8558-a5799e421b66
This commit is contained in:
gernot 2003-04-17 10:39:42 +00:00
parent 68e8269f49
commit b5441590db
5 changed files with 115 additions and 13 deletions

View File

@ -2,7 +2,7 @@
@brief Contains CallInterface - Interface class for all signals specific to a certain call.
@author Gernot Hillier <gernot@hillier.de>
$Revision: 1.1 $
$Revision: 1.2 $
*/
/***************************************************************************
@ -38,6 +38,10 @@ using namespace std;
class CallInterface
{
public:
/** @brief Called if the other party is alerted, i.e. it has started "ringing" there
*/
virtual void alerting (void) = 0;
/** @brief Called if the connection is completely established (physical + logical)
*/
virtual void callConnected (void) = 0;
@ -85,8 +89,12 @@ class CallInterface
/* History
$Log: callinterface.h,v $
Revision 1.1 2003/02/19 08:19:53 gernot
Initial revision
Revision 1.2 2003/04/17 10:39:42 gernot
- support ALERTING notification (to know when it's ringing on the other side)
- cosmetical fixes in capi.cpp
Revision 1.1.1.1 2003/02/19 08:19:53 gernot
initial checkin of 0.4
Revision 1.9 2002/12/06 12:55:04 ghillie
- updated docs

View File

@ -2,7 +2,7 @@
@brief Contains Capi - Main Class for communication with CAPI
@author Gernot Hillier <gernot@hillier.de>
$Revision: 1.4 $
$Revision: 1.5 $
*/
/***************************************************************************
@ -32,7 +32,7 @@ void* capi_exec_handler(void* arg)
}
Capi::Capi (ostream& debug, unsigned short debug_level, ostream &error, unsigned maxLogicalConnection, unsigned maxBDataBlocks,unsigned maxBDataLen) throw (CapiError, CapiMsgError)
:debug(debug),debug_level(debug_level),error(error),messageNumber(0),usedInfoMask(0),usedCIPMask(0),numControllers(0)
:debug(debug),debug_level(debug_level),error(error),messageNumber(0),usedInfoMask(0x10),usedCIPMask(0),numControllers(0)
{
if (debug_level >= 2)
debug << prefix() << "Capi object created" << endl;
@ -45,6 +45,9 @@ Capi::Capi (ostream& debug, unsigned short debug_level, ostream &error, unsigned
if (applId == 0 || info!=0)
throw (CapiMsgError(info,"Error while registering application: "+describeParamInfo(info),"Capi::Capi()"));
for (int i=1;i<=numControllers;i++)
listen_req(i, usedInfoMask, usedCIPMask); // can throw CapiMsgError
int erg=pthread_create(&thread_handle, NULL, capi_exec_handler, this); // create a normal thread
if (erg!=0)
throw (CapiMsgError(erg,"Error while starting message thread","Capi::Capi()"));
@ -352,7 +355,7 @@ Capi::data_b3_resp (_cword messageNumber, _cdword ncci, _cword dataHandle) throw
throw(CapiMsgError(info,"Error while DATA_B3_RESP: "+Capi::describeParamInfo(info),"Capi::data_b3_resp()"));
}
void
void
Capi::facility_resp (_cword messageNumber, _cdword address, _cword facilitySelector, _cstruct facilityResponseParameter) throw (CapiMsgError)
{
if (debug_level >= 2)
@ -368,8 +371,22 @@ Capi::facility_resp (_cword messageNumber, _cdword address, _cword facilitySelec
throw(CapiMsgError(info,"Error while FACILITY_RESP: "+Capi::describeParamInfo(info),"Capi::facility_resp()"));
}
void
Capi::info_resp (_cword messageNumber, _cdword address) throw (CapiMsgError)
{
if (debug_level >= 2)
debug << prefix() << ">INFO_RESP ApplId 0x" << hex << applId << ", MsgNr 0x" << messageNumber << ", Address 0x" << address << endl;
void
_cmsg new_message;
unsigned info=INFO_RESP(&new_message, applId, messageNumber, address);
if (debug_level >= 2)
debug << prefix() << "info: " << info << endl;
if (info != 0)
throw(CapiMsgError(info,"Error while INFO_RESP: "+Capi::describeParamInfo(info),"Capi::info_resp()"));
}
void
Capi::disconnect_b3_resp (_cword messageNumber, _cdword ncci) throw (CapiMsgError)
{
if (debug_level >= 2)
@ -618,10 +635,30 @@ Capi::readMessage (void) throw (CapiMsgError, CapiError, CapiWrongState, CapiExt
}
break;
case CAPI_INFO:
switch (INFO_IND_INFONUMBER(&nachricht)) {
case 0x8001: { // ALERTING
_cdword plci=INFO_IND_PLCI(&nachricht);
if (debug_level >= 2)
debug << prefix() << "<INFO_IND: PLCI 0x" << hex << plci << ", InfoNumber ALERTING " << endl;
if (connections.count(plci)==0)
throw(CapiError("PLCI unknown in INFO_IND","Capi::readMessage()"));
else
connections[plci]->info_ind_alerting(nachricht);
} break;
default:
if (debug_level >= 2)
debug << prefix() << "<INFO_IND: Controller/PLCI 0x" << hex << INFO_IND_PLCI(&nachricht) << ", InfoNumber " << INFO_IND_INFONUMBER(&nachricht) << " (ignoring)" << endl;
info_resp(nachricht.Messagenumber,INFO_IND_PLCI(&nachricht));
break;
}
break;
default:
stringstream err;
err << "Indication 0x" << hex << nachricht.Command << " not handled" << ends;
err << "Indication 0x" << hex << static_cast<int>(nachricht.Command) << " not handled" << ends;
throw (CapiError(err.str(),"Capi::readMessage()"));
break;
}
@ -657,8 +694,11 @@ Capi::run()
debug << prefix() << "**" << endl;
}
}
catch (CapiMsgError e) {
error << prefix() << "ERROR: Connection " << this << ": Error in readMessage(), message: " << e << endl;
}
catch (CapiError e) {
error << prefix() << "ERROR: Connection " << this << ": Error in readMessage(), messagge: " << e << endl;
error << prefix() << "ERROR: Connection " << this << ": Error in readMessage(), message: " << e << endl;
}
}
}
@ -911,6 +951,10 @@ Capi::getInfo(bool verbose)
/* History
$Log: capi.cpp,v $
Revision 1.5 2003/04/17 10:39:42 gernot
- support ALERTING notification (to know when it's ringing on the other side)
- cosmetical fixes in capi.cpp
Revision 1.4 2003/04/04 09:14:02 gernot
- setListenTelephony() and setListenFaxG3 now check if the given controller
supports this service and throw an error otherwise

View File

@ -2,7 +2,7 @@
@brief Contains Capi - Main Class for communication with CAPI
@author Gernot Hillier <gernot@hillier.de>
$Revision: 1.4 $
$Revision: 1.5 $
*/
/***************************************************************************
@ -317,6 +317,14 @@ class Capi {
*/
void facility_resp (_cword messageNumber, _cdword address, _cword facilitySelector, _cstruct facilityResponseParameter=NULL) throw (CapiMsgError);
/** @brief send INFO_RESP to CAPI
@param messageNumber number of the referred INDICATION message
@param address Nr. of connection (Controller/PLCI)
@throw CapiMsgError Thrown when CAPI_PUT_MESSAGE returned an error.
*/
void info_resp (_cword messageNumber, _cdword address) throw (CapiMsgError);
/** @brief send DISCONNECT_RESP to CAPI
@param messageNumber number of the referred INDICATION message
@ -433,6 +441,10 @@ class Capi {
/* History
$Log: capi.h,v $
Revision 1.5 2003/04/17 10:39:42 gernot
- support ALERTING notification (to know when it's ringing on the other side)
- cosmetical fixes in capi.cpp
Revision 1.4 2003/04/08 07:50:48 gernot
- fix wrong exception order which gcc-2.95 doesn't like...

View File

@ -2,7 +2,7 @@
@brief Contains Connection - Encapsulates a CAPI connection with all its states and methods.
@author Gernot Hillier <gernot@hillier.de>
$Revision: 1.6 $
$Revision: 1.7 $
*/
/***************************************************************************
@ -523,6 +523,27 @@ Connection::facility_ind_DTMF(_cmsg &message) throw (CapiWrongState)
call_if->gotDTMF();
}
void
Connection::info_ind_alerting(_cmsg &message) throw (CapiWrongState)
{
if (plci_state!=P01 && plci_state!=P1)
throw CapiWrongState("INFO_IND for ALERTING received in wrong state","Connection::info_ind_alerting()");
if (plci!=INFO_IND_PLCI(&message))
throw CapiError("INFO_IND received with wrong PLCI","Connection::info_ind_alerting()");
try {
capi->info_resp(message.Messagenumber,plci);
}
catch (CapiMsgError e) {
error << prefix() << "WARNING: Can't send info_resp. Message was: " << e << endl;
}
if (call_if)
call_if->alerting();
}
void
Connection::connect_conf(_cmsg& message) throw (CapiWrongState, CapiMsgError)
{
@ -979,6 +1000,10 @@ Connection::buildBconfiguration(_cdword controller, service_t service, string fa
/* History
$Log: connection.cpp,v $
Revision 1.7 2003/04/17 10:39:42 gernot
- support ALERTING notification (to know when it's ringing on the other side)
- cosmetical fixes in capi.cpp
Revision 1.6 2003/04/17 10:36:29 gernot
- fix another typo which could probably lead to errors in sending own number...

View File

@ -2,7 +2,7 @@
@brief Contains Connection - Encapsulates a CAPI connection with all its states and methods.
@author Gernot Hillier <gernot@hillier.de>
$Revision: 1.2 $
$Revision: 1.3 $
*/
/***************************************************************************
@ -391,7 +391,7 @@ class Connection
/** @brief called when we get FACILITY_IND from CAPI with facility selector saying it's DTMF
This method will save the received DTMF to received_dtmf, send a response to Capi and call
This method will save the received DTMF to received_dtmf, send a response to Capi and call
CallInterface::gotDTMF().
@param message the received FACILITY_IND message
@ -399,6 +399,15 @@ class Connection
*/
void facility_ind_DTMF(_cmsg& message) throw (CapiWrongState);
/** @brief called when we get INFO_IND from CAPI with Info number saying it's ALERTING
This method will call CallInterface::alerting().
@param message the received INFO_IND message
@throw CapiWrongState Thrown when the message is received unexpected (i.e. in a wrong plci_state)
*/
void info_ind_alerting(_cmsg& message) throw (CapiWrongState);
/** @brief called when we get DISCONNECT_B3_IND from CAPI
This method will also send a response to Capi and stop_file_transmission and stop_file_reception().
@ -627,6 +636,10 @@ class Connection
/* History
$Log: connection.h,v $
Revision 1.3 2003/04/17 10:39:42 gernot
- support ALERTING notification (to know when it's ringing on the other side)
- cosmetical fixes in capi.cpp
Revision 1.2 2003/04/04 09:17:59 gernot
- buildBconfiguration() now checks the abilities of the given controller
and throws an error if it doesn't support the service