make socket parameter in *Command contructor const

pull/1/head
Tatsuhiro Tsujikawa 2006-03-31 14:46:48 +00:00
parent e6e0177560
commit 133f759a0d
30 changed files with 28 additions and 39 deletions

View File

@ -29,7 +29,7 @@
#include "SleepCommand.h"
#include "prefs.h"
AbstractCommand::AbstractCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):
AbstractCommand::AbstractCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):
Command(cuid), req(req), e(e), checkSocketIsReadable(false), checkSocketIsWritable(false) {
if(s != NULL) {

View File

@ -50,7 +50,7 @@ private:
Socket* readCheckTarget;
Socket* writeCheckTarget;
public:
AbstractCommand(int cuid, Request* req, DownloadEngine* e, Socket* s= NULL);
AbstractCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s= NULL);
virtual ~AbstractCommand();
bool execute();
};

View File

@ -27,7 +27,7 @@
#include "InitiateConnectionCommandFactory.h"
#include "message.h"
DownloadCommand::DownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s), lastSize(0) {
DownloadCommand::DownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):AbstractCommand(cuid, req, e, s), lastSize(0) {
sw.tv_sec = 0;
sw.tv_usec = 0;
}

View File

@ -39,7 +39,7 @@ protected:
bool prepareForRetry(int wait);
bool prepareForNextSegment();
public:
DownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
DownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
virtual ~DownloadCommand();
virtual TransferEncoding* getTransferEncoding(string transferEncoding) = 0;

View File

@ -21,7 +21,7 @@
/* copyright --> */
#include "FtpDownloadCommand.h"
FtpDownloadCommand::FtpDownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* dataSocket, Socket* ctrlSocket):
FtpDownloadCommand::FtpDownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* dataSocket, const Socket* ctrlSocket):
DownloadCommand(cuid, req, e, dataSocket)
{
this->ctrlSocket = new Socket(*ctrlSocket);

View File

@ -28,7 +28,7 @@ class FtpDownloadCommand : public DownloadCommand {
private:
Socket* ctrlSocket;
public:
FtpDownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* dataSocket, Socket* ctrlSocket);
FtpDownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* dataSocket, const Socket* ctrlSocket);
~FtpDownloadCommand();
TransferEncoding* getTransferEncoding(string name);

View File

@ -26,7 +26,7 @@
#include "message.h"
#include "prefs.h"
FtpNegotiationCommand::FtpNegotiationCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):
FtpNegotiationCommand::FtpNegotiationCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):
AbstractCommand(cuid, req, e, s),
dataSocket(NULL), serverSocket(NULL), sequence(SEQ_RECV_GREETING)
{

View File

@ -80,7 +80,7 @@ private:
protected:
bool executeInternal(Segment segment);
public:
FtpNegotiationCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
FtpNegotiationCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~FtpNegotiationCommand();
};

View File

@ -23,7 +23,7 @@
#include "FtpTunnelResponseCommand.h"
#include "HttpConnection.h"
FtpTunnelRequestCommand::FtpTunnelRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s) {
FtpTunnelRequestCommand::FtpTunnelRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):AbstractCommand(cuid, req, e, s) {
setReadCheckSocket(NULL);
setWriteCheckSocket(NULL);
}

View File

@ -28,7 +28,7 @@ class FtpTunnelRequestCommand : public AbstractCommand {
protected:
bool executeInternal(Segment segment);
public:
FtpTunnelRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
FtpTunnelRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~FtpTunnelRequestCommand();
};

View File

@ -24,7 +24,7 @@
#include "DlRetryEx.h"
#include "message.h"
FtpTunnelResponseCommand::FtpTunnelResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s) {
FtpTunnelResponseCommand::FtpTunnelResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):AbstractCommand(cuid, req, e, s) {
http = new HttpConnection(cuid, socket, req, e->option, e->logger);
}

View File

@ -31,7 +31,7 @@ private:
protected:
bool executeInternal(Segment segment);
public:
FtpTunnelResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
FtpTunnelResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~FtpTunnelResponseCommand();
};

View File

@ -33,7 +33,7 @@ using namespace std;
HttpDownloadCommand::HttpDownloadCommand(int cuid, Request* req,
DownloadEngine* e,
Socket* socket):
const Socket* socket):
DownloadCommand(cuid, req, e, socket)
{
ChunkedEncoding* ce = new ChunkedEncoding();

View File

@ -37,7 +37,7 @@ class HttpDownloadCommand:public DownloadCommand {
private:
map<string, TransferEncoding*> transferEncodings;
public:
HttpDownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
HttpDownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~HttpDownloadCommand();
TransferEncoding* getTransferEncoding(string transferEncoding);

View File

@ -23,7 +23,7 @@
#include "HttpConnection.h"
#include "HttpProxyResponseCommand.h"
HttpProxyRequestCommand::HttpProxyRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s) {
HttpProxyRequestCommand::HttpProxyRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):AbstractCommand(cuid, req, e, s) {
setReadCheckSocket(NULL);
setWriteCheckSocket(socket);
}

View File

@ -28,7 +28,7 @@ class HttpProxyRequestCommand : public AbstractCommand {
protected:
bool executeInternal(Segment segment);
public:
HttpProxyRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
HttpProxyRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~HttpProxyRequestCommand();
};

View File

@ -24,7 +24,7 @@
#include "DlRetryEx.h"
#include "message.h"
HttpProxyResponseCommand::HttpProxyResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s) {
HttpProxyResponseCommand::HttpProxyResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):AbstractCommand(cuid, req, e, s) {
http = new HttpConnection(cuid, socket, req, e->option, e->logger);
}

View File

@ -31,7 +31,7 @@ private:
protected:
bool executeInternal(Segment segment);
public:
HttpProxyResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
HttpProxyResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~HttpProxyResponseCommand();
};

View File

@ -23,7 +23,7 @@
#include "HttpResponseCommand.h"
#include "HttpConnection.h"
HttpRequestCommand::HttpRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s) {
HttpRequestCommand::HttpRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):AbstractCommand(cuid, req, e, s) {
setReadCheckSocket(NULL);
setWriteCheckSocket(socket);
}

View File

@ -29,7 +29,7 @@ protected:
bool executeInternal(Segment segment);
Command* getNextCommand() const;
public:
HttpRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
HttpRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~HttpRequestCommand();
};

View File

@ -30,7 +30,7 @@
// TODO
#include "TorrentDownloadEngine.h"
HttpResponseCommand::HttpResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):
HttpResponseCommand::HttpResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s):
AbstractCommand(cuid, req, e, s) {
http = new HttpConnection(cuid, socket, req, e->option, e->logger);
}

View File

@ -37,7 +37,7 @@ private:
protected:
bool executeInternal(Segment segment);
public:
HttpResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
HttpResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
~HttpResponseCommand();
};

View File

@ -27,7 +27,7 @@
#include "message.h"
#include "prefs.h"
PeerAbstractCommand::PeerAbstractCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, Socket* s):
PeerAbstractCommand::PeerAbstractCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, const Socket* s):
Command(cuid), e(e), peer(peer), checkSocketIsReadable(false), checkSocketIsWritable(false) {
if(s != NULL) {

View File

@ -51,7 +51,7 @@ private:
Socket* readCheckTarget;
Socket* writeCheckTarget;
public:
PeerAbstractCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, Socket* s = NULL);
PeerAbstractCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, const Socket* s = NULL);
virtual ~PeerAbstractCommand();
bool execute();
};

View File

@ -64,11 +64,3 @@ bool PeerInitiateConnectionCommand::prepareForRetry(int wait) {
e->commands.push(command);
return true;
}
bool PeerInitiateConnectionCommand::useProxy() {
return e->option->get(PREF_HTTP_PROXY_ENABLED) == V_TRUE;
}
bool PeerInitiateConnectionCommand::useProxyTunnel() {
return e->option->get(PREF_HTTP_PROXY_METHOD) == V_TUNNEL;
}

View File

@ -25,9 +25,6 @@
#include "PeerAbstractCommand.h"
class PeerInitiateConnectionCommand : public PeerAbstractCommand {
private:
bool useProxy();
bool useProxyTunnel();
protected:
bool executeInternal();
bool prepareForRetry(int wait);

View File

@ -30,7 +30,7 @@
PeerInteractionCommand::PeerInteractionCommand(int cuid, Peer* peer,
TorrentDownloadEngine* e,
Socket* s, int sequence)
const Socket* s, int sequence)
:PeerAbstractCommand(cuid, peer, e, s), sequence(sequence) {
if(sequence == INITIATOR_SEND_HANDSHAKE) {
setReadCheckSocket(NULL);

View File

@ -62,7 +62,7 @@ protected:
void onAbort(Exception* ex);
void beforeSocketCheck();
public:
PeerInteractionCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, Socket* s, int sequence);
PeerInteractionCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, const Socket* s, int sequence);
~PeerInteractionCommand();
enum Seq {

View File

@ -29,7 +29,7 @@
TrackerDownloadCommand::TrackerDownloadCommand(int cuid, Request* req,
TorrentDownloadEngine* e,
Socket* s)
const Socket* s)
:AbstractCommand(cuid, req, e, s), len(0) {
resSize = 256;
res = new char[resSize];

View File

@ -38,7 +38,7 @@ private:
protected:
bool executeInternal(Segment segment);
public:
TrackerDownloadCommand(int cuid, Request* req, TorrentDownloadEngine* e, Socket* s);
TrackerDownloadCommand(int cuid, Request* req, TorrentDownloadEngine* e, const Socket* s);
~TrackerDownloadCommand();
TransferEncoding* getTransferEncoding(string transferEncoding);