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.

361 lines
8.4 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (C) Microsoft Corporation, 1998 - 1999
  4. Module Name:
  5. IASAttributeEditor.cpp
  6. Abstract:
  7. Implementation file for the CIASAttributeEditor class.
  8. Revision History:
  9. mmaguire 06/25/98 - created
  10. --*/
  11. //////////////////////////////////////////////////////////////////////////////
  12. //////////////////////////////////////////////////////////////////////////////
  13. // BEGIN INCLUDES
  14. //
  15. // standard includes:
  16. //
  17. #include "Precompiled.h"
  18. //
  19. // where we can find declaration for main class in this file:
  20. //
  21. #include "IASAttributeEditor.h"
  22. //
  23. // where we can find declarations needed in this file:
  24. //
  25. //
  26. // END INCLUDES
  27. //////////////////////////////////////////////////////////////////////////////
  28. //////////////////////////////////////////////////////////////////////////////
  29. /*++
  30. CIASAttributeEditor::ShowEditor
  31. --*/
  32. //////////////////////////////////////////////////////////////////////////////
  33. STDMETHODIMP CIASAttributeEditor::ShowEditor( /*[in, out]*/ BSTR *pReserved )
  34. {
  35. TRACE_FUNCTION("CIASAttributeEditor::ShowEditor");
  36. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  37. return E_NOTIMPL;
  38. }
  39. //////////////////////////////////////////////////////////////////////////////
  40. /*++
  41. CIASAttributeEditor::SetAttributeSchema
  42. --*/
  43. //////////////////////////////////////////////////////////////////////////////
  44. STDMETHODIMP CIASAttributeEditor::SetAttributeSchema(IIASAttributeInfo * pIASAttributeInfo)
  45. {
  46. TRACE_FUNCTION("CIASAttributeEditor::SetAttributeSchema");
  47. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  48. // Check for preconditions.
  49. if( ! pIASAttributeInfo )
  50. {
  51. return E_INVALIDARG;
  52. }
  53. m_spIASAttributeInfo = pIASAttributeInfo;
  54. return S_OK;
  55. }
  56. //////////////////////////////////////////////////////////////////////////////
  57. /*++
  58. CIASAttributeEditor::SetAttributeValue
  59. Most of the time, before you can use an editor's functionality,
  60. you need to pass it a pointer to the value the editor's methods
  61. e.g. will modify.
  62. Note that this is not always the case, for example, to gather information
  63. about the attribute's vendor, you need not always specify a value.
  64. Pass a NULL pointer to SetAttributeValue to disassociate the
  65. editor from any value.
  66. --*/
  67. //////////////////////////////////////////////////////////////////////////////
  68. STDMETHODIMP CIASAttributeEditor::SetAttributeValue(VARIANT * pValue)
  69. {
  70. TRACE_FUNCTION("CIASAttributeEditor::SetAttributeValue");
  71. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  72. // Check for preconditions.
  73. // None -- passing in a NULL pointer means we are "clearing" the
  74. // editor.
  75. ErrorTrace(0, "CIASAttributeEditor::SetAttributeValue pointer value %ld\n", pValue);
  76. m_pvarValue = pValue;
  77. return S_OK;
  78. }
  79. //////////////////////////////////////////////////////////////////////////////
  80. /*++
  81. CIASAttributeEditor::get_ValueAsString
  82. --*/
  83. //////////////////////////////////////////////////////////////////////////////
  84. STDMETHODIMP CIASAttributeEditor::get_ValueAsString(BSTR * pbstrDisplayText )
  85. {
  86. TRACE_FUNCTION("CIASAttributeEditor::get_ValueAsString");
  87. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  88. // Check for preconditions.
  89. if( ! pbstrDisplayText )
  90. {
  91. return E_INVALIDARG;
  92. }
  93. CComBSTR bstrDisplay;
  94. // This method will be overriden.
  95. // We could do our best here to give back a default string,
  96. // but for now, just return an empty string.
  97. *pbstrDisplayText = bstrDisplay.Copy();
  98. return S_OK;
  99. }
  100. //////////////////////////////////////////////////////////////////////////////
  101. /*++
  102. CIASAttributeEditor::put_ValueAsString
  103. --*/
  104. //////////////////////////////////////////////////////////////////////////////
  105. STDMETHODIMP CIASAttributeEditor::put_ValueAsString(BSTR newVal)
  106. {
  107. TRACE_FUNCTION("CIASAttributeEditor::put_ValueAsString");
  108. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  109. // TODO: Add your implementation code here
  110. return E_NOTIMPL;
  111. }
  112. //////////////////////////////////////////////////////////////////////////////
  113. /*++
  114. CIASAttributeEditor::get_VendorName
  115. For most attributes, vendor information is stored in the AttributeInfo.
  116. However, for some attributes, e.g. the RADIUS vendor specific
  117. attribute (ID == 26), vendor information is stored in the value of the
  118. editor itself.
  119. For this reason, UI clients should always query an IASAttributeEditor for vendor
  120. information rather than the AttributeInfo itself.
  121. In the default implementation here, we will query the AttributeInfo
  122. for this information. Some derived implementations of IASAttributeEditor
  123. (e.g. IASVendorSpecificAttributeEditor) will parse the value of the
  124. attribute itself to procide this info.
  125. --*/
  126. //////////////////////////////////////////////////////////////////////////////
  127. STDMETHODIMP CIASAttributeEditor::get_VendorName(BSTR * pVal)
  128. {
  129. TRACE_FUNCTION("CIASAttributeEditor::get_VendorName");
  130. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  131. // Check for preconditions.
  132. if( ! pVal )
  133. {
  134. return E_INVALIDARG;
  135. }
  136. if( ! m_spIASAttributeInfo )
  137. {
  138. // We are not initialized properly.
  139. return OLE_E_BLANK;
  140. }
  141. HRESULT hr;
  142. hr = m_spIASAttributeInfo->get_VendorName( pVal );
  143. return hr;
  144. }
  145. //////////////////////////////////////////////////////////////////////////////
  146. /*++
  147. CIASAttributeEditor::put_VendorName
  148. --*/
  149. //////////////////////////////////////////////////////////////////////////////
  150. STDMETHODIMP CIASAttributeEditor::put_VendorName(BSTR newVal)
  151. {
  152. TRACE_FUNCTION("CIASAttributeEditor::put_VendorName");
  153. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  154. return E_NOTIMPL;
  155. // Check for preconditions.
  156. // if( ! m_spIASAttributeInfo )
  157. // {
  158. // // We are not initialized properly.
  159. // return OLE_E_BLANK;
  160. // }
  161. }
  162. //////////////////////////////////////////////////////////////////////////////
  163. /*++
  164. CIASAttributeEditor::Edit
  165. We had a design change about the interface we want an editor to expose.
  166. For now, this interface method just calls our old interface methods.
  167. --*/
  168. //////////////////////////////////////////////////////////////////////////////
  169. STDMETHODIMP CIASAttributeEditor::Edit(IIASAttributeInfo * pIASAttributeInfo, /*[in]*/ VARIANT *pAttributeValue, /*[in, out]*/ BSTR *pReserved )
  170. {
  171. TRACE_FUNCTION("CIASAttributeEditor::Edit");
  172. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  173. HRESULT hr;
  174. hr = SetAttributeSchema( pIASAttributeInfo );
  175. if( FAILED( hr ) )
  176. {
  177. return hr;
  178. }
  179. // CComVariant varValue;
  180. //
  181. // hr = pIASAttributeInfo->get_Value( &varValue );
  182. // We are ignoring return value here because if we can't get it, we'll just edit a new one.
  183. //
  184. // hr = SetAttributeValue( &varValue );
  185. hr = SetAttributeValue( pAttributeValue );
  186. if( FAILED(hr ) )
  187. {
  188. return hr;
  189. }
  190. hr = ShowEditor( pReserved );
  191. // if( S_OK == hr )
  192. // {
  193. // hr = pIASAttributeInfo->put_Value( varValue );
  194. // if( FAILED(hr ) )
  195. // {
  196. // return hr;
  197. // }
  198. // }
  199. return hr;
  200. }
  201. //////////////////////////////////////////////////////////////////////////////
  202. /*++
  203. CIASAttributeEditor::GetDisplayInfo
  204. We had a design change about the interface we want an editor to expose.
  205. For now, this interface method just calls our old interface methods.
  206. --*/
  207. //////////////////////////////////////////////////////////////////////////////
  208. STDMETHODIMP CIASAttributeEditor::GetDisplayInfo(IIASAttributeInfo * pIASAttributeInfo, /*[in]*/ VARIANT *pAttributeValue, BSTR * pVendorName, BSTR * pValueAsString, /*[in, out]*/ BSTR *pReserved)
  209. {
  210. TRACE_FUNCTION("CIASAttributeEditor::GetDisplayInfo");
  211. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  212. HRESULT hr;
  213. hr = SetAttributeSchema( pIASAttributeInfo );
  214. if( FAILED( hr ) )
  215. {
  216. return hr;
  217. }
  218. CComVariant varValue;
  219. // hr = pIASAttributeInfo->get_Value( &varValue );
  220. // if( FAILED(hr ) )
  221. // {
  222. // return hr;
  223. // }
  224. //
  225. // hr = SetAttributeValue( &varValue );
  226. hr = SetAttributeValue( pAttributeValue );
  227. if( FAILED(hr ) )
  228. {
  229. return hr;
  230. }
  231. CComBSTR bstrVendorName;
  232. CComBSTR bstrValueAsString;
  233. hr = get_VendorName( &bstrVendorName );
  234. // Don't care if this failed -- we'll return empty string.
  235. hr = get_ValueAsString( &bstrValueAsString );
  236. // Don't care if this failed -- we'll return empty string.
  237. *pVendorName = bstrVendorName.Copy();
  238. *pValueAsString = bstrValueAsString.Copy();
  239. return S_OK;
  240. }