Protocols::BitTorrent::Trackers::TrackerManagerImpl Class Reference

#include <TrackerManagerImpl.h> [code]

Inherits Protocols::BitTorrent::Trackers::TrackerManager.

Inheritance diagram for Protocols::BitTorrent::Trackers::TrackerManagerImpl:

Inheritance graph
[legend]
Collaboration diagram for Protocols::BitTorrent::Trackers::TrackerManagerImpl:

Collaboration graph
[legend]
List of all members.

Detailed Description

Implementation of the TrackerManager interface.

See TrackerManager class (interface) description for more info about the purpose of this class.

Todo:
Implement real tracker request creation (from the selected torrent object). See createTrackerRequest().
Todo:
Implement session re-establishment after it gets closed? Currently the tracker manager gets stopped after the session gets closed, so maybe we should try to "reconnect". This would require adding some more member functions to the TrackerManagerStatus like sessionEstablished(), sessionClosed() etc. to keep the user informed.
Todo:
What is the meaning of the 'min interval' parameter in the TrackerResponse? I don't see the difference between the 'interval' and the 'min interval' parameter. Maybe it means that after a session gets closed the tracker manager must wait for this ammount of time before sending the first request?

Definition at line 75 of file TrackerManagerImpl.h.

Public Member Functions

 TrackerManagerImpl (TrackerRequestSessionFactory *, Timer *, TrackerManagerStatus *)
 Constructor.
 ~TrackerManagerImpl ()
 Destructor.
void start (const Torrent &)
 Starts a tracker manager.
void stop ()
 Stops a tracker manager.
void updateTime ()
 The handler that gets called when the tracker update interval elapses.
void trackerRequestSessionFactorySessionEstablished (TrackerRequestSession *)
 TrackerRequestSession was established.
void trackerRequestSessionFactorySessionError (TrackerRequestSession *, const QString &)
 There was an error in the TrackerRequestSession.
void trackerRequestSessionFactoryResponseRecieved (TrackerRequestSession *, const TrackerResponse &)
 TrackerRequestSession recieved a response.
void trackerRequestSessionFactorySessionClosing (TrackerRequestSession *)
 TrackerRequestSession started closing.
void trackerRequestSessionFactorySessionClosed (TrackerRequestSession *)
 TrackerRequestSession was closed.

Private Types

enum  State {
  Started,
  Stopping,
  Stopped
}
 States. More...

Private Member Functions

CALITKO_TESTABLE TrackerManagerImpl (const TrackerManagerImpl &)
TrackerManagerImploperator= (const TrackerManagerImpl &)
TrackerRequest createTrackerRequest () const

Private Attributes

TrackerRequestSessionFactorysessionFactory_
Timertimer_
TrackerManagerStatusstatus_
TrackerRequestSessionsession_
State state_
Torrent torrent_
uint updateInterval_
QByteArray trackerId_


Member Enumeration Documentation

enum Protocols::BitTorrent::Trackers::TrackerManagerImpl::State [private]
 

States.

Enumerator:
Started 
Stopping 
Stopped 

Definition at line 101 of file TrackerManagerImpl.h.


Constructor & Destructor Documentation

CALITKO_TESTABLE Protocols::BitTorrent::Trackers::TrackerManagerImpl::TrackerManagerImpl const TrackerManagerImpl  )  [private]
 

TrackerManagerImpl::TrackerManagerImpl TrackerRequestSessionFactory peersRequestSessionFactory,
Timer trackerUpdateTimer,
TrackerManagerStatus trackerManagerStatus
 

Constructor.

Parameters:
peersRequestSessionFactory Factory that produces request sessions.
trackerUpdateTimer Timer that will be used to time update interval.
trackerManagerStatus Tracker manager notifications listener.
Precondition:
trackerUpdateTimer must be stopped.
Constructs a TrackerManager object. No status notifications are sent.

Todo:
How to assert the precondition since there is no Timer::isStarted() member function?

Definition at line 40 of file TrackerManagerImpl.cpp.

TrackerManagerImpl::~TrackerManagerImpl  ) 
 

Destructor.

Destroys a TrackerManager object. No status notifications are sent.

Definition at line 54 of file TrackerManagerImpl.cpp.


Member Function Documentation

TrackerRequest TrackerManagerImpl::createTrackerRequest  )  const [private]
 

Todo:
Implement real tracker request creation (from the selected torrent object). Now it's returned only a hardcoded value.

Definition at line 214 of file TrackerManagerImpl.cpp.

TrackerManagerImpl& Protocols::BitTorrent::Trackers::TrackerManagerImpl::operator= const TrackerManagerImpl  )  [private]
 

void TrackerManagerImpl::start const Torrent torrent  )  [virtual]
 

Starts a tracker manager.

Parameters:
torrent Torrent object from which the tracker manager will get all needed data for retrieveing a list of peers.
Tracker manager will enter the Started state and will start periodically querying trackers to get peers from them. No status notifications are sent.

See also:
stop(), updateTime()

Implements Protocols::BitTorrent::Trackers::TrackerManager.

Definition at line 68 of file TrackerManagerImpl.cpp.

void TrackerManagerImpl::stop  )  [virtual]
 

Stops a tracker manager.

Tracker manager will enter the Stopping state - nothing could handled after then - and waits until the tracker session gets closed (if it was opened). No status notifications are sent.

See also:
start()

Implements Protocols::BitTorrent::Trackers::TrackerManager.

Definition at line 84 of file TrackerManagerImpl.cpp.

void TrackerManagerImpl::trackerRequestSessionFactoryResponseRecieved TrackerRequestSession session,
const TrackerResponse response
 

TrackerRequestSession recieved a response.

Parameters:
session TrackerRequestSession that recieved the response.
response Tracker response that was recieved.
trackerManagerFoundPeers() status notification with the recieved list of peers from the response will be sent.

Definition at line 152 of file TrackerManagerImpl.cpp.

void TrackerManagerImpl::trackerRequestSessionFactorySessionClosed TrackerRequestSession session  ) 
 

TrackerRequestSession was closed.

Parameters:
session TrackerRequestSession that was closed.
Tracker manager will enter the Stopped state - nothing could handled after then. No status notifications are sent.

See also:
stop()

Definition at line 198 of file TrackerManagerImpl.cpp.

void TrackerManagerImpl::trackerRequestSessionFactorySessionClosing TrackerRequestSession session  ) 
 

TrackerRequestSession started closing.

Parameters:
session TrackerRequestSession that started closing.
Tracker manager will enter the Stopping state - nothing could handled after then.

See also:
trackerRequestSessionFactorySessionClosed()

Definition at line 179 of file TrackerManagerImpl.cpp.

void TrackerManagerImpl::trackerRequestSessionFactorySessionError TrackerRequestSession session,
const QString &  errorMessage
 

There was an error in the TrackerRequestSession.

Parameters:
session TrackerRequestSession that had an error.
errorMessage Error message specifying what happened.
trackerManagerError() status notification with the errorMessage will be sent.

Definition at line 134 of file TrackerManagerImpl.cpp.

void TrackerManagerImpl::trackerRequestSessionFactorySessionEstablished TrackerRequestSession session  ) 
 

TrackerRequestSession was established.

Parameters:
session TrackerRequestSession that was established.
First tracker request will be sent via this session. Update requests will be sent in the updateTime() member function. No status notifications are sent.

Definition at line 117 of file TrackerManagerImpl.cpp.

void TrackerManagerImpl::updateTime  )  [virtual]
 

The handler that gets called when the tracker update interval elapses.

Precondition:
Tracker manager must be started and the session with the tracker must have been established.
An update request will be sent. No status notifications are sent.

Implements Protocols::BitTorrent::Trackers::TrackerManager.

Definition at line 100 of file TrackerManagerImpl.cpp.


Member Data Documentation

TrackerRequestSession* Protocols::BitTorrent::Trackers::TrackerManagerImpl::session_ [private]
 

Definition at line 113 of file TrackerManagerImpl.h.

TrackerRequestSessionFactory* Protocols::BitTorrent::Trackers::TrackerManagerImpl::sessionFactory_ [private]
 

Definition at line 110 of file TrackerManagerImpl.h.

State Protocols::BitTorrent::Trackers::TrackerManagerImpl::state_ [private]
 

Definition at line 114 of file TrackerManagerImpl.h.

TrackerManagerStatus* Protocols::BitTorrent::Trackers::TrackerManagerImpl::status_ [private]
 

Definition at line 112 of file TrackerManagerImpl.h.

Timer* Protocols::BitTorrent::Trackers::TrackerManagerImpl::timer_ [private]
 

Definition at line 111 of file TrackerManagerImpl.h.

Torrent Protocols::BitTorrent::Trackers::TrackerManagerImpl::torrent_ [private]
 

Definition at line 115 of file TrackerManagerImpl.h.

QByteArray Protocols::BitTorrent::Trackers::TrackerManagerImpl::trackerId_ [private]
 

Definition at line 117 of file TrackerManagerImpl.h.

uint Protocols::BitTorrent::Trackers::TrackerManagerImpl::updateInterval_ [private]
 

Definition at line 116 of file TrackerManagerImpl.h.


The documentation for this class was generated from the following files: