Changeset 9125


Ignore:
Timestamp:
Sep 17, 2009, 12:33:39 AM (13 years ago)
Author:
livings124
Message:

remove distinction between built-in trackers and custom-added trackers; add trackers to the end of the list instead of the beginning

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r9124 r9125  
    11031103        return NO;
    11041104   
    1105     //only allow modification of custom-added trackers
    1106     if ([[fTrackers objectAtIndex: row] isKindOfClass: [NSNumber class]] || ![[fTorrents objectAtIndex: 0] hasAddedTrackers])
    1107         return NO;
    1108    
    11091105    NSUInteger i;
    11101106    for (i = row-1; ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; i--);
     
    17321728    [[self window] makeKeyWindow];
    17331729   
    1734     NSUInteger index = 1;
    1735     if ([fTrackers count] > 0 && [[fTorrents objectAtIndex: 0] hasAddedTrackers])
    1736     {
    1737         for (; index < [fTrackers count]; index++)
    1738             if ([[fTrackers objectAtIndex: index] isKindOfClass: [NSNumber class]])
    1739                 break;
    1740     }
    1741     else
    1742         [fTrackers insertObject: [NSNumber numberWithInt: 0] atIndex: 0];
    1743    
    1744     [fTrackers insertObject: @"" atIndex: index];
     1730    NSUInteger tierCount = 0;
     1731    for (id trackerObject in fTrackers)
     1732        if ([trackerObject isKindOfClass: [NSNumber class]])
     1733            tierCount++;
     1734   
     1735    [fTrackers addObject: [NSNumber numberWithInt: tierCount+1]];
     1736    [fTrackers addObject: @""];
     1737   
    17451738    [fTrackerTable reloadData];
    1746     [fTrackerTable selectRowIndexes: [NSIndexSet indexSetWithIndex: index] byExtendingSelection: NO];
    1747     [fTrackerTable editColumn: 0 row: index withEvent: nil select: YES];
     1739    [fTrackerTable selectRowIndexes: [NSIndexSet indexSetWithIndex: [fTrackers count]-1] byExtendingSelection: NO];
     1740    [fTrackerTable editColumn: 0 row: [fTrackers count]-1 withEvent: nil select: YES];
    17481741}
    17491742
     
    17991792   
    18001793    //determine if removing trackers built into the torrent
    1801     if (numberBuiltIn > 0 && [[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveBuiltInTracker"])
     1794    #warning remove?
     1795    if (NO && numberBuiltIn > 0 && [[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveBuiltInTracker"])
    18021796    {
    18031797        NSAlert * alert = [[NSAlert alloc] init];
  • trunk/macosx/NSStringAdditions.m

    r9124 r9125  
    141141}
    142142
     143//also used in InfoWindow.xib
    143144- (NSComparisonResult) compareFinder: (NSString *) string
    144145{
  • trunk/macosx/Torrent.h

    r9045 r9125  
    5959    NSInteger fGroupValue;
    6060   
    61     BOOL fAddedTrackers;
    62    
    6361    NSDictionary * fQuickPauseDict;
    6462}
     
    148146- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
    149147- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;
    150 - (BOOL) hasAddedTrackers;
    151148
    152149- (NSString *) comment;
  • trunk/macosx/Torrent.m

    r9046 r9125  
    3535        useIncompleteFolder: (NSNumber *) useIncompleteFolder incompleteFolder: (NSString *) incompleteFolder
    3636        waitToStart: (NSNumber *) waitToStart
    37         groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers;
     37        groupValue: (NSNumber *) groupValue;
    3838
    3939- (BOOL) shouldUseIncompleteFolderForName: (NSString *) name;
     
    8484            downloadFolder: location
    8585            useIncompleteFolder: nil incompleteFolder: nil
    86             waitToStart: nil groupValue: nil addedTrackers: nil];
     86            waitToStart: nil groupValue: nil];
    8787   
    8888    if (self)
     
    9999            downloadFolder: location
    100100            useIncompleteFolder: nil incompleteFolder: nil
    101             waitToStart: nil groupValue: nil addedTrackers: nil];
     101            waitToStart: nil groupValue: nil];
    102102   
    103103    return self;
     
    113113                incompleteFolder: [history objectForKey: @"IncompleteFolder"]
    114114                waitToStart: [history objectForKey: @"WaitToStart"]
    115                 groupValue: [history objectForKey: @"GroupValue"]
    116                 addedTrackers: [history objectForKey: @"AddedTrackers"]];
     115                groupValue: [history objectForKey: @"GroupValue"]];
    117116   
    118117    if (self)
     
    162161                    [NSNumber numberWithBool: [self isActive]], @"Active",
    163162                    [NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
    164                     [NSNumber numberWithInt: fGroupValue], @"GroupValue",
    165                     [NSNumber numberWithBool: fAddedTrackers], @"AddedTrackers", nil];
     163                    [NSNumber numberWithInt: fGroupValue], @"GroupValue", nil];
    166164   
    167165    if (fIncompleteFolder)
     
    749747        {
    750748            tier = fInfo->trackers[i].tier;
    751             [allTrackers addObject: [NSNumber numberWithInt: fAddedTrackers ? tier : tier + 1]];
     749            [allTrackers addObject: [NSNumber numberWithInteger: tier + 1]];
    752750        }
    753751       
     
    765763- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers
    766764{
    767     //find added tracker at end of first tier
    768     NSInteger i;
    769     for (i = 1; i < [trackers count]; i++)
    770         if ([[trackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
    771             break;
    772     i--;
    773    
    774     NSString * tracker = [trackers objectAtIndex: i];
    775    
     765    NSString * tracker = [trackers lastObject];
    776766    tracker = [tracker stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
    777767   
     
    779769    {
    780770        tracker = [@"http://" stringByAppendingString: tracker];
    781         [trackers replaceObjectAtIndex: i withObject: tracker];
     771        [trackers replaceObjectAtIndex: [trackers count]-1 withObject: tracker];
    782772    }
    783773   
     
    787777    [self updateAllTrackers: trackers];
    788778   
    789     fAddedTrackers = YES;
    790779    return YES;
    791780}
    792781
     782#warning needed?
    793783- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers
    794784{
    795     //check if no user-added groups
    796     if ([trackers count] == 0 || [[trackers objectAtIndex: 0] intValue] != 0)
    797         fAddedTrackers = NO;
    798    
    799785    [self updateAllTrackers: trackers];
    800 }
    801 
    802 - (BOOL) hasAddedTrackers
    803 {
    804     return fAddedTrackers;
    805786}
    806787
     
    15681549        useIncompleteFolder: (NSNumber *) useIncompleteFolder incompleteFolder: (NSString *) incompleteFolder
    15691550        waitToStart: (NSNumber *) waitToStart
    1570         groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers
     1551        groupValue: (NSNumber *) groupValue
    15711552{
    15721553    if (!(self = [super init]))
     
    16511632    [self createFileList];
    16521633       
    1653     fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self];
    1654    
    1655     fAddedTrackers = addedTrackers ? [addedTrackers boolValue] : NO;   
     1634    fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self];
    16561635   
    16571636    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:)
Note: See TracChangeset for help on using the changeset viewer.