Changeset 3469


Ignore:
Timestamp:
Oct 19, 2007, 11:23:21 PM (14 years ago)
Author:
charles
Message:
  • don't fire the "status changed" event if the status changes while a torrent's being started for the first time.
  • cleaner setting of the DND flags in the gtk+ client.
  • cpStatus cleanup.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/torrent-inspector.c

    r3426 r3469  
    11771177
    11781178static void
    1179 set_files_enabled( GtkTreeStore   * store,
    1180                    GtkTreeIter    * iter,
    1181                    tr_torrent     * tor,
    1182                    gboolean         enabled )
     1179subtree_walk_dnd( GtkTreeStore   * store,
     1180                  GtkTreeIter    * iter,
     1181                  tr_torrent     * tor,
     1182                  gboolean         enabled,
     1183                  GArray         * indices )
    11831184{
    11841185    int index;
    11851186    GtkTreeIter child;
    1186 
     1187 
     1188    /* update this node */
    11871189    gtk_tree_model_get( GTK_TREE_MODEL(store), iter, FC_INDEX, &index, -1  );
    11881190    if (index >= 0)
    1189       tr_torrentSetFileDL( tor, index, enabled );
     1191      g_array_append_val( indices, index );
    11901192    gtk_tree_store_set( store, iter, FC_ENABLED, enabled, -1 );
    11911193
     1194    /* visit the children */
    11921195    if( gtk_tree_model_iter_children( GTK_TREE_MODEL(store), &child, iter ) ) do
    1193       set_files_enabled( store, &child, tor, enabled );
     1196      subtree_walk_dnd( store, &child, tor, enabled, indices );
    11941197    while( gtk_tree_model_iter_next( GTK_TREE_MODEL(store), &child ) );
     1198}
     1199
     1200static void
     1201set_subtree_dnd( GtkTreeStore * store,
     1202                 GtkTreeIter * iter,
     1203                 tr_torrent  * tor,
     1204                 gboolean enabled )
     1205{
     1206    GArray * indices = g_array_new( FALSE, FALSE, sizeof(int) );
     1207    subtree_walk_dnd( store, iter, tor, enabled, indices );
     1208    tr_torrentSetFileDLs( tor, (int*)indices->data, (int)indices->len, enabled );
     1209    g_array_free( indices, TRUE );
    11951210}
    11961211
     
    12851300  gtk_tree_model_get( model, &iter, FC_ENABLED, &enabled, -1 );
    12861301  enabled = !enabled;
    1287   set_files_enabled( GTK_TREE_STORE(model),
    1288                      &iter,
    1289                      tr_torrent_handle( data->gtor ),
    1290                      enabled );
     1302  set_subtree_dnd( GTK_TREE_STORE(model),
     1303                   &iter,
     1304                   tr_torrent_handle( data->gtor ),
     1305                   enabled );
    12911306
    12921307  gtk_tree_path_free( path );
  • trunk/libtransmission/internal.h

    r3412 r3469  
    6262void tr_torrentUnlock  ( const tr_torrent * );
    6363
     64int  tr_torrentIsSeed  ( const tr_torrent * );
     65
    6466void tr_torrentChangeMyPort  ( tr_torrent * );
    6567
  • trunk/libtransmission/peer-mgr.c

    r3437 r3469  
    705705    if( !t->isRunning )
    706706        return TRUE;
    707     if( tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE )
     707    if( tr_torrentIsSeed( t->tor ) )
    708708        return TRUE;
    709709
     
    15031503    /* if we're both seeds and it's been long enough for a pex exchange, close it */
    15041504    if( 1 ) {
    1505         const int clientIsSeed = tr_cpGetStatus( tor->completion ) != TR_CP_INCOMPLETE;
     1505        const int clientIsSeed = tr_torrentIsSeed( tor );
    15061506        const int peerIsSeed = atom->flags & ADDED_F_SEED_FLAG;
    15071507        if( peerIsSeed && clientIsSeed && ( !tr_torrentIsPexEnabled(tor) || (now-atom->time>=30) ) ) {
     
    15691569    struct peer_atom ** ret;
    15701570    const time_t now = time( NULL );
    1571     const int seed = tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE;
     1571    const int seed = tr_torrentIsSeed( t->tor );
    15721572
    15731573    assert( torrentIsLocked( t ) );
  • trunk/libtransmission/peer-msgs.c

    r3447 r3469  
    344344    const tr_torrent * torrent;
    345345    const tr_bitfield * bitfield;
    346     const int clientIsSeed =
    347         tr_cpGetStatus( msgs->torrent->completion ) != TR_CP_INCOMPLETE;
     346    const int clientIsSeed = tr_torrentIsSeed( msgs->torrent );
    348347
    349348    if( clientIsSeed )
     
    950949
    951950        case BT_BITFIELD: {
    952             const int clientIsSeed = tr_cpGetStatus( msgs->torrent->completion ) != TR_CP_INCOMPLETE;
     951            const int clientIsSeed = tr_torrentIsSeed( msgs->torrent );
    953952            dbgmsg( msgs, "got a bitfield" );
    954953            assert( msglen == msgs->info->have->len );
  • trunk/libtransmission/torrent.c

    r3459 r3469  
    590590***/
    591591
    592 #if 0
    593 int tr_torrentScrape( tr_torrent * tor, int * s, int * l, int * d )
    594 {
    595     return tr_trackerScrape( tor, s, l, d );
    596 }
    597 #endif
    598 
    599592static int
    600593saveFastResumeNow( void * vtor )
    601594{
    602595    tr_torrent * tor = (tr_torrent *) vtor;
    603 
    604596    tr_fastResumeSave( tor );
    605     tr_torrentRecheckCompleteness( tor );
    606 
    607     tr_timerFree( &tor->saveTimer );
     597    tor->saveTimer = NULL;
    608598    return FALSE;
    609599}
     
    1004994    *tor->errorString = '\0';
    1005995    tr_torrentResetTransferStats( tor );
    1006     tr_torrentRecheckCompleteness( tor );
     996    tor->cpStatus = tr_cpGetStatus( tor->completion );
     997    saveFastResumeSoon( tor );
    1007998    tor->startDate = tr_date( );
    1008999    tr_trackerStart( tor->tracker );
     
    11341125}
    11351126
     1127int
     1128tr_torrentIsSeed( const tr_torrent * tor )
     1129{
     1130    return tor->cpStatus==TR_CP_COMPLETE || tor->cpStatus==TR_CP_DONE;
     1131}
     1132
    11361133/**
    11371134***  File priorities
     
    12241221}
    12251222
    1226 void
    1227 tr_torrentSetFileDL( tr_torrent  * tor,
    1228                      int           fileIndex,
    1229                      int           doDownload )
     1223static void
     1224setFileDND( tr_torrent  * tor,
     1225            int           fileIndex,
     1226            int           doDownload )
    12301227{
    12311228    tr_file * file;
     
    12341231    int lastPiece, lastPieceDND;
    12351232    int i;
    1236 
    1237     tr_torrentLock( tor );
    12381233
    12391234    file = &tor->info.files[fileIndex];
     
    12711266            tor->info.pieces[i].dnd = dnd;
    12721267    }
    1273 
    1274     tr_cpInvalidateDND ( tor->completion );
    1275 
    1276     saveFastResumeSoon( tor );
    1277 
    1278     tr_torrentUnlock( tor );
    12791268}
    12801269
     
    12861275{
    12871276    int i;
     1277    tr_torrentLock( tor );
     1278
    12881279    for( i=0; i<fileCount; ++i )
    1289         tr_torrentSetFileDL( tor, files[i], doDownload );
     1280        setFileDND( tor, files[i], doDownload );
     1281    tr_cpInvalidateDND ( tor->completion );
     1282    saveFastResumeNow( tor );
     1283
     1284    tr_torrentUnlock( tor );
    12901285}
    12911286
  • trunk/libtransmission/transmission.c

    r3426 r3469  
    263263{
    264264    tr_torrent * tor;
    265 
    266     *dl = 0.0;
    267     *ul = 0.0;
    268265    tr_globalLock( h );
     266
     267    *dl = *ul = 0.0;
    269268    for( tor = h->torrentList; tor; tor = tor->next )
    270269    {
    271         tr_torrentLock( tor );
    272         if( tor->cpStatus == TR_CP_INCOMPLETE )
    273             *dl += tr_rcRate( tor->download );
     270        *dl += tr_rcRate( tor->download );
    274271        *ul += tr_rcRate( tor->upload );
    275         tr_torrentUnlock( tor );
    276     }
     272    }
     273
    277274    tr_globalUnlock( h );
    278275}
  • trunk/libtransmission/transmission.h

    r3426 r3469  
    286286/* set a batch of files to be downloaded or not. */
    287287void tr_torrentSetFileDLs ( tr_torrent   * tor,
    288                             int            * files,
    289                             int              fileCount,
    290                             int              do_download );
    291 
    292 /* single-file form of tr_torrentSetFileDLs */
    293 void tr_torrentSetFileDL( tr_torrent *, int file, int do_download );
     288                            int          * files,
     289                            int            fileCount,
     290                            int            do_download );
    294291
    295292/***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.