#671 "torrent queuing" -- add a tr_stat.isStalled flag.

This commit is contained in:
Jordan Lee 2011-08-01 23:27:11 +00:00
parent 97cd1d9d05
commit 2e9d419bd4
8 changed files with 17 additions and 2 deletions

View File

@ -164,6 +164,7 @@
id | number | tr_torrent
isFinished | boolean | tr_stat
isPrivate | boolean | tr_torrent
isStalled | boolean | tr_stat
leftUntilDone | number | tr_stat
magnetLink | number | n/a
manualAnnounceTime | number | tr_stat
@ -690,6 +691,7 @@
------+---------+-----------+----------------+-------------------------------
14 | 2.40 | NO | torrent-get | values of "status" field changed
| | yes | torrent-get | new arg "queuePosition"
| | yes | torrent-get | new arg "isStalled"
| | yes | torrent-set | new arg "queuePosition"
| | yes | session-set | new arg "download-queue-size"
| | yes | session-set | new arg "download-queue-enabled"

View File

@ -191,8 +191,9 @@ getShortTransferString( const tr_torrent * tor,
/* bandwidth speed + unicode arrow */
g_snprintf( buf, buflen, _( "%1$s %2$s" ),
gtr_get_unicode_string( GTR_UNICODE_UP ), upStr );
else if( st->isStalled )
g_strlcpy( buf, _( "Stalled" ), buflen );
else if( haveMeta )
/* the torrent isn't uploading or downloading */
g_strlcpy( buf, _( "Idle" ), buflen );
else
*buf = '\0';

View File

@ -609,6 +609,8 @@ addField( const tr_torrent * const tor,
tr_bencDictAddBool( d, key, st->finished );
else if( tr_streq( key, keylen, "isPrivate" ) )
tr_bencDictAddBool( d, key, tr_torrentIsPrivate( tor ) );
else if( tr_streq( key, keylen, "isStalled" ) )
tr_bencDictAddBool( d, key, st->isStalled );
else if( tr_streq( key, keylen, "leftUntilDone" ) )
tr_bencDictAddInt( d, key, st->leftUntilDone );
else if( tr_streq( key, keylen, "manualAnnounceTime" ) )

View File

@ -1183,6 +1183,7 @@ tr_torrentStat( tr_torrent * tor )
s->activity = tr_torrentGetActivity( tor );
s->error = tor->error;
s->queuePosition = tor->queuePosition;
s->isStalled = tr_torrentIsStalled( tor );
tr_strlcpy( s->errorString, tor->errorString, sizeof( s->errorString ) );
s->manualAnnounceTime = tr_announcerNextManualAnnounce( tor );

View File

@ -2000,6 +2000,10 @@ typedef struct tr_stat
/** The position of this torrent in the download queue.
This will be >= 0 if the torrent is queued; -1 otherwise. */
int queuePosition;
/** True if the torrent is running, but has been idle for long enough
to be considered stalled. @see tr_sessionGetQueueStalledMinutes() */
bool isStalled;
}
tr_stat;

View File

@ -178,6 +178,8 @@ TorrentDelegate :: shortTransferString( const Torrent& tor ) const
str = tr( "%1 %2" ).arg(downArrow).arg(downStr);
else if( haveUp )
str = tr( "%1 %2" ).arg(upArrow).arg(upStr);
else if( tor.isStalled( ) )
str = tr( "Stalled" );
else if( tor.hasMetadata( ) )
str = tr( "Idle" );

View File

@ -102,13 +102,14 @@ Torrent :: myProperties[] =
{ HASH_STRING, "hashString", QVariant::String, INFO },
{ IS_FINISHED, "isFinished", QVariant::Bool, STAT },
{ IS_PRIVATE, "isPrivate", QVariant::Bool, INFO },
{ IS_STALLED, "isStalled", QVariant::Bool, STAT },
{ COMMENT, "comment", QVariant::String, INFO },
{ CREATOR, "creator", QVariant::String, INFO },
{ MANUAL_ANNOUNCE_TIME, "manualAnnounceTime", QVariant::DateTime, STAT_EXTRA },
{ PEERS, "peers", TrTypes::PeerList, STAT_EXTRA },
{ TORRENT_FILE, "torrentFile", QVariant::String, STAT_EXTRA },
{ BANDWIDTH_PRIORITY, "bandwidthPriority", QVariant::Int, STAT_EXTRA },
{ QUEUE_POSITION, "queuePosition", QVariant::Int, STAT }
{ QUEUE_POSITION, "queuePosition", QVariant::Int, STAT },
};
Torrent :: KeyList

View File

@ -166,6 +166,7 @@ class Torrent: public QObject
HASH_STRING,
IS_FINISHED,
IS_PRIVATE,
IS_STALLED,
COMMENT,
CREATOR,
MANUAL_ANNOUNCE_TIME,
@ -308,6 +309,7 @@ class Torrent: public QObject
const FileList& files( ) const { return myFiles; }
int queuePosition( ) const { return getInt( QUEUE_POSITION ); }
bool isQueued( ) const { return queuePosition( ) >= 0; }
bool isStalled( ) const { return getBool( IS_STALLED ); }
public:
QString activityString( ) const;