Changeset 10550


Ignore:
Timestamp:
Apr 29, 2010, 11:08:11 PM (11 years ago)
Author:
charles
Message:

(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.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r10523 r10550  
    340340
    341341    {
    342         tr_session * session = tr_core_session( data->core );
    343         const int active = tr_sessionGetActiveTorrentCount( session );
    344         const int total = tr_sessionCountTorrents( session );
     342        const int total = tr_core_get_torrent_count( data->core );
     343        const int active = tr_core_get_active_torrent_count( data->core );
    345344        action_sensitize( "pause-all-torrents", active != 0 );
    346345        action_sensitize( "start-all-torrents", active != total );
  • trunk/gtk/tr-core.c

    r10507 r10550  
    14181418maybeInhibitHibernation( TrCore * core )
    14191419{
    1420     gboolean inhibit = pref_flag_get( PREF_KEY_INHIBIT_HIBERNATION );
    1421 
    1422     /* always allow hibernation when all the torrents are paused */
    1423     if( inhibit ) {
    1424         tr_session * session = tr_core_session( core );
    1425 
    1426         if( tr_sessionGetActiveTorrentCount( session ) == 0 )
    1427             inhibit = FALSE;
    1428     }
     1420    /* inhibit if it's enabled *AND* all the torrents are paused */
     1421    const gboolean inhibit = pref_flag_get( PREF_KEY_INHIBIT_HIBERNATION )
     1422                          && ( tr_core_get_active_torrent_count( core ) == 0 );
    14291423
    14301424    tr_core_set_hibernation_allowed( core, !inhibit );
     
    16881682}
    16891683
     1684int
     1685tr_core_get_torrent_count( TrCore * core )
     1686{
     1687    return gtk_tree_model_iter_n_children( tr_core_model( core ), NULL );
     1688}
     1689
     1690int
     1691tr_core_get_active_torrent_count( TrCore * core )
     1692{
     1693    GtkTreeIter iter;
     1694    GtkTreeModel * model = tr_core_model( core );
     1695    int activeCount = 0;
     1696
     1697    if( gtk_tree_model_get_iter_first( model, &iter ) ) do
     1698    {
     1699        int activity;
     1700        gtk_tree_model_get( model, &iter, MC_ACTIVITY, &activity, -1 );
     1701
     1702        if( activity != TR_STATUS_STOPPED )
     1703            ++activeCount;
     1704    }
     1705    while( gtk_tree_model_iter_next( model, &iter ) );
     1706
     1707    return activeCount;
     1708}
     1709
  • trunk/gtk/tr-core.h

    r10505 r10550  
    100100tr_session *   tr_core_session( TrCore * self );
    101101
     102int            tr_core_get_active_torrent_count( TrCore * self );
     103
     104int            tr_core_get_torrent_count( TrCore * self );
     105
    102106/******
    103107*******
  • trunk/libtransmission/rpcimpl.c

    r10495 r10550  
    174174    {
    175175        tr_torrent * tor = NULL;
    176         const int    n = tr_sessionCountTorrents( session );
     176        const int n = tr_sessionCountTorrents( session );
    177177        torrents = tr_new0( tr_torrent *, n );
    178178        while( ( tor = tr_torrentNext( session, tor ) ) )
  • trunk/libtransmission/session.c

    r10538 r10550  
    23922392    }
    23932393}
    2394 
    2395 int
    2396 tr_sessionGetActiveTorrentCount( tr_session * session )
    2397 {
    2398     int ret = 0;
    2399     tr_torrent * tor = NULL;
    2400 
    2401     assert( tr_isSession( session ) );
    2402 
    2403     while(( tor = tr_torrentNext( session, tor )))
    2404         if( tr_torrentGetActivity( tor ) != TR_STATUS_STOPPED )
    2405             ++ret;
    2406 
    2407     return ret;
    2408 }
  • trunk/libtransmission/session.h

    r10508 r10550  
    200200struct tr_bindsockets * tr_sessionGetBindSockets( tr_session * );
    201201
     202int tr_sessionCountTorrents( const tr_session * session );
     203
    202204enum
    203205{
  • trunk/libtransmission/transmission.h

    r10508 r10550  
    636636tr_port_forwarding tr_sessionGetPortForwarding( const tr_session * session );
    637637
    638 int tr_sessionCountTorrents( const tr_session * session );
    639 
    640638typedef enum
    641639{
     
    744742                                      tr_ctor     * ctor,
    745743                                      int         * setmeCount );
    746 
    747 int tr_sessionGetActiveTorrentCount( tr_session * session );
    748744
    749745/** @} */
     
    16501646tr_torrent_activity;
    16511647
    1652 tr_torrent_activity tr_torrentGetActivity( tr_torrent * );
    1653 
    16541648enum
    16551649{
  • trunk/qt/session.cc

    r10532 r10550  
    902902        const QByteArray tmp = key.toUtf8();
    903903        tr_bencDictAddRaw( args, "metainfo", tmp.constData(), tmp.length() );
    904         keyHandled; // treat it as base64
     904        keyHandled = true; // treat it as base64
    905905    }
    906906
Note: See TracChangeset for help on using the changeset viewer.