From: Jay Freeman (saurik) Date: Sat, 30 Aug 2008 10:46:50 +0000 (+0000) Subject: We like five icon docks. X-Git-Tag: v0.9.2557^0 X-Git-Url: https://git.saurik.com/fiveicondock.git/commitdiff_plain/b6ceaaffa81d5aea23d871ce957045ee6e48d401 We like five icon docks. --- diff --git a/Library.mm b/Library.mm deleted file mode 100644 index 2d09b23..0000000 --- a/Library.mm +++ /dev/null @@ -1,62 +0,0 @@ -#import - -extern "C" { - #include -} - -#include -#include - -#include -#include - -extern "C" void __clear_cache (char *beg, char *end); - -extern "C" CFStringRef CPPhoneNumberCopyNetworkCountryCode(); - -static void ASReplace(void *symbol, void *replace) { - //NSLog(@"AS:Notice: Remapping %p to %p", symbol, replace); - if (symbol == NULL) - return; - - int page = getpagesize(); - uintptr_t base = (uintptr_t) symbol / page * page; - - mach_port_t self = mach_task_self(); - - if (kern_return_t error = vm_protect(self, base, page, FALSE, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY)) { - NSLog(@"AS:Error:vm_protect():%d", error); - return; - } - - uint32_t *code = (uint32_t *) symbol; - - code[0] = 0xe51ff004; // ldr pc, [pc, #-4] - code[1] = (uint32_t) replace; - - __clear_cache(reinterpret_cast(code), reinterpret_cast(code + 2)); - - if (kern_return_t error = vm_protect(self, base, page, FALSE, VM_PROT_READ | VM_PROT_EXECUTE)) - NSLog(@"AS:Error:vm_protect():%d", error); -} - -/*static CFStringRef UIDefaultCountryCode_() { - return CPPhoneNumberCopyNetworkCountryCode(); -}*/ - -#define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit" - -extern "C" void ASInitialize() { - if (dlopen(UIKit, RTLD_LAZY | RTLD_NOLOAD) == NULL) - return; - //NSLog(@"AS:Notice: Installing AppSupport..."); - - struct nlist nl[2]; - memset(nl, 0, sizeof(nl)); - nl[0].n_un.n_name = (char *) "_UIDefaultCountryCode"; - nlist(UIKit, nl); - CFStringRef (*UIDefaultCountryCode)() = reinterpret_cast(nl[0].n_value); - ASReplace(reinterpret_cast(UIDefaultCountryCode), reinterpret_cast(&CPPhoneNumberCopyNetworkCountryCode)); - - //NSLog(@"AS:Notice: Done"); -} diff --git a/Tweak.mm b/Tweak.mm new file mode 100644 index 0000000..be19307 --- /dev/null +++ b/Tweak.mm @@ -0,0 +1,65 @@ +#include + +#import +#import +#import +#import +#import + +@protocol Tweak +- (float) fid_leftMarginForIconRowArray:(NSArray *)row; +- (void) fid_setOrigin:(CGPoint)origin; +- (float) fid_topIconPadding; +@end + +static bool $SBButtonBar$$isCrowded(SBButtonBar *self) { + NSArray *matrix; + object_getInstanceVariable(self, "_iconMatrix", reinterpret_cast(&matrix)); + NSArray *row([matrix objectAtIndex:0]); + return row != nil && [row indexOfObject:[NSNull null]] == NSNotFound; +} + +static float $SBButtonBar$leftMarginForIconRowArray$(SBButtonBar *self, SEL sel, NSArray *row) { + return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : [self fid_leftMarginForIconRowArray:row]; +} + +static int $SBButtonBar$maxIconColumns(SBButtonBar *self, SEL sel) { + return 5; +} + +static float $SBButtonBar$topIconPadding(SBButtonBar *self, SEL sel) { + float padding([self fid_topIconPadding]); + if ($SBButtonBar$$isCrowded(self)) + --padding; + return padding; +} + +static float $SBButtonBar$verticalIconPadding(SBButtonBar *self, SEL sel) { + return 0; +} + +static void $SBIcon$setOrigin$(SBIcon *self, SEL sel, CGPoint origin) { + if (origin.y == 10) + origin.x = (origin.x - 4) / 76 * 63 + 4; + else if (origin.y == 84) { + origin.y -= 74; + origin.x = 256; + } else goto set; + ++origin.y; + set: + [self fid_setOrigin:origin]; +} + +extern "C" void TweakInitialize() { + if (objc_getClass("SpringBoard") == nil) + return; + + Class $SBButtonBar(objc_getClass("SBButtonBar")); + MSHookMessage($SBButtonBar, @selector(leftMarginForIconRowArray:), (IMP) &$SBButtonBar$leftMarginForIconRowArray$, "fid_"); + MSHookMessage($SBButtonBar, @selector(maxIconColumns), (IMP) &$SBButtonBar$maxIconColumns, "fid_"); + MSHookMessage($SBButtonBar, @selector(topIconPadding), (IMP) &$SBButtonBar$topIconPadding, "fid_"); + MSHookMessage($SBButtonBar, @selector(verticalIconPadding), (IMP) &$SBButtonBar$verticalIconPadding, "fid_"); + + Class $SBIcon(objc_getClass("SBIcon")); + MSHookMessage($SBIcon, @selector(setOrigin:), (IMP) $SBIcon$setOrigin$, "fid_"); +} diff --git a/control b/control index 0d2f1fc..2a7cdf3 100644 --- a/control +++ b/control @@ -1,11 +1,11 @@ -Package: com.saurik.iphone.nlnf +Package: com.saurik.iphone.fid Priority: optional Section: Tweaks Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.2526-1 +Version: 0.9.2557-1 Description: fix phone numbers for roaming and locales Name: Net.-Local Number Format -Depends: mobilesubstrate (>= 0.9.2550-1) +Depends: mobilesubstrate (>= 0.9.2555-1) Author: Jay Freeman (saurik) Depiction: http://cydia.saurik.com/info/com.saurik.iphone.fid/ diff --git a/make.sh b/make.sh index 4ff90cb..2d9cc22 100755 --- a/make.sh +++ b/make.sh @@ -3,4 +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 PhoneNumberFormatting.dylib +/apl/tel/util/ldid -S *.dylib +make package