2007-05-23 00:49:31 +00:00
|
|
|
/******************************************************************************
|
2011-01-19 13:48:47 +00:00
|
|
|
* Copyright (c) Transmission authors and contributors
|
2007-05-23 00:49:31 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2007-05-23 00:49:31 +00:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2007-07-18 23:04:26 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2012-12-14 04:34:42 +00:00
|
|
|
#include <libtransmission/variant.h>
|
2011-03-03 01:59:25 +00:00
|
|
|
|
2011-08-09 05:47:24 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
#define TR_CORE_TYPE (tr_core_get_type())
|
2017-04-20 16:02:19 +00:00
|
|
|
#define TR_CORE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), TR_CORE_TYPE, TrCore))
|
2007-05-23 00:49:31 +00:00
|
|
|
|
2016-02-23 04:34:57 +00:00
|
|
|
#define TR_RESOURCE_PATH "/com/transmissionbt/transmission/"
|
|
|
|
|
2010-06-26 15:55:19 +00:00
|
|
|
typedef struct _TrCore
|
2007-05-23 00:49:31 +00:00
|
|
|
{
|
2010-06-26 15:55:19 +00:00
|
|
|
GObject parent;
|
|
|
|
|
2011-08-09 05:47:24 +00:00
|
|
|
/*< private >*/
|
2017-04-19 12:04:45 +00:00
|
|
|
struct TrCorePrivate* priv;
|
2008-02-09 17:29:05 +00:00
|
|
|
}
|
|
|
|
TrCore;
|
2007-05-23 00:49:31 +00:00
|
|
|
|
2007-05-23 17:59:35 +00:00
|
|
|
enum tr_core_err
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
TR_CORE_ERR_ADD_TORRENT_ERR = TR_PARSE_ERR,
|
|
|
|
TR_CORE_ERR_ADD_TORRENT_DUP = TR_PARSE_DUPLICATE,
|
2009-08-05 01:59:16 +00:00
|
|
|
TR_CORE_ERR_NO_MORE_TORRENTS = 1000 /* finished adding a batch */
|
2007-05-23 00:49:31 +00:00
|
|
|
};
|
|
|
|
|
2010-06-26 15:55:19 +00:00
|
|
|
typedef struct _TrCoreClass
|
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
2017-04-21 07:40:57 +00:00
|
|
|
void (* add_error)(TrCore*, enum tr_core_err, char const* name);
|
|
|
|
void (* add_prompt)(TrCore*, gpointer ctor);
|
|
|
|
void (* blocklist_updated)(TrCore*, int ruleCount);
|
|
|
|
void (* busy)(TrCore*, gboolean is_busy);
|
|
|
|
void (* prefs_changed)(TrCore*, tr_quark const key);
|
|
|
|
void (* port_tested)(TrCore*, gboolean is_open);
|
|
|
|
void (* quit)(TrCore*);
|
2010-06-26 15:55:19 +00:00
|
|
|
}
|
|
|
|
TrCoreClass;
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
GType tr_core_get_type(void) G_GNUC_CONST;
|
2007-05-23 00:49:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
TrCore* gtr_core_new(tr_session*);
|
2007-05-23 00:49:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_session* gtr_core_close(TrCore*);
|
2008-04-17 20:35:18 +00:00
|
|
|
|
2007-05-23 01:47:42 +00:00
|
|
|
/* Return the model used without incrementing the reference count */
|
2017-04-19 12:04:45 +00:00
|
|
|
GtkTreeModel* gtr_core_model(TrCore* self);
|
2011-03-03 01:59:25 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_clear(TrCore* self);
|
2007-05-23 00:49:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_session* gtr_core_session(TrCore* self);
|
2011-02-01 01:45:41 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
size_t gtr_core_get_active_torrent_count(TrCore* self);
|
2007-05-23 01:47:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
size_t gtr_core_get_torrent_count(TrCore* self);
|
2010-04-29 23:08:11 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_torrent* gtr_core_find_torrent(TrCore* core, int id);
|
2010-04-29 23:08:11 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_core_pref_changed(TrCore* core, tr_quark const key);
|
2011-03-04 05:58:32 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
/******
|
|
|
|
*******
|
|
|
|
******/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load saved state and return number of torrents added.
|
|
|
|
* May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_load(TrCore* self, gboolean forcepaused);
|
2008-02-13 03:00:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a list of torrents.
|
2008-03-18 01:22:11 +00:00
|
|
|
* This function assumes ownership of torrentFiles
|
|
|
|
*
|
|
|
|
* May pop up dialogs for each torrent if that preference is enabled.
|
2008-02-13 03:00:21 +00:00
|
|
|
* May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_add_files(TrCore* core, GSList* files, gboolean do_start, gboolean do_prompt, gboolean do_notify);
|
2009-06-11 14:51:21 +00:00
|
|
|
|
2009-11-22 16:20:22 +00:00
|
|
|
/** @brief Add a torrent from a URL */
|
2017-04-20 16:02:19 +00:00
|
|
|
bool gtr_core_add_from_url(TrCore* core, char const* url);
|
2009-11-22 16:20:22 +00:00
|
|
|
|
2009-09-17 01:28:45 +00:00
|
|
|
/** @brief Add a torrent.
|
|
|
|
@param ctor this function assumes ownership of the ctor */
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_add_ctor(TrCore* core, tr_ctor* ctor);
|
2009-09-17 01:28:45 +00:00
|
|
|
|
2009-04-07 20:13:08 +00:00
|
|
|
/** Add a torrent. */
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_add_torrent(TrCore*, tr_torrent*, gboolean do_notify);
|
2008-05-18 16:44:30 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
/**
|
|
|
|
* Notifies listeners that torrents have been added.
|
2012-12-05 17:29:46 +00:00
|
|
|
* This should be called after one or more tr_core_add* () calls.
|
2008-02-13 03:00:21 +00:00
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_torrents_added(TrCore* self);
|
2008-02-13 03:00:21 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_torrent_changed(TrCore* self, int id);
|
2017-02-21 20:18:52 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
/******
|
|
|
|
*******
|
|
|
|
******/
|
2007-05-23 01:47:42 +00:00
|
|
|
|
2008-07-16 19:38:22 +00:00
|
|
|
/* remove a torrent */
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_remove_torrent(TrCore* self, int id, gboolean delete_files);
|
2008-02-19 03:57:03 +00:00
|
|
|
|
2007-05-23 06:25:15 +00:00
|
|
|
/* update the model with current torrent status */
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_update(TrCore* self);
|
2007-05-23 02:45:28 +00:00
|
|
|
|
2009-04-07 20:13:08 +00:00
|
|
|
/**
|
|
|
|
*** Set a preference value, save the prefs file, and emit the "prefs-changed" signal
|
|
|
|
**/
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_core_set_pref(TrCore* self, tr_quark const key, char const* val);
|
|
|
|
void gtr_core_set_pref_bool(TrCore* self, tr_quark const key, gboolean val);
|
|
|
|
void gtr_core_set_pref_int(TrCore* self, tr_quark const key, int val);
|
|
|
|
void gtr_core_set_pref_double(TrCore* self, tr_quark const key, double val);
|
2009-04-07 20:13:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_port_test(TrCore* core);
|
2010-03-14 05:13:02 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_blocklist_update(TrCore* core);
|
2009-04-07 20:13:08 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void gtr_core_exec(TrCore* core, tr_variant const* benc);
|
2009-04-24 01:37:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void gtr_core_open_folder(TrCore* core, int torrent_id);
|
2009-04-24 01:37:04 +00:00
|
|
|
|
2008-02-14 17:18:00 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
2007-05-24 13:55:57 +00:00
|
|
|
|
2007-05-23 00:49:31 +00:00
|
|
|
/* column names for the model used to store torrent information */
|
2017-04-21 07:40:57 +00:00
|
|
|
/* keep this in sync with the type array in tr_core_init() in tr_core.c */
|
2007-12-19 02:46:30 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MC_NAME_COLLATED,
|
|
|
|
MC_TORRENT,
|
2011-03-03 01:59:25 +00:00
|
|
|
MC_TORRENT_ID,
|
2009-08-07 20:49:06 +00:00
|
|
|
MC_SPEED_UP,
|
|
|
|
MC_SPEED_DOWN,
|
2013-02-08 01:34:59 +00:00
|
|
|
MC_ACTIVE_PEERS_UP,
|
|
|
|
MC_ACTIVE_PEERS_DOWN,
|
2011-02-02 02:45:20 +00:00
|
|
|
MC_RECHECK_PROGRESS,
|
2010-08-04 17:35:48 +00:00
|
|
|
MC_ACTIVE,
|
2008-10-20 17:54:56 +00:00
|
|
|
MC_ACTIVITY,
|
2010-08-01 17:43:35 +00:00
|
|
|
MC_FINISHED,
|
|
|
|
MC_PRIORITY,
|
2011-08-01 22:24:24 +00:00
|
|
|
MC_QUEUE_POSITION,
|
2010-08-01 17:43:35 +00:00
|
|
|
MC_TRACKERS,
|
2011-01-21 17:07:23 +00:00
|
|
|
/* tr_stat.error
|
|
|
|
* Tracked because ACTIVITY_FILTER_ERROR needs the row-changed events */
|
|
|
|
MC_ERROR,
|
|
|
|
/* tr_stat.{ peersSendingToUs + peersGettingFromUs + webseedsSendingToUs }
|
|
|
|
* Tracked because ACTIVITY_FILTER_ACTIVE needs the row-changed events */
|
|
|
|
MC_ACTIVE_PEER_COUNT,
|
2017-04-21 07:40:57 +00:00
|
|
|
/* */
|
2007-12-19 02:46:30 +00:00
|
|
|
MC_ROW_COUNT
|
2007-05-23 00:49:31 +00:00
|
|
|
};
|
|
|
|
|
2011-08-09 05:47:24 +00:00
|
|
|
G_END_DECLS
|