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.

256 lines
7.8 KiB

  1. //***************************************************************************
  2. //
  3. // File:
  4. //
  5. // Module: MS SNMP Provider
  6. //
  7. // Purpose:
  8. //
  9. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #ifndef _CSMIR_H_
  13. #define _CSMIR_H_
  14. class CSmir;
  15. class CSmirConnObject;
  16. #include "smir.h"
  17. #include "csmirdef.h"
  18. #include "thread.h"
  19. #include "cthread.h"
  20. #include "smirevt.h"
  21. class CSmirWbemConfiguration ;
  22. class CSmirAdministrator;
  23. class CGroupToClassAssociator;
  24. class CModuleToClassAssociator;
  25. class CXToClassAssociator;
  26. class CSMIRToClassAssociator;
  27. class CSmirNotificationClassHandle;
  28. class CSmirExtNotificationClassHandle;
  29. class CSmirSerialiseHandle : public ISmirSerialiseHandle
  30. {
  31. private:
  32. friend CSmirAdministrator;
  33. friend CSmirGroupHandle;
  34. friend CSmirModuleHandle;
  35. friend CSmirClassHandle;
  36. friend CSmirNotificationClassHandle;
  37. friend CSmirExtNotificationClassHandle;
  38. CString m_serialiseString;
  39. LONG m_cRef;
  40. BOOL m_bMOFPragmas;
  41. BOOL m_bMOFAssociations;
  42. public:
  43. //IUnknown members
  44. STDMETHODIMP QueryInterface(IN REFIID, OUT PPVOID);
  45. STDMETHODIMP_(ULONG) AddRef();
  46. STDMETHODIMP_(ULONG) Release();
  47. STDMETHODIMP GetText (OUT BSTR *);
  48. CSmirSerialiseHandle(BOOL bClassDefinitionsOnly);
  49. virtual ~CSmirSerialiseHandle(){}
  50. private:
  51. //private copy constructors to prevent bcopy
  52. CSmirSerialiseHandle(CSmirSerialiseHandle&);
  53. const CSmirSerialiseHandle& operator=(CSmirSerialiseHandle &);
  54. BOOL ReturnMOFPragmas(){return m_bMOFPragmas;};
  55. BOOL ReturnMOFAssociations(){return m_bMOFAssociations;};
  56. };
  57. class CSmirInterrogator : public ISmirInterrogator
  58. {
  59. private:
  60. LONG m_cRef;
  61. CSmir *m_pSmir;
  62. #ifdef IMPLEMENTED_AS_SEPERATE_PROCESS
  63. CMutex criticalSection(FALSE,SMIR_CSMIR_INTERROGATOR_MUTEX) ;
  64. #else
  65. CCriticalSection criticalSection ;
  66. #endif
  67. public:
  68. CSmirInterrogator () ;
  69. //IUnknown members
  70. STDMETHODIMP QueryInterface(IN REFIID, OUT PPVOID);
  71. STDMETHODIMP_(ULONG) AddRef();
  72. STDMETHODIMP_(ULONG) Release();
  73. // interrogative interface
  74. STDMETHODIMP EnumModules (OUT IEnumModule **ppEnumSmirMod);
  75. STDMETHODIMP EnumGroups (OUT IEnumGroup **ppEnumSmirGroup, IN ISmirModHandle *hModule);
  76. STDMETHODIMP EnumAllClasses (OUT IEnumClass **ppEnumSmirclass);
  77. STDMETHODIMP EnumClassesInGroup (OUT IEnumClass **ppEnumSmirclass, IN ISmirGroupHandle *hGroup);
  78. STDMETHODIMP EnumClassesInModule (OUT IEnumClass **ppEnumSmirclass, IN ISmirModHandle *hModule);
  79. STDMETHODIMP GetWBEMClass (OUT IWbemClassObject **pObj, IN BSTR pszClassName);
  80. STDMETHODIMP EnumAllNotificationClasses(IEnumNotificationClass **ppEnumSmirclass);
  81. STDMETHODIMP EnumAllExtNotificationClasses(IEnumExtNotificationClass **ppEnumSmirclass);
  82. STDMETHODIMP EnumNotificationClassesInModule(IEnumNotificationClass **ppEnumSmirclass, ISmirModHandle *hModule);
  83. STDMETHODIMP EnumExtNotificationClassesInModule(IEnumExtNotificationClass **ppEnumSmirclass, ISmirModHandle *hModule);
  84. CSmirInterrogator(CSmir *pSmir);
  85. virtual ~CSmirInterrogator(){}
  86. private:
  87. //private copy constructors to prevent bcopy
  88. CSmirInterrogator(CSmirInterrogator&);
  89. const CSmirInterrogator& operator=(CSmirInterrogator &);
  90. };
  91. class CSmirAdministrator : public ISmirAdministrator
  92. {
  93. private:
  94. LONG m_cRef;
  95. CSmir *m_pSmir;
  96. #ifdef IMPLEMENTED_AS_SEPERATE_PROCESS
  97. CMutex criticalSection(FALSE,SMIR_CSMIR_ADMINISTRATOR_MUTEX) ;
  98. #else
  99. CCriticalSection criticalSection ;
  100. #endif
  101. public:
  102. CSmirAdministrator () ;
  103. //IUnknown members
  104. STDMETHODIMP QueryInterface(IN REFIID, OUT PPVOID);
  105. STDMETHODIMP_(ULONG) AddRef();
  106. STDMETHODIMP_(ULONG) Release();
  107. STDMETHODIMP CreateWBEMClass(IN BSTR pszClassName, OUT ISmirClassHandle **pHandle);
  108. STDMETHODIMP CreateWBEMNotificationClass ( IN BSTR pszClassName, OUT ISmirNotificationClassHandle **pHandle ) ;
  109. STDMETHODIMP CreateWBEMExtNotificationClass ( IN BSTR pszClassName, OUT ISmirExtNotificationClassHandle **pHandle ) ;
  110. //administrative interface
  111. STDMETHODIMP AddModule(IN ISmirModHandle *hModule);
  112. STDMETHODIMP DeleteModule(IN ISmirModHandle *hModule);
  113. STDMETHODIMP DeleteAllModules();
  114. STDMETHODIMP AddGroup(IN ISmirModHandle *hModule, IN ISmirGroupHandle *hGroup);
  115. STDMETHODIMP DeleteGroup(ISmirGroupHandle *hGroup);
  116. STDMETHODIMP AddClass(IN ISmirGroupHandle *hGroup, IN ISmirClassHandle *hClass);
  117. STDMETHODIMP DeleteClass(IN ISmirClassHandle *hClass);
  118. STDMETHODIMP GetSerialiseHandle(ISmirSerialiseHandle **hSerialise, BOOL bClassDefinitionsOnly);
  119. STDMETHODIMP AddModuleToSerialise(ISmirModHandle *hModule,ISmirSerialiseHandle *hSerialise);
  120. STDMETHODIMP AddGroupToSerialise(ISmirModHandle *hModule, ISmirGroupHandle *hGroup,ISmirSerialiseHandle *hSerialise);
  121. STDMETHODIMP AddClassToSerialise(ISmirGroupHandle *hGroup, ISmirClassHandle *hClass,ISmirSerialiseHandle *hSerialise);
  122. STDMETHODIMP AddNotificationClass(ISmirNotificationClassHandle *hClass);
  123. STDMETHODIMP AddExtNotificationClass(ISmirExtNotificationClassHandle *hClass);
  124. STDMETHODIMP DeleteNotificationClass(ISmirNotificationClassHandle *hClass);
  125. STDMETHODIMP DeleteExtNotificationClass(ISmirExtNotificationClassHandle *hClass);
  126. STDMETHODIMP AddNotificationClassToSerialise(ISmirNotificationClassHandle *hClass, ISmirSerialiseHandle *hSerialise);
  127. STDMETHODIMP AddExtNotificationClassToSerialise(ISmirExtNotificationClassHandle *hClass, ISmirSerialiseHandle *hSerialise);
  128. CSmirAdministrator(CSmir *pSmir) ;
  129. virtual ~CSmirAdministrator(){}
  130. private:
  131. //private copy constructors to prevent bcopy
  132. CSmirAdministrator(CSmirAdministrator&);
  133. const CSmirAdministrator& operator=(CSmirAdministrator &);
  134. };
  135. class CSmirWbemConfiguration : public ISMIRWbemConfiguration
  136. {
  137. private:
  138. LONG m_ReferenceCount ;
  139. CSmir *m_Smir ;
  140. IWbemContext *m_Context ;
  141. IWbemServices *m_Service ;
  142. protected:
  143. public:
  144. CSmirWbemConfiguration ( CSmir *a_Smir ) ;
  145. ~CSmirWbemConfiguration () ;
  146. //IUnknown methods
  147. //=================
  148. STDMETHODIMP QueryInterface(IN REFIID riid,OUT PPVOID ppv);
  149. STDMETHODIMP_(ULONG) AddRef();
  150. STDMETHODIMP_(ULONG) Release();
  151. STDMETHODIMP Authenticate (
  152. BSTR Server,
  153. BSTR User,
  154. BSTR Password,
  155. BSTR Locale,
  156. long lSecurityFlags,
  157. BSTR Authority ,
  158. BOOL InProc
  159. ) ;
  160. STDMETHODIMP Impersonate ( ISMIRWbemConfiguration *a_Configuration ) ;
  161. STDMETHODIMP SetContext ( IWbemContext *a_Context ) ;
  162. STDMETHODIMP GetContext ( IWbemContext **a_Context ) ;
  163. STDMETHODIMP GetServices ( IWbemServices **a_Service ) ;
  164. } ;
  165. class CSmir : public ISmirDatabase
  166. {
  167. private:
  168. friend CSmirInterrogator;
  169. friend CSmirAdministrator;
  170. friend CSmirConnObject;
  171. #ifdef IMPLEMENTED_AS_SEPERATE_PROCESS
  172. CMutex criticalSection(FALSE,SMIR_CSMIR_MUTEX) ;
  173. #else
  174. CCriticalSection criticalSection ;
  175. #endif
  176. LONG m_cRef;
  177. CSmirInterrogator m_Interrogator;
  178. CSmirAdministrator m_Administrator;
  179. CSmirWbemConfiguration m_Configuration ;
  180. public:
  181. static CSmirConnObject* sm_ConnectionObjects;
  182. //IUnknown members
  183. STDMETHODIMP QueryInterface(IN REFIID, OUT PPVOID);
  184. STDMETHODIMP_(ULONG) AddRef();
  185. STDMETHODIMP_(ULONG) Release();
  186. STDMETHODIMP AddNotify(IN ISMIRNotify *hNotify, OUT DWORD *);
  187. STDMETHODIMP DeleteNotify(IN DWORD);
  188. CSmir();
  189. virtual ~CSmir();
  190. private:
  191. //private copy constructors to prevent bcopy
  192. CSmir(CSmir&);
  193. const CSmir& operator=(CSmir &);
  194. };
  195. //structure used to pass arguments to the async class enumerator function
  196. typedef struct
  197. {
  198. CSmirConnObject *ConnectionObjects;
  199. ISmirModHandle *hModule;
  200. ISmirGroupHandle *hGroup;
  201. IConnectionPoint *pCP;
  202. DWORD dwCookie;
  203. } EnumClassAsyncArgStruct;
  204. #endif