From 7ccc1484ab74ebf5797820bdd24edccfd42aaa50 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 15 Feb 2017 10:29:44 -0800 Subject: Move some of our clearly shared code into CyteKit. --- MobileCydia.mm | 93 +++------------------------------------------------------- 1 file changed, 4 insertions(+), 89 deletions(-) (limited to 'MobileCydia.mm') diff --git a/MobileCydia.mm b/MobileCydia.mm index 3ed9cbd..3dec86e 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -112,6 +112,8 @@ extern "C" { #include "Substrate.hpp" #include "Menes/Menes.h" +#include "CyteKit/Application.h" +#include "CyteKit/NavigationController.h" #include "CyteKit/RegEx.hpp" #include "CyteKit/TableViewCell.h" #include "CyteKit/TabBarController.h" @@ -7019,15 +7021,6 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi @end /* }}} */ -/* Cydia Navigation Controller Interface {{{ */ -@interface UINavigationController (Cydia) - -- (NSArray *) navigationURLCollection; -- (void) unloadData; - -@end -/* }}} */ - /* Cydia Tab Bar Controller {{{ */ @interface CydiaTabBarController : CyteTabBarController < UITabBarControllerDelegate, @@ -7042,7 +7035,6 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi _transient NSObject *updatedelegate_; } -- (NSArray *) navigationURLCollection; - (void) beginUpdate; - (BOOL) updating; @@ -7050,19 +7042,6 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi @implementation CydiaTabBarController -- (NSArray *) navigationURLCollection { - NSMutableArray *items([NSMutableArray array]); - - // XXX: Should this deal with transient view controllers? - for (id navigation in [self viewControllers]) { - NSArray *stack = [navigation performSelector:@selector(navigationURLCollection)]; - if (stack != nil) - [items addObject:stack]; - } - - return items; -} - - (id) initWithDatabase:(Database *)database { if ((self = [super init]) != nil) { database_ = database; @@ -7161,47 +7140,6 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi @end /* }}} */ -/* Cydia Navigation Controller Implementation {{{ */ -@implementation UINavigationController (Cydia) - -- (NSArray *) navigationURLCollection { - NSMutableArray *stack([NSMutableArray array]); - - for (CyteViewController *controller in [self viewControllers]) { - NSString *url = [[controller navigationURL] absoluteString]; - if (url != nil) - [stack addObject:url]; - } - - return stack; -} - -- (void) reloadData { - [super reloadData]; - - UIViewController *visible([self visibleViewController]); - if (visible != nil) - [visible reloadData]; - - // on the iPad, this view controller is ALSO visible. :( - if (IsWildcat_) - if (UIViewController *modal = [self modalViewController]) - if ([modal modalPresentationStyle] == UIModalPresentationFormSheet) - if (UIViewController *top = [self topViewController]) - if (top != visible) - [top reloadData]; -} - -- (void) unloadData { - for (CyteViewController *page in [self viewControllers]) - [page unloadData]; - - [super unloadData]; -} - -@end -/* }}} */ - /* Cydia:// Protocol {{{ */ @interface CydiaURLProtocol : NSURLProtocol { } @@ -8999,7 +8937,7 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi @end -@interface Cydia : UIApplication < +@interface Cydia : CyteApplication < ConfirmationControllerDelegate, DatabaseDelegate, CydiaDelegate @@ -9898,32 +9836,9 @@ _end [tabbar_ setUpdateDelegate:self]; } -- (void) _sendMemoryWarningNotification { - if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iPhoneOS_3_0) // XXX: maybe 4_0? - [[NSNotificationCenter defaultCenter] postNotificationName:@"UIApplicationMemoryWarningNotification" object:[UIApplication sharedApplication]]; - else - [[NSNotificationCenter defaultCenter] postNotificationName:@"UIApplicationDidReceiveMemoryWarningNotification" object:[UIApplication sharedApplication]]; -} - -- (void) _sendMemoryWarningNotifications { - while (true) { - [self performSelectorOnMainThread:@selector(_sendMemoryWarningNotification) withObject:nil waitUntilDone:NO]; - sleep(2); - //usleep(2000000); - } -} - -- (void) applicationDidReceiveMemoryWarning:(UIApplication *)application { - NSLog(@"--"); - [[NSURLCache sharedURLCache] removeAllCachedResponses]; -} - - (void) applicationDidFinishLaunching:(id)unused { - //[NSThread detachNewThreadSelector:@selector(_sendMemoryWarningNotifications) toTarget:self withObject:nil]; - + [super applicationDidFinishLaunching:unused]; _trace(); - if ([self respondsToSelector:@selector(setApplicationSupportsShakeToEdit:)]) - [self setApplicationSupportsShakeToEdit:NO]; @synchronized (HostConfig_) { [BridgedHosts_ addObject:[[NSURL URLWithString:CydiaURL(@"")] host]]; -- cgit v1.2.3