~ubuntu-branches/ubuntu/lucid/transmission/lucid

« back to all changes in this revision

Viewing changes to macosx/InfoWindowController.m

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda, Krzysztof Klimonda, Chris Coulson
  • Date: 2009-12-11 11:46:59 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20091211114659-6ebcmonweaixdpl3
Tags: 1.80~b5-0ubuntu1
[ Krzysztof Klimonda ]
* New upstream release (LP: #496503)
* Refreshed 99_autoreconf.patch
* Removed 21_fix_inhibition.patch

[ Chris Coulson ]
* Drop debian/patches/CVE-2010-0012.patch - merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: InfoWindowController.m 9610 2009-11-27 20:47:03Z livings124 $
 
2
 * $Id: InfoWindowController.m 9908 2010-01-10 16:26:30Z livings124 $
3
3
 *
4
 
 * Copyright (c) 2006-2009 Transmission authors and contributors
 
4
 * Copyright (c) 2006-2010 Transmission authors and contributors
5
5
 *
6
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
7
 * copy of this software and associated documentation files (the "Software"),
77
77
@interface InfoWindowController (Private)
78
78
 
79
79
- (void) resetInfo;
 
80
- (void) resetInfoForTorrent: (NSNotification *) notification;
80
81
 
81
82
- (void) updateInfoGeneral;
82
83
- (void) updateInfoActivity;
207
208
    
208
209
    //allow for update notifications
209
210
    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
210
 
    [nc addObserver: self selector: @selector(resetInfo) name: @"ResetInspector" object: nil];
 
211
    [nc addObserver: self selector: @selector(resetInfoForTorrent:) name: @"ResetInspector" object: nil];
211
212
    [nc addObserver: self selector: @selector(updateInfoStats) name: @"UpdateStats" object: nil];
212
213
    [nc addObserver: self selector: @selector(updateOptions) name: @"UpdateOptions" object: nil];
213
214
}
870
871
        return;
871
872
    
872
873
    Torrent * torrent= [fTorrents objectAtIndex: 0];
873
 
    if (![torrent addTrackerToNewTier: object])
 
874
    
 
875
    BOOL added = NO;
 
876
    for (NSString * tracker in [object componentsSeparatedByString: @"\n"])
 
877
        if ([torrent addTrackerToNewTier: tracker])
 
878
            added = YES;
 
879
    
 
880
    if (!added)
874
881
        NSBeep();
875
882
    
876
883
    //reset table with either new or old value
1253
1260
        
1254
1261
        [fCreatorField setStringValue: @""];
1255
1262
        [fDateCreatedField setStringValue: @""];
1256
 
        [fCommentView setSelectable: NO];
1257
1263
        
1258
1264
        [fDataLocationField setStringValue: @""];
1259
1265
        [fDataLocationField setToolTip: nil];
1260
1266
        
1261
1267
        [fRevealDataButton setHidden: YES];
1262
1268
        
1263
 
        //don't allow empty fields to be selected
 
1269
        #warning remove after 1.8
1264
1270
        [fHashField setSelectable: NO];
1265
1271
        [fCreatorField setSelectable: NO];
1266
1272
        [fDataLocationField setSelectable: NO];
1269
1275
        [fProgressField setStringValue: @""];
1270
1276
        
1271
1277
        [fErrorMessageView setString: @""];
1272
 
        [fErrorMessageView setSelectable: NO];
1273
1278
        
1274
1279
        [fConnectedPeersField setStringValue: @""];
1275
1280
        
1366
1371
        
1367
1372
        [fDateAddedField setObjectValue: [torrent dateAdded]];
1368
1373
        
1369
 
        //allow these fields to be selected
 
1374
        #warning remove after 1.8
1370
1375
        [fHashField setSelectable: YES];
1371
1376
        [fCommentView setSelectable: ![commentString isEqualToString: @""]];
1372
 
        [fCreatorField setSelectable: ![creatorString isEqualToString: @""]];
 
1377
        [fDataLocationField setSelectable: YES];
1373
1378
        
1374
1379
        //set pieces view
1375
1380
        BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
1403
1408
    [self updateOptions];
1404
1409
}
1405
1410
 
 
1411
- (void) resetInfoForTorrent: (NSNotification *) notification
 
1412
{
 
1413
    if (fTorrents && [fTorrents containsObject: [notification object]])
 
1414
        [self resetInfo];
 
1415
}
 
1416
 
1406
1417
- (void) updateInfoGeneral
1407
1418
{   
1408
1419
    if ([fTorrents count] != 1)
1413
1424
    NSString * location = [torrent dataLocation];
1414
1425
    [fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
1415
1426
    [fDataLocationField setToolTip: location ? location : @""];
1416
 
    [fDataLocationField setSelectable: location != nil];
1417
1427
    
1418
1428
    [fRevealDataButton setHidden: !location];
1419
1429
}
1473
1483
        
1474
1484
        NSString * errorMessage = [torrent errorMessage];
1475
1485
        if (![errorMessage isEqualToString: [fErrorMessageView string]])
1476
 
        {
1477
1486
            [fErrorMessageView setString: errorMessage];
1478
 
            [fErrorMessageView setSelectable: ![errorMessage isEqualToString: @""]];
1479
 
        }
1480
1487
        
1481
1488
        [fDateCompletedField setObjectValue: [torrent dateCompleted]];
1482
1489
        
1734
1741
 
1735
1742
- (void) removeTrackers
1736
1743
{
1737
 
    const NSInteger oldCount = [fTrackers count] - [(TrackerNode *)[fTrackers lastObject] tier];
1738
 
    NSMutableSet * addresses = [NSMutableSet setWithCapacity: oldCount];
 
1744
    NSMutableIndexSet * removeIdentifiers = [NSMutableIndexSet indexSet];
1739
1745
    
1740
 
    NSIndexSet * indexes = [fTrackerTable selectedRowIndexes];
1741
 
    for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
 
1746
    NSIndexSet * selectedIndexes = [fTrackerTable selectedRowIndexes];
 
1747
    BOOL groupSelected = NO;
 
1748
    for (NSUInteger i = 0; i < [fTrackers count]; ++i)
1742
1749
    {
1743
 
        id item = [fTrackers objectAtIndex: i];
1744
 
        if ([item isKindOfClass: [NSNumber class]])
 
1750
        id object = [fTrackers objectAtIndex: i];
 
1751
        if ([object isKindOfClass: [NSNumber class]])
1745
1752
        {
1746
 
            for (++i; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; ++i)
1747
 
                [addresses addObject: [[fTrackers objectAtIndex: i] fullAnnounceAddress]];
1748
 
            --i;
 
1753
            groupSelected = [selectedIndexes containsIndex: i];
 
1754
            if (!groupSelected && i > [selectedIndexes lastIndex])
 
1755
                break;
1749
1756
        }
1750
1757
        else
1751
 
            [addresses addObject: [(TrackerNode *)item fullAnnounceAddress]];
 
1758
        {
 
1759
            if (groupSelected || [selectedIndexes containsIndex: i])
 
1760
                [removeIdentifiers addIndex: [(TrackerNode *)object identifier]];
 
1761
        }
1752
1762
    }
1753
1763
    
 
1764
    NSAssert([removeIdentifiers count] > 0, @"Trying to remove no trackers.");
 
1765
    
1754
1766
    if ([[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveTrackers"])
1755
1767
    {
1756
1768
        NSAlert * alert = [[NSAlert alloc] init];
1757
1769
        
1758
 
        if ([addresses count] > 1)
 
1770
        if ([removeIdentifiers count] > 1)
1759
1771
        {
1760
1772
            [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Are you sure you want to remove %d trackers?",
1761
 
                                                                "Remove trackers alert -> title"), [addresses count]]];
 
1773
                                                                "Remove trackers alert -> title"), [removeIdentifiers count]]];
1762
1774
            [alert setInformativeText: NSLocalizedString(@"Once removed, Transmission will no longer attempt to contact them."
1763
1775
                                        " This cannot be undone.", "Remove trackers alert -> message")];
1764
1776
        }
1784
1796
    }
1785
1797
    
1786
1798
    Torrent * torrent = [fTorrents objectAtIndex: 0];
1787
 
    [torrent removeTrackersWithAnnounceAddresses: addresses];
 
1799
    [torrent removeTrackersWithIdentifiers: removeIdentifiers];
1788
1800
    
1789
1801
    //reset table with either new or old value
1790
1802
    [fTrackers release];