Removing Unused QReachabilityOperation class
This commit is contained in:
parent
0c9a04bce3
commit
c75ebd3e81
@ -18,7 +18,6 @@
|
||||
F8E469911395742500DB05C8 /* AFURLCache.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E4698B1395742500DB05C8 /* AFURLCache.m */; };
|
||||
F8E469921395742500DB05C8 /* UIImage+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E4698D1395742500DB05C8 /* UIImage+AFNetworking.m */; };
|
||||
F8E469A9139574DA00DB05C8 /* QHTTPOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E469A4139574DA00DB05C8 /* QHTTPOperation.m */; };
|
||||
F8E469AA139574DA00DB05C8 /* QReachabilityOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E469A6139574DA00DB05C8 /* QReachabilityOperation.m */; };
|
||||
F8E469AB139574DA00DB05C8 /* QRunLoopOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E469A8139574DA00DB05C8 /* QRunLoopOperation.m */; };
|
||||
F8E469B31395752400DB05C8 /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E469B21395752400DB05C8 /* JSONKit.m */; };
|
||||
F8E469BC139575D000DB05C8 /* AFGowallaAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E469B9139575D000DB05C8 /* AFGowallaAPI.m */; };
|
||||
@ -56,8 +55,6 @@
|
||||
F8E4698D1395742500DB05C8 /* UIImage+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+AFNetworking.m"; sourceTree = "<group>"; };
|
||||
F8E469A3139574DA00DB05C8 /* QHTTPOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QHTTPOperation.h; sourceTree = "<group>"; };
|
||||
F8E469A4139574DA00DB05C8 /* QHTTPOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QHTTPOperation.m; sourceTree = "<group>"; };
|
||||
F8E469A5139574DA00DB05C8 /* QReachabilityOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QReachabilityOperation.h; sourceTree = "<group>"; };
|
||||
F8E469A6139574DA00DB05C8 /* QReachabilityOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QReachabilityOperation.m; sourceTree = "<group>"; };
|
||||
F8E469A7139574DA00DB05C8 /* QRunLoopOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRunLoopOperation.h; sourceTree = "<group>"; };
|
||||
F8E469A8139574DA00DB05C8 /* QRunLoopOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRunLoopOperation.m; sourceTree = "<group>"; };
|
||||
F8E469B11395752400DB05C8 /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = "<group>"; };
|
||||
@ -190,8 +187,6 @@
|
||||
children = (
|
||||
F8E469A3139574DA00DB05C8 /* QHTTPOperation.h */,
|
||||
F8E469A4139574DA00DB05C8 /* QHTTPOperation.m */,
|
||||
F8E469A5139574DA00DB05C8 /* QReachabilityOperation.h */,
|
||||
F8E469A6139574DA00DB05C8 /* QReachabilityOperation.m */,
|
||||
F8E469A7139574DA00DB05C8 /* QRunLoopOperation.h */,
|
||||
F8E469A8139574DA00DB05C8 /* QRunLoopOperation.m */,
|
||||
);
|
||||
@ -339,7 +334,6 @@
|
||||
F8E469911395742500DB05C8 /* AFURLCache.m in Sources */,
|
||||
F8E469921395742500DB05C8 /* UIImage+AFNetworking.m in Sources */,
|
||||
F8E469A9139574DA00DB05C8 /* QHTTPOperation.m in Sources */,
|
||||
F8E469AA139574DA00DB05C8 /* QReachabilityOperation.m in Sources */,
|
||||
F8E469AB139574DA00DB05C8 /* QRunLoopOperation.m in Sources */,
|
||||
F8E469B31395752400DB05C8 /* JSONKit.m in Sources */,
|
||||
F8E469BC139575D000DB05C8 /* AFGowallaAPI.m in Sources */,
|
||||
@ -433,6 +427,7 @@
|
||||
F8E469831395739D00DB05C8 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
#import "QRunLoopOperation.h"
|
||||
#include <SystemConfiguration/SystemConfiguration.h>
|
||||
|
||||
@interface QReachabilityOperation : QRunLoopOperation {
|
||||
NSString * _hostName;
|
||||
NSUInteger _flagsTargetMask;
|
||||
NSUInteger _flagsTargetValue;
|
||||
NSUInteger _flags;
|
||||
SCNetworkReachabilityRef _ref;
|
||||
}
|
||||
|
||||
// Initialises the operation to monitor the reachability of the specified
|
||||
// host. The operation finishes when (flags & flagsTargetMask) == flagsTargetValue.
|
||||
- (id)initWithHostName:(NSString *)hostName;
|
||||
|
||||
// Things that are configured by the init method and can't be changed.
|
||||
@property (copy, readonly ) NSString * hostName;
|
||||
|
||||
// Things you can configure before queuing the operation.
|
||||
|
||||
// runLoopThread and runLoopModes inherited from QRunLoopOperation
|
||||
@property (assign, readwrite) NSUInteger flagsTargetMask;
|
||||
@property (assign, readwrite) NSUInteger flagsTargetValue;
|
||||
|
||||
// Things that change as part of the progress of the operation.
|
||||
|
||||
// error property inherited from QRunLoopOperation
|
||||
@property (assign, readonly ) NSUInteger flags; // observable, changes on the actual run loop thread
|
||||
|
||||
@end
|
||||
@ -1,111 +0,0 @@
|
||||
#import "QReachabilityOperation.h"
|
||||
|
||||
@interface QReachabilityOperation ()
|
||||
|
||||
@property (assign, readwrite) NSUInteger flags;
|
||||
|
||||
static void ReachabilityCallback(
|
||||
SCNetworkReachabilityRef target,
|
||||
SCNetworkReachabilityFlags flags,
|
||||
void * info
|
||||
);
|
||||
|
||||
- (void)reachabilitySetFlags:(NSUInteger)newValue;
|
||||
|
||||
@end
|
||||
|
||||
@implementation QReachabilityOperation
|
||||
|
||||
- (id)initWithHostName:(NSString *)hostName {
|
||||
assert(hostName != nil);
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
self->_hostName = [hostName copy];
|
||||
self->_flagsTargetMask = kSCNetworkReachabilityFlagsReachable | kSCNetworkReachabilityFlagsInterventionRequired;
|
||||
self->_flagsTargetValue = kSCNetworkReachabilityFlagsReachable;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self->_hostName release];
|
||||
assert(self->_ref == NULL);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@synthesize hostName = _hostName;
|
||||
@synthesize flagsTargetMask = _flagsTargetMask;
|
||||
@synthesize flagsTargetValue = _flagsTargetValue;
|
||||
@synthesize flags = _flags;
|
||||
|
||||
// Called by QRunLoopOperation when the operation starts. This is our opportunity
|
||||
// to install our run loop callbacks, which is exactly what we do. The only tricky
|
||||
// thing is that we have to schedule the reachability ref to run in all of the
|
||||
// run loop modes specified by our client.
|
||||
- (void)operationDidStart {
|
||||
Boolean success;
|
||||
SCNetworkReachabilityContext context = { 0, self, NULL, NULL, NULL };
|
||||
|
||||
assert(self->_ref == NULL);
|
||||
self->_ref = SCNetworkReachabilityCreateWithName(NULL, [self.hostName UTF8String]);
|
||||
assert(self->_ref != NULL);
|
||||
|
||||
success = SCNetworkReachabilitySetCallback(self->_ref, ReachabilityCallback, &context);
|
||||
assert(success);
|
||||
|
||||
for (NSString * mode in self.actualRunLoopModes) {
|
||||
success = SCNetworkReachabilityScheduleWithRunLoop(self->_ref, CFRunLoopGetCurrent(), (CFStringRef) mode);
|
||||
assert(success);
|
||||
}
|
||||
}
|
||||
|
||||
static void ReachabilityCallback(
|
||||
SCNetworkReachabilityRef target,
|
||||
SCNetworkReachabilityFlags flags,
|
||||
void * info
|
||||
)
|
||||
// Called by the system when the reachability flags change. We just forward
|
||||
// the flags to our Objective-C code.
|
||||
{
|
||||
QReachabilityOperation * obj;
|
||||
|
||||
obj = (QReachabilityOperation *) info;
|
||||
assert([obj isKindOfClass:[QReachabilityOperation class]]);
|
||||
assert(target == obj->_ref);
|
||||
#pragma unused(target)
|
||||
|
||||
[obj reachabilitySetFlags:flags];
|
||||
}
|
||||
|
||||
// Called when the reachability flags change. We just store the flags and then
|
||||
// check to see if the flags meet our target criteria, in which case we stop the
|
||||
// operation.
|
||||
- (void)reachabilitySetFlags:(NSUInteger)newValue {
|
||||
assert( [NSThread currentThread] == self.actualRunLoopThread );
|
||||
|
||||
self.flags = newValue;
|
||||
if ( (self.flags & self.flagsTargetMask) == self.flagsTargetValue ) {
|
||||
[self finishWithError:nil];
|
||||
}
|
||||
}
|
||||
|
||||
// Called by QRunLoopOperation when the operation finishes. We just clean up
|
||||
// our reachability ref.
|
||||
- (void)operationWillFinish {
|
||||
Boolean success;
|
||||
|
||||
if (self->_ref != NULL) {
|
||||
for (NSString * mode in self.actualRunLoopModes) {
|
||||
success = SCNetworkReachabilityUnscheduleFromRunLoop(self->_ref, CFRunLoopGetCurrent(), (CFStringRef) mode);
|
||||
assert(success);
|
||||
}
|
||||
|
||||
success = SCNetworkReachabilitySetCallback(self->_ref, NULL, NULL);
|
||||
assert(success);
|
||||
|
||||
CFRelease(self->_ref);
|
||||
self->_ref = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Reference in New Issue
Block a user