diff options
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 1fd292d..e2c4b25 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -6557,19 +6557,41 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { /* Home Controller {{{ */ @interface HomeController : CydiaWebViewController { + CFRunLoopRef runloop_; + SCNetworkReachabilityRef reachability_; } @end @implementation HomeController +static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachability, SCNetworkReachabilityFlags flags, void *info) { + [(HomeController *) info dispatchEvent:@"CydiaReachabilityCallback"]; +} + - (id) init { if ((self = [super init]) != nil) { [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/#!/home/", UI_]]]; [self reloadData]; + + reachability_ = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, "cydia.saurik.com"); + if (reachability_ != NULL) { + SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL}; + SCNetworkReachabilitySetCallback(reachability_, HomeControllerReachabilityCallback, &context); + + CFRunLoopRef runloop(CFRunLoopGetCurrent()); + if (SCNetworkReachabilityScheduleWithRunLoop(reachability_, runloop, kCFRunLoopDefaultMode)) + runloop_ = runloop; + } } return self; } +- (void) dealloc { + if (reachability_ != NULL && runloop_ != NULL) + SCNetworkReachabilityUnscheduleFromRunLoop(reachability_, runloop_, kCFRunLoopDefaultMode); + [super dealloc]; +} + - (NSURL *) navigationURL { return [NSURL URLWithString:@"cydia://home"]; } |