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.

406 lines
12 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation.
  4. //
  5. // File: WLBS_Provider.h
  6. //
  7. // Module: WLBS instance provider main project header file
  8. //
  9. // Purpose: General purpose include file.
  10. //
  11. // History:
  12. //
  13. // Author: drbeck
  14. //
  15. //***************************************************************************
  16. #ifndef _WLBSPROVIDER_INCLUDED_
  17. #define _WLBSPROVIDER_INCLUDED_
  18. #include <crtdbg.h>
  19. #include <comdef.h>
  20. #include <iostream>
  21. #include <memory>
  22. #include <string>
  23. #include <wbemprov.h>
  24. #include <genlex.h> //for wmi object path parser
  25. #include <objbase.h>
  26. #include <wlbsconfig.h>
  27. #include <ntrkcomm.h>
  28. using namespace std;
  29. #include "objpath.h"
  30. #include "WLBS_MOFData.h"
  31. #include "WLBS_Root.h"
  32. #include "WLBS_Node.h"
  33. #include "WLBS_Cluster.h"
  34. #include "WLBS_NodeSetting.h"
  35. #include "WLBS_ClusterSetting.h"
  36. #include "WLBS_PortRule.h"
  37. #include "WLBS_ParticipatingNode.h"
  38. #include "WLBS_NodeSetPortRule.h"
  39. #include "WLBS_ClusClusSetting.h"
  40. #include "WLBS_NodeNodeSetting.h"
  41. typedef LPVOID * PPVOID;
  42. class CWLBSProvider : public CImpersonatedProvider
  43. {
  44. private:
  45. void GetClass(IWbemClassObject *a_pClassObject, wstring& a_szClass);
  46. void ParseObjectPath(const BSTR a_strObjectPath, ParsedObjectPath **a_pParsedObjectPath);
  47. HRESULT GetMOFSupportClass( LPCWSTR a_szObjectClass,
  48. auto_ptr<CWlbs_Root> &a_pMofClass,
  49. IWbemObjectSink* a_pResponseHandler );
  50. public:
  51. CWLBSProvider( BSTR ObjectPath = NULL,
  52. BSTR User = NULL,
  53. BSTR Password = NULL,
  54. IWbemContext *pCtx = NULL );
  55. virtual ~CWLBSProvider();
  56. HRESULT STDMETHODCALLTYPE DoGetObjectAsync(
  57. /* [in] */ BSTR ObjectPath,
  58. /* [in] */ long lFlags,
  59. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  60. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  61. HRESULT STDMETHODCALLTYPE DoPutInstanceAsync(
  62. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  63. /* [in] */ long lFlags,
  64. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  65. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  66. HRESULT STDMETHODCALLTYPE DoDeleteInstanceAsync(
  67. /* [in] */ BSTR ObjectPath,
  68. /* [in] */ long lFlags,
  69. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  70. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  71. HRESULT STDMETHODCALLTYPE DoCreateInstanceEnumAsync(
  72. /* [in] */ BSTR Class,
  73. /* [in] */ long lFlags,
  74. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  75. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  76. HRESULT STDMETHODCALLTYPE DoExecQueryAsync(
  77. /* [in] */ BSTR QueryLanguage,
  78. /* [in] */ BSTR Query,
  79. /* [in] */ long lFlags,
  80. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  81. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  82. {return WBEM_E_NOT_SUPPORTED;}
  83. HRESULT STDMETHODCALLTYPE DoExecMethodAsync(
  84. BSTR,
  85. BSTR,
  86. long,
  87. IWbemContext*,
  88. IWbemClassObject*,
  89. IWbemObjectSink* );
  90. //IWbemProviderInit
  91. HRESULT STDMETHODCALLTYPE Initialize(
  92. LPWSTR pszUser,
  93. LONG lFlags,
  94. LPWSTR pszNamespace,
  95. LPWSTR pszLocale,
  96. IWbemServices * pNamespace,
  97. IWbemContext * pCtx,
  98. IWbemProviderInitSink * pInitSink
  99. );
  100. };
  101. // Provider interfaces are provided by objects of this class
  102. /*
  103. class CWLBSProvider : public IWbemServices, public IWbemProviderInit
  104. {
  105. private:
  106. void GetClass(IWbemClassObject *a_pClassObject, wstring& a_szClass);
  107. void ParseObjectPath(const BSTR a_strObjectPath, ParsedObjectPath **a_pParsedObjectPath);
  108. void GetMOFSupportClass(LPCWSTR a_szObjectClass,
  109. auto_ptr<CWlbs_Root> &a_pMofClass,
  110. IWbemObjectSink * a_pResponseHandler);
  111. protected:
  112. // long m_cRef; //Object reference count
  113. // IWbemServices* m_pNamespace; //Pointer to namespace passed in by WinMgMt
  114. public:
  115. //constructor
  116. CWLBSProvider(
  117. BSTR ObjectPath = NULL,
  118. BSTR User = NULL,
  119. BSTR Password = NULL,
  120. IWbemContext * pCtx = NULL
  121. );
  122. //destructor
  123. ~CWLBSProvider(void);
  124. //Non-delegating object IUnknown
  125. STDMETHODIMP QueryInterface (REFIID, PPVOID);
  126. STDMETHODIMP_(ULONG) AddRef (void);
  127. STDMETHODIMP_(ULONG) Release (void);
  128. //IWbemServices
  129. //***************************************************************************
  130. // Supported Methods
  131. //***************************************************************************
  132. HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  133. BSTR a_strClass,
  134. long a_lFlags,
  135. IWbemContext * a_pIContex,
  136. IWbemObjectSink * a_pIResponseHandler
  137. );
  138. HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  139. BSTR a_strObjectPath,
  140. BSTR a_strMethodName,
  141. long a_lFlags,
  142. IWbemContext * a_pIContex,
  143. IWbemClassObject * a_pIInParams,
  144. IWbemObjectSink * a_pIResponseHandler
  145. );
  146. HRESULT STDMETHODCALLTYPE GetObjectAsync(
  147. BSTR a_strObjectPath,
  148. long a_lFlags,
  149. IWbemContext * a_pIContex,
  150. IWbemObjectSink * a_pIResponseHandler
  151. );
  152. HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  153. IWbemClassObject * a_pInst,
  154. long a_lFlags,
  155. IWbemContext * a_pIContex,
  156. IWbemObjectSink * a_pIResponseHandler
  157. );
  158. //***************************************************************************
  159. // Unsupported methods
  160. //***************************************************************************
  161. HRESULT STDMETHODCALLTYPE OpenNamespace(
  162. BSTR Namespace,
  163. long lFlags,
  164. IWbemContext * pCtx,
  165. IWbemServices ** ppWorkingNamespace,
  166. IWbemCallResult ** ppResult) {
  167. return WBEM_E_NOT_SUPPORTED;
  168. }
  169. HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  170. IWbemObjectSink *pSink) {
  171. return WBEM_E_NOT_SUPPORTED;
  172. }
  173. HRESULT STDMETHODCALLTYPE QueryObjectSink(
  174. long lFlags,
  175. IWbemObjectSink ** ppResponseHandler) {
  176. return WBEM_E_NOT_SUPPORTED;
  177. }
  178. HRESULT STDMETHODCALLTYPE GetObject(
  179. BSTR ObjectPath,
  180. long lFlags,
  181. IWbemContext * pCtx,
  182. IWbemClassObject ** ppObject,
  183. IWbemCallResult ** ppCallResult) {
  184. return WBEM_E_NOT_SUPPORTED;
  185. }
  186. HRESULT STDMETHODCALLTYPE PutClass(
  187. IWbemClassObject * pObject,
  188. long lFlags,
  189. IWbemContext * pCtx,
  190. IWbemCallResult ** ppCallResult) {
  191. return WBEM_E_NOT_SUPPORTED;
  192. }
  193. HRESULT STDMETHODCALLTYPE PutClassAsync(
  194. IWbemClassObject * pObject,
  195. long lFlags,
  196. IWbemContext * pCtx,
  197. IWbemObjectSink * pResponseHandler) {
  198. return WBEM_E_NOT_SUPPORTED;
  199. }
  200. HRESULT STDMETHODCALLTYPE DeleteClass(
  201. BSTR Class,
  202. long lFlags,
  203. IWbemContext * pCtx,
  204. IWbemCallResult ** ppCallResult) {
  205. return WBEM_E_NOT_SUPPORTED;
  206. }
  207. HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  208. BSTR Class,
  209. long lFlags,
  210. IWbemContext * pCtx,
  211. IWbemObjectSink * pResponseHandler) {
  212. return WBEM_E_NOT_SUPPORTED;
  213. }
  214. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  215. BSTR Superclass,
  216. long lFlags,
  217. IWbemContext * pCtx,
  218. IEnumWbemClassObject ** ppEnum) {
  219. return WBEM_E_NOT_SUPPORTED;
  220. }
  221. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  222. BSTR Superclass,
  223. long lFlags,
  224. IWbemContext * pCtx,
  225. IWbemObjectSink * pResponseHandler) {
  226. return WBEM_E_NOT_SUPPORTED;
  227. }
  228. HRESULT STDMETHODCALLTYPE PutInstance(
  229. IWbemClassObject * pInst,
  230. long lFlags,
  231. IWbemContext * pCtx,
  232. IWbemCallResult ** ppCallResult) {
  233. return WBEM_E_NOT_SUPPORTED;
  234. }
  235. HRESULT STDMETHODCALLTYPE DeleteInstance(
  236. BSTR ObjectPath,
  237. long lFlags,
  238. IWbemContext * pCtx,
  239. IWbemCallResult ** ppCallResult) {
  240. return WBEM_E_NOT_SUPPORTED;
  241. }
  242. HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  243. BSTR ObjectPath,
  244. long lFlags,
  245. IWbemContext * pCtx,
  246. IWbemObjectSink * pResponseHandler) {
  247. return WBEM_E_NOT_SUPPORTED;
  248. }
  249. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  250. BSTR Class,
  251. long lFlags,
  252. IWbemContext * pCtx,
  253. IEnumWbemClassObject ** ppEnum) {
  254. return WBEM_E_NOT_SUPPORTED;
  255. }
  256. HRESULT STDMETHODCALLTYPE ExecQuery(
  257. BSTR QueryLanguage,
  258. BSTR Query,
  259. long lFlags,
  260. IWbemContext * pCtx,
  261. IEnumWbemClassObject ** ppEnum) {
  262. return WBEM_E_NOT_SUPPORTED;
  263. }
  264. HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  265. BSTR QueryLanguage,
  266. BSTR Query,
  267. long lFlags,
  268. IWbemContext * pCtx,
  269. IWbemObjectSink * pResponseHandler) {
  270. return WBEM_E_NOT_SUPPORTED;
  271. }
  272. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  273. BSTR QueryLanguage,
  274. BSTR Query,
  275. long lFlags,
  276. IWbemContext * pCtx,
  277. IEnumWbemClassObject ** ppEnum) {
  278. return WBEM_E_NOT_SUPPORTED;
  279. }
  280. HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  281. BSTR QueryLanguage,
  282. BSTR Query,
  283. long lFlags,
  284. IWbemContext * pCtx,
  285. IWbemObjectSink * pResponseHandler) {
  286. return WBEM_E_NOT_SUPPORTED;
  287. }
  288. HRESULT STDMETHODCALLTYPE ExecMethod(
  289. BSTR ObjectPath,
  290. BSTR MethodName,
  291. long lFlags,
  292. IWbemContext * pCtx,
  293. IWbemClassObject * pInParams,
  294. IWbemClassObject ** ppOutParams,
  295. IWbemCallResult ** ppCallResult) {
  296. return WBEM_E_NOT_SUPPORTED;
  297. }
  298. };
  299. */
  300. typedef CWLBSProvider * PCWLBSProvider;
  301. // This class is the class factory for CWLBSProvider objects.
  302. class CWLBSClassFactory : public IClassFactory
  303. {
  304. protected:
  305. long m_cRef;
  306. public:
  307. CWLBSClassFactory(void);
  308. ~CWLBSClassFactory(void);
  309. //IUnknown members
  310. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  311. STDMETHODIMP_(ULONG) AddRef(void);
  312. STDMETHODIMP_(ULONG) Release(void);
  313. //IClassFactory members
  314. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID
  315. ,PPVOID);
  316. STDMETHODIMP LockServer(BOOL);
  317. };
  318. typedef CWLBSClassFactory *PCWLBSClassFactory;
  319. _COM_SMARTPTR_TYPEDEF(IWbemClassObject, _uuidof(IWbemClassObject));
  320. _COM_SMARTPTR_TYPEDEF(IWbemQualifierSet, _uuidof(IWbemQualifierSet));
  321. //Global Variables
  322. // These variables keep track of when the module can be unloaded
  323. extern long g_cComponents;
  324. extern long g_cServerLocks;
  325. //The one and only instance of the WLBS control class. All
  326. //WLBS control commands are implemented via this class.
  327. class CWlbsControlWrapper;
  328. extern CWlbsControlWrapper* g_pWlbsControl;
  329. // General purpose utilities.
  330. SCODE CreateInst( IWbemServices * pNamespace,
  331. LPWSTR pKey,
  332. long lVal,
  333. IWbemClassObject ** pNewInst,
  334. WCHAR * pwcClassName,
  335. IWbemContext * pCtx);
  336. #endif //_WLBSPROVIDER_INCLUDED_