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

Handshake.h

Go to the documentation of this file.
00001 //
00002 // Handshake.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 // CHandshake figures out what the remote computer wants from the first 7 bytes it sends us
00023 // http://wiki.shareaza.com/static/Developers.Code.CHandshake
00024 
00025 // Make the compiler only include the lines here once, this is the same thing as pragma once
00026 #if !defined(AFX_HANDSHAKE_H__FC762B48_46E6_4BB1_8B25_BC783DA966A4__INCLUDED_)
00027 #define AFX_HANDSHAKE_H__FC762B48_46E6_4BB1_8B25_BC783DA966A4__INCLUDED_
00028 
00029 // Only include the lines beneath this one once
00030 #pragma once
00031 
00032 // Copy in the contents of these files here before compiling
00033 #include "Connection.h" // CHandshake inherits from CConnection
00034 
00035 // OnRead needs the eDonkey2000 packet formats to see if the very first bytes the remote computer sent are one
00036 class CEDPacket;
00037 
00038 // CHandshake adds methods to figure out what network the other computer is on, and authenticate GIV and PUSH requests
00039 class CHandshake : public CConnection // Inherit from CConnection to get a socket and methods to send data through it
00040 {
00041 
00042 public:
00043 
00044         // Make a new CHanshake object
00045         CHandshake();                                   // Make a new object with null and default values
00046         CHandshake(SOCKET hSocket, SOCKADDR_IN* pHost); // Make a new one with this socket and IP address
00047         CHandshake(CHandshake* pCopy);                  // Make a new object that is a copy of this given one
00048 
00049         // Delete this CHandshake object
00050         virtual ~CHandshake(); // The CConnection destructor handles putting things away
00051 
00052 public:
00053 
00054         // Member variables for push operations and the Gnutella index (do)
00055         BOOL  m_bPushing; // True if we connected to the remote computer as part of a push
00056         DWORD m_nIndex;   // (do)
00057 
00058 public:
00059 
00060         // Push open a connection to the remote computer with the given IP address
00061         virtual BOOL Push(IN_ADDR* pAddress, WORD nPort, DWORD nIndex);
00062 
00063 protected:
00064 
00065         // Send a push request, and look at the very start of the handshake
00066         virtual BOOL OnRun();                // Make sure the connection hasn't been going on for too long
00067         virtual BOOL OnConnected();          // Send GIV to the other computer
00068         virtual void OnDropped(BOOL bError); // Record our push didn't work
00069         virtual BOOL OnRead();               // Figure out the remote computer's network from the first 7 bytes it tells us
00070 
00071 protected:
00072 
00073         // Receive push requests
00074         BOOL OnAcceptGive();       // The remote computer said GIV, see if we were expecting it
00075         BOOL OnAcceptPush();       // The remote computer said PUSH, see if we were expecting it
00076         BOOL OnPush(GGUID* pGUID); // See if a child window recognizes the guid
00077 };
00078 
00079 // End the group of lines to only include once, pragma once doesn't require an endif at the bottom
00080 #endif // !defined(AFX_HANDSHAKE_H__FC762B48_46E6_4BB1_8B25_BC783DA966A4__INCLUDED_)

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