Ver código fonte

make socket parameter in *Command contructor const

Tatsuhiro Tsujikawa 19 anos atrás
pai
commit
133f759a0d

+ 1 - 1
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) {

+ 1 - 1
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();
 };

+ 1 - 1
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;
 }

+ 1 - 1
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;

+ 1 - 1
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);

+ 1 - 1
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);

+ 1 - 1
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)
 {

+ 1 - 1
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();
 };
 

+ 1 - 1
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);
 }

+ 1 - 1
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();
 };
 

+ 1 - 1
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);
 }
 

+ 1 - 1
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();
 };
 

+ 1 - 1
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();

+ 1 - 1
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);

+ 1 - 1
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);
 }

+ 1 - 1
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();
 };
 

+ 1 - 1
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);
 }
 

+ 1 - 1
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();
 };
 

+ 1 - 1
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);
 }

+ 1 - 1
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();
 };
 

+ 1 - 1
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);
 }

+ 1 - 1
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();
 };
 

+ 1 - 1
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) {

+ 1 - 1
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();
 };

+ 0 - 8
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;
-}

+ 0 - 3
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);

+ 1 - 1
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);

+ 1 - 1
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 {

+ 1 - 1
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];

+ 1 - 1
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);