Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re #141 #400

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Classes/ASIHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "ASIHTTPRequest.h"

#if TARGET_OS_IPHONE
#import "Reachability.h"
#import "ASIReachability.h"
#import "ASIAuthenticationDialog.h"
#import <MobileCoreServices/MobileCoreServices.h>
#else
Expand Down Expand Up @@ -4667,7 +4667,7 @@ + (void)throttleBandwidthForWWANUsingLimit:(unsigned long)limit

+ (void)registerForNetworkReachabilityNotifications
{
[[Reachability reachabilityForInternetConnection] startNotifier];
[[ASIReachability reachabilityForInternetConnection] startNotifier];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
}

Expand All @@ -4679,7 +4679,7 @@ + (void)unsubscribeFromNetworkReachabilityNotifications

+ (BOOL)isNetworkReachableViaWWAN
{
return ([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == ReachableViaWWAN);
return ([[ASIReachability reachabilityForInternetConnection] currentReachabilityStatus] == ReachableViaWWAN);
}

+ (void)reachabilityChanged:(NSNotification *)note
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ extern NSString *const kInternetConnection;
extern NSString *const kLocalWiFiConnection;
extern NSString *const kReachabilityChangedNotification;

@interface Reachability: NSObject {
@interface ASIReachability: NSObject {

@private
NSString *key_;
Expand All @@ -146,27 +146,27 @@ extern NSString *const kReachabilityChangedNotification;
@property (atomic, copy) NSString *key; // Atomic because network operations are asynchronous.

// Designated Initializer.
- (Reachability *) initWithReachabilityRef: (SCNetworkReachabilityRef) ref;
- (ASIReachability *) initWithReachabilityRef: (SCNetworkReachabilityRef) ref;

// Use to check the reachability of a particular host name.
+ (Reachability *) reachabilityWithHostName: (NSString*) hostName;
+ (ASIReachability *) reachabilityWithHostName: (NSString*) hostName;

// Use to check the reachability of a particular IP address.
+ (Reachability *) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
+ (ASIReachability *) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;

// Use to check whether the default route is available.
// Should be used to, at minimum, establish network connectivity.
+ (Reachability *) reachabilityForInternetConnection;
+ (ASIReachability *) reachabilityForInternetConnection;

// Use to check whether a local wifi connection is available.
+ (Reachability *) reachabilityForLocalWiFi;
+ (ASIReachability *) reachabilityForLocalWiFi;

//Start listening for reachability notifications on the current run loop.
- (BOOL) startNotifier;
- (void) stopNotifier;

// Comparison routines to enable choosing actions in a notification.
- (BOOL) isEqual: (Reachability *) r;
- (BOOL) isEqual: (ASIReachability *) r;

// These are the status tests.
- (NetworkStatus) currentReachabilityStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE

#import <CoreFoundation/CoreFoundation.h>

#import "Reachability.h"
#import "ASIReachability.h"

NSString *const kInternetConnection = @"InternetConnection";
NSString *const kLocalWiFiConnection = @"LocalWiFiConnection";
Expand Down Expand Up @@ -180,13 +180,13 @@ static void logNetworkStatus_(const char *name, int line, NetworkStatus status)
#define logNetworkStatus(status)
#endif

@interface Reachability (private)
@interface ASIReachability (private)

- (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags;

@end

@implementation Reachability
@implementation ASIReachability

@synthesize key = key_;

Expand Down Expand Up @@ -214,7 +214,7 @@ - (void) dealloc {
} // dealloc


- (Reachability *) initWithReachabilityRef: (SCNetworkReachabilityRef) ref
- (ASIReachability *) initWithReachabilityRef: (SCNetworkReachabilityRef) ref
{
self = [super init];
if (self != nil)
Expand Down Expand Up @@ -251,15 +251,15 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach

#pragma unused (target, flags)
NSCAssert(info, @"info was NULL in ReachabilityCallback");
NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was the wrong class in ReachabilityCallback");
NSCAssert([(NSObject*) info isKindOfClass: [ASIReachability class]], @"info was the wrong class in ReachabilityCallback");

//We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
// in case someone uses the Reachablity object in a different thread.
NSAutoreleasePool* pool = [NSAutoreleasePool new];

// Post a notification to notify the client that the network reachability changed.
[[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification
object: (Reachability *) info];
object: (ASIReachability *) info];

[pool release];

Expand Down Expand Up @@ -296,7 +296,7 @@ - (void) stopNotifier {
} // stopNotifier


- (BOOL) isEqual: (Reachability *) r {
- (BOOL) isEqual: (ASIReachability *) r {

return [r.key isEqualToString: self.key];

Expand All @@ -307,13 +307,13 @@ - (BOOL) isEqual: (Reachability *) r {
#pragma mark Reachability Allocation Methods


+ (Reachability *) reachabilityWithHostName: (NSString *) hostName {
+ (ASIReachability *) reachabilityWithHostName: (NSString *) hostName {

SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);

if (ref) {

Reachability *r = [[[self alloc] initWithReachabilityRef: ref] autorelease];
ASIReachability *r = [[[self alloc] initWithReachabilityRef: ref] autorelease];

r.key = hostName;

Expand Down Expand Up @@ -345,13 +345,13 @@ + (NSString *) makeAddressKey: (in_addr_t) addr {
} // makeAddressKey:


+ (Reachability *) reachabilityWithAddress: (const struct sockaddr_in *) hostAddress {
+ (ASIReachability *) reachabilityWithAddress: (const struct sockaddr_in *) hostAddress {

SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);

if (ref) {

Reachability *r = [[[self alloc] initWithReachabilityRef: ref] autorelease];
ASIReachability *r = [[[self alloc] initWithReachabilityRef: ref] autorelease];

r.key = [self makeAddressKey: hostAddress->sin_addr.s_addr];

Expand All @@ -364,14 +364,14 @@ + (Reachability *) reachabilityWithAddress: (const struct sockaddr_in *) hostAdd
} // reachabilityWithAddress


+ (Reachability *) reachabilityForInternetConnection {
+ (ASIReachability *) reachabilityForInternetConnection {

struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;

Reachability *r = [self reachabilityWithAddress: &zeroAddress];
ASIReachability *r = [self reachabilityWithAddress: &zeroAddress];

r.key = kInternetConnection;

Expand All @@ -380,7 +380,7 @@ + (Reachability *) reachabilityForInternetConnection {
} // reachabilityForInternetConnection


+ (Reachability *) reachabilityForLocalWiFi {
+ (ASIReachability *) reachabilityForLocalWiFi {

struct sockaddr_in localWifiAddress;
bzero(&localWifiAddress, sizeof(localWifiAddress));
Expand All @@ -389,7 +389,7 @@ + (Reachability *) reachabilityForLocalWiFi {
// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);

Reachability *r = [self reachabilityWithAddress: &localWifiAddress];
ASIReachability *r = [self reachabilityWithAddress: &localWifiAddress];

r.key = kLocalWiFiConnection;

Expand Down
20 changes: 10 additions & 10 deletions iPhone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
112C25541A67F39D00E7AB8C /* ASIReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 112C25531A67F39D00E7AB8C /* ASIReachability.m */; };
112C25551A67F39D00E7AB8C /* ASIReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 112C25531A67F39D00E7AB8C /* ASIReachability.m */; };
112C25561A67F39D00E7AB8C /* ASIReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 112C25531A67F39D00E7AB8C /* ASIReachability.m */; };
B50C1823121C26DB0055FCAB /* ClientCertificateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B50C1822121C26DB0055FCAB /* ClientCertificateTests.m */; };
B50C182C121C26FA0055FCAB /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B50C182B121C26FA0055FCAB /* Security.framework */; };
B50C1848121C27510055FCAB /* client.p12 in Resources */ = {isa = PBXBuildFile; fileRef = B50C1847121C27510055FCAB /* client.p12 */; };
Expand All @@ -33,9 +36,6 @@
B540400C115114BA00D8BE63 /* ASIS3BucketRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404002115114BA00D8BE63 /* ASIS3BucketRequest.m */; };
B540400D115114BA00D8BE63 /* ASIS3ObjectRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404004115114BA00D8BE63 /* ASIS3ObjectRequest.m */; };
B540400E115114BA00D8BE63 /* ASIS3ServiceRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404006115114BA00D8BE63 /* ASIS3ServiceRequest.m */; };
B55252B411D22E2200F9B170 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B55252B311D22E2200F9B170 /* Reachability.m */; };
B55252B511D22E2200F9B170 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B55252B311D22E2200F9B170 /* Reachability.m */; };
B55252B611D22E2200F9B170 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B55252B311D22E2200F9B170 /* Reachability.m */; };
B558B5EB11C7F9C8009B4627 /* iPadMainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = B576D76311C7F4D40059B815 /* iPadMainWindow.xib */; };
B55B604D0F765A320064029C /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60460F765A320064029C /* ASIFormDataRequest.m */; };
B55B604E0F765A320064029C /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60480F765A320064029C /* ASIHTTPRequest.m */; };
Expand Down Expand Up @@ -142,6 +142,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
112C25521A67F39D00E7AB8C /* ASIReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIReachability.h; sourceTree = "<group>"; };
112C25531A67F39D00E7AB8C /* ASIReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIReachability.m; sourceTree = "<group>"; };
1D6058910D05DD3D006BFB54 /* ASIHTTPRequest iPhone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ASIHTTPRequest iPhone.app"; sourceTree = BUILT_PRODUCTS_DIR; };
B50C1821121C26DB0055FCAB /* ClientCertificateTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientCertificateTests.h; sourceTree = "<group>"; };
B50C1822121C26DB0055FCAB /* ClientCertificateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClientCertificateTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -175,8 +177,6 @@
B5404005115114BA00D8BE63 /* ASIS3ServiceRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIS3ServiceRequest.h; sourceTree = "<group>"; };
B5404006115114BA00D8BE63 /* ASIS3ServiceRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIS3ServiceRequest.m; sourceTree = "<group>"; };
B551DB4610D6938500EC1CBF /* ASIHTTPRequestConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestConfig.h; sourceTree = "<group>"; };
B55252B211D22E2200F9B170 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; };
B55252B311D22E2200F9B170 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = "<group>"; };
B558B58911C7F637009B4627 /* iPhoneInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = iPhoneInfo.plist; path = "iPhone Sample/iPhoneInfo.plist"; sourceTree = "<group>"; };
B558B58B11C7F63E009B4627 /* iPadInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = iPadInfo.plist; path = "iPhone Sample/iPadInfo.plist"; sourceTree = "<group>"; };
B55B60450F765A320064029C /* ASIFormDataRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIFormDataRequest.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -458,8 +458,8 @@
B55252B111D22E2200F9B170 /* Reachability */ = {
isa = PBXGroup;
children = (
B55252B211D22E2200F9B170 /* Reachability.h */,
B55252B311D22E2200F9B170 /* Reachability.m */,
112C25521A67F39D00E7AB8C /* ASIReachability.h */,
112C25531A67F39D00E7AB8C /* ASIReachability.m */,
);
path = Reachability;
sourceTree = "<group>";
Expand Down Expand Up @@ -724,6 +724,7 @@
files = (
B55B604D0F765A320064029C /* ASIFormDataRequest.m in Sources */,
B55B604E0F765A320064029C /* ASIHTTPRequest.m in Sources */,
112C25541A67F39D00E7AB8C /* ASIReachability.m in Sources */,
B55B604F0F765A320064029C /* ASINetworkQueue.m in Sources */,
B55B60620F765A750064029C /* main.m in Sources */,
B55B606F0F765A930064029C /* QueueViewController.m in Sources */,
Expand All @@ -737,7 +738,6 @@
B5BD2B0511CA542000D7C426 /* InfoCell.m in Sources */,
B5BD2B0611CA542000D7C426 /* ToggleCell.m in Sources */,
B5BD2B0E11CA542700D7C426 /* SampleViewController.m in Sources */,
B55252B511D22E2200F9B170 /* Reachability.m in Sources */,
B5FE752811DBBA6400F898C8 /* ASIDownloadCache.m in Sources */,
B53E6D971257B45800C1E79A /* ASIDataDecompressor.m in Sources */,
B53E6D981257B45800C1E79A /* ASIDataCompressor.m in Sources */,
Expand Down Expand Up @@ -769,6 +769,7 @@
B5873FD910FF28CA001E145F /* ASICloudFilesCDNRequest.m in Sources */,
B5873FDA10FF28CA001E145F /* ASICloudFilesContainer.m in Sources */,
B5873FDB10FF28CA001E145F /* ASICloudFilesContainerRequest.m in Sources */,
112C25551A67F39D00E7AB8C /* ASIReachability.m in Sources */,
B5873FDC10FF28CA001E145F /* ASICloudFilesContainerXMLParserDelegate.m in Sources */,
B5873FDD10FF28CA001E145F /* ASICloudFilesObject.m in Sources */,
B5873FDE10FF28CA001E145F /* ASICloudFilesObjectRequest.m in Sources */,
Expand All @@ -778,7 +779,6 @@
B540400C115114BA00D8BE63 /* ASIS3BucketRequest.m in Sources */,
B540400D115114BA00D8BE63 /* ASIS3ObjectRequest.m in Sources */,
B540400E115114BA00D8BE63 /* ASIS3ServiceRequest.m in Sources */,
B55252B411D22E2200F9B170 /* Reachability.m in Sources */,
B5FE752711DBBA6400F898C8 /* ASIDownloadCache.m in Sources */,
B51A1A9B11DDF85100ED75CF /* ASIDownloadCacheTests.m in Sources */,
B50C1823121C26DB0055FCAB /* ClientCertificateTests.m in Sources */,
Expand Down Expand Up @@ -811,8 +811,8 @@
B5BD2B0311CA542000D7C426 /* ToggleCell.m in Sources */,
B5BD2B0B11CA542700D7C426 /* RootViewController.m in Sources */,
B5BD2B0C11CA542700D7C426 /* SampleViewController.m in Sources */,
B55252B611D22E2200F9B170 /* Reachability.m in Sources */,
B5FE752911DBBA6400F898C8 /* ASIDownloadCache.m in Sources */,
112C25561A67F39D00E7AB8C /* ASIReachability.m in Sources */,
B53E6D991257B45800C1E79A /* ASIDataDecompressor.m in Sources */,
B53E6D9A1257B45800C1E79A /* ASIDataCompressor.m in Sources */,
B57AF5931258B3F1002A1F0C /* WebPageViewController.m in Sources */,
Expand Down