Team Fortress 2 Source Code as on 22/4/2020
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.

150 lines
4.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #if !defined(AFX_SERVICESDLG_H__FD755233_0A7A_4CBB_BA5E_A5D0B3B5F830__INCLUDED_)
  9. #define AFX_SERVICESDLG_H__FD755233_0A7A_4CBB_BA5E_A5D0B3B5F830__INCLUDED_
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif // _MSC_VER > 1000
  13. // ServicesDlg.h : header file
  14. //
  15. #include "iphelpers.h"
  16. #include "idle_dialog.h"
  17. #include "utllinkedlist.h"
  18. #include "resource.h"
  19. #include "window_anchor_mgr.h"
  20. #include "net_view_thread.h"
  21. #include "vmpi_defs.h"
  22. class CServiceInfo
  23. {
  24. public:
  25. bool IsOff() const; // Returns true if the time since we've heard from this guy is too long.
  26. public:
  27. CString m_ComputerName;
  28. CString m_MasterName;
  29. CString m_Password;
  30. int m_iState;
  31. // Since the live time is always changing, we only update it every 10 seconds or so.
  32. DWORD m_LiveTimeMS; // How long the service has been running (in milliseconds).
  33. DWORD m_WorkerAppTimeMS; // How long the worker app has been running (0 if it's not running).
  34. DWORD m_LastPingTimeMS; // Last time we heard from this machine. Used to detect if the service
  35. // is off or not.
  36. // Used to detect if we need to re-sort the list.
  37. const char *m_pLastStatusText;
  38. DWORD m_LastLiveTimeMS;
  39. CString m_LastMasterName;
  40. int m_CPUPercentage;
  41. CString m_ExeName;
  42. CString m_MapName;
  43. int m_MemUsageMB;
  44. // Last time we updated the service in the listbox.. used to make sure we update its on/off status
  45. // every once in a while.
  46. DWORD m_LastUpdateTime;
  47. int m_ProtocolVersion; // i.e. the service's VMPI_SERVICE_PROTOCOL_VERSION.
  48. char m_ServiceVersion[32]; // Version string.
  49. CIPAddr m_Addr;
  50. };
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CServicesDlg dialog
  53. class CServicesDlg : public CIdleDialog
  54. {
  55. // Construction
  56. public:
  57. CServicesDlg(CWnd* pParent = NULL); // standard constructor
  58. // Dialog Data
  59. //{{AFX_DATA(CServicesDlg)
  60. enum { IDD = IDD_SERVICES };
  61. CStatic m_NumServicesControl;
  62. CStatic m_NumDisabledServicesControl;
  63. CStatic m_NumWorkingServicesControl;
  64. CStatic m_NumWaitingServicesControl;
  65. CStatic m_NumOffServicesControl;
  66. CStatic m_PasswordDisplay;
  67. CListCtrl m_ServicesList;
  68. //}}AFX_DATA
  69. // Overrides
  70. // ClassWizard generated virtual function overrides
  71. //{{AFX_VIRTUAL(CServicesDlg)
  72. protected:
  73. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  74. virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  75. //}}AFX_VIRTUAL
  76. // Implementation
  77. protected:
  78. void BuildVMPIPingPacket( CUtlVector<char> &out, char cPacketID, unsigned char cProtocolVersion=VMPI_PROTOCOL_VERSION, bool bIgnorePassword=false );
  79. virtual void OnIdle();
  80. CServiceInfo* FindServiceByComputerName( const char *pComputerName );
  81. void SendToSelectedServices( const char *pData, int len );
  82. void UpdateServiceInListbox( CServiceInfo *pInfo );
  83. void UpdateServiceCountDisplay();
  84. void ResortItems();
  85. void UpdateServicesFromNetMessages();
  86. void UpdateServicesFromNetView();
  87. void BuildClipboardText( CUtlVector<char> &clipboardText );
  88. ISocket *m_pServicesPingSocket;
  89. DWORD m_dwLastServicesPing; // Last time we pinged all the services.
  90. // Restricts the password so we only see a particular set of VMPI services.
  91. CString m_Password;
  92. CUtlLinkedList<CServiceInfo*, int> m_Services;
  93. CNetViewThread m_NetViewThread;
  94. CWindowAnchorMgr m_AnchorMgr;
  95. bool m_bListChanged; // Used to detect if we need to re-sort the list.
  96. // Generated message map functions
  97. //{{AFX_MSG(CServicesDlg)
  98. virtual BOOL OnInitDialog();
  99. afx_msg void OnPatchServices();
  100. afx_msg void OnStopServices();
  101. afx_msg void OnStopJobs();
  102. afx_msg void OnFilterByPassword();
  103. afx_msg void OnForcePassword();
  104. afx_msg void OnCopyToClipboard();
  105. afx_msg void OnDblclkServicesList(NMHDR* pNMHDR, LRESULT* pResult);
  106. afx_msg void OnSize(UINT nType, int cx, int cy);
  107. //}}AFX_MSG
  108. DECLARE_MESSAGE_MAP()
  109. };
  110. //{{AFX_INSERT_LOCATION}}
  111. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  112. #endif // !defined(AFX_SERVICESDLG_H__FD755233_0A7A_4CBB_BA5E_A5D0B3B5F830__INCLUDED_)