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.

327 lines
8.4 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // objobjp.h
  6. //
  7. // alanbos 13-Feb-98 Created.
  8. //
  9. // Implementation of IWbemObjectPathEx for ISWbemObjectEx.
  10. //
  11. //***************************************************************************
  12. #ifndef _OBJOBJP_H_
  13. #define _OBJOBJP_H_
  14. class CSWbemObjectObjectPathSecurity;
  15. //***************************************************************************
  16. //
  17. // CLASS NAME:
  18. //
  19. // CSWbemObjectObjectPath
  20. //
  21. // DESCRIPTION:
  22. //
  23. // Implements the ISWbemObjectPath interface for the
  24. // ISWbemObject.Path_ property.
  25. //
  26. //***************************************************************************
  27. class CSWbemObjectObjectPath : public ISWbemObjectPath,
  28. public ISupportErrorInfo,
  29. public IProvideClassInfo
  30. {
  31. private:
  32. class CObjectObjectPathDispatchHelp : public CDispatchHelp
  33. {
  34. public:
  35. bool HandleNulls (
  36. DISPID dispidMember,
  37. unsigned short wFlags)
  38. {
  39. return false;
  40. }
  41. };
  42. IWbemClassObject *m_pIWbemClassObject;
  43. CSWbemServices *m_pSWbemServices;
  44. CObjectObjectPathDispatchHelp m_Dispatch;
  45. CWbemSite *m_pSite;
  46. CSWbemObjectObjectPathSecurity *m_pSecurity;
  47. HRESULT STDMETHODCALLTYPE GetStrVal (BSTR *value, LPWSTR name);
  48. HRESULT RaiseReadOnlyException ()
  49. {
  50. m_Dispatch.RaiseException (WBEM_E_READ_ONLY);
  51. return WBEM_E_READ_ONLY;
  52. }
  53. protected:
  54. long m_cRef; //Object reference count
  55. public:
  56. CSWbemObjectObjectPath(CSWbemServices *pSWbemServices, CSWbemObject *pSObject);
  57. ~CSWbemObjectObjectPath(void);
  58. //Non-delegating object IUnknown
  59. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  60. STDMETHODIMP_(ULONG) AddRef(void);
  61. STDMETHODIMP_(ULONG) Release(void);
  62. // IDispatch
  63. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  64. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  65. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  66. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  67. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  68. UINT cNames, LCID lcid, DISPID* rgdispid)
  69. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  70. lcid,
  71. rgdispid);}
  72. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  73. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  74. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  75. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  76. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  77. // ISWbemObjectPath methods
  78. HRESULT STDMETHODCALLTYPE get_Path(
  79. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  80. HRESULT STDMETHODCALLTYPE put_Path(
  81. /* [in] */ BSTR __RPC_FAR value)
  82. {
  83. return RaiseReadOnlyException ();
  84. }
  85. HRESULT STDMETHODCALLTYPE get_RelPath(
  86. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  87. HRESULT STDMETHODCALLTYPE put_RelPath(
  88. /* [in] */ BSTR __RPC_FAR value)
  89. {
  90. return RaiseReadOnlyException ();
  91. }
  92. HRESULT STDMETHODCALLTYPE get_DisplayName(
  93. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  94. HRESULT STDMETHODCALLTYPE put_DisplayName(
  95. /* [in] */ BSTR __RPC_FAR value)
  96. {
  97. return RaiseReadOnlyException ();
  98. }
  99. HRESULT STDMETHODCALLTYPE get_Namespace(
  100. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  101. HRESULT STDMETHODCALLTYPE put_Namespace(
  102. /* [in] */ BSTR __RPC_FAR value)
  103. {
  104. return RaiseReadOnlyException ();
  105. }
  106. HRESULT STDMETHODCALLTYPE get_ParentNamespace(
  107. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  108. HRESULT STDMETHODCALLTYPE get_Server(
  109. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  110. HRESULT STDMETHODCALLTYPE put_Server(
  111. /* [in] */ BSTR __RPC_FAR value)
  112. {
  113. return RaiseReadOnlyException ();
  114. }
  115. HRESULT STDMETHODCALLTYPE get_IsClass(
  116. /* [retval][out] */ VARIANT_BOOL __RPC_FAR *value) ;
  117. HRESULT STDMETHODCALLTYPE SetAsClass()
  118. {
  119. return RaiseReadOnlyException ();
  120. }
  121. HRESULT STDMETHODCALLTYPE get_IsSingleton(
  122. /* [retval][out] */ VARIANT_BOOL __RPC_FAR *value) ;
  123. HRESULT STDMETHODCALLTYPE SetAsSingleton()
  124. {
  125. return RaiseReadOnlyException ();
  126. }
  127. HRESULT STDMETHODCALLTYPE get_Class(
  128. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  129. HRESULT STDMETHODCALLTYPE put_Class(
  130. /* [in] */ BSTR __RPC_FAR value) ;
  131. HRESULT STDMETHODCALLTYPE get_Keys(
  132. /* [out,retval] */ ISWbemNamedValueSet **objKeys);
  133. HRESULT STDMETHODCALLTYPE get_Security_(
  134. /* [out,retval] */ ISWbemSecurity **objKeys);
  135. HRESULT STDMETHODCALLTYPE get_Locale(
  136. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  137. HRESULT STDMETHODCALLTYPE put_Locale(
  138. /* [in] */ BSTR __RPC_FAR value)
  139. {
  140. return RaiseReadOnlyException ();
  141. }
  142. HRESULT STDMETHODCALLTYPE get_Authority(
  143. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  144. HRESULT STDMETHODCALLTYPE put_Authority(
  145. /* [in] */ BSTR __RPC_FAR value)
  146. {
  147. return RaiseReadOnlyException ();
  148. }
  149. // IProvideClassInfo methods
  150. HRESULT STDMETHODCALLTYPE GetClassInfo
  151. (
  152. /* [in] */ ITypeInfo **ppTI
  153. )
  154. {
  155. return m_Dispatch.GetClassInfo (ppTI);
  156. }
  157. // ISupportErrorInfo methods
  158. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  159. (
  160. /* [in] */ REFIID riid
  161. );
  162. };
  163. //***************************************************************************
  164. //
  165. // CLASS NAME:
  166. //
  167. // CSWbemObjectObjectPathSecurity
  168. //
  169. // DESCRIPTION:
  170. //
  171. // Implements the ISWbemSecurity interface for CSWbemObjectObjectPath.
  172. //
  173. //***************************************************************************
  174. class CSWbemObjectObjectPathSecurity : public ISWbemSecurity,
  175. public ISupportErrorInfo,
  176. public IProvideClassInfo
  177. {
  178. private:
  179. CSWbemPrivilegeSet *m_pPrivilegeSet;
  180. CDispatchHelp m_Dispatch;
  181. WbemImpersonationLevelEnum m_dwImpLevel;
  182. WbemAuthenticationLevelEnum m_dwAuthnLevel;
  183. BSTR m_bsAuthority;
  184. HRESULT RaiseReadOnlyException ()
  185. {
  186. m_Dispatch.RaiseException (WBEM_E_READ_ONLY);
  187. return WBEM_E_READ_ONLY;
  188. }
  189. protected:
  190. long m_cRef; //Object reference count
  191. public:
  192. CSWbemObjectObjectPathSecurity (CSWbemServices *pSWbemServices);
  193. virtual ~CSWbemObjectObjectPathSecurity (void);
  194. //Non-delegating object IUnknown
  195. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  196. STDMETHODIMP_(ULONG) AddRef(void);
  197. STDMETHODIMP_(ULONG) Release(void);
  198. // IDispatch
  199. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  200. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  201. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  202. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  203. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  204. UINT cNames, LCID lcid, DISPID* rgdispid)
  205. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  206. lcid,
  207. rgdispid);}
  208. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  209. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  210. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  211. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  212. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  213. // ISWbemSecurity methods
  214. HRESULT STDMETHODCALLTYPE get_ImpersonationLevel
  215. (
  216. /* [out] */ WbemImpersonationLevelEnum *iImpersonationLevel
  217. );
  218. HRESULT STDMETHODCALLTYPE put_ImpersonationLevel
  219. (
  220. /* [in] */ WbemImpersonationLevelEnum iImpersonationLevel
  221. )
  222. {
  223. return RaiseReadOnlyException ();
  224. }
  225. HRESULT STDMETHODCALLTYPE get_AuthenticationLevel
  226. (
  227. /* [out] */ WbemAuthenticationLevelEnum *iAuthenticationLevel
  228. );
  229. HRESULT STDMETHODCALLTYPE put_AuthenticationLevel
  230. (
  231. /* [in] */ WbemAuthenticationLevelEnum iAuthenticationLevel
  232. )
  233. {
  234. return RaiseReadOnlyException ();
  235. }
  236. HRESULT STDMETHODCALLTYPE get_Privileges
  237. (
  238. /* [out] */ ISWbemPrivilegeSet **objWbemPrivileges
  239. );
  240. // ISupportErrorInfo methods
  241. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  242. (
  243. /* [in] */ REFIID riid
  244. );
  245. // IProvideClassInfo methods
  246. HRESULT STDMETHODCALLTYPE GetClassInfo
  247. (
  248. /* [in] */ ITypeInfo **ppTI
  249. )
  250. {
  251. return m_Dispatch.GetClassInfo (ppTI);
  252. }
  253. // Other methods
  254. CSWbemPrivilegeSet *GetPrivilegeSet ()
  255. {
  256. CSWbemPrivilegeSet *pPrivSet = m_pPrivilegeSet;
  257. if (pPrivSet)
  258. pPrivSet->AddRef ();
  259. return pPrivSet;
  260. }
  261. BSTR &GetAuthority ()
  262. {
  263. return m_bsAuthority;
  264. }
  265. };
  266. #endif