Changeset 3469
- Timestamp:
- Oct 19, 2007, 11:23:21 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/torrent-inspector.c
r3426 r3469 1177 1177 1178 1178 static void 1179 set_files_enabled( GtkTreeStore * store, 1180 GtkTreeIter * iter, 1181 tr_torrent * tor, 1182 gboolean enabled ) 1179 subtree_walk_dnd( GtkTreeStore * store, 1180 GtkTreeIter * iter, 1181 tr_torrent * tor, 1182 gboolean enabled, 1183 GArray * indices ) 1183 1184 { 1184 1185 int index; 1185 1186 GtkTreeIter child; 1186 1187 1188 /* update this node */ 1187 1189 gtk_tree_model_get( GTK_TREE_MODEL(store), iter, FC_INDEX, &index, -1 ); 1188 1190 if (index >= 0) 1189 tr_torrentSetFileDL( tor, index, enabled);1191 g_array_append_val( indices, index ); 1190 1192 gtk_tree_store_set( store, iter, FC_ENABLED, enabled, -1 ); 1191 1193 1194 /* visit the children */ 1192 1195 if( gtk_tree_model_iter_children( GTK_TREE_MODEL(store), &child, iter ) ) do 1193 s et_files_enabled( store, &child, tor, enabled);1196 subtree_walk_dnd( store, &child, tor, enabled, indices ); 1194 1197 while( gtk_tree_model_iter_next( GTK_TREE_MODEL(store), &child ) ); 1198 } 1199 1200 static void 1201 set_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 ); 1195 1210 } 1196 1211 … … 1285 1300 gtk_tree_model_get( model, &iter, FC_ENABLED, &enabled, -1 ); 1286 1301 enabled = !enabled; 1287 set_ files_enabled( GTK_TREE_STORE(model),1288 1289 1290 1302 set_subtree_dnd( GTK_TREE_STORE(model), 1303 &iter, 1304 tr_torrent_handle( data->gtor ), 1305 enabled ); 1291 1306 1292 1307 gtk_tree_path_free( path ); -
trunk/libtransmission/internal.h
r3412 r3469 62 62 void tr_torrentUnlock ( const tr_torrent * ); 63 63 64 int tr_torrentIsSeed ( const tr_torrent * ); 65 64 66 void tr_torrentChangeMyPort ( tr_torrent * ); 65 67 -
trunk/libtransmission/peer-mgr.c
r3437 r3469 705 705 if( !t->isRunning ) 706 706 return TRUE; 707 if( tr_ cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE)707 if( tr_torrentIsSeed( t->tor ) ) 708 708 return TRUE; 709 709 … … 1503 1503 /* if we're both seeds and it's been long enough for a pex exchange, close it */ 1504 1504 if( 1 ) { 1505 const int clientIsSeed = tr_ cpGetStatus( tor->completion ) != TR_CP_INCOMPLETE;1505 const int clientIsSeed = tr_torrentIsSeed( tor ); 1506 1506 const int peerIsSeed = atom->flags & ADDED_F_SEED_FLAG; 1507 1507 if( peerIsSeed && clientIsSeed && ( !tr_torrentIsPexEnabled(tor) || (now-atom->time>=30) ) ) { … … 1569 1569 struct peer_atom ** ret; 1570 1570 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 ); 1572 1572 1573 1573 assert( torrentIsLocked( t ) ); -
trunk/libtransmission/peer-msgs.c
r3447 r3469 344 344 const tr_torrent * torrent; 345 345 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 ); 348 347 349 348 if( clientIsSeed ) … … 950 949 951 950 case BT_BITFIELD: { 952 const int clientIsSeed = tr_ cpGetStatus( msgs->torrent->completion ) != TR_CP_INCOMPLETE;951 const int clientIsSeed = tr_torrentIsSeed( msgs->torrent ); 953 952 dbgmsg( msgs, "got a bitfield" ); 954 953 assert( msglen == msgs->info->have->len ); -
trunk/libtransmission/torrent.c
r3459 r3469 590 590 ***/ 591 591 592 #if 0593 int tr_torrentScrape( tr_torrent * tor, int * s, int * l, int * d )594 {595 return tr_trackerScrape( tor, s, l, d );596 }597 #endif598 599 592 static int 600 593 saveFastResumeNow( void * vtor ) 601 594 { 602 595 tr_torrent * tor = (tr_torrent *) vtor; 603 604 596 tr_fastResumeSave( tor ); 605 tr_torrentRecheckCompleteness( tor ); 606 607 tr_timerFree( &tor->saveTimer ); 597 tor->saveTimer = NULL; 608 598 return FALSE; 609 599 } … … 1004 994 *tor->errorString = '\0'; 1005 995 tr_torrentResetTransferStats( tor ); 1006 tr_torrentRecheckCompleteness( tor ); 996 tor->cpStatus = tr_cpGetStatus( tor->completion ); 997 saveFastResumeSoon( tor ); 1007 998 tor->startDate = tr_date( ); 1008 999 tr_trackerStart( tor->tracker ); … … 1134 1125 } 1135 1126 1127 int 1128 tr_torrentIsSeed( const tr_torrent * tor ) 1129 { 1130 return tor->cpStatus==TR_CP_COMPLETE || tor->cpStatus==TR_CP_DONE; 1131 } 1132 1136 1133 /** 1137 1134 *** File priorities … … 1224 1221 } 1225 1222 1226 void1227 tr_torrentSetFileDL( tr_torrent * tor,1228 1229 1223 static void 1224 setFileDND( tr_torrent * tor, 1225 int fileIndex, 1226 int doDownload ) 1230 1227 { 1231 1228 tr_file * file; … … 1234 1231 int lastPiece, lastPieceDND; 1235 1232 int i; 1236 1237 tr_torrentLock( tor );1238 1233 1239 1234 file = &tor->info.files[fileIndex]; … … 1271 1266 tor->info.pieces[i].dnd = dnd; 1272 1267 } 1273 1274 tr_cpInvalidateDND ( tor->completion );1275 1276 saveFastResumeSoon( tor );1277 1278 tr_torrentUnlock( tor );1279 1268 } 1280 1269 … … 1286 1275 { 1287 1276 int i; 1277 tr_torrentLock( tor ); 1278 1288 1279 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 ); 1290 1285 } 1291 1286 -
trunk/libtransmission/transmission.c
r3426 r3469 263 263 { 264 264 tr_torrent * tor; 265 266 *dl = 0.0;267 *ul = 0.0;268 265 tr_globalLock( h ); 266 267 *dl = *ul = 0.0; 269 268 for( tor = h->torrentList; tor; tor = tor->next ) 270 269 { 271 tr_torrentLock( tor ); 272 if( tor->cpStatus == TR_CP_INCOMPLETE ) 273 *dl += tr_rcRate( tor->download ); 270 *dl += tr_rcRate( tor->download ); 274 271 *ul += tr_rcRate( tor->upload ); 275 tr_torrentUnlock( tor );276 } 272 } 273 277 274 tr_globalUnlock( h ); 278 275 } -
trunk/libtransmission/transmission.h
r3426 r3469 286 286 /* set a batch of files to be downloaded or not. */ 287 287 void 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 ); 294 291 295 292 /***********************************************************************
Note: See TracChangeset
for help on using the changeset viewer.