]> git.saurik.com Git - uikittools.git/blobdiff - uicache.mm
Merge iOS 8 compatible uicache code from limneos.
[uikittools.git] / uicache.mm
index 29694d66f6a8ab28a208a5010410f2ddbf68c6f2..2eafcddc9702062c8d0b4f77cd981ca66ac966f6 100644 (file)
 int main(int argc, const char *argv[]) {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
+    Class $LSApplicationWorkspace(objc_getClass("LSApplicationWorkspace"));
+    LSApplicationWorkspace *workspace($LSApplicationWorkspace == nil ? nil : [$LSApplicationWorkspace defaultWorkspace]);
+
+    if ([workspace respondsToSelector:@selector(_LSPrivateRebuildApplicationDatabasesForSystemApps:internal:user:)]) {
+        if (![workspace _LSPrivateRebuildApplicationDatabasesForSystemApps:YES internal:YES user:NO])
+            fprintf(stderr, "failed to rebuild application databases");
+        return 0;
+    }
+
     bool respring(false);
 
     NSString *home(NSHomeDirectory());
@@ -100,9 +109,6 @@ int main(int argc, const char *argv[]) {
 
     system("killall lsd");
 
-    Class $LSApplicationWorkspace(objc_getClass("LSApplicationWorkspace"));
-    LSApplicationWorkspace *workspace($LSApplicationWorkspace == nil ? nil : [$LSApplicationWorkspace defaultWorkspace]);
-
     if ([workspace respondsToSelector:@selector(invalidateIconCache:)])
         while (![workspace invalidateIconCache:nil])
             sleep(1);
@@ -180,7 +186,10 @@ int main(int argc, const char *argv[]) {
 
             for (NSString *identifier in bundles) {
                 NSString *path([bundles objectForKey:identifier]);
-                [workspace registerApplication:[NSURL fileURLWithPath:path]];
+                if (kCFCoreFoundationVersionNumber >= 800)
+                    [workspace registerApplicationDictionary:[after objectForKey:identifier]];
+                else
+                    [workspace registerApplication:[NSURL fileURLWithPath:path]];
             }
 
             for (NSString *path in removed)