static gboolean updateStats( gpointer gdata ) { const char * fmt; char buf[128]; struct stat_ui * ui = gdata; tr_session_stats one, all; tr_sessionGetStats( tr_core_session( ui->core ), &one ); tr_sessionGetCumulativeStats( tr_core_session( ui->core ), &all ); setLabel( ui->one_up_lb, tr_strlsize( buf, one.uploadedBytes, sizeof( buf ) ) ); setLabel( ui->one_down_lb, tr_strlsize( buf, one.downloadedBytes, sizeof( buf ) ) ); setLabel( ui->one_time_lb, tr_strltime( buf, one.secondsActive, sizeof( buf ) ) ); setLabelFromRatio( ui->one_ratio_lb, one.ratio ); fmt = ngettext( "Started %'d time", "Started %'d times", (int)all.sessionCount ); g_snprintf( buf, sizeof( buf ), fmt, (int)all.sessionCount ); setLabel( ui->all_sessions_lb, buf ); setLabel( ui->all_up_lb, tr_strlsize( buf, all.uploadedBytes, sizeof( buf ) ) ); setLabel( ui->all_down_lb, tr_strlsize( buf, all.downloadedBytes, sizeof( buf ) ) ); setLabel( ui->all_time_lb, tr_strltime( buf, all.secondsActive, sizeof( buf ) ) ); setLabelFromRatio( ui->all_ratio_lb, all.ratio ); return TRUE; }
void tr_sessionGetCumulativeStats(tr_session const* session, tr_session_stats* setme) { struct tr_stats_handle const* stats = getStats(session); tr_session_stats current = TR_SESSION_STATS_INIT; if (stats != NULL) { tr_sessionGetStats(session, ¤t); addStats(setme, &stats->old, ¤t); } }
void tr_sessionGetCumulativeStats (const tr_session * session, tr_session_stats * setme) { const struct tr_stats_handle * stats = getStats (session); tr_session_stats current = STATS_INIT; if (stats) { tr_sessionGetStats (session, ¤t); addStats (setme, &stats->old, ¤t); } }