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.

156 lines
4.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. status.h
  7. WINS result pane state nodes
  8. FILE HISTORY:
  9. */
  10. #ifndef _STATUS_H
  11. #define _STATUS_H
  12. #ifndef _WINSHAND_H
  13. #include "winshand.h"
  14. #endif
  15. #ifndef _WINSMON_H
  16. #include "winsmon.h"
  17. #endif
  18. #ifndef _STATNODE_H
  19. #include "statnode.h"
  20. #endif
  21. #ifndef _SERVER_H
  22. #include "server.h"
  23. #endif
  24. #include "afxmt.h"
  25. class CServerStatus;
  26. /*---------------------------------------------------------------------------
  27. Class: CWinsStatusHandler
  28. ---------------------------------------------------------------------------*/
  29. class CWinsStatusHandler : public CMTWinsHandler
  30. {
  31. // Interface
  32. public:
  33. CWinsStatusHandler(ITFSComponentData *pCompData, DWORD dwUpdateInterval);
  34. ~CWinsStatusHandler();
  35. // base handler functionality we override
  36. OVERRIDE_NodeHandler_HasPropertyPages();
  37. OVERRIDE_NodeHandler_CreatePropertyPages();
  38. OVERRIDE_NodeHandler_OnAddMenuItems();
  39. OVERRIDE_NodeHandler_DestroyHandler();
  40. STDMETHODIMP_(LPCTSTR) GetString(ITFSNode * pNode, int nCol);
  41. OVERRIDE_BaseHandlerNotify_OnCreateNodeId2();
  42. public:
  43. // CWinsHandler overrides
  44. virtual HRESULT InitializeNode(ITFSNode * pNode);
  45. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  46. OVERRIDE_BaseHandlerNotify_OnExpand();
  47. OVERRIDE_BaseResultHandlerNotify_OnResultRefresh();
  48. OVERRIDE_ResultHandler_CompareItems();
  49. public:
  50. DWORD GetUpdateInterval()
  51. {
  52. return m_dwUpdateInterval;
  53. }
  54. void SetUpdateInterval(DWORD dwValue)
  55. {
  56. // set the new interval and wakeup the main probe thread
  57. // since we are resetting the interval, do a check now and
  58. // then wait the new interval
  59. m_dwUpdateInterval = dwValue;
  60. SetEvent(m_hWaitIntervalMain);
  61. }
  62. DWORD WINAPI ExecuteMonitoring();
  63. DWORD WINAPI ListeningThreadFunc() ;
  64. HRESULT AddNode(ITFSNode *pNode, CWinsServerHandler *pServer);
  65. HRESULT DeleteNode(ITFSNode *pNode, CWinsServerHandler *pServer);
  66. // we don't use query object, but being a MTHandler requires this
  67. virtual ITFSQueryObject* OnCreateQuery(ITFSNode *pNode) { return NULL; }
  68. STDMETHOD(OnNotifyHaveData)(LPARAM);
  69. typedef CArray <CServerStatus *, CServerStatus *> listServers;
  70. listServers m_listServers;
  71. // Implementation
  72. private:
  73. HRESULT CreateListeningSockets( );
  74. void StartMonitoring(ITFSNode *pNode);
  75. int Probe(CServerStatus *pServer, SOCKET listenNameSvcSock);
  76. void CloseSockets();
  77. void RemoveServer(int i);
  78. void AddServer(CServerStatus* pServer);
  79. void BuildServerList(ITFSNode *pNode);
  80. void SetIPAddress(int i, LPSTR szIP);
  81. CServerStatus* GetServer(int i);
  82. HRESULT CreateNodes(ITFSNode *pNode);
  83. void UpdateStatusColumn(ITFSNode *pNode);
  84. int GetListSize();
  85. void UpdateStatus(int nIndex, UINT uStatusId, UINT uImage);
  86. BOOL IsServerDeleted(CServerStatus *pStat);
  87. void MarkAsDeleted(LPSTR szBuffer, BOOL bDelete = TRUE);
  88. CServerStatus* GetExistingServer(LPSTR szBuffer);
  89. void NotifyMainThread();
  90. BOOL FCheckForAbort();
  91. private:
  92. // variables for monitoring
  93. fd_set m_listenSockSet;
  94. SOCKET listenNameSvcSock; // 2DO: for the listening thread...
  95. SOCKET listenSockCl; // socket listening for frames from DHCP srvs
  96. SOCKET listenSockSrv; // socket listening for frames from DHCP srvs
  97. // thread handles
  98. HANDLE m_hMainMonThread;
  99. HANDLE m_hListenThread;
  100. // event handles
  101. HANDLE m_hAbortListen;
  102. HANDLE m_hAbortMain;
  103. HANDLE m_hAnswer;
  104. HANDLE m_hWaitIntervalListen;
  105. HANDLE m_hWaitIntervalMain;
  106. HANDLE m_hPauseListening;
  107. int m_nServersUpdated;
  108. DWORD m_dwUpdateInterval; // Holds the value in milliSec
  109. CCriticalSection m_cs;
  110. SPITFSNode m_spNode;
  111. };
  112. // thread proc the background thread initially is called on
  113. DWORD WINAPI MonThreadProc(LPVOID lParam);
  114. DWORD WINAPI MainMonThread(LPVOID lParam);
  115. #endif _STATUS_H