diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2017-03-04 21:06:59 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2017-03-04 21:06:59 -0800 |
commit | 8658b2df5d752c857807a1f9a652bdc2226ec429 (patch) | |
tree | 64d39b53cdfcf97d4a567cb8adcb6c8deb704505 /CyteKit | |
parent | 300a26c1c0cdcc6f86880b6d70e7bdf81d210b4b (diff) |
Rename IsReachable to CyteIsReachable, in CyteKit.
Diffstat (limited to 'CyteKit')
-rw-r--r-- | CyteKit/extern.h | 2 | ||||
-rw-r--r-- | CyteKit/extern.mm | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/CyteKit/extern.h b/CyteKit/extern.h index c7bc270..12d0438 100644 --- a/CyteKit/extern.h +++ b/CyteKit/extern.h @@ -27,4 +27,6 @@ extern bool IsWildcat_; extern CGFloat ScreenScale_; +bool CyteIsReachable(const char *name); + #endif//CyteKit_extern_H diff --git a/CyteKit/extern.mm b/CyteKit/extern.mm index c1dc806..cb8927a 100644 --- a/CyteKit/extern.mm +++ b/CyteKit/extern.mm @@ -20,11 +20,33 @@ /* }}} */ #include <CyteKit/extern.h> + +#include <SystemConfiguration/SystemConfiguration.h> #include <UIKit/UIKit.h> bool IsWildcat_; CGFloat ScreenScale_; +bool CyteIsReachable(const char *name) { + SCNetworkReachabilityFlags flags; { + SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, 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 + ) + ; +} + __attribute__((__constructor__)) void CyteKit_extern() { UIScreen *screen([UIScreen mainScreen]); |