}
{
- 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 );
}
}
#include <gio/gio.h>
#endif
#include <glib/gi18n.h>
+#include "conf.h"
#include "notify.h"
#include "tr-prefs.h"
#include "util.h"
/* 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;
}
}
}
+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;
+}
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,
tr_ctor * ctor,
int * setmeCount );
+int tr_sessionGetActiveTorrentCount( tr_session * session );
+
/** @} */
/**
*/
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 );
/**