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.

217 lines
10 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // Purpose: WmiOleDBMap.h: interface for the CWmiOleDBMap class.
  7. //
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WMIOLEDBMAP_HEADER
  11. #define _WMIOLEDBMAP_HEADER
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif // _MSC_VER > 1000
  15. #include "headers.h"
  16. const WCHAR strIndex[] = L"Index";
  17. class CQuery;
  18. #define ALL_QUALIFIERS 0x00000003
  19. #define NO_QUALIFIERS 0x00000000
  20. #define CLASS_QUALIFIERS 0x00000001
  21. #define PROPERTY_QUALIFIERS 0x00000002
  22. #define QUALIFIER_ L"Qualifier_"
  23. #define DEFAULT_QUALIFIER_COUNT 10
  24. #define WMI_CLASS_QUALIFIER 1
  25. #define WMI_PROPERTY_QUALIFIER 2
  26. #define WMI_PROPERTY 3
  27. const CIM_OBJECTARRAY= CIM_FLAG_ARRAY | CIM_OBJECT ;
  28. class cRowColumnInfoMemMgr;
  29. class CRowDataMemMgr;
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. class CWmiOleDBMap
  32. {
  33. private:
  34. CWbemClassParameters * m_pWbemClassParms; // Common class information, such as name, context
  35. CWbemClassDefinitionWrapper * m_pWbemClassDefinition; // Just class definitions
  36. CWbemInstanceList * m_paWbemClassInstances; // Just instance info
  37. CWbemCommandManager * m_pWbemCommandManager; // To manage commands
  38. CWbemCollectionManager * m_pWbemCollectionManager;
  39. CWbemClassWrapper * m_pWbemCurInst;
  40. ULONG m_cRef;
  41. BOOL m_bMethodRowset;
  42. CPropertyMemoryMgr m_PropMemMgr;
  43. BOOL ParseQualifiedName(WCHAR * Root, WCHAR *& Parent, WCHAR *& Child );
  44. HRESULT ValidProperty(const DBCOLUMNDESC * prgColDesc);
  45. HRESULT MapDBPROPToStdPropertyQualifier( DBPROP pProp, CVARIANT & Qualifier, CVARIANT & Value, LONG & lFlavor );
  46. HRESULT MapDBPROPToStdClassQualifier( DBPROP pProp, CVARIANT & Qualifier, CVARIANT & Value, LONG & uFlavor );
  47. HRESULT SetWMIProperty(const DBCOLUMNDESC* prgColDesc);
  48. HRESULT SetWMIClassQualifier(const DBCOLUMNDESC * prgColDesc,BOOL bDefault = TRUE);
  49. HRESULT SetWMIPropertyQualifier(const DBCOLUMNDESC * prgColDesc,BOOL bDefault = TRUE);
  50. HRESULT GetPropertyColumnInfo( cRowColumnInfoMemMgr * pColumn, DBCOLUMNINFO ** pCol,CBSTR & pProperty,LONG &lFlavor);
  51. // HRESULT GetNextPropertyQualifier( CWbemClassWrapper *pInst,BSTR &strPropName,CVARIANT &vValue, LONG &lType);
  52. HRESULT GetProperties(CRowDataMemMgr * pRow,CWbemClassWrapper * pClass,cRowColumnInfoMemMgr *pColInfoMgr);
  53. HRESULT GetEmbededObjects(CWbemClassInstanceWrapper * pClass,BSTR strProperty,CVARIANT &vValue);
  54. HRESULT CommitRowDataForQualifier(CRowDataMemMgr * pRow,BSTR strQualifier,CVARIANT &vValue, ULONG lType, ULONG lFlavor);
  55. void GenerateURL(CWbemClassInstanceWrapper * pClass,BSTR strProperty,ULONG nIndex,CBSTR &strIn);
  56. void GetDefaultValue(const DBCOLUMNDESC * prgColDesc, VARIANT & varDefault);
  57. HRESULT SetColumns( const DBORDINAL cColumnDescs, const DBCOLUMNDESC rgColumnDescs[]);
  58. HRESULT GetPropertyColumnInfoForMixedRowsets( cRowColumnInfoMemMgr * pColumn, DBCOLUMNINFO ** pCol);
  59. void SetColumnTypeURL(DBCOLUMNINFO * pCol)
  60. {
  61. pCol->dwFlags |= DBCOLUMNFLAGS_ISROWURL;
  62. }
  63. public:
  64. // CWmiOleDBMap(DWORD dwFlags, IDispatch *pDisp,CWbemConnectionWrapper * pWrap);
  65. /* CWmiOleDBMap(int nSchemaType, DWORD dwFlags, WCHAR * pClassName, WCHAR * pSpecificTable, CWbemConnectionWrapper * Connect);
  66. CWmiOleDBMap(DWORD dwFlags, WCHAR * pClassName, CWbemConnectionWrapper * Connect,BOOL fSchema = FALSE);
  67. CWmiOleDBMap(DWORD dwFlags, CQuery* p, CWbemConnectionWrapper * Connect);
  68. CWmiOleDBMap(DWORD dwFlags, WCHAR * pObjectPath, CWbemConnectionWrapper * Connect,INSTANCELISTTYPE instListType);
  69. */ CWmiOleDBMap();
  70. HRESULT FInit(int nSchemaType, DWORD dwFlags, WCHAR * pClassName, WCHAR * pSpecificTable, CWbemConnectionWrapper * Connect);
  71. HRESULT FInit(DWORD dwFlags, WCHAR * pClassName, CWbemConnectionWrapper * Connect);
  72. HRESULT FInit(DWORD dwFlags, CQuery* p, CWbemConnectionWrapper * Connect);
  73. HRESULT FInit(DWORD dwFlags, WCHAR * pObjectPath, CWbemConnectionWrapper * Connect,INSTANCELISTTYPE instListType);
  74. ~CWmiOleDBMap();
  75. //===================================================================================
  76. //
  77. //===================================================================================
  78. HRESULT CreateTable( DBORDINAL cColumnDescs, const DBCOLUMNDESC rgColumnDescs[],
  79. ULONG cPropertySets, DBPROPSET rgPropertySets[]);
  80. HRESULT AddColumn(const DBCOLUMNDESC* prgColDesc, DBID** ppColumnID);
  81. HRESULT DropColumn(const DBID* pColumnID);
  82. HRESULT SetCommonDBCOLUMNINFO(DBCOLUMNINFO ** pCol,DBORDINAL uCurrentIndex);
  83. void SetColumnReadOnly(DBCOLUMNINFO * pCol, BOOL bReadOnly);
  84. HRESULT GetQualifiedNameColumnInfo( cRowColumnInfoMemMgr * pParentCol,DBCOLUMNINFO ** pCol, WCHAR * pName);
  85. HRESULT DropTable();
  86. HRESULT GetColumnCount( DBCOUNTITEM & cTotalColumns,DBCOUNTITEM & cParentColumns,DBCOUNTITEM &cNestedCols);
  87. HRESULT GetColumnInfoForParentColumns(cRowColumnInfoMemMgr * pParentCol);
  88. HRESULT ResetInstances();
  89. HRESULT ResetInstancesToNewPosition(DBROWOFFSET);
  90. HRESULT GetNextInstance(CWbemClassWrapper *&ppInst, CBSTR &strKey ,BOOL bFetchBack);
  91. HRESULT GetDataForInstance(CRowDataMemMgr * pRow,CWbemClassWrapper *pInst,cRowColumnInfoMemMgr *pColInfoMgr);
  92. HRESULT GetDataForSchemaInstance(CRowDataMemMgr * pRow,CWbemClassWrapper *pInst,cRowColumnInfoMemMgr *pColInfoMgr);
  93. HRESULT GetPropertyQualifier(BSTR strPropName, BSTR strQualifierName ,VARIANT &vValue);
  94. BOOL IsPropQualiferIncluded();
  95. HRESULT GetDataForPropertyQualifier(CRowDataMemMgr * pRow,CWbemClassWrapper *pInst,BSTR strPropName, BSTR strQualifier, cRowColumnInfoMemMgr *pColInfoMgr);
  96. BOOL IsSystemProperty(BSTR strProperty);
  97. HRESULT GetNextPropertyQualifier(CWbemClassWrapper *pInst,BSTR strPropName,BSTR &strQualifier,BOOL bFetchBack = FALSE);
  98. HRESULT ResetPropQualiferToNewPosition(CWbemClassWrapper *pInst,DBROWOFFSET lRowOffset,BSTR strPropertyName);
  99. HRESULT GetNextClassQualifier(CWbemClassWrapper *pInst,BSTR &strQualifier,BOOL bFetchBack = FALSE);
  100. HRESULT GetDataForClassQualifier(CRowDataMemMgr * pRow,CWbemClassWrapper *pInst, BSTR strQualifier, cRowColumnInfoMemMgr *pColInfoMgr);
  101. HRESULT ResetClassQualiferToNewPosition(CWbemClassWrapper *pInst,DBROWOFFSET lRowOffset);
  102. HRESULT DeleteInstance(CWbemClassWrapper * pClass );
  103. HRESULT UpdateInstance(CWbemClassWrapper *pInst , BOOL bNewInst);
  104. HRESULT AddNewInstance(CWbemClassWrapper ** ppClass );
  105. HRESULT RefreshInstance(CWbemClassWrapper * pInstance );
  106. void ReleaseAllQualifiers(CWbemClassWrapper *pInst) {pInst->ReleaseAllPropertyQualifiers(); }
  107. void ReleaseQualifier(CWbemClassWrapper *pInst,BSTR strQualifier);
  108. WCHAR * GetClassName();
  109. void SetNavigationFlags(DWORD dwFlags);
  110. void SetQueryFlags(DWORD dwFlags);
  111. HRESULT DeleteQualifier(CWbemClassWrapper *pInst,
  112. BSTR strQualifierName,
  113. BOOL bClassQualifier = TRUE ,
  114. BSTR strPropertyName = NULL);
  115. HRESULT SetProperty(CWbemClassWrapper *pInst,BSTR bstrColName,VARIANT *pvarData)
  116. {
  117. return pInst->SetProperty(bstrColName,pvarData);
  118. }
  119. HRESULT SetQualifier(CWbemClassWrapper *pInst,BSTR bstrColName,BSTR bstrQualifier ,VARIANT *pvarData,LONG lFlavor);
  120. DWORD GetFlags() { return m_pWbemClassParms->GetFlags(); }
  121. HRESULT GetProperty(CWbemClassWrapper *pInst,BSTR pProperty, BYTE *& pData,DBTYPE &dwType ,DBLENGTH & dwSize, DWORD &dwFlags );
  122. // This method is to be called before fetching any instance
  123. HRESULT SetClass(WCHAR *pClassName) {return m_pWbemClassDefinition->SetClass(pClassName); }
  124. CWbemClassWrapper *GetInstance(BSTR strPath);
  125. void GetInstanceKey(CWbemClassWrapper *pInst, CBSTR &strPath){ ((CWbemClassInstanceWrapper *)pInst)->GetKey(strPath);}
  126. CWbemClassWrapper *GetEmbededInstance(BSTR strPath,BSTR strProperty,int nIndex);
  127. HRESULT GetKeyPropertyNames( SAFEARRAY **ppsaNames) { return m_pWbemClassDefinition->GetKeyPropertyNames(ppsaNames); }
  128. int ParseQualifiedNameToGetColumnType(WCHAR * wcsName );
  129. HRESULT CWmiOleDBMap::GetInstanceCount(ULONG_PTR &lInstanceCount)
  130. {
  131. return m_paWbemClassInstances->GetNumberOfInstanceInEnumerator(&lInstanceCount);
  132. // return m_pWbemClassDefinition->GetInstanceCount(lInstanceCount);
  133. }
  134. HRESULT AddPropertyQualifier(CWbemClassWrapper *pInst,BSTR pProperty, BSTR Qualifier, VARIANT * vValue, LONG Flavor)
  135. {
  136. return pInst->SetPropertyQualifier(pProperty,Qualifier, vValue, Flavor);
  137. }
  138. HRESULT SetColumnProperties(const DBCOLUMNDESC * prgColDesc);
  139. HRESULT AddIndex(const DBID* pColumnID);
  140. HRESULT DropIndex(const DBID* pColumnID);
  141. HRESULT UnlinkObjectFromContainer(BSTR strContainerObj,BSTR pstrObject);
  142. HRESULT LinkObjectFromContainer(BSTR strContainerObj,BSTR pstrObject);
  143. HRESULT CloneAndAddNewObjectInScope(BSTR strObj, BSTR strScope,WCHAR *& pstrNewPath);
  144. void SetSytemPropertiesFlag(BOOL bSystemProperties) { m_pWbemClassParms->SetSytemPropertiesFlag(bSystemProperties);}
  145. DWORD GetInstanceStatus(CWbemClassWrapper *pInst)
  146. {
  147. return ((CWbemClassInstanceWrapper *)pInst)->GetStatus();
  148. }
  149. void SetInstanceStatus(CWbemClassWrapper *pInst, DWORD dwStatus)
  150. {
  151. ((CWbemClassInstanceWrapper *)pInst)->SetStatus(dwStatus);
  152. }
  153. INSTANCELISTTYPE GetObjListType();
  154. STDMETHODIMP_(ULONG) AddRef(void);
  155. STDMETHODIMP_(ULONG) Release(void);
  156. HRESULT SetSearchPreferences(ULONG cProps , DBPROP rgProp[]);
  157. HRESULT GetRelativePath(CWbemClassInstanceWrapper *pInst,WCHAR *& strRelPath)
  158. {
  159. return pInst->GetRelativePath(strRelPath);
  160. }
  161. FETCHDIRECTION GetCurFetchDirection() { return m_paWbemClassInstances->GetCurFetchDirection(); }
  162. void SetCurFetchDirection(FETCHDIRECTION FetchDir) { m_paWbemClassInstances->SetCurFetchDirection(FetchDir); }
  163. };
  164. #endif