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.

195 lines
5.9 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // IRowsetInfo interface implementation
  7. //
  8. /////////////////////////////////////////////////////////////////////////////////////////
  9. #include "headers.h"
  10. /////////////////////////////////////////////////////////////////////////////////////////
  11. //
  12. // Returns an interface pointer to the rowset to which the bookmark applies
  13. //
  14. // HRESULT
  15. // E_INVALIDARG ppReferencedRowset was NULL
  16. // DB_E_BADORDINAL iOrdinal was greater than number of columns in rowset
  17. // DB_E_NOTAREFERENCECOLUMN This rowset does not support bookmarks
  18. //
  19. /////////////////////////////////////////////////////////////////////////////////////////
  20. STDMETHODIMP CImpIRowsetInfo::GetReferencedRowset ( DBORDINAL iOrdinal, //IN Bookmark Column
  21. REFIID riid, // IN ID of the interface pointer to return
  22. IUnknown ** ppReferencedRowset // OUT IRowset Interface Pointer
  23. )
  24. {
  25. HRESULT hr = DB_E_BADROWHANDLE;
  26. CSetStructuredExceptionHandler seh;
  27. TRY_BLOCK;
  28. if( ppReferencedRowset )
  29. *ppReferencedRowset = NULL;
  30. // Seriliaze the object
  31. CAutoBlock cab(ROWSET->GetCriticalSection());
  32. // Clear Error information
  33. g_pCError->ClearErrorInfo();
  34. if(m_pObj->IsZoombie())
  35. {
  36. hr = E_UNEXPECTED;
  37. }
  38. else
  39. //========================================================================
  40. // Check Arguments
  41. //========================================================================
  42. if( ppReferencedRowset == NULL ){
  43. hr = E_INVALIDARG;
  44. }
  45. else{
  46. if(iOrdinal == 0 && (m_pObj->m_ulProps & BOOKMARKPROP))
  47. hr = this->QueryInterface(riid,(void **)ppReferencedRowset);
  48. else
  49. {
  50. //========================================================================
  51. // The oridinal was greater than the number of columns that we have.
  52. //========================================================================
  53. if ( ( iOrdinal == 0 ) || ( iOrdinal > m_pObj->m_cTotalCols ) ){
  54. hr = DB_E_BADORDINAL;
  55. }
  56. else{
  57. hr = m_pObj->GetChildRowset(iOrdinal,riid,ppReferencedRowset);
  58. //====================================================================
  59. // Since we don't support bookmarks, this will alway return an error
  60. //====================================================================
  61. // hr = DB_E_NOTAREFERENCECOLUMN;
  62. }
  63. }
  64. }
  65. hr = hr == S_OK ? hr :g_pCError->PostHResult(hr,&IID_IRowsetInfo);
  66. CATCH_BLOCK_HRESULT(hr,L"IRowsetInfo::GetReferencedRowset");
  67. return hr;
  68. }
  69. /////////////////////////////////////////////////////////////////////////////////////////
  70. //
  71. // Returns current settings of all properties supported by the rowset
  72. //
  73. // HRESULT
  74. // S_OK The method succeeded
  75. // E_INVALIDARG pcProperties or prgProperties was NULL
  76. // E_OUTOFMEMORY Out of memory
  77. //
  78. /////////////////////////////////////////////////////////////////////////////////////////
  79. STDMETHODIMP CImpIRowsetInfo::GetProperties ( const ULONG cPropertySets, //IN # of property sets
  80. const DBPROPIDSET rgPropertySets[], //IN Array of DBPROPIDSET
  81. ULONG* pcProperties, //OUT count of properties returned
  82. DBPROPSET** prgProperties //OUT property information returned
  83. )
  84. {
  85. assert( m_pObj );
  86. assert( m_pObj->m_pUtilProp );
  87. HRESULT hr = S_OK;
  88. CSetStructuredExceptionHandler seh;
  89. TRY_BLOCK;
  90. // Seriliaze the object
  91. CAutoBlock cab(ROWSET->GetCriticalSection());
  92. // Clear Error information
  93. g_pCError->ClearErrorInfo();
  94. if(m_pObj->IsZoombie())
  95. {
  96. hr = E_UNEXPECTED;
  97. }
  98. else
  99. {
  100. //===============================================================
  101. // Check Arguments
  102. //===============================================================
  103. hr = m_pObj->m_pUtilProp->GetPropertiesArgChk(PROPSET_ROWSET, cPropertySets,
  104. rgPropertySets, pcProperties, prgProperties);
  105. if ( SUCCEEDED(hr) ){
  106. //===============================================================
  107. // just pass this call on to the utility object that manages our
  108. // properties
  109. //===============================================================
  110. hr = m_pObj->m_pUtilProp->GetProperties( PROPSET_ROWSET, cPropertySets, rgPropertySets, pcProperties, prgProperties );
  111. }
  112. }
  113. hr = hr == S_OK ? hr :g_pCError->PostHResult(hr,&IID_IRowsetInfo);
  114. CATCH_BLOCK_HRESULT(hr,L"IRowsetInfo::GetProperties");
  115. return hr;
  116. }
  117. /////////////////////////////////////////////////////////////////////////////////////////
  118. //
  119. // Returns the interface pointer of the object that created the rowset
  120. //
  121. // HRESULT
  122. // S_OK Method Succeeded
  123. // E_INVALIDARG Invalid parameters were specified
  124. //
  125. /////////////////////////////////////////////////////////////////////////////////////////
  126. STDMETHODIMP CImpIRowsetInfo::GetSpecification ( REFIID riid, IUnknown **ppSpecification )
  127. {
  128. HRESULT hr = S_OK;
  129. CSetStructuredExceptionHandler seh;
  130. TRY_BLOCK;
  131. // Seriliaze the object
  132. CAutoBlock cab(ROWSET->GetCriticalSection());
  133. // Clear Error information
  134. g_pCError->ClearErrorInfo();
  135. if(m_pObj->IsZoombie())
  136. {
  137. hr = E_UNEXPECTED;
  138. }
  139. else
  140. if ( ppSpecification == NULL ){
  141. hr = E_INVALIDARG ;
  142. }
  143. else{
  144. // we do not have an interface pointer on the object that created this rowset, yet.
  145. *ppSpecification = NULL;
  146. if(m_pObj->m_pParentCmd)
  147. {
  148. hr = m_pObj->m_pParentCmd->GetOuterUnknown()->QueryInterface (riid,(void**)ppSpecification);
  149. }
  150. else
  151. if ( m_pObj->m_pCreator ){
  152. assert(m_pObj->m_pCreator->GetOuterUnknown());
  153. hr = m_pObj->m_pCreator->GetOuterUnknown()->QueryInterface (riid,(void**)ppSpecification);
  154. }
  155. }
  156. hr = hr == S_OK ? hr :g_pCError->PostHResult(hr,&IID_IRowsetInfo);
  157. CATCH_BLOCK_HRESULT(hr,L"IRowsetInfo::GetSpecification");
  158. return hr;
  159. }