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.

209 lines
7.7 KiB

  1. #ifndef __MBFTRECV_HPP__
  2. #define __MBFTRECV_HPP__
  3. class CMBFTFile;
  4. class MBFTReceiveSubEvent;
  5. class CT120ChannelList : public CList
  6. {
  7. DEFINE_CLIST_(CT120ChannelList, T120ChannelID)
  8. };
  9. class CRecvSubEventList : public CList
  10. {
  11. DEFINE_CLIST(CRecvSubEventList, MBFTReceiveSubEvent*)
  12. MBFTReceiveSubEvent * FindEquiv(MBFTReceiveSubEvent *);
  13. void Delete(MBFTReceiveSubEvent *);
  14. void DeleteAll(void);
  15. };
  16. class CChannelUidQueue : public CQueue
  17. {
  18. DEFINE_CQUEUE_(CChannelUidQueue, UINT_PTR)
  19. BOOL RemoveByChannelID(T120ChannelID nChannelID);
  20. UINT_PTR FindByChannelID(T120ChannelID nChannelID);
  21. };
  22. class MBFTPrivateReceive : public MBFTSession
  23. {
  24. public:
  25. enum MBFTPrivateReceiveState
  26. {
  27. EnumIdleNotInitialized,
  28. EnumIdleInitialized,
  29. EnumInitializationFailed,
  30. EnumWaitJoinControlChannel,
  31. EnumWaitRequestJoinControl,
  32. EnumWaitRequestControlConvene,
  33. EnumWaitRequestDataConvene,
  34. EnumWaitAdmitControlChannelIndication,
  35. EnumWaitAdmitDataChannelIndication,
  36. EnumWaitSendChannelResponsePDU,
  37. EnumWaitUserConfirmation,
  38. EnumWaitSendFileAcceptPDU,
  39. EnumWaitSendFileRejectPDU,
  40. EnumWaitFileOfferPDU,
  41. EnumWaitFileStartPDU,
  42. EnumWaitFileDataPDU,
  43. EnumWaitSendFileEndAcknowledgePDU,
  44. EnumWaitSendChannelLeavePDU,
  45. EnumWaitJoinDataChannel,
  46. EnumWaitRejoinDataChannel,
  47. EnumWaitRequestJoinData,
  48. EnumWaitAdmitControlChannel,
  49. EnumWaitChannelDisband,
  50. EnumWaitForTermination
  51. };
  52. MBFTPrivateReceive(LPMBFTENGINE, MBFTFILEHANDLE, T120ChannelID chidControl, T120ChannelID chidData);
  53. ~MBFTPrivateReceive(void);
  54. BOOL OnMCSChannelJoinConfirm(T120ChannelID, BOOL bSuccess);
  55. BOOL OnMCSChannelAdmitIndication(T120ChannelID, T120UserID uidManager);
  56. BOOL OnMCSChannelExpelIndication(T120ChannelID, Reason);
  57. virtual BOOL OnReceivedFileOfferPDU(T120ChannelID, T120Priority, T120UserID uidSender, T120NodeID uidNode, LPFILEOFFERPDU lpNewPDU, BOOL IsUniformSendData);
  58. BOOL OnReceivedFileStartPDU(T120ChannelID, T120Priority, T120UserID uidSender, LPFILESTARTPDU lpNewPDU, BOOL IsUniformSendData);
  59. BOOL OnReceivedFileDataPDU(T120ChannelID, T120Priority, T120UserID uidSender, LPFILEDATAPDU lpNewPDU, BOOL IsUniformSendData);
  60. BOOL OnReceivedFileErrorPDU(T120ChannelID, T120Priority, T120UserID uidSender, LPFILEERRORPDU lpNewPDU, BOOL IsUniformSendData);
  61. void OnPeerDeletedNotification(CPeerData * lpPeerData);
  62. void OnControlNotification(MBFTFILEHANDLE hFile, FileTransferControlMsg::FileTransferControl iControlCommand, LPCSTR lpszDirectory, LPCSTR lpszFileName);
  63. void DoStateMachine(void);
  64. void UnInitialize(BOOL bIsShutDown = FALSE);
  65. protected:
  66. T120UserID m_LocalMBFTUserID;
  67. T120ChannelID m_PrivateMBFTControlChannel;
  68. CT120ChannelList m_PrivateMBFTDataChannelList;
  69. T120ChannelID m_PrivateMBFTDataChannel;
  70. T120UserID m_MBFTControlSenderID;
  71. T120UserID m_MBFTDataSenderID;
  72. T120UserID m_ProshareSenderID;
  73. MBFTFILEHANDLE m_CurrentAcceptHandle; // ???
  74. MBFTFILEHANDLE m_CurrentRejectHandle; // ???
  75. MBFTFILEHANDLE m_CurrentFileEndHandle;
  76. MBFTPrivateReceiveState m_State;
  77. MBFTPrivateReceiveState m_PreviousRejectState;
  78. BOOL m_bProshareTransfer;
  79. CRecvSubEventList m_ReceiveList;
  80. MBFTReceiveSubEvent *m_CurrentReceiveEvent;
  81. BOOL m_JoinedToDataChannel;
  82. BOOL m_bOKToLeaveDataChannel;
  83. BOOL m_bEventEndPosted;
  84. CChannelUidQueue m_AdmittedChannelQueue;
  85. void JoinControlChannel(void);
  86. void JoinDataChannel(void);
  87. void LeaveDataChannel(void);
  88. void SendChannelResponsePDU(void);
  89. BOOL SendFileAcceptPDU(MBFTFILEHANDLE iFileHandle = 0);
  90. void SendFileRejectPDU(MBFTFILEHANDLE iFileHandle = 0);
  91. void SendFileEndAcknowledgePDU(MBFTFILEHANDLE iFileHandle = 0);
  92. void SendChannelLeavePDU(void);
  93. void DeleteReceiveEvent(MBFTReceiveSubEvent * lpReceive,BOOL bNotifyUser);
  94. void TerminateReceiveSession(void);
  95. void ReportError(MBFTReceiveSubEvent * lpReceiveEvent,
  96. int iErrorType,
  97. int iErrorCode,
  98. BOOL bIsLocalError = TRUE,
  99. T120UserID SenderID = 0,
  100. const char* pFileName = NULL,
  101. ULONG lFileSize = 0);
  102. void ReportReceiverError(MBFTReceiveSubEvent * lpReceiveEvent,
  103. int iErrorType,
  104. int iErrorCode,
  105. MBFTFILEHANDLE iFileHandle = 0);
  106. void DeleteNotificationMessages(MBFT_NOTIFICATION iNotificationType);
  107. int DecompressAndWrite(MBFTReceiveSubEvent * lpReceiveEvent,
  108. LPCSTR lpBuffer,LONG BufferLength,LPINT lpDecompressedSize);
  109. };
  110. #ifdef USE_BROADCAST_RECEIVE
  111. class MBFTBroadcastReceive : public MBFTPrivateReceive
  112. {
  113. private:
  114. T120UserID m_SenderID;
  115. MBFTFILEHANDLE m_FileHandle;
  116. public:
  117. MBFTBroadcastReceive(LPMBFTENGINE lpParentEngine,
  118. MBFTEVENTHANDLE EventHandle,
  119. T120ChannelID wControlChannel,
  120. T120ChannelID wDataChannel,
  121. T120UserID SenderID,
  122. MBFTFILEHANDLE FileHandle);
  123. BOOL OnMCSChannelJoinConfirm(T120ChannelID, BOOL bSuccess);
  124. BOOL OnReceivedFileOfferPDU(T120ChannelID, T120Priority, T120UserID uidSender, T120NodeID uidNode, LPFILEOFFERPDU lpNewPDU, BOOL IsUniformSendData);
  125. BOOL OnReceivedFileStartPDU(T120ChannelID, T120Priority, T120UserID uidSender, LPFILESTARTPDU lpNewPDU, BOOL IsUniformSendData);
  126. BOOL OnReceivedFileDataPDU(T120ChannelID, T120Priority, T120UserID, LPFILEDATAPDU lpNewPDU, BOOL IsUniformSendData);
  127. void OnControlNotification(MBFTFILEHANDLE hFile, FileTransferControlMsg::FileTransferControl iControlCommand, LPCSTR lpszDirectory, LPCSTR lpszFileName);
  128. void OnPeerDeletedNotification(CPeerData * lpPeerData);
  129. void DoStateMachine(void);
  130. void UnInitialize(BOOL bIsShutDown = FALSE);
  131. };
  132. #endif // USE_BROADCAST_RECEIVE
  133. typedef class MBFTPrivateReceive FAR * LPMBFTPRIVATESUBSESSIONRECEIVE;
  134. class MBFTReceiveSubEvent
  135. {
  136. private:
  137. friend class MBFTPrivateReceive;
  138. #ifdef USE_BROADCAST_RECEIVE
  139. friend class MBFTBroadcastReceive;
  140. #endif // USE_BROADCAST_RECEIVE
  141. MBFTPrivateReceive::MBFTPrivateReceiveState m_State;
  142. BOOL m_bIsBroadcast;
  143. MBFTFILEHANDLE m_hFile;
  144. ULONG m_FileSize;
  145. ULONG m_TotalBytesReceived;
  146. ULONG m_cbRecvLastNotify;
  147. T120UserID m_SenderID;
  148. CMBFTFile *m_lpFile;
  149. BOOL m_UserAccepted;
  150. BOOL m_bFileCompressed;
  151. BOOL m_bEOFAcknowledge;
  152. time_t m_FileDateTime;
  153. LPVOID m_lpV42bisPointer;
  154. char m_szFileName[_MAX_FNAME];
  155. char m_szFileDirectory[_MAX_PATH];
  156. public:
  157. MBFTReceiveSubEvent(MBFTFILEHANDLE FileHandle,
  158. LONG FileSize,
  159. LPCSTR lpszFileName,
  160. time_t FileDateTime,
  161. T120UserID SenderID,
  162. BOOL bIsBroadcast,
  163. BOOL bIsCompressed,
  164. BOOL bEOFAcknowledge);
  165. ~MBFTReceiveSubEvent(void);
  166. BOOL Init(void);
  167. BOOL IsEqual(MBFTReceiveSubEvent *lpObject);
  168. void InitV42DeCompression(int v42bisP1,int v42bisP2);
  169. };
  170. #endif //__MBFTRECV_HPP__
  171.