Changeset 9220


Ignore:
Timestamp:
Sep 29, 2009, 3:02:44 AM (12 years ago)
Author:
livings124
Message:

getting closer to re-adding "add tracker" functionality

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.h

    r9203 r9220  
    5454    IBOutlet NSButton * fRevealDataButton;
    5555   
    56     NSArray * fTrackers;
     56    NSMutableArray * fTrackers;
    5757    IBOutlet TrackerTableView * fTrackerTable;
    5858    TrackerCell * fTrackerCell;
  • trunk/macosx/InfoWindowController.m

    r9203 r9220  
    9191- (BOOL) canQuickLookFile: (FileListNode *) item;
    9292
    93 #warning lookie
    94 /*- (void) addTrackers;
    95 - (void) removeTrackers;*/
     93- (void) addTrackers;
     94- (void) removeTrackers;
    9695
    9796@end
     
    383382        fTrackers = nil;
    384383       
     384        [fTrackerTable setTrackers: fTrackers];
    385385        [fTrackerTable reloadData];
    386         [fTrackerTable setTrackers: nil];
    387386       
    388387        [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_ADD_TAG];
     
    906905    if (tableView == fTrackerTable)
    907906    {
    908         const BOOL group = [[fTrackers objectAtIndex: row] isKindOfClass: [NSNumber class]];
    909         return group ? [tableColumn dataCellForRow: row] : fTrackerCell;
     907        const BOOL tracker = [[fTrackers objectAtIndex: row] isKindOfClass: [TrackerNode class]];
     908        return tracker ? fTrackerCell : [tableColumn dataCellForRow: row];
    910909    }
    911910   
     
    10731072}
    10741073
    1075 #warning fix!
    1076 #if 0
    10771074- (void) tableView: (NSTableView *) tableView setObjectValue: (id) object forTableColumn: (NSTableColumn *) tableColumn
    10781075    row: (NSInteger) row
     
    10811078        return;
    10821079   
    1083     [fTrackers replaceObjectAtIndex: row withObject: object];
    1084    
    10851080    Torrent * torrent= [fTorrents objectAtIndex: 0];
    1086     if (![torrent updateAllTrackersForAdd: fTrackers])
     1081    if (![torrent addTrackerToNewTier: object])
    10871082        NSBeep();
    10881083   
    10891084    //reset table with either new or old value
    10901085    [fTrackers release];
    1091     fTrackers = [[torrent allTrackers: YES] retain];
    1092     [fTrackerTable deselectAll: self];
     1086    fTrackers = [[torrent allTrackerStats] retain];
    10931087   
    10941088    [fTrackerTable setTrackers: fTrackers];
    10951089    [fTrackerTable reloadData];
    1096 }
    1097 #endif
     1090    [fTrackerTable deselectAll: self];
     1091}
    10981092
    10991093- (void) addRemoveTracker: (id) sender
    11001094{
    1101 /*    //don't allow add/remove when currently adding - it leads to weird results
     1095    //don't allow add/remove when currently adding - it leads to weird results
    11021096    if ([fTrackerTable editedRow] != -1)
    11031097        return;
     
    11061100        [self removeTrackers];
    11071101    else
    1108         [self addTrackers];*/
     1102        [self addTrackers];
    11091103}
    11101104
    11111105#warning what?!
    1112 - (BOOL) tableView: (NSTableView *) tableView shouldEditTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
     1106/*- (BOOL) tableView: (NSTableView *) tableView shouldEditTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
    11131107{
    11141108    if (tableView != fTrackerTable)
     
    11191113   
    11201114    return [[fTrackers objectAtIndex: i] intValue] == 0;
    1121 }
     1115}*/
    11221116
    11231117- (BOOL) acceptsPreviewPanelControl: (QLPreviewPanel *) panel
     
    14451439    Torrent * torrent = [fTorrents objectAtIndex: 0];
    14461440   
     1441    #warning still update unselected rows
    14471442    //get update tracker stats
    1448     [fTrackers release];
    1449     fTrackers = [[torrent allTrackerStats] retain];
    1450    
    1451     [fTrackerTable setTrackers: fTrackers];
    1452     [fTrackerTable reloadData];
     1443    if ([fTrackerTable editedRow] == -1)
     1444    {
     1445        [fTrackers release];
     1446        fTrackers = [[torrent allTrackerStats] retain];
     1447       
     1448        [fTrackerTable setTrackers: fTrackers];
     1449        [fTrackerTable reloadData];
     1450    }
    14531451}
    14541452
     
    16791677}
    16801678
    1681 #if 0
    1682 
    16831679#warning doesn't like blank addresses
    16841680- (void) addTrackers
     
    16861682    [[self window] makeKeyWindow];
    16871683   
    1688     NSUInteger tierCount = 0;
    1689     for (id trackerObject in fTrackers)
    1690         if ([trackerObject isKindOfClass: [NSNumber class]])
    1691             tierCount++;
    1692    
    1693     [fTrackers addObject: [NSNumber numberWithInt: tierCount+1]];
     1684    [fTrackers addObject: [NSNumber numberWithInt: [(TrackerNode *)[fTrackers lastObject] tier]+1]];
    16941685    [fTrackers addObject: @""];
    16951686   
     1687    [fTrackerTable setTrackers: fTrackers];
    16961688    [fTrackerTable reloadData];
    16971689    [fTrackerTable selectRowIndexes: [NSIndexSet indexSetWithIndex: [fTrackers count]-1] byExtendingSelection: NO];
     
    17831775    //reset table with either new or old value
    17841776    [fTrackers release];
    1785     fTrackers = [[torrent allTrackers: YES] retain];
     1777    fTrackers = [[torrent allTrackerStats] retain];
    17861778   
    17871779    [fTrackerTable setTrackers: fTrackers];
     
    17891781}
    17901782
    1791 #endif
    1792 
    17931783@end
  • trunk/macosx/Torrent.h

    r9204 r9220  
    133133- (uint64_t) sizeLeft;
    134134
    135 - (NSArray *) allTrackerStats;
    136 - (NSArray *) allTrackersFlat; //used by GroupRules
    137 /*- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
    138 - (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;*/
     135- (NSMutableArray *) allTrackerStats;
     136- (NSMutableArray *) allTrackersFlat; //used by GroupRules
     137- (BOOL) addTrackerToNewTier: (NSString *) tracker;
     138- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;
    139139
    140140- (NSString *) comment;
  • trunk/macosx/Torrent.m

    r9204 r9220  
    673673}
    674674
    675 - (NSArray *) allTrackerStats
     675- (NSMutableArray *) allTrackerStats
    676676{
    677677    int count;
     
    698698}
    699699
    700 - (NSArray *) allTrackersFlat
     700- (NSMutableArray *) allTrackersFlat
    701701{
    702702    NSMutableArray * allTrackers = [NSMutableArray arrayWithCapacity: fInfo->trackerCount];
     
    708708}
    709709
    710 /*- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers
    711 {
    712     NSString * tracker = [trackers lastObject];
     710- (BOOL) addTrackerToNewTier: (NSString *) tracker
     711{
    713712    tracker = [tracker stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
    714713   
    715714    if ([tracker rangeOfString: @"://"].location == NSNotFound)
    716     {
    717715        tracker = [@"http://" stringByAppendingString: tracker];
    718         [trackers replaceObjectAtIndex: [trackers count]-1 withObject: tracker];
    719     }
    720716   
    721717    if (!tr_httpIsValidURL([tracker UTF8String]))
    722718        return NO;
    723719   
     720    //recreate the tracker structure
     721    const int oldTrackerCount = fInfo->trackerCount;
     722    tr_tracker_info * trackerStructs = tr_new(tr_tracker_info, oldTrackerCount+1);
     723    for (NSInteger i=0; i < oldTrackerCount; ++i)
     724        trackerStructs[i] = fInfo->trackers[i];
     725   
     726    trackerStructs[oldTrackerCount].announce = (char *)[tracker UTF8String];
     727    trackerStructs[oldTrackerCount].tier = trackerStructs[oldTrackerCount-1].tier + 1;
     728   
     729    tr_torrentSetAnnounceList(fHandle, trackerStructs, oldTrackerCount+1);
     730    tr_free(trackerStructs);
     731   
     732    return YES;
     733}
     734
     735#warning this doesn't work
     736- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers
     737{
    724738    [self updateAllTrackers: trackers];
    725    
    726     return YES;
    727 }
    728 
    729 - (void) updateAllTrackersForRemove: (NSMutableArray *) trackers
    730 {
    731     [self updateAllTrackers: trackers];
    732 }*/
     739}
    733740
    734741- (NSString *) comment
     
    18001807}
    18011808
     1809#warning needs to be removed
    18021810- (void) updateAllTrackers: (NSMutableArray *) trackers
    18031811{
  • trunk/macosx/TrackerNode.h

    r9209 r9220  
    3636- (NSString *) fullAnnounceAddress;
    3737
     38- (NSInteger) tier;
     39
    3840- (NSInteger) totalSeeders;
    3941- (NSInteger) totalLeechers;
  • trunk/macosx/TrackerNode.m

    r9212 r9220  
    5353{
    5454    return [NSString stringWithUTF8String: fStat.announce];
     55}
     56
     57- (NSInteger) tier
     58{
     59    return fStat.tier;
    5560}
    5661
  • trunk/macosx/TrackerTableView.m

    r9219 r9220  
    5757    }
    5858   
    59     NSString * text = [addresses componentsJoinedByString: @"\n"];;
     59    NSString * text = [addresses componentsJoinedByString: @"\n"];
    6060   
    6161    NSPasteboard * pb = [NSPasteboard generalPasteboard];
     
    7474- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
    7575{
    76     SEL action = [menuItem action];
     76    const SEL action = [menuItem action];
    7777   
    7878    if (action == @selector(copy:))
Note: See TracChangeset for help on using the changeset viewer.