00001 00008 /*************************************************************************** 00009 * * 00010 * This program is free software; you can redistribute it and/or modify * 00011 * it under the terms of the GNU General Public License as published by * 00012 * the Free Software Foundation; either version 2 of the License, or * 00013 * (at your option) any later version. * 00014 * * 00015 ***************************************************************************/ 00016 00017 #ifndef CAPI_H 00018 #define CAPI_H 00019 00020 #include <capi20.h> 00021 #include <string> 00022 #include <map> 00023 #include <vector> 00024 #include "capiexception.h" 00025 00026 class Connection; 00027 class ApplicationInterface; 00028 00033 void* capi_exec_handler(void* args); 00034 00060 class Capi { 00061 friend class Connection; 00062 friend void* capi_exec_handler(void*); 00063 00064 public: 00076 Capi (ostream &debug, unsigned short debug_level, ostream &error, unsigned maxLogicalConnection=2, unsigned maxBDataBlocks=7,unsigned maxBDataLen=2048) throw (CapiError, CapiMsgError); 00077 00082 ~Capi(); 00083 00088 void registerApplicationInterface(ApplicationInterface* application_in); 00089 00103 void setListenFaxG3 (_cdword Controller=0) throw (CapiMsgError,CapiError); 00104 00118 void setListenTelephony (_cdword Controller=0) throw (CapiMsgError,CapiError); 00119 00139 string getInfo(bool verbose=false); 00140 00141 private: 00142 00147 void unregisterConnection (_cdword plci); 00148 00154 void readProfile() throw (CapiMsgError); 00155 00156 00157 /********************************************************************************/ 00158 /* methods to send CAPI messages - called by the Connection class */ 00159 /********************************************************************************/ 00160 00161 /*************************** REQUESTS *******************************************/ 00162 00170 void listen_req (_cdword Controller, _cdword InfoMask=0x03FF, _cdword CIPMask=0x1FFF03FF) throw (CapiMsgError); 00171 00177 void alert_req (_cdword plci) throw (CapiMsgError); 00178 00198 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); 00199 00211 void select_b_protocol_req (_cdword plci, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration) throw (CapiMsgError); 00212 00218 void connect_b3_req (_cdword plci) throw (CapiMsgError); 00219 00229 void data_b3_req (_cdword ncci, void* Data, _cword DataLength,_cword DataHandle,_cword Flags) throw (CapiMsgError); 00230 00237 void disconnect_b3_req (_cdword ncci, _cstruct ncpi=NULL) throw (CapiMsgError); 00238 00247 void disconnect_req (_cdword plci, _cstruct Keypadfacility=NULL, _cstruct Useruserdata=NULL, _cstruct Facilitydataarray=NULL) throw (CapiMsgError); 00248 00256 void facility_req (_cdword address, _cword FacilitySelector, _cstruct FacilityRequestParameter) throw (CapiMsgError); 00257 00258 /*************************** RESPONSES *******************************************/ 00259 00273 void connect_resp (_cword messageNumber, _cdword plci, _cword reject, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration) throw (CapiMsgError); 00274 00281 void connect_active_resp (_cword messageNumber, _cdword plci) throw (CapiMsgError); 00282 00291 void connect_b3_resp (_cword messageNumber, _cdword ncci, _cword reject, _cstruct ncpi) throw (CapiMsgError); 00292 00299 void connect_b3_active_resp (_cword messageNumber, _cdword ncci) throw (CapiMsgError); 00300 00308 void data_b3_resp (_cword messageNumber, _cdword ncci, _cword dataHandle) throw (CapiMsgError); 00309 00318 void facility_resp (_cword messageNumber, _cdword address, _cword facilitySelector, _cstruct facilityResponseParameter=NULL) throw (CapiMsgError); 00319 00326 void info_resp (_cword messageNumber, _cdword address) throw (CapiMsgError); 00327 00334 void disconnect_resp (_cword messageNumber, _cdword plci) throw (CapiMsgError); 00335 00342 void disconnect_b3_resp (_cword messageNumber, _cdword ncci) throw (CapiMsgError); 00343 00344 /********************************************************************************/ 00345 /* main message handling method for incoming msgs */ 00346 /********************************************************************************/ 00347 00358 void readMessage (void) throw (CapiMsgError, CapiError, CapiWrongState, CapiExternalError); 00359 00360 /********************************************************************************/ 00361 /* methods for internal use */ 00362 /********************************************************************************/ 00363 00372 static string describeParamInfo (unsigned int info); 00373 00378 unsigned short getApplId(void) {return applId;} 00379 00382 virtual void run(void); 00383 00388 string prefix(); 00389 00390 /********************************************************************************/ 00391 /* attributes */ 00392 /********************************************************************************/ 00393 00396 class CardProfileT 00397 { 00398 public: 00401 CardProfileT() 00402 :manufacturer(""),version(""),bChannels(0),fax(false),faxExt(false),dtmf(false) 00403 {} 00404 00405 string manufacturer; 00406 string version; 00407 int bChannels; 00408 bool transp; 00409 bool fax; 00410 bool faxExt; 00411 bool dtmf; 00412 bool suppServ; 00413 }; 00414 00415 short numControllers; 00416 string capiManufacturer, 00417 capiVersion; 00418 00419 vector <CardProfileT> profiles; 00420 00421 00422 map <_cdword,Connection*> connections; 00423 00424 00425 _cword messageNumber; 00426 _cdword usedInfoMask; 00427 _cdword usedCIPMask; 00428 00429 unsigned applId; 00430 00431 ApplicationInterface *application; 00432 ostream &debug, 00433 &error; 00434 unsigned short debug_level; 00435 00436 pthread_t thread_handle; 00437 }; 00438 00439 #endif 00440 00441 /* History 00442 00443 Old Log (for new changes see ChangeLog): 00444 Revision 1.5 2003/04/17 10:39:42 gernot 00445 - support ALERTING notification (to know when it's ringing on the other side) 00446 - cosmetical fixes in capi.cpp 00447 00448 Revision 1.4 2003/04/08 07:50:48 gernot 00449 - fix wrong exception order which gcc-2.95 doesn't like... 00450 00451 Revision 1.3 2003/04/04 09:14:02 gernot 00452 - setListenTelephony() and setListenFaxG3 now check if the given controller 00453 supports this service and throw an error otherwise 00454 00455 Revision 1.2 2003/04/03 21:16:03 gernot 00456 - added new readProfile() which stores controller profiles in attributes 00457 - getInfo() only creates the string out of the stored values and doesn't 00458 do the real inquiry any more 00459 - getInfo() and numControllers aren't static any more 00460 00461 Revision 1.1.1.1 2003/02/19 08:19:53 gernot 00462 initial checkin of 0.4 00463 00464 Revision 1.22 2003/02/10 14:20:52 ghillie 00465 merged from NATIVE_PTHREADS to HEAD 00466 00467 Revision 1.21.2.1 2003/02/09 15:05:36 ghillie 00468 - rewritten to use native pthread_* calls instead of CommonC++ Thread 00469 00470 Revision 1.21 2003/01/06 16:29:52 ghillie 00471 - destructor doesn't throw any exceptions any more 00472 00473 Revision 1.20 2003/01/04 16:07:42 ghillie 00474 - log improvements: log_level, timestamp 00475 00476 Revision 1.19 2002/12/18 14:40:44 ghillie 00477 - removed this nasty listen_state. Made nothing than problems 00478 00479 Revision 1.18 2002/12/11 13:05:34 ghillie 00480 - minor comment improvements 00481 00482 Revision 1.17 2002/12/09 15:33:23 ghillie 00483 - debug and error stream now given in constructor 00484 00485 Revision 1.16 2002/12/05 15:02:36 ghillie 00486 - constructor: removed param application (pointer to ApplicationInterface, now given by registerApplInterface()), added param debug giving debug stream 00487 - new methods registerApplicationInterface(), unregisterConnection() 00488 - connect_req gets COnnection* now 00489 00490 Revision 1.15 2002/11/29 11:38:13 ghillie 00491 - missed some changes because CapiCommThread was deleted 00492 00493 Revision 1.14 2002/11/29 11:11:12 ghillie 00494 - moved communication thread from own class (CapiCommThread) to Capi class 00495 00496 Revision 1.13 2002/11/29 10:23:07 ghillie 00497 - updated comments, use doxygen format now 00498 00499 Revision 1.12 2002/11/27 15:58:13 ghillie 00500 updated comments for doxygen 00501 00502 Revision 1.11 2002/11/25 20:58:47 ghillie 00503 - improved documentation, is now readable by doxygen 00504 - setListen* can now set listen state for all available controllers 00505 00506 Revision 1.10 2002/11/22 15:08:22 ghillie 00507 - new method select_b_protocol_req() 00508 - added SELECT_B_PROTOCOL_CONF case in readMessage() 00509 00510 Revision 1.9 2002/11/19 15:57:18 ghillie 00511 - Added missing throw() declarations 00512 - phew. Added error handling. All exceptions are caught now. 00513 00514 Revision 1.8 2002/11/18 14:24:09 ghillie 00515 - moved global severity_t to CapiError::severity_t 00516 - added throw() declarations 00517 00518 Revision 1.7 2002/11/17 14:39:23 ghillie 00519 removed CapiError from this header -> exceptions are now defined in capiexception.h 00520 00521 Revision 1.6 2002/11/15 15:25:53 ghillie 00522 added ALERT_REQ so we don't loose a call when we wait before connection establishment 00523 00524 Revision 1.5 2002/11/13 08:34:54 ghillie 00525 moved history to the bottom 00526 00527 Revision 1.4 2002/11/08 07:57:07 ghillie 00528 added functions to initiate a call 00529 corrected FACILITY calls to use PLCI instead of NCCI in DTMF processing as told by Mr. Ortmann on comp.dcom.isdn.capi 00530 00531 Revision 1.3 2002/10/31 15:39:04 ghillie 00532 added missing FACILITY_RESP message (oops...) 00533 00534 Revision 1.2 2002/10/31 12:37:35 ghillie 00535 added DTMF support 00536 00537 Revision 1.1 2002/10/25 13:29:38 ghillie 00538 grouped files into subdirectories 00539 00540 Revision 1.8 2002/10/09 14:36:22 gernot 00541 added CallModule base class for all call handling modules 00542 00543 Revision 1.7 2002/10/09 11:18:59 gernot 00544 cosmetic changes (again...) and changed info function of CAPI class 00545 00546 Revision 1.6 2002/10/08 12:01:26 gernot 00547 cosmetic... (indentation) 00548 00549 Revision 1.5 2002/10/01 09:02:04 gernot 00550 changes for compilation with gcc3.2 00551 00552 Revision 1.4 2002/09/22 14:22:53 gernot 00553 some cosmetic comment improvements ;-) 00554 00555 Revision 1.3 2002/09/19 12:08:19 gernot 00556 added magic CVS strings 00557 00558 * Sun Sep 15 2002 - gernot@hillier.de 00559 - put under CVS, cvs changelog follows above 00560 00561 * Sun May 19 2002 - gernot@hillier.de 00562 - changed to not using QT libs any more 00563 - modified to conform to CAPI20-Spec, 4th edition (parameter names, ...) 00564 00565 * Sun Apr 1 2002 - gernot@hillier.de 00566 - first version 00567 00568 */