00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(AFX_CHATSESSION_H__F75BAA22_513A_4569_9BFB_90A053662CDB__INCLUDED_)
00023 #define AFX_CHATSESSION_H__F75BAA22_513A_4569_9BFB_90A053662CDB__INCLUDED_
00024
00025 #pragma once
00026
00027 #include "Connection.h"
00028
00029 class CEDPacket;
00030 class CEDClient;
00031 class CG2Packet;
00032 class CGProfile;
00033 class CChatFrame;
00034 class CPrivateChatFrame;
00035
00036
00037 class CChatSession : public CConnection
00038 {
00039
00040 public:
00041 CChatSession(CChatFrame* pFrame = NULL);
00042 virtual ~CChatSession();
00043
00044
00045 public:
00046 BOOL m_bGUID;
00047 GGUID m_pGUID;
00048 public:
00049 int m_nState;
00050 PROTOCOLID m_nProtocol;
00051 BOOL m_bOld;
00052 BOOL m_bMustPush;
00053 DWORD m_tPushed;
00054 CString m_sUserAgent;
00055 CString m_sUserNick;
00056 CGProfile* m_pProfile;
00057 BOOL m_bUnicode;
00058 DWORD m_nClientID;
00059 SOCKADDR_IN m_pServer;
00060 public:
00061 CPrivateChatFrame* m_pWndPrivate;
00062 CWnd* m_pWndPublic;
00063
00064
00065 public:
00066 void Setup(GGUID* pGUID, SOCKADDR_IN* pHost, BOOL bMustPush);
00067 BOOL Connect();
00068 TRISTATE GetConnectedState() const;
00069 void OnED2KMessage(CEDPacket* pPacket);
00070 virtual void AttachTo(CConnection* pConnection);
00071 BOOL SendPush(BOOL bAutomatic);
00072 BOOL OnPush(GGUID* pGUID, CConnection* pConnection);
00073 virtual void Close();
00074 public:
00075 void Print(LPCTSTR pszString);
00076 void Send(CG2Packet* pPacket, BOOL bRelease = TRUE);
00077 BOOL SendPrivateMessage(BOOL bAction, LPCTSTR pszText);
00078 void StatusMessage(int nFlags, UINT nID, ...);
00079 void OnOpenWindow();
00080 void OnCloseWindow();
00081 protected:
00082 virtual BOOL OnRun();
00083 virtual BOOL OnConnected();
00084 virtual BOOL OnRead();
00085 virtual void OnDropped(BOOL bError);
00086 virtual BOOL OnHeaderLine(CString& strHeader, CString& strValue);
00087 virtual BOOL OnHeadersComplete();
00088 protected:
00089 BOOL ReadHandshake();
00090 BOOL ReadPacketsED2K();
00091 BOOL SendPacketsED2K();
00092 BOOL ReadText();
00093 BOOL ReadPackets();
00094 void PostOpenWindow();
00095 protected:
00096
00097 BOOL SendChatMessage(CEDPacket* pPacket);
00098 BOOL OnChatMessage(CEDPacket* pPacket);
00099 BOOL OnEstablished();
00100 BOOL OnText(const CString& str);
00101 BOOL OnPacket(CG2Packet* pPacket);
00102 BOOL OnProfileChallenge(CG2Packet* pPacket);
00103 BOOL OnProfileDelivery(CG2Packet* pPacket);
00104 BOOL OnChatRequest(CG2Packet* pPacket);
00105 BOOL OnChatAnswer(CG2Packet* pPacket);
00106 BOOL OnChatMessage(CG2Packet* pPacket);
00107
00108 };
00109
00110 enum
00111 {
00112 cssNull, cssConnecting, cssRequest1, cssHeaders1, cssRequest2, cssHeaders2,
00113 cssRequest3, cssHeaders3, cssHandshake, cssActive
00114 };
00115
00116 #endif // !defined(AFX_CHATSESSION_H__F75BAA22_513A_4569_9BFB_90A053662CDB__INCLUDED_)