1 /* WinterBoard - Theme Manager for the iPhone
2 * Copyright (C) 2008-2010 Jay Freeman (saurik)
6 * Redistribution and use in source and binary
7 * forms, with or without modification, are permitted
8 * provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the
11 * above copyright notice, this list of conditions
12 * and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions
15 * and the following disclaimer in the documentation
16 * and/or other materials provided with the
18 * 3. The name of the author may not be used to endorse
19 * or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
24 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
33 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #define _trace() do { \
44 struct timeval _ctv; \
45 gettimeofday(&_ctv, NULL); \
50 fprintf(stderr, "%lu.%.6u[%f]:_trace()@%s:%u[%s]\n", \
51 _ctv.tv_sec, _ctv.tv_usec, \
52 (_ctv.tv_sec - _ltv.tv_sec) + (_ctv.tv_usec - _ltv.tv_usec) / 1000000.0, \
53 __FILE__, __LINE__, __FUNCTION__\
60 #import <CoreFoundation/CoreFoundation.h>
61 #import <Foundation/Foundation.h>
62 #import <CoreGraphics/CoreGraphics.h>
63 #import <ImageIO/CGImageSource.h>
65 #import <Celestial/AVController.h>
66 #import <Celestial/AVItem.h>
67 #import <Celestial/AVQueue.h>
69 #include <substrate.h>
71 #import <UIKit/UIKit.h>
73 #import <SpringBoard/SBApplication.h>
74 #import <SpringBoard/SBApplicationIcon.h>
75 #import <SpringBoard/SBAppWindow.h>
76 #import <SpringBoard/SBAwayView.h>
77 #import <SpringBoard/SBBookmarkIcon.h>
78 #import <SpringBoard/SBButtonBar.h>
79 #import <SpringBoard/SBCalendarIconContentsView.h>
80 #import <SpringBoard/SBIconController.h>
81 #import <SpringBoard/SBIconLabel.h>
82 #import <SpringBoard/SBIconList.h>
83 #import <SpringBoard/SBIconModel.h>
84 #import <SpringBoard/SBImageCache.h>
85 // XXX: #import <SpringBoard/SBSearchView.h>
86 #import <SpringBoard/SBSearchTableViewCell.h>
87 #import <SpringBoard/SBStatusBarContentsView.h>
88 #import <SpringBoard/SBStatusBarController.h>
89 #import <SpringBoard/SBStatusBarOperatorNameView.h>
90 #import <SpringBoard/SBStatusBarTimeView.h>
91 #import <SpringBoard/SBUIController.h>
92 #import <SpringBoard/SBWidgetApplicationIcon.h>
94 #import <MobileSMS/mSMSMessageTranscriptController.h>
96 #import <MediaPlayer/MPMoviePlayerController.h>
97 #import <MediaPlayer/MPVideoView.h>
98 #import <MediaPlayer/MPVideoView-PlaybackControl.h>
100 #import <CoreGraphics/CGGeometry.h>
102 #import <ChatKit/CKMessageCell.h>
104 extern "C" void __clear_cache (char *beg, char *end);
106 @protocol WinterBoard
110 Class $MPMoviePlayerController;
112 Class $WebCoreFrameBridge;
117 Class $UINavigationBar;
120 Class $CKMessageCell;
121 Class $CKTimestampView;
122 Class $CKTranscriptController;
123 Class $CKTranscriptTableView;
125 Class $SBApplication;
126 Class $SBApplicationIcon;
128 Class $SBBookmarkIcon;
130 Class $SBCalendarIconContentsView;
131 Class $SBDockIconListView;
134 Class $SBIconController;
138 //Class $SBImageCache;
140 Class $SBSearchTableViewCell;
141 Class $SBStatusBarContentsView;
142 Class $SBStatusBarController;
143 Class $SBStatusBarOperatorNameView;
144 Class $SBStatusBarTimeView;
145 Class $SBUIController;
146 Class $SBWidgetApplicationIcon;
151 @interface NSDictionary (WinterBoard)
152 - (UIColor *) wb$colorForKey:(NSString *)key;
153 - (BOOL) wb$boolForKey:(NSString *)key;
156 @implementation NSDictionary (WinterBoard)
158 - (UIColor *) wb$colorForKey:(NSString *)key {
159 NSString *value = [self objectForKey:key];
166 - (BOOL) wb$boolForKey:(NSString *)key {
167 if (NSString *value = [self objectForKey:key])
168 return [value boolValue];
174 static BOOL (*_GSFontGetUseLegacyFontMetrics)();
175 #define $GSFontGetUseLegacyFontMetrics() \
176 (_GSFontGetUseLegacyFontMetrics == NULL ? YES : _GSFontGetUseLegacyFontMetrics())
178 static bool Debug_ = false;
179 static bool Engineer_ = false;
180 static bool SummerBoard_ = true;
181 static bool SpringBoard_;
183 static UIImage *(*_UIApplicationImageWithName)(NSString *name);
184 static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path);
185 static CGImageRef (*_UIImageRefAtPath)(NSString *name, bool cache, UIImageOrientation *orientation, float *scale);
186 static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain);
187 static NSBundle *(*_UIKitBundle)();
188 static bool (*_UIPackedImageTableGetIdentifierForName)(NSString *, int *);
189 static int (*_UISharedImageNameGetIdentifier)(NSString *);
190 CGColorRef (*UIKBGetNamedColor)(CFStringRef colorName);
192 static NSMutableDictionary *UIImages_;
193 static NSMutableDictionary *PathImages_;
194 static NSMutableDictionary *Cache_;
195 static NSMutableDictionary *Strings_;
196 static NSMutableDictionary *Themed_;
197 static NSMutableDictionary *Bundles_;
199 static NSFileManager *Manager_;
200 static NSDictionary *English_;
201 static NSMutableDictionary *Info_;
202 static NSMutableArray *themes_;
204 static NSString *$getTheme$(NSArray *files, bool parent = false) {
206 if (NSString *path = [Themed_ objectForKey:files])
207 return reinterpret_cast<id>(path) == [NSNull null] ? nil : path;
210 NSLog(@"WB:Debug: %@", [files description]);
214 for (NSString *theme in themes_)
215 for (NSString *file in files) {
216 path = [NSString stringWithFormat:@"%@/%@", theme, file];
217 if ([Manager_ fileExistsAtPath:path]) {
218 path = parent ? theme : path;
226 [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast<id>(path)) forKey:files];
230 static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui) {
231 NSString *identifier = [bundle bundleIdentifier];
232 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
234 if (identifier != nil)
235 [names addObject:[NSString stringWithFormat:@"Bundles/%@/%@", identifier, file]];
236 if (NSString *folder = [[bundle bundlePath] lastPathComponent])
237 [names addObject:[NSString stringWithFormat:@"Folders/%@/%@", folder, file]];
239 [names addObject:[NSString stringWithFormat:@"UIImages/%@", file]];
241 #define remapResourceName(oldname, newname) \
242 else if ([file isEqualToString:(oldname)]) \
243 [names addObject:[NSString stringWithFormat:@"%@.png", newname]]; \
245 bool summer(SpringBoard_ && SummerBoard_);
247 if (identifier == nil);
248 else if ([identifier isEqualToString:@"com.apple.chatkit"])
249 [names addObject:[NSString stringWithFormat:@"Bundles/com.apple.MobileSMS/%@", file]];
250 else if ([identifier isEqualToString:@"com.apple.calculator"])
251 [names addObject:[NSString stringWithFormat:@"Files/Applications/Calculator.app/%@", file]];
253 remapResourceName(@"FSO_BG.png", @"StatusBar")
254 remapResourceName(Four_ ? @"SBDockBG-old.png" : @"SBDockBG.png", @"Dock")
255 remapResourceName(@"SBWeatherCelsius.png", @"Icons/Weather")
257 if (NSString *path = $getTheme$(names))
263 static NSString *$pathForIcon$(SBApplication *self, NSString *suffix = @"") {
264 NSString *identifier = [self bundleIdentifier];
265 NSString *path = [self path];
266 NSString *folder = [path lastPathComponent];
267 NSString *dname = [self displayName];
268 NSString *didentifier = [self displayIdentifier];
271 NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier);
273 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
275 /* XXX: I might need to keep this for backwards compatibility
276 if (identifier != nil)
277 [names addObject:[NSString stringWithFormat:@"Bundles/%@/icon.png", identifier]];
279 [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]]; */
281 #define testForIcon(Name) \
282 if (NSString *name = Name) \
283 [names addObject:[NSString stringWithFormat:@"Icons%@/%@.png", suffix, name]];
285 if (![didentifier isEqualToString:identifier])
286 testForIcon(didentifier);
288 testForIcon(identifier);
291 if ([identifier isEqualToString:@"com.apple.MobileSMS"])
294 if (didentifier != nil) {
295 testForIcon([English_ objectForKey:didentifier]);
297 NSArray *parts = [didentifier componentsSeparatedByString:@"-"];
298 if ([parts count] != 1)
299 if (NSDictionary *english = [[[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingString:@"/English.lproj/UIRoleDisplayNames.strings"]] autorelease])
300 testForIcon([english objectForKey:[parts lastObject]]);
303 if (NSString *path = $getTheme$(names))
309 @interface NSBundle (WinterBoard)
310 + (NSBundle *) wb$bundleWithFile:(NSString *)path;
313 @implementation NSBundle (WinterBoard)
315 + (NSBundle *) wb$bundleWithFile:(NSString *)path {
316 path = [path stringByDeletingLastPathComponent];
317 if (path == nil || [path length] == 0 || [path isEqualToString:@"/"])
320 NSBundle *bundle([Bundles_ objectForKey:path]);
321 if (reinterpret_cast<id>(bundle) == [NSNull null])
323 else if (bundle == nil) {
324 if ([Manager_ fileExistsAtPath:[path stringByAppendingPathComponent:@"Info.plist"]])
325 bundle = [NSBundle bundleWithPath:path];
327 bundle = [NSBundle wb$bundleWithFile:path];
329 NSLog(@"WB:Debug:PathBundle(%@, %@)", path, bundle);
330 [Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast<id>(bundle)) forKey:path];
338 @interface NSString (WinterBoard)
339 - (NSString *) wb$themedPath;
342 @implementation NSString (WinterBoard)
344 - (NSString *) wb$themedPath {
346 NSLog(@"WB:Debug:Bypass(\"%@\")", self);
348 if (NSBundle *bundle = [NSBundle wb$bundleWithFile:self]) {
349 NSString *file([self stringByResolvingSymlinksInPath]);
350 NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]);
351 if ([file hasPrefix:prefix]) {
352 NSUInteger length([prefix length]);
353 if (length != [file length])
354 if (NSString *path = $pathForFile$inBundle$([file substringFromIndex:(length + 1)], bundle, false))
364 void WBLogRect(const char *tag, struct CGRect rect) {
365 NSLog(@"%s:{%f,%f+%f,%f}", tag, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
368 void WBLogHierarchy(UIView *view, unsigned index = 0, unsigned indent = 0) {
369 CGRect frame([view frame]);
370 NSLog(@"%*s|%2d:%p:%s : {%f,%f+%f,%f} (%@)", indent * 3, "", index, view, class_getName([view class]), frame.origin.x, frame.origin.y, frame.size.width, frame.size.height, [view backgroundColor]);
372 for (UIView *child in [view subviews])
373 WBLogHierarchy(child, index++, indent + 1);
376 UIImage *$cacheForImage$(UIImage *image) {
377 CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB());
378 CGRect rect = {CGPointMake(1, 1), [image size]};
379 CGSize size = {rect.size.width + 2, rect.size.height + 2};
381 CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
382 CGColorSpaceRelease(space);
384 CGContextDrawImage(context, rect, [image CGImage]);
385 CGImageRef ref(CGBitmapContextCreateImage(context));
386 CGContextRelease(context);
388 UIImage *cache([UIImage imageWithCGImage:ref]);
394 /*MSHook(id, SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$, SBImageCache *self, SEL sel, NSString *name, unsigned width, unsigned height, unsigned capacity) {
395 //if ([name isEqualToString:@"icons"]) return nil;
396 return _SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$(self, sel, name, width, height, capacity);
399 MSHook(void, SBIconModel$cacheImageForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
400 NSString *key([icon displayIdentifier]);
402 if (UIImage *image = [icon icon]) {
403 CGSize size = [image size];
404 if (size.width != 59 || size.height != 60) {
405 UIImage *cache($cacheForImage$(image));
406 [Cache_ setObject:cache forKey:key];
411 _SBIconModel$cacheImageForIcon$(self, sel, icon);
414 MSHook(void, SBIconModel$cacheImagesForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
415 /* XXX: do I /really/ have to do this? figure out how to cache the small icon! */
416 _SBIconModel$cacheImagesForIcon$(self, sel, icon);
418 NSString *key([icon displayIdentifier]);
420 if (UIImage *image = [icon icon]) {
421 CGSize size = [image size];
422 if (size.width != 59 || size.height != 60) {
423 UIImage *cache($cacheForImage$(image));
424 [Cache_ setObject:cache forKey:key];
430 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
431 NSString *key([icon displayIdentifier]);
432 if (UIImage *image = [Cache_ objectForKey:key])
435 return _SBIconModel$getCachedImagedForIcon$(self, sel, icon);
438 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$smallIcon$, SBIconModel *self, SEL sel, SBIcon *icon, BOOL small) {
440 return _SBIconModel$getCachedImagedForIcon$smallIcon$(self, sel, icon, small);
441 NSString *key([icon displayIdentifier]);
442 if (UIImage *image = [Cache_ objectForKey:key])
445 return _SBIconModel$getCachedImagedForIcon$smallIcon$(self, sel, icon, small);
448 MSHook(id, SBSearchView$initWithFrame$, id /* XXX: SBSearchView */ self, SEL sel, struct CGRect frame) {
449 if ((self = _SBSearchView$initWithFrame$(self, sel, frame)) != nil) {
450 [self setBackgroundColor:[UIColor clearColor]];
451 for (UIView *child in [self subviews])
452 [child setBackgroundColor:[UIColor clearColor]];
456 MSHook(id, SBSearchTableViewCell$initWithStyle$reuseIdentifier$, SBSearchTableViewCell *self, SEL sel, int style, NSString *reuse) {
457 if ((self = _SBSearchTableViewCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
458 [self setBackgroundColor:[UIColor clearColor]];
462 MSHook(void, SBSearchTableViewCell$drawRect$, SBSearchTableViewCell *self, SEL sel, struct CGRect rect, BOOL selected) {
463 _SBSearchTableViewCell$drawRect$(self, sel, rect, selected);
464 float inset([self edgeInset]);
465 [[UIColor clearColor] set];
466 UIRectFill(CGRectMake(0, 0, inset, rect.size.height));
467 UIRectFill(CGRectMake(rect.size.width - inset, 0, inset, rect.size.height));
470 MSHook(UIImage *, SBApplicationIcon$icon, SBApplicationIcon *self, SEL sel) {
471 if (![Info_ wb$boolForKey:@"ComposeStoreIcons"])
472 if (NSString *path = $pathForIcon$([self application]))
473 return [UIImage imageWithContentsOfFile:path];
474 return _SBApplicationIcon$icon(self, sel);
477 MSHook(UIImage *, SBApplicationIcon$generateIconImage$, SBApplicationIcon *self, SEL sel, int type) {
479 if (![Info_ wb$boolForKey:@"ComposeStoreIcons"]) {
481 if (NSString *path72 = $pathForIcon$([self application], @"-72"))
482 return [UIImage imageWithContentsOfFile:path72];
483 if (NSString *path = $pathForIcon$([self application]))
484 if (UIImage *image = [UIImage imageWithContentsOfFile:path]) {
486 if ([$SBIcon respondsToSelector:@selector(defaultIconImageSize)])
487 width = [$SBIcon defaultIconImageSize].width;
490 return width == 59 ? image : [image _imageScaledToProportion:(width / 59.0) interpolationQuality:5];
493 return _SBApplicationIcon$generateIconImage$(self, sel, type);
496 MSHook(UIImage *, SBWidgetApplicationIcon$icon, SBWidgetApplicationIcon *self, SEL sel) {
498 NSLog(@"WB:Debug:Widget(%@:%@)", [self displayIdentifier], [self displayName]);
499 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
500 return [UIImage imageWithContentsOfFile:path];
501 return _SBWidgetApplicationIcon$icon(self, sel);
504 MSHook(UIImage *, SBBookmarkIcon$icon, SBBookmarkIcon *self, SEL sel) {
506 NSLog(@"WB:Debug:Bookmark(%@:%@)", [self displayIdentifier], [self displayName]);
507 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
508 return [UIImage imageWithContentsOfFile:path];
509 return _SBBookmarkIcon$icon(self, sel);
512 MSHook(NSString *, SBApplication$pathForIcon, SBApplication *self, SEL sel) {
513 if (NSString *path = $pathForIcon$(self))
515 return _SBApplication$pathForIcon(self, sel);
518 static UIImage *CachedImageAtPath(NSString *path) {
519 path = [path stringByResolvingSymlinksInPath];
520 UIImage *image = [PathImages_ objectForKey:path];
522 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
523 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
525 image = [image autorelease];
526 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:path];
530 MSHook(CGImageSourceRef, CGImageSourceCreateWithURL, CFURLRef url, CFDictionaryRef options) {
532 NSLog(@"WB:Debug: CGImageSourceCreateWithURL(\"%@\", %s)", url, options);
533 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
534 if (NSString *path = (NSString *) CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle))
535 if (NSString *themed = [path wb$themedPath])
537 url = (CFURLRef) [NSURL fileURLWithPath:themed];
538 CGImageSourceRef source(_CGImageSourceCreateWithURL(url, options));
543 MSHook(CGImageRef, _UIImageRefAtPath, NSString *name, bool cache, UIImageOrientation *orientation, float *scale) {
545 NSLog(@"WB:Debug: _UIImageRefAtPath(\"%@\")", name);
547 NSString *themed([name wb$themedPath]);
549 if (false && SpringBoard_ && SummerBoard_ && themed == name) {
550 if ([name isEqualToString:@"/System/Library/CoreServices/SpringBoard.app/SBDockBGT-Portrait.png"])
551 if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Dock.png"])) {
552 UIImage *image([UIImage imageWithContentsOfFile:path]);
553 CGImageRef ref([[image _imageScaledToProportion:2.4 interpolationQuality:5] imageRef]);
559 return __UIImageRefAtPath(themed, cache, orientation, scale);
562 /*MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) {
564 return __UIImageAtPath(name, nil);
566 NSString *key = [NSString stringWithFormat:@"B:%@/%@", [bundle bundleIdentifier], name];
567 UIImage *image = [PathImages_ objectForKey:key];
569 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
571 NSLog(@"WB:Debug: _UIImageAtPath(\"%@\", %@)", name, bundle);
572 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
573 image = CachedImageAtPath(path);
575 image = __UIImageAtPath(name, bundle);
576 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
581 MSHook(UIImage *, _UIApplicationImageWithName, NSString *name) {
582 NSBundle *bundle = [NSBundle mainBundle];
584 NSLog(@"WB:Debug: _UIApplicationImageWithName(\"%@\", %@)", name, bundle);
585 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
586 return CachedImageAtPath(path);
587 return __UIApplicationImageWithName(name);
590 #define WBDelegate(delegate) \
591 - (NSMethodSignature*) methodSignatureForSelector:(SEL)sel { \
593 NSLog(@"WB:MS:%s:(%s)", class_getName([self class]), sel_getName(sel)); \
594 if (NSMethodSignature *sig = [delegate methodSignatureForSelector:sel]) \
596 NSLog(@"WB:Error: [%s methodSignatureForSelector:(%s)]", class_getName([self class]), sel_getName(sel)); \
600 - (void) forwardInvocation:(NSInvocation*)inv { \
601 SEL sel = [inv selector]; \
602 if ([delegate respondsToSelector:sel]) \
603 [inv invokeWithTarget:delegate]; \
605 NSLog(@"WB:Error: [%s forwardInvocation:(%s)]", class_getName([self class]), sel_getName(sel)); \
608 MSHook(NSString *, NSBundle$pathForResource$ofType$, NSBundle *self, SEL sel, NSString *resource, NSString *type) {
609 NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
611 NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
612 if (NSString *path = $pathForFile$inBundle$(file, self, false))
614 return _NSBundle$pathForResource$ofType$(self, sel, resource, type);
617 void $setBarStyle$_(NSString *name, int &style) {
619 NSLog(@"WB:Debug:%@Style:%d", name, style);
620 NSNumber *number = nil;
622 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style-%d", name, style]];
624 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style", name]];
626 style = [number intValue];
628 NSLog(@"WB:Debug:%@Style=%d", name, style);
632 MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *self, SEL sel, CGRect rect) {
633 NSBundle *bundle([NSBundle mainBundle]);
635 CFLocaleRef locale(CFLocaleCopyCurrent());
636 CFDateFormatterRef formatter(CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle));
639 CFDateRef now(CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()));
641 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NUMBER_FORMAT" value:@"d" table:@"SpringBoard"]);
642 CFStringRef date(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
643 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NAME_FORMAT" value:@"cccc" table:@"SpringBoard"]);
644 CFStringRef day(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
648 CFRelease(formatter);
650 NSString *datestyle([@""
651 "font-family: Helvetica; "
652 "font-weight: bold; "
655 "" stringByAppendingString:(IsWild_
656 ? @"font-size: 54px; "
657 : @"font-size: 39px; "
660 NSString *daystyle([@""
661 "font-family: Helvetica; "
662 "font-weight: bold; "
664 "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px; "
665 "" stringByAppendingString:(IsWild_
666 ? @"font-size: 11px; "
667 : @"font-size: 9px; "
670 if (NSString *style = [Info_ objectForKey:@"CalendarIconDateStyle"])
671 datestyle = [datestyle stringByAppendingString:style];
672 if (NSString *style = [Info_ objectForKey:@"CalendarIconDayStyle"])
673 daystyle = [daystyle stringByAppendingString:style];
675 float width([self bounds].size.width);
677 CGSize datesize = [(NSString *)date sizeWithStyle:datestyle forWidth:(width + leeway)];
678 CGSize daysize = [(NSString *)day sizeWithStyle:daystyle forWidth:(width + leeway)];
680 unsigned base0(IsWild_ ? 89 : 70);
681 if ($GSFontGetUseLegacyFontMetrics())
683 unsigned base1(IsWild_ ? 18 : 16);
690 [(NSString *)date drawAtPoint:CGPointMake(
691 (width + 1 - datesize.width) / 2, (base0 - datesize.height) / 2
692 ) withStyle:datestyle];
694 [(NSString *)day drawAtPoint:CGPointMake(
695 (width + 1 - daysize.width) / 2, (base1 - daysize.height) / 2
696 ) withStyle:daystyle];
702 /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) {
705 if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"])
706 style = [number intValue];
708 if (UIColor *color = [Info_ wb$colorForKey:@"NavigationBarTint"])
711 return [self wb$initWithFrame:frame withBarStyle:style withTintColor:tint];
714 /*static id UINavigationBar$initWithCoder$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame, NSCoder *coder) {
715 self = [self wb$initWithCoder:coder];
718 UINavigationBar$setBarStyle$_(self);
722 static id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame) {
723 self = [self wb$initWithFrame:frame];
726 UINavigationBar$setBarStyle$_(self);
730 MSHook(void, UIToolbar$setBarStyle$, UIToolbar *self, SEL sel, int style) {
731 $setBarStyle$_(@"Toolbar", style);
732 return _UIToolbar$setBarStyle$(self, sel, style);
735 MSHook(void, UINavigationBar$setBarStyle$, UINavigationBar *self, SEL sel, int style) {
736 $setBarStyle$_(@"NavigationBar", style);
737 return _UINavigationBar$setBarStyle$(self, sel, style);
740 MSHook(void, SBButtonBar$didMoveToSuperview, UIView *self, SEL sel) {
741 [[self superview] setBackgroundColor:[UIColor clearColor]];
742 _SBButtonBar$didMoveToSuperview(self, sel);
745 MSHook(void, SBStatusBarContentsView$didMoveToSuperview, UIView *self, SEL sel) {
746 [[self superview] setBackgroundColor:[UIColor clearColor]];
747 _SBStatusBarContentsView$didMoveToSuperview(self, sel);
750 MSHook(UIImage *, UIImage$defaultDesktopImage, UIImage *self, SEL sel) {
752 NSLog(@"WB:Debug:DefaultDesktopImage");
753 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"LockBackground.png", @"LockBackground.jpg", nil]))
754 return [UIImage imageWithContentsOfFile:path];
755 return _UIImage$defaultDesktopImage(self, sel);
758 static NSArray *Wallpapers_;
759 static bool Papered_;
761 static NSString *WallpaperFile_;
762 static UIImageView *WallpaperImage_;
763 static UIWebDocumentView *WallpaperPage_;
764 static NSURL *WallpaperURL_;
766 #define _release(object) \
767 do if (object != nil) { \
772 MSHook(id, SBUIController$init, SBUIController *self, SEL sel) {
773 self = _SBUIController$init(self, sel);
777 UIDevice *device([UIDevice currentDevice]);
778 IsWild_ = [device respondsToSelector:@selector(isWildcat)] && [device isWildcat];
781 UIImageView *&_wallpaperView(MSHookIvar<UIImageView *>(self, "_wallpaperView"));
782 if (&_wallpaperView != NULL) {
783 [_wallpaperView removeFromSuperview];
784 [_wallpaperView release];
785 _wallpaperView = nil;
789 UIView *&_contentLayer(MSHookIvar<UIView *>(self, "_contentLayer"));
790 UIView *&_contentView(MSHookIvar<UIView *>(self, "_contentView"));
793 if (&_contentLayer != NULL)
794 player = &_contentLayer;
795 else if (&_contentView != NULL)
796 player = &_contentView;
799 UIView *layer(player == NULL ? nil : *player);
801 UIWindow *window([[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]);
802 UIView *content([[[UIView alloc] initWithFrame:[window frame]] autorelease]);
803 [window setContentView:content];
805 UIWindow *&_window(MSHookIvar<UIWindow *>(self, "_window"));
806 [window setBackgroundColor:[_window backgroundColor]];
807 [_window setBackgroundColor:[UIColor clearColor]];
809 [window setLevel:-1000];
810 [window setHidden:NO];
812 /*if (player != NULL)
815 [content setBackgroundColor:[layer backgroundColor]];
816 [layer setBackgroundColor:[UIColor clearColor]];
819 if (!SummerBoard_ || !IsWild_)
822 CGRect bounds([content bounds]);
823 bounds.origin.y = -30;
824 indirect = [[[UIView alloc] initWithFrame:bounds] autorelease];
825 [content addSubview:indirect];
826 [indirect zoomToScale:2.4];
829 _release(WallpaperFile_);
830 _release(WallpaperImage_);
831 _release(WallpaperPage_);
832 _release(WallpaperURL_);
834 if (NSString *theme = $getTheme$(Wallpapers_, true)) {
835 NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"];
836 if ([Manager_ fileExistsAtPath:mp4]) {
840 static AVController *controller_(nil);
841 if (controller_ == nil) {
842 AVQueue *queue([AVQueue avQueue]);
843 controller_ = [[AVController avControllerWithQueue:queue error:&error] retain];
846 AVQueue *queue([controller_ queue]);
848 UIView *video([[[UIView alloc] initWithFrame:[indirect bounds]] autorelease]);
849 [controller_ setLayer:[video _layer]];
851 AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]);
852 [queue appendItem:item error:&error];
854 [controller_ play:&error];
855 #elif UseMPMoviePlayerController
856 NSURL *url([NSURL fileURLWithPath:mp4]);
857 MPMoviePlayerController *controller = [[$MPMoviePlayerController alloc] initWithContentURL:url];
858 controller.movieControlMode = MPMovieControlModeHidden;
861 MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[indirect bounds]] autorelease];
862 [video setMovieWithPath:mp4];
863 [video setRepeatMode:1];
864 [video setRepeatGap:-1];
865 [video playFromBeginning];;
868 [indirect addSubview:video];
871 NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"];
872 NSString *jpg = [theme stringByAppendingPathComponent:@"Wallpaper.jpg"];
875 if ([Manager_ fileExistsAtPath:png])
877 else if ([Manager_ fileExistsAtPath:jpg])
883 image = [[UIImage alloc] initWithContentsOfFile:path];
885 image = [image autorelease];
889 WallpaperFile_ = [path retain];
890 WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
891 if (NSNumber *number = [Info_ objectForKey:@"WallpaperAlpha"])
892 [WallpaperImage_ setAlpha:[number floatValue]];
893 [indirect addSubview:WallpaperImage_];
896 NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"];
897 if ([Manager_ fileExistsAtPath:html]) {
898 CGRect bounds = [indirect bounds];
900 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
901 [view setAutoresizes:true];
903 WallpaperPage_ = [view retain];
904 WallpaperURL_ = [[NSURL fileURLWithPath:html] retain];
906 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
908 [view setBackgroundColor:[UIColor clearColor]];
909 if ([view respondsToSelector:@selector(setDrawsBackground:)])
910 [view setDrawsBackground:NO];
911 [[view webView] setDrawsBackground:NO];
913 [indirect addSubview:view];
917 for (size_t i(0), e([themes_ count]); i != e; ++i) {
918 NSString *theme = [themes_ objectAtIndex:(e - i - 1)];
919 NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"];
920 if ([Manager_ fileExistsAtPath:html]) {
921 CGRect bounds = [indirect bounds];
923 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
924 [view setAutoresizes:true];
926 NSURL *url = [NSURL fileURLWithPath:html];
927 [view loadRequest:[NSURLRequest requestWithURL:url]];
929 [view setBackgroundColor:[UIColor clearColor]];
930 if ([view respondsToSelector:@selector(setDrawsBackground:)])
931 [view setDrawsBackground:NO];
932 [[view webView] setDrawsBackground:NO];
934 [indirect addSubview:view];
941 MSHook(void, SBAwayView$updateDesktopImage$, SBAwayView *self, SEL sel, UIImage *image) {
942 NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]);
943 UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
945 if (path != nil && _backgroundView != nil)
948 _SBAwayView$updateDesktopImage$(self, sel, image);
951 CGRect bounds = [self bounds];
953 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
954 [view setAutoresizes:true];
956 if (WallpaperPage_ != nil)
957 [WallpaperPage_ release];
958 WallpaperPage_ = [view retain];
960 if (WallpaperURL_ != nil)
961 [WallpaperURL_ release];
962 WallpaperURL_ = [[NSURL fileURLWithPath:path] retain];
964 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
966 [[view webView] setDrawsBackground:false];
967 [view setBackgroundColor:[UIColor clearColor]];
969 [self insertSubview:view aboveSubview:_backgroundView];
973 /*extern "C" CGColorRef CGGStateGetSystemColor(void *);
974 extern "C" CGColorRef CGGStateGetFillColor(void *);
975 extern "C" CGColorRef CGGStateGetStrokeColor(void *);
976 extern "C" NSString *UIStyleStringFromColor(CGColorRef);*/
978 /* WBTimeLabel {{{ */
979 @interface WBTimeLabel : NSProxy {
981 _transient SBStatusBarTimeView *view_;
984 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view;
988 @implementation WBTimeLabel
995 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view {
996 time_ = [time retain];
1001 - (NSString *) description {
1007 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
1008 if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
1009 BOOL &_mode(MSHookIvar<BOOL>(view_, "_mode"));;
1011 [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
1012 "font-family: Helvetica; "
1013 "font-weight: bold; "
1016 "%@", _mode ? @"white" : @"black", custom]];
1021 return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
1026 /* WBBadgeLabel {{{ */
1027 @interface WBBadgeLabel : NSProxy {
1031 - (id) initWithBadge:(NSString *)badge;
1032 - (NSString *) description;
1036 @implementation WBBadgeLabel
1043 - (id) initWithBadge:(NSString *)badge {
1044 badge_ = [badge retain];
1048 - (NSString *) description {
1049 return [badge_ description];
1054 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
1055 if (NSString *custom = [Info_ objectForKey:@"BadgeStyle"]) {
1056 [badge_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
1057 "font-family: Helvetica; "
1058 "font-weight: bold; "
1066 return [badge_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
1072 MSHook(void, SBIcon$setAlpha$, SBIcon *self, SEL sel, float alpha) {
1073 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
1074 alpha = [number floatValue];
1075 return _SBIcon$setAlpha$(self, sel, alpha);
1078 MSHook(id, SBIconBadge$initWithBadge$, SBIconBadge *self, SEL sel, NSString *badge) {
1079 if ((self = _SBIconBadge$initWithBadge$(self, sel, badge)) != nil) {
1080 id &_badge(MSHookIvar<id>(self, "_badge"));
1082 if (id label = [[WBBadgeLabel alloc] initWithBadge:[_badge autorelease]])
1087 void SBStatusBarController$setStatusBarMode(int &mode) {
1089 NSLog(@"WB:Debug:setStatusBarMode:%d", mode);
1090 if (mode < 100) // 104:hidden 105:glowing
1091 if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"])
1092 mode = [number intValue];
1095 /*MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int animation) {
1096 NSLog(@"mode:%d orientation:%d duration:%f animation:%d", mode, orientation, duration, animation);
1097 SBStatusBarController$setStatusBarMode(mode);
1098 return _SBStatusBarController$setStatusBarMode$orientation$duration$animation$(self, sel, mode, orientation, duration, animation);
1101 MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int fenceID, int animation) {
1102 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d", mode, orientation, duration, fenceID, animation);
1103 SBStatusBarController$setStatusBarMode(mode);
1104 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, fenceID, animation);
1107 MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int fenceID, int animation, double startTime) {
1108 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d startTime:%f", mode, orientation, duration, fenceID, animation, startTime);
1109 SBStatusBarController$setStatusBarMode(mode);
1110 //NSLog(@"mode=%u", mode);
1111 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$(self, sel, mode, orientation, duration, fenceID, animation, startTime);
1114 /*MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) {
1115 if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"])
1116 mode = [number intValue];
1117 return _SBStatusBarContentsView$initWithStatusBar$mode$(self, sel, bar, mode);
1120 MSHook(NSString *, SBStatusBarOperatorNameView$operatorNameStyle, SBStatusBarOperatorNameView *self, SEL sel) {
1121 NSString *style(_SBStatusBarOperatorNameView$operatorNameStyle(self, sel));
1123 NSLog(@"operatorNameStyle= %@", style);
1124 if (NSString *custom = [Info_ objectForKey:@"OperatorNameStyle"])
1125 style = [NSString stringWithFormat:@"%@; %@", style, custom];
1129 MSHook(void, SBStatusBarOperatorNameView$setOperatorName$fullSize$, SBStatusBarOperatorNameView *self, SEL sel, NSString *name, BOOL full) {
1131 NSLog(@"setOperatorName:\"%@\" fullSize:%u", name, full);
1132 return _SBStatusBarOperatorNameView$setOperatorName$fullSize$(self, sel, name, NO);
1135 // XXX: replace this with [SBStatusBarTimeView tile]
1136 MSHook(void, SBStatusBarTimeView$drawRect$, SBStatusBarTimeView *self, SEL sel, CGRect rect) {
1137 id &_time(MSHookIvar<id>(self, "_time"));
1138 if (_time != nil && [_time class] != [WBTimeLabel class])
1139 object_setInstanceVariable(self, "_time", reinterpret_cast<void *>([[WBTimeLabel alloc] initWithTime:[_time autorelease] view:self]));
1140 return _SBStatusBarTimeView$drawRect$(self, sel, rect);
1143 @interface UIView (WinterBoard)
1144 - (bool) wb$isWBImageView;
1145 - (void) wb$logHierarchy;
1148 @implementation UIView (WinterBoard)
1150 - (bool) wb$isWBImageView {
1154 - (void) wb$logHierarchy {
1155 WBLogHierarchy(self);
1160 @interface WBImageView : UIImageView {
1163 - (bool) wb$isWBImageView;
1164 - (void) wb$updateFrame;
1167 @implementation WBImageView
1169 - (bool) wb$isWBImageView {
1173 - (void) wb$updateFrame {
1174 CGRect frame([self frame]);
1177 for (UIView *view(self); ; ) {
1178 view = [view superview];
1181 frame.origin.y -= [view frame].origin.y;
1184 [self setFrame:frame];
1189 MSHook(void, SBIconList$setFrame$, SBIconList *self, SEL sel, CGRect frame) {
1190 NSArray *subviews([self subviews]);
1191 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1192 if (view != nil && [view wb$isWBImageView])
1193 [view wb$updateFrame];
1194 _SBIconList$setFrame$(self, sel, frame);
1197 MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *self, SEL sel) {
1198 SBIconModel *&_iconModel(MSHookIvar<SBIconModel *>(self, "_iconModel"));
1199 NSArray *lists([_iconModel iconLists]);
1201 for (unsigned i(0), e([lists count]); i != e; ++i)
1202 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Page%u.png", i]])) {
1203 SBIconList *list([lists objectAtIndex:i]);
1204 NSArray *subviews([list subviews]);
1206 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1207 if (view == nil || ![view wb$isWBImageView]) {
1208 view = [[[WBImageView alloc] init] autorelease];
1209 [list insertSubview:view atIndex:0];
1212 UIImage *image([UIImage imageWithContentsOfFile:path]);
1214 CGRect frame([view frame]);
1215 frame.size = [image size];
1216 [view setFrame:frame];
1218 [view setImage:image];
1219 [view wb$updateFrame];
1222 return _SBIconController$noteNumberOfIconListsChanged(self, sel);
1225 MSHook(id, SBIconLabel$initWithSize$label$, SBIconLabel *self, SEL sel, CGSize size, NSString *label) {
1226 self = _SBIconLabel$initWithSize$label$(self, sel, size, label);
1228 [self setClipsToBounds:NO];
1232 MSHook(void, SBIconLabel$setInDock$, SBIconLabel *self, SEL sel, BOOL docked) {
1233 id &_label(MSHookIvar<id>(self, "_label"));
1234 if (![Info_ wb$boolForKey:@"UndockedIconLabels"])
1236 if (_label != nil && [_label respondsToSelector:@selector(setInDock:)])
1237 [_label setInDock:docked];
1238 return _SBIconLabel$setInDock$(self, sel, docked);
1241 MSHook(BOOL, SBDockIconListView$shouldShowNewDock, id self, SEL sel) {
1242 return SummerBoard_ && Docked_ ? NO : _SBDockIconListView$shouldShowNewDock(self, sel);
1245 MSHook(void, SBDockIconListView$setFrame$, id self, SEL sel, CGRect frame) {
1246 _SBDockIconListView$setFrame$(self, sel, frame);
1249 MSHook(NSString *, NSBundle$localizedStringForKey$value$table$, NSBundle *self, SEL sel, NSString *key, NSString *value, NSString *table) {
1250 NSString *identifier = [self bundleIdentifier];
1251 NSLocale *locale = [NSLocale currentLocale];
1252 NSString *language = [locale objectForKey:NSLocaleLanguageCode];
1254 NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language);
1255 NSString *file = table == nil ? @"Localizable" : table;
1256 NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file];
1257 NSDictionary *strings;
1258 if ((strings = [Strings_ objectForKey:name]) != nil) {
1259 if (static_cast<id>(strings) != [NSNull null]) strings:
1260 if (NSString *value = [strings objectForKey:key])
1262 } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
1265 if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
1266 [Strings_ setObject:[strings autorelease] forKey:name];
1270 [Strings_ setObject:[NSNull null] forKey:name];
1271 return _NSBundle$localizedStringForKey$value$table$(self, sel, key, value, table);
1274 @class WebCoreFrameBridge;
1275 MSHook(CGSize, WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$, WebCoreFrameBridge *self, SEL sel, id node, float width) {
1278 void **core(reinterpret_cast<void **>([node _node]));
1279 if (core == NULL || core[6] == NULL)
1281 return _WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(self, sel, node, width);
1284 MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
1285 CGRect bounds = [self bounds];
1287 static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
1290 Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
1291 docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
1293 NSString *label(MSHookIvar<NSString *>(self, "_label"));
1295 NSString *style = [NSString stringWithFormat:@""
1296 "font-family: Helvetica; "
1297 "font-weight: bold; "
1299 "", (docked || !SummerBoard_ ? @"white" : @"#b3b3b3"), (IsWild_
1300 ? @"font-size: 12px; "
1301 : @"font-size: 11px; "
1305 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px 1px 0px; "];
1307 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
1309 bool ellipsis(false);
1310 float max = 75, width;
1312 width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
1315 size_t length([label length]);
1316 float spacing((width - max) / (length - 1));
1318 if (spacing > 1.25) {
1320 label = [label substringToIndex:(length - 1)];
1324 style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
1328 label = [label stringByAppendingString:@"..."];
1330 if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
1331 style = [style stringByAppendingString:custom];
1333 CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];
1334 [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
1337 MSHook(void, CKMessageCell$addBalloonView$, id self, SEL sel, CKBalloonView *balloon) {
1338 _CKMessageCell$addBalloonView$(self, sel, balloon);
1339 [balloon setBackgroundColor:[UIColor clearColor]];
1342 MSHook(id, CKMessageCell$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1343 if ((self = _CKMessageCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1344 [[self contentView] setBackgroundColor:[UIColor clearColor]];
1348 MSHook(id, CKTimestampView$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1349 if ((self = _CKTimestampView$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1350 UILabel *&_label(MSHookIvar<UILabel *>(self, "_label"));
1351 [_label setBackgroundColor:[UIColor clearColor]];
1355 MSHook(void, CKTranscriptTableView$setSeparatorStyle$, id self, SEL sel, int style) {
1356 _CKTranscriptTableView$setSeparatorStyle$(self, sel, UITableViewCellSeparatorStyleNone);
1359 MSHook(id, CKTranscriptTableView$initWithFrame$style$, id self, SEL sel, CGRect frame, int style) {
1361 if ((self = _CKTranscriptTableView$initWithFrame$style$(self, sel, frame, style)) != nil) {
1362 [self setSeparatorStyle:UITableViewCellSeparatorStyleNone];
1366 MSHook(void, TranscriptController$loadView, mSMSMessageTranscriptController *self, SEL sel) {
1367 _TranscriptController$loadView(self, sel);
1369 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
1370 if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
1371 [image autorelease];
1373 UIView *&_transcriptTable(MSHookIvar<UIView *>(self, "_transcriptTable"));
1374 UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
1376 if (&_transcriptTable != NULL)
1377 table = _transcriptTable;
1378 else if (&_transcriptLayer != NULL)
1379 table = _transcriptLayer;
1383 UIView *placard(table != nil ? [table superview] : MSHookIvar<UIView *>(self, "_backPlacard"));
1384 UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]);
1387 [placard insertSubview:background atIndex:0];
1389 [table setBackgroundColor:[UIColor clearColor]];
1390 [placard insertSubview:background belowSubview:table];
1395 MSHook(UIImage *, _UIImageWithName, NSString *name) {
1397 NSLog(@"WB:Debug: _UIImageWithName(\"%@\")", name);
1402 if (_UIPackedImageTableGetIdentifierForName != NULL)
1403 packed = _UIPackedImageTableGetIdentifierForName(name, &identifier);
1404 else if (_UISharedImageNameGetIdentifier != NULL) {
1405 identifier = _UISharedImageNameGetIdentifier(name);
1406 packed = identifier != -1;
1413 NSLog(@"WB:Debug: _UISharedImageNameGetIdentifier(\"%@\") = %d", name, identifier);
1416 return __UIImageWithName(name);
1418 NSNumber *key([NSNumber numberWithInt:identifier]);
1419 UIImage *image([UIImages_ objectForKey:key]);
1421 return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithName(name) : image;
1422 if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {
1423 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
1425 [image autorelease];
1427 [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1428 return image == nil ? __UIImageWithName(name) : image;
1432 MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
1433 NSString *key([NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name]);
1434 UIImage *image([PathImages_ objectForKey:key]);
1436 return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithNameInDomain(name, domain) : image;
1438 NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);
1439 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {
1440 image = [[UIImage alloc] initWithContentsOfFile:path];
1442 [image autorelease];
1444 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1445 return image == nil ? __UIImageWithNameInDomain(name, domain) : image;
1448 MSHook(CGColorRef, UIKBGetNamedColor, CFStringRef colorName)
1450 static CFMutableDictionaryRef keyboardColors;
1451 if (!keyboardColors) {
1452 keyboardColors = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
1453 NSString *path = [[NSBundle bundleWithPath:@"/System/Library/Frameworks/UIKit.framework"] pathForResource:@"UIKBColors" ofType:@"plist"];
1454 NSDictionary *colorSettings = [NSDictionary dictionaryWithContentsOfFile:path];
1455 if (colorSettings) {
1456 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
1457 for (NSString *settingName in [colorSettings allKeys]) {
1458 NSArray *c = [colorSettings objectForKey:settingName];
1459 CGFloat components[4];
1460 switch ([c count]) {
1462 components[0] = [[c objectAtIndex:0] floatValue];
1463 components[1] = components[0];
1464 components[2] = components[0];
1465 components[3] = 1.0f;
1468 components[0] = [[c objectAtIndex:0] floatValue];
1469 components[1] = components[0];
1470 components[2] = components[0];
1471 components[0] = [[c objectAtIndex:1] floatValue];
1474 components[0] = [[c objectAtIndex:0] floatValue];
1475 components[1] = [[c objectAtIndex:1] floatValue];
1476 components[2] = [[c objectAtIndex:2] floatValue];
1477 components[3] = 1.0f;
1480 components[0] = [[c objectAtIndex:0] floatValue];
1481 components[1] = [[c objectAtIndex:1] floatValue];
1482 components[2] = [[c objectAtIndex:2] floatValue];
1483 components[3] = [[c objectAtIndex:3] floatValue];
1488 CGColorRef color = CGColorCreate(colorSpace, components);
1489 CFDictionarySetValue(keyboardColors, settingName, color);
1492 CGColorSpaceRelease(colorSpace);
1495 return (CGColorRef)CFDictionaryGetValue(keyboardColors, colorName) ?: _UIKBGetNamedColor(colorName);
1498 MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
1500 NSLog(@"WB:Debug: GSFontCreateWithName(\"%s\", %f)", name, size);
1501 if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
1502 name = [font UTF8String];
1503 //if (NSString *scale = [Info_ objectForKey:[NSString stringWithFormat:@"FontScale-%s", name]])
1504 // size *= [scale floatValue];
1505 return _GSFontCreateWithName(name, traits, size);
1508 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
1509 #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
1511 bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
1513 MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
1515 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %p, %u)", a0, a1, a2);
1516 bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
1518 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);
1521 NSString *path = [NSString stringWithUTF8String:a1];
1522 if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
1523 NSString *file = [path substringFromIndex:31];
1524 for (NSString *theme in themes_) {
1525 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
1526 if ([Manager_ fileExistsAtPath:path]) {
1527 strcpy(a1, [path UTF8String]);
1536 static void ChangeWallpaper(
1537 CFNotificationCenterRef center,
1541 CFDictionaryRef info
1544 NSLog(@"WB:Debug:ChangeWallpaper!");
1547 if (WallpaperFile_ != nil) {
1548 image = [[UIImage alloc] initWithContentsOfFile:WallpaperFile_];
1550 image = [image autorelease];
1553 if (WallpaperImage_ != nil)
1554 [WallpaperImage_ setImage:image];
1555 if (WallpaperPage_ != nil)
1556 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
1560 #define WBRename(name, sel, imp) \
1561 _ ## name ## $ ## imp = MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp)
1563 template <typename Type_>
1564 static void nlset(Type_ &function, struct nlist *nl, size_t index) {
1565 struct nlist &name(nl[index]);
1566 uintptr_t value(name.n_value);
1567 if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
1568 value |= 0x00000001;
1569 function = reinterpret_cast<Type_>(value);
1572 template <typename Type_>
1573 static void dlset(Type_ &function, const char *name) {
1574 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
1577 /*static void WBImage(const struct mach_header* mh, intptr_t vmaddr_slide) {
1578 uint32_t count(_dyld_image_count());
1579 for (uint32_t index(0); index != count; ++index)
1580 if (_dyld_get_image_header(index) == mh) {
1581 CGImageSourceRef (*CGImageSourceCreateWithURL)(CFURLRef url, CFDictionaryRef options);
1582 dlset(CGImageSourceCreateWithURL, "CGImageSourceCreateWithURL");
1583 MSHookFunction(&CGImageSourceCreateWithURL, &$CGImageSourceCreateWithURL, &_CGImageSourceCreateWithURL);
1587 extern "C" void WBInitialize() {
1588 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
1590 NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);
1592 NSLog(@"WB:Notice: WinterBoard");
1594 dlset(_GSFontGetUseLegacyFontMetrics, "GSFontGetUseLegacyFontMetrics");
1596 //if ([NSBundle bundleWithIdentifier:@"com.apple.ImageIO.framework"] != nil)
1597 MSHookFunction(&CGImageSourceCreateWithURL, &$CGImageSourceCreateWithURL, &_CGImageSourceCreateWithURL);
1599 // _dyld_register_func_for_add_image(&WBImage);
1603 if ([NSBundle bundleWithIdentifier:@"com.apple.UIKit"] != nil) {
1605 memset(nl, 0, sizeof(nl));
1606 nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName";
1607 nl[1].n_un.n_name = (char *) "__UIImageAtPath";
1608 nl[2].n_un.n_name = (char *) "__UIImageRefAtPath";
1609 nl[3].n_un.n_name = (char *) "__UIImageWithNameInDomain";
1610 nl[4].n_un.n_name = (char *) "__UIKitBundle";
1611 nl[5].n_un.n_name = (char *) "__UIPackedImageTableGetIdentifierForName";
1612 nl[6].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";
1615 nlset(_UIApplicationImageWithName, nl, 0);
1616 nlset(_UIImageAtPath, nl, 1);
1617 nlset(_UIImageRefAtPath, nl, 2);
1618 nlset(_UIImageWithNameInDomain, nl, 3);
1619 nlset(_UIKitBundle, nl, 4);
1620 nlset(_UIPackedImageTableGetIdentifierForName, nl, 5);
1621 nlset(_UISharedImageNameGetIdentifier, nl, 6);
1623 MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
1624 MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath);
1625 MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
1626 MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
1628 dlset(UIKBGetNamedColor, "UIKBGetNamedColor");
1629 if (UIKBGetNamedColor != NULL && identifier) {
1630 MSHookFunction(UIKBGetNamedColor, &$UIKBGetNamedColor, &_UIKBGetNamedColor);
1635 MSHookFunction(&GSFontCreateWithName, &$GSFontCreateWithName, &_GSFontCreateWithName);
1637 if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {
1640 memset(nl, 0, sizeof(nl));
1641 nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb";
1642 nlist(AudioToolbox, nl);
1643 nlset(_Z24GetFileNameForThisActionmPcRb, nl, 0);
1644 MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &__Z24GetFileNameForThisActionmPcRb);
1648 $NSBundle = objc_getClass("NSBundle");
1650 _NSBundle$localizedStringForKey$value$table$ = MSHookMessage($NSBundle, @selector(localizedStringForKey:value:table:), &$NSBundle$localizedStringForKey$value$table$);
1651 _NSBundle$pathForResource$ofType$ = MSHookMessage($NSBundle, @selector(pathForResource:ofType:), &$NSBundle$pathForResource$ofType$);
1653 $UIImage = objc_getClass("UIImage");
1654 $UINavigationBar = objc_getClass("UINavigationBar");
1655 $UIToolbar = objc_getClass("UIToolbar");
1657 _UIImage$defaultDesktopImage = MSHookMessage(object_getClass($UIImage), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage);
1659 //WBRename("UINavigationBar", @selector(initWithCoder:), (IMP) &UINavigationBar$initWithCoder$);
1660 //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:), (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
1662 _UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$);
1663 _UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$);
1665 Manager_ = [[NSFileManager defaultManager] retain];
1666 UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1667 PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1668 Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0];
1669 Bundles_ = [[NSMutableDictionary alloc] initWithCapacity:2];
1670 Themed_ = [[NSMutableDictionary alloc] initWithCapacity:128];
1672 themes_ = [[NSMutableArray alloc] initWithCapacity:8];
1674 if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
1675 // Load Settings {{{
1676 if (NSNumber *value = [settings objectForKey:@"SummerBoard"])
1677 SummerBoard_ = [value boolValue];
1678 if (NSNumber *value = [settings objectForKey:@"Debug"])
1679 Debug_ = [value boolValue];
1681 NSArray *themes([settings objectForKey:@"Themes"]);
1683 if (NSString *theme = [settings objectForKey:@"Theme"])
1684 themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
1686 [NSNumber numberWithBool:true], @"Active",
1690 for (NSDictionary *theme in themes) {
1691 NSNumber *active([theme objectForKey:@"Active"]);
1692 if (![active boolValue])
1695 NSString *name([theme objectForKey:@"Name"]);
1699 NSString *theme(nil);
1701 #define testForTheme(format...) \
1702 if (theme == nil) { \
1703 NSString *path = [NSString stringWithFormat:format]; \
1704 if ([Manager_ fileExistsAtPath:path]) { \
1705 [themes_ addObject:path]; \
1710 testForTheme(@"/Library/Themes/%@.theme", name)
1711 testForTheme(@"/Library/Themes/%@", name)
1712 testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)
1718 Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
1720 for (NSString *theme in themes_)
1721 if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])
1722 for (NSString *key in [info allKeys])
1723 if ([Info_ objectForKey:key] == nil)
1724 [Info_ setObject:[info objectForKey:key] forKey:key];
1726 bool sms($getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]) != nil);
1728 SpringBoard_ = [identifier isEqualToString:@"com.apple.springboard"];
1730 if ([NSBundle bundleWithIdentifier:@"com.apple.chatkit"] != nil)
1733 $CKMessageCell = objc_getClass("CKMessageCell");
1734 _CKMessageCell$addBalloonView$ = MSHookMessage($CKMessageCell, @selector(addBalloonView:), &$CKMessageCell$addBalloonView$);
1735 _CKMessageCell$initWithStyle$reuseIdentifier$ = MSHookMessage($CKMessageCell, @selector(initWithStyle:reuseIdentifier:), &$CKMessageCell$initWithStyle$reuseIdentifier$);
1737 $CKTranscriptTableView = objc_getClass("CKTranscriptTableView");
1738 _CKTranscriptTableView$setSeparatorStyle$ = MSHookMessage($CKTranscriptTableView, @selector(setSeparatorStyle:), &$CKTranscriptTableView$setSeparatorStyle$);
1739 _CKTranscriptTableView$initWithFrame$style$ = MSHookMessage($CKTranscriptTableView, @selector(initWithFrame:style:), &$CKTranscriptTableView$initWithFrame$style$);
1741 $CKTimestampView = objc_getClass("CKTimestampView");
1742 _CKTimestampView$initWithStyle$reuseIdentifier$ = MSHookMessage($CKTimestampView, @selector(initWithStyle:reuseIdentifier:), &$CKTimestampView$initWithStyle$reuseIdentifier$);
1744 $CKTranscriptController = objc_getClass("CKTranscriptController");
1745 _TranscriptController$loadView = MSHookMessage($CKTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1749 if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
1752 if (_TranscriptController$loadView == NULL) {
1753 Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
1754 _TranscriptController$loadView = MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1758 } else if (SpringBoard_) {
1760 CFNotificationCenterAddObserver(
1761 CFNotificationCenterGetDarwinNotifyCenter(),
1762 NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0
1765 if ($getTheme$([NSArray arrayWithObject:@"Wallpaper.mp4"]) != nil) {
1766 NSBundle *MediaPlayer([NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"]);
1767 if (MediaPlayer != nil)
1770 $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
1771 $MPVideoView = objc_getClass("MPVideoView");
1774 $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
1776 $SBApplication = objc_getClass("SBApplication");
1777 $SBApplicationIcon = objc_getClass("SBApplicationIcon");
1778 $SBAwayView = objc_getClass("SBAwayView");
1779 $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
1780 $SBButtonBar = objc_getClass("SBButtonBar");
1781 $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
1782 $SBDockIconListView = objc_getClass("SBDockIconListView");
1783 $SBIcon = objc_getClass("SBIcon");
1784 $SBIconBadge = objc_getClass("SBIconBadge");
1785 $SBIconController = objc_getClass("SBIconController");
1786 $SBIconLabel = objc_getClass("SBIconLabel");
1787 $SBIconList = objc_getClass("SBIconList");
1788 $SBIconModel = objc_getClass("SBIconModel");
1789 //$SBImageCache = objc_getClass("SBImageCache");
1790 $SBSearchView = objc_getClass("SBSearchView");
1791 $SBSearchTableViewCell = objc_getClass("SBSearchTableViewCell");
1792 $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
1793 $SBStatusBarController = objc_getClass("SBStatusBarController");
1794 $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
1795 $SBStatusBarTimeView = objc_getClass("SBStatusBarTimeView");
1796 $SBUIController = objc_getClass("SBUIController");
1797 $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon");
1799 Four_ = $SBDockIconListView != nil;
1801 WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$);
1804 WBRename(SBApplication, pathForIcon, pathForIcon);
1805 WBRename(SBApplicationIcon, icon, icon);
1806 WBRename(SBApplicationIcon, generateIconImage:, generateIconImage$);
1809 WBRename(SBBookmarkIcon, icon, icon);
1810 WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview);
1811 WBRename(SBCalendarIconContentsView, drawRect:, drawRect$);
1812 WBRename(SBIcon, setAlpha:, setAlpha$);
1813 WBRename(SBIconBadge, initWithBadge:, initWithBadge$);
1814 WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged);
1815 WBRename(SBUIController, init, init);
1816 WBRename(SBWidgetApplicationIcon, icon, icon);
1818 WBRename(SBDockIconListView, setFrame:, setFrame$);
1819 MSHookMessage(object_getClass($SBDockIconListView), @selector(shouldShowNewDock), &$SBDockIconListView$shouldShowNewDock, &_SBDockIconListView$shouldShowNewDock);
1821 WBRename(SBIconLabel, drawRect:, drawRect$);
1822 WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
1823 WBRename(SBIconLabel, setInDock:, setInDock$);
1825 WBRename(SBIconList, setFrame:, setFrame$);
1827 WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
1828 WBRename(SBIconModel, cacheImagesForIcon:, cacheImagesForIcon$);
1829 WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
1830 WBRename(SBIconModel, getCachedImagedForIcon:smallIcon:, getCachedImagedForIcon$smallIcon$);
1832 WBRename(SBSearchView, initWithFrame:, initWithFrame$);
1833 WBRename(SBSearchTableViewCell, drawRect:, drawRect$);
1834 WBRename(SBSearchTableViewCell, initWithStyle:reuseIdentifier:, initWithStyle$reuseIdentifier$);
1836 //WBRename(SBImageCache, initWithName:forImageWidth:imageHeight:initialCapacity:, initWithName$forImageWidth$imageHeight$initialCapacity$);
1838 WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
1839 WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
1840 //WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
1841 //WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:animation:, setStatusBarMode$orientation$duration$animation$);
1842 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$);
1843 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:startTime:, setStatusBarMode$orientation$duration$fenceID$animation$startTime$);
1844 WBRename(SBStatusBarOperatorNameView, operatorNameStyle, operatorNameStyle);
1845 WBRename(SBStatusBarOperatorNameView, setOperatorName:fullSize:, setOperatorName$fullSize$);
1846 WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
1849 English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
1851 Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
1855 Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
1856 Papered_ = $getTheme$(Wallpapers_) != nil;
1858 Docked_ = $getTheme$([NSArray arrayWithObjects:@"Dock.png", nil]);
1860 if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
1861 [Info_ setObject:[NSNumber numberWithBool:(
1863 [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
1864 [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
1865 )] forKey:@"UndockedIconLabels"];
1868 NSLog(@"WB:Debug:Info = %@", [Info_ description]);