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.

362 lines
15 KiB

  1. /**INC+**********************************************************************/
  2. /* Header: cclipdat.h */
  3. /* */
  4. /* Purpose: Clip Client Addin data */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1998-1999 */
  7. /* */
  8. /**INC-**********************************************************************/
  9. #ifndef _H_CCLIPDAT
  10. #define _H_CCLIPDAT
  11. #include <adcgdata.h>
  12. /****************************************************************************/
  13. /* Number of excluded formats */
  14. /****************************************************************************/
  15. #ifndef OS_WINCE
  16. #define CB_EXCLUDED_FORMAT_COUNT 8
  17. #define CB_EXCLUDED_FORMAT_COUNT_NO_RD 17
  18. #else
  19. #define CB_EXCLUDED_FORMAT_COUNT 9
  20. #define CB_EXCLUDED_FORMAT_COUNT_NO_RD 18
  21. #endif
  22. class CClip ;
  23. typedef CClip *PCClip ;
  24. class CImpIDataObject ;
  25. typedef CImpIDataObject *PCImpIDataObject ;
  26. class CEnumFormatEtc ;
  27. class CClipData : public IUnknown
  28. {
  29. friend CImpIDataObject ;
  30. friend CEnumFormatEtc ;
  31. private:
  32. LONG _cRef ;
  33. TS_CLIP_PDU _ClipPDU ;
  34. PCClip _pClip ;
  35. PCImpIDataObject _pImpIDataObject ;
  36. CRITICAL_SECTION _csLock;
  37. BOOL _fLockInitialized;
  38. public:
  39. CClipData(PCClip);
  40. ~CClipData(void);
  41. void TearDown();
  42. HRESULT DCINTERNAL SetNumFormats(ULONG);
  43. DCVOID SetClipData(HGLOBAL, DCUINT) ;
  44. //IUnknown members that delegate to _pUnkOuter.
  45. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  46. STDMETHODIMP_(ULONG) AddRef(void);
  47. STDMETHODIMP_(ULONG) Release(void);
  48. } ;
  49. typedef CClipData *PCClipData ;
  50. class CImpIDataObject : public IDataObject
  51. {
  52. private:
  53. LONG _cRef;
  54. LPUNKNOWN _pUnkOuter;
  55. ULONG _maxNumFormats ;
  56. ULONG _numFormats ; // Current number of formats in IDataObject
  57. LPFORMATETC _pFormats ; // Buffer of [_maxNumFormats] FORMATETC's
  58. LPSTGMEDIUM _pSTGMEDIUM ; // Our fixed STGMEDIUM (always an HGLOBAL)
  59. DCUINT _uiSTGType ; // type of the STGMEDIUM content (clip type CF_*)
  60. // _lastFormatRequested is used to see if we can avoid re-requesting the
  61. // same data twice over the wire.
  62. CLIPFORMAT _lastFormatRequested ;
  63. CLIPFORMAT _cfDropEffect ;
  64. DCVOID
  65. FreeSTGMEDIUM(void);
  66. public:
  67. PTS_CLIP_PDU _pClipPDU ;
  68. CImpIDataObject(LPUNKNOWN);
  69. ~CImpIDataObject(void);
  70. HRESULT Init(ULONG) ;
  71. DCVOID SetClipData(HGLOBAL, DCUINT) ;
  72. //IUnknown members that delegate to _pUnkOuter.
  73. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  74. STDMETHODIMP_(ULONG) AddRef(void);
  75. STDMETHODIMP_(ULONG) Release(void);
  76. public:
  77. //IDataObject members
  78. STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
  79. STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
  80. STDMETHODIMP QueryGetData(LPFORMATETC);
  81. STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC);
  82. STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
  83. STDMETHODIMP EnumFormatEtc(DWORD, LPENUMFORMATETC *);
  84. STDMETHODIMP DAdvise(LPFORMATETC, DWORD
  85. , LPADVISESINK, DWORD *);
  86. STDMETHODIMP DUnadvise(DWORD);
  87. STDMETHODIMP EnumDAdvise(LPENUMSTATDATA *);
  88. };
  89. class CEnumFormatEtc : public IEnumFORMATETC
  90. {
  91. private:
  92. LONG _cRef;
  93. LPUNKNOWN _pUnkRef;
  94. LPFORMATETC _pFormats;
  95. ULONG _iCur;
  96. ULONG _cItems;
  97. public:
  98. CEnumFormatEtc(LPUNKNOWN);
  99. ~CEnumFormatEtc(void);
  100. DCVOID Init(LPFORMATETC, ULONG) ;
  101. //IUnknown members that delegate to _pUnkOuter.
  102. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  103. STDMETHODIMP_(ULONG) AddRef(void);
  104. STDMETHODIMP_(ULONG) Release(void);
  105. //IEnumFORMATETC members
  106. STDMETHODIMP Next(ULONG, LPFORMATETC, ULONG *);
  107. STDMETHODIMP Skip(ULONG);
  108. STDMETHODIMP Reset(void);
  109. STDMETHODIMP Clone(IEnumFORMATETC **);
  110. };
  111. typedef CEnumFormatEtc *PCEnumFormatEtc;
  112. #if ((defined (OS_WINNT)) || ((defined (OS_WINCE)) && (_WIN32_WCE >= 300) ))
  113. #define USE_SEMAPHORE
  114. #endif
  115. /**STRUCT+*******************************************************************/
  116. /* Structure: CLIP_DATA */
  117. /* */
  118. /* Description: Shared Clip global data */
  119. /****************************************************************************/
  120. typedef struct tagCLIP_DATA
  121. {
  122. /************************************************************************/
  123. /* Clipboard viewer chain information */
  124. /************************************************************************/
  125. HWND viewerWindow;
  126. HWND nextViewer;
  127. /************************************************************************/
  128. /* Our state information */
  129. /************************************************************************/
  130. DCBOOL moreToDo;
  131. DCBOOL pendingClose;
  132. DCUINT state;
  133. DCBOOL rcvOpen;
  134. DCBOOL clipOpen;
  135. DCUINT16 failType;
  136. /************************************************************************/
  137. /* Send and receive buffers */
  138. /************************************************************************/
  139. #ifdef USE_SEMAPHORE
  140. #define CB_PERM_BUF_COUNT 1
  141. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  142. //txPermBuffer buffer must be aligned on a processor
  143. //word boundary
  144. //The placement of the HANDLE before
  145. //the field must NOT be changed.
  146. HANDLE txPermBufSem;
  147. DCUINT8 txPermBuffer[CHANNEL_CHUNK_LENGTH];
  148. #else
  149. #define CB_PERM_BUF_COUNT 2
  150. DCUINT8 txPermBuffer[CB_PERM_BUF_COUNT][CHANNEL_CHUNK_LENGTH];
  151. DCBOOL txPermBufInUse[CB_PERM_BUF_COUNT];
  152. #endif
  153. HPDCUINT8 rxpBuffer; /* pointer to start of buffer */
  154. HPDCUINT8 rxpBufferCurrent; /* current location in buffer */
  155. DCUINT32 rxBufferLen; /* size of buffer */
  156. DCUINT32 rxBufferLeft; /* bytes left to receive */
  157. /************************************************************************/
  158. /* Server/client format ID map */
  159. /************************************************************************/
  160. CB_FORMAT_MAP idMap[CB_MAX_FORMATS];
  161. /************************************************************************/
  162. /* other useful data */
  163. /************************************************************************/
  164. DCUINT pendingClientID;
  165. DCUINT pendingServerID;
  166. DCBOOL DIBFormatExists;
  167. /************************************************************************/
  168. /* Channel API stuff */
  169. /************************************************************************/
  170. ULONG channelHandle;
  171. LPVOID initHandle;
  172. HINSTANCE hInst;
  173. CHANNEL_ENTRY_POINTS_EX channelEP;
  174. DWORD dropEffect ; // We currently only support FO_COPY and FO_MOVE
  175. DWORD dwVersion ;
  176. BOOL fAlreadyCopied ;
  177. BOOL fDrivesRedirected ;
  178. BOOL fFileCutCopyOn ; // If we can handle file cut/copy
  179. PUT_THREAD_DATA pClipThreadData ;
  180. // locatation where temp files will go; the +1 is for an extra NULL char
  181. // that may be needed for the SHFileOperation
  182. char baseTempDirA[MAX_PATH] ;
  183. wchar_t baseTempDirW[MAX_PATH] ;
  184. char tempDirA[MAX_PATH+1] ;
  185. wchar_t tempDirW[MAX_PATH+1] ;
  186. char pasteInfoA[MAX_PATH + 1];
  187. // Message used to send messages between the threads
  188. UINT regMsg ;
  189. #ifdef OS_WINCE
  190. HWND dataWindow;
  191. #endif
  192. } CLIP_DATA;
  193. /**STRUCT-*******************************************************************/
  194. const DCTCHAR g_excludedFormatList[CB_EXCLUDED_FORMAT_COUNT]
  195. [TS_FORMAT_NAME_LEN]
  196. = {
  197. _T("Link" ),
  198. _T("OwnerLink" ),
  199. _T("ObjectLink" ),
  200. _T("Ole Private Data" ),
  201. _T("Link Source" ),
  202. _T("Link Source Descriptor"),
  203. _T("Embed Source" ),
  204. #ifdef OS_WINCE
  205. _T("RTF in UTF8" ), //Pocketword doesnt correctly support UTF8.
  206. #endif
  207. _T("Embedded Object" )
  208. } ;
  209. // If drive redirection is turned off, we have to exclude mroe things
  210. // because we can't handle them
  211. const DCTCHAR g_excludedFormatList_NO_RD[CB_EXCLUDED_FORMAT_COUNT_NO_RD]
  212. [TS_FORMAT_NAME_LEN]
  213. = {
  214. _T("Link" ),
  215. _T("OwnerLink" ),
  216. _T("ObjectLink" ),
  217. _T("Ole Private Data" ),
  218. _T("Link Source" ),
  219. _T("Link Source Descriptor"),
  220. _T("Embed Source" ),
  221. #ifdef OS_WINCE
  222. _T("RTF in UTF8" ), //Pocketword doesnt correctly support UTF8.
  223. #endif
  224. _T("DataObject" ),
  225. _T("Object Descriptor" ),
  226. _T("Shell IDList Array" ),
  227. _T("Shell Object Offsets" ),
  228. _T("FileName" ),
  229. _T("FileNameW" ),
  230. _T("FileContents" ),
  231. _T("FileGroupDescriptor" ),
  232. _T("FileGroupDescriptorW" ),
  233. _T("Embedded Object" )
  234. } ;
  235. /****************************************************************************/
  236. /* Clip State Table */
  237. /****************************************************************************/
  238. static DCUINT cbStateTable[CB_NUMEVENTS][CB_NUMSTATES]
  239. = {
  240. /********************************************************************/
  241. /* This is not a state table in the strict sense. It simply shows */
  242. /* which events are valid in which states. It is not used to drive */
  243. /* CB. */
  244. /* */
  245. /* Values mean */
  246. /* - 0 event OK in this state. */
  247. /* - 1 warning - event may occur in this state, but we should */
  248. /* ignore it (eg we shouldn't send a format list before the */
  249. /* monitor has joined the call! */
  250. /* - 2 error - event should not occur in ths state at all. */
  251. /* */
  252. /* These values are hard-coded here in order to make the table */
  253. /* readable. They correspond to the constants CB_TABLE_OK, */
  254. /* CB_TABLE_WARN & CB_TABLE_ERROR. */
  255. /* */
  256. /* Terminated */
  257. /* | Initialized */
  258. /* | | Enabled */
  259. /* | | | Local CB owner */
  260. /* | | | | Shared CB owner */
  261. /* | | | | | Pending format list rsp */
  262. /* | | | | | | Sending format data */
  263. /* | | | | | | | Pending format data rsp */
  264. /* | | | | | | | | */
  265. /********************************************************************/
  266. /* init/term */
  267. { 0, 2, 2, 2, 2, 2, 2, 2}, /* CB_Init */
  268. { 2, 0, 1, 1, 1, 2, 2, 2}, /* CB_Enable */
  269. { 1, 1, 0, 0, 0, 0, 0, 0}, /* CB_Disable */
  270. { 1, 0, 1, 1, 1, 1, 1, 1}, /* CB_Term */
  271. /* local CB messages */
  272. { 0, 1, 2, 2, 2, 2, 2, 2}, /* WM_CREATE */
  273. { 2, 0, 2, 2, 2, 2, 2, 2}, /* WM_DESTROY */
  274. { 2, 0, 0, 0, 0, 0, 0, 0}, /* WM_CHANGECBCHAIN */
  275. { 1, 1, 0, 0, 0, 1, 0, 0}, /* WM_DRAWCLIPBOARD */
  276. { 2, 2, 2, 0, 1, 1, 1, 1}, /* WM_RENDERFORMAT */
  277. /* shared CB messages */
  278. { 2, 2, 0, 0, 0, 0, 2, 0}, /* Format list */
  279. { 2, 2, 2, 2, 1, 0, 2, 2}, /* Format list rsp */
  280. { 2, 2, 2, 2, 0, 0, 2, 2}, /* Format data rq */
  281. { 2, 2, 2, 2, 2, 2, 2, 0} /* Format data rsp */
  282. };
  283. #ifdef DC_DEBUG
  284. /****************************************************************************/
  285. /* State and event descriptions (debug build only) */
  286. /****************************************************************************/
  287. const DCTCHAR cbState[CB_NUMSTATES][35]
  288. = {
  289. _T("CB_STATE_NOT_INIT"),
  290. _T("CB_STATE_INITIALIZED"),
  291. _T("CB_STATE_ENABLED"),
  292. _T("CB_STATE_LOCAL_CB_OWNER"),
  293. _T("CB_STATE_SHARED_CB_OWNER"),
  294. _T("CB_STATE_PENDING_FORMAT_LIST_RSP"),
  295. _T("CB_STATE_SENDING_FORMAT_DATA"),
  296. _T("CB_STATE_PENDING_FORMAT_DATA_RSP")
  297. };
  298. const DCTCHAR cbEvent[CB_NUMEVENTS][35]
  299. = {
  300. _T("CB_EVENT_CB_INIT"),
  301. _T("CB_EVENT_CB_ENABLE"),
  302. _T("CB_EVENT_CB_DISABLE"),
  303. _T("CB_EVENT_CB_TERM"),
  304. _T("CB_EVENT_WM_CREATE"),
  305. _T("CB_EVENT_WM_DESTROY"),
  306. _T("CB_EVENT_WM_CHANGECBCHAIN"),
  307. _T("CB_EVENT_WM_DRAWCLIPBOARD"),
  308. _T("CB_EVENT_WM_RENDERFORMAT"),
  309. _T("CB_EVENT_FORMAT_LIST"),
  310. _T("CB_EVENT_FORMAT_LIST_RSP"),
  311. _T("CB_EVENT_FORMAT_DATA_RQ"),
  312. _T("CB_EVENT_FORMAT_DATA_RSP")
  313. };
  314. #endif /* DC_DEBUG */
  315. #endif /* _H_ACBDATA */