X-Git-Url: https://git.saurik.com/uikittools.git/blobdiff_plain/2a72f832e35d56a748537c894b00a236bae8f16a..db9133b87555cf295f22b9c6ada353b2413395d2:/uicache.mm diff --git a/uicache.mm b/uicache.mm index e08fe5d..ea6ac7e 100644 --- a/uicache.mm +++ b/uicache.mm @@ -5,6 +5,10 @@ #include #include +#include + +#include + @interface NSMutableArray (Cydia) - (void) addInfoDictionary:(NSDictionary *)info; @end @@ -30,17 +34,23 @@ @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); - if (NSMutableDictionary *cache = [[NSMutableDictionary alloc] initWithContentsOfFile:path]) { - [cache autorelease]; + 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]); + + if (NSMutableDictionary *cache = [NSMutableDictionary dictionaryWithContentsOfFile:path]) { NSFileManager *manager = [NSFileManager defaultManager]; NSError *error = nil; + NSMutableArray *bundles([NSMutableArray arrayWithCapacity:16]); + id system = [cache objectForKey:@"System"]; if (system == nil) goto error; @@ -52,26 +62,58 @@ int main() { if ([app hasSuffix:@".app"]) { NSString *path = [@"/Applications" stringByAppendingPathComponent:app]; NSString *plist = [path stringByAppendingPathComponent:@"Info.plist"]; - if (NSMutableDictionary *info = [[NSMutableDictionary alloc] initWithContentsOfFile:plist]) { - [info autorelease]; - if ([info objectForKey:@"CFBundleIdentifier"] == nil) - fprintf(stderr, "%s missing CFBundleIdentifier", [app UTF8String]); - else { + + if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:plist]) { + if ([info objectForKey:@"CFBundleIdentifier"] != nil) { + [bundles addObject:path]; [info setObject:path forKey:@"Path"]; [info setObject:@"System" forKey:@"ApplicationType"]; [system addInfoDictionary:info]; - } + } else + fprintf(stderr, "%s missing CFBundleIdentifier", [app UTF8String]); } } } else goto error; [cache writeToFile:path atomically:YES]; + if (workspace != nil) + for (NSString *bundle in bundles) { + [workspace unregisterApplication:[NSURL fileURLWithPath:bundle]]; + [workspace registerApplication:[NSURL fileURLWithPath:bundle]]; + } + if (false) error: 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];