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.

146 lines
4.2 KiB

  1. #define PP_PRE_SWITCH 0x00000001
  2. #define PP_POST_SWITCH 0x00000002
  3. #define PP_DELETE 0x00000004
  4. #define PP_PRE_SWITCH 0x00000001
  5. #define PP_POST_SWITCH 0x00000002
  6. #define PP_DELETE 0x00000004
  7. #define DATASNIFSIZEDOCFILE_MIN 2048
  8. class CMimeHandlerTest1 : public CBaseProtocol
  9. //: public IOInetProtocol
  10. , public IOInetProtocolSink
  11. {
  12. public:
  13. // IUnknown methods
  14. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  15. STDMETHODIMP_(ULONG) AddRef(void);
  16. STDMETHODIMP_(ULONG) Release(void);
  17. //
  18. //IOInetProtocol methods
  19. STDMETHODIMP Start(LPCWSTR szUrl,IOInetProtocolSink *pProtSink,
  20. IOInetBindInfo *pOIBindInfo,DWORD grfSTI,DWORD dwReserved);
  21. STDMETHODIMP Continue(PROTOCOLDATA *pStateInfo);
  22. STDMETHODIMP Abort(HRESULT hrReason,DWORD dwOptions);
  23. STDMETHODIMP Terminate(DWORD dwOptions);
  24. STDMETHODIMP Suspend();
  25. STDMETHODIMP Resume();
  26. STDMETHODIMP Read(void *pv,ULONG cb,ULONG *pcbRead);
  27. STDMETHODIMP Seek(LARGE_INTEGER dlibMove,DWORD dwOrigin,
  28. ULARGE_INTEGER *plibNewPosition);
  29. STDMETHODIMP LockRequest(DWORD dwOptions);
  30. STDMETHODIMP UnlockRequest();
  31. //
  32. // IOInetProtocolSink methods
  33. STDMETHODIMP Switch(PROTOCOLDATA *pStateInfo);
  34. STDMETHODIMP ReportProgress(ULONG ulStatusCode, LPCWSTR szStatusText);
  35. STDMETHODIMP ReportData( DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax);
  36. STDMETHODIMP ReportResult(HRESULT hrResult, DWORD dwError, LPCWSTR wzResult);
  37. public:
  38. STDMETHODIMP Create(CMimeHandlerTest1 **ppCProtHandler);
  39. STDMETHODIMP OnDataReceived(DWORD *pgrfBSC, DWORD *pcbBytesAvailable, DWORD *pdwTotalSize);
  40. void SetProtSink(IOInetProtocolSink *pProtSnk)
  41. {
  42. TransAssert((pProtSnk));
  43. /*
  44. if (pProtSnk)
  45. {
  46. pProtSnk->AddRef();
  47. }
  48. if (_pProtSnk)
  49. {
  50. _pProtSnk->Release();
  51. }
  52. */
  53. _pProtSnk = pProtSnk;
  54. }
  55. void SetDelegate(IUnknown *pUnk, IOInetProtocolSink *pProtSnk)
  56. {
  57. TransAssert((pProtSnk && pUnk));
  58. /*
  59. if (pProtSnk)
  60. {
  61. pProtSnk->AddRef();
  62. }
  63. if (pUnk)
  64. {
  65. pUnk->AddRef();
  66. }
  67. if (_pProtSnk)
  68. {
  69. _pProtSnk->Release();
  70. }
  71. if (_pUnk)
  72. {
  73. _pUnk->Release();
  74. }
  75. */
  76. _pProtSnk = pProtSnk;
  77. _pUnk = pUnk;
  78. }
  79. STDMETHODIMP Initialize(DWORD dwMode, DWORD dwOptions, IUnknown *pUnk, IOInetProtocol *pProt, IOInetProtocolSink *pProtSnk);
  80. CMimeHandlerTest1(REFCLSID rclsid, IUnknown *pUnkOuter, IUnknown **ppUnkInner);
  81. virtual ~CMimeHandlerTest1()
  82. {
  83. if (_pProt)
  84. {
  85. _pProt->Release();
  86. }
  87. if (_pProtSnk)
  88. {
  89. _pProtSnk->Release();
  90. }
  91. delete [] _pwzFileName;
  92. delete [] _pwzMimeSuggested;
  93. delete [] _pBuffer;
  94. }
  95. private:
  96. CRefCount _CRefs; // the total refcount of this object
  97. CMutexSem _mxs; // used in Read, Seek, Abort and package list in case of apartment threaded
  98. IUnknown *_pUnk;
  99. IOInetProtocol *_pProt; // the prot the filter reads from
  100. IOInetProtocolSink *_pProtSnk; // the prot report progress
  101. DWORD _dwOInetBdgFlags;
  102. DWORD _dwMode; //
  103. LPBYTE _pBuffer; // DNLD_BUFFER_SIZE size buffer
  104. ULONG _cbBufferSize;
  105. ULONG _cbTotalBytesRead;
  106. ULONG _cbBufferFilled; //how much of the buffer is in use
  107. //ULONG _cbDataSize;
  108. ULONG _cbDataSniffMin;
  109. ULONG _cbBytesReported; // how much was reported
  110. BOOL _fDocFile : 1;
  111. BOOL _fMimeVerified : 1;
  112. BOOL _fDelete : 1;
  113. LPWSTR _pwzFileName;
  114. LPWSTR _pwzMimeSuggested;
  115. };