/* */ #ifndef _D_PEER_ABSTRACT_COMMAND_H_ #define _D_PEER_ABSTRACT_COMMAND_H_ #include "Command.h" #include "SharedHandle.h" #include "TimeA2.h" namespace aria2 { class DownloadEngine; class Exception; class Peer; class SocketCore; class PeerAbstractCommand : public Command { private: Time checkPoint; time_t timeout; protected: DownloadEngine* e; SharedHandle socket; SharedHandle peer; void setTimeout(time_t timeout) { this->timeout = timeout; } virtual bool prepareForNextPeer(time_t wait); virtual void onAbort() {}; // This function is called when DownloadFailureException is caught right after // the invocation of onAbort(). virtual void onFailure() {}; virtual bool exitBeforeExecute() = 0; virtual bool executeInternal() = 0; void setReadCheckSocket(const SharedHandle& socket); void setWriteCheckSocket(const SharedHandle& socket); void disableReadCheckSocket(); void disableWriteCheckSocket(); void setNoCheck(bool check); void updateKeepAlive(); private: bool checkSocketIsReadable; bool checkSocketIsWritable; SharedHandle readCheckTarget; SharedHandle writeCheckTarget; bool noCheck; public: PeerAbstractCommand(cuid_t cuid, const SharedHandle& peer, DownloadEngine* e, const SharedHandle& s = SharedHandle()); virtual ~PeerAbstractCommand(); virtual bool execute(); }; } // namespace aria2 #endif // _D_PEER_ABSTRACT_COMMAND_H_