Revert "transmission: update from 2.13 to 2.22"
[tomato.git] / release / src / router / transmission / gtk / tr-core.h
blob55032bd78d941af0065630e413d15e3e2d0f449e
1 /******************************************************************************
2 * $Id: tr-core.h 11114 2010-08-04 17:35:48Z Longinus00 $
4 * Copyright (c) 2007-2008 Transmission authors and contributors
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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 *****************************************************************************/
25 #ifndef TR_CORE_H
26 #define TR_CORE_H
28 #include <glib-object.h>
29 #include <gtk/gtk.h>
31 #include <libtransmission/transmission.h>
32 #include "conf.h" /* pref_flag_t */
33 #include "tr-torrent.h"
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 )
46 typedef struct _TrCore
48 GObject parent;
50 struct TrCorePrivate * priv;
52 TrCore;
54 enum tr_core_err
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 */
61 typedef struct _TrCoreClass
63 GObjectClass parent_class;
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*);
73 TrCoreClass;
75 GType tr_core_get_type( void );
77 TrCore * tr_core_new( tr_session * );
79 void tr_core_close( TrCore* );
81 /* Return the model used without incrementing the reference count */
82 GtkTreeModel * tr_core_model( TrCore * self );
84 tr_session * tr_core_session( TrCore * self );
86 int tr_core_get_active_torrent_count( TrCore * self );
88 int tr_core_get_torrent_count( TrCore * self );
90 /******
91 *******
92 ******/
94 /**
95 * Load saved state and return number of torrents added.
96 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
98 int tr_core_load( TrCore * self,
99 gboolean forcepaused );
102 * Add a list of torrents.
103 * This function assumes ownership of torrentFiles
105 * May pop up dialogs for each torrent if that preference is enabled.
106 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
108 void tr_core_add_list( TrCore * self,
109 GSList * torrentFiles,
110 pref_flag_t start,
111 pref_flag_t prompt,
112 gboolean doNotify );
114 #define tr_core_add_list_defaults( c, l, doNotify ) \
115 tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT, doNotify )
118 /** @brief Add a torrent. */
119 gboolean tr_core_add_metainfo( TrCore * core,
120 const char * base64_metainfo,
121 gboolean * setme_success,
122 GError ** err );
124 /** @brief Add a torrent from a URL */
125 void tr_core_add_from_url( TrCore * core, const char * url );
127 /** @brief Add a torrent.
128 @param ctor this function assumes ownership of the ctor */
129 void tr_core_add_ctor( TrCore * core,
130 tr_ctor * ctor );
133 /** Add a torrent. */
134 void tr_core_add_torrent( TrCore*, TrTorrent*, gboolean doNotify );
136 /** Present the main window */
137 gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err );
141 * Notifies listeners that torrents have been added.
142 * This should be called after one or more tr_core_add*() calls.
144 void tr_core_torrents_added( TrCore * self );
146 /******
147 *******
148 ******/
150 /* remove a torrent */
151 void tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, gboolean deleteFiles );
152 void tr_core_remove_torrent_from_id( TrCore * self, int id, gboolean deleteFiles );
154 /* update the model with current torrent status */
155 void tr_core_update( TrCore * self );
157 /* emit the "quit" signal */
158 void tr_core_quit( TrCore * self );
161 *** Set a preference value, save the prefs file, and emit the "prefs-changed" signal
164 void tr_core_set_pref ( TrCore * self, const char * key, const char * val );
165 void tr_core_set_pref_bool( TrCore * self, const char * key, gboolean val );
166 void tr_core_set_pref_int ( TrCore * self, const char * key, int val );
167 void tr_core_set_pref_double( TrCore * self, const char * key, double val );
173 void tr_core_torrent_changed( TrCore * core, int id );
175 void tr_core_port_test( TrCore * core );
177 void tr_core_blocklist_update( TrCore * core );
179 void tr_core_exec( TrCore * core, const tr_benc * benc );
181 void tr_core_exec_json( TrCore * core, const char * json );
188 /* column names for the model used to store torrent information */
189 /* keep this in sync with the type array in tr_core_init() in tr_core.c */
190 enum
192 MC_NAME,
193 MC_NAME_COLLATED,
194 MC_TORRENT,
195 MC_TORRENT_RAW,
196 MC_SPEED_UP,
197 MC_SPEED_DOWN,
198 MC_ACTIVE,
199 MC_ACTIVITY,
200 MC_FINISHED,
201 MC_PRIORITY,
202 MC_TRACKERS,
203 MC_ROW_COUNT
206 #endif