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.

275 lines
9.6 KiB

  1. /******************************************************************
  2. SNetScal.cpp -- WBEM provider class implementation
  3. MODULE:
  4. DhcpProv.dll
  5. DESCRIPTION:
  6. Contains: the definition of the DHCP_SuperScope class,
  7. the static table of manageable objects.
  8. REVISION:
  9. 08/03/98 - created
  10. ******************************************************************/
  11. #include <stdafx.h>
  12. #include "SScoFn.h" // needed for the declarations of all the functions.
  13. #include "SScoScal.h" // own header
  14. // the name of the WBEM class
  15. #define PROVIDER_NAME_DHCP_SUPERSCOPE "DHCP_SuperScope"
  16. #define PROP_SScope_Name L"Name"
  17. // main class instantiation.
  18. CDHCP_SuperScope MyDHCP_SuperScope_Scalars (PROVIDER_NAME_DHCP_SUPERSCOPE, PROVIDER_NAMESPACE_DHCP) ;
  19. /*****************************************************************************
  20. *
  21. * FUNCTION : CDHCP_SuperScope::CDHCP_SuperScope
  22. *
  23. * DESCRIPTION : Constructor
  24. *
  25. * INPUTS : none
  26. *
  27. * RETURNS : nothing
  28. *
  29. * COMMENTS : Calls the Provider constructor.
  30. *
  31. *****************************************************************************/
  32. CDHCP_SuperScope::CDHCP_SuperScope (const CHString& strName, LPCSTR pszNameSpace ) :
  33. Provider(strName, pszNameSpace)
  34. {
  35. }
  36. /*****************************************************************************
  37. *
  38. * FUNCTION : CDHCP_SuperScope::~CDHCP_SuperScope
  39. *
  40. * DESCRIPTION : Destructor
  41. *
  42. * INPUTS : none
  43. *
  44. * RETURNS : nothing
  45. *
  46. * COMMENTS :
  47. *
  48. *****************************************************************************/
  49. CDHCP_SuperScope::~CDHCP_SuperScope ()
  50. {
  51. }
  52. /*****************************************************************************
  53. *
  54. * FUNCTION : CDHCP_SuperScope::EnumerateInstances
  55. *
  56. * DESCRIPTION : Returns all the instances of this class.
  57. *
  58. * INPUTS : none
  59. *
  60. * RETURNS : WBEM_S_NO_ERROR if successful
  61. *
  62. * COMMENTS : Enumerates all this instances of this class. As there is only one
  63. * DHCP Server per system, there is only one instance for this class
  64. *
  65. *****************************************************************************/
  66. HRESULT CDHCP_SuperScope::EnumerateInstances ( MethodContext* pMethodContext, long lFlags )
  67. {
  68. CDHCP_SuperScope_Parameters SuperScopeParams(NULL); // don't know here the scope
  69. HRESULT hRes = WBEM_E_FAILED;
  70. LPDHCP_SUPER_SCOPE_TABLE pScopesTable;
  71. LPDHCP_SUPER_SCOPE_TABLE_ENTRY *pSortedEntries = NULL ;
  72. DWORD dwNumEntries;
  73. if (SuperScopeParams.GetSuperScopes(pScopesTable, TRUE) &&
  74. SuperScopeParams.GetSortedScopes(ENTRIES_SORTED_ON_SUPER_SCOPE, pSortedEntries, dwNumEntries))
  75. {
  76. for (int i = 0; i<dwNumEntries; i++)
  77. {
  78. if(pSortedEntries[i]->SuperScopeName != NULL &&
  79. (i == 0 || pSortedEntries[i]->SuperScopeNumber != pSortedEntries[i-1]->SuperScopeNumber))
  80. {
  81. CInstance *pInstance = CreateNewInstance(pMethodContext); // create now the instance;
  82. if (pInstance != NULL)
  83. {
  84. pInstance->SetCHString(PROP_SScope_Name, pSortedEntries[i]->SuperScopeName);
  85. hRes = Commit(pInstance);
  86. if (hRes != WBEM_S_NO_ERROR)
  87. break;
  88. }
  89. }
  90. }
  91. }
  92. return hRes;
  93. }
  94. /*****************************************************************************
  95. *
  96. * FUNCTION : CDHCP_SuperScope::GetObject
  97. *
  98. * DESCRIPTION : Find a single instance based on the key properties for the
  99. * class.
  100. *
  101. * INPUTS : A pointer to a CInstance object containing the key properties.
  102. *
  103. * RETURNS : WBEM_S_NO_ERROR if the instance can be found
  104. * WBEM_E_NOT_FOUND if the instance described by the key properties
  105. * could not be found
  106. * WBEM_E_FAILED if the instance could be found but another error
  107. * occurred.
  108. *
  109. * COMMENTS :
  110. *
  111. *****************************************************************************/
  112. HRESULT CDHCP_SuperScope::GetObject ( CInstance* pInstance, long lFlags )
  113. {
  114. CHString str;
  115. if (pInstance->GetCHString(PROP_SScope_Name, str))
  116. {
  117. CDHCP_SuperScope_Parameters SuperScopeParams(str);
  118. if (SuperScopeParams.ExistsSuperScope())
  119. {
  120. return WBEM_S_NO_ERROR;
  121. }
  122. }
  123. return WBEM_E_NOT_FOUND;
  124. }
  125. /*****************************************************************************
  126. *
  127. * FUNCTION : CDHCP_SuperScope::ExecQuery
  128. *
  129. * DESCRIPTION : You are passed a method context to use in the creation of
  130. * instances that satisfy the query, and a CFrameworkQuery
  131. * which describes the query. Create and populate all
  132. * instances which satisfy the query. CIMOM will post -
  133. * filter the query for you, you may return more instances
  134. * or more properties than are requested and CIMOM
  135. * will filter out any that do not apply.
  136. *
  137. *
  138. * INPUTS :
  139. *
  140. * RETURNS : WBEM_E_PROVIDER_NOT_CAPABLE if not supported for this class
  141. * WBEM_E_FAILED if the query failed
  142. * WBEM_S_NO_ERROR if query was successful
  143. *
  144. * COMMENTS : TO DO: Most providers will not need to implement this method. If you don't, cimom
  145. * will call your enumerate function to get all the instances and perform the
  146. * filtering for you. Unless you expect SIGNIFICANT savings from implementing
  147. * queries, you should remove this entire method.
  148. *
  149. *****************************************************************************/
  150. HRESULT CDHCP_SuperScope::ExecQuery (MethodContext *pMethodContext, CFrameworkQuery& Query, long lFlags)
  151. {
  152. return WBEM_E_PROVIDER_NOT_CAPABLE;
  153. }
  154. /*****************************************************************************
  155. *
  156. * FUNCTION : CDHCP_SuperScope::PutInstance
  157. *
  158. * DESCRIPTION : PutInstance should be used in provider classes that can write
  159. * instance information back to the hardware or software.
  160. * For example: Win32_Environment will allow a PutInstance of a new
  161. * environment variable, because environment variables are "software"
  162. * related. However, a class like Win32_MotherboardDevice will not
  163. * allow editing of the bus speed. Since by default PutInstance
  164. * returns WBEM_E_PROVIDER_NOT_CAPABLE, this function is placed here as a
  165. * skeleton, but can be removed if not used.
  166. *
  167. * INPUTS :
  168. *
  169. * RETURNS : WBEM_E_PROVIDER_NOT_CAPABLE if PutInstance is not available
  170. * WBEM_E_FAILED if there is an error delivering the instance
  171. * WBEM_E_INVALID_PARAMETER if any of the instance properties
  172. * are incorrect.
  173. * WBEM_S_NO_ERROR if instance is properly delivered
  174. *
  175. * COMMENTS : TO DO: If you don't intend to support writing to your provider, remove this method.
  176. *
  177. *****************************************************************************/
  178. HRESULT CDHCP_SuperScope::PutInstance ( const CInstance &Instance, long lFlags)
  179. {
  180. return WBEM_E_PROVIDER_NOT_CAPABLE;
  181. }
  182. /*****************************************************************************
  183. *
  184. * FUNCTION : CDHCP_SuperScope::DeleteInstance
  185. *
  186. * DESCRIPTION : DeleteInstance, like PutInstance, actually writes information
  187. * to the software or hardware. For most hardware devices,
  188. * DeleteInstance should not be implemented, but for software
  189. * configuration, DeleteInstance implementation is plausible.
  190. * Like PutInstance, DeleteInstance returns WBEM_E_PROVIDER_NOT_CAPABLE from
  191. * inside Provider::DeleteInstance (defined in Provider.h). So, if
  192. * you choose not to implement DeleteInstance, remove this function
  193. * definition and the declaration from DHCP_Server_Scalars.h
  194. *
  195. * INPUTS :
  196. *
  197. * RETURNS : WBEM_E_PROVIDER_NOT_CAPABLE if DeleteInstance is not available.
  198. * WBEM_E_FAILED if there is an error deleting the instance.
  199. * WBEM_E_INVALID_PARAMETER if any of the instance properties
  200. * are incorrect.
  201. * WBEM_S_NO_ERROR if instance is properly deleted.
  202. *
  203. * COMMENTS : TO DO: If you don't intend to support deleting instances, remove this method.
  204. *
  205. *****************************************************************************/
  206. HRESULT CDHCP_SuperScope::DeleteInstance ( const CInstance &Instance, long lFlags )
  207. {
  208. CHString str;
  209. if (Instance.GetCHString(PROP_SScope_Name, str))
  210. {
  211. CDHCP_SuperScope_Parameters SuperScopeParams(str);
  212. if (SuperScopeParams.DeleteSuperScope())
  213. {
  214. return WBEM_S_NO_ERROR;
  215. }
  216. }
  217. return WBEM_E_FAILED;
  218. }
  219. /*****************************************************************************
  220. *
  221. * FUNCTION : CDHCP_SuperScope::ExecMethod
  222. *
  223. * DESCRIPTION : Override this function to provide support for methods.
  224. * A method is an entry point for the user of your provider
  225. * to request your class perform some function above and
  226. * beyond a change of state. (A change of state should be
  227. * handled by PutInstance() )
  228. *
  229. * INPUTS : A pointer to a CInstance containing the instance the method was executed against.
  230. * A string containing the method name
  231. * A pointer to the CInstance which contains the IN parameters.
  232. * A pointer to the CInstance to contain the OUT parameters.
  233. * A set of specialized method flags
  234. *
  235. * RETURNS : WBEM_E_PROVIDER_NOT_CAPABLE if not implemented for this class
  236. * WBEM_S_NO_ERROR if method executes successfully
  237. * WBEM_E_FAILED if error occurs executing method
  238. *
  239. * COMMENTS : TO DO: If you don't intend to support Methods, remove this method.
  240. *
  241. *****************************************************************************/
  242. HRESULT CDHCP_SuperScope::ExecMethod ( const CInstance& Instance,
  243. const BSTR bstrMethodName,
  244. CInstance *pInParams,
  245. CInstance *pOutParams,
  246. long lFlags)
  247. {
  248. return WBEM_E_PROVIDER_NOT_CAPABLE;
  249. }