From 69550bfb6151084fbcc21534b43724603ae477a9 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 21 May 2009 11:37:04 +0000 Subject: [PATCH] Various upgrades for 3.x and performance. --- Library.mm | 120 ++++++++++++++++++++++++++++++++++++++--------------- conffiles | 1 + control | 4 +- makefile | 8 ++-- 4 files changed, 94 insertions(+), 39 deletions(-) create mode 100644 conffiles diff --git a/Library.mm b/Library.mm index 95dc7ff..9242b67 100644 --- a/Library.mm +++ b/Library.mm @@ -35,7 +35,26 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define _trace() NSLog(@"WB:_trace(%u)", __LINE__); +#include + +struct timeval _ltv; +bool _itv; + +#define _trace() do { \ + struct timeval _ctv; \ + gettimeofday(&_ctv, NULL); \ + if (!_itv) { \ + _itv = true; \ + _ltv = _ctv; \ + } \ + fprintf(stderr, "%lu.%.6u[%f]:_trace()@%s:%u[%s]\n", \ + _ctv.tv_sec, _ctv.tv_usec, \ + (_ctv.tv_sec - _ltv.tv_sec) + (_ctv.tv_usec - _ltv.tv_usec) / 1000000.0, \ + __FILE__, __LINE__, __FUNCTION__\ + ); \ + _ltv = _ctv; \ +} while (false) + #define _transient #import @@ -57,7 +76,6 @@ #import #import #import -#import #import #import #import @@ -100,7 +118,6 @@ Class $SBAwayView; Class $SBBookmarkIcon; Class $SBButtonBar; Class $SBCalendarIconContentsView; -Class $SBContentLayer; Class $SBIcon; Class $SBIconBadge; Class $SBIconController; @@ -112,6 +129,7 @@ Class $SBStatusBarContentsView; Class $SBStatusBarController; Class $SBStatusBarOperatorNameView; Class $SBStatusBarTimeView; +Class $SBUIController; Class $SBWidgetApplicationIcon; @interface NSDictionary (WinterBoard) @@ -145,7 +163,6 @@ static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path); static CGImageRef (*_UIImageRefAtPath)(NSString *name, bool cache, UIImageOrientation *orientation); static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain); static NSBundle *(*_UIKitBundle)(); -static void (*_UISharedImageInitialize)(bool); static int (*_UISharedImageNameGetIdentifier)(NSString *); static UIImage *(*_UISharedImageWithIdentifier)(int); @@ -263,6 +280,7 @@ static NSString *$pathForIcon$(SBApplication *self) { path = [path stringByDeletingLastPathComponent]; if (path == nil || [path length] == 0 || [path isEqualToString:@"/"]) return nil; + return [NSBundle mainBundle]; NSBundle *bundle([Bundles_ objectForKey:path]); if (reinterpret_cast(bundle) == [NSNull null]) @@ -274,7 +292,7 @@ static NSString *$pathForIcon$(SBApplication *self) { bundle = [NSBundle wb$bundleWithFile:path]; if (Debug_) NSLog(@"WB:Debug:PathBundle(%@, %@)", path, bundle); - [Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast(bundle)) forKey:path]; + //[Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast(bundle)) forKey:path]; } return bundle; @@ -293,6 +311,7 @@ static NSString *$pathForIcon$(SBApplication *self) { NSLog(@"WB:Debug:Bypass(\"%@\")", self); if (NSBundle *bundle = [NSBundle wb$bundleWithFile:self]) { + return self; NSString *file([self stringByResolvingSymlinksInPath]); NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]); if ([file hasPrefix:prefix]) { @@ -398,7 +417,7 @@ static UIImage *CachedImageAtPath(NSString *path) { MSHook(CGImageRef, _UIImageRefAtPath, NSString *name, bool cache, UIImageOrientation *orientation) { if (Debug_) NSLog(@"WB:Debug: _UIImageRefAtPath(\"%@\", %s)", name, cache ? "true" : "false"); - return __UIImageRefAtPath([name wb$themedPath], cache, orientation); + return __UIImageRefAtPath(([name wb$themedPath], name), cache, orientation); } /*MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) { @@ -528,7 +547,7 @@ MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *s } /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground *self, SEL sel, CGRect frame, int style, UIColor *tint) { - _trace(); +_trace(); if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"]) style = [number intValue]; @@ -595,11 +614,27 @@ static NSURL *WallpaperURL_; object = nil; \ } while (false) -MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize size) { - self = _SBContentLayer$initWithSize$(self, sel, size); +void DumpHierarchy(UIView *view, unsigned index = 0, unsigned indent = 0) { + NSLog(@"%*s|%2d:%s", indent * 3, "", index, class_getName([view class])); + index = 0; + for (UIView *child in [view subviews]) + DumpHierarchy(child, index++, indent + 1); +} + +MSHook(id, SBUIController$init, SBUIController *self, SEL sel) { + self = _SBUIController$init(self, sel); if (self == nil) return nil; + UIWindow *&_window(MSHookIvar(self, "_window")); + UIView *&_contentView(MSHookIvar(self, "_contentView")); + + UIView *content([[[UIView alloc] initWithFrame:[_contentView frame]] autorelease]); + [content setBackgroundColor:[_contentView backgroundColor]]; + [_contentView setBackgroundColor:[UIColor clearColor]]; + [_contentView setFrame:[content bounds]]; + [_window setContentView:content]; + _release(WallpaperFile_); _release(WallpaperImage_); _release(WallpaperPage_); @@ -619,7 +654,7 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s AVQueue *queue([controller_ queue]); - UIView *video([[[UIView alloc] initWithFrame:[self bounds]] autorelease]); + UIView *video([[[UIView alloc] initWithFrame:[_contentView bounds]] autorelease]); [controller_ setLayer:[video _layer]]; AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]); @@ -632,14 +667,14 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s controller.movieControlMode = MPMovieControlModeHidden; [controller play]; #else - MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[self bounds]] autorelease]; + MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[_contentView bounds]] autorelease]; [video setMovieWithPath:mp4]; [video setRepeatMode:1]; [video setRepeatGap:-1]; [video playFromBeginning];; #endif - [self addSubview:video]; + [content addSubview:video]; } NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"]; @@ -662,12 +697,12 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s if (image != nil) { WallpaperFile_ = [path retain]; WallpaperImage_ = [[UIImageView alloc] initWithImage:image]; - [self addSubview:WallpaperImage_]; + [content addSubview:WallpaperImage_]; } NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"]; if ([Manager_ fileExistsAtPath:html]) { - CGRect bounds = [self bounds]; + CGRect bounds = [content bounds]; UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]); [view setAutoresizes:true]; @@ -680,7 +715,7 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s [[view webView] setDrawsBackground:false]; [view setBackgroundColor:[UIColor clearColor]]; - [self addSubview:view]; + [content addSubview:view]; } } @@ -688,7 +723,7 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s NSString *theme = [themes_ objectAtIndex:(e - i - 1)]; NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"]; if ([Manager_ fileExistsAtPath:html]) { - CGRect bounds = [self bounds]; + CGRect bounds = [content bounds]; UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]); [view setAutoresizes:true]; @@ -699,10 +734,13 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s [[view webView] setDrawsBackground:false]; [view setBackgroundColor:[UIColor clearColor]]; - [self addSubview:view]; + [content addSubview:view]; } } + [content addSubview:_contentView]; + DumpHierarchy(_window); + return self; } @@ -843,20 +881,38 @@ MSHook(id, SBIconBadge$initWithBadge$, SBIconBadge *self, SEL sel, NSString *bad } return self; } -MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int id, int animation) { +void SBStatusBarController$setStatusBarMode(int &mode) { if (Debug_) NSLog(@"WB:Debug:setStatusBarMode:%d", mode); if (mode < 100) // 104:hidden 105:glowing if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"]) mode = [number intValue]; - return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, id, animation); } -MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) { +/*MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int animation) { + NSLog(@"mode:%d orientation:%d duration:%f animation:%d", mode, orientation, duration, animation); + SBStatusBarController$setStatusBarMode(mode); + return _SBStatusBarController$setStatusBarMode$orientation$duration$animation$(self, sel, mode, orientation, duration, animation); +}*/ + +MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int fenceID, int animation) { + NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d", mode, orientation, duration, fenceID, animation); + SBStatusBarController$setStatusBarMode(mode); + return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, fenceID, animation); +} + +MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int fenceID, int animation, double startTime) { + NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d startTime:%f", mode, orientation, duration, fenceID, animation, startTime); + SBStatusBarController$setStatusBarMode(mode); + NSLog(@"mode=%u", mode); + return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$(self, sel, mode, orientation, duration, fenceID, animation, startTime); +} + +/*MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) { if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"]) mode = [number intValue]; return _SBStatusBarContentsView$initWithStatusBar$mode$(self, sel, bar, mode); -} +}*/ MSHook(NSString *, SBStatusBarOperatorNameView$operatorNameStyle, SBStatusBarOperatorNameView *self, SEL sel) { NSString *style(_SBStatusBarOperatorNameView$operatorNameStyle(self, sel)); @@ -1175,7 +1231,7 @@ extern "C" void WBInitialize() { NSLog(@"WB:Notice: WinterBoard"); - struct nlist nl[9]; + struct nlist nl[8]; memset(nl, 0, sizeof(nl)); nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName"; @@ -1183,9 +1239,8 @@ extern "C" void WBInitialize() { nl[2].n_un.n_name = (char *) "__UIImageRefAtPath"; nl[3].n_un.n_name = (char *) "__UIImageWithNameInDomain"; nl[4].n_un.n_name = (char *) "__UIKitBundle"; - nl[5].n_un.n_name = (char *) "__UISharedImageInitialize"; - nl[6].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier"; - nl[7].n_un.n_name = (char *) "__UISharedImageWithIdentifier"; + nl[5].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier"; + nl[6].n_un.n_name = (char *) "__UISharedImageWithIdentifier"; nlist(UIKit, nl); @@ -1194,9 +1249,8 @@ extern "C" void WBInitialize() { _UIImageRefAtPath = (CGImageRef (*)(NSString *, bool, UIImageOrientation *)) nl[2].n_value; _UIImageWithNameInDomain = (UIImage *(*)(NSString *, NSString *)) nl[3].n_value; _UIKitBundle = (NSBundle *(*)()) nl[4].n_value; - _UISharedImageInitialize = (void (*)(bool)) nl[5].n_value; - _UISharedImageNameGetIdentifier = (int (*)(NSString *)) nl[6].n_value; - _UISharedImageWithIdentifier = (UIImage *(*)(int)) nl[7].n_value; + _UISharedImageNameGetIdentifier = (int (*)(NSString *)) nl[5].n_value; + _UISharedImageWithIdentifier = (UIImage *(*)(int)) nl[6].n_value; MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName); MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath); @@ -1231,8 +1285,6 @@ extern "C" void WBInitialize() { _UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$); _UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$); - _UISharedImageInitialize(false); - Manager_ = [[NSFileManager defaultManager] retain]; UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16]; PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16]; @@ -1315,7 +1367,6 @@ extern "C" void WBInitialize() { $SBBookmarkIcon = objc_getClass("SBBookmarkIcon"); $SBButtonBar = objc_getClass("SBButtonBar"); $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView"); - $SBContentLayer = objc_getClass("SBContentLayer"); $SBIcon = objc_getClass("SBIcon"); $SBIconBadge = objc_getClass("SBIconBadge"); $SBIconController = objc_getClass("SBIconController"); @@ -1327,6 +1378,7 @@ extern "C" void WBInitialize() { $SBStatusBarController = objc_getClass("SBStatusBarController"); $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView"); $SBStatusBarTimeView = objc_getClass("SBStatusBarTimeView"); + $SBUIController = objc_getClass("SBUIController"); $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon"); WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$); @@ -1336,10 +1388,10 @@ extern "C" void WBInitialize() { WBRename(SBBookmarkIcon, icon, icon); WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview); WBRename(SBCalendarIconContentsView, drawRect:, drawRect$); - WBRename(SBContentLayer, initWithSize:, initWithSize$); WBRename(SBIcon, setAlpha:, setAlpha$); WBRename(SBIconBadge, initWithBadge:, initWithBadge$); WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged); + WBRename(SBUIController, init, init); WBRename(SBWidgetApplicationIcon, icon, icon); WBRename(SBIconLabel, drawRect:, drawRect$); @@ -1355,8 +1407,10 @@ extern "C" void WBInitialize() { WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$); WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview); - WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$); + //WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$); + //WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:animation:, setStatusBarMode$orientation$duration$animation$); WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$); + WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:startTime:, setStatusBarMode$orientation$duration$fenceID$animation$startTime$); WBRename(SBStatusBarOperatorNameView, operatorNameStyle, operatorNameStyle); WBRename(SBStatusBarOperatorNameView, setOperatorName:fullSize:, setOperatorName$fullSize$); WBRename(SBStatusBarTimeView, drawRect:, drawRect$); diff --git a/conffiles b/conffiles new file mode 100644 index 0000000..2ad2a04 --- /dev/null +++ b/conffiles @@ -0,0 +1 @@ +/Applications/WinterBoard.app/Info.plist diff --git a/control b/control index 7594ba4..0e2f5c9 100644 --- a/control +++ b/control @@ -3,10 +3,10 @@ Priority: optional Section: System Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.2796-1 +Version: 0.9.2920-1 Description: more powerful, open-source SummerBoard Name: WinterBoard -Depends: mobilesubstrate (>= 0.9.2660-1) +Depends: mobilesubstrate (>= 0.9.2660-1), killall Provides: theme-manager Conflicts: com.modmyifone.winterboardicon Replaces: com.modmyifone.winterboardicon diff --git a/makefile b/makefile index b23bf2c..d567b7a 100644 --- a/makefile +++ b/makefile @@ -10,13 +10,13 @@ clean: rm -f WinterBoard WinterBoard.dylib UIImages WinterBoard.dylib: Library.mm makefile ../mobilesubstrate/substrate.h - $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -lobjc -init _WBInitialize -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -framework GraphicsServices -framework Celestial -I../mobilesubstrate -L../mobilesubstrate -lsubstrate -framework UIKit -multiply_defined suppress -F$(PKG_ROOT)/System/Library/PrivateFrameworks + $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -lobjc -init _WBInitialize -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -framework GraphicsServices -framework Celestial -I../mobilesubstrate -L../mobilesubstrate -lsubstrate -framework UIKit -F$(PKG_ROOT)/System/Library/PrivateFrameworks UIImages: UIImages.mm makefile - $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -I/apl/inc/iPhoneOS-2.0 -multiply_defined suppress + $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -I/apl/inc/iPhoneOS-2.0 WinterBoard: Application.mm makefile - $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -framework CoreGraphics -I/apl/sdk -multiply_defined suppress + $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -framework CoreGraphics -I/apl/sdk package: rm -rf winterboard @@ -28,7 +28,7 @@ package: cp -a WinterBoard.plist winterboard/Library/MobileSubstrate/DynamicLibraries cp -a *.theme winterboard/Library/Themes find winterboard/Library/Themes -name .svn | while read -r line; do rm -rf "$${line}"; done - cp -a control preinst prerm winterboard/DEBIAN + cp -a conffiles control preinst prerm winterboard/DEBIAN cp -a Test.sh icon.png WinterBoard.dylib WinterBoard UIImages Info.plist winterboard/Applications/WinterBoard.app dpkg-deb -b winterboard winterboard_$(shell grep ^Version: control | cut -d ' ' -f 2)_iphoneos-arm.deb -- 2.45.2