Source code of Windows XP (NT5)
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.

277 lines
8.3 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // @module Binder.h | Binder.cpp base object and contained interface
  7. //
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////////
  10. #ifndef _BINDER_H_
  11. #define _BINDER_H_
  12. #include "headers.h"
  13. // forward declaration
  14. class CImplICreateRow;
  15. class CImplIDBBinderProperties;
  16. class CImplIBindResource;
  17. typedef CImplICreateRow* PICREATEROW;
  18. typedef CImplIDBBinderProperties* PIDBBINDERPROPERTIES;
  19. typedef CImplIBindResource* PIDBBINDRESOURCE;
  20. typedef CDBSession* PDBSESSION;
  21. class CBinder:public CBaseObj
  22. {
  23. friend class CImplICreateRow;
  24. friend class CImplIDBBinderProperties;
  25. friend class CImplIBindResource;
  26. CDataSource* m_pDataSrc;
  27. CDBSession* m_pSession; //Parent Session Object
  28. PICREATEROW m_pICreateRow;
  29. PIDBBINDERPROPERTIES m_pIBinderProperties;
  30. PIDBBINDRESOURCE m_pIBindResource;
  31. PIMPISUPPORTERRORINFO m_pISupportErrorInfo; // contained ISupportErrorInfo
  32. CUtilProp* m_pUtilProp;
  33. CURLParser* m_pUrlParser;
  34. BOOL m_fDSOInitialized;
  35. HRESULT CreateDSO(IUnknown *pUnkOuter,LONG lInitFlag, REFGUID guidTemp,IUnknown ** ppUnk);
  36. HRESULT CreateSession(IUnknown *pUnkOuter, REFGUID guidTemp,IUnknown ** ppUnk);
  37. HRESULT CreateCommand(IUnknown *pUnkOuter, REFGUID guidTemp,IUnknown ** ppUnk);
  38. HRESULT CreateRow(IUnknown *pUnkOuter, REFGUID guidTemp,IUnknown ** ppUnk , ROWCREATEBINDFLAG rowCreateFlag = ROWOPEN);
  39. HRESULT CreateRowset(IUnknown *pUnkOuter, REFGUID guidTemp,IUnknown ** ppUnk);
  40. // void GetInitAndBindFlagsFromBindFlags(DBBINDURLFLAG dwBindURLFlags,LONG & lInitMode ,LONG & lInitBindFlags);
  41. HRESULT ReleaseAllObjects();
  42. HRESULT AddInterfacesForISupportErrorInfo();
  43. public:
  44. CBinder(LPUNKNOWN pUnkOuter);
  45. ~CBinder();
  46. HRESULT InitBinder();
  47. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  48. STDMETHODIMP_(ULONG) AddRef(void);
  49. STDMETHODIMP_(ULONG) Release(void);
  50. };
  51. class CImplIBindResource : public IBindResource
  52. {
  53. private:
  54. CBinder *m_pObj;
  55. DEBUGCODE(ULONG m_cRef);
  56. BOOL CheckBindURLFlags(DBBINDURLFLAG dwBindURLFlags , REFGUID rguid); // Function to check if proper flags are
  57. // are set for the require object
  58. // To check if URL Matches the requested type of object
  59. BOOL CheckIfProperURL(BSTR & strUrl,REFGUID rguid,DBBINDURLSTATUS * pdwBindStatus);
  60. HRESULT BindURL(IUnknown * pUnkOuter,
  61. LPCOLESTR pwszURL,
  62. DBBINDURLFLAG dwBindURLFlags,
  63. REFGUID rguid,
  64. REFIID riid,
  65. DBIMPLICITSESSION * pImplSession,
  66. DBBINDURLSTATUS * pdwBindStatus,
  67. IUnknown ** ppUnk);
  68. // void GetInitAndBindFlagsFromBindFlags(DBBINDURLFLAG dwBindURLFlags,LONG & lInitMode ,LONG & lInitBindFlags);
  69. public:
  70. CImplIBindResource( CBinder *pObj )
  71. {
  72. DEBUGCODE(m_cRef = 0L);
  73. m_pObj = pObj;
  74. }
  75. ~CImplIBindResource()
  76. {
  77. }
  78. STDMETHODIMP_(ULONG) AddRef(void)
  79. {
  80. DEBUGCODE(InterlockedIncrement((long*)&m_cRef));
  81. return m_pObj->GetOuterUnknown()->AddRef();
  82. }
  83. STDMETHODIMP_(ULONG) Release(void)
  84. {
  85. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef);
  86. if( lRef < 0 ){
  87. ASSERT("Reference count on Object went below 0!")
  88. })
  89. return m_pObj->GetOuterUnknown()->Release();
  90. }
  91. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv)
  92. {
  93. return m_pObj->GetOuterUnknown()->QueryInterface(riid, ppv);
  94. }
  95. STDMETHODIMP Bind( IUnknown * pUnkOuter,
  96. LPCOLESTR pwszURL,
  97. DBBINDURLFLAG dwBindURLFlags,
  98. REFGUID rguid,
  99. REFIID riid,
  100. IAuthenticate * pAuthenticate,
  101. DBIMPLICITSESSION * pImplSession,
  102. DBBINDURLSTATUS * pdwBindStatus,
  103. IUnknown ** ppUnk);
  104. };
  105. class CImplICreateRow : public ICreateRow
  106. {
  107. private:
  108. CBinder *m_pObj;
  109. DEBUGCODE(ULONG m_cRef);
  110. BOOL CheckBindURLFlags(DBBINDURLFLAG dwBindURLFlags , REFGUID rguid);
  111. BOOL CheckIfProperURL(BSTR & strUrl,REFGUID rguid,DBBINDURLSTATUS * pdwBindStatus);
  112. HRESULT BindURL( IUnknown * pUnkOuter,
  113. LPCOLESTR pwszURL,
  114. DBBINDURLFLAG dwBindURLFlags,
  115. REFGUID rguid,
  116. REFIID riid,
  117. DBIMPLICITSESSION * pImplSession,
  118. DBBINDURLSTATUS * pdwBindStatus,
  119. IUnknown ** ppUnk);
  120. HRESULT CreateNewRow( IUnknown * pUnkOuter,
  121. LPCOLESTR pwszURL,
  122. DBBINDURLFLAG dwBindURLFlags,
  123. REFGUID rguid,
  124. REFIID riid,
  125. DBIMPLICITSESSION * pImplSession,
  126. DBBINDURLSTATUS * pdwBindStatus,
  127. IUnknown ** ppUnk);
  128. public:
  129. CImplICreateRow( CBinder *pObj )
  130. {
  131. DEBUGCODE(m_cRef = 0L);
  132. m_pObj = pObj;
  133. }
  134. ~CImplICreateRow()
  135. {
  136. }
  137. STDMETHODIMP_(ULONG) AddRef(void)
  138. {
  139. DEBUGCODE(InterlockedIncrement((long*)&m_cRef));
  140. return m_pObj->GetOuterUnknown()->AddRef();
  141. }
  142. STDMETHODIMP_(ULONG) Release(void)
  143. {
  144. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef);
  145. if( lRef < 0 ){
  146. ASSERT("Reference count on Object went below 0!")
  147. })
  148. return m_pObj->GetOuterUnknown()->Release();
  149. }
  150. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv)
  151. {
  152. return m_pObj->GetOuterUnknown()->QueryInterface(riid, ppv);
  153. }
  154. STDMETHODIMP CreateRow(IUnknown * pUnkOuter,
  155. LPCOLESTR pwszURL,
  156. DBBINDURLFLAG dwBindURLFlags,
  157. REFGUID rguid,
  158. REFIID riid,
  159. IAuthenticate * pAuthenticate,
  160. DBIMPLICITSESSION * pImplSession,
  161. DBBINDURLSTATUS * pdwBindStatus,
  162. LPOLESTR * ppwszNewURL,
  163. IUnknown ** ppUnk);
  164. };
  165. class CImplIDBBinderProperties : public IDBBinderProperties
  166. {
  167. private:
  168. CBinder *m_pObj;
  169. DEBUGCODE(ULONG m_cRef);
  170. DWORD GetBitMask(REFGUID rguid);
  171. public:
  172. CImplIDBBinderProperties( CBinder *pObj )
  173. {
  174. DEBUGCODE(m_cRef = 0L);
  175. m_pObj = pObj;
  176. }
  177. ~CImplIDBBinderProperties()
  178. {
  179. }
  180. STDMETHODIMP_(ULONG) AddRef(void)
  181. {
  182. DEBUGCODE(InterlockedIncrement((long*)&m_cRef));
  183. return m_pObj->GetOuterUnknown()->AddRef();
  184. }
  185. STDMETHODIMP_(ULONG) Release(void)
  186. {
  187. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef);
  188. if( lRef < 0 ){
  189. ASSERT("Reference count on Object went below 0!")
  190. })
  191. return m_pObj->GetOuterUnknown()->Release();
  192. }
  193. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv)
  194. {
  195. return m_pObj->GetOuterUnknown()->QueryInterface(riid, ppv);
  196. }
  197. //==========================================================
  198. // IDBProperties member functions
  199. //==========================================================
  200. STDMETHODIMP GetProperties // GetProperties method
  201. (
  202. ULONG cPropertySets,
  203. const DBPROPIDSET rgPropertySets[],
  204. ULONG* pcProperties,
  205. DBPROPSET** prgProperties
  206. );
  207. STDMETHODIMP GetPropertyInfo // GetPropertyInfo method
  208. (
  209. ULONG cPropertySets,
  210. const DBPROPIDSET rgPropertySets[],
  211. ULONG* pcPropertyInfoSets,
  212. DBPROPINFOSET** prgPropertyInfoSets,
  213. WCHAR** ppDescBuffer
  214. );
  215. STDMETHODIMP SetProperties // SetProperties method
  216. (
  217. ULONG cProperties,
  218. DBPROPSET rgProperties[]
  219. );
  220. STDMETHODIMP Reset();
  221. };
  222. #endif