From: Jay Freeman (saurik) Date: Sat, 30 Aug 2008 20:24:02 +0000 (+0000) Subject: Fixed a fatal uninstallation flaw in Five Icon Dock. X-Git-Tag: v0.9.2558^0 X-Git-Url: https://git.saurik.com/fiveicondock.git/commitdiff_plain/f90a2ed3345d474c8882aefbb19a01060beb8e22 Fixed a fatal uninstallation flaw in Five Icon Dock. --- diff --git a/control b/control index 0643644..c1a0189 100644 --- a/control +++ b/control @@ -3,7 +3,7 @@ Priority: optional Section: Tweaks Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.2557-1 +Version: 0.9.2558-1 Description: fits even more stuff right down there Name: Five Icon Dock Depends: mobilesubstrate (>= 0.9.2555-1) diff --git a/make.sh b/make.sh index 2d9cc22..de010e4 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 +/apl/tel/util/ldid -S *.dylib prerm make package diff --git a/makefile b/makefile index 396816f..ec40f4a 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,6 @@ name := FiveIconDock id := fid +control := prerm include ../tweak.mk + +all: prerm diff --git a/prerm.mm b/prerm.mm new file mode 100644 index 0000000..8c38b04 --- /dev/null +++ b/prerm.mm @@ -0,0 +1,85 @@ +#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) + 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; +}