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 $
4
* Copyright (c) 2006-2009 Transmission authors and contributors
4
* Copyright (c) 2006-2010 Transmission authors and contributors
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"),
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];
872
873
Torrent * torrent= [fTorrents objectAtIndex: 0];
873
if (![torrent addTrackerToNewTier: object])
876
for (NSString * tracker in [object componentsSeparatedByString: @"\n"])
877
if ([torrent addTrackerToNewTier: tracker])
876
883
//reset table with either new or old value
1254
1261
[fCreatorField setStringValue: @""];
1255
1262
[fDateCreatedField setStringValue: @""];
1256
[fCommentView setSelectable: NO];
1258
1264
[fDataLocationField setStringValue: @""];
1259
1265
[fDataLocationField setToolTip: nil];
1261
1267
[fRevealDataButton setHidden: YES];
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];
1367
1372
[fDateAddedField setObjectValue: [torrent dateAdded]];
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];
1374
1379
//set pieces view
1375
1380
BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
1413
1424
NSString * location = [torrent dataLocation];
1414
1425
[fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
1415
1426
[fDataLocationField setToolTip: location ? location : @""];
1416
[fDataLocationField setSelectable: location != nil];
1418
1428
[fRevealDataButton setHidden: !location];
1474
1484
NSString * errorMessage = [torrent errorMessage];
1475
1485
if (![errorMessage isEqualToString: [fErrorMessageView string]])
1477
1486
[fErrorMessageView setString: errorMessage];
1478
[fErrorMessageView setSelectable: ![errorMessage isEqualToString: @""]];
1481
1488
[fDateCompletedField setObjectValue: [torrent dateCompleted]];
1735
1742
- (void) removeTrackers
1737
const NSInteger oldCount = [fTrackers count] - [(TrackerNode *)[fTrackers lastObject] tier];
1738
NSMutableSet * addresses = [NSMutableSet setWithCapacity: oldCount];
1744
NSMutableIndexSet * removeIdentifiers = [NSMutableIndexSet indexSet];
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)
1743
id item = [fTrackers objectAtIndex: i];
1744
if ([item isKindOfClass: [NSNumber class]])
1750
id object = [fTrackers objectAtIndex: i];
1751
if ([object isKindOfClass: [NSNumber class]])
1746
for (++i; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; ++i)
1747
[addresses addObject: [[fTrackers objectAtIndex: i] fullAnnounceAddress]];
1753
groupSelected = [selectedIndexes containsIndex: i];
1754
if (!groupSelected && i > [selectedIndexes lastIndex])
1751
[addresses addObject: [(TrackerNode *)item fullAnnounceAddress]];
1759
if (groupSelected || [selectedIndexes containsIndex: i])
1760
[removeIdentifiers addIndex: [(TrackerNode *)object identifier]];
1764
NSAssert([removeIdentifiers count] > 0, @"Trying to remove no trackers.");
1754
1766
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveTrackers"])
1756
1768
NSAlert * alert = [[NSAlert alloc] init];
1758
if ([addresses count] > 1)
1770
if ([removeIdentifiers count] > 1)
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")];
1786
1798
Torrent * torrent = [fTorrents objectAtIndex: 0];
1787
[torrent removeTrackersWithAnnounceAddresses: addresses];
1799
[torrent removeTrackersWithIdentifiers: removeIdentifiers];
1789
1801
//reset table with either new or old value
1790
1802
[fTrackers release];