]> granicus.if.org Git - transmission/commitdiff
(trunk libT) Remove tr_torrentNext() from the public libT API (wereHamster)
authorCharles Kerr <charles@transmissionbt.com>
Tue, 13 Jan 2009 16:39:19 +0000 (16:39 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Tue, 13 Jan 2009 16:39:19 +0000 (16:39 +0000)
gtk/main.c
gtk/notify.c
gtk/tr-core.c
libtransmission/session.c
libtransmission/torrent.h
libtransmission/transmission.h

index 13f6f293ac3ef4dc52338a3d4a0c1cb51559d086..47ef71aa1e7792c0c67b77dc8f7ba182f8f2911a 100644 (file)
@@ -237,12 +237,8 @@ refreshTorrentActions( struct cbdata * data )
     }
 
     {
-        tr_torrent * tor = NULL;
         tr_session * session = tr_core_session( data->core );
-        int activeCount = 0;
-        while(( tor = tr_torrentNext( session, tor )))
-            if( TR_STATUS_IS_ACTIVE( tr_torrentGetActivity( tor )))
-                ++activeCount;
+        int activeCount = tr_sessionGetActiveTorrentCount( session );
         action_sensitize( "pause-all-torrents", activeCount != 0 );
     }
 }
index 5e9007313d97da2d1f7f9be598f428bc332ae957..6df5b6180a88f29f8299eb7948f9c691e1e6ad48 100644 (file)
@@ -15,6 +15,7 @@
  #include <gio/gio.h>
 #endif
 #include <glib/gi18n.h>
+#include "conf.h"
 #include "notify.h"
 #include "tr-prefs.h"
 #include "util.h"
index 058e6f74bd912988a8d64a8d77a4e89ce3519ac5..b38f45e1ebc7035b6adb185168bd4a01ce977289 100644 (file)
@@ -1207,13 +1207,9 @@ maybeInhibitHibernation( TrCore * core )
 
     /* always allow hibernation when all the torrents are paused */
     if( inhibit ) {
-        gboolean active = FALSE;
-        tr_session *  session = tr_core_session( core );
-        tr_torrent * tor = NULL;
-        while(( tor = tr_torrentNext( session, tor )))
-            if(( active = ( tr_torrentGetActivity( tor ) != TR_STATUS_STOPPED )))
-                break;
-        if( !active )
+        tr_session * session = tr_core_session( core );
+
+        if( tr_sessionGetActiveTorrentCount( session ) == 0 )
             inhibit = FALSE;
     }
 
index 7f8c5d85e167c0b8264e4deae5902dc1f40164d2..d18178882bcfcb083e9b3e60fdf8c8387198561a 100644 (file)
@@ -1399,3 +1399,15 @@ tr_sessionSetProxyPassword( tr_session * session,
     }
 }
 
+int
+tr_sessionGetActiveTorrentCount( tr_session * session )
+{
+    int ret;
+    tr_torrent * tor;
+
+    while(( tor = tr_torrentNext( session, tor )))
+        if( tr_torrentGetActivity( tor ) != TR_STATUS_STOPPED )
+            ++ret;
+    
+    return ret;
+}
index d69485cd94076421831b64a6d7818c5d2b72ef52..a03c3eeb49bbc3d0993f87414f87b1c587284947 100644 (file)
@@ -111,6 +111,10 @@ int              tr_torrentPromoteTracker( tr_torrent   * tor,
 time_t*          tr_torrentGetMTimes( const tr_torrent  * tor,
                                       size_t            * setmeCount );
 
+tr_torrent*      tr_torrentNext( tr_session  * session,
+                                 tr_torrent  * current );
+
+
 typedef enum
 {
     TR_VERIFY_NONE,
index d36da10ebde2d8a545f026750d2a766d055cfc12..c82decdcb460397e6a5433707a2169688b496569 100644 (file)
@@ -563,6 +563,8 @@ tr_torrent ** tr_sessionLoadTorrents( tr_session  * session,
                                       tr_ctor     * ctor,
                                       int         * setmeCount );
 
+int tr_sessionGetActiveTorrentCount( tr_session * session );
+
 /** @} */
 
 /**
@@ -817,15 +819,6 @@ typedef int tr_fileFunc( const char * filename );
  */
 void tr_torrentDeleteLocalData( tr_torrent * torrent,  tr_fileFunc fileFunc );
 
-/**
- * @brief Iterate through the torrents.
- *
- * Pass in a NULL pointer to get the first torrent.
- */
-tr_torrent* tr_torrentNext( tr_session  * session,
-                            tr_torrent  * current );
-
-
 uint64_t tr_torrentGetBytesLeftToAllocate( const tr_torrent * torrent );
 
 /**