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.

187 lines
8.6 KiB

  1. /*****************************************************************************\
  2. FILE: ftpdrop.h - IDropTarget interface
  3. Remarks:
  4. Note that you cannot create a shortcut on an FTP site. Although
  5. there's nothing technically preventing it, it's not done because
  6. the shortcut won't be of much use on an FTP site. (It points to
  7. your local machine, which doesn't help much for people not on the
  8. same network!)
  9. If you really want to put a shortcut file on an FTP site, create
  10. it on the desktop, then drag the shortcut onto the FTP site.
  11. The default verb for FTP sites is always "Copy". This is true
  12. even if an intra-site drag-drop is being done.
  13. DESCRIPTION:
  14. DefView will cache the IDropTarget pointer (CFtpDrop) for a shell extension.
  15. When it calls CFtpDrop::Drop(), the work needs to be done on a background
  16. thread in order to not block the UI thread. The problem is that if the user
  17. does another drag to the same Ftp Window, CFtpDrop::Drop() will be called again.
  18. For this reasons, CFtpDrop::Drop() cannot have any state after it returns.
  19. In order to accomplish this with the asynch background thread, we have
  20. CFtpDrop::Drop() call CDropOperation_Create(), and then CDropOperation->DoOperation().
  21. And then it will orphan (call Release()) the CDropOperation. The CDropOperation
  22. will then destroy itself when the copy is finishes. This enables subsequent calls
  23. to CFtpDrop::Drop() to spawn separate CDropOperation objects so each can maintain
  24. the state for that specifc operation and CFtpDrop remains stateless.
  25. \*****************************************************************************/
  26. #ifndef _FTPDROP_H
  27. #define _FTPDROP_H
  28. #include "util.h"
  29. typedef enum OPS
  30. { // Overwrite prompt status
  31. opsPrompt, // Prompt each collision
  32. opsYesToAll, // Overwrite unconditionally
  33. opsNoToAll, // Never overwrite
  34. opsCancel, // Stop the operation
  35. } OPS;
  36. #define COHDI_FILESIZE_COUNT 5
  37. #define COHDI_COPY_FILES 6
  38. typedef struct tagCOPYONEHDROPINFO
  39. {
  40. CFtpFolder * pff;
  41. LPCWSTR pszFSSource;
  42. LPCWSTR pszFtpDest;
  43. LPCWSTR pszDir;
  44. DWORD dwOperation; // COHDI_FILESIZE_COUNT, COHDI_COPY_FILES, etc.
  45. OPS ops;
  46. BOOL fIsRoot;
  47. CMultiLanguageCache * pmlc;
  48. LPITEMIDLIST pidlServer;
  49. BOOL fFireChangeNotify; // Don't fire change notify on BrowserOnly when replacing a file.
  50. PROGRESSINFO progInfo;
  51. } COPYONEHDROPINFO, * LPCOPYONEHDROPINFO;
  52. typedef HRESULT (*STREAMCOPYPROC)(IStream * pstm, DWORD dwFlags, DWORD dwFileSizeHigh, DWORD dwFileSizeLow, LPVOID pv, ULARGE_INTEGER *pqw);
  53. #ifdef UNICODE
  54. #define _EnumOneHdrop _EnumOneHdropW
  55. #else // UNICODE
  56. #define _EnumOneHdrop _EnumOneHdropA
  57. #endif // UNICODE
  58. /*****************************************************************************\
  59. CFtpDrop
  60. de and pde are rather gnarly.
  61. pde is where the output drop effect is kept. A drop handler
  62. can force the effect to be DROPEFFECT_COPY if it encounters a
  63. situation that indicates that the source shouldn't be deleted.
  64. (E.g., if a file is not copied due to an illegal file name.)
  65. de is where the current effect is kept. A drop handler
  66. should consult de to decide whether or not the source
  67. should be deleted. (Used by the HDROP handler, because it is
  68. the drop target's responsibility to delete the source of an
  69. HDROP if applicable.)
  70. You should read from de and write to *pde. Don't
  71. write to de or read from *pde.
  72. The overwrite prompting state tells us how to handle
  73. the case where an incoming file collides with an existing file.
  74. DESCRIPTION:
  75. DefView will cache the IDropTarget pointer (CFtpDrop) for a shell extension.
  76. When it calls CFtpDrop::Drop(), the work needs to be done on a background
  77. thread in order to not block the UI thread. The problem is that if the user
  78. does another drag to the same Ftp Window, CFtpDrop::Drop() will be called again.
  79. For this reasons, CFtpDrop::Drop() cannot have any state after it returns.
  80. In order to accomplish this with the asynch background thread, we have
  81. CFtpDrop::Drop() call CDropOperation_Create(), and then CDropOperation->DoOperation().
  82. And then it will orphan (call Release()) the CDropOperation. The CDropOperation
  83. will then destroy itself when the copy is finishes. This enables subsequent calls
  84. to CFtpDrop::Drop() to spawn separate CDropOperation objects so each can maintain
  85. the state for that specifc operation and CFtpDrop remains stateless.
  86. \*****************************************************************************/
  87. class CFtpDrop : public IDropTarget
  88. {
  89. public:
  90. //////////////////////////////////////////////////////
  91. // Public Interfaces
  92. //////////////////////////////////////////////////////
  93. // *** IUnknown ***
  94. virtual STDMETHODIMP_(ULONG) AddRef(void);
  95. virtual STDMETHODIMP_(ULONG) Release(void);
  96. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  97. // *** IDropTarget ***
  98. virtual STDMETHODIMP DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  99. virtual STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  100. virtual STDMETHODIMP DragLeave(void);
  101. virtual STDMETHODIMP Drop(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  102. public:
  103. CFtpDrop();
  104. ~CFtpDrop(void);
  105. // Public Member Functions
  106. DWORD GetEffectsAvail(IDataObject * pdto);
  107. STDMETHODIMP EnumHdrop(HGLOBAL hdrop, HGLOBAL hmap, BOOL fCopy);
  108. static HRESULT _CopyHglobal(IStream * pstm, DWORD dwFlags, DWORD dwFileSizeHigh, DWORD dwFileSizeLow, LPVOID pvSrc, ULARGE_INTEGER *pqw);
  109. static HRESULT CopyStream(IStream * pstm, DWORD dwFlags, DWORD dwFileSizeHigh, DWORD dwFileSizeLow, LPVOID pvSrc, ULARGE_INTEGER *pqw);
  110. // Friend Functions
  111. friend HRESULT CFtpDrop_Create(CFtpFolder * pff, HWND hwnd, CFtpDrop ** ppfm);
  112. protected:
  113. // Protected Member Variables
  114. int m_cRef;
  115. CFtpFolder * m_pff; // The owner
  116. CFtpDir * m_pfd; // The FtpDir of the owner
  117. HWND m_hwnd; // The window being drug over
  118. DWORD m_grfks; // Last grfKeyState seen
  119. DWORD m_grfksAvail; // Effects available
  120. DROPEFFECT m_de; // Effect being performed
  121. DROPEFFECT * m_pde; // Output effect
  122. OPS m_ops; // Overwrite prompting state
  123. int m_cobj; // Number of objects being dropped
  124. // Private Member Functions
  125. HRESULT SetEffect(DROPEFFECT * pde);
  126. HRESULT _InvokePaste(LPCMINVOKECOMMANDINFO pici);
  127. BOOL _HasData(IDataObject * pdto, FORMATETC * pformatetc) { return (S_OK == pdto->QueryGetData(pformatetc)); };
  128. DROPEFFECT GetEffect(POINTL pt);
  129. HRESULT CopyStorage(LPCTSTR pszFile, IStorage * pstgIn);
  130. HRESULT CopyHdrop(IDataObject * pdto, STGMEDIUM *psm);
  131. HRESULT CopyAsStream(LPCTSTR pszName, DWORD dwFileAttributes, DWORD dwFlags, DWORD dwFileSizeHigh, DWORD dwFileSizeLow, STREAMCOPYPROC pfn, LPVOID pv);
  132. HRESULT CopyFCont(LPCTSTR pszName, DWORD dwFileAttributes, DWORD dwFlags, DWORD dwFileSizeHigh, DWORD dwFileSizeLow, STGMEDIUM *psm);
  133. HRESULT CopyFGD(IDataObject * pdto, STGMEDIUM *psm, BOOL fUnicode);
  134. HRESULT _Copy(IDataObject * pdto);
  135. HRESULT _CopyOneHdrop(LPCTSTR pszFSSource, LPCTSTR pszFtpDest, IProgressDialog * ppd);
  136. HRESULT _StartBackgroundInteration(void);
  137. HRESULT _DoCountIteration(void);
  138. HRESULT _GetFSSourcePaths(HGLOBAL hdrop, BOOL * pfAnsi);
  139. HRESULT _GetFtpDestPaths(HGLOBAL hmap, BOOL fAnsi);
  140. private:
  141. // Private Member Variables
  142. LPCTSTR m_pszzFSSource; // Paths
  143. LPCTSTR m_pszzFtpDest; // Map
  144. HRESULT _CalcSizeOneHdrop(LPCWSTR pszFSSource, LPCWSTR pszFtpDest, IProgressDialog * ppd);
  145. HRESULT _GetFileDescriptor(LONG nIndex, LPFILEGROUPDESCRIPTORW pfgdW, LPFILEGROUPDESCRIPTORA pfgdA, BOOL fUnicode, LPFILEDESCRIPTOR pfd);
  146. HRESULT _CreateFGDDirectory(LPFILEDESCRIPTOR pfd);
  147. BOOL _IsFTPOperationAllowed(IDataObject * pdto);
  148. CFtpDir * _GetRelativePidl(LPCWSTR pszFullPath, DWORD dwFileAttributes, DWORD dwFileSizeHigh, DWORD dwFileSizeLow, LPITEMIDLIST * ppidl);
  149. };
  150. #endif // _FTPDROP_H