00001 #ifndef __AGENTDLG_H__ 00002 #define __AGENTDLG_H__ 00003 00004 #if _MSC_VER > 1000 00005 #pragma once 00006 #endif // _MSC_VER > 1000 00007 00008 #include "auto_ptr.h" 00009 00010 #include "Log.h" 00011 #include "Queue.h" 00012 #include "Encapsulator.h" 00013 #include "CenterCommunicator.h" 00014 00022 class CAgentDlg : public CDialog 00023 { 00024 private: 00026 enum { 00027 SWITCH_LIST_TIMER = 1, 00028 REGISTER_ON_CENTER_TIMER = 2, 00029 AGENTS_TICK_TIMER = 3, 00030 }; 00031 00032 public: 00034 CAgentDlg(CWnd* pParent = NULL); 00035 00037 void AddToOutbox(MESSAGE_TYPE type, UINT32 info, RefCountBuffer msg); 00038 00039 // Dialog Data 00040 //{{AFX_DATA(CAgentDlg) 00041 enum { IDD = IDD_AGENT_DIALOG }; 00042 CListCtrl m_AgentsList; 00043 CIPAddressCtrl m_IPAddress; 00044 CString m_Status; 00045 short m_PortNum; 00046 CString m_Nickname; 00047 //}}AFX_DATA 00048 00049 // ClassWizard generated virtual function overrides 00050 //{{AFX_VIRTUAL(CAgentDlg) 00051 protected: 00052 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 00053 //}}AFX_VIRTUAL 00054 00055 // Implementation 00056 protected: 00057 HICON m_hIcon; 00058 00059 // Generated message map functions 00060 //{{AFX_MSG(CAgentDlg) 00061 virtual BOOL OnInitDialog(); 00062 afx_msg void OnSysCommand(UINT nID, LPARAM lParam); 00063 afx_msg void OnPaint(); 00064 afx_msg HCURSOR OnQueryDragIcon(); 00065 afx_msg void OnConnect(); 00066 afx_msg void OnExit(); 00067 afx_msg void OnTimer(UINT nIDEvent); 00068 afx_msg void OnDblclkAgentsList(NMHDR* pNMHDR, LRESULT* pResult); 00069 afx_msg void OnDisconnect(); 00070 //}}AFX_MSG 00071 DECLARE_MESSAGE_MAP() 00072 00073 private: 00074 void InitAgent(); 00075 void InitEncryption(); 00076 bool RegisterOnCenter(); 00077 void SwitchLists(); 00078 void HandleInMessageQueue(); 00079 void HandleOutMessageQueue(); 00080 void UpdateTimers(); 00081 void UpdateList(); 00082 void ParseIniValues(); 00083 long flip_ip_address(long addr); 00084 00085 private: 00086 auto_ptr<CenterCommunicator> _center_com; 00087 auto_ptr<Encapsulator> _encapsulator; 00088 CWinThread *_recieve_msg_thread; 00089 00090 AGENT_VECTOR _agents_list; 00091 AGENT_VECTOR _new_agents_list; 00092 00093 CENTER_PARAMS _center_params; 00094 CENTER_PARAMS _new_center_params; 00095 00096 AGENT _agent; 00097 ADDRESS _center_address; 00098 00099 Queue _out_msg_queue; 00100 std::queue<UINT32> _out_info_queue; 00101 std::queue<MESSAGE_TYPE> _out_type_queue; 00102 00103 Log _activity_log; 00104 }; 00105 00106 //{{AFX_INSERT_LOCATION}} 00107 // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 00108 00109 #endif // __AGENTDLG_H__