2009-09-25 21:05:59 +00:00
|
|
|
/*
|
2014-01-18 20:56:57 +00:00
|
|
|
* This file Copyright (C) 2010-2014 Mnemosyne LLC
|
2009-09-25 21:05:59 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-09-25 21:05:59 +00:00
|
|
|
*
|
2010-10-01 13:33:39 +00:00
|
|
|
* $Id$
|
2009-09-25 21:05:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TRANSMISSION__
|
|
|
|
#error only libtransmission should #include this header.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _TR_ANNOUNCER_H_
|
|
|
|
#define _TR_ANNOUNCER_H_
|
|
|
|
|
|
|
|
#include "transmission.h"
|
|
|
|
|
|
|
|
struct tr_announcer;
|
|
|
|
struct tr_torrent_tiers;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* *** Tracker Publish / Subscribe
|
|
|
|
* **/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_TRACKER_WARNING,
|
|
|
|
TR_TRACKER_ERROR,
|
|
|
|
TR_TRACKER_ERROR_CLEAR,
|
|
|
|
TR_TRACKER_PEERS
|
|
|
|
}
|
|
|
|
TrackerEventType;
|
|
|
|
|
2011-01-22 17:45:54 +00:00
|
|
|
struct tr_pex;
|
|
|
|
|
2010-01-19 19:37:00 +00:00
|
|
|
/** @brief Notification object to tell listeners about announce or scrape occurences */
|
2009-09-25 21:05:59 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* what type of event this is */
|
|
|
|
TrackerEventType messageType;
|
|
|
|
|
|
|
|
/* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */
|
2010-05-19 19:02:25 +00:00
|
|
|
const char * text;
|
|
|
|
const char * tracker;
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
/* for TR_TRACKER_PEERS */
|
2011-01-22 17:45:54 +00:00
|
|
|
const struct tr_pex * pex;
|
|
|
|
size_t pexCount;
|
2010-04-20 21:54:03 +00:00
|
|
|
|
2010-12-27 19:18:17 +00:00
|
|
|
/* [0...100] for probability a peer is a seed. calculated by the leecher/seeder ratio */
|
2010-04-20 21:54:03 +00:00
|
|
|
int8_t seedProbability;
|
2009-09-25 21:05:59 +00:00
|
|
|
}
|
|
|
|
tr_tracker_event;
|
|
|
|
|
2013-09-08 17:08:18 +00:00
|
|
|
typedef void (*tr_tracker_callback) (tr_torrent * tor,
|
|
|
|
const tr_tracker_event * event,
|
|
|
|
void * client_data);
|
2010-06-19 14:33:10 +00:00
|
|
|
|
2009-09-25 21:05:59 +00:00
|
|
|
/**
|
|
|
|
*** Session ctor/dtor
|
|
|
|
**/
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerInit (tr_session *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerClose (tr_session *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** For torrent customers
|
|
|
|
**/
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
struct tr_torrent_tiers * tr_announcerAddTorrent (tr_torrent * torrent,
|
2013-09-08 17:08:18 +00:00
|
|
|
tr_tracker_callback cb,
|
2012-12-05 17:29:46 +00:00
|
|
|
void * cbdata);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
bool tr_announcerHasBacklog (const struct tr_announcer *);
|
2009-12-02 05:30:46 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerResetTorrent (struct tr_announcer*, tr_torrent*);
|
2009-10-02 04:54:02 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerRemoveTorrent (struct tr_announcer * ,
|
|
|
|
tr_torrent *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerChangeMyPort (tr_torrent *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
bool tr_announcerCanManualAnnounce (const tr_torrent *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerManualAnnounce (tr_torrent *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerTorrentStarted (tr_torrent *);
|
|
|
|
void tr_announcerTorrentStopped (tr_torrent *);
|
|
|
|
void tr_announcerTorrentCompleted (tr_torrent *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2010-02-08 16:47:30 +00:00
|
|
|
enum { TR_ANN_UP, TR_ANN_DOWN, TR_ANN_CORRUPT };
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerAddBytes (tr_torrent *, int up_down_or_corrupt, uint32_t byteCount);
|
2010-02-08 16:47:30 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
time_t tr_announcerNextManualAnnounce (const tr_torrent *);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_tracker_stat * tr_announcerStats (const tr_torrent * torrent,
|
|
|
|
int * setmeTrackerCount);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_announcerStatsFree (tr_tracker_stat * trackers,
|
|
|
|
int trackerCount);
|
2009-09-25 21:05:59 +00:00
|
|
|
|
2011-03-17 18:51:31 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_tracker_udp_upkeep (tr_session * session);
|
2011-03-17 18:51:31 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_tracker_udp_close (tr_session * session);
|
2011-03-17 18:51:31 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
bool tr_tracker_udp_is_idle (const tr_session * session);
|
2011-03-17 18:51:31 +00:00
|
|
|
|
|
|
|
|
2009-09-25 21:05:59 +00:00
|
|
|
|
|
|
|
#endif /* _TR_ANNOUNCER_H_ */
|