]> git.saurik.com Git - uikittools.git/blobdiff - uicache.mm
Merge uicache from WinterBoard Settings.
[uikittools.git] / uicache.mm
index 4b477c6668a01101308ab57e5c601af8c8f6b4cf..ea6ac7e16e8ed281d03cec1f6c93869ca8b81c51 100644 (file)
 
 @end
 
-int main() {
+int main(int argc, const char *argv[]) {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
-    NSString *path([NSString stringWithFormat:@"%@/Library/Caches/com.apple.mobile.installation.plist", NSHomeDirectory()]);
+    bool respring(false);
+
+    NSString *home(NSHomeDirectory());
+    NSString *path([NSString stringWithFormat:@"%@/Library/Caches/com.apple.mobile.installation.plist", home]);
 
     Class $LSApplicationWorkspace(objc_getClass("LSApplicationWorkspace"));
     LSApplicationWorkspace *workspace($LSApplicationWorkspace == nil ? nil : [$LSApplicationWorkspace defaultWorkspace]);
@@ -61,7 +64,7 @@ int main() {
                     NSString *plist = [path stringByAppendingPathComponent:@"Info.plist"];
 
                     if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:plist]) {
-                        if (NSString *bundle = [info objectForKey:@"CFBundleIdentifier"]) {
+                        if ([info objectForKey:@"CFBundleIdentifier"] != nil) {
                             [bundles addObject:path];
                             [info setObject:path forKey:@"Path"];
                             [info setObject:@"System" forKey:@"ApplicationType"];
@@ -84,7 +87,33 @@ int main() {
             fprintf(stderr, "%s\n", error == nil ? strerror(errno) : [[error localizedDescription] UTF8String]);
     } else fprintf(stderr, "cannot open cache file. incorrect user?\n");
 
-    notify_post("com.apple.mobile.application_installed");
+    if (respring || kCFCoreFoundationVersionNumber >= 550.32) {
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-icons", home] UTF8String]);
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-icons.plist", home] UTF8String]);
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-smallicons", home] UTF8String]);
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-smallicons.plist", home] UTF8String]);
+
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.SpringBoard.folderSwitcherLinen", home] UTF8String]);
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.SpringBoard.notificationCenterLinen", home] UTF8String]);
+
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.SpringBoard.folderSwitcherLinen.0", home] UTF8String]);
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.SpringBoard.folderSwitcherLinen.1", home] UTF8String]);
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.SpringBoard.folderSwitcherLinen.2", home] UTF8String]);
+        unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.SpringBoard.folderSwitcherLinen.3", home] UTF8String]);
+
+        system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/SpringBoardIconCache", home] UTF8String]);
+        system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/SpringBoardIconCache-small", home] UTF8String]);
+        system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/com.apple.IconsCache", home] UTF8String]);
+        system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/com.apple.newsstand", home] UTF8String]);
+        system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/com.apple.springboard.sharedimagecache", home] UTF8String]);
+    }
+
+    system("killall installd");
+
+    if (respring)
+        system("launchctl stop com.apple.SpringBoard");
+    else
+        notify_post("com.apple.mobile.application_installed");
 
     [pool release];