begin the reorganization of the inspector tracker tab - a lot still left to do

This commit is contained in:
Mitchell Livingston 2009-09-26 04:02:39 +00:00
parent 28e119c1bb
commit 06df79d02f
8 changed files with 241 additions and 1005 deletions

View File

@ -79,6 +79,7 @@
A21282A80CA6C66800EAEE0F /* StatusBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = A21282A60CA6C66800EAEE0F /* StatusBarView.m */; };
A215BF5C0F02EBB800350CDB /* GroupRules.xib in Resources */ = {isa = PBXBuildFile; fileRef = A215BF5B0F02EBB800350CDB /* GroupRules.xib */; };
A219798B0D07B78400438EA7 /* GroupToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A219798A0D07B78400438EA7 /* GroupToolbarItem.m */; };
A21A9BE2106D86A800F1C3C1 /* TrackerNode.m in Sources */ = {isa = PBXBuildFile; fileRef = A21A9BE1106D86A800F1C3C1 /* TrackerNode.m */; };
A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
A21FBBAB0EDA78C300BC3C51 /* bandwidth.h in Headers */ = {isa = PBXBuildFile; fileRef = A21FBBA90EDA78C300BC3C51 /* bandwidth.h */; };
A21FBBAC0EDA78C300BC3C51 /* bandwidth.c in Sources */ = {isa = PBXBuildFile; fileRef = A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */; };
@ -486,6 +487,8 @@
A215BF5D0F02EBB800350CDB /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = macosx/en.lproj/GroupRules.xib; sourceTree = "<group>"; };
A21979890D07B78400438EA7 /* GroupToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GroupToolbarItem.h; path = macosx/GroupToolbarItem.h; sourceTree = "<group>"; };
A219798A0D07B78400438EA7 /* GroupToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GroupToolbarItem.m; path = macosx/GroupToolbarItem.m; sourceTree = "<group>"; };
A21A9BE0106D86A800F1C3C1 /* TrackerNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TrackerNode.h; path = macosx/TrackerNode.h; sourceTree = "<group>"; };
A21A9BE1106D86A800F1C3C1 /* TrackerNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TrackerNode.m; path = macosx/TrackerNode.m; sourceTree = "<group>"; };
A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
A21FBBA90EDA78C300BC3C51 /* bandwidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bandwidth.h; path = libtransmission/bandwidth.h; sourceTree = "<group>"; };
A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bandwidth.c; path = libtransmission/bandwidth.c; sourceTree = "<group>"; };
@ -901,6 +904,8 @@
080E96DDFE201D6D7F000001 /* Sources */ = {
isa = PBXGroup;
children = (
A21A9BE0106D86A800F1C3C1 /* TrackerNode.h */,
A21A9BE1106D86A800F1C3C1 /* TrackerNode.m */,
32CA4F630368D1EE00C91783 /* Transmission_Prefix.pch */,
29B97316FDCFA39411CA2CEA /* main.m */,
A29D84021049C25600D1987A /* NSApplicationAdditions.h */,
@ -1990,6 +1995,7 @@
A232F07E0EEA034A00041646 /* BonjourController.m in Sources */,
A23F526F0F14395900AA02E3 /* PredicateEditorRowTemplateAny.m in Sources */,
A29D84041049C25600D1987A /* NSApplicationAdditions.m in Sources */,
A21A9BE2106D86A800F1C3C1 /* TrackerNode.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -34,7 +34,6 @@
@interface InfoWindowController : NSWindowController <QLPreviewPanelDataSource, QLPreviewPanelDelegate>
{
NSArray * fTorrents;
NSMutableArray * fTrackers;
IBOutlet NSView * fInfoView, * fActivityView, * fTrackerView, * fPeersView, * fFilesView, * fOptionsView;
NSInteger fCurrentTabTag;
@ -55,8 +54,6 @@
IBOutlet TrackerTableView * fTrackerTable;
IBOutlet NSSegmentedControl * fTrackerAddRemoveControl;
IBOutlet NSTextField * fAnnounceAddressField, * fAnnounceLastField, * fAnnounceResponseField, * fAnnounceNextField,
* fScrapeAddressField, * fScrapeLastField, * fScrapeResponseField, * fScrapeNextField;
NSArray * fPeers, * fWebSeeds;
IBOutlet NSTableView * fPeerTable, * fWebSeedTable;
@ -77,6 +74,7 @@
* fUploadLimitLabel, * fDownloadLimitLabel, * fPeersConnectLabel,
* fPeersConnectField;
NSArray * fTrackers;
NSCache * fTrackerIconCache;
NSMutableSet * fTrackerIconLoading;

View File

@ -23,16 +23,17 @@
*****************************************************************************/
#import "InfoWindowController.h"
#import "Torrent.h"
#import "InfoTabButtonCell.h"
#import "FileOutlineView.h"
#import "FileOutlineController.h"
#import "FileListNode.h"
#import "PeerProgressIndicatorCell.h"
#import "TrackerTableView.h"
#import "PiecesView.h"
#import "FileOutlineController.h"
#import "FileOutlineView.h"
#import "InfoTabButtonCell.h"
#import "NSApplicationAdditions.h"
#import "NSStringAdditions.h"
#import "PeerProgressIndicatorCell.h"
#import "PiecesView.h"
#import "Torrent.h"
#import "TrackerNode.h"
#import "TrackerTableView.h"
#include "utils.h" //tr_getRatio()
#define TAB_INFO_IDENT @"Info"
@ -86,8 +87,8 @@ typedef enum
- (BOOL) canQuickLook;
- (BOOL) canQuickLookFile: (FileListNode *) item;
- (void) addTrackers;
- (void) removeTrackers;
/*- (void) addTrackers;
- (void) removeTrackers;*/
@end
@ -355,24 +356,6 @@ typedef enum
[fErrorMessageView setString: @""];
[fErrorMessageView setSelectable: NO];
[fAnnounceAddressField setStringValue: @""];
[fAnnounceAddressField setToolTip: nil];
[fAnnounceAddressField setSelectable: NO];
[fAnnounceLastField setStringValue: @""];
[fAnnounceResponseField setStringValue: @""];
[fAnnounceResponseField setToolTip: nil];
[fAnnounceResponseField setSelectable: NO];
[fAnnounceNextField setStringValue: @""];
[fScrapeAddressField setStringValue: @""];
[fScrapeAddressField setToolTip: nil];
[fScrapeAddressField setSelectable: NO];
[fScrapeLastField setStringValue: @""];
[fScrapeResponseField setStringValue: @""];
[fScrapeResponseField setToolTip: nil];
[fScrapeResponseField setSelectable: NO];
[fScrapeNextField setStringValue: @""];
[fConnectedPeersField setStringValue: @""];
[fDownloadingFromField setStringValue: @""];
[fUploadingToField setStringValue: @""];
@ -401,6 +384,9 @@ typedef enum
[fTrackers release];
fTrackers = nil;
[fTrackerTable reloadData];
[fTrackerTable setTrackers: nil];
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_ADD_TAG];
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
@ -467,8 +453,6 @@ typedef enum
[fCommentView setSelectable: ![commentString isEqualToString: @""]];
[fCreatorField setSelectable: ![creatorString isEqualToString: @""]];
[fDataLocationField setSelectable: YES];
[fAnnounceAddressField setSelectable: YES];
[fScrapeAddressField setSelectable: YES];
//set pieces view
BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
@ -487,12 +471,7 @@ typedef enum
[fWebSeedTable reloadData];
}
//get trackers for table
[fTrackers release];
#warning fix!
fTrackers = [[torrent allTrackers: YES] retain];
[fTrackerTable deselectAll: self];
[fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
@ -504,10 +483,6 @@ typedef enum
//update stats and settings
[self updateInfoStats];
[self updateOptions];
//reload tables that won't change every update
[fTrackerTable setTrackers: fTrackers];
[fTrackerTable reloadData];
}
- (void) updateInfoStats
@ -924,9 +899,9 @@ typedef enum
if ([ident isEqualToString: @"Icon"])
{
NSAssert([item isKindOfClass: [NSString class]], @"Value passed to tracker table's icon row is not a string!");
NSAssert([item isKindOfClass: [TrackerNode class]], @"Value passed to tracker table's icon row is not a TrackerNode!");
NSURL * address = [NSURL URLWithString: item];
NSURL * address = [NSURL URLWithString: [(TrackerNode *)item host]];
NSArray * hostComponents = [[address host] componentsSeparatedByString: @"."];
//let's try getting the tracker address without using any subdomains
@ -947,7 +922,7 @@ typedef enum
return (icon && icon != [NSNull null]) ? icon : [NSImage imageNamed: @"FavIcon.png"];
}
if ([ident isEqualToString: @"Address"])
return item;
return [(TrackerNode *)item host];
else
return [NSString stringWithFormat: NSLocalizedString(@"Tier %d", "Inspector -> tracker table"), [item integerValue]];
}
@ -1133,6 +1108,7 @@ typedef enum
}
#warning fix!
#if 0
- (void) tableView: (NSTableView *) tableView setObjectValue: (id) object forTableColumn: (NSTableColumn *) tableColumn
row: (NSInteger) row
{
@ -1153,19 +1129,21 @@ typedef enum
[fTrackerTable setTrackers: fTrackers];
[fTrackerTable reloadData];
}
#endif
- (void) addRemoveTracker: (id) sender
{
//don't allow add/remove when currently adding - it leads to weird results
/* //don't allow add/remove when currently adding - it leads to weird results
if ([fTrackerTable editedRow] != -1)
return;
if ([[sender cell] tagForSegment: [sender selectedSegment]] == TRACKER_REMOVE_TAG)
[self removeTrackers];
else
[self addTrackers];
[self addTrackers];*/
}
#warning what?!
- (BOOL) tableView: (NSTableView *) tableView shouldEditTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
{
if (tableView != fTrackerTable)
@ -1502,71 +1480,16 @@ typedef enum
#warning fix!
- (void) updateInfoTracker
{
/*if ([fTorrents count] != 1)
if ([fTorrents count] != 1)
return;
Torrent * torrent = [fTorrents objectAtIndex: 0];
//announce fields
NSString * announceAddress = [torrent trackerAddressAnnounce];
[fAnnounceAddressField setStringValue: announceAddress];
[fAnnounceAddressField setToolTip: announceAddress];
//get update tracker stats
[fTrackers release];
fTrackers = [[torrent allTrackerStats] retain];
[fAnnounceLastField setObjectValue: [torrent lastAnnounceTime]];
NSString * announceResponse = [torrent announceResponse];
[fAnnounceResponseField setStringValue: announceResponse];
[fAnnounceResponseField setToolTip: announceResponse];
[fAnnounceResponseField setSelectable: ![announceResponse isEqualToString: @""]];
NSInteger announceNext = [torrent nextAnnounceTime];
NSString * announceNextString;
switch (announceNext)
{
case STAT_TIME_NOW:
announceNextString = [NSLocalizedString(@"In progress", "Inspector -> tracker tab") stringByAppendingEllipsis];
break;
case STAT_TIME_NONE:
announceNextString = @"";
break;
default:
announceNextString = [NSString timeString: announceNext showSeconds: YES];
}
[fAnnounceNextField setStringValue: announceNextString];
//scrape fields
NSString * scrapeAddress;
if ((scrapeAddress = [torrent trackerAddressScrape]))
{
[fScrapeAddressField setStringValue: scrapeAddress];
[fScrapeAddressField setToolTip: scrapeAddress];
}
else
{
[fScrapeAddressField setStringValue: @""];
[fScrapeAddressField setToolTip: @""];
}
[fScrapeLastField setObjectValue: [torrent lastScrapeTime]];
NSString * scrapeResponse = [torrent scrapeResponse];
[fScrapeResponseField setStringValue: scrapeResponse];
[fScrapeResponseField setToolTip: scrapeResponse];
[fScrapeResponseField setSelectable: ![scrapeResponse isEqualToString: @""]];
NSInteger scrapeNext = [torrent nextScrapeTime];
NSString * scrapeNextString;
switch (scrapeNext)
{
case STAT_TIME_NOW:
scrapeNextString = [NSLocalizedString(@"In progress", "Inspector -> tracker tab") stringByAppendingEllipsis];
break;
case STAT_TIME_NONE:
scrapeNextString = @"";
break;
default:
scrapeNextString = [NSString timeString: scrapeNext showSeconds: YES];
}
[fScrapeNextField setStringValue: scrapeNextString];*/
[fTrackerTable setTrackers: fTrackers];
[fTrackerTable reloadData];
}
- (void) updateInfoPeers
@ -1794,6 +1717,8 @@ typedef enum
return [item isFolder] || [torrent fileProgress: item] == 1.0;
}
#if 0
#warning doesn't like blank addresses
- (void) addTrackers
{
@ -1902,4 +1827,6 @@ typedef enum
[fTrackerTable reloadData];
}
#endif
@end

View File

@ -28,6 +28,7 @@
@class FileListNode;
#warning remove!?
#define STAT_TIME_NONE -1
#define STAT_TIME_NOW -2
@ -141,10 +142,10 @@
- (NSInteger) nextScrapeTime;
- (NSString *) scrapeResponse;*/
- (NSMutableArray *) allTrackers: (BOOL) separators;
- (NSArray *) allTrackersFlat;
- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;
- (NSArray *) allTrackerStats;
- (NSArray *) allTrackersFlat; //used by GroupRules
/*- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;*/
- (NSString *) comment;
- (NSString *) creator;

View File

@ -26,6 +26,7 @@
#import "GroupsController.h"
#import "FileListNode.h"
#import "NSStringAdditions.h"
#import "TrackerNode.h"
#import "utils.h" //tr_httpIsValidURL
@interface Torrent (Private)
@ -739,32 +740,40 @@ int trashDataFile(const char * filename)
return [NSString stringWithUTF8String: fStat->scrapeResponse];
}*/
- (NSMutableArray *) allTrackers: (BOOL) separators
- (NSArray *) allTrackerStats
{
const NSInteger count = fInfo->trackerCount;
const NSInteger capacity = (separators && count > 0) ? count + fInfo->trackers[count-1].tier + 1 : count;
NSMutableArray * allTrackers = [NSMutableArray arrayWithCapacity: capacity];
int count;
tr_tracker_stat * stats = tr_torrentTrackers(fHandle, &count);
for (NSInteger i = 0, tier = -1; i < count; i++)
NSMutableArray * trackers = [NSMutableArray arrayWithCapacity: count + stats[count-1].tier + 1];
int prevTier = -1;
for (int i=0; i < count; ++i)
{
if (separators && tier != fInfo->trackers[i].tier)
if (stats[i].tier != prevTier)
{
tier = fInfo->trackers[i].tier;
[allTrackers addObject: [NSNumber numberWithInteger: tier + 1]];
[trackers addObject: [NSNumber numberWithInteger: stats[i].tier]];
prevTier = stats[i].tier;
}
[allTrackers addObject: [NSString stringWithUTF8String: fInfo->trackers[i].announce]];
TrackerNode * tracker = [[TrackerNode alloc] initWithTrackerStat: stats[i]];
[trackers addObject: tracker];
[tracker release];
}
return allTrackers;
tr_torrentTrackersFree(stats, count);
return trackers;
}
- (NSArray *) allTrackersFlat
{
return [self allTrackers: NO];
NSMutableArray * allTrackers = [NSMutableArray arrayWithCapacity: fInfo->trackerCount];
for (NSInteger i = 0, tier = -1; i < fInfo->trackerCount; i++)
[allTrackers addObject: [NSString stringWithUTF8String: fInfo->trackers[i].announce]];
}
- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers
/*- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers
{
NSString * tracker = [trackers lastObject];
tracker = [tracker stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
@ -786,7 +795,7 @@ int trashDataFile(const char * filename)
- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers
{
[self updateAllTrackers: trackers];
}
}*/
- (NSString *) comment
{

70
macosx/TrackerNode.h Normal file
View File

@ -0,0 +1,70 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2009 Transmission authors and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import <transmission.h>
@interface TrackerNode : NSObject
{
tr_tracker_stat fStat;
}
- (id) initWithTrackerStat: (tr_tracker_stat) stat;
- (NSString *) host;
#if 0
- (BOOL) isActive;
- (int) tier;
- (BOOL) isAnnouncing;
- (BOOL) hasAnnounced;
- (BOOL) willAnnounce;
- (NSDate *) nextAnnounceDate;
- (BOOL) isScraping;
- (BOOL) hasScraped;
- (BOOL) willScrape;
- (NSDate *) nextScrapeDate;
- (int) lastAnnouncePeerCount;
- (NSString *) lastAnnounceResult;
- (NSDate *) lastAnnounceStartDate;
- (BOOL) lastAnnounceSucceeded;
- (NSDate *) lastAnnounceDate;
- (NSString *) lastScrapeResult;
- (NSDate *) lastScrapeDate;
- (NSDate *) lastScrapeStartDate;
- (BOOL) lastScrapeSucceeded;
- (NSDate *) lastScrapeDate;
- (int) seederCount;
- (int) leecherCount;
- (int) downloadCount;
#endif
@end

44
macosx/TrackerNode.m Normal file
View File

@ -0,0 +1,44 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2009 Transmission authors and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#import "TrackerNode.h"
@implementation TrackerNode
- (id) initWithTrackerStat: (tr_tracker_stat) stat
{
if ((self = [super init]))
{
fStat = stat;
}
return self;
}
- (NSString *) host
{
return [NSString stringWithUTF8String: fStat.host];
}
@end

File diff suppressed because it is too large Load Diff