Skip to content

Commit

Permalink
D-lo: Fixed some includes issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
dloman77 committed Jan 27, 2010
1 parent 7ec6e6c commit e7600ac
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
15 changes: 10 additions & 5 deletions include/GS/NetSockPortal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@
#ifndef __NETSOCKPORTAL_H__
#define __NETSOCKPORTAL_H__

#include <QTcpServer>
#include <QTcpSocket>
#include <QString>

#include "GE/Logger.h"
#include "GS/netMsg/NetMsgFactory.h"

class NetSockPortalManager;

class NetSockPortal: public QTcpSocket
{
Q_OBJECT
Q_OBJECT

friend class NetSockPortalManager;
friend class NetSockPortalManager;

public:
NetSockPortal(QObject* parent = 0);
NetSockPortal(NetSockPortalManager* parent);
virtual ~NetSockPortal();

bool hasMsg();
Expand All @@ -55,12 +58,12 @@ class NetSockPortal: public QTcpSocket
NotConnected = 0, Handshaking = 5, Ready = 10, Failed = 15,
};

signals:
signals:
void msgReady();
void portalHandshakeComplete();

protected slots:
void moveDataFromSocketBuffer();
void moveDataFromSocketBuffer();

private:
QString remHostName;
Expand All @@ -70,6 +73,8 @@ protected slots:

int portStatus;

NetSockPortalManager* nspm;

};

#endif
Expand Down
1 change: 1 addition & 0 deletions include/GS/NetSockPortalManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QList>
#include <QByteArray>


class NetSockPortalManager: public QTcpServer
{
Q_OBJECT
Expand Down
19 changes: 11 additions & 8 deletions src/GS/NetSockPortal.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
#include "GS/GSCommon.h"
#include "GS/netMsg/NetMsg.h"
#include "GS/netMsg/RemHostNameSetMsg.h"
#include "GS/NetSockPortalManager.h"

#include <QHostAddress>

NetSockPortal::NetSockPortal(QObject* parent) :
QTcpSocket(parent)
NetSockPortal::NetSockPortal(NetSockPortalManager* nspm) :
QTcpSocket()
{
this->log = Logger::getInstance();
this->nspm = nspm;

QObject::connect(this, SIGNAL(readyRead()), this, SLOT(
moveDataFromSocketBuffer()));
Expand Down Expand Up @@ -94,12 +96,13 @@ void NetSockPortal::moveDataFromSocketBuffer()
return;
}

// //If the nspm returns a NetSockPortal object, then this host is already on the network!
// if (this->nspm->getPortalByRemHostname(remoteHostname) != NULL)
// {
// this->disconnect(PORTAL_HANDSHAKE_FAILURE);
// return;
// }
//If the nspm returns a NetSockPortal object, then this host is already on the network!
if (this->nspm->getPortalByRemHostname(remoteHostname)
!= NULL)
{
this->disconnect(PORTAL_HANDSHAKE_FAILURE);
return;
}

this->remHostName = remoteHostname;
this->portStatus = NetSockPortal::Ready;
Expand Down
8 changes: 4 additions & 4 deletions src/GS/NetSockPortalManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ NetSockPortal* NetSockPortalManager::connectTo(QHostAddress addy, quint16 port)
NetSockPortal* NetSockPortalManager::preparePortal()
{
//Create new NSP and setup signals
NetSockPortal* nsp = new NetSockPortal();
NetSockPortal* nsp = new NetSockPortal(this);

//Set up signal prior to initializing the NSP with a socket Descriptor
QObject::connect(nsp, SIGNAL(portalHandshakeComplete()), this, SLOT(
Expand Down Expand Up @@ -105,7 +105,7 @@ void NetSockPortalManager::handlePortalHandshakeCompleted()
NetSockPortal* nsp = (NetSockPortal*) sender();

//Map the NSP
this->portalList->insert(nsp->getRemoteHostName(), nsp);
NetSockPortalManager::portalList->insert(nsp->getRemoteHostName(), nsp);

QObject::disconnect(nsp, SIGNAL(portalHandshakeComplete()), this, SLOT(
handlePortalHandshakeCompleted()));
Expand All @@ -120,7 +120,7 @@ void NetSockPortalManager::handlePortalDisconnect()
NetSockPortal* nsp = (NetSockPortal*) sender();

//Map the NSP
this->portalList->remove(nsp->getRemoteHostName());
NetSockPortalManager::portalList->remove(nsp->getRemoteHostName());
}

void NetSockPortalManager::sendLocalHostName(NetSockPortal* nsp)
Expand All @@ -131,7 +131,7 @@ void NetSockPortalManager::sendLocalHostName(NetSockPortal* nsp)

NetSockPortal* NetSockPortalManager::getPortalByRemHostname(QString remHostName)
{
return this->portalList->value(remHostName, NULL);
return NetSockPortalManager::portalList->value(remHostName, NULL);
}

// Local Variables:
Expand Down

0 comments on commit e7600ac

Please sign in to comment.