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.

166 lines
4.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997-1999 **/
  4. /**********************************************************************/
  5. /*
  6. node.cpp
  7. Root node information (the root node is not displayed
  8. in the MMC framework but contains information such as
  9. all of the subnodes in this snapin).
  10. FILE HISTORY:
  11. */
  12. #include "stdafx.h"
  13. #include "snmpclst.h"
  14. #include "handler.h"
  15. #include "util.h"
  16. #include "statsdlg.h"
  17. #include "modeless.h"
  18. #include "snmppp.h"
  19. extern CString g_strMachineName;
  20. /*---------------------------------------------------------------------------
  21. CSnmpRootHandler implementation
  22. ---------------------------------------------------------------------------*/
  23. /*!--------------------------------------------------------------------------
  24. CSnmpRootHandler::HasPropertyPages
  25. Implementation of ITFSNodeHandler::HasPropertyPages
  26. NOTE: the root node handler has to over-ride this function to
  27. handle the snapin manager property page (wizard) case!!!
  28. Author: KennT
  29. ---------------------------------------------------------------------------*/
  30. STDMETHODIMP
  31. CSnmpRootHandler::HasPropertyPages
  32. (
  33. ITFSNode * pNode,
  34. LPDATAOBJECT pDataObject,
  35. DATA_OBJECT_TYPES type,
  36. DWORD dwType
  37. )
  38. {
  39. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  40. HRESULT hr = hrOK;
  41. if (dwType & TFS_COMPDATA_CREATE)
  42. {
  43. // This is the case where we are asked to bring up property
  44. // pages when the user is adding a new snapin. These calls
  45. // are forwarded to the root node to handle.
  46. hr = S_FALSE;
  47. }
  48. else
  49. {
  50. // we have property pages in the normal case
  51. hr = S_OK;
  52. }
  53. return hr;
  54. }
  55. /*---------------------------------------------------------------------------
  56. CSnmpRootHandler::CreatePropertyPages
  57. Description
  58. Author: EricDav
  59. ---------------------------------------------------------------------------*/
  60. #ifndef PROPSHEETPAGE_LATEST
  61. #ifdef UNICODE
  62. #define PROPSHEETPAGE_LATEST PROPSHEETPAGEW_LATEST
  63. #else
  64. #define PROPSHEETPAGE_LATEST PROPSHEETPAGEA_LATEST
  65. #endif
  66. #endif
  67. HPROPSHEETPAGE MyCreatePropertySheetPage(AFX_OLDPROPSHEETPAGE* ppsp)
  68. {
  69. PROPSHEETPAGE_LATEST pspLatest = {0};
  70. CopyMemory (&pspLatest, ppsp, ppsp->dwSize);
  71. pspLatest.dwSize = sizeof(pspLatest);
  72. return (::CreatePropertySheetPage (&pspLatest));
  73. }
  74. STDMETHODIMP
  75. CSnmpRootHandler::CreatePropertyPages
  76. (
  77. ITFSNode *pNode,
  78. LPPROPERTYSHEETCALLBACK lpProvider,
  79. LPDATAOBJECT pDataObject,
  80. LONG_PTR handle,
  81. DWORD dwType
  82. )
  83. {
  84. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  85. HRESULT hr;
  86. DWORD dwError;
  87. CString strServiceName;
  88. static UINT s_cfServiceName = RegisterClipboardFormat(L"FILEMGMT_SNAPIN_SERVICE_NAME");
  89. static UINT s_cfMachineName = RegisterClipboardFormat(L"MMC_SNAPIN_MACHINE_NAME");
  90. g_strMachineName.Empty();
  91. hr = ::ExtractString( pDataObject,
  92. (CLIPFORMAT) s_cfMachineName,
  93. &g_strMachineName,
  94. 255 );
  95. if (FAILED(hr))
  96. return FALSE;
  97. hr = ::ExtractString( pDataObject,
  98. (CLIPFORMAT) s_cfServiceName,
  99. &strServiceName,
  100. 255 );
  101. if (FAILED(hr))
  102. return FALSE;
  103. if( !lstrcmpi(strServiceName, L"Snmp") ) {
  104. SPIComponentData spComponentData;
  105. m_spNodeMgr->GetComponentData(&spComponentData);
  106. CAgentPage *pAgentPage = new CAgentPage();
  107. // tell MMC to hook the proc because we are running on a separate,
  108. // non MFC thread.
  109. MMCPropPageCallback(&pAgentPage->m_psp);
  110. HPROPSHEETPAGE hAgentPage = MyCreatePropertySheetPage(&pAgentPage->m_psp);
  111. if(hAgentPage == NULL)
  112. return E_UNEXPECTED;
  113. lpProvider->AddPage(hAgentPage);
  114. CTrapsPage *pTrapsPage = new CTrapsPage();
  115. MMCPropPageCallback(&pTrapsPage->m_psp);
  116. HPROPSHEETPAGE hTrapsPage = MyCreatePropertySheetPage(&pTrapsPage->m_psp);
  117. if(hTrapsPage == NULL)
  118. return E_UNEXPECTED;
  119. lpProvider->AddPage(hTrapsPage);
  120. CSecurityPage *pSecurityPage = new CSecurityPage();
  121. MMCPropPageCallback(&pSecurityPage->m_psp);
  122. HPROPSHEETPAGE hSecurityPage = MyCreatePropertySheetPage(&pSecurityPage->m_psp);
  123. if(hSecurityPage == NULL)
  124. return E_UNEXPECTED;
  125. lpProvider->AddPage(hSecurityPage);
  126. }
  127. return hr;
  128. }