1 /* $Id$ */ 2 /* 3 * Copyright (c) 1990-1996 Sam Leffler 4 * Copyright (c) 1991-1996 Silicon Graphics, Inc. 5 * HylaFAX is a trademark of Silicon Graphics 6 * 7 * Permission to use, copy, modify, distribute, and sell this software and 8 * its documentation for any purpose is hereby granted without fee, provided 9 * that (i) the above copyright notices and this permission notice appear in 10 * all copies of the software and related documentation, and (ii) the names of 11 * Sam Leffler and Silicon Graphics may not be used in any advertising or 12 * publicity relating to the software without the specific, prior written 13 * permission of Sam Leffler and Silicon Graphics. 14 * 15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 18 * 19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 24 * OF THIS SOFTWARE. 25 */ 26 #ifndef _ModemConfig_ 27 #define _ModemConfig_ 28 /* 29 * Modem Configuration. 30 */ 31 #include "FaxConfig.h" 32 #include "FaxModem.h" 33 34 #include "Array.h" 35 #include "StrArray.h" 36 37 class id_config 38 { 39 public: 40 fxStr pattern; 41 int answerlength; 42 compare(const id_config * n)43 int compare (const id_config* n) const 44 { 45 return ::compare(pattern, n->pattern); 46 } 47 48 }; 49 50 fxDECLARE_ObjArray(IDConfArray, id_config); 51 52 struct ModemConfig : public FaxConfig { 53 private: 54 BaudRate getRate(const char*); 55 u_int getFill(const char*); 56 FlowControl getFlow(const char*); 57 void setVolumeCmds(const fxStr& value); 58 u_int getSpeed(const char* value); 59 u_int getDataFormat(const char* value); 60 u_int getRTNHandling(const char* cp); 61 u_int getBadPageHandling(const char* cp); 62 u_int getJBIGSupport(const char* cp); 63 ECMType getECMType(const char* cp); 64 65 static bool findRate(const char*, BaudRate&); 66 static bool findATResponse(const char*, ATResponse&); 67 static bool findFlow(const char*, FlowControl&); 68 static bool findDataFormat(const char*, u_int&); 69 static bool findRTNHandling(const char*, RTNHandling&); 70 protected: 71 ModemConfig(); 72 73 void setupConfig(); 74 virtual void resetConfig(); 75 76 virtual bool setConfigItem(const char* tag, const char* value); 77 virtual void configError(const char* fmt, ...) = 0; 78 virtual void configTrace(const char* fmt, ...) = 0; 79 fxStr parseATCmd(const char*); 80 81 u_int callidIndex; // call id index 82 public: 83 fxStr type; // modem type 84 fxStr resetCmds; // extra modem reset commands for start of initialization 85 fxStr readyCmds; // extra modem reset commands for end of initialization 86 fxStr dialCmd; // cmd for dialing (%s for number) 87 fxStr answerAnyCmd; // cmd for answering unknown call type 88 fxStr answerDataCmd; // cmd for answering data call 89 fxStr answerFaxCmd; // cmd for answering fax call 90 fxStr answerVoiceCmd; // cmd for answering voice call 91 fxStr answerDialCmd; // cmd for answering a dialed call 92 fxStr ringResponse; // cmd to respond after AT_RING 93 fxStr hardFlowCmd; // cmd for hardware flow control 94 fxStr softFlowCmd; // cmd for software flow control 95 fxStr noFlowCmd; // cmd for disabling flow control 96 fxStr setupDTRCmd; // cmd for setting up DTR handling 97 fxStr setupDCDCmd; // cmd for setting up DCD handling 98 fxStr setupAACmd; // cmd for setting up adaptive answer 99 fxStr noAutoAnswerCmd; // cmd for disabling auto-answer 100 fxStr setVolumeCmd[5]; // cmd for setting modem speaker volume 101 fxStr echoOffCmd; // cmd for disabling echo 102 fxStr verboseResultsCmd; // cmd for enabling verbose result codes 103 fxStr resultCodesCmd; // cmd for enabling result codes 104 fxStr onHookCmd; // cmd for placing phone ``on hook'' 105 fxStr softResetCmd; // cmd for doing soft reset 106 u_int softResetCmdDelay; // time in ms to pause after soft reset 107 u_int noAutoAnswerCmdDelay; // time in ms to pause after noAutoAnswerCmd 108 u_int ringsBeforeResponse; // number of rings to wait before ModemRingResponse 109 u_int ringTimeout; // timeout in ms after RING to reset 110 fxStr waitTimeCmd; // cmd for setting carrier wait time 111 fxStr pauseTimeCmd; // cmd for setting "," pause time 112 fxStr mfrQueryCmd; // cmd for getting modem manufacturer 113 fxStr modelQueryCmd; // cmd for getting modem model id 114 fxStr revQueryCmd; // cmd for getting modem firmware rev 115 fxStr answerAnyBeginCmd; // cmd to start unknown inbound session 116 fxStr answerDataBeginCmd; // cmd to start inbound data session 117 fxStr answerFaxBeginCmd; // cmd to start inbound fax session 118 fxStr answerVoiceBeginCmd; // cmd to start inbound voice session 119 fxStr sendBeginCmd; // cmd to start outbound session 120 fxStr recvSuccessCmd; // cmd for after successful reception 121 fxStr class0Cmd; // cmd for setting Class 0 122 fxStr classQueryCmd; // cmd for getting modem services 123 // distinctive ring 124 fxStr ringData; // data call ring string 125 fxStr ringFax; // fax call ring string 126 fxStr ringVoice; // voice call ring string 127 fxStr ringExtended; // extended ring 128 fxStr dringOn; // pattern for distinctive ring silence interval 129 fxStr dringOff; // pattern for distinctive ring ring interval 130 bool noAnswerVoice; // leave voice calls unanswered 131 bool saverawimage; // debugging feature to save raw image data 132 // call identification 133 IDConfArray idConfig; // pattern for ID info 134 // protocol timers 135 u_int t1Timer; // T.30 T1 timer (ms) 136 u_int t2Timer; // T.30 T2 timer (ms) 137 u_int t4Timer; // T.30 T4 timer (ms) 138 u_int dialResponseTimeout; // dialing command timeout (ms) 139 u_int answerResponseTimeout; // answer command timeout (ms) 140 u_int pageStartTimeout; // page send/receive timeout (ms) 141 u_int pageDoneTimeout; // page send/receive timeout (ms) 142 // for class 1: 143 fxStr class1Cmd; // cmd for setting Class 1 144 fxStr class1AdaptRecvCmd; // cmd to enable adaptive reception control 145 fxStr class1EnableV34Cmd; // cmd to enable V.34 support in Class 1.0 146 fxStr class1NFLOCmd; // cmd to setup no flow control 147 fxStr class1SFLOCmd; // cmd to setup software flow control 148 fxStr class1HFLOCmd; // cmd to setup hardware flow control 149 fxStr class1PPMWaitCmd; // cmd to stop and wait prior to PPM 150 fxStr class1ResponseWaitCmd; // cmd to wait prior to TCF response 151 fxStr class1RMQueryCmd; // cmd to query modem for receive demodulators 152 fxStr class1TCFWaitCmd; // cmd to stop and wait prior to TCF 153 fxStr class1TMQueryCmd; // cmd to query modem for transmit modulators 154 fxStr class1EOPWaitCmd; // cmd to stop and wait prior to EOP 155 fxStr class1SwitchingCmd; // after recv HDLC and before sending 156 fxStr class1MsgRecvHackCmd; // cmd to avoid +FCERROR before image 157 fxStr class1TCFRecvHackCmd; // cmd to avoid +FCERROR before TCF 158 u_int class1TCFRecvTimeout; // timeout receiving TCF 159 u_int class1RecvAbortOK; // if non-zero, OK sent after recv abort 160 u_int class1RMPersistence; // how many times to persist through +FCERROR 161 u_int class1HookSensitivity; // how many times to persist through on-hook detections 162 u_int class1Resolutions; // resolutions support 163 u_int class1FrameOverhead; // overhead bytes in received frames 164 u_int class1RecvIdentTimer; // timeout receiving initial identity 165 u_int class1TCFMaxNonZero; // non-zero threshold for TCF check 166 u_int class1TCFMinRun; // min length of zero run for TCF check 167 u_int class1TCFMinRunECMMod; // modify min length in ECM by this factor 168 u_int class1TMConnectDelay; // delay (ms) after +FTM CONNECT 169 u_int class1ECMFrameSize; // ECM frame size for transmission 170 u_int class1PageLengthSupport;// page length support 171 u_int class1PageWidthSupport; // page width support 172 bool class1GreyJPEGSupport; // Greyscale JPEG support 173 bool class1ColorJPEGSupport; // Full-color JPEG support 174 bool class1ECMSupport; // support T.30-A ECM 175 bool class1MRSupport; // support 2-D MR 176 bool class1MMRSupport; // support 2-D MMR 177 bool class1PersistentECM; // continue to correct 178 bool class1ValidateV21Frames;// check received FCS values in V.21 179 bool class1ModemHasDLEBug; // modem doesn't double-up DLEs in V.21 180 bool class1HasRHConnectBug; // modem reports CONNECT after +FRH=3 to non-V.21-HDLC data 181 // for class 2 and 2.0: 182 fxStr class2Cmd; // cmd for setting Class 2/2.0 183 fxStr class2DCCQueryCmd; // cmd to query modem capabilities 184 fxStr class2CQQueryCmd; // cmd to query copy quality checking 185 fxStr class2BORCmd; // cmd to set bit order 186 fxStr class2DisableV17Cmd; // cmd to disable V.17 support 187 fxStr class2RELCmd; // cmd to enable byte-aligned EOL 188 fxStr class2CQCmd; // cmd to setup copy quality checking 189 fxStr class2AbortCmd; // cmd to abort a session 190 fxStr class2TBCCmd; // cmd to enable stream mode 191 fxStr class2CRCmd; // cmd to enable receive capability 192 fxStr class2PHCTOCmd; // cmd to set Phase C timeout parameter 193 fxStr class2BUGCmd; // cmd to enable HDLC frame tracing 194 fxStr class2LIDCmd; // cmd to set local identifier string 195 fxStr class2DCCCmd; // cmd to set modem capabilities 196 fxStr class2DISCmd; // cmd to set session parameters 197 fxStr class2DDISCmd; // cmd to set ses. params. before dial 198 fxStr class2CIGCmd; // cmd to set polling identifier 199 fxStr class2SPLCmd; // cmd to set polling request 200 fxStr class2PTSCmd; // cmd to set page status 201 fxStr class2PTSQueryCmd; // cmd to query page status 202 fxStr class2NFLOCmd; // cmd to setup no flow control 203 fxStr class2SFLOCmd; // cmd to setup software flow control 204 fxStr class2HFLOCmd; // cmd to setup hardware flow control 205 fxStr class2MINSPCmd; // cmd to setup min transmit speed 206 fxStr class2RecvDataTrigger; // send to start recv 207 bool class2JPEGSupport; // use JPEG support as reported by the modem 208 bool class2XmitWaitForXON; // wait for XON before send 209 bool class2RTFCC; // real-time fax compression conversion 210 bool class2SendRTC; // append RTC to page data on transmit 211 // for class 2.0: 212 fxStr class2PIECmd; // cmd to set proc interrupt handling 213 fxStr class2NRCmd; // cmd to set status reporting 214 // for class T.class2: 215 fxStr class2APQueryCmd; // cmd to query address&polling caps. 216 fxStr class2APCmd; // cmd to setup address&polling caps. 217 ECMType class2ECMType; // ECM specification type to use 218 fxStr class2SACmd; // cmd to set subaddress 219 fxStr class2PACmd; // cmd to set selective polling address 220 fxStr class2PWCmd; // cmd to set password for transmit/poll 221 bool class2UseHex; // parse capabilities strings as hex 222 bool class2HexNSF; // parse nsf strings as hex 223 bool class2UseLineCount; // use the firmware decoder's line count 224 225 FlowControl flowControl; // DTE-DCE flow control method 226 BaudRate maxRate; // max DTE-DCE rate to try 227 u_int recvFillOrder; // bit order of recvd data 228 u_int sendFillOrder; // bit order of sent data 229 u_int frameFillOrder; // bit order of HDLC frames 230 u_int resetDelay; // delay (ms) after reseting modem 231 u_int dtrDropDelay; // delay (ms) after dropping DTR 232 u_int baudRateDelay; // delay (ms) after setting baud rate 233 u_int atCmdDelay; // delay (ms) between each AT cmd 234 u_int percentGoodLines; // required % of good lines in page 235 u_int maxConsecutiveBadLines; // max consecutive bad lines in page 236 u_int minAcceptedLineCount; // min accepted number of lines in page 237 u_int minSpeed; // minimum speed for fax transmits 238 bool softRTFCC; // real-time fax compression conversion (software) 239 bool waitForConnect; // modem sends multiple answer responses 240 fxStr tagLineFmt; // format string for tag lines 241 fxStr tagLineFontFile; // font file for imaging tag lines 242 fxStr tagLineCoverNumString; // format string for tagline cover page numbers 243 u_int recvDataFormat; // received facsimile data format 244 bool useJobTagLine; // Use Job tagline or use conf taglineformat 245 bool raiseATCmd; // whether or not to raise-case the AT commands 246 bool doPhaseCDebug; // Query modem during Phase C for debugging info. 247 248 RTNHandling rtnHandling; // RTN signal handling method 249 BadPageHandling badPageHandling; // bad page (received) handling method 250 JBIGSupport class1JBIGSupport; // monochrome JBIG support 251 bool saveUnconfirmedPages; // don't delete unconfirmed pages 252 bool countSkippedPages; // count (or nor) and notify skipped pages 253 254 fxStrArray playList; // List of files for ESC_PLAY 255 256 // Distinctive ring data as sequences of DRON/DROF intervals 257 struct { 258 int cadence[5]; // the ring cadence as a five-dimensional vector 259 double magsqrd; // magnitude of the vector squared 260 u_int type; // call type of voice, fax, or data 261 } distinctiveRings[5]; // up to 5 distinctive ring numbers 262 u_int NoDRings; // number of distinctive rings numbers found 263 264 virtual ~ModemConfig(); 265 266 void parseCallID(const char*, CallID&) const; 267 const fxStr& getFlowCmd(FlowControl) const; 268 void parseDR(const char*); 269 void processDRString(char*, const u_int); 270 }; 271 #endif /* _ModemConfig_ */ 272