From: Jay Freeman (saurik) Date: Mon, 24 Aug 2009 03:24:14 +0000 (+0000) Subject: Upgrading Five Icon Dock to new API. X-Git-Tag: v0.9.3184~5 X-Git-Url: https://git.saurik.com/fiveicondock.git/commitdiff_plain/e8dc11fba40dae8ed747662239e8cefbe5505385 Upgrading Five Icon Dock to new API. --- diff --git a/Tweak.mm b/Tweak.mm index 8e6a74d..28e7ebb 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -7,16 +7,22 @@ #import #import -MSHook(float, SBButtonBar$leftMarginForIconRowArray$, SBButtonBar *self, SEL sel, NSArray *row) { - return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : _SBButtonBar$leftMarginForIconRowArray$(self, sel, row); +MSHookClass(SBButtonBar) +MSHookClass(SBIcon) +MSHookClass(SBIconModel) + +MSHookMetaClass(SBIconModel) + +MSMessageHook1(float, SBButtonBar, leftMarginForIconRowArray, NSArray *row) { + return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : MSCall1(SBButtonBar, leftMarginForIconRowArray, row); } -static int $SBButtonBar$maxIconColumns(SBButtonBar *self, SEL sel) { - return 5; +MSMessageHook0(int, SBButtonBar, maxIconColumns) { + return 10; } static unsigned $SBButtonBar$count(SBButtonBar *self) { - NSArray *&_iconMatrix(MSHookIvar(self, "_iconMatrix")); + MSIvar(NSArray *, _iconMatrix); NSArray *row([_iconMatrix objectAtIndex:0]); unsigned count(0); for (id icon in row) @@ -25,11 +31,11 @@ static unsigned $SBButtonBar$count(SBButtonBar *self) { return count; } -static float $SBButtonBar$topIconPadding(SBButtonBar *self, SEL sel) { +MSMessageHook0(float, SBButtonBar, topIconPadding) { return 313370 + $SBButtonBar$count(self); } -MSHook(void, SBIcon$setOrigin$, SBIcon *self, SEL sel, CGPoint origin) { +MSMessageHook1(void, SBIcon, setOrigin, CGPoint origin) { unsigned count(origin.y); if (count < 313370) goto set; @@ -44,11 +50,11 @@ MSHook(void, SBIcon$setOrigin$, SBIcon *self, SEL sel, CGPoint origin) { origin.y = 11; set: - _SBIcon$setOrigin$(self, sel, origin); + MSCall1(SBIcon, setOrigin, origin); } -MSHook(CGPoint, SBButtonBar$originForIconAtX$Y$, SBButtonBar *self, SEL sel, int x, int y) { - CGPoint origin;//(_SBButtonBar$originForIconAtX$Y$(self, sel, x, y)); +MSMessageHook2(CGPoint, SBButtonBar, originForIconAtX,Y, int x, int y) { + CGPoint origin;//(_SBButtonBar$originForIconAtX$Y$(self, _cmd, x, y)); //NSLog(@"f:%u,%u=(%f,%f)", x, y, origin.x, origin.y); origin.y = 11; @@ -65,21 +71,6 @@ MSHook(CGPoint, SBButtonBar$originForIconAtX$Y$, SBButtonBar *self, SEL sel, int return origin; } -static int $SBIconModel$maxIconListCount(SBIconModel *self, SEL sel) { +MSMetaMessageHook0(int, SBIconModel, maxIconListCount) { return 16; } - -extern "C" void TweakInitialize() { - Class $SBButtonBar(objc_getClass("SBButtonBar")); - MSHookMessage($SBButtonBar, @selector(leftMarginForIconRowArray:), MSHake(SBButtonBar$leftMarginForIconRowArray$)); - MSHookMessage($SBButtonBar, @selector(maxIconColumns), &$SBButtonBar$maxIconColumns); - MSHookMessage($SBButtonBar, @selector(topIconPadding), &$SBButtonBar$topIconPadding); - MSHookMessage($SBButtonBar, @selector(originForIconAtX:Y:), MSHake(SBButtonBar$originForIconAtX$Y$)); - - Class $SBIcon(objc_getClass("SBIcon")); - MSHookMessage($SBIcon, @selector(setOrigin:), MSHake(SBIcon$setOrigin$)); - - Class $SBIconModel(objc_getClass("SBIconModel")); - Class $$SBIconModel(object_getClass($SBIconModel)); - MSHookMessage($$SBIconModel, @selector(maxIconListCount), &$SBIconModel$maxIconListCount); -} diff --git a/control b/control index 0d58b9f..8f9366f 100644 --- a/control +++ b/control @@ -3,7 +3,7 @@ Priority: optional Section: Tweaks Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.3012-1 +Version: 0.9.3013-1 Description: fits even more stuff right down there Name: Five+ Icon Dock Depends: mobilesubstrate (>= 0.9.3005-1), firmware (>= 2.2) diff --git a/make.sh b/make.sh index de010e4..2d9cc22 100755 --- a/make.sh +++ b/make.sh @@ -3,5 +3,5 @@ set -e export PKG_ARCH=${PKG_ARCH-iphoneos-arm} PATH=/apl/n42/pre/bin:$PATH /apl/tel/exec.sh com.saurik.winterboard make "$@" export CODESIGN_ALLOCATE=$(which arm-apple-darwin9-codesign_allocate) -/apl/tel/util/ldid -S *.dylib prerm +/apl/tel/util/ldid -S *.dylib make package diff --git a/makefile b/makefile index d0dcecf..43dade7 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,2 @@ name := FiveIconDock -id := fid -control := prerm include ../tweak.mk diff --git a/prerm.mm b/prerm.mm deleted file mode 100644 index d58d3e8..0000000 --- a/prerm.mm +++ /dev/null @@ -1,85 +0,0 @@ -#import - -#include -#include -#include - -int main(int argc, const char *argv[]) { - if (argc < 2 || strcmp(argv[1], "remove") != 0) - return 0; - - struct passwd *passwd = getpwnam("mobile"); - if (passwd == NULL) { - perror("getpwnam"); - return 0; - } - - if (setregid(passwd->pw_gid, passwd->pw_gid) == -1) { - perror("setregid"); - return 1; - } - - if (setreuid(passwd->pw_uid, passwd->pw_uid) == -1) { - perror("setreuid"); - return 1; - } - - NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); - - NSString *path([NSString stringWithFormat:@"%@/Library/Preferences/com.apple.springboard.plist", NSHomeDirectory()]); - - NSMutableDictionary *settings([[NSMutableDictionary alloc] initWithContentsOfFile:path]); - if (settings == nil) - return 0; - - NSMutableDictionary *iconState([settings objectForKey:@"iconState"]); - if (iconState == nil) - return 0; - - NSMutableDictionary *buttonBar([iconState objectForKey:@"buttonBar"]); - if (buttonBar == nil) - return 0; - - NSMutableArray *buttonBarIconMatrix([buttonBar objectForKey:@"iconMatrix"]); - if (buttonBarIconMatrix == nil || [buttonBarIconMatrix count] == 0) - return 0; - - NSMutableArray *buttonBarRow([buttonBarIconMatrix objectAtIndex:0]); - if (buttonBarRow == nil || [buttonBarRow count] < 5) - return 0; - - NSMutableDictionary *fifth([buttonBarRow objectAtIndex:4]); - - if (![fifth isEqual:[NSNumber numberWithInt:0]]) { - NSMutableArray *iconLists([iconState objectForKey:@"iconLists"]); - if (iconLists == nil) - iconLists = [NSMutableArray arrayWithCapacity:1]; - else for (NSUInteger i(0), e([iconLists count]); i != e; ++i) { - NSMutableDictionary *iconList([iconLists objectAtIndex:i]); - NSMutableArray *iconMatrix([iconList objectForKey:@"iconMatrix"]); - if (iconMatrix == nil) - continue; - - for (NSUInteger i(0), e([iconMatrix count]); i != e; ++i) { - NSMutableArray *row([iconMatrix objectAtIndex:i]); - NSUInteger spot([row indexOfObject:[NSNumber numberWithInteger:0]]); - if (spot != NSNotFound) { - [row replaceObjectAtIndex:i withObject:fifth]; - goto save; - } - } - } - - [iconLists addObject:[NSDictionary dictionaryWithObjectsAndKeys: - [NSArray arrayWithObjects:[NSArray arrayWithObject:fifth], nil], @"iconMatrix", - nil]]; - } - - save: - [buttonBarRow removeLastObject]; - bool saved([settings writeToFile:path atomically:YES]); - - [pool release]; - - return saved ? 0 : 1; -}