source: branches/2.1x/gtk/tr-core.h @ 12089

Last change on this file since 12089 was 12089, checked in by jordan, 11 years ago

(2.1x gtk) #4080 "Toggling speed limit mode from the web interface doesn't affect GUI" -- fixed.

  • Property svn:keywords set to Date Rev Author Id
File size: 6.5 KB
Line 
1/******************************************************************************
2 * $Id: tr-core.h 12089 2011-03-04 06:08:40Z jordan $
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
50    struct TrCorePrivate  * priv;
51}
52TrCore;
53
54enum tr_core_err
55{
56    TR_CORE_ERR_ADD_TORRENT_ERR  = TR_PARSE_ERR,
57    TR_CORE_ERR_ADD_TORRENT_DUP  = TR_PARSE_DUPLICATE,
58    TR_CORE_ERR_NO_MORE_TORRENTS = 1000 /* finished adding a batch */
59};
60
61typedef struct _TrCoreClass
62{
63    GObjectClass parent_class;
64
65    void (* add_error)         (TrCore*, enum tr_core_err, const char * name);
66    void (* add_prompt)        (TrCore*, gpointer ctor);
67    void (* blocklist_updated) (TrCore*, int ruleCount );
68    void (* busy)              (TrCore*, gboolean isBusy);
69    void (* prefs_changed)     (TrCore*, const char* key);
70    void (* port_tested)       (TrCore*, gboolean isOpen);
71    void (* quit)              (TrCore*);
72}
73TrCoreClass;
74
75GType          tr_core_get_type( void );
76
77TrCore *       tr_core_new( tr_session * );
78
79void           tr_core_close( TrCore* );
80
81/* Return the model used without incrementing the reference count */
82GtkTreeModel * tr_core_model( TrCore * self );
83
84tr_session *   tr_core_session( TrCore * self );
85
86size_t         tr_core_get_active_torrent_count( TrCore * self );
87
88size_t         tr_core_get_torrent_count( TrCore * self );
89
90void           tr_core_pref_changed( TrCore * core, const char * key );
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 */
100int      tr_core_load( TrCore * self,
101                       gboolean forcepaused );
102
103/**
104 * Add a list of torrents.
105 * This function assumes ownership of torrentFiles
106 *
107 * May pop up dialogs for each torrent if that preference is enabled.
108 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
109 */
110void     tr_core_add_list( TrCore *    self,
111                           GSList *    torrentFiles,
112                           pref_flag_t start,
113                           pref_flag_t prompt,
114                           gboolean    doNotify );
115
116#define tr_core_add_list_defaults( c, l, doNotify ) \
117    tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT, doNotify )
118
119
120/** @brief Add a torrent. */
121gboolean tr_core_add_metainfo( TrCore      * core,
122                               const char  * base64_metainfo,
123                               gboolean    * setme_success,
124                               GError     ** err );
125
126/** @brief Add a torrent from a URL */
127void tr_core_add_from_url( TrCore * core, const char * url );
128
129/** @brief Add a torrent.
130    @param ctor this function assumes ownership of the ctor */
131void tr_core_add_ctor( TrCore  * core,
132                       tr_ctor * ctor );
133
134
135/** Add a torrent. */
136void tr_core_add_torrent( TrCore*, TrTorrent*, gboolean doNotify );
137
138/** Present the main window */
139gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err );
140
141
142/**
143 * Notifies listeners that torrents have been added.
144 * This should be called after one or more tr_core_add*() calls.
145 */
146void     tr_core_torrents_added( TrCore * self );
147
148/******
149*******
150******/
151
152/* remove a torrent */
153void  tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, gboolean deleteFiles );
154void  tr_core_remove_torrent_from_id( TrCore * self, int id, gboolean deleteFiles );
155
156/* update the model with current torrent status */
157void  tr_core_update( TrCore * self );
158
159/* emit the "quit" signal */
160void  tr_core_quit( TrCore * self );
161
162/**
163***  Set a preference value, save the prefs file, and emit the "prefs-changed" signal
164**/
165
166void tr_core_set_pref     ( TrCore * self, const char * key, const char * val );
167void tr_core_set_pref_bool( TrCore * self, const char * key, gboolean val );
168void tr_core_set_pref_int ( TrCore * self, const char * key, int val );
169void tr_core_set_pref_double( TrCore * self, const char * key, double val );
170
171/**
172***
173**/
174
175void tr_core_torrent_changed( TrCore * core, int id );
176
177void tr_core_port_test( TrCore * core );
178
179void tr_core_blocklist_update( TrCore * core );
180
181void tr_core_exec( TrCore * core, const tr_benc * benc );
182
183void tr_core_exec_json( TrCore * core, const char * json );
184
185
186/**
187***
188**/
189
190/* column names for the model used to store torrent information */
191/* keep this in sync with the type array in tr_core_init() in tr_core.c */
192enum
193{
194    MC_NAME,
195    MC_NAME_COLLATED,
196    MC_TORRENT,
197    MC_TORRENT_RAW,
198    MC_SPEED_UP,
199    MC_SPEED_DOWN,
200    MC_ACTIVE,
201    MC_ACTIVITY,
202    MC_FINISHED,
203    MC_PRIORITY,
204    MC_TRACKERS,
205    MC_ROW_COUNT
206};
207
208#endif
Note: See TracBrowser for help on using the repository browser.