2 * This file Copyright (C) 2010-2014 Mnemosyne LLC
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
7 * $Id: announcer.h 14241 2014-01-21 03:10:30Z jordan $
10 #ifndef __TRANSMISSION__
11 #error only libtransmission should #include this header.
14 #ifndef _TR_ANNOUNCER_H_
15 #define _TR_ANNOUNCER_H_
17 #include "transmission.h"
20 struct tr_torrent_tiers
;
23 * *** Tracker Publish / Subscribe
30 TR_TRACKER_ERROR_CLEAR
,
37 /** @brief Notification object to tell listeners about announce or scrape occurences */
40 /* what type of event this is */
41 TrackerEventType messageType
;
43 /* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */
47 /* for TR_TRACKER_PEERS */
48 const struct tr_pex
* pex
;
51 /* [0...100] for probability a peer is a seed. calculated by the leecher/seeder ratio */
52 int8_t seedProbability
;
56 typedef void (*tr_tracker_callback
) (tr_torrent
* tor
,
57 const tr_tracker_event
* event
,
64 void tr_announcerInit (tr_session
*);
66 void tr_announcerClose (tr_session
*);
69 *** For torrent customers
72 struct tr_torrent_tiers
* tr_announcerAddTorrent (tr_torrent
* torrent
,
73 tr_tracker_callback cb
,
76 bool tr_announcerHasBacklog (const struct tr_announcer
*);
78 void tr_announcerResetTorrent (struct tr_announcer
*, tr_torrent
*);
80 void tr_announcerRemoveTorrent (struct tr_announcer
* ,
83 void tr_announcerChangeMyPort (tr_torrent
*);
85 bool tr_announcerCanManualAnnounce (const tr_torrent
*);
87 void tr_announcerManualAnnounce (tr_torrent
*);
89 void tr_announcerTorrentStarted (tr_torrent
*);
90 void tr_announcerTorrentStopped (tr_torrent
*);
91 void tr_announcerTorrentCompleted (tr_torrent
*);
93 enum { TR_ANN_UP
, TR_ANN_DOWN
, TR_ANN_CORRUPT
};
94 void tr_announcerAddBytes (tr_torrent
*, int up_down_or_corrupt
, uint32_t byteCount
);
96 time_t tr_announcerNextManualAnnounce (const tr_torrent
*);
98 tr_tracker_stat
* tr_announcerStats (const tr_torrent
* torrent
,
99 int * setmeTrackerCount
);
101 void tr_announcerStatsFree (tr_tracker_stat
* trackers
,
108 void tr_tracker_udp_upkeep (tr_session
* session
);
110 void tr_tracker_udp_close (tr_session
* session
);
112 bool tr_tracker_udp_is_idle (const tr_session
* session
);
116 #endif /* _TR_ANNOUNCER_H_ */