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

connection.h

Go to the documentation of this file.
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 CONNECTION_H 00018 #define CONNECTION_H 00019 00020 #include <capi20.h> 00021 #include <vector> 00022 #include <string> 00023 #include <fstream> 00024 #include "capiexception.h" 00025 00026 class CallInterface; 00027 class Capi; 00028 00029 using namespace std; 00030 00049 class Connection 00050 { 00051 friend class Capi; 00052 00053 public: 00064 enum service_t { 00065 VOICE, 00066 FAXG3, 00067 OTHER 00068 }; 00069 00088 Connection (Capi* capi, _cdword controller, string call_from, bool clir, string call_to, service_t service, string faxStationID, string faxHeadline) throw (CapiExternalError, CapiMsgError); 00089 00100 ~Connection(); 00101 00106 void registerCallInterface(CallInterface *call_if); 00107 00126 void changeProtocol (service_t desired_service, string faxStationID, string faxHeadline) throw (CapiMsgError, CapiExternalError, CapiWrongState); 00127 00141 void start_file_transmission(string filename) throw (CapiError,CapiWrongState,CapiExternalError,CapiMsgError); 00142 00147 void stop_file_transmission(); 00148 00160 void start_file_reception(string filename) throw (CapiWrongState, CapiExternalError); 00161 00166 void stop_file_reception(); 00167 00170 enum disconnect_mode_t { 00171 ALL, 00172 PHYSICAL_ONLY, 00173 LOGICAL_ONLY 00174 }; 00175 00194 void disconnectCall(disconnect_mode_t disconnect_mode=ALL) throw (CapiMsgError); 00195 00207 void connectWaiting(service_t desired_service, string faxStationID="", string faxHeadline="") throw (CapiWrongState,CapiExternalError,CapiMsgError); 00208 00218 void rejectWaiting(_cword reject) throw (CapiWrongState, CapiMsgError, CapiExternalError); 00219 00229 void acceptWaiting() throw (CapiMsgError, CapiWrongState); 00230 00240 void enableDTMF() throw (CapiWrongState, CapiMsgError); 00241 00247 void disableDTMF() throw (CapiWrongState, CapiMsgError); 00248 00255 string getDTMF(); 00256 00259 void clearDTMF(); 00260 00265 string getCalledPartyNumber(); 00266 00271 string getCallingPartyNumber(); 00272 00277 service_t getService(); 00278 00286 _cword getCause(); 00287 00295 _cword getCauseB3(); 00296 00297 00300 enum connection_state_t { 00301 DOWN, 00302 WAITING, 00303 UP, 00304 OTHER_STATE 00305 }; 00306 00311 connection_state_t getState(); 00312 00318 struct fax_info_t { 00319 int rate; 00320 bool hiRes; 00321 unsigned short format; 00322 int pages; 00323 std::string stationID; 00324 }; 00325 00330 fax_info_t* getFaxInfo(); 00331 00339 void errorMessage(string message); 00340 00341 00350 void debugMessage(string message, unsigned short level); 00351 00352 protected: 00353 00368 Connection (_cmsg& message, Capi *capi, unsigned short DDILength=0, unsigned short DDIBaseLength=0, std::vector<std::string> DDIStopNumbers=std::vector<std::string>()); 00369 00370 /********************************************************************************/ 00371 /* methods handling CAPI messages - called by the Capi class */ 00372 /********************************************************************************/ 00373 00374 /*************************** INDICATIONS ****************************************/ 00375 00385 void connect_active_ind(_cmsg& message) throw (CapiWrongState, CapiMsgError); 00386 00395 void connect_b3_ind(_cmsg& message) throw (CapiWrongState, CapiMsgError); 00396 00406 void connect_b3_active_ind(_cmsg& message) throw (CapiError,CapiWrongState,CapiExternalError); 00407 00417 void data_b3_ind(_cmsg& message) throw (CapiError,CapiWrongState,CapiMsgError); 00418 00428 void facility_ind_DTMF(_cmsg& message) throw (CapiError,CapiWrongState); 00429 00438 void info_ind_alerting(_cmsg& message) throw (CapiError,CapiWrongState); 00439 00451 bool info_ind_called_party_nr(_cmsg& message) throw (CapiError,CapiWrongState); 00452 00462 void disconnect_b3_ind(_cmsg& message) throw (CapiError,CapiWrongState); 00463 00473 void disconnect_ind(_cmsg& message) throw (CapiError,CapiWrongState,CapiMsgError); 00474 00475 /*************************** CONFIRMATIONS **************************************/ 00476 00483 void connect_conf(_cmsg& message) throw (CapiWrongState, CapiMsgError); 00484 00491 void connect_b3_conf(_cmsg& message) throw (CapiWrongState, CapiMsgError); 00492 00500 void select_b_protocol_conf(_cmsg& message) throw (CapiError,CapiWrongState,CapiMsgError); 00501 00509 void alert_conf(_cmsg& message) throw (CapiError,CapiWrongState,CapiMsgError); 00510 00521 void data_b3_conf(_cmsg& message) throw (CapiError,CapiWrongState, CapiMsgError, CapiExternalError); 00522 00530 void facility_conf_DTMF(_cmsg& message) throw (CapiError,CapiWrongState,CapiMsgError); 00531 00539 void disconnect_b3_conf(_cmsg& message) throw (CapiError,CapiWrongState,CapiMsgError); 00540 00548 void disconnect_conf(_cmsg& message) throw (CapiError,CapiWrongState,CapiMsgError); 00549 00550 /********************************************************************************/ 00551 /* internal methods */ 00552 /********************************************************************************/ 00553 00558 string prefix(); 00559 00566 string getNumber (_cstruct capi_input, bool isCallingNr); 00567 00581 void send_block() throw (CapiError,CapiWrongState,CapiExternalError,CapiMsgError); 00582 00603 void buildBconfiguration(_cdword controller, service_t service, string faxStationID, string faxHeadline, _cword& B1proto, _cword& B2proto, _cword& B3proto, _cstruct& B1config, _cstruct& B2config, _cstruct& B3config) throw (CapiExternalError); 00604 00614 void convertToCP437(string &text); 00615 00616 /********************************************************************************/ 00617 /* attributes */ 00618 /********************************************************************************/ 00619 00625 enum plci_state_t { 00626 P0, 00627 P01, 00628 P1, 00629 P2, 00630 P3, 00631 P4, 00632 P5, 00633 P6, 00634 PACT 00635 } plci_state; 00636 00641 enum ncci_state_t { 00642 N0, 00643 N01, 00644 N1, 00645 N2, 00646 N3, 00647 N4, 00648 N5, 00649 NACT 00650 } ncci_state; 00651 00652 _cdword plci; 00653 _cdword ncci; 00654 00655 service_t service; 00656 00657 _cword connect_ind_msg_nr; 00658 00659 _cword disconnect_cause, 00660 disconnect_cause_b3; 00661 00662 string call_from; 00663 string call_to; 00664 00665 string received_dtmf; 00666 00667 bool keepPhysicalConnection, 00668 our_call; 00669 00670 CallInterface *call_if; 00671 Capi *capi; 00672 00673 pthread_mutex_t send_mutex, 00674 receive_mutex; 00675 00676 ofstream *file_for_reception; 00677 ifstream *file_to_send; 00678 00679 ostream &debug, 00680 &error; 00681 unsigned short debug_level; 00682 00691 char send_buffer[7][2048]; 00692 00693 unsigned short buffer_start, 00694 buffers_used; 00695 00696 fax_info_t* fax_info; 00697 00698 unsigned short DDILength; 00699 unsigned short DDIBaseLength; 00700 vector<string> DDIStopNumbers; 00701 }; 00702 00703 #endif 00704 00705 /* History 00706 00707 $Log: connection.h,v $ 00708 Revision 1.6.2.4 2003/11/11 21:05:41 gernot 00709 - fix typo in comment 00710 00711 Revision 1.6.2.3 2003/11/02 14:58:16 gernot 00712 - use DDI_base_length instead of DDI_base 00713 - added DDI_stop_numbers option 00714 - use DDI_* options in the Connection class 00715 - call the Python script if number is complete 00716 00717 Revision 1.6.2.2 2003/11/01 22:59:33 gernot 00718 - read CalledPartyNr InfoElements 00719 00720 Revision 1.6.2.1 2003/10/26 16:51:55 gernot 00721 - begin implementation of DDI, get DDI Info Elements 00722 00723 Revision 1.6 2003/06/28 12:49:47 gernot 00724 - convert fax headline to CP437, so that german umlauts and other special 00725 characters will work now 00726 00727 Revision 1.5 2003/05/25 13:38:30 gernot 00728 - support reception of color fax documents 00729 00730 Revision 1.4 2003/05/24 13:48:54 gernot 00731 - get fax details (calling station ID, transfer format, ...), handle PLCI 00732 00733 Revision 1.3 2003/04/17 10:39:42 gernot 00734 - support ALERTING notification (to know when it's ringing on the other side) 00735 - cosmetical fixes in capi.cpp 00736 00737 Revision 1.2 2003/04/04 09:17:59 gernot 00738 - buildBconfiguration() now checks the abilities of the given controller 00739 and throws an error if it doesn't support the service 00740 - it also sets the fax protocol setting now the highest available ability 00741 (fax G3 or fax G3 extended) of the controller, thus preparing fax polling 00742 and *working around a severe bug in the AVM drivers producing a kernel 00743 oops* with some analog fax devices. AVM knows about this and analyzes it. 00744 00745 Revision 1.1.1.1 2003/02/19 08:19:53 gernot 00746 initial checkin of 0.4 00747 00748 Revision 1.30 2003/02/10 14:20:52 ghillie 00749 merged from NATIVE_PTHREADS to HEAD 00750 00751 Revision 1.29.2.1 2003/02/10 14:07:54 ghillie 00752 - use pthread_mutex_* instead of CommonC++ Semaphore 00753 00754 Revision 1.29 2003/01/04 16:08:22 ghillie 00755 - log improvements: log_level, timestamp 00756 - added methods debugMessage(), errorMessage(), removed get*Stream() 00757 - added some additional debug output for connection setup / finish 00758 00759 Revision 1.28 2002/12/16 13:13:47 ghillie 00760 - added getCauseB3 to return B3 cause 00761 00762 Revision 1.27 2002/12/13 11:46:59 ghillie 00763 - added attribute our_call to differ outgoing and incoming calls 00764 00765 Revision 1.26 2002/12/11 13:39:05 ghillie 00766 - added support for PHYSICAL_ONLY disconnect in disconnectCall() 00767 00768 Revision 1.25 2002/12/10 15:06:15 ghillie 00769 - new methods get*Stream() for use in capisuitemodule 00770 00771 Revision 1.24 2002/12/09 15:42:24 ghillie 00772 - save debug and error stream in own attributes 00773 00774 Revision 1.23 2002/12/06 15:25:47 ghillie 00775 - new return value for getState(): WAITING 00776 00777 Revision 1.22 2002/12/06 13:07:36 ghillie 00778 - update docs because application is now responsible to delete 00779 Connection object 00780 - new methods getCause() and getState() 00781 00782 Revision 1.21 2002/12/05 15:05:12 ghillie 00783 - moved constructor for incoming calls to "private:" 00784 00785 Revision 1.20 2002/12/02 12:31:36 ghillie 00786 renamed Connection::SPEECH to Connection::VOICE 00787 00788 Revision 1.19 2002/11/29 10:25:01 ghillie 00789 - updated comments, use doxygen format now 00790 00791 Revision 1.18 2002/11/27 16:03:20 ghillie 00792 updated comments for doxygen 00793 00794 Revision 1.17 2002/11/25 11:51:54 ghillie 00795 - removed the unhandy CIP parameters from the interface to the application layer, use service type instead 00796 - rejectWaiting() tests against cause!=0 now 00797 - removed isUp() method 00798 00799 Revision 1.16 2002/11/22 15:13:44 ghillie 00800 - new attribute keepPhysicalConnection which prevents disconnect_b3_ind() from sending disconnect_req() 00801 - moved the ugly B*configuration, B*protocol settings from some methods to private method buildBconfiguration 00802 - new methods changeProtocol(), select_b_protocol_conf(), clearDTMF() 00803 - disconnect_b3_ind sets ncci_state to N0 before calling the callbacks 00804 - added parameter disconnect_mode to disconnectCall() 00805 - getDTMF() does non-destructive read now 00806 00807 Revision 1.15 2002/11/21 15:30:28 ghillie 00808 - added new method Connection::acceptWaiting() - sends ALERT_REQ 00809 - updated description of Connection::connectWaiting() 00810 00811 Revision 1.14 2002/11/19 15:57:19 ghillie 00812 - Added missing throw() declarations 00813 - phew. Added error handling. All exceptions are caught now. 00814 00815 Revision 1.13 2002/11/18 14:24:09 ghillie 00816 - moved global severity_t to CapiError::severity_t 00817 - added throw() declarations 00818 00819 Revision 1.12 2002/11/18 12:24:33 ghillie 00820 - changed disconnectCall() so that it doesn't throw exceptions any more, 00821 so that we can call it in any state 00822 00823 Revision 1.11 2002/11/17 14:40:55 ghillie 00824 added isUp() 00825 00826 Revision 1.10 2002/11/15 15:25:53 ghillie 00827 added ALERT_REQ so we don't loose a call when we wait before connection establishment 00828 00829 Revision 1.9 2002/11/15 13:49:10 ghillie 00830 fix: callmodule wasn't aborted when call was only connected/disconnected physically 00831 00832 Revision 1.8 2002/11/14 17:05:19 ghillie 00833 major structural changes - much is easier, nicer and better prepared for the future now: 00834 - added DisconnectLogical handler to CallInterface 00835 - DTMF handling moved from CallControl to Connection 00836 - new call module ConnectModule for establishing connection 00837 - python script reduced from 2 functions to one (callWaiting, callConnected 00838 merged to callIncoming) 00839 - call modules implement the CallInterface now, not CallControl any more 00840 => this freed CallControl from nearly all communication stuff 00841 00842 Revision 1.7 2002/11/13 08:34:54 ghillie 00843 moved history to the bottom 00844 00845 Revision 1.6 2002/11/10 17:05:18 ghillie 00846 changed to support multiple buffers -> deadlock in stop_file_transmission!! 00847 00848 Revision 1.5 2002/11/08 07:57:07 ghillie 00849 added functions to initiate a call 00850 corrected FACILITY calls to use PLCI instead of NCCI in DTMF processing as told by Mr. Ortmann on comp.dcom.isdn.capi 00851 00852 Revision 1.4 2002/10/31 12:40:06 ghillie 00853 added DTMF support 00854 small fixes like making some unnecessary global variables local, removed some unnecessary else cases 00855 00856 Revision 1.3 2002/10/30 14:29:25 ghillie 00857 added getCIPvalue 00858 00859 Revision 1.2 2002/10/29 14:27:42 ghillie 00860 added stop_file_*, added semaphores 00861 00862 Revision 1.1 2002/10/25 13:29:38 ghillie 00863 grouped files into subdirectories 00864 00865 Revision 1.10 2002/10/10 12:45:40 gernot 00866 added AudioReceive module, some small details changed 00867 00868 Revision 1.9 2002/10/09 11:18:59 gernot 00869 cosmetic changes (again...) and changed info function of CAPI class 00870 00871 Revision 1.8 2002/10/04 15:48:03 gernot 00872 structure changes completed & compiles now! 00873 00874 Revision 1.7 2002/10/04 13:27:15 gernot 00875 some restructuring to get it to a working state ;-) 00876 00877 does not do anything useful yet nor does it even compile... 00878 00879 Revision 1.6 2002/10/01 09:02:04 gernot 00880 changes for compilation with gcc3.2 00881 00882 Revision 1.5 2002/09/22 14:22:53 gernot 00883 some cosmetic comment improvements ;-) 00884 00885 Revision 1.4 2002/09/19 12:08:19 gernot 00886 added magic CVS strings 00887 00888 * Sun Sep 15 2002 - gernot@hillier.de 00889 - put under CVS, cvs changelog follows above 00890 00891 * Sun May 20 2002 - gernot@hillier.de 00892 - first version 00893 00894 */

Generated on Sun Nov 28 14:37:44 2004 for CapiSuite by doxygen 1.3.8