diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 8ae514800..747b5ed8c 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -539,10 +539,13 @@ typedef enum int maxPeers = [torrent maxPeerConnect]; - while ((torrent = [enumerator nextObject]) && maxPeers != INVALID) + while ((torrent = [enumerator nextObject])) { - if (/*maxPeers != INVALID &&*/ maxPeers != [torrent maxPeerConnect]) + if (maxPeers != [torrent maxPeerConnect]) + { maxPeers = INVALID; + break; + } } //set peer view diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index 98614867c..8f8c4eeb8 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -57,7 +57,6 @@ [super dealloc]; } -#warning don't update when the window is closed - (void) awakeFromNib { NSWindow * window = [self window]; diff --git a/macosx/PortChecker.h b/macosx/PortChecker.h index 2f9dd22df..a8846cb0a 100644 --- a/macosx/PortChecker.h +++ b/macosx/PortChecker.h @@ -34,11 +34,14 @@ typedef enum @interface PortChecker : NSObject { - id fDelegate; - port_status_t fStatus; + id fDelegate; + port_status_t fStatus; + int fPortNumber; NSURLConnection * fConnection; - NSMutableData * fPortProbeData; + NSMutableData * fPortProbeData; + + NSTimer * fTimer; } - (id) initForPort: (int) portNumber withDelegate: (id) delegate; diff --git a/macosx/PortChecker.m b/macosx/PortChecker.m index 7ad5a1b80..28f06a46e 100644 --- a/macosx/PortChecker.m +++ b/macosx/PortChecker.m @@ -26,6 +26,7 @@ #import "NSApplicationAdditions.h" #define CHECKER_URL @"http://transmission.m0k.org/PortCheck.php?port=%d" +#define CHECK_FIRE 3.0 @implementation PortChecker @@ -35,20 +36,11 @@ { fDelegate = delegate; - NSURLRequest * portProbeRequest = [NSURLRequest requestWithURL: [NSURL URLWithString: - [NSString stringWithFormat: CHECKER_URL, portNumber]] cachePolicy: - [NSApp isOnLeopardOrBetter] ? NSURLRequestReloadIgnoringLocalCacheData : NSURLRequestReloadIgnoringCacheData - timeoutInterval: 15.0]; - + fPortNumber = portNumber; fStatus = PORT_STATUS_CHECKING; - if ((fConnection = [[NSURLConnection alloc] initWithRequest: portProbeRequest delegate: self])) - fPortProbeData = [[NSMutableData alloc] init]; - else - { - NSLog(@"Unable to get port status: failed to initiate connection"); - [self callBackWithStatus: PORT_STATUS_ERROR]; - } + fTimer = [NSTimer scheduledTimerWithTimeInterval: CHECK_FIRE target: self selector: @selector(startProbe) + userInfo: nil repeats: NO]; } return self; @@ -56,6 +48,8 @@ - (void) dealloc { + [fTimer invalidate]; + [fConnection release]; [fPortProbeData release]; [super dealloc]; @@ -66,8 +60,27 @@ return fStatus; } +- (void) startProbe +{ + fTimer = nil; + + NSURLRequest * portProbeRequest = [NSURLRequest requestWithURL: [NSURL URLWithString: + [NSString stringWithFormat: CHECKER_URL, fPortNumber]] cachePolicy: + [NSApp isOnLeopardOrBetter] ? NSURLRequestReloadIgnoringLocalCacheData : NSURLRequestReloadIgnoringCacheData + timeoutInterval: 15.0]; + + if ((fConnection = [[NSURLConnection alloc] initWithRequest: portProbeRequest delegate: self])) + fPortProbeData = [[NSMutableData alloc] init]; + else + { + NSLog(@"Unable to get port status: failed to initiate connection"); + [self callBackWithStatus: PORT_STATUS_ERROR]; + } +} + - (void) endProbe { + [fTimer invalidate]; [fConnection cancel]; } diff --git a/macosx/StatsWindowController.m b/macosx/StatsWindowController.m index 3c6922013..bd340baf6 100644 --- a/macosx/StatsWindowController.m +++ b/macosx/StatsWindowController.m @@ -64,7 +64,7 @@ tr_handle * fLib; { [fTimer invalidate]; - [fStatsWindowInstance release]; + [fStatsWindowInstance release]; fStatsWindowInstance = nil; } diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 7f1de3bc2..48c8b3a14 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -700,6 +700,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * return fInfo->isPrivate; } +#warning not working - (NSString *) torrentLocation { return [NSString stringWithUTF8String: fInfo->torrent];