]> git.saurik.com Git - winterboard.git/blobdiff - Library.mm
Temporary iOS 5 support.
[winterboard.git] / Library.mm
index a55c7d1c5c8d1c12ccafddb1aa58f20dc42ab358..65a799433c13f7a63db7562e02c7e14f6f896381 100644 (file)
@@ -476,7 +476,7 @@ MSHook(UIImage *, SBApplicationIcon$icon, SBApplicationIcon *self, SEL sel) {
 MSHook(UIImage *, SBApplicationIcon$generateIconImage$, SBApplicationIcon *self, SEL sel, int type) {
     if (type == 2)
         if (![Info_ wb$boolForKey:@"ComposeStoreIcons"]) {
-            if (IsWild_)
+            if (IsWild_ && false) // XXX: delete this code, it should not be supported
                 if (NSString *path72 = $pathForIcon$([self application], @"-72"))
                     return [UIImage imageWithContentsOfFile:path72];
             if (NSString *path = $pathForIcon$([self application]))
@@ -776,6 +776,18 @@ MSHook(id, SBUIController$init, SBUIController *self, SEL sel) {
     UIDevice *device([UIDevice currentDevice]);
     IsWild_ = [device respondsToSelector:@selector(isWildcat)] && [device isWildcat];
 
+    BOOL (*GSSystemHasCapability)(CFStringRef) = reinterpret_cast<BOOL (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemHasCapability"));
+
+    if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
+        [Info_ setObject:[NSNumber numberWithBool:(
+            !(Papered_ || GSSystemHasCapability != NULL && GSSystemHasCapability(CFSTR("homescreen-wallpaper"))) ||
+            [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
+            [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
+        )] forKey:@"UndockedIconLabels"];
+
+    if (Debug_)
+        NSLog(@"WB:Debug:Info = %@", [Info_ description]);
+
     if (Papered_) {
         UIImageView *&_wallpaperView(MSHookIvar<UIImageView *>(self, "_wallpaperView"));
         if (&_wallpaperView != NULL) {
@@ -1394,6 +1406,8 @@ MSHook(void, TranscriptController$loadView, mSMSMessageTranscriptController *sel
 MSHook(UIImage *, _UIImageWithName, NSString *name) {
     if (Debug_)
         NSLog(@"WB:Debug: _UIImageWithName(\"%@\")", name);
+    if (name == nil)
+        return nil;
 
     int identifier;
     bool packed;
@@ -1717,12 +1731,16 @@ extern "C" void WBInitialize() {
 
         $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
 
+        bool olden(dlsym(RTLD_DEFAULT, "GSLibraryCopyGenerationInfoValueForKey") == NULL);
+
+        if (olden)
+            $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
+
         $SBApplication = objc_getClass("SBApplication");
         $SBApplicationIcon = objc_getClass("SBApplicationIcon");
         $SBAwayView = objc_getClass("SBAwayView");
         $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
         $SBButtonBar = objc_getClass("SBButtonBar");
-        $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
         $SBDockIconListView = objc_getClass("SBDockIconListView");
         $SBIcon = objc_getClass("SBIcon");
         $SBIconBadge = objc_getClass("SBIconBadge");
@@ -1762,7 +1780,9 @@ extern "C" void WBInitialize() {
         WBRename(SBDockIconListView, setFrame:, setFrame$);
         MSHookMessage(object_getClass($SBDockIconListView), @selector(shouldShowNewDock), &$SBDockIconListView$shouldShowNewDock, &_SBDockIconListView$shouldShowNewDock);
 
-        WBRename(SBIconLabel, drawRect:, drawRect$);
+        if (olden)
+            WBRename(SBIconLabel, drawRect:, drawRect$);
+
         WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
         WBRename(SBIconLabel, setInDock:, setInDock$);
 
@@ -1801,15 +1821,5 @@ extern "C" void WBInitialize() {
 
     Docked_ = $getTheme$([NSArray arrayWithObjects:@"Dock.png", nil]);
 
-    if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
-        [Info_ setObject:[NSNumber numberWithBool:(
-            !Papered_ ||
-            [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
-            [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
-        )] forKey:@"UndockedIconLabels"];
-
-    if (Debug_)
-        NSLog(@"WB:Debug:Info = %@", [Info_ description]);
-
     [pool release];
 }