Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ChatSession.h

Go to the documentation of this file.
00001 //
00002 // ChatSession.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 // Construction
00040 public:
00041         CChatSession(CChatFrame* pFrame = NULL);
00042         virtual ~CChatSession();
00043 
00044 // Attributes
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;             // ED2K Client in UTF-8 format
00058         DWORD                   m_nClientID;    // ED2K Client ID (if appropriate)
00059         SOCKADDR_IN             m_pServer;              // ED2K server (If appropriate)
00060 public:
00061         CPrivateChatFrame*      m_pWndPrivate;
00062         CWnd*                           m_pWndPublic;
00063 
00064 // Operations
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_)

Generated on Thu Dec 15 10:39:34 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2