1 | /* |
---|
2 | * This file Copyright (C) 2010-2014 Mnemosyne LLC |
---|
3 | * |
---|
4 | * It may be used under the GNU GPL versions 2 or 3 |
---|
5 | * or any future license endorsed by Mnemosyne LLC. |
---|
6 | * |
---|
7 | * $Id: announcer.h 14241 2014-01-21 03:10:30Z jordan $ |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef __TRANSMISSION__ |
---|
11 | #error only libtransmission should #include this header. |
---|
12 | #endif |
---|
13 | |
---|
14 | #ifndef _TR_ANNOUNCER_H_ |
---|
15 | #define _TR_ANNOUNCER_H_ |
---|
16 | |
---|
17 | #include "transmission.h" |
---|
18 | |
---|
19 | struct tr_announcer; |
---|
20 | struct tr_torrent_tiers; |
---|
21 | |
---|
22 | /** |
---|
23 | * *** Tracker Publish / Subscribe |
---|
24 | * **/ |
---|
25 | |
---|
26 | typedef enum |
---|
27 | { |
---|
28 | TR_TRACKER_WARNING, |
---|
29 | TR_TRACKER_ERROR, |
---|
30 | TR_TRACKER_ERROR_CLEAR, |
---|
31 | TR_TRACKER_PEERS |
---|
32 | } |
---|
33 | TrackerEventType; |
---|
34 | |
---|
35 | struct tr_pex; |
---|
36 | |
---|
37 | /** @brief Notification object to tell listeners about announce or scrape occurences */ |
---|
38 | typedef struct |
---|
39 | { |
---|
40 | /* what type of event this is */ |
---|
41 | TrackerEventType messageType; |
---|
42 | |
---|
43 | /* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */ |
---|
44 | const char * text; |
---|
45 | const char * tracker; |
---|
46 | |
---|
47 | /* for TR_TRACKER_PEERS */ |
---|
48 | const struct tr_pex * pex; |
---|
49 | size_t pexCount; |
---|
50 | |
---|
51 | /* [0...100] for probability a peer is a seed. calculated by the leecher/seeder ratio */ |
---|
52 | int8_t seedProbability; |
---|
53 | } |
---|
54 | tr_tracker_event; |
---|
55 | |
---|
56 | typedef void (*tr_tracker_callback) (tr_torrent * tor, |
---|
57 | const tr_tracker_event * event, |
---|
58 | void * client_data); |
---|
59 | |
---|
60 | /** |
---|
61 | *** Session ctor/dtor |
---|
62 | **/ |
---|
63 | |
---|
64 | void tr_announcerInit (tr_session *); |
---|
65 | |
---|
66 | void tr_announcerClose (tr_session *); |
---|
67 | |
---|
68 | /** |
---|
69 | *** For torrent customers |
---|
70 | **/ |
---|
71 | |
---|
72 | struct tr_torrent_tiers * tr_announcerAddTorrent (tr_torrent * torrent, |
---|
73 | tr_tracker_callback cb, |
---|
74 | void * cbdata); |
---|
75 | |
---|
76 | bool tr_announcerHasBacklog (const struct tr_announcer *); |
---|
77 | |
---|
78 | void tr_announcerResetTorrent (struct tr_announcer*, tr_torrent*); |
---|
79 | |
---|
80 | void tr_announcerRemoveTorrent (struct tr_announcer * , |
---|
81 | tr_torrent *); |
---|
82 | |
---|
83 | void tr_announcerChangeMyPort (tr_torrent *); |
---|
84 | |
---|
85 | bool tr_announcerCanManualAnnounce (const tr_torrent *); |
---|
86 | |
---|
87 | void tr_announcerManualAnnounce (tr_torrent *); |
---|
88 | |
---|
89 | void tr_announcerTorrentStarted (tr_torrent *); |
---|
90 | void tr_announcerTorrentStopped (tr_torrent *); |
---|
91 | void tr_announcerTorrentCompleted (tr_torrent *); |
---|
92 | |
---|
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); |
---|
95 | |
---|
96 | time_t tr_announcerNextManualAnnounce (const tr_torrent *); |
---|
97 | |
---|
98 | tr_tracker_stat * tr_announcerStats (const tr_torrent * torrent, |
---|
99 | int * setmeTrackerCount); |
---|
100 | |
---|
101 | void tr_announcerStatsFree (tr_tracker_stat * trackers, |
---|
102 | int trackerCount); |
---|
103 | |
---|
104 | /*** |
---|
105 | **** |
---|
106 | ***/ |
---|
107 | |
---|
108 | void tr_tracker_udp_upkeep (tr_session * session); |
---|
109 | |
---|
110 | void tr_tracker_udp_close (tr_session * session); |
---|
111 | |
---|
112 | bool tr_tracker_udp_is_idle (const tr_session * session); |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | #endif /* _TR_ANNOUNCER_H_ */ |
---|