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 #include <sys/sysctl.h>
106 extern "C" void __clear_cache (char *beg, char *end);
108 @protocol WinterBoard
112 Class $MPMoviePlayerController;
114 Class $WebCoreFrameBridge;
119 Class $UINavigationBar;
122 Class $CKMessageCell;
123 Class $CKTimestampView;
124 Class $CKTranscriptController;
125 Class $CKTranscriptTableView;
127 Class $SBApplication;
128 Class $SBApplicationIcon;
130 Class $SBBookmarkIcon;
132 Class $SBCalendarIconContentsView;
133 Class $SBDockIconListView;
136 Class $SBIconController;
141 //Class $SBImageCache;
143 Class $SBSearchTableViewCell;
144 Class $SBStatusBarContentsView;
145 Class $SBStatusBarController;
146 Class $SBStatusBarOperatorNameView;
147 Class $SBStatusBarTimeView;
148 Class $SBUIController;
149 Class $SBWidgetApplicationIcon;
151 #define SBIconView SBIcon
156 @interface NSDictionary (WinterBoard)
157 - (UIColor *) wb$colorForKey:(NSString *)key;
158 - (BOOL) wb$boolForKey:(NSString *)key;
161 @implementation NSDictionary (WinterBoard)
163 - (UIColor *) wb$colorForKey:(NSString *)key {
164 NSString *value = [self objectForKey:key];
171 - (BOOL) wb$boolForKey:(NSString *)key {
172 if (NSString *value = [self objectForKey:key])
173 return [value boolValue];
179 static BOOL (*_GSFontGetUseLegacyFontMetrics)();
180 #define $GSFontGetUseLegacyFontMetrics() \
181 (_GSFontGetUseLegacyFontMetrics == NULL ? YES : _GSFontGetUseLegacyFontMetrics())
183 static bool Debug_ = false;
184 static bool Engineer_ = false;
185 static bool SummerBoard_ = true;
186 static bool SpringBoard_;
188 static UIImage *(*_UIApplicationImageWithName)(NSString *name);
189 static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path);
190 static CGImageRef (*_UIImageRefAtPath)(NSString *name, bool cache, UIImageOrientation *orientation, float *scale);
191 static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain);
192 static NSBundle *(*_UIKitBundle)();
193 static bool (*_UIPackedImageTableGetIdentifierForName)(NSString *, int *);
194 static int (*_UISharedImageNameGetIdentifier)(NSString *);
196 static NSMutableDictionary *UIImages_;
197 static NSMutableDictionary *PathImages_;
198 static NSMutableDictionary *Cache_;
199 static NSMutableDictionary *Strings_;
200 static NSMutableDictionary *Themed_;
201 static NSMutableDictionary *Bundles_;
203 static NSFileManager *Manager_;
204 static NSDictionary *English_;
205 static NSMutableDictionary *Info_;
206 static NSMutableArray *themes_;
208 static NSString *$getTheme$(NSArray *files, bool parent = false) {
210 if (NSString *path = [Themed_ objectForKey:files])
211 return reinterpret_cast<id>(path) == [NSNull null] ? nil : path;
214 NSLog(@"WB:Debug: %@", [files description]);
218 for (NSString *theme in themes_)
219 for (NSString *file in files) {
220 path = [NSString stringWithFormat:@"%@/%@", theme, file];
221 if ([Manager_ fileExistsAtPath:path]) {
222 path = parent ? theme : path;
230 [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast<id>(path)) forKey:files];
234 static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui) {
235 NSString *identifier = [bundle bundleIdentifier];
236 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
238 if (identifier != nil)
239 [names addObject:[NSString stringWithFormat:@"Bundles/%@/%@", identifier, file]];
240 if (NSString *folder = [[bundle bundlePath] lastPathComponent])
241 [names addObject:[NSString stringWithFormat:@"Folders/%@/%@", folder, file]];
243 [names addObject:[NSString stringWithFormat:@"UIImages/%@", file]];
245 #define remapResourceName(oldname, newname) \
246 else if ([file isEqualToString:(oldname)]) \
247 [names addObject:[NSString stringWithFormat:@"%@.png", newname]]; \
249 bool summer(SpringBoard_ && SummerBoard_);
251 if (identifier == nil);
252 else if ([identifier isEqualToString:@"com.apple.chatkit"])
253 [names addObject:[NSString stringWithFormat:@"Bundles/com.apple.MobileSMS/%@", file]];
254 else if ([identifier isEqualToString:@"com.apple.calculator"])
255 [names addObject:[NSString stringWithFormat:@"Files/Applications/Calculator.app/%@", file]];
257 remapResourceName(@"FSO_BG.png", @"StatusBar")
258 remapResourceName(Four_ ? @"SBDockBG-old.png" : @"SBDockBG.png", @"Dock")
259 remapResourceName(@"SBWeatherCelsius.png", @"Icons/Weather")
261 if (NSString *path = $getTheme$(names))
267 static NSString *$pathForIcon$(SBApplication *self, NSString *suffix = @"") {
268 NSString *identifier = [self bundleIdentifier];
269 NSString *path = [self path];
270 NSString *folder = [path lastPathComponent];
271 NSString *dname = [self displayName];
272 NSString *didentifier = [self displayIdentifier];
275 NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier);
277 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
279 /* XXX: I might need to keep this for backwards compatibility
280 if (identifier != nil)
281 [names addObject:[NSString stringWithFormat:@"Bundles/%@/icon.png", identifier]];
283 [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]]; */
285 #define testForIcon(Name) \
286 if (NSString *name = Name) \
287 [names addObject:[NSString stringWithFormat:@"Icons%@/%@.png", suffix, name]];
289 if (![didentifier isEqualToString:identifier])
290 testForIcon(didentifier);
292 testForIcon(identifier);
295 if ([identifier isEqualToString:@"com.apple.MobileSMS"])
298 if (didentifier != nil) {
299 testForIcon([English_ objectForKey:didentifier]);
301 NSArray *parts = [didentifier componentsSeparatedByString:@"-"];
302 if ([parts count] != 1)
303 if (NSDictionary *english = [[[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingString:@"/English.lproj/UIRoleDisplayNames.strings"]] autorelease])
304 testForIcon([english objectForKey:[parts lastObject]]);
307 if (NSString *path = $getTheme$(names))
313 @interface NSBundle (WinterBoard)
314 + (NSBundle *) wb$bundleWithFile:(NSString *)path;
317 @implementation NSBundle (WinterBoard)
319 + (NSBundle *) wb$bundleWithFile:(NSString *)path {
320 path = [path stringByDeletingLastPathComponent];
321 if (path == nil || [path length] == 0 || [path isEqualToString:@"/"])
324 NSBundle *bundle([Bundles_ objectForKey:path]);
325 if (reinterpret_cast<id>(bundle) == [NSNull null])
327 else if (bundle == nil) {
328 if ([Manager_ fileExistsAtPath:[path stringByAppendingPathComponent:@"Info.plist"]])
329 bundle = [NSBundle bundleWithPath:path];
331 bundle = [NSBundle wb$bundleWithFile:path];
333 NSLog(@"WB:Debug:PathBundle(%@, %@)", path, bundle);
334 [Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast<id>(bundle)) forKey:path];
342 @interface NSString (WinterBoard)
343 - (NSString *) wb$themedPath;
346 @implementation NSString (WinterBoard)
348 - (NSString *) wb$themedPath {
350 NSLog(@"WB:Debug:Bypass(\"%@\")", self);
352 if (NSBundle *bundle = [NSBundle wb$bundleWithFile:self]) {
353 NSString *file([self stringByResolvingSymlinksInPath]);
354 NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]);
355 if ([file hasPrefix:prefix]) {
356 NSUInteger length([prefix length]);
357 if (length != [file length])
358 if (NSString *path = $pathForFile$inBundle$([file substringFromIndex:(length + 1)], bundle, false))
368 void WBLogRect(const char *tag, struct CGRect rect) {
369 NSLog(@"%s:{%f,%f+%f,%f}", tag, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
372 void WBLogHierarchy(UIView *view, unsigned index = 0, unsigned indent = 0) {
373 CGRect frame([view frame]);
374 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]);
376 for (UIView *child in [view subviews])
377 WBLogHierarchy(child, index++, indent + 1);
380 UIImage *$cacheForImage$(UIImage *image) {
381 CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB());
382 CGRect rect = {CGPointMake(1, 1), [image size]};
383 CGSize size = {rect.size.width + 2, rect.size.height + 2};
385 CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
386 CGColorSpaceRelease(space);
388 CGContextDrawImage(context, rect, [image CGImage]);
389 CGImageRef ref(CGBitmapContextCreateImage(context));
390 CGContextRelease(context);
392 UIImage *cache([UIImage imageWithCGImage:ref]);
398 /*MSHook(id, SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$, SBImageCache *self, SEL sel, NSString *name, unsigned width, unsigned height, unsigned capacity) {
399 //if ([name isEqualToString:@"icons"]) return nil;
400 return _SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$(self, sel, name, width, height, capacity);
403 MSHook(void, SBIconModel$cacheImageForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
404 NSString *key([icon displayIdentifier]);
406 if (UIImage *image = [icon icon]) {
407 CGSize size = [image size];
408 if (size.width != 59 || size.height != 60) {
409 UIImage *cache($cacheForImage$(image));
410 [Cache_ setObject:cache forKey:key];
415 _SBIconModel$cacheImageForIcon$(self, sel, icon);
418 MSHook(void, SBIconModel$cacheImagesForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
419 /* XXX: do I /really/ have to do this? figure out how to cache the small icon! */
420 _SBIconModel$cacheImagesForIcon$(self, sel, icon);
422 NSString *key([icon displayIdentifier]);
424 if (UIImage *image = [icon icon]) {
425 CGSize size = [image size];
426 if (size.width != 59 || size.height != 60) {
427 UIImage *cache($cacheForImage$(image));
428 [Cache_ setObject:cache forKey:key];
434 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
435 NSString *key([icon displayIdentifier]);
436 if (UIImage *image = [Cache_ objectForKey:key])
439 return _SBIconModel$getCachedImagedForIcon$(self, sel, icon);
442 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$smallIcon$, SBIconModel *self, SEL sel, SBIcon *icon, BOOL small) {
444 return _SBIconModel$getCachedImagedForIcon$smallIcon$(self, sel, icon, small);
445 NSString *key([icon displayIdentifier]);
446 if (UIImage *image = [Cache_ objectForKey:key])
449 return _SBIconModel$getCachedImagedForIcon$smallIcon$(self, sel, icon, small);
452 MSHook(id, SBSearchView$initWithFrame$, id /* XXX: SBSearchView */ self, SEL sel, struct CGRect frame) {
453 if ((self = _SBSearchView$initWithFrame$(self, sel, frame)) != nil) {
454 [self setBackgroundColor:[UIColor clearColor]];
455 for (UIView *child in [self subviews])
456 [child setBackgroundColor:[UIColor clearColor]];
460 MSHook(id, SBSearchTableViewCell$initWithStyle$reuseIdentifier$, SBSearchTableViewCell *self, SEL sel, int style, NSString *reuse) {
461 if ((self = _SBSearchTableViewCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
462 [self setBackgroundColor:[UIColor clearColor]];
466 MSHook(void, SBSearchTableViewCell$drawRect$, SBSearchTableViewCell *self, SEL sel, struct CGRect rect, BOOL selected) {
467 _SBSearchTableViewCell$drawRect$(self, sel, rect, selected);
468 float inset([self edgeInset]);
469 [[UIColor clearColor] set];
470 UIRectFill(CGRectMake(0, 0, inset, rect.size.height));
471 UIRectFill(CGRectMake(rect.size.width - inset, 0, inset, rect.size.height));
474 MSHook(UIImage *, SBApplicationIcon$icon, SBApplicationIcon *self, SEL sel) {
475 if (![Info_ wb$boolForKey:@"ComposeStoreIcons"])
476 if (NSString *path = $pathForIcon$([self application]))
477 return [UIImage imageWithContentsOfFile:path];
478 return _SBApplicationIcon$icon(self, sel);
481 MSHook(UIImage *, SBApplicationIcon$generateIconImage$, SBApplicationIcon *self, SEL sel, int type) {
483 if (![Info_ wb$boolForKey:@"ComposeStoreIcons"]) {
484 if (IsWild_ && false) // XXX: delete this code, it should not be supported
485 if (NSString *path72 = $pathForIcon$([self application], @"-72"))
486 return [UIImage imageWithContentsOfFile:path72];
487 if (NSString *path = $pathForIcon$([self application]))
488 if (UIImage *image = [UIImage imageWithContentsOfFile:path]) {
490 if ([$SBIcon respondsToSelector:@selector(defaultIconImageSize)])
491 width = [$SBIcon defaultIconImageSize].width;
494 return width == 59 ? image : [image _imageScaledToProportion:(width / 59.0) interpolationQuality:5];
497 return _SBApplicationIcon$generateIconImage$(self, sel, type);
500 MSHook(UIImage *, SBWidgetApplicationIcon$icon, SBWidgetApplicationIcon *self, SEL sel) {
502 NSLog(@"WB:Debug:Widget(%@:%@)", [self displayIdentifier], [self displayName]);
503 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
504 return [UIImage imageWithContentsOfFile:path];
505 return _SBWidgetApplicationIcon$icon(self, sel);
508 MSHook(UIImage *, SBBookmarkIcon$icon, SBBookmarkIcon *self, SEL sel) {
510 NSLog(@"WB:Debug:Bookmark(%@:%@)", [self displayIdentifier], [self displayName]);
511 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
512 return [UIImage imageWithContentsOfFile:path];
513 return _SBBookmarkIcon$icon(self, sel);
516 MSHook(NSString *, SBApplication$pathForIcon, SBApplication *self, SEL sel) {
517 if (NSString *path = $pathForIcon$(self))
519 return _SBApplication$pathForIcon(self, sel);
522 static UIImage *CachedImageAtPath(NSString *path) {
523 path = [path stringByResolvingSymlinksInPath];
524 UIImage *image = [PathImages_ objectForKey:path];
526 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
527 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
529 image = [image autorelease];
530 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:path];
534 MSHook(CGImageSourceRef, CGImageSourceCreateWithURL, CFURLRef url, CFDictionaryRef options) {
536 NSLog(@"WB:Debug: CGImageSourceCreateWithURL(\"%@\", %s)", url, options);
537 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
538 if (NSString *path = (NSString *) CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle))
539 if (NSString *themed = [path wb$themedPath])
541 url = (CFURLRef) [NSURL fileURLWithPath:themed];
542 CGImageSourceRef source(_CGImageSourceCreateWithURL(url, options));
547 MSHook(CGImageRef, _UIImageRefAtPath, NSString *name, bool cache, UIImageOrientation *orientation, float *scale) {
549 NSLog(@"WB:Debug: _UIImageRefAtPath(\"%@\")", name);
551 NSString *themed([name wb$themedPath]);
553 if (false && SpringBoard_ && SummerBoard_ && themed == name) {
554 if ([name isEqualToString:@"/System/Library/CoreServices/SpringBoard.app/SBDockBGT-Portrait.png"])
555 if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Dock.png"])) {
556 UIImage *image([UIImage imageWithContentsOfFile:path]);
557 CGImageRef ref([[image _imageScaledToProportion:2.4 interpolationQuality:5] imageRef]);
563 return __UIImageRefAtPath(themed, cache, orientation, scale);
566 /*MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) {
568 return __UIImageAtPath(name, nil);
570 NSString *key = [NSString stringWithFormat:@"B:%@/%@", [bundle bundleIdentifier], name];
571 UIImage *image = [PathImages_ objectForKey:key];
573 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
575 NSLog(@"WB:Debug: _UIImageAtPath(\"%@\", %@)", name, bundle);
576 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
577 image = CachedImageAtPath(path);
579 image = __UIImageAtPath(name, bundle);
580 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
585 MSHook(UIImage *, _UIApplicationImageWithName, NSString *name) {
586 NSBundle *bundle = [NSBundle mainBundle];
588 NSLog(@"WB:Debug: _UIApplicationImageWithName(\"%@\", %@)", name, bundle);
589 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
590 return CachedImageAtPath(path);
591 return __UIApplicationImageWithName(name);
594 #define WBDelegate(delegate) \
595 - (NSMethodSignature*) methodSignatureForSelector:(SEL)sel { \
597 NSLog(@"WB:MS:%s:(%s)", class_getName([self class]), sel_getName(sel)); \
598 if (NSMethodSignature *sig = [delegate methodSignatureForSelector:sel]) \
600 NSLog(@"WB:Error: [%s methodSignatureForSelector:(%s)]", class_getName([self class]), sel_getName(sel)); \
604 - (void) forwardInvocation:(NSInvocation*)inv { \
605 SEL sel = [inv selector]; \
606 if ([delegate respondsToSelector:sel]) \
607 [inv invokeWithTarget:delegate]; \
609 NSLog(@"WB:Error: [%s forwardInvocation:(%s)]", class_getName([self class]), sel_getName(sel)); \
612 MSHook(NSString *, NSBundle$pathForResource$ofType$, NSBundle *self, SEL sel, NSString *resource, NSString *type) {
613 NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
615 NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
616 if (NSString *path = $pathForFile$inBundle$(file, self, false))
618 return _NSBundle$pathForResource$ofType$(self, sel, resource, type);
621 void $setBarStyle$_(NSString *name, int &style) {
623 NSLog(@"WB:Debug:%@Style:%d", name, style);
624 NSNumber *number = nil;
626 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style-%d", name, style]];
628 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style", name]];
630 style = [number intValue];
632 NSLog(@"WB:Debug:%@Style=%d", name, style);
636 MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *self, SEL sel, CGRect rect) {
637 NSBundle *bundle([NSBundle mainBundle]);
639 CFLocaleRef locale(CFLocaleCopyCurrent());
640 CFDateFormatterRef formatter(CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle));
643 CFDateRef now(CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()));
645 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NUMBER_FORMAT" value:@"d" table:@"SpringBoard"]);
646 CFStringRef date(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
647 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NAME_FORMAT" value:@"cccc" table:@"SpringBoard"]);
648 CFStringRef day(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
652 CFRelease(formatter);
654 NSString *datestyle([@""
655 "font-family: Helvetica; "
656 "font-weight: bold; "
659 "" stringByAppendingString:(IsWild_
660 ? @"font-size: 54px; "
661 : @"font-size: 39px; "
664 NSString *daystyle([@""
665 "font-family: Helvetica; "
666 "font-weight: bold; "
668 "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px; "
669 "" stringByAppendingString:(IsWild_
670 ? @"font-size: 11px; "
671 : @"font-size: 9px; "
674 if (NSString *style = [Info_ objectForKey:@"CalendarIconDateStyle"])
675 datestyle = [datestyle stringByAppendingString:style];
676 if (NSString *style = [Info_ objectForKey:@"CalendarIconDayStyle"])
677 daystyle = [daystyle stringByAppendingString:style];
679 float width([self bounds].size.width);
681 CGSize datesize = [(NSString *)date sizeWithStyle:datestyle forWidth:(width + leeway)];
682 CGSize daysize = [(NSString *)day sizeWithStyle:daystyle forWidth:(width + leeway)];
684 unsigned base0(IsWild_ ? 89 : 70);
685 if ($GSFontGetUseLegacyFontMetrics())
687 unsigned base1(IsWild_ ? 18 : 16);
694 [(NSString *)date drawAtPoint:CGPointMake(
695 (width + 1 - datesize.width) / 2, (base0 - datesize.height) / 2
696 ) withStyle:datestyle];
698 [(NSString *)day drawAtPoint:CGPointMake(
699 (width + 1 - daysize.width) / 2, (base1 - daysize.height) / 2
700 ) withStyle:daystyle];
706 /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) {
709 if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"])
710 style = [number intValue];
712 if (UIColor *color = [Info_ wb$colorForKey:@"NavigationBarTint"])
715 return [self wb$initWithFrame:frame withBarStyle:style withTintColor:tint];
718 /*static id UINavigationBar$initWithCoder$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame, NSCoder *coder) {
719 self = [self wb$initWithCoder:coder];
722 UINavigationBar$setBarStyle$_(self);
726 static id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame) {
727 self = [self wb$initWithFrame:frame];
730 UINavigationBar$setBarStyle$_(self);
734 MSHook(void, UIToolbar$setBarStyle$, UIToolbar *self, SEL sel, int style) {
735 $setBarStyle$_(@"Toolbar", style);
736 return _UIToolbar$setBarStyle$(self, sel, style);
739 MSHook(void, UINavigationBar$setBarStyle$, UINavigationBar *self, SEL sel, int style) {
740 $setBarStyle$_(@"NavigationBar", style);
741 return _UINavigationBar$setBarStyle$(self, sel, style);
744 MSHook(void, SBButtonBar$didMoveToSuperview, UIView *self, SEL sel) {
745 [[self superview] setBackgroundColor:[UIColor clearColor]];
746 _SBButtonBar$didMoveToSuperview(self, sel);
749 MSHook(void, SBStatusBarContentsView$didMoveToSuperview, UIView *self, SEL sel) {
750 [[self superview] setBackgroundColor:[UIColor clearColor]];
751 _SBStatusBarContentsView$didMoveToSuperview(self, sel);
754 MSHook(UIImage *, UIImage$defaultDesktopImage, UIImage *self, SEL sel) {
756 NSLog(@"WB:Debug:DefaultDesktopImage");
757 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"LockBackground.png", @"LockBackground.jpg", nil]))
758 return [UIImage imageWithContentsOfFile:path];
759 return _UIImage$defaultDesktopImage(self, sel);
762 static NSArray *Wallpapers_;
763 static bool Papered_;
765 static NSString *WallpaperFile_;
766 static UIImageView *WallpaperImage_;
767 static UIWebDocumentView *WallpaperPage_;
768 static NSURL *WallpaperURL_;
770 #define _release(object) \
771 do if (object != nil) { \
776 MSHook(id, SBUIController$init, SBUIController *self, SEL sel) {
777 self = _SBUIController$init(self, sel);
783 sysctlbyname("hw.machine", NULL, &size, NULL, 0);
784 char *machine = new char[size];
786 if (sysctlbyname("hw.machine", machine, &size, NULL, 0) == -1) {
787 perror("sysctlbyname(\"hw.machine\", ?)");
792 IsWild_ = machine != NULL && strncmp(machine, "iPad", 4) == 0;
795 BOOL (*GSSystemHasCapability)(CFStringRef) = reinterpret_cast<BOOL (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemHasCapability"));
797 if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
798 [Info_ setObject:[NSNumber numberWithBool:(
799 !(Papered_ || GSSystemHasCapability != NULL && GSSystemHasCapability(CFSTR("homescreen-wallpaper"))) ||
800 [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
801 [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
802 )] forKey:@"UndockedIconLabels"];
805 NSLog(@"WB:Debug:Info = %@", [Info_ description]);
808 UIImageView *&_wallpaperView(MSHookIvar<UIImageView *>(self, "_wallpaperView"));
809 if (&_wallpaperView != NULL) {
810 [_wallpaperView removeFromSuperview];
811 [_wallpaperView release];
812 _wallpaperView = nil;
816 UIView *&_contentLayer(MSHookIvar<UIView *>(self, "_contentLayer"));
817 UIView *&_contentView(MSHookIvar<UIView *>(self, "_contentView"));
820 if (&_contentLayer != NULL)
821 player = &_contentLayer;
822 else if (&_contentView != NULL)
823 player = &_contentView;
826 UIView *layer(player == NULL ? nil : *player);
828 UIWindow *window([[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]);
829 UIView *content([[[UIView alloc] initWithFrame:[window frame]] autorelease]);
830 [window setContentView:content];
832 UIWindow *&_window(MSHookIvar<UIWindow *>(self, "_window"));
833 [window setBackgroundColor:[_window backgroundColor]];
834 [_window setBackgroundColor:[UIColor clearColor]];
836 [window setLevel:-1000];
837 [window setHidden:NO];
839 /*if (player != NULL)
842 [content setBackgroundColor:[layer backgroundColor]];
843 [layer setBackgroundColor:[UIColor clearColor]];
846 if (!SummerBoard_ || !IsWild_)
849 CGRect bounds([content bounds]);
850 bounds.origin.y = -30;
851 indirect = [[[UIView alloc] initWithFrame:bounds] autorelease];
852 [content addSubview:indirect];
853 [indirect zoomToScale:2.4];
856 _release(WallpaperFile_);
857 _release(WallpaperImage_);
858 _release(WallpaperPage_);
859 _release(WallpaperURL_);
861 if (NSString *theme = $getTheme$(Wallpapers_, true)) {
862 NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"];
863 if ([Manager_ fileExistsAtPath:mp4]) {
867 static AVController *controller_(nil);
868 if (controller_ == nil) {
869 AVQueue *queue([AVQueue avQueue]);
870 controller_ = [[AVController avControllerWithQueue:queue error:&error] retain];
873 AVQueue *queue([controller_ queue]);
875 UIView *video([[[UIView alloc] initWithFrame:[indirect bounds]] autorelease]);
876 [controller_ setLayer:[video _layer]];
878 AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]);
879 [queue appendItem:item error:&error];
881 [controller_ play:&error];
882 #elif UseMPMoviePlayerController
883 NSURL *url([NSURL fileURLWithPath:mp4]);
884 MPMoviePlayerController *controller = [[$MPMoviePlayerController alloc] initWithContentURL:url];
885 controller.movieControlMode = MPMovieControlModeHidden;
888 MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[indirect bounds]] autorelease];
889 [video setMovieWithPath:mp4];
890 [video setRepeatMode:1];
891 [video setRepeatGap:-1];
892 [video playFromBeginning];;
895 [indirect addSubview:video];
898 NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"];
899 NSString *jpg = [theme stringByAppendingPathComponent:@"Wallpaper.jpg"];
902 if ([Manager_ fileExistsAtPath:png])
904 else if ([Manager_ fileExistsAtPath:jpg])
910 image = [[UIImage alloc] initWithContentsOfFile:path];
912 image = [image autorelease];
916 WallpaperFile_ = [path retain];
917 WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
918 if (NSNumber *number = [Info_ objectForKey:@"WallpaperAlpha"])
919 [WallpaperImage_ setAlpha:[number floatValue]];
920 [indirect addSubview:WallpaperImage_];
923 NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"];
924 if ([Manager_ fileExistsAtPath:html]) {
925 CGRect bounds = [indirect bounds];
927 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
928 [view setAutoresizes:true];
930 WallpaperPage_ = [view retain];
931 WallpaperURL_ = [[NSURL fileURLWithPath:html] retain];
933 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
935 [view setBackgroundColor:[UIColor clearColor]];
936 if ([view respondsToSelector:@selector(setDrawsBackground:)])
937 [view setDrawsBackground:NO];
938 [[view webView] setDrawsBackground:NO];
940 [indirect addSubview:view];
944 for (size_t i(0), e([themes_ count]); i != e; ++i) {
945 NSString *theme = [themes_ objectAtIndex:(e - i - 1)];
946 NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"];
947 if ([Manager_ fileExistsAtPath:html]) {
948 CGRect bounds = [indirect bounds];
950 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
951 [view setAutoresizes:true];
953 NSURL *url = [NSURL fileURLWithPath:html];
954 [view loadRequest:[NSURLRequest requestWithURL:url]];
956 [view setBackgroundColor:[UIColor clearColor]];
957 if ([view respondsToSelector:@selector(setDrawsBackground:)])
958 [view setDrawsBackground:NO];
959 [[view webView] setDrawsBackground:NO];
961 [indirect addSubview:view];
968 MSHook(void, SBAwayView$updateDesktopImage$, SBAwayView *self, SEL sel, UIImage *image) {
969 NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]);
970 UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
972 if (path != nil && _backgroundView != nil)
975 _SBAwayView$updateDesktopImage$(self, sel, image);
978 CGRect bounds = [self bounds];
980 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
981 [view setAutoresizes:true];
983 if (WallpaperPage_ != nil)
984 [WallpaperPage_ release];
985 WallpaperPage_ = [view retain];
987 if (WallpaperURL_ != nil)
988 [WallpaperURL_ release];
989 WallpaperURL_ = [[NSURL fileURLWithPath:path] retain];
991 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
993 [[view webView] setDrawsBackground:false];
994 [view setBackgroundColor:[UIColor clearColor]];
996 [self insertSubview:view aboveSubview:_backgroundView];
1000 /*extern "C" CGColorRef CGGStateGetSystemColor(void *);
1001 extern "C" CGColorRef CGGStateGetFillColor(void *);
1002 extern "C" CGColorRef CGGStateGetStrokeColor(void *);
1003 extern "C" NSString *UIStyleStringFromColor(CGColorRef);*/
1005 /* WBTimeLabel {{{ */
1006 @interface WBTimeLabel : NSProxy {
1008 _transient SBStatusBarTimeView *view_;
1011 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view;
1015 @implementation WBTimeLabel
1022 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view {
1023 time_ = [time retain];
1028 - (NSString *) description {
1034 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
1035 if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
1036 BOOL &_mode(MSHookIvar<BOOL>(view_, "_mode"));;
1038 [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
1039 "font-family: Helvetica; "
1040 "font-weight: bold; "
1043 "%@", _mode ? @"white" : @"black", custom]];
1048 return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
1053 /* WBBadgeLabel {{{ */
1054 @interface WBBadgeLabel : NSProxy {
1058 - (id) initWithBadge:(NSString *)badge;
1059 - (NSString *) description;
1063 @implementation WBBadgeLabel
1070 - (id) initWithBadge:(NSString *)badge {
1071 badge_ = [badge retain];
1075 - (NSString *) description {
1076 return [badge_ description];
1081 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
1082 if (NSString *custom = [Info_ objectForKey:@"BadgeStyle"]) {
1083 [badge_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
1084 "font-family: Helvetica; "
1085 "font-weight: bold; "
1093 return [badge_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
1099 MSHook(void, SBIconView$setIconImageAlpha$, SBIconView *self, SEL sel, float alpha) {
1100 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
1101 alpha = [number floatValue];
1102 return _SBIconView$setIconImageAlpha$(self, sel, alpha);
1105 MSHook(void, SBIconView$setIconLabelAlpha$, SBIconView *self, SEL sel, float alpha) {
1106 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
1107 alpha = [number floatValue];
1108 return _SBIconView$setIconLabelAlpha$(self, sel, alpha);
1111 MSHook(id, SBIconView$initWithDefaultSize, SBIconView *self, SEL sel) {
1112 if ((self = _SBIconView$initWithDefaultSize(self, sel)) != nil) {
1113 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"]) {
1114 // XXX: note: this is overridden above, which is silly
1115 float alpha([number floatValue]);
1116 [self setIconImageAlpha:alpha];
1117 [self setIconLabelAlpha:alpha];
1122 MSHook(void, SBIcon$setAlpha$, SBIcon *self, SEL sel, float alpha) {
1123 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
1124 alpha = [number floatValue];
1125 return _SBIcon$setAlpha$(self, sel, alpha);
1128 MSHook(id, SBIconBadge$initWithBadge$, SBIconBadge *self, SEL sel, NSString *badge) {
1129 if ((self = _SBIconBadge$initWithBadge$(self, sel, badge)) != nil) {
1130 id &_badge(MSHookIvar<id>(self, "_badge"));
1132 if (id label = [[WBBadgeLabel alloc] initWithBadge:[_badge autorelease]])
1137 void SBStatusBarController$setStatusBarMode(int &mode) {
1139 NSLog(@"WB:Debug:setStatusBarMode:%d", mode);
1140 if (mode < 100) // 104:hidden 105:glowing
1141 if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"])
1142 mode = [number intValue];
1145 /*MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int animation) {
1146 NSLog(@"mode:%d orientation:%d duration:%f animation:%d", mode, orientation, duration, animation);
1147 SBStatusBarController$setStatusBarMode(mode);
1148 return _SBStatusBarController$setStatusBarMode$orientation$duration$animation$(self, sel, mode, orientation, duration, animation);
1151 MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int fenceID, int animation) {
1152 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d", mode, orientation, duration, fenceID, animation);
1153 SBStatusBarController$setStatusBarMode(mode);
1154 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, fenceID, animation);
1157 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) {
1158 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d startTime:%f", mode, orientation, duration, fenceID, animation, startTime);
1159 SBStatusBarController$setStatusBarMode(mode);
1160 //NSLog(@"mode=%u", mode);
1161 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$(self, sel, mode, orientation, duration, fenceID, animation, startTime);
1164 /*MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) {
1165 if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"])
1166 mode = [number intValue];
1167 return _SBStatusBarContentsView$initWithStatusBar$mode$(self, sel, bar, mode);
1170 MSHook(NSString *, SBStatusBarOperatorNameView$operatorNameStyle, SBStatusBarOperatorNameView *self, SEL sel) {
1171 NSString *style(_SBStatusBarOperatorNameView$operatorNameStyle(self, sel));
1173 NSLog(@"operatorNameStyle= %@", style);
1174 if (NSString *custom = [Info_ objectForKey:@"OperatorNameStyle"])
1175 style = [NSString stringWithFormat:@"%@; %@", style, custom];
1179 MSHook(void, SBStatusBarOperatorNameView$setOperatorName$fullSize$, SBStatusBarOperatorNameView *self, SEL sel, NSString *name, BOOL full) {
1181 NSLog(@"setOperatorName:\"%@\" fullSize:%u", name, full);
1182 return _SBStatusBarOperatorNameView$setOperatorName$fullSize$(self, sel, name, NO);
1185 // XXX: replace this with [SBStatusBarTimeView tile]
1186 MSHook(void, SBStatusBarTimeView$drawRect$, SBStatusBarTimeView *self, SEL sel, CGRect rect) {
1187 id &_time(MSHookIvar<id>(self, "_time"));
1188 if (_time != nil && [_time class] != [WBTimeLabel class])
1189 object_setInstanceVariable(self, "_time", reinterpret_cast<void *>([[WBTimeLabel alloc] initWithTime:[_time autorelease] view:self]));
1190 return _SBStatusBarTimeView$drawRect$(self, sel, rect);
1193 @interface UIView (WinterBoard)
1194 - (bool) wb$isWBImageView;
1195 - (void) wb$logHierarchy;
1198 @implementation UIView (WinterBoard)
1200 - (bool) wb$isWBImageView {
1204 - (void) wb$logHierarchy {
1205 WBLogHierarchy(self);
1210 @interface WBImageView : UIImageView {
1213 - (bool) wb$isWBImageView;
1214 - (void) wb$updateFrame;
1217 @implementation WBImageView
1219 - (bool) wb$isWBImageView {
1223 - (void) wb$updateFrame {
1224 CGRect frame([self frame]);
1227 for (UIView *view(self); ; ) {
1228 view = [view superview];
1231 frame.origin.y -= [view frame].origin.y;
1234 [self setFrame:frame];
1239 MSHook(void, SBIconList$setFrame$, SBIconList *self, SEL sel, CGRect frame) {
1240 NSArray *subviews([self subviews]);
1241 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1242 if (view != nil && [view wb$isWBImageView])
1243 [view wb$updateFrame];
1244 _SBIconList$setFrame$(self, sel, frame);
1247 MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *self, SEL sel) {
1248 SBIconModel *&_iconModel(MSHookIvar<SBIconModel *>(self, "_iconModel"));
1249 NSArray *lists([_iconModel iconLists]);
1251 for (unsigned i(0), e([lists count]); i != e; ++i)
1252 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Page%u.png", i]])) {
1253 SBIconList *list([lists objectAtIndex:i]);
1254 NSArray *subviews([list subviews]);
1256 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1257 if (view == nil || ![view wb$isWBImageView]) {
1258 view = [[[WBImageView alloc] init] autorelease];
1259 [list insertSubview:view atIndex:0];
1262 UIImage *image([UIImage imageWithContentsOfFile:path]);
1264 CGRect frame([view frame]);
1265 frame.size = [image size];
1266 [view setFrame:frame];
1268 [view setImage:image];
1269 [view wb$updateFrame];
1272 return _SBIconController$noteNumberOfIconListsChanged(self, sel);
1275 MSHook(id, SBIconLabel$initWithSize$label$, SBIconLabel *self, SEL sel, CGSize size, NSString *label) {
1276 self = _SBIconLabel$initWithSize$label$(self, sel, size, label);
1278 [self setClipsToBounds:NO];
1282 MSHook(void, SBIconLabel$setInDock$, SBIconLabel *self, SEL sel, BOOL docked) {
1283 id &_label(MSHookIvar<id>(self, "_label"));
1284 if (![Info_ wb$boolForKey:@"UndockedIconLabels"])
1286 if (_label != nil && [_label respondsToSelector:@selector(setInDock:)])
1287 [_label setInDock:docked];
1288 return _SBIconLabel$setInDock$(self, sel, docked);
1291 MSHook(BOOL, SBDockIconListView$shouldShowNewDock, id self, SEL sel) {
1292 return SummerBoard_ && Docked_ ? NO : _SBDockIconListView$shouldShowNewDock(self, sel);
1295 MSHook(void, SBDockIconListView$setFrame$, id self, SEL sel, CGRect frame) {
1296 _SBDockIconListView$setFrame$(self, sel, frame);
1299 MSHook(NSString *, NSBundle$localizedStringForKey$value$table$, NSBundle *self, SEL sel, NSString *key, NSString *value, NSString *table) {
1300 NSString *identifier = [self bundleIdentifier];
1301 NSLocale *locale = [NSLocale currentLocale];
1302 NSString *language = [locale objectForKey:NSLocaleLanguageCode];
1304 NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language);
1305 NSString *file = table == nil ? @"Localizable" : table;
1306 NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file];
1307 NSDictionary *strings;
1308 if ((strings = [Strings_ objectForKey:name]) != nil) {
1309 if (static_cast<id>(strings) != [NSNull null]) strings:
1310 if (NSString *value = [strings objectForKey:key])
1312 } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
1315 if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
1316 [Strings_ setObject:[strings autorelease] forKey:name];
1320 [Strings_ setObject:[NSNull null] forKey:name];
1321 return _NSBundle$localizedStringForKey$value$table$(self, sel, key, value, table);
1324 @class WebCoreFrameBridge;
1325 MSHook(CGSize, WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$, WebCoreFrameBridge *self, SEL sel, id node, float width) {
1328 void **core(reinterpret_cast<void **>([node _node]));
1329 if (core == NULL || core[6] == NULL)
1331 return _WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(self, sel, node, width);
1334 MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
1335 CGRect bounds = [self bounds];
1337 static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
1340 Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
1341 docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
1343 NSString *label(MSHookIvar<NSString *>(self, "_label"));
1345 NSString *style = [NSString stringWithFormat:@""
1346 "font-family: Helvetica; "
1347 "font-weight: bold; "
1349 "", (docked || !SummerBoard_ ? @"white" : @"#b3b3b3"), (IsWild_
1350 ? @"font-size: 12px; "
1351 : @"font-size: 11px; "
1355 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px 1px 0px; "];
1357 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
1359 bool ellipsis(false);
1360 float max = 75, width;
1362 width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
1365 size_t length([label length]);
1366 float spacing((width - max) / (length - 1));
1368 if (spacing > 1.25) {
1370 label = [label substringToIndex:(length - 1)];
1374 style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
1378 label = [label stringByAppendingString:@"..."];
1380 if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
1381 style = [style stringByAppendingString:custom];
1383 CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];
1384 [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
1387 MSHook(void, CKMessageCell$addBalloonView$, id self, SEL sel, CKBalloonView *balloon) {
1388 _CKMessageCell$addBalloonView$(self, sel, balloon);
1389 [balloon setBackgroundColor:[UIColor clearColor]];
1392 MSHook(id, CKMessageCell$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1393 if ((self = _CKMessageCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1394 [[self contentView] setBackgroundColor:[UIColor clearColor]];
1398 MSHook(id, CKTimestampView$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1399 if ((self = _CKTimestampView$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1400 UILabel *&_label(MSHookIvar<UILabel *>(self, "_label"));
1401 [_label setBackgroundColor:[UIColor clearColor]];
1405 MSHook(void, CKTranscriptTableView$setSeparatorStyle$, id self, SEL sel, int style) {
1406 _CKTranscriptTableView$setSeparatorStyle$(self, sel, UITableViewCellSeparatorStyleNone);
1409 MSHook(id, CKTranscriptTableView$initWithFrame$style$, id self, SEL sel, CGRect frame, int style) {
1411 if ((self = _CKTranscriptTableView$initWithFrame$style$(self, sel, frame, style)) != nil) {
1412 [self setSeparatorStyle:UITableViewCellSeparatorStyleNone];
1416 MSHook(void, TranscriptController$loadView, mSMSMessageTranscriptController *self, SEL sel) {
1417 _TranscriptController$loadView(self, sel);
1419 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
1420 if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
1421 [image autorelease];
1423 UIView *&_transcriptTable(MSHookIvar<UIView *>(self, "_transcriptTable"));
1424 UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
1426 if (&_transcriptTable != NULL)
1427 table = _transcriptTable;
1428 else if (&_transcriptLayer != NULL)
1429 table = _transcriptLayer;
1433 UIView *placard(table != nil ? [table superview] : MSHookIvar<UIView *>(self, "_backPlacard"));
1434 UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]);
1437 [placard insertSubview:background atIndex:0];
1439 [table setBackgroundColor:[UIColor clearColor]];
1440 [placard insertSubview:background belowSubview:table];
1445 MSHook(UIImage *, _UIImageWithName, NSString *name) {
1447 NSLog(@"WB:Debug: _UIImageWithName(\"%@\")", name);
1454 if (_UIPackedImageTableGetIdentifierForName != NULL)
1455 packed = _UIPackedImageTableGetIdentifierForName(name, &identifier);
1456 else if (_UISharedImageNameGetIdentifier != NULL) {
1457 identifier = _UISharedImageNameGetIdentifier(name);
1458 packed = identifier != -1;
1465 NSLog(@"WB:Debug: _UISharedImageNameGetIdentifier(\"%@\") = %d", name, identifier);
1468 return __UIImageWithName(name);
1470 NSNumber *key([NSNumber numberWithInt:identifier]);
1471 UIImage *image([UIImages_ objectForKey:key]);
1473 return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithName(name) : image;
1474 if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {
1475 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
1477 [image autorelease];
1479 [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1480 return image == nil ? __UIImageWithName(name) : image;
1484 MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
1485 NSString *key([NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name]);
1486 UIImage *image([PathImages_ objectForKey:key]);
1488 return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithNameInDomain(name, domain) : image;
1490 NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);
1491 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {
1492 image = [[UIImage alloc] initWithContentsOfFile:path];
1494 [image autorelease];
1496 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1497 return image == nil ? __UIImageWithNameInDomain(name, domain) : image;
1500 MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
1502 NSLog(@"WB:Debug: GSFontCreateWithName(\"%s\", %f)", name, size);
1503 if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
1504 name = [font UTF8String];
1505 //if (NSString *scale = [Info_ objectForKey:[NSString stringWithFormat:@"FontScale-%s", name]])
1506 // size *= [scale floatValue];
1507 return _GSFontCreateWithName(name, traits, size);
1510 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
1511 #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
1513 bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
1515 MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
1517 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %p, %u)", a0, a1, a2);
1518 bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
1520 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);
1523 NSString *path = [NSString stringWithUTF8String:a1];
1524 if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
1525 NSString *file = [path substringFromIndex:31];
1526 for (NSString *theme in themes_) {
1527 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
1528 if ([Manager_ fileExistsAtPath:path]) {
1529 strcpy(a1, [path UTF8String]);
1538 static void ChangeWallpaper(
1539 CFNotificationCenterRef center,
1543 CFDictionaryRef info
1546 NSLog(@"WB:Debug:ChangeWallpaper!");
1549 if (WallpaperFile_ != nil) {
1550 image = [[UIImage alloc] initWithContentsOfFile:WallpaperFile_];
1552 image = [image autorelease];
1555 if (WallpaperImage_ != nil)
1556 [WallpaperImage_ setImage:image];
1557 if (WallpaperPage_ != nil)
1558 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
1562 #define WBRename(name, sel, imp) \
1563 _ ## name ## $ ## imp = MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp)
1565 template <typename Type_>
1566 static void nlset(Type_ &function, struct nlist *nl, size_t index) {
1567 struct nlist &name(nl[index]);
1568 uintptr_t value(name.n_value);
1569 if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
1570 value |= 0x00000001;
1571 function = reinterpret_cast<Type_>(value);
1574 template <typename Type_>
1575 static void dlset(Type_ &function, const char *name) {
1576 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
1579 /*static void WBImage(const struct mach_header* mh, intptr_t vmaddr_slide) {
1580 uint32_t count(_dyld_image_count());
1581 for (uint32_t index(0); index != count; ++index)
1582 if (_dyld_get_image_header(index) == mh) {
1583 CGImageSourceRef (*CGImageSourceCreateWithURL)(CFURLRef url, CFDictionaryRef options);
1584 dlset(CGImageSourceCreateWithURL, "CGImageSourceCreateWithURL");
1585 MSHookFunction(&CGImageSourceCreateWithURL, &$CGImageSourceCreateWithURL, &_CGImageSourceCreateWithURL);
1589 extern "C" void WBInitialize() {
1590 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
1592 NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);
1594 NSLog(@"WB:Notice: WinterBoard");
1596 dlset(_GSFontGetUseLegacyFontMetrics, "GSFontGetUseLegacyFontMetrics");
1598 //if ([NSBundle bundleWithIdentifier:@"com.apple.ImageIO.framework"] != nil)
1599 MSHookFunction(&CGImageSourceCreateWithURL, &$CGImageSourceCreateWithURL, &_CGImageSourceCreateWithURL);
1601 // _dyld_register_func_for_add_image(&WBImage);
1605 if ([NSBundle bundleWithIdentifier:@"com.apple.UIKit"] != nil) {
1607 memset(nl, 0, sizeof(nl));
1608 nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName";
1609 nl[1].n_un.n_name = (char *) "__UIImageAtPath";
1610 nl[2].n_un.n_name = (char *) "__UIImageRefAtPath";
1611 nl[3].n_un.n_name = (char *) "__UIImageWithNameInDomain";
1612 nl[4].n_un.n_name = (char *) "__UIKitBundle";
1613 nl[5].n_un.n_name = (char *) "__UIPackedImageTableGetIdentifierForName";
1614 nl[6].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";
1617 nlset(_UIApplicationImageWithName, nl, 0);
1618 nlset(_UIImageAtPath, nl, 1);
1619 nlset(_UIImageRefAtPath, nl, 2);
1620 nlset(_UIImageWithNameInDomain, nl, 3);
1621 nlset(_UIKitBundle, nl, 4);
1622 nlset(_UIPackedImageTableGetIdentifierForName, nl, 5);
1623 nlset(_UISharedImageNameGetIdentifier, nl, 6);
1625 MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
1626 MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath);
1627 MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
1628 MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
1632 MSHookFunction(&GSFontCreateWithName, &$GSFontCreateWithName, &_GSFontCreateWithName);
1634 if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {
1637 memset(nl, 0, sizeof(nl));
1638 nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb";
1639 nlist(AudioToolbox, nl);
1640 nlset(_Z24GetFileNameForThisActionmPcRb, nl, 0);
1641 MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &__Z24GetFileNameForThisActionmPcRb);
1645 $NSBundle = objc_getClass("NSBundle");
1647 _NSBundle$localizedStringForKey$value$table$ = MSHookMessage($NSBundle, @selector(localizedStringForKey:value:table:), &$NSBundle$localizedStringForKey$value$table$);
1648 _NSBundle$pathForResource$ofType$ = MSHookMessage($NSBundle, @selector(pathForResource:ofType:), &$NSBundle$pathForResource$ofType$);
1650 $UIImage = objc_getClass("UIImage");
1651 $UINavigationBar = objc_getClass("UINavigationBar");
1652 $UIToolbar = objc_getClass("UIToolbar");
1654 _UIImage$defaultDesktopImage = MSHookMessage(object_getClass($UIImage), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage);
1656 //WBRename("UINavigationBar", @selector(initWithCoder:), (IMP) &UINavigationBar$initWithCoder$);
1657 //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:), (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
1659 _UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$);
1660 _UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$);
1662 Manager_ = [[NSFileManager defaultManager] retain];
1663 UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1664 PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1665 Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0];
1666 Bundles_ = [[NSMutableDictionary alloc] initWithCapacity:2];
1667 Themed_ = [[NSMutableDictionary alloc] initWithCapacity:128];
1669 themes_ = [[NSMutableArray alloc] initWithCapacity:8];
1671 if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
1672 // Load Settings {{{
1673 if (NSNumber *value = [settings objectForKey:@"SummerBoard"])
1674 SummerBoard_ = [value boolValue];
1675 if (NSNumber *value = [settings objectForKey:@"Debug"])
1676 Debug_ = [value boolValue];
1678 NSArray *themes([settings objectForKey:@"Themes"]);
1680 if (NSString *theme = [settings objectForKey:@"Theme"])
1681 themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
1683 [NSNumber numberWithBool:true], @"Active",
1687 for (NSDictionary *theme in themes) {
1688 NSNumber *active([theme objectForKey:@"Active"]);
1689 if (![active boolValue])
1692 NSString *name([theme objectForKey:@"Name"]);
1696 NSString *theme(nil);
1698 #define testForTheme(format...) \
1699 if (theme == nil) { \
1700 NSString *path = [NSString stringWithFormat:format]; \
1701 if ([Manager_ fileExistsAtPath:path]) { \
1702 [themes_ addObject:path]; \
1707 testForTheme(@"/Library/Themes/%@.theme", name)
1708 testForTheme(@"/Library/Themes/%@", name)
1709 testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)
1715 Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
1717 for (NSString *theme in themes_)
1718 if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])
1719 for (NSString *key in [info allKeys])
1720 if ([Info_ objectForKey:key] == nil)
1721 [Info_ setObject:[info objectForKey:key] forKey:key];
1723 bool sms($getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]) != nil);
1725 SpringBoard_ = [identifier isEqualToString:@"com.apple.springboard"];
1727 if ([NSBundle bundleWithIdentifier:@"com.apple.chatkit"] != nil)
1730 $CKMessageCell = objc_getClass("CKMessageCell");
1731 _CKMessageCell$addBalloonView$ = MSHookMessage($CKMessageCell, @selector(addBalloonView:), &$CKMessageCell$addBalloonView$);
1732 _CKMessageCell$initWithStyle$reuseIdentifier$ = MSHookMessage($CKMessageCell, @selector(initWithStyle:reuseIdentifier:), &$CKMessageCell$initWithStyle$reuseIdentifier$);
1734 $CKTranscriptTableView = objc_getClass("CKTranscriptTableView");
1735 _CKTranscriptTableView$setSeparatorStyle$ = MSHookMessage($CKTranscriptTableView, @selector(setSeparatorStyle:), &$CKTranscriptTableView$setSeparatorStyle$);
1736 _CKTranscriptTableView$initWithFrame$style$ = MSHookMessage($CKTranscriptTableView, @selector(initWithFrame:style:), &$CKTranscriptTableView$initWithFrame$style$);
1738 $CKTimestampView = objc_getClass("CKTimestampView");
1739 _CKTimestampView$initWithStyle$reuseIdentifier$ = MSHookMessage($CKTimestampView, @selector(initWithStyle:reuseIdentifier:), &$CKTimestampView$initWithStyle$reuseIdentifier$);
1741 $CKTranscriptController = objc_getClass("CKTranscriptController");
1742 _TranscriptController$loadView = MSHookMessage($CKTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1746 if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
1749 if (_TranscriptController$loadView == NULL) {
1750 Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
1751 _TranscriptController$loadView = MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1755 } else if (SpringBoard_) {
1757 CFNotificationCenterAddObserver(
1758 CFNotificationCenterGetDarwinNotifyCenter(),
1759 NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0
1762 if ($getTheme$([NSArray arrayWithObject:@"Wallpaper.mp4"]) != nil) {
1763 NSBundle *MediaPlayer([NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"]);
1764 if (MediaPlayer != nil)
1767 $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
1768 $MPVideoView = objc_getClass("MPVideoView");
1771 $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
1773 bool olden(dlsym(RTLD_DEFAULT, "GSLibraryCopyGenerationInfoValueForKey") == NULL);
1776 $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
1778 $SBApplication = objc_getClass("SBApplication");
1779 $SBApplicationIcon = objc_getClass("SBApplicationIcon");
1780 $SBAwayView = objc_getClass("SBAwayView");
1781 $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
1782 $SBButtonBar = objc_getClass("SBButtonBar");
1783 $SBDockIconListView = objc_getClass("SBDockIconListView");
1784 $SBIcon = objc_getClass("SBIcon");
1785 $SBIconBadge = objc_getClass("SBIconBadge");
1786 $SBIconController = objc_getClass("SBIconController");
1787 $SBIconLabel = objc_getClass("SBIconLabel");
1788 $SBIconList = objc_getClass("SBIconList");
1789 $SBIconModel = objc_getClass("SBIconModel");
1790 $SBIconView = objc_getClass("SBIconView");
1791 //$SBImageCache = objc_getClass("SBImageCache");
1792 $SBSearchView = objc_getClass("SBSearchView");
1793 $SBSearchTableViewCell = objc_getClass("SBSearchTableViewCell");
1794 $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
1795 $SBStatusBarController = objc_getClass("SBStatusBarController");
1796 $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
1797 $SBStatusBarTimeView = objc_getClass("SBStatusBarTimeView");
1798 $SBUIController = objc_getClass("SBUIController");
1799 $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon");
1801 if ($SBIconView == nil)
1802 $SBIconView = $SBIcon;
1804 Four_ = $SBDockIconListView != nil;
1806 WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$);
1809 WBRename(SBApplication, pathForIcon, pathForIcon);
1810 WBRename(SBApplicationIcon, icon, icon);
1811 WBRename(SBApplicationIcon, generateIconImage:, generateIconImage$);
1814 WBRename(SBBookmarkIcon, icon, icon);
1815 WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview);
1816 WBRename(SBCalendarIconContentsView, drawRect:, drawRect$);
1817 WBRename(SBIcon, setAlpha:, setAlpha$);
1818 WBRename(SBIconBadge, initWithBadge:, initWithBadge$);
1819 WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged);
1820 WBRename(SBIconView, initWithDefaultSize, initWithDefaultSize);
1821 WBRename(SBIconView, setIconImageAlpha:, setIconImageAlpha$);
1822 WBRename(SBIconView, setIconLabelAlpha:, setIconLabelAlpha$);
1823 WBRename(SBUIController, init, init);
1824 WBRename(SBWidgetApplicationIcon, icon, icon);
1826 WBRename(SBDockIconListView, setFrame:, setFrame$);
1827 MSHookMessage(object_getClass($SBDockIconListView), @selector(shouldShowNewDock), &$SBDockIconListView$shouldShowNewDock, &_SBDockIconListView$shouldShowNewDock);
1830 WBRename(SBIconLabel, drawRect:, drawRect$);
1832 WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
1833 WBRename(SBIconLabel, setInDock:, setInDock$);
1835 WBRename(SBIconList, setFrame:, setFrame$);
1837 WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
1838 WBRename(SBIconModel, cacheImagesForIcon:, cacheImagesForIcon$);
1839 WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
1840 WBRename(SBIconModel, getCachedImagedForIcon:smallIcon:, getCachedImagedForIcon$smallIcon$);
1842 WBRename(SBSearchView, initWithFrame:, initWithFrame$);
1843 WBRename(SBSearchTableViewCell, drawRect:, drawRect$);
1844 WBRename(SBSearchTableViewCell, initWithStyle:reuseIdentifier:, initWithStyle$reuseIdentifier$);
1846 //WBRename(SBImageCache, initWithName:forImageWidth:imageHeight:initialCapacity:, initWithName$forImageWidth$imageHeight$initialCapacity$);
1848 WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
1849 WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
1850 //WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
1851 //WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:animation:, setStatusBarMode$orientation$duration$animation$);
1852 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$);
1853 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:startTime:, setStatusBarMode$orientation$duration$fenceID$animation$startTime$);
1854 WBRename(SBStatusBarOperatorNameView, operatorNameStyle, operatorNameStyle);
1855 WBRename(SBStatusBarOperatorNameView, setOperatorName:fullSize:, setOperatorName$fullSize$);
1856 WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
1859 English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
1861 Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
1865 Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
1866 Papered_ = $getTheme$(Wallpapers_) != nil;
1868 Docked_ = $getTheme$([NSArray arrayWithObjects:@"Dock.png", nil]);