34
34
#include "conf.h" /* pref_flag_t */
35
35
#include "tr-torrent.h"
37
#define TR_CORE_TYPE (tr_core_get_type())
38
#define TR_CORE(o) G_TYPE_CHECK_INSTANCE_CAST((o),TR_CORE_TYPE,TrCore)
39
#define TR_IS_CORE(o) G_TYPE_CHECK_INSTANCE_TYPE((o),TR_CORE_TYPE)
40
#define TR_CORE_CLASS(k) G_TYPE_CHECK_CLASS_CAST((k),TR_CORE_TYPE,TrCoreClass)
41
#define TR_IS_CORE_CLASS(k) G_TYPE_CHECK_CLASS_TYPE((k),TR_CORE_TYPE)
42
#define TR_CORE_GET_CLASS(o) G_TYPE_INSTANCE_GET_CLASS((o),TR_CORE_TYPE,TrCoreClass)
37
#define TR_CORE_TYPE ( tr_core_get_type( ) )
38
#define TR_CORE( o ) G_TYPE_CHECK_INSTANCE_CAST( ( o ), TR_CORE_TYPE,\
40
#define TR_IS_CORE( o ) G_TYPE_CHECK_INSTANCE_TYPE( ( o ), TR_CORE_TYPE )
41
#define TR_CORE_CLASS( k ) G_TYPE_CHECK_CLASS_CAST( ( k ), TR_CORE_TYPE,\
43
#define TR_IS_CORE_CLASS( k ) G_TYPE_CHECK_CLASS_TYPE( ( k ), TR_CORE_TYPE )
44
#define TR_CORE_GET_CLASS( o ) G_TYPE_INSTANCE_GET_CLASS( ( o ),\
48
float clientDownloadSpeed;
49
float clientUploadSpeed;
52
float clientDownloadSpeed;
53
float clientUploadSpeed;
52
56
typedef struct TrCore
55
59
struct TrCorePrivate * priv;
59
63
typedef struct TrCoreClass
64
void handler( TrCore *, enum tr_core_err, const char *, gpointer ) */
67
/* "blocklist-updated" signal with a callback type of
68
void (*callback )( TrCore*, int ruleCount, gpointer userData ). */
71
/* "port-tested" signal with a callback type of
72
void( *callback )( TrCore*, gboolean isOpen, gpointer userData ). */
75
/* "error" signal with a callback type of
76
void( *callback )( TrCore*, enum tr_core_err, const char * humanReadable, gpointer userData ). */
67
/* "add-torrent-prompt" signal:
68
void handler( TrCore *, gpointer ctor, gpointer userData )
79
/* "add-torrent-prompt" signal with a callback type of
80
void ( *callback)( TrCore *, gpointer ctor, gpointer userData )
69
81
The handler assumes ownership of ctor and must free when done */
84
TR_CORE_ERR_ADD_TORRENT, /* adding a torrent failed */
85
/* no more torrents to be added, used for grouping torrent add errors */
86
TR_CORE_ERR_NO_MORE_TORRENTS,
87
TR_CORE_ERR_SAVE_STATE /* error saving state */
96
TR_CORE_ERR_ADD_TORRENT_ERR = TR_EINVALID,
97
TR_CORE_ERR_ADD_TORRENT_DUP = TR_EDUPLICATE,
98
TR_CORE_ERR_NO_MORE_TORRENTS, /* finished adding a batch */
99
TR_CORE_ERR_SAVE_STATE /* error saving state */
90
GType tr_core_get_type( void );
92
TrCore * tr_core_new( tr_handle * );
94
void tr_core_close( TrCore* );
102
GType tr_core_get_type( void );
104
TrCore * tr_core_new( tr_session * );
106
void tr_core_close( TrCore* );
96
108
/* Return the model used without incrementing the reference count */
97
109
GtkTreeModel * tr_core_model( TrCore * self );
99
tr_handle * tr_core_handle( TrCore * self );
111
tr_session * tr_core_session( TrCore * self );
101
void tr_core_get_stats( const TrCore * core,
102
struct core_stats * setme );
113
void tr_core_get_stats( const TrCore * core,
114
struct core_stats * setme );
126
131
* May pop up dialogs for each torrent if that preference is enabled.
127
132
* May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
129
void tr_core_add_list( TrCore * self,
130
GSList * torrentFiles,
132
pref_flag_t prompt );
134
#define tr_core_add_list_defaults(c,l) \
135
tr_core_add_list(c,l,PREF_FLAG_DEFAULT,PREF_FLAG_DEFAULT)
134
void tr_core_add_list( TrCore * self,
135
GSList * torrentFiles,
137
pref_flag_t prompt );
139
#define tr_core_add_list_defaults( c, l ) \
140
tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT )
143
/** Add a torrent. */
144
gboolean tr_core_add_file( TrCore*, const char * filename, gboolean * setme_success, GError ** err );
145
/** Add a torrent. */
140
146
void tr_core_add_torrent( TrCore*, TrTorrent* );
148
/** Present the main window */
149
gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err );
143
153
* Notifies listeners that torrents have been added.
144
154
* This should be called after one or more tr_core_add*() calls.
146
void tr_core_torrents_added( TrCore * self );
156
void tr_core_torrents_added( TrCore * self );
152
void tr_core_delete_torrent( TrCore * self, GtkTreeIter * iter );
162
/* we've gotten notice from RPC that a torrent has been destroyed;
163
update our gui accordingly */
164
void tr_core_torrent_destroyed( TrCore * self, int torrentId );
154
void tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, int deleteFiles );
166
/* remove a torrent */
167
void tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, int deleteFiles );
156
169
/* update the model with current torrent status */
157
void tr_core_update( TrCore * self );
170
void tr_core_update( TrCore * self );
159
172
/* emit the "quit" signal */
160
void tr_core_quit( TrCore * self );
162
/* Set a preference value, save the prefs file, and emit the
163
"prefs-changed" signal */
164
void tr_core_set_pref( TrCore * self, const char * key, const char * val );
166
/* Set a boolean preference value, save the prefs file, and emit the
167
"prefs-changed" signal */
173
void tr_core_quit( TrCore * self );
176
*** Set a preference value, save the prefs file, and emit the "prefs-changed" signal
179
void tr_core_set_pref ( TrCore * self, const char * key, const char * val );
168
180
void tr_core_set_pref_bool( TrCore * self, const char * key, gboolean val );
170
/* Set an integer preference value, save the prefs file, and emit the
171
"prefs-changed" signal */
172
void tr_core_set_pref_int( TrCore * self, const char * key, int val );
181
void tr_core_set_pref_int ( TrCore * self, const char * key, int val );
182
void tr_core_set_pref_double( TrCore * self, const char * key, double val );
188
void tr_core_port_test( TrCore * core );
190
void tr_core_blocklist_update( TrCore * core );
192
void tr_core_exec( TrCore * core, const tr_benc * benc );
194
void tr_core_exec_json( TrCore * core, const char * json );