static char* getShortTransferString (const tr_torrent * tor, const tr_stat * st, double uploadSpeed_KBps, double downloadSpeed_KBps, char * buf, size_t buflen) { const int haveMeta = tr_torrentHasMetadata (tor); const int haveUp = haveMeta && st->peersGettingFromUs > 0; const int haveDown = haveMeta && ((st->peersSendingToUs > 0) || (st->webseedsSendingToUs > 0)); if (haveDown) { char dnStr[32], upStr[32]; tr_formatter_speed_KBps (dnStr, downloadSpeed_KBps, sizeof (dnStr)); tr_formatter_speed_KBps (upStr, uploadSpeed_KBps, sizeof (upStr)); /* down speed, down symbol, up speed, up symbol */ g_snprintf (buf, buflen, _("%1$s %2$s %3$s %4$s"), dnStr, gtr_get_unicode_string (GTR_UNICODE_DOWN), upStr, gtr_get_unicode_string (GTR_UNICODE_UP)); } else if (haveUp) { char upStr[32]; tr_formatter_speed_KBps (upStr, uploadSpeed_KBps, sizeof (upStr)); /* up speed, up symbol */ g_snprintf (buf, buflen, _("%1$s %2$s"), upStr, gtr_get_unicode_string (GTR_UNICODE_UP)); } else if (st->isStalled) { g_strlcpy (buf, _("Stalled"), buflen); } else { *buf = '\0'; } return buf; }
static char* getShortTransferString( const tr_torrent * tor, const tr_stat * st, double uploadSpeed_KBps, double downloadSpeed_KBps, char * buf, size_t buflen ) { char downStr[32], upStr[32]; const int haveMeta = tr_torrentHasMetadata( tor ); const int haveUp = haveMeta && st->peersGettingFromUs > 0; const int haveDown = haveMeta && ( ( st->peersSendingToUs > 0 ) || ( st->webseedsSendingToUs > 0 ) ); if( haveDown ) tr_formatter_speed_KBps( downStr, downloadSpeed_KBps, sizeof( downStr ) ); if( haveUp ) tr_formatter_speed_KBps( upStr, uploadSpeed_KBps, sizeof( upStr ) ); if( haveDown && haveUp ) /* 1==down arrow, 2==down speed, 3==up arrow, 4==down speed */ g_snprintf( buf, buflen, _( "%1$s %2$s, %3$s %4$s" ), gtr_get_unicode_string( GTR_UNICODE_DOWN ), downStr, gtr_get_unicode_string( GTR_UNICODE_UP ), upStr ); else if( haveDown ) /* bandwidth speed + unicode arrow */ g_snprintf( buf, buflen, _( "%1$s %2$s" ), gtr_get_unicode_string( GTR_UNICODE_DOWN ), downStr ); else if( haveUp ) /* 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 ) g_strlcpy( buf, _( "Idle" ), buflen ); else *buf = '\0'; return buf; }
static char* getShortTransferString( const tr_torrent * tor, const tr_stat * torStat, double uploadSpeed, double downloadSpeed, char * buf, size_t buflen ) { char downStr[32], upStr[32]; const int haveMeta = tr_torrentHasMetadata( tor ); const int haveDown = haveMeta && torStat->peersSendingToUs > 0; const int haveUp = haveMeta && torStat->peersGettingFromUs > 0; if( haveDown ) tr_strlspeed( downStr, downloadSpeed, sizeof( downStr ) ); if( haveUp ) tr_strlspeed( upStr, uploadSpeed, sizeof( upStr ) ); if( haveDown && haveUp ) /* 1==down speed, 2==down arrow, 3==up speed, 4==down arrow */ g_snprintf( buf, buflen, _( "%1$s %2$s, %3$s %4$s" ), gtr_get_unicode_string( GTR_UNICODE_DOWN ), downStr, gtr_get_unicode_string( GTR_UNICODE_UP ), upStr ); else if( haveDown ) /* bandwidth speed + unicode arrow */ g_snprintf( buf, buflen, _( "%1$s %2$s" ), gtr_get_unicode_string( GTR_UNICODE_DOWN ), downStr ); else if( haveUp ) /* bandwidth speed + unicode arrow */ g_snprintf( buf, buflen, _( "%1$s %2$s" ), gtr_get_unicode_string( GTR_UNICODE_UP ), upStr ); else if( tr_torrentHasMetadata( tor ) ) /* the torrent isn't uploading or downloading */ g_strlcpy( buf, _( "Idle" ), buflen ); else *buf = '\0'; return buf; }
char* tr_strlratio (char * buf, double ratio, size_t buflen) { return tr_strratio (buf, buflen, ratio, gtr_get_unicode_string (GTR_UNICODE_INF)); }