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.

164 lines
7.8 KiB

  1. /*****************************************************************************\
  2. FILE: ftpobj.h
  3. \*****************************************************************************/
  4. #ifndef _FTPOBJ_H
  5. #define _FTPOBJ_H
  6. #include "ftpefe.h"
  7. typedef struct
  8. {
  9. DVTARGETDEVICE dvTargetDevice;
  10. FORMATETC formatEtc;
  11. STGMEDIUM medium;
  12. } FORMATETC_STGMEDIUM;
  13. /*****************************************************************************\
  14. CLASS: CFtpObj
  15. Careful! The elements of m_stgCache are rather weird due to delayed
  16. rendering. If m_stgCache[].tymed == TYMED_HGLOBAL but
  17. m_stgCache[].hGlobal == 0, then the FORMATETC exists in the DataObject,
  18. but hasn't been rendered yet.
  19. It will be rendered when you call CFtpObj::_ForceRender().
  20. This weirdness with delayed rendering means that you have to be
  21. careful when you try to access the gizmo.
  22. 1. Before trying to use the gizmo, use CFtpObj::_ForceRender().
  23. 2. When trying to free the gizmo, use CFtpObj::_ReleasePstg().
  24. Yet another weirdness with m_stgCache is that all hGlobal's have a
  25. special babysitter pUnkForRelease. This is important so that
  26. interactions between CFtpObj::GetData and CFtpObj::SetData are isolated.
  27. (If you were lazy and used the CFtpObj itself as the pUnkForRelease,
  28. then you'd run into trouble if somebody tried to SetData into the
  29. data object, which overwrites an hGlobal you had previously given away.)
  30. m_nStartIndex/m_nEndIndex: We give out a list of FILEDESCRIPTORS in the
  31. FILEGROUPDESCRIPTOR. If the directory attribute is set, the caller will
  32. just create the directory. If it's a file, it will call IDataObject::GetData()
  33. with DROP_FCont. We would like to display progress on the old shell because
  34. it normally doesn't display progress until NT5. We need to decide when to start
  35. and stop. We set m_nStartIndex to -1 to indicate that we don't know. When we
  36. get a DROP_FCont call, we then calculate the first and the last. We will then
  37. display the progress dialog until the caller has either called the last one or
  38. errored out.
  39. The data is kept in two places. The data we offer and render is in m_stgCache.
  40. The data we will carry is stored in m_hdsaSetData.
  41. \*****************************************************************************/
  42. class CFtpObj : public IDataObject
  43. , public IPersistStream
  44. , public IInternetSecurityMgrSite
  45. , public IAsyncOperation
  46. {
  47. public:
  48. //////////////////////////////////////////////////////
  49. // Public Interfaces
  50. //////////////////////////////////////////////////////
  51. // *** IUnknown ***
  52. virtual STDMETHODIMP_(ULONG) AddRef(void);
  53. virtual STDMETHODIMP_(ULONG) Release(void);
  54. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  55. // *** IDataObject ***
  56. virtual STDMETHODIMP GetData(FORMATETC *pfmtetcIn, STGMEDIUM *pstgmed);
  57. virtual STDMETHODIMP GetDataHere(FORMATETC *pfmtetc, STGMEDIUM *pstgpmed);
  58. virtual STDMETHODIMP QueryGetData(FORMATETC *pfmtetc);
  59. virtual STDMETHODIMP GetCanonicalFormatEtc(FORMATETC *pfmtetcIn, FORMATETC *pfmtetcOut);
  60. virtual STDMETHODIMP SetData(FORMATETC *pfmtetc, STGMEDIUM *pstgmed, BOOL bRelease);
  61. virtual STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppienumFormatEtc);
  62. virtual STDMETHODIMP DAdvise(FORMATETC *pfmtetc, DWORD dwAdviseFlags, IAdviseSink * piadvsink, DWORD * pdwConnection);
  63. virtual STDMETHODIMP DUnadvise(DWORD dwConnection);
  64. virtual STDMETHODIMP EnumDAdvise(IEnumSTATDATA **ppienumStatData);
  65. // *** IPersist ***
  66. virtual STDMETHODIMP GetClassID(CLSID *pClassID){ *pClassID = CLSID_FtpDataObject; return S_OK; }
  67. // *** IPersistStream ***
  68. virtual STDMETHODIMP IsDirty(void) {return S_OK;} // Indicate that we are dirty and ::Save() needs to be called.
  69. virtual STDMETHODIMP Load(IStream *pStm);
  70. virtual STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
  71. virtual STDMETHODIMP GetSizeMax(ULARGE_INTEGER * pcbSize);
  72. // *** IInternetSecurityMgrSite ***
  73. virtual STDMETHODIMP GetWindow(HWND * phwnd) { if (phwnd) *phwnd = NULL; return S_OK; };
  74. virtual STDMETHODIMP EnableModeless(BOOL fEnable) {return E_NOTIMPL;};
  75. // *** IAsyncOperation methods ***
  76. virtual STDMETHODIMP SetAsyncMode(BOOL fDoOpAsync) {return E_NOTIMPL;};
  77. virtual STDMETHODIMP GetAsyncMode(BOOL * pfIsOpAsync);
  78. virtual STDMETHODIMP StartOperation(IBindCtx * pbcReserved);
  79. virtual STDMETHODIMP InOperation(BOOL * pfInAsyncOp);
  80. virtual STDMETHODIMP EndOperation(HRESULT hResult, IBindCtx * pbcReserved, DWORD dwEffects);
  81. public:
  82. CFtpObj();
  83. ~CFtpObj(void);
  84. // Public Member Functions
  85. static int _DSA_FreeCB(LPVOID pvItem, LPVOID pvlparam);
  86. CFtpPidlList * GetHfpl() { return m_pflHfpl;};
  87. // Friend Functions
  88. friend HRESULT CFtpObj_Create(CFtpFolder * pff, CFtpPidlList * pflHfpl, REFIID riid, LPVOID * ppvObj);
  89. friend HRESULT CFtpObj_Create(CFtpFolder * pff, CFtpPidlList * pflHfpl, CFtpObj ** ppfo);
  90. friend HRESULT CFtpObj_Create(REFIID riid, void ** ppvObj);
  91. friend class CFtpEfe;
  92. protected:
  93. // Private Member Variables
  94. int m_cRef;
  95. CFtpFolder * m_pff; // My dad
  96. CFtpDir * m_pfd; // My dad's home
  97. CFtpPidlList * m_pflHfpl; // List/Array of pidls
  98. STGMEDIUM m_stgCache[DROP_MAX];
  99. HDSA m_hdsaSetData; // Array of SetData. Each item is a FORMATETC_STGMEDIUM.
  100. // Members for Progress on Legacy systems.
  101. IProgressDialog * m_ppd;
  102. ULARGE_INTEGER m_uliCompleted;
  103. ULARGE_INTEGER m_uliTotal;
  104. int m_nStartIndex; // Commented above in CLASS: CFtpObj
  105. int m_nEndIndex; // Commented above in CLASS: CFtpObj
  106. BOOL m_fFGDRendered; // Did we expand m_pflHfpl?
  107. BOOL m_fCheckSecurity; // TRUE means check security and display UI. FALSE means it's unsafe and cancel w/o UI because it was already shown..
  108. BOOL m_fDidAsynchStart; // Did the IDropTarget call IAsynchDataObject::StartOperation() to start the copy? (To show he supports it)
  109. BOOL m_fErrAlreadyDisplayed; // Did was already display the error?
  110. IUnknown * m_punkThreadRef; // Don't allow the browser closing to cancel our drag/drop operation.
  111. // Private Member Functions
  112. void _CheckStg(void);
  113. BOOL _IsLindexOkay(int ife, FORMATETC *pfeWant);
  114. HRESULT _FindData(FORMATETC *pfe, PINT piOut);
  115. HRESULT _FindDataForGet(FORMATETC *pfe, PINT piOut);
  116. HGLOBAL _DelayRender_FGD(BOOL fUnicode);
  117. HRESULT _DelayRender_IDList(STGMEDIUM * pStgMedium);
  118. HRESULT _DelayRender_URL(STGMEDIUM * pStgMedium);
  119. HRESULT _DelayRender_PrefDe(STGMEDIUM * pStgMedium);
  120. HRESULT _RenderOlePersist(STGMEDIUM * pStgMedium);
  121. HRESULT _RenderFGD(int nIndex, STGMEDIUM * pStgMedium);
  122. HRESULT _ForceRender(int ife);
  123. HRESULT _RefThread(void);
  124. CFtpPidlList * _ExpandPidlListRecursively(CFtpPidlList * ppidlListSrc);
  125. int _FindExtraDataIndex(FORMATETC *pfe);
  126. HRESULT _SetExtraData(FORMATETC *pfe, STGMEDIUM *pstg, BOOL fRelease);
  127. HRESULT _RenderFileContents(LPFORMATETC pfe, LPSTGMEDIUM pstg);
  128. HRESULT _DoProgressForLegacySystemsPre(void);
  129. HRESULT _DoProgressForLegacySystemsStart(LPCITEMIDLIST pidl, int nIndex);
  130. HRESULT _DoProgressForLegacySystemsPost(LPCITEMIDLIST pidl, BOOL fLast);
  131. HRESULT _SetProgressDialogValues(int nIndex);
  132. HRESULT _CloseProgressDialog(void);
  133. };
  134. #endif // _FTPOBJ_H