1 | /****************************************************************************** |
---|
2 | * $Id: tr_torrent.h 2441 2007-07-20 03:24:04Z charles $ |
---|
3 | * |
---|
4 | * Copyright (c) 2006-2007 Transmission authors and contributors |
---|
5 | * |
---|
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
---|
7 | * copy of this software and associated documentation files (the "Software"), |
---|
8 | * to deal in the Software without restriction, including without limitation |
---|
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
10 | * and/or sell copies of the Software, and to permit persons to whom the |
---|
11 | * Software is furnished to do so, subject to the following conditions: |
---|
12 | * |
---|
13 | * The above copyright notice and this permission notice shall be included in |
---|
14 | * all copies or substantial portions of the Software. |
---|
15 | * |
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
---|
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
22 | * DEALINGS IN THE SOFTWARE. |
---|
23 | *****************************************************************************/ |
---|
24 | |
---|
25 | #ifndef TR_TORRENT_H |
---|
26 | #define TR_TORRENT_H |
---|
27 | |
---|
28 | #include <glib-object.h> |
---|
29 | #include <libtransmission/transmission.h> |
---|
30 | #include <libtransmission/bencode.h> |
---|
31 | #include "util.h" |
---|
32 | |
---|
33 | /* boxed type for tr_tracker_info_t */ |
---|
34 | #define TR_TRACKER_BOXED_TYPE (tr_tracker_boxed_get_type ()) |
---|
35 | GType |
---|
36 | tr_tracker_boxed_get_type( void ); |
---|
37 | |
---|
38 | #define TR_TORRENT_TYPE (tr_torrent_get_type ()) |
---|
39 | #define TR_TORRENT(obj) \ |
---|
40 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), TR_TORRENT_TYPE, TrTorrent)) |
---|
41 | #define TR_TORRENT_CLASS(klass) \ |
---|
42 | (G_TYPE_CHECK_CLASS_CAST ((klass), TR_TORRENT_TYPE, TrTorrentClass)) |
---|
43 | #define TR_IS_TORRENT(obj) \ |
---|
44 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TR_TORRENT_TYPE)) |
---|
45 | #define TR_IS_TORRENT_CLASS(klass) \ |
---|
46 | (G_TYPE_CHECK_CLASS_TYPE ((klass), TR_TORRENT_TYPE)) |
---|
47 | #define TR_TORRENT_GET_CLASS(obj) \ |
---|
48 | (G_TYPE_INSTANCE_GET_CLASS ((obj), TR_TORRENT_TYPE, TrTorrentClass)) |
---|
49 | |
---|
50 | typedef struct _TrTorrent TrTorrent; |
---|
51 | typedef struct _TrTorrentClass TrTorrentClass; |
---|
52 | |
---|
53 | /* treat the contents of this structure as private */ |
---|
54 | struct _TrTorrent { |
---|
55 | GObject parent; |
---|
56 | tr_torrent_t *handle; |
---|
57 | char *dir; |
---|
58 | char *delfile; |
---|
59 | tr_stat_t stat; |
---|
60 | time_t lastStatTime; |
---|
61 | |
---|
62 | /* FIXME: hm, are these heavyweight enough to deserve their own properties? */ |
---|
63 | gboolean severed; |
---|
64 | gboolean disposed; |
---|
65 | gboolean seeding_cap_enabled; |
---|
66 | gdouble seeding_cap; /* ratio to stop seeding at */ |
---|
67 | }; |
---|
68 | |
---|
69 | struct _TrTorrentClass { |
---|
70 | GObjectClass parent; |
---|
71 | }; |
---|
72 | |
---|
73 | GType |
---|
74 | tr_torrent_get_type(void); |
---|
75 | |
---|
76 | tr_torrent_t * |
---|
77 | tr_torrent_handle(TrTorrent *tor); |
---|
78 | |
---|
79 | const tr_stat_t * |
---|
80 | tr_torrent_stat(TrTorrent *tor); |
---|
81 | |
---|
82 | const tr_info_t * |
---|
83 | tr_torrent_info(TrTorrent *tor); |
---|
84 | |
---|
85 | void |
---|
86 | tr_torrent_start( TrTorrent * tor ); |
---|
87 | |
---|
88 | void |
---|
89 | tr_torrent_stop( TrTorrent * tor ); |
---|
90 | |
---|
91 | char* |
---|
92 | tr_torrent_status_str ( TrTorrent * tor ); |
---|
93 | |
---|
94 | void |
---|
95 | tr_torrent_check_seeding_cap ( TrTorrent* ); |
---|
96 | void |
---|
97 | tr_torrent_set_seeding_cap_ratio ( TrTorrent*, gdouble ratio ); |
---|
98 | void |
---|
99 | tr_torrent_set_seeding_cap_enabled ( TrTorrent*, gboolean ); |
---|
100 | |
---|
101 | TrTorrent * |
---|
102 | tr_torrent_new( tr_handle_t * handle, const char * path, const char * dir, |
---|
103 | enum tr_torrent_action act, gboolean paused, char ** err); |
---|
104 | |
---|
105 | TrTorrent * |
---|
106 | tr_torrent_new_with_data( tr_handle_t * handle, uint8_t * data, size_t size, |
---|
107 | const char * dir, gboolean paused, char ** err ); |
---|
108 | |
---|
109 | TrTorrent * |
---|
110 | tr_torrent_new_with_state( tr_handle_t * handle, benc_val_t * state, |
---|
111 | gboolean forcepaused, char ** err ); |
---|
112 | |
---|
113 | gboolean |
---|
114 | tr_torrent_get_state( TrTorrent * tor, benc_val_t * state ); |
---|
115 | |
---|
116 | void |
---|
117 | tr_torrent_state_saved(TrTorrent *tor); |
---|
118 | |
---|
119 | void |
---|
120 | tr_torrent_sever( TrTorrent * tor ); |
---|
121 | |
---|
122 | #endif |
---|