source: trunk/gtk/tr-core.h @ 10717

Last change on this file since 10717 was 10717, checked in by charles, 12 years ago

(trunk) add "filename" arg to the dbus message when passing a .torrent from one instance of Transmission to another

  • Property svn:keywords set to Date Rev Author Id
File size: 6.9 KB
Line 
1/******************************************************************************
2 * $Id: tr-core.h 10717 2010-06-03 19:53:01Z charles $
3 *
4 * Copyright (c) 2007-2008 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_CORE_H
26#define TR_CORE_H
27
28#include <glib-object.h>
29#include <gtk/gtk.h>
30
31#include <libtransmission/transmission.h>
32#include "conf.h" /* pref_flag_t */
33#include "tr-torrent.h"
34
35#define TR_CORE_TYPE ( tr_core_get_type( ) )
36#define TR_CORE( o ) G_TYPE_CHECK_INSTANCE_CAST( ( o ), TR_CORE_TYPE,\
37                                                TrCore )
38#define TR_IS_CORE( o ) G_TYPE_CHECK_INSTANCE_TYPE( ( o ), TR_CORE_TYPE )
39#define TR_CORE_CLASS( k ) G_TYPE_CHECK_CLASS_CAST( ( k ), TR_CORE_TYPE,\
40                                                   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 ),\
43                                                         TR_CORE_TYPE, \
44                                                         TrCoreClass )
45
46typedef struct TrCore
47{
48    GObject    parent;
49    struct TrCorePrivate  * priv;
50}
51TrCore;
52
53typedef struct TrCoreClass
54{
55    GObjectClass    parent;
56
57    /* "blocklist-updated" signal with a callback type of
58        void (*callback )( TrCore*, int ruleCount, gpointer userData ). */
59    int blocklistSignal;
60
61    /* "port-tested" signal with a callback type of
62       void( *callback )( TrCore*, gboolean isOpen, gpointer userData ). */
63    int portSignal;
64
65    /* "error" signal with a callback type of
66       void( *callback )( TrCore*, enum tr_core_err, const char * humanReadable, gpointer userData ). */
67    int errsig;
68
69    /* "add-torrent-prompt" signal with a callback type of
70       void ( *callback)( TrCore *, gpointer ctor, gpointer userData )
71       The handler assumes ownership of ctor and must free when done */
72    int promptsig;
73
74    /* "quit" signal:
75       void handler( TrCore *, gpointer ) */
76    int quitsig;
77
78    /* "prefs-changed" signal:
79       void handler( TrCore *, int, gpointer ) */
80    int prefsig;
81}
82TrCoreClass;
83
84enum tr_core_err
85{
86    TR_CORE_ERR_ADD_TORRENT_ERR  = TR_PARSE_ERR,
87    TR_CORE_ERR_ADD_TORRENT_DUP  = TR_PARSE_DUPLICATE,
88    TR_CORE_ERR_NO_MORE_TORRENTS = 1000 /* finished adding a batch */
89};
90
91GType          tr_core_get_type( void );
92
93TrCore *       tr_core_new( tr_session * );
94
95void           tr_core_close( TrCore* );
96
97/* Return the model used without incrementing the reference count */
98GtkTreeModel * tr_core_model( TrCore * self );
99
100tr_session *   tr_core_session( TrCore * self );
101
102int            tr_core_get_active_torrent_count( TrCore * self );
103
104int            tr_core_get_torrent_count( TrCore * self );
105
106/******
107*******
108******/
109
110/**
111 * Load saved state and return number of torrents added.
112 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
113 */
114int      tr_core_load( TrCore * self,
115                       gboolean forcepaused );
116
117/**
118 * Add a list of torrents.
119 * This function assumes ownership of torrentFiles
120 *
121 * May pop up dialogs for each torrent if that preference is enabled.
122 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
123 */
124void     tr_core_add_list( TrCore *    self,
125                           GSList *    torrentFiles,
126                           pref_flag_t start,
127                           pref_flag_t prompt,
128                           gboolean    doNotify );
129
130#define tr_core_add_list_defaults( c, l, doNotify ) \
131    tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT, doNotify )
132
133
134/** @brief Add a torrent. */
135gboolean tr_core_add_metainfo( TrCore      * core,
136                               const char  * payload,
137                               const char  * optional_filename,
138                               gboolean    * setme_success,
139                               GError     ** err );
140
141/** @brief Add a torrent from a URL */
142void tr_core_add_from_url( TrCore * core, const char * url );
143
144/** @brief Add a torrent.
145    @param ctor this function assumes ownership of the ctor */
146void tr_core_add_ctor( TrCore  * core,
147                       tr_ctor * ctor );
148
149
150/** Add a torrent. */
151void tr_core_add_torrent( TrCore*, TrTorrent*, gboolean doNotify );
152
153/** Present the main window */
154gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err );
155
156
157/**
158 * Notifies listeners that torrents have been added.
159 * This should be called after one or more tr_core_add*() calls.
160 */
161void     tr_core_torrents_added( TrCore * self );
162
163/******
164*******
165******/
166
167/* remove a torrent */
168void  tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, gboolean deleteFiles );
169void  tr_core_remove_torrent_from_id( TrCore * self, int id, gboolean deleteFiles );
170
171/* update the model with current torrent status */
172void  tr_core_update( TrCore * self );
173
174/* emit the "quit" signal */
175void  tr_core_quit( TrCore * self );
176
177/**
178***  Set a preference value, save the prefs file, and emit the "prefs-changed" signal
179**/
180
181void tr_core_set_pref     ( TrCore * self, const char * key, const char * val );
182void tr_core_set_pref_bool( TrCore * self, const char * key, gboolean val );
183void tr_core_set_pref_int ( TrCore * self, const char * key, int val );
184void tr_core_set_pref_double( TrCore * self, const char * key, double val );
185
186/**
187***
188**/
189
190void tr_core_torrent_changed( TrCore * core, int id );
191
192void tr_core_port_test( TrCore * core );
193
194void tr_core_blocklist_update( TrCore * core );
195
196void tr_core_exec( TrCore * core, const tr_benc * benc );
197
198void tr_core_exec_json( TrCore * core, const char * json );
199
200
201/**
202***
203**/
204
205/* column names for the model used to store torrent information */
206/* keep this in sync with the type array in tr_core_init() in tr_core.c */
207enum
208{
209    MC_NAME,
210    MC_NAME_COLLATED,
211    MC_TORRENT,
212    MC_TORRENT_RAW,
213    MC_SPEED_UP,
214    MC_SPEED_DOWN,
215    MC_ACTIVITY,
216    MC_ROW_COUNT
217};
218
219#endif
Note: See TracBrowser for help on using the repository browser.