/* */ #ifndef _D_DEFAULT_BT_ANNOUNCE_H_ #define _D_DEFAULT_BT_ANNOUNCE_H_ #include "BtAnnounce.h" #include "TimeA2.h" #include "AnnounceList.h" namespace aria2 { class BtContext; class Option; class Logger; class BtRuntime; class PieceStorage; class PeerStorage; class Randomizer; class DefaultBtAnnounce : public BtAnnounce { private: SharedHandle btContext; unsigned int trackers; Time prevAnnounceTime; time_t interval; time_t minInterval; unsigned int complete; unsigned int incomplete; AnnounceList announceList; std::string trackerId; std::string key; const Option* option; Logger* logger; SharedHandle _randomizer; SharedHandle btRuntime; SharedHandle pieceStorage; SharedHandle peerStorage; public: DefaultBtAnnounce(const SharedHandle& btContext, const Option* option); virtual ~DefaultBtAnnounce(); void setBtRuntime(const SharedHandle& btRuntime); SharedHandle getBtRuntime() const; void setPieceStorage(const SharedHandle& pieceStorage); SharedHandle getPieceStorage() const; void setPeerStorage(const SharedHandle& peerStorage); SharedHandle getPeerStorage() const; bool isDefaultAnnounceReady(); bool isStoppedAnnounceReady(); bool isCompletedAnnounceReady(); virtual bool isAnnounceReady(); virtual std::string getAnnounceUrl(); virtual void announceStart(); virtual void announceSuccess(); virtual void announceFailure(); virtual bool isAllAnnounceFailed(); virtual void resetAnnounce(); virtual void processAnnounceResponse(const unsigned char* trackerResponse, size_t trackerResponseLength); virtual bool noMoreAnnounce(); virtual void shuffleAnnounce(); virtual void overrideMinInterval(time_t interval); void generateKey(); void setRandomizer(const SharedHandle& randomizer); time_t getInterval() const { return interval; } time_t getMinInterval() const { return minInterval; } unsigned int getComplete() const { return complete; } unsigned int getIncomplete() const { return incomplete; } const std::string& getTrackerID() const { return trackerId; } }; } // namespace aria2 #endif // _D_DEFAULT_BT_ANNOUNCE_H_