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.

868 lines
24 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: Transact.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 12-04-95 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef _TRANSACT_HXX_
  18. #define _TRANSACT_HXX_
  19. #include <urlmon.hxx>
  20. #include <urlmki.h>
  21. #include "cbinding.hxx"
  22. #ifdef DBG
  23. #define AssertDo(a) (a)
  24. #else // !DEBUG
  25. #define ASSERTDATA
  26. #define AssertDo(a) (a)
  27. #define WITH_EXCEPTION
  28. #endif // DBG
  29. #ifdef unix
  30. #undef offsetof
  31. #endif /* unix */
  32. #define offsetof(s,m) ( (SIZE_T) &(((s *)0)->m) )
  33. #define GETPPARENT(pmemb, struc, membname) (\
  34. (struc*)(((char*)(pmemb))-offsetof(struc, membname)))
  35. //#define BREAK_ONERROR(hrBreak) if (FAILED(hrBreak)) { break; }
  36. #define DATASNIFSIZE_MIN 256
  37. #define DATASNIFSIZEDOCFILE_MIN 2048
  38. #define DATASNIFSIZEDOCFILE_MAX 4096
  39. class CTransactionMgr;
  40. class CTransPacket;
  41. class CTransaction;
  42. class CTransData;
  43. #define PI_FILTER_MODE_DATA 0x00000100
  44. class CTransactionMgr : public CLifePtr
  45. {
  46. public:
  47. CTransactionMgr();
  48. virtual ~CTransactionMgr();
  49. HRESULT AddTransaction(CTransaction *pCTrans);
  50. HRESULT RemoveTransaction(CTransaction *pCTrans);
  51. private:
  52. CTransaction *_pCTransFirst; // First in the linked list
  53. CTransaction *_pCTransLast; // First in the linked list
  54. };
  55. // These two structures are used to pass data from the inloader callbacks
  56. // to the wndproc of the hidden window in the main thread.
  57. class CTransPacket : public PROTOCOLDATA
  58. {
  59. public:
  60. CTransPacket(PROTOCOLDATA *pSI);
  61. CTransPacket(BINDSTATUS NMsg, HRESULT hrRet = NOERROR, LPCWSTR szStr = NULL, DWORD cbAvailable = 0, DWORD cbTotal = 0, DWORD dwResult = 0);
  62. ~CTransPacket();
  63. CTransPacket& operator=(const CTransPacket& CTPSrc);
  64. LPWSTR DupWStr(LPSTR szStr)
  65. {
  66. DWORD dwLen = strlen(szStr) + 1;
  67. LPWSTR wzStr = new WCHAR [dwLen];
  68. if (wzStr)
  69. {
  70. A2W(szStr, wzStr,dwLen);
  71. }
  72. return wzStr;
  73. }
  74. CTransPacket *GetNext()
  75. { return _pCTPNext; }
  76. void SetNext(CTransPacket *pCTP)
  77. { _pCTPNext = pCTP; }
  78. BINDSTATUS GetNotMsg()
  79. { return _NotMsg; }
  80. BOOL IsLastNotMsg()
  81. { return (_NotMsg == BINDSTATUS_ENDDOWNLOADDATA || _NotMsg == BINDSTATUS_ERROR); }
  82. BOOL IsAsyncNotMsg()
  83. { return (_NotMsg == BINDSTATUS_INTERNALASYNC); }
  84. //private:
  85. DWORD _dwCurrentSize;
  86. DWORD _dwTotalSize;
  87. DWORD _dwResult;
  88. LPWSTR _pwzStr;
  89. HRESULT _hrResult;
  90. private:
  91. BINDSTATUS _NotMsg;
  92. CTransPacket *_pCTPNext; //the next packet
  93. };
  94. typedef enum
  95. {
  96. TransSt_None = 0
  97. ,TransSt_Initialized = 1
  98. ,TransSt_OperationStarted = 2
  99. ,TransSt_OperationFinished = 3
  100. ,TransSt_Aborted = 4
  101. } TransactionState;
  102. typedef enum
  103. {
  104. TransData_None = 0
  105. ,TransData_Initialized = 1
  106. ,TransData_ReadingStarted = 2
  107. ,TransData_ReadingFinished = 3
  108. ,TransData_ProtoTerminated = 4
  109. } TransDataState;
  110. typedef enum
  111. {
  112. DataSink_Unknown = 0
  113. ,DataSink_StreamNoCopyData = 1
  114. ,DataSink_File
  115. ,DataSink_Storage
  116. ,DataSink_StreamOnFile
  117. ,DataSink_StreamBindToObject
  118. ,DataSink_GenericStream
  119. } DataSink;
  120. typedef enum
  121. {
  122. TS_None = 0
  123. ,TS_Prepared = 1
  124. ,TS_Completed = 2
  125. } ThreadSwitchState;
  126. #include "prothndl.hxx"
  127. class CTransaction : public IOInetProtocolSink
  128. ,public ITransProtocolSink
  129. ,public IOInetBindInfo
  130. ,public IServiceProvider
  131. ,public IAuthenticate
  132. ,public IOInetProtocol
  133. ,public IOInetPriority
  134. ,public IWrappedProtocol
  135. {
  136. public:
  137. // IUnknown methods
  138. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  139. STDMETHODIMP_(ULONG) AddRef(void);
  140. STDMETHODIMP_(ULONG) Release(void);
  141. //
  142. // IOInetProtocolSink
  143. //
  144. STDMETHODIMP Switch(
  145. PROTOCOLDATA *pStateInfo);
  146. STDMETHODIMP ReportProgress(
  147. ULONG ulStatusCode,
  148. LPCWSTR szStatusText);
  149. STDMETHODIMP ReportData(
  150. DWORD grfBSCF,
  151. ULONG ulProgress,
  152. ULONG ulProgressMax);
  153. STDMETHODIMP ReportResult(
  154. HRESULT hrResult,
  155. DWORD dwError,
  156. LPCWSTR wzResult);
  157. // ITransProtocolSink
  158. STDMETHODIMP QueryBindFlags (DWORD *pdwFlags);
  159. // IAuthenticate methods
  160. STDMETHODIMP Authenticate(
  161. HWND* phwnd,
  162. LPWSTR *pszUsername,
  163. LPWSTR *pszPassword);
  164. // IOInetBindInfo methods
  165. STDMETHODIMP GetBindInfo(
  166. DWORD *grfBINDF,
  167. BINDINFO * pbindinfo);
  168. STDMETHODIMP GetBindString(
  169. ULONG ulStringType,
  170. LPOLESTR *ppwzStr,
  171. ULONG cEl,
  172. ULONG *pcElFetched
  173. );
  174. // IServiceProvider
  175. STDMETHODIMP QueryService(REFGUID rsid, REFIID iid, void ** ppvObj);
  176. //
  177. // IOInetProtocol
  178. //
  179. STDMETHODIMP Start(
  180. LPCWSTR szUrl,
  181. IOInetProtocolSink *pProtSink,
  182. IOInetBindInfo *pOIBindInfo,
  183. DWORD grfSTI,
  184. DWORD_PTR dwReserved
  185. );
  186. STDMETHODIMP Continue(
  187. PROTOCOLDATA *pStateInfo
  188. );
  189. STDMETHODIMP Abort(
  190. HRESULT hrReason,
  191. DWORD dwOptions
  192. );
  193. STDMETHODIMP Terminate(
  194. DWORD dwOptions
  195. );
  196. STDMETHODIMP Suspend();
  197. STDMETHODIMP Resume();
  198. STDMETHODIMP Read(
  199. void *pv,
  200. ULONG cb,
  201. ULONG *pcbRead);
  202. STDMETHODIMP Seek(
  203. LARGE_INTEGER dlibMove,
  204. DWORD dwOrigin,
  205. ULARGE_INTEGER *plibNewPosition);
  206. STDMETHODIMP LockRequest(
  207. DWORD dwOptions);
  208. STDMETHODIMP UnlockRequest();
  209. // end IOInetProtocol
  210. // OInetPriority
  211. STDMETHODIMP SetPriority(LONG nPriority);
  212. STDMETHODIMP GetPriority(LONG * pnPriority);
  213. // IWrappedProtocol
  214. STDMETHODIMP GetWrapperCode(LONG * pnCode, DWORD_PTR dwReserved);
  215. static HRESULT Create(LPBC pBC, DWORD grfFlags, IUnknown *pUnkOuter, IUnknown **ppUnk, CTransaction **ppCTrans);
  216. LPWSTR GetUrl()
  217. {
  218. UrlMkAssert((_pwzUrl != NULL));
  219. return _pwzUrl;
  220. }
  221. LPWSTR GetRedirectUrl()
  222. {
  223. return _pwzRedirectUrl;
  224. }
  225. LPWSTR SetRedirectUrl(LPWSTR pwzStr)
  226. {
  227. TransAssert((_pProt));
  228. if (_pwzRedirectUrl)
  229. {
  230. delete [] _pwzRedirectUrl;
  231. }
  232. _pwzRedirectUrl = OLESTRDuplicate(pwzStr);
  233. return _pwzRedirectUrl;
  234. }
  235. REFCLSID GetProtocolClassID()
  236. {
  237. if (_pProt)
  238. {
  239. TransAssert((_clsidProtocol != CLSID_NULL ));
  240. return (REFCLSID)_clsidProtocol;
  241. }
  242. else
  243. {
  244. return CLSID_NULL;
  245. }
  246. }
  247. HRESULT QueryOption(DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf);
  248. HRESULT QueryInfo(DWORD dwOption, LPVOID pBuffer, DWORD *pcbBuf, DWORD *pdwFlags, DWORD *pdwReserved);
  249. //
  250. // manage clients interfaces
  251. //
  252. HRESULT AddClientOInet(IOInetProtocolSink *pOInetProtSink, IOInetBindInfo *pOInetBindInfo);
  253. HRESULT RemoveClientOInet();
  254. HRESULT RestartOperation(LPWSTR pwzURL, DWORD dwCase);
  255. HRESULT Redirect(LPWSTR pwzUrl);
  256. HRESULT CompleteOperation(BOOL fNested = FALSE);
  257. HRESULT MyPeekMessage(MSG *pMsg, HWND hwnd, UINT min, UINT max, WORD wFlag);
  258. // These two methods are used to implement the linked list of
  259. // internet transactions that is owned by the internet transaction list
  260. // object.
  261. CTransaction *GetNextTransaction()
  262. { return _pCTransNext; }
  263. void SetNextTransaction(CTransaction *pCTransNext)
  264. { _pCTransNext = pCTransNext; }
  265. STDMETHOD_(HWND, GetNotificationWnd)()
  266. {
  267. if (!_hwndNotify)
  268. {
  269. _hwndNotify = GetThreadNotificationWnd();
  270. }
  271. return _hwndNotify;
  272. }
  273. void SetNext(CTransaction *pCTransNext)
  274. { _pCTransNext = pCTransNext; }
  275. void SetBinding(CBinding *pCBdg)
  276. { _pClntProtSink = pCBdg; }
  277. HRESULT PrepareThreadTransfer();
  278. HRESULT ThreadTransfer();
  279. //TRIDENT BTS->BTO
  280. void SuspendDispatchingPackets(CTransPacket* pCTP);
  281. void ResumeDispatchingPackets();
  282. TransactionState GetState()
  283. { return _State; }
  284. TransactionState SetState(TransactionState newTS )
  285. {
  286. TransactionState tsTemp = _State;
  287. _State = newTS;
  288. return tsTemp;
  289. }
  290. OperationState GetOperationState()
  291. { return _OperationState; }
  292. OperationState SetOperationState(OperationState newTS)
  293. {
  294. OperationState tsTemp = _OperationState;
  295. _OperationState = newTS;
  296. return tsTemp;
  297. }
  298. ULONG BdgAddRef() { return _cBdgRefs++; }
  299. ULONG BdgRelease() { return --_cBdgRefs; }
  300. STDMETHOD (OnINetCallback)(BOOL fFromMsgQueue = FALSE);
  301. STDMETHOD (OnINetInternalCallback)(CTransPacket *pCTPIn);
  302. STDMETHOD (PreDispatch)();
  303. STDMETHOD (PostDispatch)();
  304. void AddCTransPacket(CTransPacket *pCTP, BOOL fTail = TRUE);
  305. CTransPacket *GetNextCTransPacket();
  306. CTransPacket *GetCurrentCTransPacket()
  307. {
  308. return _pCTPCur;
  309. }
  310. BOOL GotCTransPacket();
  311. STDMETHODIMP DispatchPacket(CTransPacket *pCTPIn);
  312. STDMETHODIMP DispatchReport(BINDSTATUS NotMsg, DWORD grfBSCF, DWORD dwCurrentSize, DWORD dwTotalSize, LPCWSTR pwzStr = 0, DWORD dwError = 0, HRESULT hresult = NOERROR);
  313. STDMETHODIMP OnDataReceived(DWORD *pgrfBSC, DWORD *pcbBytesAvailable, DWORD *pdwTotalSize);
  314. STDMETHODIMP OnAttach(LPCWSTR pwzURL, IOInetBindInfo *pOInetBindInfo, IOInetProtocolSink *pOInetBindSink, DWORD grfOptions, DWORD_PTR dwReserved);
  315. STDMETHODIMP LoadHandler(LPCWSTR pwzURL, COInetProt *pCProt, DWORD dwMode);
  316. HRESULT GetHResult()
  317. {
  318. return _hrResult;
  319. }
  320. BINDINFO *GetTransBindInfo();
  321. DWORD GetTransBindFlags()
  322. { return _grfBINDF; }
  323. void SetTransBindFlags(DWORD dwF)
  324. { _grfBINDF = dwF; }
  325. BOOL IsFreeThreaded()
  326. {
  327. return !(_dwOInetBdgFlags & OIBDG_APARTMENTTHREADED);
  328. }
  329. BOOL IsApartmentThread()
  330. {
  331. TransAssert((_dwThreadId != 0));
  332. return (_dwThreadId == GetCurrentThreadId());
  333. }
  334. DWORD GetBSCF()
  335. {
  336. return _grfBSCF;
  337. }
  338. VOID UpdateVerifiedMimeType(LPCWSTR pwzMime);
  339. public:
  340. class CPrivUnknown : public IUnknown
  341. {
  342. public:
  343. STDMETHOD(QueryInterface) ( REFIID riid, LPVOID FAR* ppvObj);
  344. STDMETHOD_(ULONG,AddRef) (void);
  345. STDMETHOD_(ULONG,Release) (void);
  346. ~CPrivUnknown() {}
  347. CPrivUnknown() : _CRefs() {}
  348. private:
  349. CRefCount _CRefs; // the total refcount of this object
  350. };
  351. friend class CPrivUnknown;
  352. CPrivUnknown _Unknown;
  353. IUnknown *_pUnkOuter;
  354. //
  355. // the pUnkInner of the aggregated APP (protocol)
  356. IUnknown *_pUnkInner; // the inner object if the protocol supports aggregation
  357. IUnknown *GetIUnkInner(BOOL fReleaseOuter = FALSE)
  358. {
  359. if (fReleaseOuter)
  360. {
  361. TransAssert((_CRefs > 0));
  362. _CRefs--;
  363. }
  364. return &_Unknown;
  365. }
  366. private:
  367. CTransaction(DWORD grfFlags, LPBYTE pByte, ULONG cbSizeBuffer, IUnknown *pUnkOuter);
  368. ~CTransaction();
  369. #if DBG==1
  370. WORD GetTotalPostedMsgId()
  371. {
  372. return _wTotalPostedMsg;
  373. }
  374. #else
  375. #define GetTotalPostedMsgId() 0
  376. #endif
  377. public:
  378. private:
  379. union
  380. {
  381. ULONG _flags;
  382. #ifndef unix
  383. struct
  384. {
  385. #endif /* !unix */
  386. unsigned _fAborted : 1;
  387. #ifndef unix
  388. };
  389. #endif /* !unix */
  390. };
  391. CRefCount _CRefs; // the total refcount of this object
  392. // File that the data is being downloaded to
  393. LPWSTR _pwzRedirectUrl;
  394. LPWSTR _pwzUrl;
  395. LPWSTR _pwzProtClsId;
  396. LONG _nPriority;
  397. // client pointer
  398. IOInetProtocolSink *_pClntProtSink;
  399. IOInetBindInfo *_pClntBindInfo;
  400. IBindCtx *_pBndCtx;
  401. CTransaction *_pCTransNext; // Next transaction in the linked list
  402. IOInetProtocol *_pProt;
  403. IWinInetHttpInfo *_pInetHttpInfo;
  404. IWinInetInfo *_pInetInfo;
  405. CLSID _clsidProtocol;
  406. DWORD _dwPacketsTotal;
  407. HWND _hwndNotify; // notification window for this
  408. CTransactionMgr *_pCTransMgr;
  409. TransactionState _State;
  410. OperationState _OperationState;
  411. ULONG _cBdgRefs;
  412. DWORD _dwThreadId;
  413. DWORD _dwProcessId;
  414. DWORD _grfBSCF;
  415. // data to handle the packets
  416. CTransPacket *_pCTPHead; // frist on
  417. CTransPacket *_pCTPTail; //
  418. CTransPacket *_pCTPCur; // the current one which gets dispatched
  419. CTransPacket *_pCTPTransfer; // used on transfering to another thread
  420. DWORD _grfInternalFlags;
  421. CRefCount _cPacketsInList;
  422. CRefCount _cPostedMsg;
  423. BOOL _fDispatch;
  424. BOOL _fUnlocked;
  425. ThreadSwitchState _ThreadTransferState;
  426. BOOL _fResultReported;
  427. BOOL _fResultDispatched;
  428. DWORD _dwDispatchLevel;
  429. BOOL _fTerminated;
  430. BOOL _fTerminating;
  431. BOOL _fReceivedTerminate;
  432. BOOL _fCallTerminate;
  433. BOOL _fDocFile;
  434. BOOL _fMimeVerified;
  435. BOOL _fResultReceived;
  436. BOOL _fMimeHandlerEnabled;
  437. BOOL _fEncodingHandlerEnabled;
  438. BOOL _fClsInstallerHandlerEnabled;
  439. BOOL _fMimeHandlerLoaded;
  440. BOOL _fAttached;
  441. BOOL _fLocked;
  442. BOOL _fModalLoopRunning;
  443. BOOL _fForceAsyncReportResult;
  444. BOOL _fPreferDefaultHandler;
  445. // special (delayed) abort handling
  446. BOOL _fStarting;
  447. BOOL _fReceivedAbort;
  448. HRESULT _hrAbort;
  449. DWORD _dwAbort;
  450. DWORD _dwTerminateOptions;
  451. HRESULT _hrResult;
  452. DWORD _dwResult;
  453. LPWSTR _pwzResult;
  454. LPWSTR _pwzFileName;
  455. LPWSTR _pwzAttachmentName;
  456. LPWSTR _pwzMimeSuggested;
  457. CMutexSem _mxs; // used in Read, Seek, Abort and package list in case of apartment threaded
  458. CMutexSem _mxsBind; // used in method Bind
  459. BINDINFO *_pBndInfo;
  460. DWORD _grfBINDF;
  461. DWORD _dwOInetBdgFlags;
  462. ULONG _ulCurrentSize;
  463. ULONG _ulTotalSize;
  464. LPBYTE _pBuffer; // DNLD_BUFFER_SIZE size buffer
  465. ULONG _cbBufferSize;
  466. ULONG _cbTotalBytesRead;
  467. ULONG _cbBufferFilled; //how much of the buffer is in use
  468. //
  469. ULONG _cbDataSize;
  470. ULONG _cbReadReturn;
  471. ULONG _cbDataSniffMin;
  472. ULONG _cbBytesReported; // how much was reported
  473. //
  474. LARGE_INTEGER _dlibReadPos;
  475. COInetProt _CProtEmbed; // to embed
  476. // Not used: COInetProt _CProtEncoding; // encoding
  477. COInetProt _CProtClsInstaller; // encoding
  478. // Not used: COInetProt _COInetProtPost; // for mime verification on worker thread
  479. BOOL _fProtEmbed;
  480. BOOL _fContentDispositionAttach;
  481. BOOL _fAcceptRanges;
  482. #if DBG==1
  483. WORD _wTotalPostedMsg;
  484. #endif
  485. };
  486. class CTransData : public ITransactionData
  487. {
  488. private:
  489. CTransData(CTransaction *pTrans, LPBYTE pByte, DWORD dwSizeBuffer, BOOL fBindToObject);
  490. ~CTransData();
  491. public:
  492. STDMETHODIMP SetFileName(LPWSTR szFile);
  493. LPWSTR GetFileName();
  494. STDMETHODIMP GetData(FORMATETC **ppformatetc, STGMEDIUM **ppmedium, DWORD grfBSCF);
  495. STDMETHODIMP FindFormatETC();
  496. STDMETHODIMP SetClipFormat(CLIPFORMAT cfFormat);
  497. STDMETHODIMP ReadHere(LPBYTE pBuffer, DWORD cbBytes, DWORD *dwRead);
  498. STDMETHODIMP Seek(LARGE_INTEGER dlibMove,DWORD dwOrigin,ULARGE_INTEGER *plibNewPosition);
  499. STDMETHODIMP OnDataReceived(DWORD grfBSC, DWORD cbBytesRead, DWORD dwTotalSize, DWORD *pcbNewAvailable);
  500. STDMETHODIMP OnDataInBuffer(BYTE *pBuffer, DWORD cbBytesRead, DWORD dwBytesTotal);
  501. STDMETHODIMP GetReadBuffer(BYTE **ppBuffer, DWORD *pcbBytes);
  502. STDMETHODIMP OnStart(IOInetProtocol *pCINet);
  503. STDMETHODIMP OnTerminate();
  504. STDMETHODIMP IsObjectReady();
  505. STDMETHODIMP InProgress();
  506. STDMETHODIMP_(BOOL) IsRemoteObjectReady()
  507. {
  508. return _fRemoteReady;
  509. }
  510. STDMETHODIMP GetClassID(CLSID clsidIn, CLSID *pclsid);
  511. STDMETHODIMP SetMimeType(LPCWSTR pszMine);
  512. LPCWSTR GetMimeType();
  513. STDMETHODIMP GetAcceptStr(LPWSTR *ppwzStr, ULONG *pcElements);
  514. STDMETHODIMP GetAcceptMimes(LPWSTR *ppStr, ULONG cel, ULONG *pcElements);
  515. STDMETHODIMP PrepareThreadTransfer();
  516. DataSink GetDataSink();
  517. DataSink SetDataSink(DWORD dwBindF);
  518. DataSink SwitchDataSink(DataSink dsNew);
  519. void OnEndofData();
  520. BOOL IsFileRequired();
  521. BOOL IsFromCache()
  522. {
  523. return _fCache;
  524. }
  525. void SetFromCacheFlag(BOOL fCache)
  526. {
  527. _fCache = fCache;
  528. }
  529. void ResetCINet(IOInetProtocol *pCINet)
  530. {
  531. if (_pProt)
  532. {
  533. _pProt->Release();
  534. }
  535. _pProt = pCINet;
  536. if (_pProt)
  537. {
  538. _pProt->AddRef();
  539. }
  540. }
  541. ULONG GetDataSize()
  542. {
  543. return _cbDataSize;
  544. }
  545. DWORD GetBindFlags()
  546. {
  547. return _grfBindF;
  548. }
  549. LPWSTR GetUrl()
  550. {
  551. UrlMkAssert((FALSE));
  552. return NULL;
  553. }
  554. VOID SetFileAsStmFile()
  555. {
  556. _fFileAsStmOnFile = TRUE;
  557. }
  558. BOOL IsEOFOnSwitchSink()
  559. {
  560. return _fEOFOnSwitchSink;
  561. }
  562. LPWSTR SetRedirectUrl(LPWSTR pwzStr)
  563. {
  564. if (_pwzRedirectUrl)
  565. {
  566. delete [] _pwzRedirectUrl;
  567. }
  568. _pwzRedirectUrl = OLESTRDuplicate(pwzStr);
  569. return _pwzRedirectUrl;
  570. }
  571. public:
  572. // IUnknown methods
  573. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  574. STDMETHODIMP_(ULONG) AddRef(void);
  575. STDMETHODIMP_(ULONG) Release(void);
  576. // ITransactionData methods
  577. STDMETHODIMP GetTransactionData(LPCWSTR pwzUrl, LPOLESTR *ppwzFilename, LPOLESTR *ppwzMime,
  578. DWORD *pdwSizeTotal, DWORD *pdwSizeAvailable, DWORD dwReserved);
  579. static HRESULT Create(LPCWSTR pwzUrl, DWORD grfBindF, REFIID riid, IBindCtx *pBndCtx, BOOL fBindToObject, CTransData **ppCTD);
  580. STDMETHODIMP Initialize(LPCWSTR pwzUrl, DWORD grfBindF, REFIID riid, IBindCtx *pBndCtx, BOOL fBindToObject = FALSE);
  581. private:
  582. CRefCount _CRefs; // refcount class
  583. TransDataState _TransDataState;
  584. IOInetProtocol *_pProt;
  585. STGMEDIUM *_pStgMed;
  586. FORMATETC _formatetc; // The format that we are sending
  587. CLIPFORMAT _cfFormat;
  588. IEnumFORMATETC *_pEnumFE;
  589. IBindCtx *_pBndCtx;
  590. IID *_piidRes;
  591. DWORD _grfMode;
  592. DWORD _dwAttached;
  593. DWORD _grfBindF;
  594. DWORD _grfBSC;
  595. LPWSTR _pwzUrl;
  596. LPWSTR _pwzRedirectUrl;
  597. unsigned _fBindToObject : 1; //changes with attachment... DO NOT USE FLAG.
  598. unsigned _fMimeTypeVerified : 1;
  599. unsigned _fDocFile : 1;
  600. unsigned _fInitialized : 1;
  601. unsigned _fRemoteReady : 1;
  602. unsigned _fCache : 1;
  603. unsigned _fLocked : 1;
  604. unsigned _fFileAsStmOnFile : 1;
  605. unsigned _fEOFOnSwitchSink : 1;
  606. LPBYTE _lpBuffer; // DNLD_BUFFER_SIZE size buffer
  607. ULONG _cbBufferSize;
  608. ULONG _cbDataSize;
  609. ULONG _cbTotalBytesRead;
  610. ULONG _cbReadReturn;
  611. ULONG _cbBufferFilled; //how much of the buffer is in use
  612. ULONG _cbDataSniffMin;
  613. ULONG _cbBytesReported; // how much was reported
  614. DataSink _ds;
  615. HANDLE _hFile;
  616. WCHAR _wzMime[SZMIMESIZE_MAX];
  617. WCHAR _wzFileName[MAX_PATH];
  618. };
  619. //+---------------------------------------------------------------------------
  620. //
  621. // Class: CModalLoop ()
  622. //
  623. // Purpose:
  624. //
  625. // Interface: CModalLoop --
  626. // ~CModalLoop --
  627. // QueryInterface --
  628. // AddRef --
  629. // Release --
  630. // HandleInComingCall --
  631. // RetryRejectedCall --
  632. // MessagePending --
  633. // _CRefs --
  634. // _pMsgFlter --
  635. //
  636. // History: 8-21-96 JohannP (Johann Posch) Created
  637. //
  638. // Notes:
  639. //
  640. //----------------------------------------------------------------------------
  641. class CModalLoop : public IMessageFilter
  642. {
  643. public:
  644. CModalLoop(HRESULT *phr);
  645. ~CModalLoop();
  646. STDMETHOD(QueryInterface) ( REFIID riid, LPVOID FAR* ppvObj);
  647. STDMETHOD_(ULONG,AddRef) (void);
  648. STDMETHOD_(ULONG,Release) (void);
  649. STDMETHOD_(DWORD, HandleInComingCall)(
  650. DWORD dwCallType,HTASK htaskCaller,
  651. DWORD dwTickCount,LPINTERFACEINFO lpInterfaceInfo);
  652. STDMETHOD_(DWORD, RetryRejectedCall)(
  653. HTASK htaskCallee,DWORD dwTickCount,
  654. DWORD dwRejectType);
  655. STDMETHOD_(DWORD, MessagePending)(
  656. HTASK htaskCallee,
  657. DWORD dwTickCount,
  658. DWORD dwPendingType);
  659. HRESULT HandlePendingMessage(
  660. DWORD dwPendingType,
  661. DWORD dwPendingRecursion,
  662. DWORD dwReserved);
  663. private:
  664. CRefCount _CRefs; // refcount class
  665. IMessageFilter *_pMsgFlter;
  666. };
  667. CTransactionMgr * GetThreadTransactionMgr(BOOL fCreate = TRUE);
  668. #define ChkHResult(hr) { if (FAILED(hr)) { UrlMkAssert((FALSE)); goto End; } }
  669. extern char szContent[];
  670. extern char szClassID[];
  671. extern char szFlags[];
  672. extern char szClass[];
  673. extern char szExtension[];
  674. extern const GUID CLSID_PluginHost;
  675. // private flags for bad header
  676. #define MIMESNIFF_BADHEADER 0x00010000
  677. HRESULT GetMimeFileExtension(LPSTR pszMime, LPSTR pszExt, DWORD cbSize);
  678. HRESULT GetClassFromExt(LPSTR pszExt, CLSID *pclsid);
  679. HRESULT IsDocFile(LPVOID pBuffer, DWORD cbSize);
  680. HRESULT GetPlugInClsID(LPSTR pszExt, LPSTR pszName, LPSTR pszMime, CLSID *pclsid);
  681. HRESULT FindMediaTypeFormat(LPCWSTR pwzType, CLIPFORMAT *cfType, DWORD *pdwFormat);
  682. HRESULT GetMimeFlags(LPCWSTR pwzMime, DWORD *pdwFlags);
  683. #endif //_TRANSACT_HXX_