1 | /* |
---|
2 | * This file Copyright (C) 2007-2008 Charles Kerr <charles@transmissionbt.com> |
---|
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: tracker.h 7404 2008-12-16 00:20:44Z charles $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef __TRANSMISSION__ |
---|
14 | #error only libtransmission should #include this header. |
---|
15 | #endif |
---|
16 | |
---|
17 | #ifndef _TR_TRACKER_H_ |
---|
18 | #define _TR_TRACKER_H_ |
---|
19 | |
---|
20 | #include <inttypes.h> /* for uint8_t */ |
---|
21 | #include "transmission.h" |
---|
22 | #include "publish.h" |
---|
23 | |
---|
24 | /** |
---|
25 | *** Locating a tracker |
---|
26 | **/ |
---|
27 | |
---|
28 | typedef struct tr_tracker tr_tracker; |
---|
29 | |
---|
30 | tr_tracker * tr_trackerNew( const tr_torrent * ); |
---|
31 | |
---|
32 | void tr_trackerFree( tr_tracker * ); |
---|
33 | |
---|
34 | void tr_trackerSessionClose( tr_session * ); |
---|
35 | |
---|
36 | /** |
---|
37 | *** Tracker Publish / Subscribe |
---|
38 | **/ |
---|
39 | |
---|
40 | typedef enum |
---|
41 | { |
---|
42 | TR_TRACKER_WARNING, |
---|
43 | TR_TRACKER_ERROR, |
---|
44 | TR_TRACKER_ERROR_CLEAR, |
---|
45 | TR_TRACKER_PEERS |
---|
46 | } |
---|
47 | TrackerEventType; |
---|
48 | |
---|
49 | typedef struct |
---|
50 | { |
---|
51 | /* what type of event this is */ |
---|
52 | TrackerEventType messageType; |
---|
53 | |
---|
54 | /* the torrent's 20-character sha1 hash */ |
---|
55 | const uint8_t * hash; |
---|
56 | |
---|
57 | /* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */ |
---|
58 | const char * text; |
---|
59 | |
---|
60 | /* for TR_TRACKER_PEERS */ |
---|
61 | const uint8_t * compact; |
---|
62 | int compactLen; |
---|
63 | int allAreSeeds; |
---|
64 | } |
---|
65 | tr_tracker_event; |
---|
66 | |
---|
67 | tr_publisher_tag tr_trackerSubscribe( struct tr_tracker * tag, |
---|
68 | tr_delivery_func func, |
---|
69 | void * user ); |
---|
70 | |
---|
71 | void tr_trackerUnsubscribe( struct tr_tracker * tracker, |
---|
72 | tr_publisher_tag tag ); |
---|
73 | |
---|
74 | /*** |
---|
75 | **** |
---|
76 | ***/ |
---|
77 | |
---|
78 | void tr_trackerStat( const tr_tracker * tracker, |
---|
79 | struct tr_stat * setme ); |
---|
80 | |
---|
81 | void tr_trackerStart( struct tr_tracker * ); |
---|
82 | |
---|
83 | void tr_trackerCompleted( struct tr_tracker * ); |
---|
84 | |
---|
85 | void tr_trackerStop( struct tr_tracker * ); |
---|
86 | |
---|
87 | void tr_trackerReannounce( struct tr_tracker * ); |
---|
88 | |
---|
89 | void tr_trackerChangeMyPort( struct tr_tracker * ); |
---|
90 | |
---|
91 | const tr_tracker_info * tr_trackerGetAddress( struct tr_tracker * ); |
---|
92 | |
---|
93 | int tr_trackerCanManualAnnounce( const struct tr_tracker * ); |
---|
94 | |
---|
95 | time_t tr_trackerGetManualAnnounceTime( const struct tr_tracker * ); |
---|
96 | |
---|
97 | void tr_trackerGetCounts( const struct tr_tracker *, |
---|
98 | int * setme_completedCount, |
---|
99 | int * setme_leecherCount, |
---|
100 | int * setme_seederCount, |
---|
101 | int * setme_downloaderCount ); |
---|
102 | |
---|
103 | #endif |
---|