1 | /* |
---|
2 | * This file Copyright (C) 2009-2010 Mnemosyne LLC |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2(b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id:$ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef __TRANSMISSION__ |
---|
14 | #error only libtransmission should #include this header. |
---|
15 | #endif |
---|
16 | |
---|
17 | #ifndef _TR_ANNOUNCER_H_ |
---|
18 | #define _TR_ANNOUNCER_H_ |
---|
19 | |
---|
20 | #include "transmission.h" |
---|
21 | #include "publish.h" |
---|
22 | |
---|
23 | struct tr_announcer; |
---|
24 | struct tr_torrent_tiers; |
---|
25 | |
---|
26 | /** |
---|
27 | * *** Tracker Publish / Subscribe |
---|
28 | * **/ |
---|
29 | |
---|
30 | typedef enum |
---|
31 | { |
---|
32 | TR_TRACKER_WARNING, |
---|
33 | TR_TRACKER_ERROR, |
---|
34 | TR_TRACKER_ERROR_CLEAR, |
---|
35 | TR_TRACKER_PEERS |
---|
36 | } |
---|
37 | TrackerEventType; |
---|
38 | |
---|
39 | /** @brief Notification object to tell listeners about announce or scrape occurences */ |
---|
40 | typedef struct |
---|
41 | { |
---|
42 | /* what type of event this is */ |
---|
43 | TrackerEventType messageType; |
---|
44 | |
---|
45 | /* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */ |
---|
46 | const char * text; |
---|
47 | const char * tracker; |
---|
48 | |
---|
49 | /* for TR_TRACKER_PEERS */ |
---|
50 | const uint8_t * compact; |
---|
51 | int compactLen; |
---|
52 | |
---|
53 | /* [0...100] for probability a peer is a seed. calculated by the leecher/seeder ratio */ |
---|
54 | int8_t seedProbability; |
---|
55 | } |
---|
56 | tr_tracker_event; |
---|
57 | |
---|
58 | /** |
---|
59 | *** Session ctor/dtor |
---|
60 | **/ |
---|
61 | |
---|
62 | void tr_announcerInit( tr_session * ); |
---|
63 | |
---|
64 | void tr_announcerClose( tr_session * ); |
---|
65 | |
---|
66 | /** |
---|
67 | *** For torrent customers |
---|
68 | **/ |
---|
69 | |
---|
70 | struct tr_torrent_tiers * tr_announcerAddTorrent( struct tr_announcer *, |
---|
71 | tr_torrent * ); |
---|
72 | |
---|
73 | tr_bool tr_announcerHasBacklog( const struct tr_announcer * ); |
---|
74 | |
---|
75 | void tr_announcerResetTorrent( struct tr_announcer*, tr_torrent* ); |
---|
76 | |
---|
77 | tr_publisher_tag tr_announcerSubscribe( struct tr_torrent_tiers * tiers, |
---|
78 | tr_delivery_func func, |
---|
79 | void * userData ); |
---|
80 | |
---|
81 | void tr_announcerUnsubscribe( struct tr_torrent_tiers * tiers, |
---|
82 | tr_publisher_tag tag ); |
---|
83 | |
---|
84 | void tr_announcerRemoveTorrent( struct tr_announcer * , |
---|
85 | tr_torrent * ); |
---|
86 | |
---|
87 | void tr_announcerChangeMyPort( tr_torrent * ); |
---|
88 | |
---|
89 | tr_bool tr_announcerCanManualAnnounce( const tr_torrent * ); |
---|
90 | |
---|
91 | void tr_announcerManualAnnounce( tr_torrent * ); |
---|
92 | |
---|
93 | void tr_announcerTorrentStarted( tr_torrent * ); |
---|
94 | void tr_announcerTorrentStopped( tr_torrent * ); |
---|
95 | void tr_announcerTorrentCompleted( tr_torrent * ); |
---|
96 | |
---|
97 | enum { TR_ANN_UP, TR_ANN_DOWN, TR_ANN_CORRUPT }; |
---|
98 | void tr_announcerAddBytes( tr_torrent *, int up_down_or_corrupt, uint32_t byteCount ); |
---|
99 | |
---|
100 | time_t tr_announcerNextManualAnnounce( const tr_torrent * ); |
---|
101 | |
---|
102 | tr_tracker_stat * tr_announcerStats( const tr_torrent * torrent, |
---|
103 | int * setmeTrackerCount ); |
---|
104 | |
---|
105 | void tr_announcerStatsFree( tr_tracker_stat * trackers, |
---|
106 | int trackerCount ); |
---|
107 | |
---|
108 | |
---|
109 | #endif /* _TR_ANNOUNCER_H_ */ |
---|