mirror of https://github.com/aria2/aria2
make socket parameter in *Command contructor const
parent
e6e0177560
commit
133f759a0d
|
@ -29,7 +29,7 @@
|
||||||
#include "SleepCommand.h"
|
#include "SleepCommand.h"
|
||||||
#include "prefs.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) {
|
Command(cuid), req(req), e(e), checkSocketIsReadable(false), checkSocketIsWritable(false) {
|
||||||
|
|
||||||
if(s != NULL) {
|
if(s != NULL) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
Socket* readCheckTarget;
|
Socket* readCheckTarget;
|
||||||
Socket* writeCheckTarget;
|
Socket* writeCheckTarget;
|
||||||
public:
|
public:
|
||||||
AbstractCommand(int cuid, Request* req, DownloadEngine* e, Socket* s= NULL);
|
AbstractCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s= NULL);
|
||||||
virtual ~AbstractCommand();
|
virtual ~AbstractCommand();
|
||||||
bool execute();
|
bool execute();
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "InitiateConnectionCommandFactory.h"
|
#include "InitiateConnectionCommandFactory.h"
|
||||||
#include "message.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_sec = 0;
|
||||||
sw.tv_usec = 0;
|
sw.tv_usec = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ protected:
|
||||||
bool prepareForRetry(int wait);
|
bool prepareForRetry(int wait);
|
||||||
bool prepareForNextSegment();
|
bool prepareForNextSegment();
|
||||||
public:
|
public:
|
||||||
DownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
DownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
virtual ~DownloadCommand();
|
virtual ~DownloadCommand();
|
||||||
|
|
||||||
virtual TransferEncoding* getTransferEncoding(string transferEncoding) = 0;
|
virtual TransferEncoding* getTransferEncoding(string transferEncoding) = 0;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "FtpDownloadCommand.h"
|
#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)
|
DownloadCommand(cuid, req, e, dataSocket)
|
||||||
{
|
{
|
||||||
this->ctrlSocket = new Socket(*ctrlSocket);
|
this->ctrlSocket = new Socket(*ctrlSocket);
|
||||||
|
|
|
@ -28,7 +28,7 @@ class FtpDownloadCommand : public DownloadCommand {
|
||||||
private:
|
private:
|
||||||
Socket* ctrlSocket;
|
Socket* ctrlSocket;
|
||||||
public:
|
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();
|
~FtpDownloadCommand();
|
||||||
|
|
||||||
TransferEncoding* getTransferEncoding(string name);
|
TransferEncoding* getTransferEncoding(string name);
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "prefs.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),
|
AbstractCommand(cuid, req, e, s),
|
||||||
dataSocket(NULL), serverSocket(NULL), sequence(SEQ_RECV_GREETING)
|
dataSocket(NULL), serverSocket(NULL), sequence(SEQ_RECV_GREETING)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,7 +80,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
public:
|
public:
|
||||||
FtpNegotiationCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
FtpNegotiationCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~FtpNegotiationCommand();
|
~FtpNegotiationCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "FtpTunnelResponseCommand.h"
|
#include "FtpTunnelResponseCommand.h"
|
||||||
#include "HttpConnection.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);
|
setReadCheckSocket(NULL);
|
||||||
setWriteCheckSocket(NULL);
|
setWriteCheckSocket(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class FtpTunnelRequestCommand : public AbstractCommand {
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
public:
|
public:
|
||||||
FtpTunnelRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
FtpTunnelRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~FtpTunnelRequestCommand();
|
~FtpTunnelRequestCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "DlRetryEx.h"
|
#include "DlRetryEx.h"
|
||||||
#include "message.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);
|
http = new HttpConnection(cuid, socket, req, e->option, e->logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
public:
|
public:
|
||||||
FtpTunnelResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
FtpTunnelResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~FtpTunnelResponseCommand();
|
~FtpTunnelResponseCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ using namespace std;
|
||||||
|
|
||||||
HttpDownloadCommand::HttpDownloadCommand(int cuid, Request* req,
|
HttpDownloadCommand::HttpDownloadCommand(int cuid, Request* req,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
Socket* socket):
|
const Socket* socket):
|
||||||
DownloadCommand(cuid, req, e, socket)
|
DownloadCommand(cuid, req, e, socket)
|
||||||
{
|
{
|
||||||
ChunkedEncoding* ce = new ChunkedEncoding();
|
ChunkedEncoding* ce = new ChunkedEncoding();
|
||||||
|
|
|
@ -37,7 +37,7 @@ class HttpDownloadCommand:public DownloadCommand {
|
||||||
private:
|
private:
|
||||||
map<string, TransferEncoding*> transferEncodings;
|
map<string, TransferEncoding*> transferEncodings;
|
||||||
public:
|
public:
|
||||||
HttpDownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
HttpDownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~HttpDownloadCommand();
|
~HttpDownloadCommand();
|
||||||
|
|
||||||
TransferEncoding* getTransferEncoding(string transferEncoding);
|
TransferEncoding* getTransferEncoding(string transferEncoding);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "HttpConnection.h"
|
#include "HttpConnection.h"
|
||||||
#include "HttpProxyResponseCommand.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);
|
setReadCheckSocket(NULL);
|
||||||
setWriteCheckSocket(socket);
|
setWriteCheckSocket(socket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class HttpProxyRequestCommand : public AbstractCommand {
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
public:
|
public:
|
||||||
HttpProxyRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
HttpProxyRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~HttpProxyRequestCommand();
|
~HttpProxyRequestCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "DlRetryEx.h"
|
#include "DlRetryEx.h"
|
||||||
#include "message.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);
|
http = new HttpConnection(cuid, socket, req, e->option, e->logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
public:
|
public:
|
||||||
HttpProxyResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
HttpProxyResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~HttpProxyResponseCommand();
|
~HttpProxyResponseCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "HttpResponseCommand.h"
|
#include "HttpResponseCommand.h"
|
||||||
#include "HttpConnection.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);
|
setReadCheckSocket(NULL);
|
||||||
setWriteCheckSocket(socket);
|
setWriteCheckSocket(socket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
Command* getNextCommand() const;
|
Command* getNextCommand() const;
|
||||||
public:
|
public:
|
||||||
HttpRequestCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
HttpRequestCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~HttpRequestCommand();
|
~HttpRequestCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
// TODO
|
// TODO
|
||||||
#include "TorrentDownloadEngine.h"
|
#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) {
|
AbstractCommand(cuid, req, e, s) {
|
||||||
http = new HttpConnection(cuid, socket, req, e->option, e->logger);
|
http = new HttpConnection(cuid, socket, req, e->option, e->logger);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
public:
|
public:
|
||||||
HttpResponseCommand(int cuid, Request* req, DownloadEngine* e, Socket* s);
|
HttpResponseCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||||
~HttpResponseCommand();
|
~HttpResponseCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "prefs.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) {
|
Command(cuid), e(e), peer(peer), checkSocketIsReadable(false), checkSocketIsWritable(false) {
|
||||||
|
|
||||||
if(s != NULL) {
|
if(s != NULL) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ private:
|
||||||
Socket* readCheckTarget;
|
Socket* readCheckTarget;
|
||||||
Socket* writeCheckTarget;
|
Socket* writeCheckTarget;
|
||||||
public:
|
public:
|
||||||
PeerAbstractCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, Socket* s = NULL);
|
PeerAbstractCommand(int cuid, Peer* peer, TorrentDownloadEngine* e, const Socket* s = NULL);
|
||||||
virtual ~PeerAbstractCommand();
|
virtual ~PeerAbstractCommand();
|
||||||
bool execute();
|
bool execute();
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,11 +64,3 @@ bool PeerInitiateConnectionCommand::prepareForRetry(int wait) {
|
||||||
e->commands.push(command);
|
e->commands.push(command);
|
||||||
return true;
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
#include "PeerAbstractCommand.h"
|
#include "PeerAbstractCommand.h"
|
||||||
|
|
||||||
class PeerInitiateConnectionCommand : public PeerAbstractCommand {
|
class PeerInitiateConnectionCommand : public PeerAbstractCommand {
|
||||||
private:
|
|
||||||
bool useProxy();
|
|
||||||
bool useProxyTunnel();
|
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal();
|
bool executeInternal();
|
||||||
bool prepareForRetry(int wait);
|
bool prepareForRetry(int wait);
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
PeerInteractionCommand::PeerInteractionCommand(int cuid, Peer* peer,
|
PeerInteractionCommand::PeerInteractionCommand(int cuid, Peer* peer,
|
||||||
TorrentDownloadEngine* e,
|
TorrentDownloadEngine* e,
|
||||||
Socket* s, int sequence)
|
const Socket* s, int sequence)
|
||||||
:PeerAbstractCommand(cuid, peer, e, s), sequence(sequence) {
|
:PeerAbstractCommand(cuid, peer, e, s), sequence(sequence) {
|
||||||
if(sequence == INITIATOR_SEND_HANDSHAKE) {
|
if(sequence == INITIATOR_SEND_HANDSHAKE) {
|
||||||
setReadCheckSocket(NULL);
|
setReadCheckSocket(NULL);
|
||||||
|
|
|
@ -62,7 +62,7 @@ protected:
|
||||||
void onAbort(Exception* ex);
|
void onAbort(Exception* ex);
|
||||||
void beforeSocketCheck();
|
void beforeSocketCheck();
|
||||||
public:
|
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();
|
~PeerInteractionCommand();
|
||||||
|
|
||||||
enum Seq {
|
enum Seq {
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
TrackerDownloadCommand::TrackerDownloadCommand(int cuid, Request* req,
|
TrackerDownloadCommand::TrackerDownloadCommand(int cuid, Request* req,
|
||||||
TorrentDownloadEngine* e,
|
TorrentDownloadEngine* e,
|
||||||
Socket* s)
|
const Socket* s)
|
||||||
:AbstractCommand(cuid, req, e, s), len(0) {
|
:AbstractCommand(cuid, req, e, s), len(0) {
|
||||||
resSize = 256;
|
resSize = 256;
|
||||||
res = new char[resSize];
|
res = new char[resSize];
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal(Segment segment);
|
bool executeInternal(Segment segment);
|
||||||
public:
|
public:
|
||||||
TrackerDownloadCommand(int cuid, Request* req, TorrentDownloadEngine* e, Socket* s);
|
TrackerDownloadCommand(int cuid, Request* req, TorrentDownloadEngine* e, const Socket* s);
|
||||||
~TrackerDownloadCommand();
|
~TrackerDownloadCommand();
|
||||||
|
|
||||||
TransferEncoding* getTransferEncoding(string transferEncoding);
|
TransferEncoding* getTransferEncoding(string transferEncoding);
|
||||||
|
|
Loading…
Reference in New Issue