Skip to content

Commit

Permalink
[CHANGE] Update SCNetworkCheckReachabilityByName (deprecated in 10.6)…
Browse files Browse the repository at this point in the history
… to SCNetworkReachabilityCreateWithName+SCNetworkReachabilityGetFlags. [ticket 11](http://rentzsch.lighthouseapp.com/projects/24800/tickets/11) (Justin Williams)
  • Loading branch information
rentzsch committed Dec 2, 2009
1 parent 5860044 commit b8f0b35
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/JRFeedbackController.m
Expand Up @@ -9,6 +9,7 @@
#import <AddressBook/AddressBook.h>
#import "NSURLRequest+postForm.h"
#import <SystemConfiguration/SCNetwork.h>
#import <SystemConfiguration/SystemConfiguration.h>

#if USE_GROWL
#import <Growl/GrowlApplicationBridge.h>
Expand All @@ -34,9 +35,16 @@ + (void)showFeedback {

+ (void)showFeedbackWithBugDetails:(NSString *)details {
SCNetworkConnectionFlags reachabilityFlags;
Boolean reachabilityResult = SCNetworkCheckReachabilityByName([[[JRFeedbackController postURL] host] UTF8String], &reachabilityFlags);

//NSLog(@"reachabilityFlags: %lx", reachabilityFlags);
const char *hostname = [[[JRFeedbackController postURL] host] UTF8String];
#ifdef MAC_OS_X_VERSION_10_6
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, hostname);
Boolean reachabilityResult = SCNetworkReachabilityGetFlags(reachability, &reachabilityFlags);
CFRelease(reachability);
#else
Boolean reachabilityResult = SCNetworkCheckReachabilityByName(hostname, &reachabilityFlags);
#endif

// NSLog(@"reachabilityFlags: %lx", reachabilityFlags);
BOOL showFeedbackWindow = reachabilityResult
&& (reachabilityFlags & kSCNetworkFlagsReachable)
&& !(reachabilityFlags & kSCNetworkFlagsConnectionRequired)
Expand Down

3 comments on commit b8f0b35

@seanm
Copy link

@seanm seanm commented on b8f0b35 Feb 19, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rentzsch, I get that SCNetworkCheckReachabilityByName() is deprecated, but why is the replacement code in an "#ifdef MAC_OS_X_VERSION_10_6"? All the APIs used there seem to be available back to 10.3. Thanks. Sean.

@rentzsch
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCNetworkReachabilityCreateWithName+SCNetworkReachabilityGetFlags are available since 10.3?

@seanm
Copy link

@seanm seanm commented on b8f0b35 Feb 19, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so says SCNetworkReachability.h

Please sign in to comment.