Changeset 6734


Ignore:
Timestamp:
Sep 6, 2008, 9:57:13 PM (13 years ago)
Author:
livings124
Message:

if delay is off, perform the port check probe without any timer; on 10.5, set the port checker to ignore remote cache data on top of local cache data

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PortChecker.m

    r6733 r6734  
    2929#define CHECK_FIRE  3.0
    3030
     31@interface PortChecker (Private)
     32
     33- (void) startProbe;
     34
     35@end
     36
    3137@implementation PortChecker
    3238
     
    4046        fStatus = PORT_STATUS_CHECKING;
    4147       
    42         fTimer = [NSTimer scheduledTimerWithTimeInterval: (delay ? CHECK_FIRE : 0.1) target: self
    43                     selector: @selector(startProbe) userInfo: nil repeats: NO];
     48        if (delay)
     49            fTimer = [NSTimer scheduledTimerWithTimeInterval: CHECK_FIRE target: self
     50                        selector: @selector(startProbe) userInfo: nil repeats: NO];
     51        else
     52            [self startProbe];
    4453    }
    4554   
     
    6170}
    6271
    63 - (void) startProbe
    64 {
    65     fTimer = nil;
    66    
    67     NSURLRequest * portProbeRequest = [NSURLRequest requestWithURL: [NSURL URLWithString:
    68                 [NSString stringWithFormat: CHECKER_URL, fPortNumber]] cachePolicy:
    69                 [NSApp isOnLeopardOrBetter] ? NSURLRequestReloadIgnoringLocalCacheData : NSURLRequestReloadIgnoringCacheData
    70                 timeoutInterval: 15.0];
    71    
    72     if ((fConnection = [[NSURLConnection alloc] initWithRequest: portProbeRequest delegate: self]))
    73         fPortProbeData = [[NSMutableData alloc] init];
    74     else
    75     {
    76         NSLog(@"Unable to get port status: failed to initiate connection");
    77         [self callBackWithStatus: PORT_STATUS_ERROR];
    78     }
    79 }
    80 
    8172- (void) cancelProbe
    8273{
     
    9485        [fDelegate performSelectorOnMainThread: @selector(portCheckerDidFinishProbing:) withObject: self waitUntilDone: NO];
    9586}
    96 
    97 #pragma mark NSURLConnection delegate methods
    9887
    9988- (void) connection: (NSURLConnection *) connection didReceiveResponse: (NSURLResponse *) response
     
    140129
    141130@end
     131
     132@implementation PortChecker (Private)
     133
     134- (void) startProbe
     135{
     136    fTimer = nil;
     137   
     138    NSURLRequest * portProbeRequest = [NSURLRequest requestWithURL: [NSURL URLWithString:
     139                [NSString stringWithFormat: CHECKER_URL, fPortNumber]] cachePolicy:
     140                [NSApp isOnLeopardOrBetter] ? NSURLRequestReloadIgnoringLocalAndRemoteCacheData : NSURLRequestReloadIgnoringCacheData
     141                timeoutInterval: 15.0];
     142   
     143    if ((fConnection = [[NSURLConnection alloc] initWithRequest: portProbeRequest delegate: self]))
     144        fPortProbeData = [[NSMutableData alloc] init];
     145    else
     146    {
     147        NSLog(@"Unable to get port status: failed to initiate connection");
     148        [self callBackWithStatus: PORT_STATUS_ERROR];
     149    }
     150}
     151
     152@end
     153
  • trunk/macosx/PrefsController.m

    r6733 r6734  
    366366            [fPortChecker release];
    367367        }
    368         fPortChecker = [[PortChecker alloc] initForPort: fPeerPort
    369             delay: tr_sessionIsPortForwardingEnabled(fHandle) withDelegate: self];
     368        fPortChecker = [[PortChecker alloc] initForPort: fPeerPort delay: tr_sessionIsPortForwardingEnabled(fHandle) withDelegate: self];
    370369    }
    371370}
Note: See TracChangeset for help on using the changeset viewer.