]> git.saurik.com Git - uikittools.git/commitdiff
Adding gssc and updating uicache.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 6 Apr 2010 11:16:28 +0000 (11:16 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 6 Apr 2010 11:16:28 +0000 (11:16 +0000)
control
gssc.mm [new file with mode: 0644]
makefile
uicache.mm

diff --git a/control b/control
index 1163b4f66b0ec273036b7f96db1309d427529e53..c8c0a8ade2ace74c24289491b25c1569f6dcf5c0 100644 (file)
--- a/control
+++ b/control
@@ -4,8 +4,8 @@ Section: Utilities
 Installed-Size: %S
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
 Installed-Size: %S
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 1.0.2995-1
-Description: UIKit-related command line access utilities
+Version: 1.0.3160-1
+Description: UIKit/GraphicsServices command line access
 Name: UIKit Tools
 Author: Jay Freeman (saurik) <saurik@saurik.com>
 Depiction: http://cydia.saurik.com/info/uikittools/
 Name: UIKit Tools
 Author: Jay Freeman (saurik) <saurik@saurik.com>
 Depiction: http://cydia.saurik.com/info/uikittools/
diff --git a/gssc.mm b/gssc.mm
new file mode 100644 (file)
index 0000000..0c40ed5
--- /dev/null
+++ b/gssc.mm
@@ -0,0 +1,42 @@
+#import <GraphicsServices/GraphicsServices.h>
+#import <UIKit/UIKit.h>
+#include <stdio.h>
+#include <dlfcn.h>
+
+static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
+static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
+
+int main(int argc, char *argv[]) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NSString *name = nil;
+
+    if (argc == 2)
+        name = [NSString stringWithUTF8String:argv[0]];
+    else if (argc > 2) {
+        fprintf(stderr, "usage: %s [capability]\n", argv[0]);
+        exit(1);
+    }
+
+    $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
+    $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
+
+    const NSArray *capability;
+
+    if ($GSSystemCopyCapability != NULL) {
+        capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name)));
+        capability = [capability autorelease];
+    } else if ($GSSystemGetCapability != NULL) {
+        capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name)));
+    } else
+        capability = nil;
+
+    NSLog(@"%@", capability);
+
+    /*for (NSString *value in capability)
+        printf("%s\n", [value UTF8String]);*/
+
+    [pool release];
+
+    return 0;
+}
index 8386a1821b29628c1389b8350cea418d8058a6e5..d55c38afff874eb709f2bb84e50db4ec6c240274 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,4 +1,4 @@
-uikittools = uiduid uishoot uicache uiopen
+uikittools = uiduid uishoot uicache uiopen gssc
 
 all: $(uikittools)
 
 
 all: $(uikittools)
 
@@ -8,7 +8,7 @@ clean:
 .PHONY: all clean package
 
 %: %.mm
 .PHONY: all clean package
 
 %: %.mm
-       $${PKG_TARG}-g++ -o $@ $< -framework CoreFoundation -framework Foundation -framework UIKit -lobjc
+       $${PKG_TARG}-g++ -o $@ $< -framework CoreFoundation -framework Foundation -framework UIKit -framework GraphicsServices -F"$${PKG_ROOT}"/System/Library/PrivateFrameworks -lobjc
        ldid -S $@
 
 package: all
        ldid -S $@
 
 package: all
index e08fe5d49ea2bfa27b928671832ab8e835cb1505..904b1752b55c6654799df2fa898e63b7d483d770 100644 (file)
@@ -5,6 +5,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <objc/runtime.h>
+
+#include <MobileCoreServices/LSApplicationWorkspace.h>
+
 @interface NSMutableArray (Cydia)
 - (void) addInfoDictionary:(NSDictionary *)info;
 @end
 @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()]);
 
 
     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;
 
         NSFileManager *manager = [NSFileManager defaultManager];
         NSError *error = nil;
 
+        NSMutableArray *bundles([NSMutableArray arrayWithCapacity:16]);
+
         id system = [cache objectForKey:@"System"];
         if (system == nil)
             goto error;
         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 ([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];
                             [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];
 
                     }
                 }
         } 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");
         if (false) error:
             fprintf(stderr, "%s\n", error == nil ? strerror(errno) : [[error localizedDescription] UTF8String]);
     } else fprintf(stderr, "cannot open cache file. incorrect user?\n");