]> git.saurik.com Git - fiveicondock.git/commitdiff
Fixed a fatal uninstallation flaw in Five Icon Dock. v0.9.2558
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 30 Aug 2008 20:24:02 +0000 (20:24 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 30 Aug 2008 20:24:02 +0000 (20:24 +0000)
control
make.sh
makefile
prerm.mm [new file with mode: 0644]

diff --git a/control b/control
index 064364474dfaf6d5ed07b46698bd65f64635f8c6..c1a0189dfa59e607ecc5e5491ff0da3683ff95fe 100644 (file)
--- a/control
+++ b/control
@@ -3,7 +3,7 @@ Priority: optional
 Section: Tweaks
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 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 2d9cc22ea4d2e9e3f4deff753688bd70dbe6a4f3..de010e47320b5a21825bddb0758a44ff52bc4dd5 100755 (executable)
--- 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
index 396816f560d632ff02ccf50236bc2eac92c3750e..ec40f4a9ab96ee9da07542393919958dae07eb6f 100644 (file)
--- 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 (file)
index 0000000..8c38b04
--- /dev/null
+++ b/prerm.mm
@@ -0,0 +1,85 @@
+#import <Foundation/Foundation.h>
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <unistd.h>
+
+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;
+}