diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-03-31 14:46:48 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-03-31 14:46:48 +0000 |
| commit | 133f759a0db70861cea143d408283701a87f554e (patch) | |
| tree | f772b2f5a4b7e3362180dd0502fcf771151febf2 | |
| parent | e6e017756096d53417622c0a4048d1dfb4340f49 (diff) | |
make socket parameter in *Command contructor const
30 files changed, 28 insertions, 39 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 942e1a55..a6ff1352 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -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) { diff --git a/src/AbstractCommand.h b/src/AbstractCommand.h index e6328a71..7a69c88e 100644 --- a/src/AbstractCommand.h +++ b/src/AbstractCommand.h @@ -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(); }; diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 86b56004..a197ccf3 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -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; } diff --git a/src/DownloadCommand.h b/src/DownloadCommand.h index 79aaf2e5..31d39302 100644 --- a/src/DownloadCommand.h +++ b/src/DownloadCommand.h @@ -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; diff --git a/src/FtpDownloadCommand.cc b/src/FtpDownloadCommand.cc index 3d29c84c..836857dc 100644 --- a/src/FtpDownloadCommand.cc +++ b/src/FtpDownloadCommand.cc @@ -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); diff --git a/src/FtpDownloadCommand.h b/src/FtpDownloadCommand.h index b2db68a8..d39ce1d1 100644 --- a/src/FtpDownloadCommand.h +++ b/src/FtpDownloadCommand.h @@ -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); diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 2f5bb342..9f19995a 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -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) { diff --git a/src/FtpNegotiationCommand.h b/src/FtpNegotiationCommand.h index 29e2c0e6..930fab0e 100644 --- a/src/FtpNegotiationCommand.h +++ b/src/FtpNegotiationCommand.h @@ -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(); }; diff --git a/src/FtpTunnelRequestCommand.cc b/src/FtpTunnelRequestCommand.cc index f103f7ce..6146af32 100644 --- a/src/FtpTunnelRequestCommand.cc +++ b/src/FtpTunnelRequestCommand.cc @@ -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); } diff --git a/src/FtpTunnelRequestCommand.h b/src/FtpTunnelRequestCommand.h index 817f1c9d..35df06e1 100644 --- a/src/FtpTunnelRequestCommand.h +++ b/src/FtpTunnelRequestCommand.h @@ -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(); }; diff --git a/src/FtpTunnelResponseCommand.cc b/src/FtpTunnelResponseCommand.cc index 7009310c..7e44a83c 100644 --- a/src/FtpTunnelResponseCommand.cc +++ b/src/FtpTunnelResponseCommand.cc @@ -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); } diff --git a/src/FtpTunnelResponseCommand.h b/src/FtpTunnelResponseCommand.h index eeba75ac..bf304f29 100644 --- a/src/FtpTunnelResponseCommand.h +++ b/src/FtpTunnelResponseCommand.h @@ -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(); }; diff --git a/src/HttpDownloadCommand.cc b/src/HttpDownloadCommand.cc index 164fc070..ed3351b8 100644 --- a/src/HttpDownloadCommand.cc +++ b/src/HttpDownloadCommand.cc @@ -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(); diff --git a/src/HttpDownloadCommand.h b/src/HttpDownloadCommand.h index 81a537d0..cec431f9 100644 --- a/src/HttpDownloadCommand.h +++ b/src/HttpDownloadCommand.h @@ -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); diff --git a/src/HttpProxyRequestCommand.cc b/src/HttpProxyRequestCommand.cc index f1a5a8c9..196fca31 100644 --- a/src/HttpProxyRequestCommand.cc +++ b/src/HttpProxyRequestCommand.cc @@ -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); } diff --git a/src/HttpProxyRequestCommand.h b/src/HttpProxyRequestCommand.h index 0fe5ca67..6317faa0 100644 --- a/src/HttpProxyRequestCommand.h +++ b/src/HttpProxyRequestCommand.h @@ -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(); }; diff --git a/src/HttpProxyResponseCommand.cc b/src/HttpProxyResponseCommand.cc index cb2764b9..9d0949f6 100644 --- a/src/HttpProxyResponseCommand.cc +++ b/src/HttpProxyResponseCommand.cc @@ -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); } diff --git a/src/HttpProxyResponseCommand.h b/src/HttpProxyResponseCommand.h index 370066e4..f9f7c4bf 100644 --- a/src/HttpProxyResponseCommand.h +++ b/src/HttpProxyResponseCommand.h @@ -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(); }; diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc index 84439b6b..2ca9455e 100644 --- a/src/HttpRequestCommand.cc +++ b/src/HttpRequestCommand.cc @@ -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); } diff --git a/src/HttpRequestCommand.h b/src/HttpRequestCommand.h index f387cdce..d224c5c3 100644 --- a/src/HttpRequestCommand.h +++ b/src/HttpRequestCommand.h @@ -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(); }; diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index d6717d15..be9826e1 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -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); } diff --git a/src/HttpResponseCommand.h b/src/HttpResponseCommand.h index c5269235..2de48586 100644 --- a/src/HttpResponseCommand.h +++ b/src/HttpResponseCommand.h @@ -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(); }; diff --git a/src/PeerAbstractCommand.cc b/src/PeerAbstractCommand.cc index 384ae0e7..fe164ffa 100644 --- a/src/PeerAbstractCommand.cc +++ b/src/PeerAbstractCommand.cc @@ -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) { diff --git a/src/PeerAbstractCommand.h b/src/PeerAbstractCommand.h index 317e0dd7..b5036da0 100644 --- a/src/PeerAbstractCommand.h +++ b/src/PeerAbstractCommand.h @@ -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(); }; diff --git a/src/PeerInitiateConnectionCommand.cc b/src/PeerInitiateConnectionCommand.cc index 441d5e27..3671d67e 100644 --- a/src/PeerInitiateConnectionCommand.cc +++ b/src/PeerInitiateConnectionCommand.cc @@ -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; -} diff --git a/src/PeerInitiateConnectionCommand.h b/src/PeerInitiateConnectionCommand.h index 64c2a7d2..b6599544 100644 --- a/src/PeerInitiateConnectionCommand.h +++ b/src/PeerInitiateConnectionCommand.h @@ -25,9 +25,6 @@ #include "PeerAbstractCommand.h" class PeerInitiateConnectionCommand : public PeerAbstractCommand { -private: - bool useProxy(); - bool useProxyTunnel(); protected: bool executeInternal(); bool prepareForRetry(int wait); diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc index a5569dbb..a2d76af6 100644 --- a/src/PeerInteractionCommand.cc +++ b/src/PeerInteractionCommand.cc @@ -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); diff --git a/src/PeerInteractionCommand.h b/src/PeerInteractionCommand.h index 3950c6ba..72488391 100644 --- a/src/PeerInteractionCommand.h +++ b/src/PeerInteractionCommand.h @@ -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 { diff --git a/src/TrackerDownloadCommand.cc b/src/TrackerDownloadCommand.cc index 85780f7e..e452b6ae 100644 --- a/src/TrackerDownloadCommand.cc +++ b/src/TrackerDownloadCommand.cc @@ -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]; diff --git a/src/TrackerDownloadCommand.h b/src/TrackerDownloadCommand.h index 7fed8bf5..c37f76da 100644 --- a/src/TrackerDownloadCommand.h +++ b/src/TrackerDownloadCommand.h @@ -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); |
