Leaked source code of windows server 2003
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.

170 lines
4.5 KiB

  1. #define USE_DEBUG_CONTEXT DEBUG_CONTEXT_T30_MAIN
  2. #include "prep.h"
  3. #include "t30.h"
  4. #include "efaxcb.h"
  5. #include "debug.h"
  6. #include "glbproto.h"
  7. #include "psslog.h"
  8. #define FILE_ID FILE_ID_T30MAIN
  9. BOOL T30Cl1Rx(PThrdGlbl pTG)
  10. {
  11. USHORT uRet1;
  12. BOOL RetCode = FALSE;
  13. DEBUG_FUNCTION_NAME(_T("T30Cl1Rx - Answering"));
  14. PSSLogEntry(PSS_MSG, 0, "Phase A - Call establishment");
  15. SignalStatusChange(pTG, FS_ANSWERED);
  16. // first get SEND_CAPS (before answering)
  17. if (!ProtGetBC(pTG, SEND_CAPS))
  18. {
  19. uRet1 = T30_CALLFAIL;
  20. goto done;
  21. }
  22. PSSLogEntry(PSS_MSG, 1, "Answering...");
  23. if (NCULink(pTG, NCULINK_RX) != CONNECT_OK)
  24. {
  25. uRet1 = T30_ANSWERFAIL;
  26. goto done;
  27. }
  28. // Protocol Dump
  29. RestartDump(pTG);
  30. uRet1 = T30MainBody(pTG, FALSE);
  31. // t-jonb: If we've already called PutRecvBuf(RECV_STARTPAGE), but not
  32. // PutRecvBuf(RECV_ENDPAGE / DOC), then InFileHandleNeedsBeClosed==1, meaning
  33. // there's a .RX file that hasn't been copied to the .TIF file. Since the
  34. // call was disconnected, there will be no chance to send RTN. Therefore, we call
  35. // PutRecvBuf(RECV_ENDDOC_FORCESAVE) to keep the partial page and tell
  36. // rx_thrd to terminate.
  37. if (uRet1==T30_CALLFAIL && pTG->InFileHandleNeedsBeClosed)
  38. {
  39. if (! FlushFileBuffers (pTG->InFileHandle ) )
  40. {
  41. DebugPrintEx(DEBUG_WRN, "FlushFileBuffers FAILED LE=%lx", GetLastError());
  42. // Continue to save what we have
  43. }
  44. pTG->BytesIn = pTG->BytesInNotFlushed;
  45. ICommPutRecvBuf(pTG, NULL, RECV_ENDDOC_FORCESAVE);
  46. }
  47. // Protocol Dump
  48. PrintDump(pTG);
  49. done:
  50. if (uRet1==T30_CALLDONE)
  51. {
  52. SignalStatusChange(pTG, FS_COMPLETED);
  53. RetCode = TRUE;
  54. DebugPrintEx(DEBUG_MSG,"SUCCESSFUL RECV");
  55. }
  56. else if (pTG->StatusId == FS_NOT_FAX_CALL)
  57. {
  58. RetCode = FALSE;
  59. DebugPrintEx( DEBUG_ERR, "DATA CALL attempt HANDOVER (0x%04x)", uRet1);
  60. }
  61. else
  62. {
  63. if (!pTG->fFatalErrorWasSignaled)
  64. {
  65. pTG->fFatalErrorWasSignaled = 1;
  66. SignalStatusChange(pTG, FS_FATAL_ERROR);
  67. }
  68. RetCode = FALSE;
  69. DebugPrintEx( DEBUG_ERR, "FAILED RECV (0x%04x)", uRet1);
  70. }
  71. // Dont do this!! The Modem driver queues up commands for later execution, so the
  72. // DCN we just sent is probably in the queue. Doing a sync here causes that send
  73. // to be aborted, so the recvr never gets a DCN and thinks teh recv failed. This
  74. // is bug#6803
  75. NCULink(pTG, NCULINK_HANGUP);
  76. return (RetCode);
  77. }
  78. BOOL T30Cl1Tx(PThrdGlbl pTG,LPSTR szPhone)
  79. {
  80. USHORT uRet1;
  81. BOOL RetCode = FALSE;
  82. DEBUG_FUNCTION_NAME(_T("T30Cl1Tx"));
  83. PSSLogEntry(PSS_MSG, 0, "Phase A - Call establishment");
  84. DebugPrintEx(DEBUG_MSG,"Going to change the state to FS_DIALING");
  85. SignalStatusChange(pTG, FS_DIALING);
  86. if( pTG->fAbortRequested)
  87. {
  88. uRet1 = T30_CALLFAIL;
  89. goto done;
  90. }
  91. if (szPhone)
  92. {
  93. PSSLogEntry(PSS_MSG, 1, "Dialing...");
  94. DebugPrintEx(DEBUG_MSG, "Enter into NCUDial");
  95. if (NCUDial(pTG, szPhone) != CONNECT_OK)
  96. {
  97. DebugPrintEx(DEBUG_ERR,"Problem at NCUDial. Jump to done");
  98. uRet1 = T30_DIALFAIL;
  99. goto done;
  100. }
  101. }
  102. // Protocol Dump
  103. RestartDump(pTG); // Reset the offsets
  104. DebugPrintEx(DEBUG_MSG,"Enter to main body");
  105. uRet1 = T30MainBody(pTG, TRUE);
  106. // Protocol Dump
  107. PrintDump(pTG);
  108. done:
  109. if (uRet1==T30_CALLDONE)
  110. {
  111. SignalStatusChange(pTG, FS_COMPLETED);
  112. RetCode = TRUE;
  113. DebugPrintEx(DEBUG_MSG,"SUCCESSFUL SEND");
  114. }
  115. else
  116. {
  117. if (!pTG->fFatalErrorWasSignaled)
  118. {
  119. pTG->fFatalErrorWasSignaled = 1;
  120. SignalStatusChange(pTG, FS_FATAL_ERROR);
  121. }
  122. RetCode = FALSE;
  123. DebugPrintEx( DEBUG_ERR, "FAILED SEND (0x%04x)", uRet1);
  124. }
  125. // Dont do this!! The Modem driver queues up commands for later execution, so the
  126. // DCN we just sent is probably in the queue. Doing a sync here causes that send
  127. // to be aborted, so the recvr never gets a DCN and thinks teh recv failed. This
  128. // is bug#6803
  129. DebugPrintEx(DEBUG_MSG,"Calling to NCULink to do NCULINK_HANGUP");
  130. NCULink(pTG, NCULINK_HANGUP);
  131. return (RetCode);
  132. }