Changeset 1322
- Timestamp:
- Jan 9, 2007, 1:09:23 AM (15 years ago)
- Location:
- trunk/macosx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.h
r1283 r1322 173 173 - (void) setQuickRatioGlobal: (id) sender; 174 174 175 #warning simplify? 175 176 - (void) checkWaitingForStopped: (NSNotification *) notification; 176 - (void) checkToStartWaiting: (Torrent *) finishedTorrent;177 177 - (void) torrentStartSettingChange: (NSNotification *) notification; 178 178 - (void) globalStartSettingChange: (NSNotification *) notification; 179 179 180 180 - (void) torrentStoppedForRatio: (NSNotification *) notification; 181 182 - (void) attemptToStartAuto: (Torrent *) torrent; 183 - (void) attemptToStartMultipleAuto: (NSArray *) torrents; 181 - (void) updateTorrentsInQueue; 184 182 185 183 - (void) changeAutoImport; -
trunk/macosx/Controller.m
r1305 r1322 598 598 [torrent setDownloadFolder: folder]; 599 599 [torrent update]; 600 [self attemptToStartAuto: torrent];601 600 602 601 [fTorrents addObject: torrent]; … … 604 603 } 605 604 606 [self updateUI: nil]; 607 [self applyFilter: nil]; 608 609 [self updateTorrentHistory]; 605 [self updateTorrentsInQueue]; 610 606 } 611 607 … … 662 658 [torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]]; 663 659 [torrent update]; 664 [self attemptToStartAuto: torrent];665 660 666 661 [fTorrents addObject: torrent]; 667 662 668 [self updateUI: nil]; 669 [self applyFilter: nil]; 663 [self updateTorrentsInQueue]; 670 664 } 671 665 … … 792 786 [torrent setWaitToStart: YES]; 793 787 794 [self attemptToStartMultipleAuto: torrents]; 795 796 [self updateUI: nil]; 797 [self applyFilter: nil]; 798 [self updateTorrentHistory]; 788 [self updateTorrentsInQueue]; 799 789 } 800 790 … … 1157 1147 [fInfoController updateInfoStats]; 1158 1148 1159 [self applyFilter: nil]; 1160 [self checkToStartWaiting: torrent]; 1149 [self updateTorrentsInQueue]; 1161 1150 1162 1151 if ([fDefaults boolForKey: @"PlayDownloadSound"]) … … 1578 1567 - (void) checkWaitingForStopped: (NSNotification *) notification 1579 1568 { 1580 [self checkToStartWaiting: [notification object]];1569 [self updateTorrentsInQueue]; 1581 1570 1582 1571 [self updateUI: nil]; … … 1585 1574 } 1586 1575 1587 - (void) checkToStartWaiting: (Torrent *) finishedTorrent1588 {1589 //don't try to start a transfer if there should be none waiting1590 if (![fDefaults boolForKey: @"Queue"])1591 return;1592 1593 int desiredActive = [fDefaults integerForKey: @"QueueDownloadNumber"];1594 1595 NSEnumerator * enumerator = [fTorrents objectEnumerator];1596 Torrent * torrent, * torrentToStart = nil;1597 while ((torrent = [enumerator nextObject]))1598 {1599 //ignore the torrent just stopped1600 if (torrent == finishedTorrent)1601 continue;1602 1603 if ([torrent isActive])1604 {1605 if (![torrent isSeeding] && ![torrent isError])1606 {1607 desiredActive--;1608 if (desiredActive <= 0)1609 return;1610 }1611 }1612 else1613 {1614 //use as next if it is waiting to start and either no previous or order value is lower1615 if ([torrent waitingToStart] && (!torrentToStart1616 || [[torrentToStart orderValue] compare: [torrent orderValue]] == NSOrderedDescending))1617 torrentToStart = torrent;1618 }1619 }1620 1621 //since it hasn't returned, the queue amount has not been met1622 if (torrentToStart)1623 {1624 [torrentToStart startTransfer];1625 1626 [self updateUI: nil];1627 [self applyFilter: nil];1628 [self updateTorrentHistory];1629 }1630 }1631 1632 1576 - (void) torrentStartSettingChange: (NSNotification *) notification 1633 1577 { 1634 [self attemptToStartMultipleAuto: [notification object]]; 1635 1636 [self updateUI: nil]; 1637 [self applyFilter: nil]; 1638 [self updateTorrentHistory]; 1578 [self updateTorrentsInQueue]; 1639 1579 } 1640 1580 1641 1581 - (void) globalStartSettingChange: (NSNotification *) notification 1642 1582 { 1643 [self attemptToStartMultipleAuto: fTorrents]; 1644 1645 [self updateUI: nil]; 1646 [self applyFilter: nil]; 1647 [self updateTorrentHistory]; 1583 [self updateTorrentsInQueue]; 1648 1584 } 1649 1585 … … 1667 1603 - (void) attemptToStartAuto: (Torrent *) torrent 1668 1604 { 1669 [self attemptToStartMultipleAuto: [NSArray arrayWithObject: torrent]];1605 [self updateTorrentsInQueue]; 1670 1606 } 1671 1607 1672 1608 //will try to start, taking into consideration the start preference 1673 - (void) attemptToStartMultipleAuto: (NSArray *) torrents1609 - (void) updateTorrentsInQueue 1674 1610 { 1675 1611 if (![fDefaults boolForKey: @"Queue"]) 1676 1612 { 1677 NSEnumerator * enumerator = [ torrents objectEnumerator];1613 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 1678 1614 Torrent * torrent; 1679 1615 while ((torrent = [enumerator nextObject])) … … 1698 1634 1699 1635 //sort torrents by order value 1700 NSArray * sortedTorrents; 1701 if ([torrents count] > 1 && desiredActive > 0) 1702 { 1703 NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: 1704 @"orderValue" ascending: YES] autorelease]; 1705 NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil]; 1706 1707 sortedTorrents = [torrents sortedArrayUsingDescriptors: descriptors]; 1708 [descriptors release]; 1709 } 1710 else 1711 sortedTorrents = torrents; 1636 NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: 1637 @"orderValue" ascending: YES] autorelease]; 1638 NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil]; 1639 1640 NSArray * sortedTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors]; 1641 [descriptors release]; 1712 1642 1713 1643 enumerator = [sortedTorrents objectEnumerator]; … … 1721 1651 { 1722 1652 [torrent startTransfer]; 1723 desiredActive--; 1653 if ([torrent isActive]) 1654 desiredActive--; 1724 1655 } 1725 1656 else … … 1729 1660 } 1730 1661 } 1662 1663 [self updateUI: nil]; 1664 [self applyFilter: nil]; 1665 [self updateTorrentHistory]; 1731 1666 } 1732 1667 -
trunk/macosx/Torrent.m
r1320 r1322 259 259 } 260 260 261 fStat = tr_torrentStat(fHandle); 261 262 [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self]; 262 263 } … … 447 448 448 449 if (![self isActive] && [self alertForVolumeAvailable] && [self alertForRemainingDiskSpace]) 450 { 449 451 tr_torrentStart(fHandle); 452 [self update]; 453 } 450 454 } 451 455 … … 459 463 460 464 tr_torrentStop(fHandle); 465 [self update]; 461 466 462 467 if (!wasSeeding)
Note: See TracChangeset
for help on using the changeset viewer.