Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
void tr_statsSaveDirty(tr_session* session)
{
    struct tr_stats_handle* h = getStats(session);

    if (h != NULL && h->isDirty)
    {
        tr_session_stats cumulative = TR_SESSION_STATS_INIT;
        tr_sessionGetCumulativeStats(session, &cumulative);
        saveCumulativeStats(session, &cumulative);
        h->isDirty = false;
    }
}
Ejemplo n.º 3
0
void
tr_statsSaveDirty( tr_session * session )
{
    struct tr_stats_handle * h = getStats( session );
    if( ( h != NULL ) && h->isDirty )
    {
        tr_session_stats cumulative = STATS_INIT;
        tr_sessionGetCumulativeStats( session, &cumulative );
        saveCumulativeStats( session, &cumulative );
        h->isDirty = FALSE;
    }
}