00001 /* 00002 00003 Copyright (C) 2006-2007 by Peter Dimov. 00004 00005 This file is part of Calitko (http://www.calitko.org). 00006 00007 Calitko is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 Calitko is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Calitko; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 */ 00022 00023 #ifndef PROTOCOLS__BIT_TORRENT__TRANSFERS__TRANSFER_H 00024 #define PROTOCOLS__BIT_TORRENT__TRANSFERS__TRANSFER_H 00025 00026 #include "Imports.h" 00027 #include "PacketProcessor.h" 00028 #include "TransferSession.h" 00029 #include "TransferSessionStatus.h" 00030 00031 namespace Protocols { 00032 namespace BitTorrent { 00033 namespace Transfers { 00034 00050 class TrackerManager 00051 { 00052 CALITKO_MOCKABLE 00053 00054 public: 00055 virtual ~TrackerManager() {} 00056 virtual void start (const Uri &announce) = 0; 00057 virtual void stop() = 0; 00058 }; 00059 00060 class TrackerManagerStatus 00061 { 00062 CALITKO_MOCKABLE 00063 00064 public: 00065 virtual ~TrackerManagerStatus() {} 00066 virtual void trackerManagerFoundPeers (const QList <PeerInfo> &) = 0; 00067 }; 00068 00076 class SessionManager 00077 { 00078 CALITKO_MOCKABLE 00079 00080 public: 00081 virtual ~SessionManager() {} 00082 virtual void start() = 0; 00083 virtual void addPeers (const QList <PeerInfo> &) = 0; 00084 virtual void closedSession (TransferSession *) = 0; 00085 virtual void stop() = 0; 00086 }; 00087 00088 class SessionManagerStatus 00089 { 00090 CALITKO_MOCKABLE 00091 00092 public: 00093 virtual ~SessionManagerStatus() {} 00094 virtual void sessionManagerEstablishedSession (TransferSession *) = 0; 00095 }; 00096 00098 00110 class Transfer : TransferSessionStatus 00111 { 00112 CALITKO_TESTABLE 00113 REFERENCE_OBJECT (Transfer) 00114 00115 public: 00116 Transfer(TrackerManager *, 00117 SessionManager *, 00118 QList <PacketProcessor *>); 00119 00120 void start (const Torrent &); 00121 void stop(); 00122 00123 // Implementation for the TrackerManagerStatus interface: 00124 void trackerManagerFoundPeers (const QList <PeerInfo> &); 00125 00126 // Implementation for the SessionManagerStatus interface: 00127 void sessionManagerEstablishedSession (TransferSession *); 00128 00129 // Implementation for the SessionStatus interface: 00130 void transferSessionReceivedPacket (TransferSession *, 00131 const Packet &); 00132 void transferSessionSendingPacket (TransferSession *, 00133 const Packet &); 00134 void transferSessionClosing (TransferSession *); 00135 void transferSessionClosed (TransferSession *); 00136 00137 private: 00138 TrackerManager *trackerManager_; 00139 SessionManager *sessionManager_; 00140 QList <PacketProcessor *> packetProcessors_; 00141 }; 00142 00143 } // namespace Transfers 00144 } // namespace BitTorrent 00145 } // namespace Protocols 00146 00147 #endif // PROTOCOLS__BIT_TORRENT__TRANSFERS__TRANSFER_H