Changeset 3899


Ignore:
Timestamp:
Nov 20, 2007, 3:01:59 AM (15 years ago)
Author:
charles
Message:

finish backport the speed/stability improvements from trunk to 0.9x.
sync some text strings in the gtk+ client up with the mac client.

Location:
branches/0.9x
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9x/daemon/client.c

    r3175 r3899  
    492492
    493493    req->str = dircpy;
     494
     495    return 0;
     496}
     497
     498int
     499client_crypto( const char * mode )
     500{
     501    struct req * req;
     502    char       * modecpy;
     503
     504    modecpy = strdup( mode );
     505    if( NULL == modecpy )
     506    {
     507        mallocmsg( strlen( mode ) );
     508        return -1;
     509    }
     510
     511    req = addreq( IPC_MSG_CRYPTO, -1, NULL );
     512    if( NULL == req )
     513    {
     514        free( modecpy );
     515        return -1;
     516    }
     517
     518    req->str = modecpy;
    494519
    495520    return 0;
     
    801826                buf = ipc_mkint( con->ipc, &buflen, req->id, -1, req->num );
    802827                break;
     828            case IPC_MSG_CRYPTO:
    803829            case IPC_MSG_DIR:
    804830                buf = ipc_mkstr( con->ipc, &buflen, req->id, -1, req->str );
  • branches/0.9x/daemon/client.h

    r1708 r3899  
    6565int  client_uplimit  ( int );
    6666int  client_dir      ( const char * );
     67int  client_crypto   ( const char * );
    6768int  client_start    ( size_t, const int * );
    6869int  client_stop     ( size_t, const int * );
  • branches/0.9x/daemon/remote.c

    r3401 r3899  
    7373    char              dir[MAXPATHLEN];
    7474    int               pex;
     75    const char *      crypto;
    7576};
    7677
     
    175176        ( '\0' != o.dir[0]          &&   0 > client_dir      ( o.dir     ) ) ||
    176177        ( !SLIST_EMPTY( &o.files )  &&   0 > client_addfiles ( &o.files  ) ) ||
     178        ( o.crypto                  &&   0 > client_crypto   ( o.crypto  ) ) ||
    177179        ( o.startall                &&   0 > client_start    ( 0, NULL   ) ) ||
    178180        ( o.stopall                 &&   0 > client_stop     ( 0, NULL   ) ) ||
     
    230232  "\n"
    231233  "  -a --add <torrent>        Add a torrent\n"
     234  "  -c --encryption preferred Prefer peers to use encryption\n"
     235  "  -c --encryption required  Require encryption for all peers\n"
    232236  "  -d --download-limit <int> Max download rate in KiB/s\n"
    233237  "  -D --download-unlimited   No download rate limit\n"
     
    261265readargs( int argc, char ** argv, struct opts * opts )
    262266{
    263     char optstr[] = "a:d:DeEf:hilmMp:qr:s:S:t:u:Ux";
     267    char optstr[] = "a:c:d:DeEf:hilmMp:qr:s:S:t:u:Ux";
    264268    struct option longopts[] =
    265269    {
    266270        { "add",                required_argument, NULL, 'a' },
     271        { "encryption",         required_argument, NULL, 'c' },
    267272        { "download-limit",     required_argument, NULL, 'd' },
    268273        { "download-unlimited", no_argument,       NULL, 'D' },
     
    307312                    return -1;
    308313                }
     314                break;
     315            case 'c':
     316                if(!strcasecmp(optarg, "preferred"))
     317                    opts->crypto = "preferred";
     318                else if(!strcasecmp(optarg, "required"))
     319                    opts->crypto = "required";
     320                else
     321                    usage("invalid encryption mode: %s", optarg);
    309322                break;
    310323            case 'd':
  • branches/0.9x/daemon/server.c

    r3579 r3899  
    105105        0 > ipc_addmsg( gl_tree, IPC_MSG_AUTOMAP,      intmsg  ) ||
    106106        0 > ipc_addmsg( gl_tree, IPC_MSG_AUTOSTART,    intmsg  ) ||
     107        0 > ipc_addmsg( gl_tree, IPC_MSG_CRYPTO,       strmsg  ) ||
    107108        0 > ipc_addmsg( gl_tree, IPC_MSG_DOWNLIMIT,    intmsg  ) ||
    108109        0 > ipc_addmsg( gl_tree, IPC_MSG_DIR,          strmsg  ) ||
    109110        0 > ipc_addmsg( gl_tree, IPC_MSG_GETAUTOMAP,   prefmsg ) ||
    110111        0 > ipc_addmsg( gl_tree, IPC_MSG_GETAUTOSTART, prefmsg ) ||
     112        0 > ipc_addmsg( gl_tree, IPC_MSG_GETCRYPTO,    prefmsg ) ||
    111113        0 > ipc_addmsg( gl_tree, IPC_MSG_GETDOWNLIMIT, prefmsg ) ||
    112114        0 > ipc_addmsg( gl_tree, IPC_MSG_GETDIR,       prefmsg ) ||
     
    636638    switch( id )
    637639    {
     640        case IPC_MSG_CRYPTO:
     641            if(!strcasecmp(val->val.s.s, "preferred"))
     642                torrent_set_encryption(TR_ENCRYPTION_PREFERRED);
     643            else if(!strcasecmp(val->val.s.s, "required"))
     644                torrent_set_encryption(TR_ENCRYPTION_REQUIRED);
     645            else
     646            {
     647                msgresp(client, tag, IPC_MSG_BAD);
     648                return;
     649            }
     650            break;
    638651        case IPC_MSG_DIR:
    639652            torrent_set_directory( val->val.s.s );
     
    903916    uint8_t       * buf;
    904917    size_t          buflen;
     918    const char    * strval;
    905919
    906920    switch( id )
     
    913927            buf = ipc_mkint( client->ipc, &buflen, IPC_MSG_AUTOSTART, tag,
    914928                             torrent_get_autostart() );
     929            break;
     930        case IPC_MSG_GETCRYPTO:
     931            switch(torrent_get_encryption())
     932            {
     933                case TR_ENCRYPTION_PREFERRED:
     934                    strval = "preferred";
     935                    break;
     936                case TR_ENCRYPTION_REQUIRED:
     937                    strval = "required";
     938                    break;
     939                default:
     940                    assert(0);
     941                    return;
     942            }
     943            buf = ipc_mkstr(client->ipc, &buflen, IPC_MSG_CRYPTO, tag, strval);
    915944            break;
    916945        case IPC_MSG_GETDIR:
  • branches/0.9x/daemon/torrents.c

    r3579 r3899  
    9898static int                 gl_downlimit = -1;
    9999static char                gl_dir[MAXPATHLEN];
     100static tr_encryption_mode  gl_crypto    = TR_ENCRYPTION_PREFERRED;
    100101
    101102RB_GENERATE_STATIC( tortree, tor, idlinks, toridcmp )
     
    466467{
    467468    return gl_dir;
     469}
     470
     471void
     472torrent_set_encryption(tr_encryption_mode mode)
     473{
     474    tr_setEncryptionMode(gl_handle, mode);
     475    gl_crypto = mode;
     476    savestate();
     477}
     478
     479tr_encryption_mode
     480torrent_get_encryption(void)
     481{
     482    return tr_getEncryptionMode(gl_handle);
    468483}
    469484
     
    738753    }
    739754
     755    str = tr_bencDictFind( &top, "encryption-mode" );
     756    if( NULL != str && TYPE_STR == str->type )
     757    {
     758        if(!strcasecmp(str->val.s.s, "preferred"))
     759            gl_crypto = TR_ENCRYPTION_PREFERRED;
     760        else if(!strcasecmp(str->val.s.s, "required"))
     761            gl_crypto = TR_ENCRYPTION_REQUIRED;
     762    }
     763
     764    tr_setEncryptionMode(gl_handle, gl_crypto);
     765
    740766    list = tr_bencDictFind( &top, "torrents" );
    741767    if( NULL == list || TYPE_LIST != list->type )
     
    795821
    796822    tr_bencInit( &top, TYPE_DICT );
    797     if( tr_bencDictReserve( &top, 8 ) )
     823    if( tr_bencDictReserve( &top, 9 ) )
    798824    {
    799825      nomem:
     
    810836    tr_bencInitStr( tr_bencDictAdd( &top, "default-directory" ),
    811837                    gl_dir, -1, 1 );
     838    if(TR_ENCRYPTION_REQUIRED == gl_crypto)
     839        tr_bencInitStr(tr_bencDictAdd(&top, "encryption-mode"), "required", -1, 1);
     840    else
     841        tr_bencInitStr(tr_bencDictAdd(&top, "encryption-mode"), "preferred", -1, 1);
    812842    list = tr_bencDictAdd( &top, "torrents" );
    813843    tr_bencInit( list, TYPE_LIST );
     
    849879    }
    850880
    851     buf = ( uint8_t * )tr_bencSaveMalloc( &top, &len );
     881    buf = ( uint8_t * )tr_bencSave( &top, &len );
    852882    SAFEBENCFREE( &top );
    853883    if( NULL == buf )
  • branches/0.9x/daemon/torrents.h

    r3111 r3899  
    5858void         torrent_set_directory       ( const char * );
    5959const char * torrent_get_directory       ( void );
     60void         torrent_set_encryption      ( tr_encryption_mode );
     61tr_encryption_mode torrent_get_encryption      ( void );
    6062
    6163#endif /* TR_DAEMON_TORRENTS_H */
  • branches/0.9x/gtk/actions.c

    r3392 r3899  
    5858  { "toggle-main-window", NULL,
    5959    N_("Show _Main Window"), NULL, NULL, G_CALLBACK(action_cb), TRUE },
    60   { "toggle-debug-window", NULL,
    61     N_("Show _Debug Window"), NULL, NULL, G_CALLBACK(action_cb), FALSE }
     60  { "toggle-message-log", NULL,
     61    N_("Show Message _Log"), NULL, NULL, G_CALLBACK(action_cb), FALSE }
    6262};
    6363
     
    7272    N_("_Start"), "<control>S", NULL, G_CALLBACK(action_cb) },
    7373  { "verify-torrent", NULL,
    74     N_("_Verify Local Files"), NULL, NULL, G_CALLBACK(action_cb) },
     74    N_("_Verify Local Data"), NULL, NULL, G_CALLBACK(action_cb) },
    7575  { "pause-torrent", GTK_STOCK_MEDIA_PAUSE,
    7676    N_("_Pause"), "<control>P", NULL, G_CALLBACK(action_cb) },
  • branches/0.9x/gtk/main.c

    r3586 r3899  
    111111};
    112112
    113 struct exitdata {
    114     struct cbdata * cbdata;
    115     time_t          started;
    116     guint           timer;
    117 };
    118 
    119 #define CBDATA_PTR              "callback-data-pointer"
     113#define CBDATA_PTR "callback-data-pointer"
    120114
    121115static GtkUIManager * myUIManager = NULL;
     
    134128static void
    135129wannaquit( void * vdata );
    136 static gboolean
    137 exitcheck(gpointer gdata);
    138130static void
    139131setupdrag(GtkWidget *widget, struct cbdata *data);
     
    256248
    257249    /* initialize gtk */
     250    g_thread_init( NULL );
    258251    gtk_init_with_args( &argc, &argv, _("[torrent files]"), entries, domain, NULL );
    259252    myUIManager = gtk_ui_manager_new ();
     
    413406}
    414407
     408static gpointer
     409quitThreadFunc( gpointer gdata )
     410{
     411    struct cbdata * cbdata = gdata;
     412
     413    tr_close( tr_core_handle( cbdata->core ) );
     414
     415    /* shutdown the gui */
     416    if( cbdata->prefs )
     417        gtk_widget_destroy( GTK_WIDGET( cbdata->prefs ) );
     418    if( cbdata->wind )
     419        gtk_widget_destroy( GTK_WIDGET( cbdata->wind ) );
     420    g_object_unref( cbdata->core );
     421    if( cbdata->icon )
     422        g_object_unref( cbdata->icon );
     423    if( cbdata->errqueue ) {
     424        g_list_foreach( cbdata->errqueue, (GFunc)g_free, NULL );
     425        g_list_free( cbdata->errqueue );
     426    }
     427    g_free( cbdata );
     428
     429    /* exit the gtk main loop */
     430    gtk_main_quit( );
     431    return NULL;
     432}
     433
    415434static void
    416435wannaquit( void * vdata )
    417436{
    418   struct cbdata * data;
    419   struct exitdata *edata;
    420 
    421   data = vdata;
    422   if( data->closing )
    423   {
    424       return;
    425   }
    426   data->closing = TRUE;
    427 
    428   /* stop the update timer */
    429   if(0 < data->timer)
    430     g_source_remove(data->timer);
    431   data->timer = 0;
    432 
    433   /* pause torrents and stop nat traversal */
    434   tr_core_shutdown( data->core );
    435 
    436   /* set things up to wait for torrents to stop */
    437   edata = g_new0(struct exitdata, 1);
    438   edata->cbdata = data;
    439   edata->started = time(NULL);
    440   /* check if torrents are still running */
    441   if(exitcheck(edata)) {
    442     /* yes, start the exit timer and disable widgets */
    443     edata->timer = g_timeout_add(EXIT_CHECK_INTERVAL, exitcheck, edata);
    444     if( NULL != data->wind )
    445     {
    446         gtk_widget_set_sensitive( GTK_WIDGET( data->wind ), FALSE );
    447     }
    448   }
    449 }
    450 
    451 static gboolean
    452 exitcheck( gpointer gdata )
    453 {
    454     struct exitdata    * edata;
    455     struct cbdata      * cbdata;
    456 
    457     edata  = gdata;
    458     cbdata = edata->cbdata;
    459 
    460     /* keep waiting until we're ready to quit or we hit the exit timeout */
    461     if( time( NULL ) - edata->started < TRACKER_EXIT_TIMEOUT )
    462     {
    463         if( !tr_core_quiescent( cbdata->core ) )
    464         {
    465             updatemodel( cbdata );
    466             return TRUE;
    467         }
    468     }
    469 
    470     /* exit otherwise */
    471     if( 0 < edata->timer )
    472     {
    473         g_source_remove( edata->timer );
    474     }
    475     g_free( edata );
    476     /* note that cbdata->prefs holds a reference to cbdata->core, and
    477        it's destruction may trigger callbacks that use cbdata->core */
    478     if( NULL != cbdata->prefs )
    479     {
    480         gtk_widget_destroy( GTK_WIDGET( cbdata->prefs ) );
    481     }
    482     if( NULL != cbdata->wind )
    483     {
    484         gtk_widget_destroy( GTK_WIDGET( cbdata->wind ) );
    485     }
    486     g_object_unref( cbdata->core );
    487     if( NULL != cbdata->icon )
    488     {
    489         g_object_unref( cbdata->icon );
    490     }
    491     g_assert( 0 == cbdata->timer );
    492     if( NULL != cbdata->errqueue )
    493     {
    494         g_list_foreach( cbdata->errqueue, (GFunc) g_free, NULL );
    495         g_list_free( cbdata->errqueue );
    496     }
    497     g_free( cbdata );
    498     gtk_main_quit();
    499 
    500     return FALSE;
     437    struct cbdata * cbdata = vdata;
     438
     439    /* stop the update timer */
     440    if( cbdata->timer ) {
     441        g_source_remove( cbdata->timer );
     442        cbdata->timer = 0;
     443    }
     444
     445    /* clear the UI */
     446    gtk_list_store_clear( GTK_LIST_STORE( tr_core_model( cbdata->core ) ) );
     447    gtk_widget_set_sensitive( GTK_WIDGET( cbdata->wind ), FALSE );
     448
     449    /* shut down libT */
     450    g_thread_create( quitThreadFunc, vdata, TRUE, NULL );
    501451}
    502452
     
    895845msgwinclosed()
    896846{
    897   action_toggle( "toggle-debug-window", FALSE );
     847  action_toggle( "toggle-message-log", FALSE );
    898848  return FALSE;
    899849}
     
    989939        }
    990940    }
    991     else if (!strcmp (action_name, "toggle-debug-window"))
     941    else if (!strcmp (action_name, "toggle-message-log"))
    992942    {
    993943        if( !data->msgwin )
     
    1000950        else
    1001951        {
    1002             action_toggle("toggle-debug-window", FALSE);
     952            action_toggle("toggle-message-log", FALSE);
    1003953            gtk_widget_destroy( data->msgwin );
    1004954            data->msgwin = NULL;
  • branches/0.9x/gtk/msgwin.c

    r3401 r3899  
    188188{
    189189  GtkWindow * window = GTK_WINDOW( gtk_widget_get_toplevel( w ) );
    190   GtkWidget * d = gtk_file_chooser_dialog_new( _("Save Debug Log"), window,
     190  GtkWidget * d = gtk_file_chooser_dialog_new( _("Save Log"), window,
    191191                                               GTK_FILE_CHOOSER_ACTION_SAVE,
    192192                                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
     
    230230
    231231  win = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    232   gtk_window_set_title( GTK_WINDOW( win ), _( "Debug Window" ) );
     232  gtk_window_set_title( GTK_WINDOW( win ), _( "Message Log" ) );
    233233  gtk_window_set_default_size( GTK_WINDOW( win ), 600, 400 );
    234   gtk_window_set_role( GTK_WINDOW( win ), "debug-window" );
     234  gtk_window_set_role( GTK_WINDOW( win ), "message-log" );
    235235  vbox = gtk_vbox_new( FALSE, 0 );
    236236
  • branches/0.9x/gtk/torrent-inspector.c

    r3470 r3899  
    3737#include "util.h"
    3838
    39 #define UPDATE_INTERVAL_MSEC 1500
     39#define UPDATE_INTERVAL_MSEC 2000
    4040
    4141/****
     
    240240  PEER_COL_IS_UPLOADING,
    241241  PEER_COL_UPLOAD_RATE,
     242  PEER_COL_STATUS,
    242243  N_PEER_COLS
    243244};
     
    253254  N_("DL Rate"),
    254255  N_("Uploading"),
    255   N_("UL Rate")
     256  N_("UL Rate"),
     257  N_("Status")
    256258};
    257259
     
    289291                      PEER_COL_IS_UPLOADING, peer->isUploading,
    290292                      PEER_COL_UPLOAD_RATE, peer->uploadToRate,
     293                      PEER_COL_STATUS, peer->status,
    291294                      -1);
    292295}
     
    317320                                         G_TYPE_FLOAT,   /* downloadFromRate */
    318321                                         G_TYPE_BOOLEAN, /* isUploading */
    319                                          G_TYPE_FLOAT);  /* uploadToRate */
     322                                         G_TYPE_FLOAT,   /* uploadToRate */
     323                                         G_TYPE_INT );   /* tr_peer_status */
    320324
    321325  int n_peers = 0;
     
    341345                          "stock-id", (is_encrypted ? "transmission-lock" : NULL),
    342346                          NULL);
     347}
     348
     349static void
     350render_status( GtkTreeViewColumn  * column UNUSED,
     351               GtkCellRenderer    * renderer,
     352               GtkTreeModel       * tree_model,
     353               GtkTreeIter        * iter,
     354               gpointer             data UNUSED )
     355{
     356    int status;
     357    const char * text;
     358    gtk_tree_model_get( tree_model, iter, PEER_COL_STATUS, &status, -1 );
     359    switch( status )
     360    {
     361        case TR_PEER_STATUS_HANDSHAKE:            text = _( "Handshaking" ); break;
     362        case TR_PEER_STATUS_PEER_IS_CHOKED:       text = _( "Peer is Choked" ); break;
     363        case TR_PEER_STATUS_CLIENT_IS_CHOKED:     text = _( "Choked" ); break;
     364        case TR_PEER_STATUS_CLIENT_IS_INTERESTED: text = _( "Choked & Interested" ); break;
     365        case TR_PEER_STATUS_READY:                text = _( "Ready" ); break;
     366        case TR_PEER_STATUS_REQUEST_SENT:         text = _( "Request Sent" ); break;
     367        case TR_PEER_STATUS_ACTIVE           :    text = _( "Active" ); break;
     368        case TR_PEER_STATUS_ACTIVE_AND_CHOKED:    text = _( "Active & Choked" ); break;
     369        default:                                  text = "BUG"; break;
     370    }
     371    g_object_set (renderer, "text", text, NULL);
    343372}
    344373
     
    478507  fmtpeercount (p->completed_lb, stat->completedFromTracker );
    479508
    480   free (peers);
     509  free( peers );
    481510}
    482511
     
    496525                         PEER_COL_IS_ENCRYPTED,
    497526                         PEER_COL_UPLOAD_RATE,
    498                          PEER_COL_DOWNLOAD_RATE };
     527                         PEER_COL_DOWNLOAD_RATE
     528#if 0
     529                         , PEER_COL_STATUS
     530#endif
     531                       };
    499532
    500533  m  = peer_model_new (tor);
     
    569602                                                 NULL, NULL);
    570603        break;
     604
     605      case PEER_COL_STATUS:
     606        r = gtk_cell_renderer_text_new( );
     607        c = gtk_tree_view_column_new_with_attributes (t, r, "text", col, NULL);
     608        gtk_tree_view_column_set_cell_data_func (c, r, render_status, NULL, NULL);
     609        break;
     610       
    571611
    572612      default:
     
    779819{
    780820  GtkWidget * state_lb;
    781   GtkWidget * corrupt_dl_lb;
    782   GtkWidget * valid_dl_lb;
     821  GtkWidget * progress_lb;
     822  GtkWidget * have_lb;
    783823  GtkWidget * dl_lb;
    784824  GtkWidget * ul_lb;
     825  GtkWidget * failed_lb;
    785826  GtkWidget * ratio_lb;
    786827  GtkWidget * err_lb;
    787   GtkWidget * remaining_lb;
    788828  GtkWidget * swarm_lb;
    789829  GtkWidget * date_added_lb;
     
    799839  Activity * a = (Activity*) g_object_get_data (G_OBJECT(top), "activity-data");
    800840  const tr_stat * stat = tr_torrent_stat( a->gtor );
    801   char *pch;
     841  char *pch, *pch2, *pch3;
    802842
    803843  pch = tr_torrent_status_str( a->gtor );
     
    805845  g_free (pch);
    806846
    807   pch = readablesize (stat->corruptEver);
    808   gtk_label_set_text (GTK_LABEL(a->corrupt_dl_lb), pch);
     847  pch = g_strdup_printf( "%.1f%% (%.1f%% selected)", stat->percentComplete*100.0, stat->percentDone*100.0 );
     848  gtk_label_set_text (GTK_LABEL(a->progress_lb), pch);
    809849  g_free (pch);
    810850
    811   pch = readablesize (stat->haveValid);
    812   gtk_label_set_text (GTK_LABEL(a->valid_dl_lb), pch);
    813   g_free (pch);
     851  pch = readablesize( stat->haveValid + stat->haveUnchecked );
     852  pch2 = readablesize( stat->haveValid );
     853  pch3 = g_strdup_printf( _("%s (%s verified)"), pch, pch2 );
     854  gtk_label_set_text( GTK_LABEL( a->have_lb ), pch3 );
     855  g_free( pch3 );
     856  g_free( pch2 );
     857  g_free( pch );
    814858
    815859  pch = readablesize (stat->downloadedEver);
     
    821865  g_free (pch);
    822866
    823   pch = ratiostr (stat->downloadedEver, stat->uploadedEver);
     867  pch = readablesize (stat->corruptEver);
     868  gtk_label_set_text (GTK_LABEL(a->failed_lb), pch);
     869  g_free (pch);
     870
     871  pch = g_strdup_printf( "%.1f", stat->ratio );
    824872  gtk_label_set_text (GTK_LABEL(a->ratio_lb), pch);
    825873  g_free (pch);
     
    827875  pch = readablespeed (stat->swarmspeed);
    828876  gtk_label_set_text (GTK_LABEL(a->swarm_lb), pch);
    829   g_free (pch);
    830 
    831   pch = readablesize (stat->leftUntilDone);
    832   gtk_label_set_text (GTK_LABEL(a->remaining_lb), pch);
    833877  g_free (pch);
    834878
     
    870914    hig_workarea_add_row (t, &row, name, l, NULL);
    871915
    872     g_snprintf (name, sizeof(name), namefmt, _("Corrupt DL"));
    873     l = a->corrupt_dl_lb = gtk_label_new (NULL);
     916    g_snprintf (name, sizeof(name), namefmt, _("Progress"));
     917    l = a->progress_lb = gtk_label_new (NULL);
    874918    hig_workarea_add_row (t, &row, name, l, NULL);
    875919
    876     g_snprintf (name, sizeof(name), namefmt, _("Valid DL"));
    877     l = a->valid_dl_lb = gtk_label_new (NULL);
     920    g_snprintf (name, sizeof(name), namefmt, _("Have") );
     921    l = a->have_lb = gtk_label_new (NULL);
    878922    hig_workarea_add_row (t, &row, name, l, NULL);
    879923
     
    886930    hig_workarea_add_row (t, &row, name, l, NULL);
    887931
     932    g_snprintf (name, sizeof(name), namefmt, _("Failed DL"));
     933    l = a->failed_lb = gtk_label_new (NULL);
     934    hig_workarea_add_row (t, &row, name, l, NULL);
     935
    888936    g_snprintf (name, sizeof(name), namefmt, _("Ratio"));
    889937    l = a->ratio_lb = gtk_label_new (NULL);
    890     hig_workarea_add_row (t, &row, name, l, NULL);
    891 
    892     g_snprintf (name, sizeof(name), namefmt, _("Remaining"));
    893     l = a->remaining_lb = gtk_label_new (NULL);
    894938    hig_workarea_add_row (t, &row, name, l, NULL);
    895939
  • branches/0.9x/gtk/tr_core.c

    r3573 r3899  
    123123    TrCore       * self = (TrCore *) obj;
    124124    GObjectClass * parent;
    125     GtkTreeIter    iter;
    126     TrTorrent    * tor;
    127125
    128126    if( self->disposed )
    129     {
    130127        return;
    131     }
     128
    132129    self->disposed = TRUE;
    133 
    134130    pref_save( NULL );
    135 
    136 #ifdef REFDBG
    137     fprintf( stderr, "core    %p dispose\n", self );
    138 #endif
    139 
    140     /* sever all remaining torrents in the model */
    141     if( gtk_tree_model_get_iter_first( self->model, &iter ) ) do
    142     {
    143         gtk_tree_model_get( self->model, &iter, MC_TORRENT, &tor, -1 );
    144         tr_torrent_sever( tor );
    145         g_object_unref( tor );
    146     }
    147     while( gtk_tree_model_iter_next( self->model, &iter ) );
    148     g_object_unref( self->model );
    149 
    150 #ifdef REFDBG
    151     fprintf( stderr, "core    %p dead\n", self );
    152 #endif
    153 
    154     /* close the libtransmission instance */
    155     tr_close( self->handle );
    156 
    157     /* Chain up to the parent class */
    158131    parent = g_type_class_peek( g_type_parent( TR_CORE_TYPE ) );
    159132    parent->dispose( obj );
     
    297270        /* leechers, completedFromTracker, downloaded,    uploaded */
    298271        G_TYPE_INT,  G_TYPE_INT,           G_TYPE_UINT64, G_TYPE_UINT64,
    299         /* left,       TrTorrent object, ID for IPC */
    300         G_TYPE_UINT64, TR_TORRENT_TYPE,  G_TYPE_INT,
     272        /* ratio,      left,          TrTorrent object, ID for IPC */
     273        G_TYPE_FLOAT,  G_TYPE_UINT64, TR_TORRENT_TYPE,  G_TYPE_INT,
    301274    };
    302275
     
    372345
    373346    return self->disposed ? NULL : self->handle;
    374 }
    375 
    376 void
    377 tr_core_shutdown( TrCore * self )
    378 {
    379     GtkTreeIter iter;
    380 
    381     TR_IS_CORE( self );
    382 
    383     if( self->disposed )
    384         return;
    385 
    386     g_assert( !self->quitting );
    387     self->quitting = TRUE;
    388 
    389     /* try to stop all the torrents nicely */
    390     if ( gtk_tree_model_get_iter_first( self->model, &iter) ) do {
    391         TrTorrent * tor;
    392         gtk_tree_model_get( self->model, &iter, MC_TORRENT, &tor, -1 );
    393         tr_torrent_sever( tor );
    394         g_object_unref( tor );
    395     } while( gtk_list_store_remove( GTK_LIST_STORE(self->model), &iter ) );
    396 
    397     /* shut down nat traversal */
    398     tr_natTraversalEnable( self->handle, 0 );
    399 }
    400 
    401 gboolean
    402 tr_core_quiescent( TrCore * self )
    403 {
    404     const tr_handle_status * hstat;
    405 
    406     TR_IS_CORE( self );
    407     g_assert( self->quitting );
    408 
    409     if( self->disposed )
    410         return TRUE;
    411 
    412     if ( tr_torrentCount( self->handle ) != 0 )
    413         return FALSE;
    414 
    415     hstat = tr_handleStatus( self->handle );
    416     return TR_NAT_TRAVERSAL_DISABLED == hstat->natTraversalStatus;
    417347}
    418348
     
    633563                            MC_DOWN,        st->downloadedEver,
    634564                            MC_UP,          st->uploadedEver,
     565                            MC_RATIO,       st->ratio,
    635566                            MC_LEFT,        st->leftUntilDone,
    636567                            -1 );
  • branches/0.9x/gtk/tr_core.h

    r3449 r3899  
    110110tr_core_handle( TrCore * self );
    111111
    112 /* Try to politely stop all torrents and nat traversal */
    113 void
    114 tr_core_shutdown( TrCore * self );
    115 
    116 /* Returns true if the shutdown has completed */
    117 gboolean
    118 tr_core_quiescent( TrCore * self );
    119 
    120112/* Load saved state, return number of torrents added. May trigger one
    121113   or more "error" signals with TR_CORE_ERR_ADD_TORRENT */
     
    190182  MC_PROG_C, MC_PROG_D, MC_DRATE, MC_URATE, MC_ETA, MC_PEERS,
    191183  MC_UPEERS, MC_DPEERS, MC_SEED, MC_LEECH, MC_DONE,
    192   MC_DOWN, MC_UP, MC_LEFT, MC_TORRENT, MC_ID,
     184  MC_DOWN, MC_UP, MC_RATIO, MC_LEFT, MC_TORRENT, MC_ID,
    193185  MC_ROW_COUNT
    194186};
  • branches/0.9x/gtk/tr_torrent.c

    r3605 r3899  
    300300        case TR_STATUS_CHECK_WAIT:
    301301            prog = st->recheckProgress * 100.0; /* [0...100] */
    302             top = g_strdup_printf( _("Waiting to verify local files (%.1f%% tested)"), prog );
     302            top = g_strdup_printf( _("Waiting to verify local data (%.1f%% tested)"), prog );
    303303            break;
    304304
    305305        case TR_STATUS_CHECK:
    306306            prog = st->recheckProgress * 100.0; /* [0...100] */
    307             top = g_strdup_printf( _("Verifying local files (%.1f%% tested)"), prog );
     307            top = g_strdup_printf( _("Verifying local data (%.1f%% tested)"), prog );
    308308            break;
    309309
  • branches/0.9x/gtk/tr_window.c

    r3449 r3899  
    120120{
    121121    char  * dlstr, * ulstr, * str, * marked;
    122     gfloat  prog, dl, ul;
     122    gfloat  prog, dl, ul, ratio;
    123123    guint64 down, up;
    124124
    125125    gtk_tree_model_get( model, iter, MC_PROG_D, &prog, MC_DRATE, &dl,
    126                         MC_URATE, &ul, MC_DOWN, &down, MC_UP, &up, -1 );
     126                        MC_URATE, &ul, MC_DOWN, &down, MC_UP, &up, MC_RATIO, &ratio, -1 );
    127127    prog = MAX( prog, 0.0 );
    128128    prog = MIN( prog, 1.0 );
     
    131131    if( 1.0 == prog )
    132132    {
    133         dlstr = ratiostr( down, up );
     133        dlstr = g_strdup_printf( "%.1f", ratio );
    134134        str = g_strdup_printf( _("Ratio: %s\nUL: %s"), dlstr, ulstr );
    135135    }
  • branches/0.9x/gtk/ui.h

    r3436 r3899  
    2323"    </menu>\n"
    2424"    <menu action='help-menu'>\n"
    25 "      <menuitem action='toggle-debug-window'/>\n"
     25"      <menuitem action='toggle-message-log'/>\n"
    2626"      <separator/>\n"
    2727"      <menuitem action='show-about-dialog'/>\n"
     
    5353"    <separator/>\n"
    5454"    <menuitem action='toggle-main-window'/>\n"
    55 "    <menuitem action='toggle-debug-window'/>\n"
     55"    <menuitem action='toggle-message-log'/>\n"
    5656"    <menuitem action='show-about-dialog'/>\n"
    5757"    <separator/>\n"
  • branches/0.9x/gtk/util.c

    r3647 r3899  
    122122}
    123123
    124 char *
    125 ratiostr(guint64 down, guint64 up) {
    126   double ratio;
    127 
    128   if(0 == up && 0 == down)
    129     return g_strdup(_("N/A"));
    130 
    131   if(0 == down)
    132     /* this is a UTF-8 infinity symbol */
    133     return g_strdup("\xE2\x88\x9E");
    134 
    135   ratio = (double)up / (double)down;
    136 
    137   return g_strdup_printf("%.*f", BESTDECIMAL(ratio), ratio);
    138 }
    139 
    140124gboolean
    141125mkdir_p(const char *name, mode_t mode)
  • branches/0.9x/gtk/util.h

    r3380 r3899  
    6363char *
    6464rfc822date (guint64 epoch_msec);
    65 
    66 /* returns a string representing the download ratio.
    67    the string must be g_free()d */
    68 char *
    69 ratiostr(guint64 down, guint64 up);
    7065
    7166/* create a directory and any missing parent directories */
  • branches/0.9x/libtransmission/crypto.c

    r3567 r3899  
    1111 */
    1212
     13#include <sys/types.h> /* for event.h, as well as netinet/in.h on some platforms */
    1314#include <assert.h>
    1415#include <inttypes.h> /* uint8_t */
    1516#include <string.h> /* memcpy */
    1617#include <stdarg.h>
    17 
    18 #include <sys/types.h> /* for event.h, as well as netinet/in.h on some platforms */
    1918#include <netinet/in.h> /* struct in_addr */
    2019
  • branches/0.9x/libtransmission/ratecontrol.c

    r3614 r3899  
    2323 *****************************************************************************/
    2424
    25 #include <string.h>
     25#include <string.h> /* memset */
    2626
    2727#include "transmission.h"
    2828#include "platform.h"
    2929#include "ratecontrol.h"
    30 #include "shared.h"
    3130#include "utils.h"
    3231
    3332#define GRANULARITY_MSEC 250
    34 #define SHORT_INTERVAL_MSEC 3000
    35 #define LONG_INTERVAL_MSEC 20000
     33#define SHORT_INTERVAL_MSEC 4000
     34#define LONG_INTERVAL_MSEC 8000
    3635#define HISTORY_SIZE (LONG_INTERVAL_MSEC / GRANULARITY_MSEC)
    3736
    38 typedef struct
     37struct tr_transfer
    3938{
    4039    uint64_t date;
    4140    uint64_t size;
    42 }
    43 tr_transfer_t;
     41};
    4442
    4543struct tr_ratecontrol
     
    4846    int limit;
    4947    int newest;
    50     tr_transfer_t transfers[HISTORY_SIZE];
     48    struct tr_transfer transfers[HISTORY_SIZE];
    5149};
    5250
     
    9795***/
    9896
    99 int
    100 tr_rcCanTransfer( const tr_ratecontrol * r )
    101 {
    102     int ret;
    103 
    104     if( r == NULL )
    105         ret = 0;
    106     else {
    107         tr_lockLock( (tr_lock*)r->lock );
    108         ret = rateForInterval( r, SHORT_INTERVAL_MSEC ) < r->limit;
    109         tr_lockUnlock( (tr_lock*)r->lock );
    110     }
    111 
    112     return ret;
    113 }
    114 
    11597size_t
    11698tr_rcBytesLeft( const tr_ratecontrol * r )
     
    120102    if( r != NULL )
    121103    {
    122         float cur, max;
    123         size_t kb;
     104        float cur, max, kb;
    124105 
    125106        tr_lockLock( (tr_lock*)r->lock );
     
    128109        max = r->limit;
    129110        kb = max>cur ? max-cur : 0;
    130         bytes = kb * 1024u;
     111        bytes = (size_t)(kb * 1024);
    131112
    132113        tr_lockUnlock( (tr_lock*)r->lock );
     
    183164    tr_lockLock( (tr_lock*)r->lock );
    184165    r->newest = 0;
    185     memset( r->transfers, 0, sizeof(tr_transfer_t) * HISTORY_SIZE );
     166    memset( r->transfers, 0, sizeof(struct tr_transfer) * HISTORY_SIZE );
    186167    tr_lockUnlock( (tr_lock*)r->lock );
    187168}
  • branches/0.9x/libtransmission/ratecontrol.h

    r3614 r3899  
    3131void             tr_rcSetLimit( tr_ratecontrol *, int );
    3232int              tr_rcGetLimit( const tr_ratecontrol * );
    33 int              tr_rcCanTransfer( const tr_ratecontrol * );
    3433size_t           tr_rcBytesLeft( const tr_ratecontrol * );
    3534void             tr_rcTransferred( tr_ratecontrol *, size_t byteCount );
  • branches/0.9x/libtransmission/tracker.c

    r3827 r3899  
    1818#include <libgen.h> /* basename */
    1919
    20 #include <sys/queue.h> /* libevent needs this */
    21 #include <sys/types.h> /* libevent needs this */
     20#include <sys/queue.h> /* evhttp.h needs this */
    2221#include <event.h>
    2322#include <evhttp.h>
     
    626625   
    627626    evbuffer_add_printf( buf, "%s"
    628                               "%sinfo_hash=%s"
     627                              "%cinfo_hash=%s"
    629628                              "&peer_id=%s"
    630629                              "&port=%d"
     
    641640                              "%s%s",
    642641        ann,
    643         ( strchr(ann, '?') == NULL ? "?" : "&" ),
     642        strchr(ann, '?') ? '&' : '?',
    644643        t->escaped,
    645644        t->peer_id,
     
    715714    const char * warning;
    716715    tr_tracker * t;
    717     int err = 0;
    718716    int responseCode;
    719717
     
    799797            tr_bencFree( &benc );
    800798    }
    801     else
    802     {
    803         tr_inf( "Bad response for torrent '%s' on request '%s' "
    804                 "... trying again in 30 seconds",
    805                 t->name, t->lastRequest );
    806 
    807         err = 1;
    808     }
    809799
    810800    if (( warning = updateAddresses( t, req ) )) {
     
    851841    else if( 500<=responseCode && responseCode<=599 )
    852842    {
    853         dbgmsg( t, "got a 5xx error... retrying in 15 seconds." );
     843        dbgmsg( t, "Got a 5xx error... retrying in 15 seconds." );
    854844
    855845        /* Response status codes beginning with the digit "5" indicate
     
    864854    else
    865855    {
    866         dbgmsg( t, "unhandled condition... retrying in 120 seconds." );
     856        dbgmsg( t, "Invalid response from tracker... retrying in 120 seconds." );
    867857
    868858        /* WTF did we get?? */
  • branches/0.9x/libtransmission/utils.c

    r3897 r3899  
    824824
    825825tr_bitfield*
    826 tr_bitfieldAnd( tr_bitfield * a, const tr_bitfield * b )
     826tr_bitfieldOr( tr_bitfield * a, const tr_bitfield * b )
    827827{
    828828    uint8_t *ait;
     
    832832
    833833    for( ait=a->bits, bit=b->bits, aend=ait+a->len; ait!=aend; ++ait, ++bit )
    834         *ait &= *bit;
     834        *ait |= *bit;
    835835
    836836    return a;
  • branches/0.9x/libtransmission/utils.h

    r3649 r3899  
    174174size_t tr_bitfieldCountTrueBits( const tr_bitfield* );
    175175
    176 tr_bitfield* tr_bitfieldAnd( tr_bitfield*, const tr_bitfield* );
     176tr_bitfield* tr_bitfieldOr( tr_bitfield*, const tr_bitfield* );
    177177
    178178#endif
Note: See TracChangeset for help on using the changeset viewer.