summaryrefslogtreecommitdiff
path: root/Cydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2010-10-06 19:55:06 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2010-10-06 19:55:06 -0700
commitafb5333ac3d26972c58bd01b77397014caad58b3 (patch)
treebfe45bc04e73fca352088b9b2c70722f80178991 /Cydia.mm
parenta9dbe12cff9b5de401da271e92ac72a285227670 (diff)
Apple's Reachability code is ludicrously complex (and APSL).
Diffstat (limited to 'Cydia.mm')
-rw-r--r--Cydia.mm26
1 files changed, 20 insertions, 6 deletions
diff --git a/Cydia.mm b/Cydia.mm
index 8f42c6d..090823d 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -59,6 +59,8 @@
#include <CoreFoundation/CFPriv.h>
#include <CoreFoundation/CFUniChar.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+
#include <UIKit/UIKit.h>
#include "iPhonePrivate.h"
@@ -121,9 +123,6 @@ extern "C" {
#include "UICaboodle/BrowserView.h"
#include "substrate.h"
-
-// Apple's sample Reachability code, ASPL licensed.
-#include "Reachability.h"
/* }}} */
/* Profiler {{{ */
@@ -7972,10 +7971,25 @@ static _finline void _setHomePage(Cydia *self) {
- (void) _refreshIfPossible {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- Reachability* reachability = [Reachability reachabilityWithHostName:@"cydia.saurik.com"];
- NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
+ SCNetworkReachabilityFlags flags; {
+ SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(NULL, "cydia.saurik.com"));
+ SCNetworkReachabilityGetFlags(reachability, &flags);
+ CFRelease(reachability);
+ }
+
+ // XXX: this elaborate mess is what Apple is using to determine this? :(
+ // XXX: do we care if the user has to intervene? maybe that's ok?
+ bool reachable(
+ (flags & kSCNetworkReachabilityFlagsReachable) != 0 && (
+ (flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0 || (
+ (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0 ||
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0
+ ) && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0 ||
+ (flags & kSCNetworkReachabilityFlagsIsWWAN) != 0
+ )
+ );
- if (loaded_ || ManualRefresh || remoteHostStatus == NotReachable) loaded:
+ if (loaded_ || ManualRefresh || !reachable) loaded:
[self performSelectorOnMainThread:@selector(_loaded) withObject:nil waitUntilDone:NO];
else {
loaded_ = true;