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

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

(trunk gtk) #3346 "busy icon needed while processing request" -- added.

  • Property svn:keywords set to Date Rev Author Id
File size: 6.4 KB
Line 
1/******************************************************************************
2 * $Id: tr-core.h 10863 2010-06-26 15:55:19Z 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
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
86int            tr_core_get_active_torrent_count( TrCore * self );
87
88int            tr_core_get_torrent_count( TrCore * self );
89
90/******
91*******
92******/
93
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
97 */
98int      tr_core_load( TrCore * self,
99                       gboolean forcepaused );
100
101/**
102 * Add a list of torrents.
103 * This function assumes ownership of torrentFiles
104 *
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
107 */
108void     tr_core_add_list( TrCore *    self,
109                           GSList *    torrentFiles,
110                           pref_flag_t start,
111                           pref_flag_t prompt,
112                           gboolean    doNotify );
113
114#define tr_core_add_list_defaults( c, l, doNotify ) \
115    tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT, doNotify )
116
117
118/** @brief Add a torrent. */
119gboolean tr_core_add_metainfo( TrCore      * core,
120                               const char  * payload,
121                               const char  * optional_filename,
122                               gboolean    * setme_success,
123                               GError     ** err );
124
125/** @brief Add a torrent from a URL */
126void tr_core_add_from_url( TrCore * core, const char * url );
127
128/** @brief Add a torrent.
129    @param ctor this function assumes ownership of the ctor */
130void tr_core_add_ctor( TrCore  * core,
131                       tr_ctor * ctor );
132
133
134/** Add a torrent. */
135void tr_core_add_torrent( TrCore*, TrTorrent*, gboolean doNotify );
136
137/** Present the main window */
138gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err );
139
140
141/**
142 * Notifies listeners that torrents have been added.
143 * This should be called after one or more tr_core_add*() calls.
144 */
145void     tr_core_torrents_added( TrCore * self );
146
147/******
148*******
149******/
150
151/* remove a torrent */
152void  tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, gboolean deleteFiles );
153void  tr_core_remove_torrent_from_id( TrCore * self, int id, gboolean deleteFiles );
154
155/* update the model with current torrent status */
156void  tr_core_update( TrCore * self );
157
158/* emit the "quit" signal */
159void  tr_core_quit( TrCore * self );
160
161/**
162***  Set a preference value, save the prefs file, and emit the "prefs-changed" signal
163**/
164
165void tr_core_set_pref     ( TrCore * self, const char * key, const char * val );
166void tr_core_set_pref_bool( TrCore * self, const char * key, gboolean val );
167void tr_core_set_pref_int ( TrCore * self, const char * key, int val );
168void tr_core_set_pref_double( TrCore * self, const char * key, double val );
169
170/**
171***
172**/
173
174void tr_core_torrent_changed( TrCore * core, int id );
175
176void tr_core_port_test( TrCore * core );
177
178void tr_core_blocklist_update( TrCore * core );
179
180void tr_core_exec( TrCore * core, const tr_benc * benc );
181
182void tr_core_exec_json( TrCore * core, const char * json );
183
184
185/**
186***
187**/
188
189/* column names for the model used to store torrent information */
190/* keep this in sync with the type array in tr_core_init() in tr_core.c */
191enum
192{
193    MC_NAME,
194    MC_NAME_COLLATED,
195    MC_TORRENT,
196    MC_TORRENT_RAW,
197    MC_SPEED_UP,
198    MC_SPEED_DOWN,
199    MC_ACTIVITY,
200    MC_ROW_COUNT
201};
202
203#endif
Note: See TracBrowser for help on using the repository browser.