summaryrefslogtreecommitdiff
path: root/uicache.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2010-04-06 11:16:28 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2010-04-06 11:16:28 +0000
commit020dfc54dc819f7c10e8eb43d4ddaaef834dca70 (patch)
treefa789fd7d492f40fb987fa919accce3b2926f368 /uicache.mm
parent2a72f832e35d56a748537c894b00a236bae8f16a (diff)
Adding gssc and updating uicache.
Diffstat (limited to 'uicache.mm')
-rw-r--r--uicache.mm27
1 files changed, 19 insertions, 8 deletions
diff --git a/uicache.mm b/uicache.mm
index e08fe5d..904b175 100644
--- a/uicache.mm
+++ b/uicache.mm
@@ -5,6 +5,10 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <objc/runtime.h>
+
+#include <MobileCoreServices/LSApplicationWorkspace.h>
+
@interface NSMutableArray (Cydia)
- (void) addInfoDictionary:(NSDictionary *)info;
@end
@@ -35,12 +39,15 @@ int main() {
NSString *path([NSString stringWithFormat:@"%@/Library/Caches/com.apple.mobile.installation.plist", NSHomeDirectory()]);
- if (NSMutableDictionary *cache = [[NSMutableDictionary alloc] initWithContentsOfFile:path]) {
- [cache autorelease];
+ 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,21 +59,25 @@ 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 (NSString *bundle = [info objectForKey:@"CFBundleIdentifier"]) {
+ [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 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");