Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
9.1 KiB

  1. /*===========================================================================*/
  2. /* Copyright (c) 1987 - 1988, Future Soft Engineering, Inc. */
  3. /* Houston, Texas */
  4. /*===========================================================================*/
  5. #define NOGDICAPMASKS TRUE
  6. #define NOVIRTUALKEYCODES TRUE
  7. #define NOICONS TRUE
  8. #define NOKEYSTATES TRUE
  9. #define NOSYSCOMMANDS TRUE
  10. #define NOATOM TRUE
  11. #define NOCLIPBOARD TRUE
  12. #define NODRAWTEXT TRUE
  13. #define NOMINMAX TRUE
  14. #define NOOPENFILE TRUE
  15. #define NOSCROLL TRUE
  16. #define NOHELP TRUE
  17. #define NOPROFILER TRUE
  18. #define NODEFERWINDOWPOS TRUE
  19. #define NOPEN TRUE
  20. #define NO_TASK_DEFINES TRUE
  21. #define NOLSTRING TRUE
  22. #define WIN31
  23. #define USECOMM
  24. #include <windows.h>
  25. #include "port1632.h"
  26. #include "dcrc.h"
  27. #include "dynacomm.h"
  28. #include "task.h"
  29. #include "connect.h"
  30. /*--------------------- >>> Local Global Declarations <<< -------------------*/
  31. static INT retryCnt;
  32. static INT timeOutSec; /* mbbx 2.00: display time remaining */
  33. /*---------------------------------------------------------------------------*/
  34. /* dbDialing() - Dialing dialog box message proccessing. */
  35. /*---------------------------------------------------------------------------*/
  36. #define MAX_DIAL_STRLEN 21 /* mbbx 2.00: CUA */
  37. INT_PTR APIENTRY dbDialing(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  38. {
  39. CHAR tmp1[TMPNSTR], tmp2[TMPNSTR];
  40. COMSTAT serInfo;
  41. switch(message)
  42. {
  43. case WM_INITDIALOG:
  44. initDlgPos(hDlg); /* mbbx 2.00: CUA... */
  45. strcpy(tmp1, trmParams.phone);
  46. if(strlen(tmp1) > MAX_DIAL_STRLEN)
  47. strcpy(tmp1+(MAX_DIAL_STRLEN-3), "...");
  48. SetDlgItemText(hDlg, IDDIALING, tmp1);
  49. retryCnt = 0;
  50. itemHit = -1;
  51. if(!SetTimer(hDlg, -1, 128, NULL)) /* rjs bugs 006 */
  52. {
  53. LoadString(hInst, STRERRNOTIMERS, tmp1, TMPNSTR);
  54. MessageBox(hDlg, tmp1, NULL, MB_OK | MB_ICONEXCLAMATION);
  55. break;
  56. }
  57. return(TRUE);
  58. case WM_TIMER:
  59. if(itemHit == -1)
  60. {
  61. sprintf(tmp1, "%u", timeOutSec = trmParams.dlyRetry); /* mbbx 2.00: time remaining... */
  62. SetDlgItemText(hDlg, IDDIALTIME, tmp1);
  63. if(!sPortErr) /* rjs bug2 */
  64. {
  65. termSendCmd(trmParams.originate, strlen(trmParams.originate), TRUE); /* mbbx 2.01.19 ... */
  66. getMdmResult();
  67. termSendCmd(trmParams.dialPrefix, strlen(trmParams.dialPrefix), FALSE);
  68. strcpy(tmp1, trmParams.phone); /* mbbx 2.01.18 ... */
  69. strcpy(tmp1+strlen(tmp1), trmParams.phone2);
  70. termSendCmd(tmp1, strlen(tmp1), 0x0080 | FALSE);
  71. termSendCmd(trmParams.dialSuffix, strlen(trmParams.dialSuffix), TRUE);
  72. }
  73. else
  74. modemReset();
  75. dialStart = tickCount();
  76. itemHit = 0;
  77. }
  78. else if(itemHit == 0)
  79. {
  80. updateTimer();
  81. if(trmParams.fCarrier) /* mbbx 1.10: CUA... */
  82. mdmConnect();
  83. else if(modemBytes())
  84. {
  85. getMdmResult();
  86. mdmOnLine = (mdmValid && (mdmResult[2] == 'C'));
  87. // mdmOnLine = TRUE;
  88. }
  89. if(mdmOnLine)
  90. {
  91. getMdmResult();
  92. if(trmParams.flgSignal)
  93. {
  94. sysBeep();
  95. sysBeep(); /* mbbx 2.00: more noise for signal... */
  96. sysBeep();
  97. }
  98. timerAction(TRUE, TRUE); /* mbbx 1.03 */
  99. break;
  100. }
  101. if((tickCount() - dialStart) > (DWORD)((trmParams.dlyRetry > 30) ? (trmParams.dlyRetry * 60) : (30 * 60)))
  102. {
  103. if((trmParams.flgRetry) && ((retryCnt < trmParams.cntRetry) || (trmParams.cntRetry == 255)))
  104. {
  105. LoadString(hInst, STR_RETRYCOUNT, tmp1, TMPNSTR);
  106. sprintf(tmp2, tmp1, ++retryCnt);
  107. SetDlgItemText(hDlg, IDDIALRETRY, tmp2);
  108. if(trmParams.flgSignal) /* mbbx 2.00: redial beep optional... */
  109. sysBeep();
  110. itemHit = -1;
  111. }
  112. else
  113. {
  114. if(!sPortErr) /* rjs bug2 */
  115. modemWr(CR);
  116. break;
  117. }
  118. }
  119. else if((INT)(trmParams.dlyRetry - ((tickCount() - dialStart) / 60)) != timeOutSec)
  120. {
  121. sprintf(tmp1, "%u", timeOutSec = trmParams.dlyRetry - ((tickCount() - dialStart) / 60));
  122. SetDlgItemText(hDlg, IDDIALTIME, tmp1);
  123. }
  124. }
  125. return(TRUE);
  126. case WM_COMMAND: /* mbbx 2.00: only one control... */
  127. modemWr(CR);
  128. break;
  129. default:
  130. return(FALSE);
  131. }
  132. KillTimer(hDlg, -1); /* mbbx 2.00: eliminate statics... */
  133. EndDialog(hDlg, TRUE);
  134. return(TRUE);
  135. }
  136. /*---------------------------------------------------------------------------*/
  137. /* dialPhone() - [scf] */
  138. /*---------------------------------------------------------------------------*/
  139. VOID dialPhone()
  140. {
  141. BYTE tmp1[TMPNSTR];
  142. DCB dcb;
  143. if(trmParams.comDevRef == ITMDLLCONNECT) /* slc nova 031 */
  144. {
  145. DLL_ConnectConnector(ghCCB, TRUE);
  146. return;
  147. }
  148. if(*trmParams.phone == 0) /* Don't dial if no phone no. */
  149. doSettings(IDDBPHON, dbPhon);
  150. if(*trmParams.phone == 0) /* Don't dial if no phone no. */
  151. return;
  152. while(modemBytes())
  153. rdModem(FALSE);
  154. offCursor();
  155. if(mdmOnLine) /* Tell user to hang up */
  156. {
  157. LoadString(hInst, STR_HANGUP, tmp1, TMPNSTR);
  158. itemHit = testBox(NULL, -(MB_OK | MB_ICONHAND), STR_ERRCAPTION, tmp1);
  159. onCursor();
  160. return;
  161. }
  162. if(trmParams.flgRetry )
  163. trmParams.cntRetry = 255;
  164. dialing = TRUE;
  165. DialogBox(hInst, MAKEINTRESOURCE(IDDBDIALING), GetFocus(), dbDialing);
  166. dialing = FALSE;
  167. onCursor();
  168. trmParams.cntRetry = 0;
  169. }
  170. /*---------------------------------------------------------------------------*/
  171. /* hangUpPhone() - [scf] */
  172. /*---------------------------------------------------------------------------*/
  173. VOID hangUpPhone()
  174. {
  175. if(trmParams.comDevRef == ITMDLLCONNECT) /* slc nova 031 */
  176. {
  177. DLL_DisconnectConnector(ghCCB);
  178. return;
  179. }
  180. SetCursor(LoadCursor(NULL, IDC_WAIT)); /* mbbx 1.10: ala jtf */
  181. delay(33, NULL); /* mbbx 0.62: formerly 66 ticks */
  182. termSendCmd(trmParams.hangSuffix, strlen(trmParams.hangSuffix), 0x0040 | TRUE); /* mbbx 2.01.19 ... */
  183. getMdmResult();
  184. if(trmParams.fCarrier) /* mbbx 1.10: carrier... */
  185. mdmConnect();
  186. else
  187. mdmOnLine = FALSE;
  188. modemReset(); /* mbbx: isolate COM */
  189. timerAction(FALSE, FALSE); /* mbbx 1.03 */
  190. SetCursor(LoadCursor(NULL, IDC_ARROW)); /* mbbx 1.10: ala jtf */
  191. }
  192. /*---------------------------------------------------------------------------*/
  193. /* getMdmResult() - [mbb] */
  194. /*---------------------------------------------------------------------------*/
  195. VOID getMdmResult()
  196. {
  197. LONG begTime;
  198. begTime = tickCount();
  199. *mdmResult = 0;
  200. mdmValid = FALSE;
  201. repeat
  202. {
  203. rdModem(TRUE);
  204. if(!dialing)
  205. idleProcess();
  206. }
  207. until(mdmValid || ((tickCount() - begTime) > 90));
  208. if(!mdmValid && (*mdmResult >= 2))
  209. mdmValid = TRUE; /* mbbx: override timeout !!! */
  210. }
  211. /*---------------------------------------------------------------------------*/
  212. /* termSendCmd() - [mbb] */
  213. /*---------------------------------------------------------------------------*/
  214. /* convert ==> ABCDEFGHIJKLMNOPQRSTUVWXYZ */
  215. #define PHONE_CHARS "2223334445556667-77888999-"
  216. BOOL termSendCmd(BYTE * str, int nBytes, WORD wFlags)
  217. {
  218. INT ndx;
  219. if(wFlags & 0x0040) /* get modem's attention */
  220. {
  221. if(nBytes == 0)
  222. return(TRUE);
  223. termSendCmd(trmParams.hangPrefix, strlen(trmParams.hangPrefix), (3 << 8) | FALSE);
  224. delay(66, NULL);
  225. getMdmResult();
  226. }
  227. for(ndx = 0; ndx < nBytes; ndx += 1)
  228. {
  229. if(wFlags & 0x0080) /* xlate phone string */
  230. {
  231. if((str[ndx] >= 'A') && (str[ndx] <= 'Z'))
  232. str[ndx] = PHONE_CHARS[str[ndx] - 'A'];
  233. else if((str[ndx] >= 'a') && (str[ndx] <= 'z'))
  234. str[ndx] = PHONE_CHARS[str[ndx] - 'a'];
  235. }
  236. modemWr(str[ndx]);
  237. if((wFlags & 0xFF00) > 0)
  238. delay(((wFlags >> 8) & 0x00FF), NULL);
  239. if(!dialing) /* mbbx 2.01.19: why is this needed ??? */
  240. idleProcess();
  241. }
  242. if(wFlags & 0x0001) /* send CR */
  243. modemWr(CR);
  244. if(wFlags & 0x0002) /* clear modem response */
  245. getMdmResult();
  246. return(TRUE);
  247. }