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.

158 lines
4.7 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) Microsoft Corporation, 1995 - 1999
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. #ifndef _DATAOBJ_H
  9. #define _DATAOBJ_H
  10. typedef CArray<MMC_COOKIE, MMC_COOKIE> CCookiePtrArray;
  11. class CDataObject : public IDataObject, public CComObjectRoot
  12. {
  13. friend class CSnapin;
  14. // ATL Maps
  15. DECLARE_NOT_AGGREGATABLE(CDataObject)
  16. BEGIN_COM_MAP(CDataObject)
  17. COM_INTERFACE_ENTRY(IDataObject)
  18. END_COM_MAP()
  19. // Construction/Destruction
  20. CDataObject();
  21. ~CDataObject() {}
  22. // Clipboard formats that are required by the console
  23. public:
  24. static unsigned int m_cfNodeType; // Required by the console
  25. static unsigned int m_cfNodeTypeString; // Required by the console
  26. static unsigned int m_cfDisplayName; // Required by the console
  27. static unsigned int m_cfCoClass; // Required by the console
  28. static unsigned int m_cfIsMultiSel; // Required by the console
  29. static unsigned int m_cfInternal; // Step 3
  30. static unsigned int m_cfWorkstation; // Published information
  31. // Standard IDataObject methods
  32. public:
  33. // Implemented
  34. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium);
  35. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium);
  36. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc);
  37. ULONG InternalAddRef()
  38. {
  39. return CComObjectRoot::InternalAddRef();
  40. }
  41. ULONG InternalRelease()
  42. {
  43. return CComObjectRoot::InternalRelease();
  44. }
  45. // Not Implemented
  46. private:
  47. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc);
  48. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  49. { return E_NOTIMPL; };
  50. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  51. { return E_NOTIMPL; };
  52. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
  53. LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  54. { return E_NOTIMPL; };
  55. STDMETHOD(DUnadvise)(DWORD dwConnection)
  56. { return E_NOTIMPL; };
  57. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  58. { return E_NOTIMPL; };
  59. // Implementation
  60. public:
  61. void SetType(DATA_OBJECT_TYPES type) // Step 3
  62. { ASSERT(m_internal.m_type == CCT_UNINITIALIZED); m_internal.m_type = type; }
  63. public:
  64. void SetCookie(MMC_COOKIE cookie) { m_internal.m_cookie = cookie; } // Step 3
  65. void SetString(LPTSTR lpString) { m_internal.m_string = lpString; }
  66. void SetClsid(const CLSID& clsid) { m_internal.m_clsid = clsid; }
  67. void SetMultiSelData(SMMCObjectTypes* psGuidObjTypes, UINT cbMultiSelData)
  68. {
  69. // make sure [1] still good enough
  70. ASSERT(cbMultiSelData == sizeof(m_sGuidObjTypes));
  71. if (cbMultiSelData == sizeof(m_sGuidObjTypes))
  72. {
  73. m_cbMultiSelData = cbMultiSelData;
  74. CopyMemory(&m_sGuidObjTypes, psGuidObjTypes, cbMultiSelData);
  75. }
  76. }
  77. ULONG AddCookie(MMC_COOKIE Cookie);
  78. ULONG QueryCookieCount(VOID)
  79. {
  80. return m_rgCookies.GetSize();
  81. }
  82. STDMETHODIMP GetCookieAt(ULONG iCookie, MMC_COOKIE *pCookie);
  83. STDMETHODIMP RemoveCookieAt(ULONG iCookie);
  84. void SetMultiSelDobj()
  85. {
  86. m_bMultiSelDobj = TRUE;
  87. }
  88. #ifdef _DEBUG
  89. UINT dbg_refCount;
  90. void AddRefMultiSelDobj()
  91. {
  92. ASSERT(m_bMultiSelDobj == TRUE);
  93. ++dbg_refCount;
  94. }
  95. void ReleaseMultiSelDobj()
  96. {
  97. ASSERT(m_bMultiSelDobj == TRUE);
  98. --dbg_refCount;
  99. //if (dbg_refCount == 0)
  100. // ::MessageBox(NULL, _T("Final release on multi-sel-dobj"), _T("Sample snapin"), MB_OK);
  101. }
  102. #endif
  103. private:
  104. HRESULT CreateNodeTypeData(LPSTGMEDIUM lpMedium);
  105. HRESULT CreateNodeTypeStringData(LPSTGMEDIUM lpMedium);
  106. HRESULT CreateDisplayName(LPSTGMEDIUM lpMedium);
  107. HRESULT CreateInternal(LPSTGMEDIUM lpMedium); // Step 3
  108. HRESULT CreateWorkstationName(LPSTGMEDIUM lpMedium);
  109. HRESULT CreateCoClassID(LPSTGMEDIUM lpMedium);
  110. HRESULT CreateMultiSelData(LPSTGMEDIUM lpMedium);
  111. HRESULT Create(const void* pBuffer, int len, LPSTGMEDIUM lpMedium);
  112. HRESULT CreateVariableLen(const void* pBuffer, int len, LPSTGMEDIUM lpMedium);
  113. INTERNAL m_internal; // Step 3
  114. SMMCObjectTypes m_sGuidObjTypes; // length[1] good enough for now
  115. UINT m_cbMultiSelData;
  116. BOOL m_bMultiSelDobj;
  117. CCookiePtrArray m_rgCookies;
  118. };
  119. #endif