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

Last change on this file since 5122 was 5122, checked in by charles, 14 years ago

(gtk) make the filename naming scheme a little more consistent.

  • Property svn:keywords set to Date Rev Author Id
File size: 5.1 KB
Line 
1/******************************************************************************
2 * $Id: tr-core.h 5122 2008-02-26 19:58:03Z 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 <string.h>
29
30#include <glib-object.h>
31#include <gtk/gtk.h>
32
33#include <libtransmission/transmission.h>
34
35#include "tr-torrent.h"
36#include "util.h"
37
38#define TR_CORE_TYPE (tr_core_get_type())
39#define TR_CORE(o) G_TYPE_CHECK_INSTANCE_CAST((o),TR_CORE_TYPE,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,TrCoreClass)
42#define TR_IS_CORE_CLASS(k) G_TYPE_CHECK_CLASS_TYPE((k),TR_CORE_TYPE)
43#define TR_CORE_GET_CLASS(o) G_TYPE_INSTANCE_GET_CLASS((o),TR_CORE_TYPE,TrCoreClass)
44
45struct core_stats
46{
47    int downloadCount;
48    int seedingCount;
49    float clientDownloadSpeed;
50    float clientUploadSpeed;
51};
52
53typedef struct TrCore
54{
55    GObject                 parent;
56    struct TrCorePrivate  * priv;
57}
58TrCore;
59
60typedef struct TrCoreClass
61{
62    GObjectClass parent;
63
64    /* "error" signal:
65       void handler( TrCore *, enum tr_core_err, const char *, gpointer ) */
66    int errsig;
67
68    /* "directory-prompt" signal:
69       void handler( TrCore *, GList *, gpointer ctor, gpointer userData ) */
70    int promptsig;
71
72    /* "quit" signal:
73       void handler( TrCore *, gpointer ) */
74    int quitsig;
75
76    /* "prefs-changed" signal:
77       void handler( TrCore *, int, gpointer ) */
78    int prefsig;
79}
80TrCoreClass;
81
82enum tr_core_err
83{
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 */
88};
89
90GType tr_core_get_type( void );
91
92TrCore * tr_core_new( void );
93
94/* Return the model used without incrementing the reference count */
95GtkTreeModel * tr_core_model( TrCore * self );
96
97tr_handle * tr_core_handle( TrCore * self );
98
99const struct core_stats* tr_core_get_stats( const TrCore * self );
100
101/******
102*******
103******/
104
105/**
106 * Load saved state and return number of torrents added.
107 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
108 */
109int tr_core_load( TrCore * self, gboolean forcepaused );
110
111/**
112 * Add a torrent.
113 * May trigger an "error" signal with TR_CORE_ERR_ADD_TORRENT
114 * Caller must free the ctor.
115 */
116void tr_core_add_ctor( TrCore * self, tr_ctor * ctor );
117
118/**
119 * Add a list of torrents.
120 * May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
121 */
122void tr_core_add_list( TrCore   * self,
123                       GList    * torrentFiles,
124                       tr_ctor  * ctor );
125
126/**
127 * Add a torrent.
128 */
129void tr_core_add_torrent( TrCore*, TrTorrent* );
130
131/**
132 * Notifies listeners that torrents have been added.
133 * This should be called after one or more tr_core_add*() calls.
134 */
135void tr_core_torrents_added( TrCore * self );
136
137/******
138*******
139******/
140
141void tr_core_delete_torrent( TrCore * self, GtkTreeIter * iter );
142
143void tr_core_remove_torrent( TrCore * self, TrTorrent * gtor, int deleteFiles );
144
145/* update the model with current torrent status */
146void tr_core_update( TrCore * self );
147
148/* emit the "quit" signal */
149void tr_core_quit( TrCore * self );
150
151/* Set a preference value, save the prefs file, and emit the
152   "prefs-changed" signal */
153void tr_core_set_pref( TrCore * self, const char * key, const char * val );
154
155/* Set a boolean preference value, save the prefs file, and emit the
156   "prefs-changed" signal */
157void tr_core_set_pref_bool( TrCore * self, const char * key, gboolean val );
158
159/* Set an integer preference value, save the prefs file, and emit the
160   "prefs-changed" signal */
161void tr_core_set_pref_int( TrCore * self, const char * key, int val );
162
163/**
164***
165**/
166
167/* column names for the model used to store torrent information */
168/* keep this in sync with the type array in tr_core_init() in tr_core.c */
169enum
170{
171    MC_NAME,
172    MC_NAME_COLLATED,
173    MC_HASH,
174    MC_TORRENT,
175    MC_TORRENT_RAW,
176    MC_STATUS,
177    MC_ID,
178    MC_ROW_COUNT
179};
180
181#endif
Note: See TracBrowser for help on using the repository browser.