summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-22 18:50:50 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-22 18:50:50 -0700
commit02f21c73082efec21b063d395196329f16f9ec73 (patch)
treec5b89a16a1457e4e1222f239913dcc497e12dfc8 /MobileCydia.mm
parent37f1fb03279b8a53166a602fc49975aa07953700 (diff)
Backup reachability events.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm22
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"];
}