(trunk) minor transmission.h API cleanup.
1. remove tr_sessionGetActiveTorrentCount() 2. make tr_sessionCountTorrents() package-visible instead of public. 3. make tr_torrentGetActivity() private instead of public.
This commit is contained in:
parent
31f4d24004
commit
d384b38f07
|
@ -339,9 +339,8 @@ refreshActions( struct cbdata * data )
|
|||
}
|
||||
|
||||
{
|
||||
tr_session * session = tr_core_session( data->core );
|
||||
const int active = tr_sessionGetActiveTorrentCount( session );
|
||||
const int total = tr_sessionCountTorrents( session );
|
||||
const int total = tr_core_get_torrent_count( data->core );
|
||||
const int active = tr_core_get_active_torrent_count( data->core );
|
||||
action_sensitize( "pause-all-torrents", active != 0 );
|
||||
action_sensitize( "start-all-torrents", active != total );
|
||||
}
|
||||
|
|
|
@ -1417,15 +1417,9 @@ tr_core_set_hibernation_allowed( TrCore * core,
|
|||
static void
|
||||
maybeInhibitHibernation( TrCore * core )
|
||||
{
|
||||
gboolean inhibit = pref_flag_get( PREF_KEY_INHIBIT_HIBERNATION );
|
||||
|
||||
/* always allow hibernation when all the torrents are paused */
|
||||
if( inhibit ) {
|
||||
tr_session * session = tr_core_session( core );
|
||||
|
||||
if( tr_sessionGetActiveTorrentCount( session ) == 0 )
|
||||
inhibit = FALSE;
|
||||
}
|
||||
/* inhibit if it's enabled *AND* all the torrents are paused */
|
||||
const gboolean inhibit = pref_flag_get( PREF_KEY_INHIBIT_HIBERNATION )
|
||||
&& ( tr_core_get_active_torrent_count( core ) == 0 );
|
||||
|
||||
tr_core_set_hibernation_allowed( core, !inhibit );
|
||||
}
|
||||
|
@ -1687,3 +1681,29 @@ tr_core_torrent_changed( TrCore * core, int id )
|
|||
while( gtk_tree_model_iter_next( model, &iter ) );
|
||||
}
|
||||
|
||||
int
|
||||
tr_core_get_torrent_count( TrCore * core )
|
||||
{
|
||||
return gtk_tree_model_iter_n_children( tr_core_model( core ), NULL );
|
||||
}
|
||||
|
||||
int
|
||||
tr_core_get_active_torrent_count( TrCore * core )
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel * model = tr_core_model( core );
|
||||
int activeCount = 0;
|
||||
|
||||
if( gtk_tree_model_get_iter_first( model, &iter ) ) do
|
||||
{
|
||||
int activity;
|
||||
gtk_tree_model_get( model, &iter, MC_ACTIVITY, &activity, -1 );
|
||||
|
||||
if( activity != TR_STATUS_STOPPED )
|
||||
++activeCount;
|
||||
}
|
||||
while( gtk_tree_model_iter_next( model, &iter ) );
|
||||
|
||||
return activeCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,10 @@ GtkTreeModel * tr_core_model( TrCore * self );
|
|||
|
||||
tr_session * tr_core_session( TrCore * self );
|
||||
|
||||
int tr_core_get_active_torrent_count( TrCore * self );
|
||||
|
||||
int tr_core_get_torrent_count( TrCore * self );
|
||||
|
||||
/******
|
||||
*******
|
||||
******/
|
||||
|
|
|
@ -173,7 +173,7 @@ getTorrents( tr_session * session,
|
|||
else /* all of them */
|
||||
{
|
||||
tr_torrent * tor = NULL;
|
||||
const int n = tr_sessionCountTorrents( session );
|
||||
const int n = tr_sessionCountTorrents( session );
|
||||
torrents = tr_new0( tr_torrent *, n );
|
||||
while( ( tor = tr_torrentNext( session, tor ) ) )
|
||||
torrents[torrentCount++] = tor;
|
||||
|
|
|
@ -2391,18 +2391,3 @@ tr_sessionSetProxyPassword( tr_session * session,
|
|||
session->proxyPassword = tr_strdup( password );
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
tr_sessionGetActiveTorrentCount( tr_session * session )
|
||||
{
|
||||
int ret = 0;
|
||||
tr_torrent * tor = NULL;
|
||||
|
||||
assert( tr_isSession( session ) );
|
||||
|
||||
while(( tor = tr_torrentNext( session, tor )))
|
||||
if( tr_torrentGetActivity( tor ) != TR_STATUS_STOPPED )
|
||||
++ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -199,6 +199,8 @@ const struct tr_address* tr_sessionGetPublicAddress( const tr_session *, int tr
|
|||
|
||||
struct tr_bindsockets * tr_sessionGetBindSockets( tr_session * );
|
||||
|
||||
int tr_sessionCountTorrents( const tr_session * session );
|
||||
|
||||
enum
|
||||
{
|
||||
SESSION_MAGIC_NUMBER = 3845,
|
||||
|
|
|
@ -635,8 +635,6 @@ tr_port_forwarding;
|
|||
|
||||
tr_port_forwarding tr_sessionGetPortForwarding( const tr_session * session );
|
||||
|
||||
int tr_sessionCountTorrents( const tr_session * session );
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TR_CLIENT_TO_PEER = 0, TR_UP = 0,
|
||||
|
@ -744,8 +742,6 @@ tr_torrent ** tr_sessionLoadTorrents( tr_session * session,
|
|||
tr_ctor * ctor,
|
||||
int * setmeCount );
|
||||
|
||||
int tr_sessionGetActiveTorrentCount( tr_session * session );
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
@ -1649,8 +1645,6 @@ typedef enum
|
|||
}
|
||||
tr_torrent_activity;
|
||||
|
||||
tr_torrent_activity tr_torrentGetActivity( tr_torrent * );
|
||||
|
||||
enum
|
||||
{
|
||||
TR_PEER_FROM_INCOMING = 0, /* connections made to the listening port */
|
||||
|
|
|
@ -901,7 +901,7 @@ Session :: addTorrent( QString key, QString localPath )
|
|||
if( !keyHandled ) {
|
||||
const QByteArray tmp = key.toUtf8();
|
||||
tr_bencDictAddRaw( args, "metainfo", tmp.constData(), tmp.length() );
|
||||
keyHandled; // treat it as base64
|
||||
keyHandled = true; // treat it as base64
|
||||
}
|
||||
|
||||
exec( &top );
|
||||
|
|
Loading…
Reference in New Issue