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.

128 lines
3.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. statnode.cpp
  7. Status leaf node
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "statnode.h"
  12. CServerStatus::CServerStatus(ITFSComponentData *pCompData):
  13. CWinsHandler(pCompData)
  14. {
  15. m_bExpanded = FALSE;
  16. m_nState = loaded;
  17. dwState = SERVER_ADDED;
  18. m_uImage = ICON_IDX_SERVER;
  19. m_timeLast = 0;
  20. }
  21. HRESULT
  22. CServerStatus::InitializeNode
  23. (
  24. ITFSNode * pNode
  25. )
  26. {
  27. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  28. CString strDisplay;
  29. FormDisplayName(strDisplay);
  30. SetDisplayName(strDisplay);
  31. // Make the node immediately visible
  32. pNode->SetVisibilityState(TFS_VIS_SHOW);
  33. pNode->SetData(TFS_DATA_COOKIE, (LPARAM) pNode);
  34. pNode->SetData(TFS_DATA_USER, (LPARAM) this);
  35. pNode->SetData(TFS_DATA_TYPE, WINSSNAP_STATUS_LEAF_NODE);
  36. pNode->SetData(TFS_DATA_IMAGEINDEX, m_uImage);
  37. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, m_uImage);
  38. pNode->SetData(TFS_DATA_SCOPE_LEAF_NODE, TRUE);
  39. SetColumnStringIDs(&aColumns[WINSSNAP_REPLICATION_PARTNER][0]);
  40. SetColumnWidths(&aColumnWidths[WINSSNAP_REPLICATION_PARTNER][0]);
  41. return hrOK;
  42. }
  43. /*---------------------------------------------------------------------------
  44. Overridden base handler functions
  45. ---------------------------------------------------------------------------*/
  46. /*!--------------------------------------------------------------------------
  47. CServerStatus::GetString
  48. Implementation of ITFSNodeHandler::GetString
  49. Author: KennT
  50. ---------------------------------------------------------------------------*/
  51. STDMETHODIMP_(LPCTSTR)
  52. CServerStatus::GetString
  53. (
  54. ITFSComponent * pComponent,
  55. MMC_COOKIE cookie,
  56. int nCol
  57. )
  58. {
  59. if (nCol == 0 || nCol == -1)
  60. return GetDisplayName();
  61. switch(nCol)
  62. {
  63. case -1:
  64. case 0:
  65. return GetDisplayName();
  66. case 1:
  67. return m_strStatus;
  68. case 2:
  69. if (m_timeLast == 0)
  70. m_strLastChecked.Empty();
  71. else
  72. {
  73. FormatDateTime(m_strLastChecked, m_timeLast);
  74. }
  75. return m_strLastChecked;
  76. default:
  77. return NULL;
  78. }
  79. }
  80. /*---------------------------------------------------------------------------
  81. Command handlers
  82. ---------------------------------------------------------------------------*/
  83. void
  84. CServerStatus:: FormDisplayName(CString &strDisplay)
  85. {
  86. WCHAR wString[MAX_PATH] = {0};
  87. int nBytes = 0;
  88. // form the string for the first column
  89. nBytes = ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szServerName, -1, wString, 0);
  90. ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szServerName, -1, wString, nBytes);
  91. CString strServer(wString);
  92. m_strServerName = strServer;
  93. if(dwIPAddress != 0)
  94. {
  95. ::MakeIPAddress(dwIPAddress, m_strIPAddress);
  96. strDisplay.Format(IDS_SERVER_NAME_FORMAT, m_strServerName, m_strIPAddress);
  97. }
  98. else
  99. {
  100. strDisplay = m_strServerName;
  101. }
  102. }