summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-22 18:18:06 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-22 18:18:06 -0700
commit6cbfbe28f883e3df8b61cf7959bd8de9d41ab33e (patch)
tree474f87c815ce1d705ed7ec493b216e7d8b6b68f6 /MobileCydia.mm
parent9de35e86cd6e4f26365397472e50ea7a0e136cfd (diff)
Move IsReachable() to its own function.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm40
1 files changed, 21 insertions, 19 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index e97f3dc..a2d4333 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -258,6 +258,26 @@ static NSString *Warning_;
static bool AprilFools_;
+static bool IsReachable(const char *name) {
+ SCNetworkReachabilityFlags flags; {
+ SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(NULL, name));
+ 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?
+ return
+ (flags & kSCNetworkReachabilityFlagsReachable) != 0 && (
+ (flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0 || (
+ (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0 ||
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0
+ ) && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0 ||
+ (flags & kSCNetworkReachabilityFlagsIsWWAN) != 0
+ )
+ ;
+}
+
static const NSUInteger UIViewAutoresizingFlexibleBoth(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
static _finline NSString *CydiaURL(NSString *path) {
@@ -9294,26 +9314,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
// We are going to load, so remember that.
loaded_ = true;
- 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 we can reach the server, auto-refresh!
- if (reachable)
+ if (IsReachable("cydia.saurik.com"))
[tabbar_ performSelectorOnMainThread:@selector(setUpdate:) withObject:update waitUntilDone:NO];
}