~ubuntu-branches/ubuntu/precise/transmission/precise

« back to all changes in this revision

Viewing changes to gtk/tr-core.h

  • Committer: Bazaar Package Importer
  • Author(s): Leo Costela
  • Date: 2009-05-17 19:39:51 UTC
  • mto: (1.3.4 upstream) (2.2.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: james.westby@ubuntu.com-20090517193951-k8x15sqoxzf7cuyx
ImportĀ upstreamĀ versionĀ 1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: tr-core.h 5646 2008-04-19 00:41:32Z charles $
 
2
 * $Id: tr-core.h 8279 2009-04-24 01:37:04Z charles $
3
3
 *
4
4
 * Copyright (c) 2007-2008 Transmission authors and contributors
5
5
 *
34
34
#include "conf.h" /* pref_flag_t */
35
35
#include "tr-torrent.h"
36
36
 
37
 
#define TR_CORE_TYPE (tr_core_get_type())
38
 
#define TR_CORE(o) G_TYPE_CHECK_INSTANCE_CAST((o),TR_CORE_TYPE,TrCore)
39
 
#define TR_IS_CORE(o) G_TYPE_CHECK_INSTANCE_TYPE((o),TR_CORE_TYPE)
40
 
#define TR_CORE_CLASS(k) G_TYPE_CHECK_CLASS_CAST((k),TR_CORE_TYPE,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),TR_CORE_TYPE,TrCoreClass)
 
37
#define TR_CORE_TYPE ( tr_core_get_type( ) )
 
38
#define TR_CORE( o ) G_TYPE_CHECK_INSTANCE_CAST( ( o ), TR_CORE_TYPE,\
 
39
                                                TrCore )
 
40
#define TR_IS_CORE( o ) G_TYPE_CHECK_INSTANCE_TYPE( ( o ), TR_CORE_TYPE )
 
41
#define TR_CORE_CLASS( k ) G_TYPE_CHECK_CLASS_CAST( ( k ), TR_CORE_TYPE,\
 
42
                                                   TrCoreClass )
 
43
#define TR_IS_CORE_CLASS( k ) G_TYPE_CHECK_CLASS_TYPE( ( k ), TR_CORE_TYPE )
 
44
#define TR_CORE_GET_CLASS( o ) G_TYPE_INSTANCE_GET_CLASS( ( o ),\
 
45
                                                         TR_CORE_TYPE, \
 
46
                                                         TrCoreClass )
43
47
 
44
48
struct core_stats
45
49
{
46
 
    int downloadCount;
47
 
    int seedingCount;
48
 
    float clientDownloadSpeed;
49
 
    float clientUploadSpeed;
 
50
    int      downloadCount;
 
51
    int      seedingCount;
 
52
    float    clientDownloadSpeed;
 
53
    float    clientUploadSpeed;
50
54
};
51
55
 
52
56
typedef struct TrCore
53
57
{
54
 
    GObject                 parent;
 
58
    GObject    parent;
55
59
    struct TrCorePrivate  * priv;
56
60
}
57
61
TrCore;
58
62
 
59
63
typedef struct TrCoreClass
60
64
{
61
 
    GObjectClass parent;
62
 
 
63
 
    /* "error" signal:
64
 
       void handler( TrCore *, enum tr_core_err, const char *, gpointer ) */
 
65
    GObjectClass    parent;
 
66
 
 
67
    /* "blocklist-updated" signal with a callback type of
 
68
        void (*callback )( TrCore*, int ruleCount, gpointer userData ). */
 
69
    int blocklistSignal;
 
70
 
 
71
    /* "port-tested" signal with a callback type of
 
72
       void( *callback )( TrCore*, gboolean isOpen, gpointer userData ). */
 
73
    int portSignal;
 
74
 
 
75
    /* "error" signal with a callback type of
 
76
       void( *callback )( TrCore*, enum tr_core_err, const char * humanReadable, gpointer userData ). */
65
77
    int errsig;
66
78
 
67
 
    /* "add-torrent-prompt" signal:
68
 
       void handler( TrCore *, gpointer ctor, gpointer userData )
 
79
    /* "add-torrent-prompt" signal with a callback type of
 
80
       void ( *callback)( TrCore *, gpointer ctor, gpointer userData )
69
81
       The handler assumes ownership of ctor and must free when done */
70
82
    int promptsig;
71
83
 
81
93
 
82
94
enum tr_core_err
83
95
{
84
 
    TR_CORE_ERR_ADD_TORRENT,    /* adding a torrent failed */
85
 
    /* no more torrents to be added, used for grouping torrent add errors */
86
 
    TR_CORE_ERR_NO_MORE_TORRENTS,
87
 
    TR_CORE_ERR_SAVE_STATE      /* error saving state */
 
96
    TR_CORE_ERR_ADD_TORRENT_ERR  = TR_EINVALID,
 
97
    TR_CORE_ERR_ADD_TORRENT_DUP  = TR_EDUPLICATE,
 
98
    TR_CORE_ERR_NO_MORE_TORRENTS,  /* finished adding a batch */
 
99
    TR_CORE_ERR_SAVE_STATE         /* error saving state */
88
100
};
89
101
 
90
 
GType tr_core_get_type( void );
91
 
 
92
 
TrCore * tr_core_new( tr_handle * );
93
 
 
94
 
void tr_core_close( TrCore* );
 
102
GType          tr_core_get_type( void );
 
103
 
 
104
TrCore *       tr_core_new( tr_session * );
 
105
 
 
106
void           tr_core_close( TrCore* );
95
107
 
96
108
/* Return the model used without incrementing the reference count */
97
109
GtkTreeModel * tr_core_model( TrCore * self );
98
110
 
99
 
tr_handle * tr_core_handle( TrCore * self );
 
111
tr_session *   tr_core_session( TrCore * self );
100
112
 
101
 
void tr_core_get_stats( const TrCore      * core, 
102
 
                        struct core_stats * setme );
 
113
void           tr_core_get_stats( const TrCore *      core,
 
114
                                  struct core_stats * setme );
103
115
 
104
116
/******
105
117
*******
109
121
 * Load saved state and return number of torrents added.
110
122
 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
111
123
 */
112
 
int tr_core_load( TrCore * self, gboolean forcepaused );
113
 
 
114
 
/**
115
 
 * Add a torrent.
116
 
 * This function assumes ownership of ctor
117
 
 *
118
 
 * May trigger an "error" signal with TR_CORE_ERR_ADD_TORRENT
119
 
 */
120
 
void tr_core_add_ctor( TrCore * self, tr_ctor * ctor );
 
124
int      tr_core_load( TrCore * self,
 
125
                       gboolean forcepaused );
121
126
 
122
127
/**
123
128
 * Add a list of torrents.
126
131
 * May pop up dialogs for each torrent if that preference is enabled.
127
132
 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
128
133
 */
129
 
void tr_core_add_list( TrCore      * self,
130
 
                       GSList      * torrentFiles,
131
 
                       pref_flag_t   start,
132
 
                       pref_flag_t   prompt );
133
 
 
134
 
#define tr_core_add_list_defaults(c,l) \
135
 
        tr_core_add_list(c,l,PREF_FLAG_DEFAULT,PREF_FLAG_DEFAULT)
136
 
 
137
 
/**
138
 
 * Add a torrent.
139
 
 */
 
134
void     tr_core_add_list( TrCore *    self,
 
135
                           GSList *    torrentFiles,
 
136
                           pref_flag_t start,
 
137
                           pref_flag_t prompt );
 
138
 
 
139
#define tr_core_add_list_defaults( c, l ) \
 
140
    tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT )
 
141
 
 
142
 
 
143
/** Add a torrent. */
 
144
gboolean tr_core_add_file( TrCore*, const char * filename, gboolean * setme_success, GError **    err );
 
145
/** Add a torrent. */
140
146
void tr_core_add_torrent( TrCore*, TrTorrent* );
141
147
 
 
148
/** Present the main window */
 
149
gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err ); 
 
150
 
 
151
 
142
152
/**
143
153
 * Notifies listeners that torrents have been added.
144
154
 * This should be called after one or more tr_core_add*() calls.
145
155
 */
146
 
void tr_core_torrents_added( TrCore * self );
 
156
void     tr_core_torrents_added( TrCore * self );
147
157
 
148
158
/******
149
159
*******
150
160
******/
151
161
 
152
 
void tr_core_delete_torrent( TrCore * self, GtkTreeIter * iter );
 
162
/* we've gotten notice from RPC that a torrent has been destroyed;
 
163
   update our gui accordingly */
 
164
void  tr_core_torrent_destroyed( TrCore * self, int torrentId );
153
165
 
154
 
void tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, int deleteFiles );
 
166
/* remove a torrent */
 
167
void  tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, int deleteFiles );
155
168
 
156
169
/* update the model with current torrent status */
157
 
void tr_core_update( TrCore * self );
 
170
void  tr_core_update( TrCore * self );
158
171
 
159
172
/* emit the "quit" signal */
160
 
void tr_core_quit( TrCore * self );
161
 
 
162
 
/* Set a preference value, save the prefs file, and emit the
163
 
   "prefs-changed" signal */
164
 
void tr_core_set_pref( TrCore * self, const char * key, const char * val );
165
 
 
166
 
/* Set a boolean preference value, save the prefs file, and emit the
167
 
   "prefs-changed" signal */
 
173
void  tr_core_quit( TrCore * self );
 
174
 
 
175
/**
 
176
***  Set a preference value, save the prefs file, and emit the "prefs-changed" signal
 
177
**/
 
178
 
 
179
void tr_core_set_pref     ( TrCore * self, const char * key, const char * val );
168
180
void tr_core_set_pref_bool( TrCore * self, const char * key, gboolean val );
169
 
 
170
 
/* Set an integer preference value, save the prefs file, and emit the
171
 
   "prefs-changed" signal */
172
 
void tr_core_set_pref_int( TrCore * self, const char * key, int val );
 
181
void tr_core_set_pref_int ( TrCore * self, const char * key, int val );
 
182
void tr_core_set_pref_double( TrCore * self, const char * key, double val );
 
183
 
 
184
/**
 
185
***
 
186
**/
 
187
 
 
188
void tr_core_port_test( TrCore * core );
 
189
 
 
190
void tr_core_blocklist_update( TrCore * core );
 
191
 
 
192
void tr_core_exec( TrCore * core, const tr_benc * benc );
 
193
 
 
194
void tr_core_exec_json( TrCore * core, const char * json );
 
195
 
173
196
 
174
197
/**
175
198
***
181
204
{
182
205
    MC_NAME,
183
206
    MC_NAME_COLLATED,
184
 
    MC_HASH,
185
207
    MC_TORRENT,
186
208
    MC_TORRENT_RAW,
187
 
    MC_STATUS,
188
 
    MC_ID,
 
209
    MC_ACTIVITY,
189
210
    MC_ROW_COUNT
190
211
};
191
212