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.

213 lines
5.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. ipxface
  7. Base IPX interface node handler
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "ipxface.h"
  12. #include "ipxadmin.h" // for CreateDataObjectFromInterfaceInfo
  13. #include "column.h" // for ComponentConfigStream
  14. #include "ipxconn.h" // for IPXConnection
  15. #include "format.h" // for FormatNumber
  16. BaseIPXResultNodeData::BaseIPXResultNodeData()
  17. {
  18. #ifdef DEBUG
  19. StrCpy(m_szDebug, _T("BaseIPXResultNodeData"));
  20. #endif
  21. m_pIPXConnection = NULL;
  22. m_fClient = FALSE;
  23. }
  24. BaseIPXResultNodeData::~BaseIPXResultNodeData()
  25. {
  26. if (m_pIPXConnection)
  27. m_pIPXConnection->Release();
  28. m_pIPXConnection = NULL;
  29. }
  30. HRESULT BaseIPXResultNodeData::Init(ITFSNode *pNode, IInterfaceInfo *pIf,
  31. IPXConnection *pIPXConn)
  32. {
  33. HRESULT hr = hrOK;
  34. BaseIPXResultNodeData * pData = NULL;
  35. pData = new BaseIPXResultNodeData;
  36. pData->m_spIf.Set(pIf);
  37. pData->m_pIPXConnection = pIPXConn;
  38. pIPXConn->AddRef();
  39. SET_BASEIPXRESULT_NODEDATA(pNode, pData);
  40. return hr;
  41. }
  42. HRESULT BaseIPXResultNodeData::Free(ITFSNode *pNode)
  43. {
  44. BaseIPXResultNodeData * pData = GET_BASEIPXRESULT_NODEDATA(pNode);
  45. ASSERT_BASEIPXRESULT_NODEDATA(pData);
  46. pData->m_spIf.Release();
  47. delete pData;
  48. SET_BASEIPXRESULT_NODEDATA(pNode, NULL);
  49. return hrOK;
  50. }
  51. /*---------------------------------------------------------------------------
  52. BaseIPXResultHandler implementation
  53. ---------------------------------------------------------------------------*/
  54. DEBUG_DECLARE_INSTANCE_COUNTER(BaseIPXResultHandler)
  55. IMPLEMENT_ADDREF_RELEASE(BaseIPXResultHandler)
  56. STDMETHODIMP BaseIPXResultHandler::QueryInterface(REFIID riid, LPVOID *ppv)
  57. {
  58. // Is the pointer bad?
  59. if (ppv == NULL)
  60. return E_INVALIDARG;
  61. // Place NULL in *ppv in case of failure
  62. *ppv = NULL;
  63. // This is the non-delegating IUnknown implementation
  64. if (riid == IID_IUnknown)
  65. *ppv = (LPVOID) this;
  66. else if (riid == IID_IRtrAdviseSink)
  67. *ppv = &m_IRtrAdviseSink;
  68. else
  69. return CBaseResultHandler::QueryInterface(riid, ppv);
  70. // If we're going to return an interface, AddRef it first
  71. if (*ppv)
  72. {
  73. ((LPUNKNOWN) *ppv)->AddRef();
  74. return hrOK;
  75. }
  76. else
  77. return E_NOINTERFACE;
  78. }
  79. /*---------------------------------------------------------------------------
  80. NodeHandler implementation
  81. ---------------------------------------------------------------------------*/
  82. /*!--------------------------------------------------------------------------
  83. BaseIPXResultHandler::GetString
  84. -
  85. Author: KennT
  86. ---------------------------------------------------------------------------*/
  87. STDMETHODIMP_(LPCTSTR) BaseIPXResultHandler::GetString(ITFSComponent * pComponent,
  88. MMC_COOKIE cookie,
  89. int nCol)
  90. {
  91. Assert(m_spNodeMgr);
  92. SPITFSNode spNode;
  93. BaseIPXResultNodeData * pData;
  94. ConfigStream * pConfig;
  95. m_spNodeMgr->FindNode(cookie, &spNode);
  96. Assert(spNode);
  97. pData = GET_BASEIPXRESULT_NODEDATA(spNode);
  98. Assert(pData);
  99. ASSERT_BASEIPXRESULT_NODEDATA(pData);
  100. pComponent->GetUserData((LONG_PTR *) &pConfig);
  101. Assert(pConfig);
  102. return pData->m_rgData[pConfig->MapColumnToSubitem(m_ulColumnId, nCol)].m_stData;
  103. }
  104. /*!--------------------------------------------------------------------------
  105. BaseIPXResultHandler::CompareItems
  106. -
  107. Author: KennT
  108. ---------------------------------------------------------------------------*/
  109. STDMETHODIMP_(int) BaseIPXResultHandler::CompareItems(ITFSComponent * pComponent, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int nCol)
  110. {
  111. ConfigStream * pConfig;
  112. pComponent->GetUserData((LONG_PTR *) &pConfig);
  113. Assert(pConfig);
  114. int nSubItem = pConfig->MapColumnToSubitem(m_ulColumnId, nCol);
  115. if (pConfig->GetSortCriteria(m_ulColumnId, nCol) == CON_SORT_BY_DWORD)
  116. {
  117. SPITFSNode spNodeA, spNodeB;
  118. BaseIPXResultNodeData * pNodeDataA, *pNodeDataB;
  119. m_spNodeMgr->FindNode(cookieA, &spNodeA);
  120. m_spNodeMgr->FindNode(cookieB, &spNodeB);
  121. pNodeDataA = GET_BASEIPXRESULT_NODEDATA(spNodeA);
  122. ASSERT_BASEIPXRESULT_NODEDATA(pNodeDataA);
  123. pNodeDataB = GET_BASEIPXRESULT_NODEDATA(spNodeB);
  124. ASSERT_BASEIPXRESULT_NODEDATA(pNodeDataB);
  125. return pNodeDataA->m_rgData[nSubItem].m_dwData -
  126. pNodeDataB->m_rgData[nSubItem].m_dwData;
  127. }
  128. else
  129. return StriCmpW(GetString(pComponent, cookieA, nCol),
  130. GetString(pComponent, cookieB, nCol));
  131. }
  132. ImplementEmbeddedUnknown(BaseIPXResultHandler, IRtrAdviseSink)
  133. STDMETHODIMP BaseIPXResultHandler::EIRtrAdviseSink::OnChange(LONG_PTR ulConn,
  134. DWORD dwChangeType, DWORD dwObjectType, LPARAM lUserParam, LPARAM lParam)
  135. {
  136. InitPThis(BaseIPXResultHandler, IRtrAdviseSink);
  137. HRESULT hr = hrOK;
  138. Panic0("Should never reach here, interface nodes have no children");
  139. return hr;
  140. }
  141. HRESULT BaseIPXResultHandler::Init(IInterfaceInfo *pIfInfo, ITFSNode *pParent)
  142. {
  143. return hrOK;
  144. }
  145. STDMETHODIMP BaseIPXResultHandler::DestroyResultHandler(MMC_COOKIE cookie)
  146. {
  147. SPITFSNode spNode;
  148. m_spNodeMgr->FindNode(cookie, &spNode);
  149. BaseIPXResultNodeData::Free(spNode);
  150. BaseRouterHandler::DestroyResultHandler(cookie);
  151. return hrOK;
  152. }
  153. /*!--------------------------------------------------------------------------
  154. FillInNumberData
  155. -
  156. Author: KennT
  157. ---------------------------------------------------------------------------*/
  158. void FillInNumberData(BaseIPXResultNodeData *pNodeData, UINT iIndex,
  159. DWORD dwData)
  160. {
  161. TCHAR szNumber[32];
  162. FormatNumber(dwData, szNumber, DimensionOf(szNumber), FALSE);
  163. pNodeData->m_rgData[iIndex].m_stData = szNumber;
  164. pNodeData->m_rgData[iIndex].m_dwData = dwData;
  165. }