mirror of
https://github.com/transmission/transmission.git
synced 2026-04-02 00:27:38 +01:00
modify the tr_stat struct as hashed out by charles_ and BentMyWookie. sync gtk, ipc, and wx clients.
This commit is contained in:
7
README
7
README
@@ -9,14 +9,15 @@ Transmission runs on Mac OS X (Cocoa interface),
|
||||
Linux/NetBSD/FreeBSD/OpenBSD (GTK+ interface)
|
||||
and BeOS (native interface).
|
||||
|
||||
For more information (including build instructions), please consult the
|
||||
website: http://transmission.m0k.org/
|
||||
For more information (including build instructions),
|
||||
please consult the website: http://transmission.m0k.org/
|
||||
|
||||
|
||||
Building Transmission
|
||||
=====================
|
||||
|
||||
Transmission has an Xcode project file (Transmission.xcodeproj) that allows it to be built in Xcode.
|
||||
Transmission has an Xcode project file (Transmission.xcodeproj)
|
||||
that allows it to be built in Xcode.
|
||||
|
||||
Building a Transmission release from the command line:
|
||||
|
||||
|
||||
@@ -813,6 +813,7 @@ static GtkWidget* info_page_new (tr_torrent * tor)
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget * state_lb;
|
||||
GtkWidget * corrupt_dl_lb;
|
||||
GtkWidget * valid_dl_lb;
|
||||
GtkWidget * dl_lb;
|
||||
GtkWidget * ul_lb;
|
||||
@@ -832,27 +833,29 @@ refresh_activity (GtkWidget * top)
|
||||
{
|
||||
Activity * a = (Activity*) g_object_get_data (G_OBJECT(top), "activity-data");
|
||||
const tr_stat * stat = tr_torrent_stat( a->gtor );
|
||||
guint64 size;
|
||||
char *pch;
|
||||
|
||||
pch = tr_torrent_status_str( a->gtor );
|
||||
gtk_label_set_text (GTK_LABEL(a->state_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
size = stat->downloadedValid;
|
||||
pch = readablesize (size);
|
||||
pch = readablesize (stat->corruptEver);
|
||||
gtk_label_set_text (GTK_LABEL(a->corrupt_dl_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
pch = readablesize (stat->haveValid);
|
||||
gtk_label_set_text (GTK_LABEL(a->valid_dl_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
pch = readablesize (stat->downloaded);
|
||||
pch = readablesize (stat->downloadedEver);
|
||||
gtk_label_set_text (GTK_LABEL(a->dl_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
pch = readablesize (stat->uploaded);
|
||||
pch = readablesize (stat->uploadedEver);
|
||||
gtk_label_set_text (GTK_LABEL(a->ul_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
pch = ratiostr (stat->downloaded, stat->uploaded);
|
||||
pch = ratiostr (stat->downloadedEver, stat->uploadedEver);
|
||||
gtk_label_set_text (GTK_LABEL(a->ratio_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
@@ -860,7 +863,7 @@ refresh_activity (GtkWidget * top)
|
||||
gtk_label_set_text (GTK_LABEL(a->swarm_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
pch = readablesize (stat->left);
|
||||
pch = readablesize (stat->leftUntilDone);
|
||||
gtk_label_set_text (GTK_LABEL(a->remaining_lb), pch);
|
||||
g_free (pch);
|
||||
|
||||
@@ -901,6 +904,10 @@ activity_page_new (TrTorrent * gtor)
|
||||
l = a->state_lb = gtk_label_new (NULL);
|
||||
hig_workarea_add_row (t, &row, name, l, NULL);
|
||||
|
||||
g_snprintf (name, sizeof(name), namefmt, _("Corrupt DL"));
|
||||
l = a->corrupt_dl_lb = gtk_label_new (NULL);
|
||||
hig_workarea_add_row (t, &row, name, l, NULL);
|
||||
|
||||
g_snprintf (name, sizeof(name), namefmt, _("Valid DL"));
|
||||
l = a->valid_dl_lb = gtk_label_new (NULL);
|
||||
hig_workarea_add_row (t, &row, name, l, NULL);
|
||||
|
||||
@@ -609,9 +609,9 @@ tr_core_update( TrCore * self )
|
||||
MC_LEECH, st->leechers,
|
||||
MC_DONE, st->completedFromTracker,
|
||||
MC_TRACKER, st->tracker,
|
||||
MC_DOWN, st->downloaded,
|
||||
MC_UP, st->uploaded,
|
||||
MC_LEFT, st->left,
|
||||
MC_DOWN, st->downloadedEver,
|
||||
MC_UP, st->uploadedEver,
|
||||
MC_LEFT, st->leftUntilDone,
|
||||
-1 );
|
||||
}
|
||||
while( gtk_tree_model_iter_next( self->model, &iter ) );
|
||||
|
||||
@@ -290,7 +290,7 @@ tr_cpGetStatus ( const tr_completion * cp )
|
||||
}
|
||||
|
||||
uint64_t
|
||||
tr_cpDownloadedValid( const tr_completion * cp )
|
||||
tr_cpHaveValid( const tr_completion * cp )
|
||||
{
|
||||
uint64_t b = 0;
|
||||
const tr_torrent * tor = cp->tor;
|
||||
@@ -308,3 +308,9 @@ tr_cpDownloadedValid( const tr_completion * cp )
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
tr_cpHaveTotal( const tr_completion * cp )
|
||||
{
|
||||
return cp->completeHave;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ void tr_cpReset( tr_completion * );
|
||||
/* General */
|
||||
|
||||
cp_status_t tr_cpGetStatus ( const tr_completion * );
|
||||
uint64_t tr_cpDownloadedValid( const tr_completion * );
|
||||
uint64_t tr_cpHaveTotal( const tr_completion * );
|
||||
uint64_t tr_cpHaveValid( const tr_completion * );
|
||||
uint64_t tr_cpLeftUntilComplete( const tr_completion * );
|
||||
uint64_t tr_cpLeftUntilDone( const tr_completion * );
|
||||
float tr_cpPercentComplete( const tr_completion * );
|
||||
|
||||
@@ -767,16 +767,14 @@ ipc_addstat( benc_val_t * list, int tor,
|
||||
switch( 1 << ii )
|
||||
{
|
||||
case IPC_ST_COMPLETED:
|
||||
tr_bencInitInt( item, st->downloadedValid );
|
||||
case IPC_ST_DOWNVALID:
|
||||
tr_bencInitInt( item, st->haveValid );
|
||||
break;
|
||||
case IPC_ST_DOWNSPEED:
|
||||
tr_bencInitInt( item, st->rateDownload * 1024 );
|
||||
break;
|
||||
case IPC_ST_DOWNTOTAL:
|
||||
tr_bencInitInt( item, st->downloaded );
|
||||
break;
|
||||
case IPC_ST_DOWNVALID:
|
||||
tr_bencInitInt( item, st->downloadedValid );
|
||||
tr_bencInitInt( item, st->downloadedEver );
|
||||
break;
|
||||
case IPC_ST_ERROR:
|
||||
error = st->error;
|
||||
@@ -921,7 +919,7 @@ ipc_addstat( benc_val_t * list, int tor,
|
||||
tr_bencInitInt( item, st->rateUpload * 1024 );
|
||||
break;
|
||||
case IPC_ST_UPTOTAL:
|
||||
tr_bencInitInt( item, st->uploaded );
|
||||
tr_bencInitInt( item, st->uploadedEver );
|
||||
break;
|
||||
default:
|
||||
assert( 0 );
|
||||
|
||||
@@ -30,10 +30,10 @@ typedef struct tr_peer
|
||||
unsigned int peerSupportsEncryption : 1;
|
||||
unsigned int doDisconnect : 1;
|
||||
|
||||
struct in_addr in_addr;
|
||||
uint16_t port;
|
||||
struct tr_peerIo * io;
|
||||
uint8_t from;
|
||||
uint16_t port;
|
||||
struct in_addr in_addr;
|
||||
struct tr_peerIo * io;
|
||||
|
||||
struct tr_bitfield * banned;
|
||||
struct tr_bitfield * blame;
|
||||
@@ -45,7 +45,6 @@ typedef struct tr_peer
|
||||
|
||||
time_t clientSentPieceDataAt;
|
||||
time_t peerSentPieceDataAt;
|
||||
time_t peerSentKeepaliveAt;
|
||||
time_t chokeChangedAt;
|
||||
time_t connectionChangedAt;
|
||||
|
||||
|
||||
@@ -620,14 +620,15 @@ readBtLength( tr_peermsgs * msgs, struct evbuffer * inbuf )
|
||||
|
||||
tr_peerIoReadUint32( msgs->io, inbuf, &len );
|
||||
|
||||
if( len == 0 ) { /* peer sent us a keepalive message */
|
||||
if( len == 0 ) /* peer sent us a keepalive message */
|
||||
dbgmsg( msgs, "peer sent us a keepalive message..." );
|
||||
msgs->info->peerSentKeepaliveAt = time( NULL );
|
||||
} else {
|
||||
else {
|
||||
dbgmsg( msgs, "peer is sending us a message with %"PRIu64" bytes...\n", (uint64_t)len );
|
||||
msgs->incomingMessageLength = len;
|
||||
msgs->state = AWAITING_BT_MESSAGE;
|
||||
} return READ_AGAIN;
|
||||
}
|
||||
|
||||
return READ_AGAIN;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -760,7 +760,7 @@ tr_torrentStat( tr_torrent * tor )
|
||||
s->percentComplete = tr_cpPercentComplete ( tor->completion );
|
||||
|
||||
s->percentDone = tr_cpPercentDone( tor->completion );
|
||||
s->left = tr_cpLeftUntilDone( tor->completion );
|
||||
s->leftUntilDone = tr_cpLeftUntilDone( tor->completion );
|
||||
|
||||
switch( tor->runStatus ) {
|
||||
case TR_RUN_CHECKING_WAIT: s->status = TR_STATUS_CHECK_WAIT; break;
|
||||
@@ -801,16 +801,16 @@ tr_torrentStat( tr_torrent * tor )
|
||||
|
||||
s->eta = s->rateDownload < 0.1
|
||||
? -1.0f
|
||||
: (s->left / s->rateDownload / 1024.0);
|
||||
: (s->leftUntilDone / s->rateDownload / 1024.0);
|
||||
|
||||
s->corrupt = tor->corruptCur + tor->corruptPrev;
|
||||
s->uploaded = tor->uploadedCur + tor->uploadedPrev;
|
||||
s->downloaded = tor->downloadedCur + tor->downloadedPrev;
|
||||
s->downloadedValid = tr_cpDownloadedValid( tor->completion );
|
||||
s->corruptEver = tor->corruptCur + tor->corruptPrev;
|
||||
s->downloadedEver = tor->downloadedCur + tor->downloadedPrev;
|
||||
s->uploadedEver = tor->uploadedCur + tor->uploadedPrev;
|
||||
s->haveValid = tr_cpHaveValid( tor->completion );
|
||||
s->haveUnchecked = tr_cpHaveTotal( tor->completion ) - s->haveValid;
|
||||
|
||||
s->ratio = s->downloaded || s->downloadedValid
|
||||
? (float)s->uploaded / (float)MAX(s->downloaded, s->downloadedValid)
|
||||
: TR_RATIO_NA;
|
||||
s->ratio = s->downloadedEver ? s->uploadedEver / (float)s->downloadedEver
|
||||
: TR_RATIO_NA;
|
||||
|
||||
tr_torrentUnlock( tor );
|
||||
|
||||
|
||||
@@ -62,11 +62,14 @@ extern "C" {
|
||||
|
||||
#define TR_DEFAULT_PORT 9090
|
||||
|
||||
#define TR_PEER_FROM__MAX 4
|
||||
#define TR_PEER_FROM_INCOMING 0 /* connections made to the listening port */
|
||||
#define TR_PEER_FROM_TRACKER 1 /* peers received from a tracker */
|
||||
#define TR_PEER_FROM_CACHE 2 /* peers read from the peer cache */
|
||||
#define TR_PEER_FROM_PEX 3 /* peers discovered via PEX */
|
||||
enum
|
||||
{
|
||||
TR_PEER_FROM_INCOMING = 0, /* connections made to the listening port */
|
||||
TR_PEER_FROM_TRACKER = 1, /* peers received from a tracker */
|
||||
TR_PEER_FROM_CACHE = 2, /* peers read from the peer cache */
|
||||
TR_PEER_FROM_PEX = 3, /* peers discovered via PEX */
|
||||
TR_PEER_FROM__MAX
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* Error codes
|
||||
@@ -644,11 +647,31 @@ struct tr_stat
|
||||
int leechers;
|
||||
int completedFromTracker;
|
||||
|
||||
uint64_t left;
|
||||
uint64_t downloaded;
|
||||
uint64_t downloadedValid;
|
||||
uint64_t uploaded;
|
||||
uint64_t corrupt;
|
||||
/* Byte count of how much data is left to be downloaded until
|
||||
* we're done -- that is, until we've got all the pieces we wanted. */
|
||||
uint64_t leftUntilDone;
|
||||
|
||||
/* Byte count of all the corrupt data you've ever downloaded for
|
||||
* this torrent. If you're on a poisoned torrent, this number can
|
||||
* grow very large. */
|
||||
uint64_t corruptEver;
|
||||
|
||||
/* Byte count of all data you've ever uploaded for this torrent. */
|
||||
uint64_t uploadedEver;
|
||||
|
||||
/* Byte count of all the non-corrupt data you've ever downloaded
|
||||
* for this torrent. If you deleted the files and downloaded a second time,
|
||||
* this will be 2*totalSize.. */
|
||||
uint64_t downloadedEver;
|
||||
|
||||
/* Byte count of all the checksum-verified data we have for this torrent. */
|
||||
uint64_t haveValid;
|
||||
|
||||
/* Byte count of all the partial piece data we have for this torrent.
|
||||
* As pieces become complete, this value may decrease as portions of it are
|
||||
* moved to `corrupt' or `haveValid'. */
|
||||
uint64_t haveUnchecked;
|
||||
|
||||
float swarmspeed;
|
||||
|
||||
#define TR_RATIO_NA -1
|
||||
|
||||
@@ -49,7 +49,7 @@ TorrentFilter :: GetFlags( const tr_torrent * tor )
|
||||
? FLAG_ACTIVE
|
||||
: FLAG_IDLE;
|
||||
|
||||
flags |= s->left
|
||||
flags |= s->leftUntilDone
|
||||
? FLAG_INCOMPLETE
|
||||
: FLAG_COMPLETE;
|
||||
|
||||
|
||||
@@ -274,15 +274,15 @@ TorrentListCtrl :: RefreshTorrent( tr_torrent * tor,
|
||||
break;
|
||||
|
||||
case COL_RATIO:
|
||||
xstr = wxString::Format( _T("%%%d"), (int)(s->uploaded / (double)s->downloadedValid) );
|
||||
xstr = wxString::Format( _T("%%%d"), (int)(s->uploadedEver / (double)s->downloadedEver) );
|
||||
break;
|
||||
|
||||
case COL_RECEIVED:
|
||||
xstr = getReadableSize( s->downloaded );
|
||||
xstr = getReadableSize( s->downloadedEver );
|
||||
break;
|
||||
|
||||
case COL_REMAINING:
|
||||
xstr = getReadableSize( s->left );
|
||||
xstr = getReadableSize( s->leftUntilDone );
|
||||
break;
|
||||
|
||||
case COL_SEEDS:
|
||||
@@ -293,7 +293,7 @@ TorrentListCtrl :: RefreshTorrent( tr_torrent * tor,
|
||||
break;
|
||||
|
||||
case COL_SENT:
|
||||
xstr = getReadableSize( s->uploaded );
|
||||
xstr = getReadableSize( s->uploadedEver );
|
||||
break;
|
||||
|
||||
case COL_SIZE:
|
||||
@@ -447,8 +447,8 @@ TorrentListCtrl :: Compare( long item1, long item2, long sortData )
|
||||
break;
|
||||
|
||||
case COL_RATIO: {
|
||||
const double ra = sa->uploaded / (double) sa->downloadedValid;
|
||||
const double rb = sb->uploaded / (double) sb->downloadedValid;
|
||||
const double ra = sa->uploadedEver / (double)(sa->downloadedEver + 0.01);
|
||||
const double rb = sb->uploadedEver / (double)(sb->downloadedEver + 0.01);
|
||||
if( ra < rb )
|
||||
ret = -1;
|
||||
else if( ra > rb )
|
||||
@@ -459,18 +459,18 @@ TorrentListCtrl :: Compare( long item1, long item2, long sortData )
|
||||
}
|
||||
|
||||
case COL_RECEIVED:
|
||||
if( sa->downloaded < sb->downloaded )
|
||||
if( sa->downloadedEver < sb->downloadedEver )
|
||||
ret = -1;
|
||||
else if( sa->downloaded > sb->downloaded )
|
||||
else if( sa->downloadedEver > sb->downloadedEver )
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
case COL_REMAINING:
|
||||
if( sa->left < sb->left )
|
||||
if( sa->leftUntilDone < sb->leftUntilDone )
|
||||
ret = -1;
|
||||
else if( sa->left > sb->left )
|
||||
else if( sa->leftUntilDone > sb->leftUntilDone )
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
@@ -482,9 +482,9 @@ TorrentListCtrl :: Compare( long item1, long item2, long sortData )
|
||||
break;
|
||||
|
||||
case COL_SENT:
|
||||
if( sa->uploaded < sb->uploaded )
|
||||
if( sa->uploadedEver < sb->uploadedEver )
|
||||
ret = -1;
|
||||
else if( sa->uploaded > sb->uploaded )
|
||||
else if( sa->uploadedEver > sb->uploadedEver )
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
Reference in New Issue
Block a user