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

Last change on this file since 12638 was 12638, checked in by jordan, 10 years ago

(trunk gtk) bump the glib2 requirement from 2.8 to 2.26 s.t. transmission-gtk can use glib's GDBus module and drop the glib-dbus library dependency

  • Property svn:keywords set to Date Rev Author Id
File size: 6.6 KB
Line 
1/******************************************************************************
2 * $Id: tr-core.h 12638 2011-08-07 16:42:38Z jordan $
3 *
4 * Copyright (c) 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 GTR_CORE_H
26#define GTR_CORE_H
27
28#include <glib-object.h>
29#include <gtk/gtk.h>
30
31#include <libtransmission/transmission.h>
32#include <libtransmission/bencode.h>
33
34#define TR_CORE_TYPE ( gtr_core_get_type() )
35#define TR_CORE(o) G_TYPE_CHECK_INSTANCE_CAST((o), TR_CORE_TYPE, TrCore)
36#define TR_IS_CORE(o) G_TYPE_CHECK_INSTANCE_TYPE((o), TR_CORE_TYPE )
37#define TR_CORE_CLASS(k) G_TYPE_CHECK_CLASS_CAST((k), TR_CORE_TYPE, TrCoreClass)
38#define TR_IS_CORE_CLASS(k) G_TYPE_CHECK_CLASS_TYPE((k), TR_CORE_TYPE )
39#define TR_CORE_GET_CLASS(o) G_TYPE_INSTANCE_GET_CLASS((o), TR_CORE_TYPE, TrCoreClass)
40
41typedef struct _TrCore
42{
43    GObject parent;
44
45    struct TrCorePrivate  * priv;
46}
47TrCore;
48
49enum tr_core_err
50{
51    TR_CORE_ERR_ADD_TORRENT_ERR  = TR_PARSE_ERR,
52    TR_CORE_ERR_ADD_TORRENT_DUP  = TR_PARSE_DUPLICATE,
53    TR_CORE_ERR_NO_MORE_TORRENTS = 1000 /* finished adding a batch */
54};
55
56typedef struct _TrCoreClass
57{
58    GObjectClass parent_class;
59
60    void (* add_error)         (TrCore*, enum tr_core_err, const char * name);
61    void (* add_prompt)        (TrCore*, gpointer ctor);
62    void (* blocklist_updated) (TrCore*, int ruleCount );
63    void (* busy)              (TrCore*, gboolean is_busy);
64    void (* prefs_changed)     (TrCore*, const char* key);
65    void (* port_tested)       (TrCore*, gboolean is_open);
66    void (* quit)              (TrCore*);
67}
68TrCoreClass;
69
70GType          gtr_core_get_type( void );
71
72TrCore *       gtr_core_new( tr_session * );
73
74void           gtr_core_close( TrCore* );
75
76/* Return the model used without incrementing the reference count */
77GtkTreeModel * gtr_core_model( TrCore * self );
78
79void           gtr_core_clear( TrCore * self );
80
81tr_session *   gtr_core_session( TrCore * self );
82
83size_t         gtr_core_get_active_torrent_count( TrCore * self );
84
85size_t         gtr_core_get_torrent_count( TrCore * self );
86
87tr_torrent *   gtr_core_find_torrent( TrCore * core, int id );
88
89void           gtr_core_pref_changed( TrCore * core, const char * key );
90
91
92/******
93*******
94******/
95
96/**
97 * Load saved state and return number of torrents added.
98 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
99 */
100void gtr_core_load( TrCore * self, gboolean forcepaused );
101
102/**
103 * Add a list of torrents.
104 * This function assumes ownership of torrentFiles
105 *
106 * May pop up dialogs for each torrent if that preference is enabled.
107 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
108 */
109void gtr_core_add_list( TrCore *    self,
110                        GSList *    torrentFiles,
111                        gboolean    do_start,
112                        gboolean    do_prompt,
113                        gboolean    do_notify );
114
115void gtr_core_add_list_defaults( TrCore    * core,
116                                 GSList    * torrentFiles,
117                                 gboolean    do_notify );
118
119
120/** @brief Add a torrent from a URL */
121void gtr_core_add_from_url( TrCore * core, const char * url );
122
123/** @brief Add a torrent.
124    @param ctor this function assumes ownership of the ctor */
125void gtr_core_add_ctor( TrCore * core, tr_ctor * ctor );
126
127/** Add a torrent. */
128void gtr_core_add_torrent( TrCore*, tr_torrent*, gboolean do_notify );
129
130/**
131 * Notifies listeners that torrents have been added.
132 * This should be called after one or more tr_core_add*() calls.
133 */
134void gtr_core_torrents_added( TrCore * self );
135
136/******
137*******
138******/
139
140/* remove a torrent */
141void gtr_core_remove_torrent( TrCore * self, int id, gboolean delete_files );
142
143/* update the model with current torrent status */
144void gtr_core_update( TrCore * self );
145
146/**
147***  Set a preference value, save the prefs file, and emit the "prefs-changed" signal
148**/
149
150void gtr_core_set_pref       ( TrCore * self, const char * key, const char * val );
151void gtr_core_set_pref_bool  ( TrCore * self, const char * key, gboolean val );
152void gtr_core_set_pref_int   ( TrCore * self, const char * key, int val );
153void gtr_core_set_pref_double( TrCore * self, const char * key, double val );
154
155/**
156***
157**/
158
159void gtr_core_port_test( TrCore * core );
160
161void gtr_core_blocklist_update( TrCore * core );
162
163void gtr_core_exec( TrCore * core, const tr_benc * benc );
164
165void gtr_core_exec_json( TrCore * core, const char * json );
166
167void gtr_core_open_folder( TrCore * core, int torrent_id );
168
169
170/**
171***
172**/
173
174/* column names for the model used to store torrent information */
175/* keep this in sync with the type array in tr_core_init() in tr_core.c */
176enum
177{
178    MC_NAME_COLLATED,
179    MC_TORRENT,
180    MC_TORRENT_ID,
181    MC_SPEED_UP,
182    MC_SPEED_DOWN,
183    MC_RECHECK_PROGRESS,
184    MC_ACTIVE,
185    MC_ACTIVITY,
186    MC_FINISHED,
187    MC_PRIORITY,
188    MC_QUEUE_POSITION,
189    MC_TRACKERS,
190
191    /* tr_stat.error
192     * Tracked because ACTIVITY_FILTER_ERROR needs the row-changed events */
193    MC_ERROR,
194
195    /* tr_stat.{ peersSendingToUs + peersGettingFromUs + webseedsSendingToUs }
196     * Tracked because ACTIVITY_FILTER_ACTIVE needs the row-changed events */
197    MC_ACTIVE_PEER_COUNT,
198
199    MC_ROW_COUNT
200};
201
202
203#define TR_DBUS_SESSION_SERVICE_NAME  "com.transmissionbt.transmission.Session"
204#define TR_DBUS_SESSION_INTERFACE     "com.transmissionbt.transmission.Session"
205#define TR_DBUS_SESSION_OBJECT_PATH   "/com/transmissionbt/transmission/Session"
206
207#define TR_DBUS_DISPLAY_SERVICE_NAME  "com.transmissionbt.transmission.Display"
208#define TR_DBUS_DISPLAY_INTERFACE     "com.transmissionbt.transmission.Display"
209#define TR_DBUS_DISPLAY_OBJECT_PATH   "/com/transmissionbt/transmission/Display"
210
211
212#endif /* GTR_CORE_H */
Note: See TracBrowser for help on using the repository browser.