Changeset 2169
- Timestamp:
- Jun 20, 2007, 12:54:05 AM (15 years ago)
- Location:
- trunk/macosx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.h
r2168 r2169 168 168 169 169 - (void) updateTorrentsInQueue; 170 - (int) numToStartFromQueue: (BOOL) downloadQueue; 170 171 171 172 - (void) torrentFinishedDownloading: (NSNotification *) notification; 172 173 - (void) torrentRestartedDownloading: (NSNotification *) notification; 174 173 175 - (void) updateTorrentHistory; 174 176 -
trunk/macosx/Controller.m
r2168 r2169 1377 1377 seed = [fDefaults boolForKey: @"QueueSeed"]; 1378 1378 1379 //determine the number of downloads needed to start 1380 int desiredDownloadActive = download ? [fDefaults integerForKey: @"QueueDownloadNumber"] : 0, 1381 desiredSeedActive = seed ? [fDefaults integerForKey: @"QueueSeedNumber"] : 0; 1382 1383 Torrent * torrent; 1384 NSEnumerator * enumerator; 1385 if (download || seed) 1386 { 1387 enumerator = [fTorrents objectEnumerator]; 1388 while ((torrent = [enumerator nextObject])) 1389 if ([torrent isActive] && ![torrent isStalled] && ![torrent isError]) 1390 { 1391 if ([torrent allDownloaded]) 1392 desiredSeedActive--; 1393 else 1394 desiredDownloadActive--; 1395 1396 if (desiredDownloadActive <= 0 && desiredSeedActive <= 0) 1397 break; 1398 } 1399 } 1379 int desiredDownloadActive = [self numToStartFromQueue: YES], 1380 desiredSeedActive = [self numToStartFromQueue: NO]; 1400 1381 1401 1382 //sort torrents by order value … … 1413 1394 sortedTorrents = fTorrents; 1414 1395 1415 enumerator = [sortedTorrents objectEnumerator]; 1396 Torrent * torrent; 1397 NSEnumerator * enumerator = [sortedTorrents objectEnumerator]; 1416 1398 while ((torrent = [enumerator nextObject])) 1417 1399 { … … 1446 1428 } 1447 1429 1430 - (int) numToStartFromQueue: (BOOL) downloadQueue 1431 { 1432 if (![fDefaults boolForKey: downloadQueue ? @"Queue" : @"QueueSeed"]) 1433 return 0; 1434 1435 int desired = [fDefaults integerForKey: downloadQueue ? @"QueueDownloadNumber" : @"QueueSeedNumber"]; 1436 1437 Torrent * torrent; 1438 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 1439 while ((torrent = [enumerator nextObject])) 1440 if ([torrent isActive] && ![torrent isStalled] && ![torrent isError]) 1441 { 1442 if ([torrent allDownloaded] != downloadQueue) 1443 { 1444 desired--; 1445 if (desired <= 0) 1446 return 0; 1447 } 1448 } 1449 1450 return desired; 1451 } 1452 1448 1453 - (void) torrentFinishedDownloading: (NSNotification *) notification 1449 1454 { … … 1468 1473 [fBadger incrementCompleted]; 1469 1474 1470 #warning make better 1471 if ([fDefaults boolForKey: @"QueueSeed"]) 1475 if ([fDefaults boolForKey: @"QueueSeed"] && [self numToStartFromQueue: NO] <= 0) 1472 1476 { 1473 1477 [torrent stopTransfer]; … … 1484 1488 [fInfoController updateInfoStats]; 1485 1489 1486 #warning make better 1487 if ([fDefaults boolForKey: @"Queue"]) 1490 if ([fDefaults boolForKey: @"Queue"] && [self numToStartFromQueue: YES] <= 0) 1488 1491 { 1489 1492 [torrent stopTransfer]; -
trunk/macosx/Torrent.m
r2168 r2169 1370 1370 } 1371 1371 1372 #warning when going seeding to download, update queue1373 1372 [self update]; 1374 [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self]; //for paused torrents 1373 if ([self isPaused]) 1374 [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self]; //for paused torrents 1375 1375 } 1376 1376
Note: See TracChangeset
for help on using the changeset viewer.