1 /* WinterBoard - Theme Manager for the iPhone
2 * Copyright (C) 2008 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>
64 #import <Celestial/AVController.h>
65 #import <Celestial/AVItem.h>
66 #import <Celestial/AVQueue.h>
68 #include <substrate.h>
70 #import <UIKit/UIKit.h>
72 #import <SpringBoard/SBApplication.h>
73 #import <SpringBoard/SBApplicationIcon.h>
74 #import <SpringBoard/SBAppWindow.h>
75 #import <SpringBoard/SBAwayView.h>
76 #import <SpringBoard/SBBookmarkIcon.h>
77 #import <SpringBoard/SBButtonBar.h>
78 #import <SpringBoard/SBCalendarIconContentsView.h>
79 #import <SpringBoard/SBIconController.h>
80 #import <SpringBoard/SBIconLabel.h>
81 #import <SpringBoard/SBIconList.h>
82 #import <SpringBoard/SBIconModel.h>
83 #import <SpringBoard/SBImageCache.h>
84 #import <SpringBoard/SBStatusBarContentsView.h>
85 #import <SpringBoard/SBStatusBarController.h>
86 #import <SpringBoard/SBStatusBarOperatorNameView.h>
87 #import <SpringBoard/SBStatusBarTimeView.h>
88 #import <SpringBoard/SBUIController.h>
89 #import <SpringBoard/SBWidgetApplicationIcon.h>
91 #import <MobileSMS/mSMSMessageTranscriptController.h>
93 #import <MediaPlayer/MPMoviePlayerController.h>
94 #import <MediaPlayer/MPVideoView.h>
95 #import <MediaPlayer/MPVideoView-PlaybackControl.h>
97 #import <CoreGraphics/CGGeometry.h>
99 extern "C" void __clear_cache (char *beg, char *end);
101 @protocol WinterBoard
105 Class $MPMoviePlayerController;
107 Class $WebCoreFrameBridge;
112 Class $UINavigationBar;
115 Class $SBApplication;
116 Class $SBApplicationIcon;
118 Class $SBBookmarkIcon;
120 Class $SBCalendarIconContentsView;
123 Class $SBIconController;
127 //Class $SBImageCache;
128 Class $SBStatusBarContentsView;
129 Class $SBStatusBarController;
130 Class $SBStatusBarOperatorNameView;
131 Class $SBStatusBarTimeView;
132 Class $SBUIController;
133 Class $SBWidgetApplicationIcon;
135 @interface NSDictionary (WinterBoard)
136 - (UIColor *) colorForKey:(NSString *)key;
137 - (BOOL) boolForKey:(NSString *)key;
140 @implementation NSDictionary (WinterBoard)
142 - (UIColor *) colorForKey:(NSString *)key {
143 NSString *value = [self objectForKey:key];
150 - (BOOL) boolForKey:(NSString *)key {
151 if (NSString *value = [self objectForKey:key])
152 return [value boolValue];
159 bool Engineer_ = false;
161 static UIImage *(*_UIApplicationImageWithName)(NSString *name);
162 static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path);
163 static CGImageRef (*_UIImageRefAtPath)(NSString *name, bool cache, UIImageOrientation *orientation);
164 static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain);
165 static NSBundle *(*_UIKitBundle)();
166 static int (*_UISharedImageNameGetIdentifier)(NSString *);
167 static UIImage *(*_UISharedImageWithIdentifier)(int);
169 static NSMutableDictionary *UIImages_;
170 static NSMutableDictionary *PathImages_;
171 static NSMutableDictionary *Cache_;
172 static NSMutableDictionary *Strings_;
173 static NSMutableDictionary *Themed_;
174 static NSMutableDictionary *Bundles_;
176 static NSFileManager *Manager_;
177 static NSDictionary *English_;
178 static NSMutableDictionary *Info_;
179 static NSMutableArray *themes_;
181 static NSString *$getTheme$(NSArray *files, bool parent = false) {
183 if (NSString *path = [Themed_ objectForKey:files])
184 return reinterpret_cast<id>(path) == [NSNull null] ? nil : path;
187 NSLog(@"WB:Debug: %@", [files description]);
191 for (NSString *theme in themes_)
192 for (NSString *file in files) {
193 path = [NSString stringWithFormat:@"%@/%@", theme, file];
194 if ([Manager_ fileExistsAtPath:path]) {
195 path = parent ? theme : path;
203 [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast<id>(path)) forKey:files];
207 static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui) {
208 NSString *identifier = [bundle bundleIdentifier];
209 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
211 if (identifier != nil)
212 [names addObject:[NSString stringWithFormat:@"Bundles/%@/%@", identifier, file]];
213 if (NSString *folder = [[bundle bundlePath] lastPathComponent])
214 [names addObject:[NSString stringWithFormat:@"Folders/%@/%@", folder, file]];
216 [names addObject:[NSString stringWithFormat:@"UIImages/%@", file]];
218 #define remapResourceName(oldname, newname) \
219 else if ([file isEqualToString:oldname]) \
220 [names addObject:[NSString stringWithFormat:@"%@.png", newname]]; \
222 if (identifier == nil);
223 else if ([identifier isEqualToString:@"com.apple.calculator"])
224 [names addObject:[NSString stringWithFormat:@"Files/Applications/Calculator.app/%@", file]];
225 else if (![identifier isEqualToString:@"com.apple.springboard"]);
226 remapResourceName(@"FSO_BG.png", @"StatusBar")
227 remapResourceName(@"SBDockBG.png", @"Dock")
228 remapResourceName(@"SBWeatherCelsius.png", @"Icons/Weather")
230 if (NSString *path = $getTheme$(names))
235 static NSString *$pathForIcon$(SBApplication *self) {
236 NSString *identifier = [self bundleIdentifier];
237 NSString *path = [self path];
238 NSString *folder = [path lastPathComponent];
239 NSString *dname = [self displayName];
240 NSString *didentifier = [self displayIdentifier];
243 NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier);
245 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
247 if (identifier != nil)
248 [names addObject:[NSString stringWithFormat:@"Bundles/%@/icon.png", identifier]];
250 [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]];
252 #define testForIcon(Name) \
253 if (NSString *name = Name) \
254 [names addObject:[NSString stringWithFormat:@"Icons/%@.png", name]];
256 testForIcon(identifier);
259 if (didentifier != nil) {
260 testForIcon([English_ objectForKey:didentifier]);
262 NSArray *parts = [didentifier componentsSeparatedByString:@"-"];
263 if ([parts count] != 1)
264 if (NSDictionary *english = [[[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingString:@"/English.lproj/UIRoleDisplayNames.strings"]] autorelease])
265 testForIcon([english objectForKey:[parts lastObject]]);
268 if (NSString *path = $getTheme$(names))
273 @interface NSBundle (WinterBoard)
274 + (NSBundle *) wb$bundleWithFile:(NSString *)path;
277 @implementation NSBundle (WinterBoard)
279 + (NSBundle *) wb$bundleWithFile:(NSString *)path {
280 path = [path stringByDeletingLastPathComponent];
281 if (path == nil || [path length] == 0 || [path isEqualToString:@"/"])
283 return [NSBundle mainBundle];
285 NSBundle *bundle([Bundles_ objectForKey:path]);
286 if (reinterpret_cast<id>(bundle) == [NSNull null])
288 else if (bundle == nil) {
289 if ([Manager_ fileExistsAtPath:[path stringByAppendingPathComponent:@"Info.plist"]])
290 bundle = [NSBundle bundleWithPath:path];
292 bundle = [NSBundle wb$bundleWithFile:path];
294 NSLog(@"WB:Debug:PathBundle(%@, %@)", path, bundle);
295 //[Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast<id>(bundle)) forKey:path];
303 @interface NSString (WinterBoard)
304 - (NSString *) wb$themedPath;
307 @implementation NSString (WinterBoard)
309 - (NSString *) wb$themedPath {
311 NSLog(@"WB:Debug:Bypass(\"%@\")", self);
313 if (NSBundle *bundle = [NSBundle wb$bundleWithFile:self]) {
315 NSString *file([self stringByResolvingSymlinksInPath]);
316 NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]);
317 if ([file hasPrefix:prefix]) {
318 NSUInteger length([prefix length]);
319 if (length != [file length])
320 if (NSString *path = $pathForFile$inBundle$([file substringFromIndex:(length + 1)], bundle, false))
330 UIImage *$cacheForImage$(UIImage *image) {
331 CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB());
332 CGRect rect = {CGPointMake(1, 1), [image size]};
333 CGSize size = {rect.size.width + 2, rect.size.height + 2};
335 CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
336 CGColorSpaceRelease(space);
338 CGContextDrawImage(context, rect, [image CGImage]);
339 CGImageRef ref(CGBitmapContextCreateImage(context));
340 CGContextRelease(context);
342 UIImage *cache([UIImage imageWithCGImage:ref]);
348 /*MSHook(id, SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$, SBImageCache *self, SEL sel, NSString *name, unsigned width, unsigned height, unsigned capacity) {
349 //if ([name isEqualToString:@"icons"]) return nil;
350 return _SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$(self, sel, name, width, height, capacity);
353 MSHook(void, SBIconModel$cacheImageForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
354 NSString *key([icon displayIdentifier]);
356 if (UIImage *image = [icon icon]) {
357 CGSize size = [image size];
358 if (size.width != 59 || size.height != 60) {
359 UIImage *cache($cacheForImage$(image));
360 [Cache_ setObject:cache forKey:key];
365 _SBIconModel$cacheImageForIcon$(self, sel, icon);
368 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
369 NSString *key([icon displayIdentifier]);
370 if (UIImage *image = [Cache_ objectForKey:key])
373 return _SBIconModel$getCachedImagedForIcon$(self, sel, icon);
376 MSHook(UIImage *, SBApplicationIcon$icon, SBApplicationIcon *self, SEL sel) {
377 if (![Info_ boolForKey:@"ComposeStoreIcons"])
378 if (NSString *path = $pathForIcon$([self application]))
379 return [UIImage imageWithContentsOfFile:path];
380 return _SBApplicationIcon$icon(self, sel);
383 MSHook(UIImage *, SBWidgetApplicationIcon$icon, SBWidgetApplicationIcon *self, SEL sel) {
385 NSLog(@"WB:Debug:Widget(%@:%@)", [self displayIdentifier], [self displayName]);
386 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
387 return [UIImage imageWithContentsOfFile:path];
388 return _SBWidgetApplicationIcon$icon(self, sel);
391 MSHook(UIImage *, SBBookmarkIcon$icon, SBBookmarkIcon *self, SEL sel) {
393 NSLog(@"WB:Debug:Bookmark(%@:%@)", [self displayIdentifier], [self displayName]);
394 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
395 return [UIImage imageWithContentsOfFile:path];
396 return _SBBookmarkIcon$icon(self, sel);
399 MSHook(NSString *, SBApplication$pathForIcon, SBApplication *self, SEL sel) {
400 if (NSString *path = $pathForIcon$(self))
402 return _SBApplication$pathForIcon(self, sel);
405 static UIImage *CachedImageAtPath(NSString *path) {
406 path = [path stringByResolvingSymlinksInPath];
407 UIImage *image = [PathImages_ objectForKey:path];
409 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
410 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
412 image = [image autorelease];
413 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:path];
417 MSHook(CGImageRef, _UIImageRefAtPath, NSString *name, bool cache, UIImageOrientation *orientation) {
419 NSLog(@"WB:Debug: _UIImageRefAtPath(\"%@\", %s)", name, cache ? "true" : "false");
420 return __UIImageRefAtPath(([name wb$themedPath], name), cache, orientation);
423 /*MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) {
425 return __UIImageAtPath(name, nil);
427 NSString *key = [NSString stringWithFormat:@"B:%@/%@", [bundle bundleIdentifier], name];
428 UIImage *image = [PathImages_ objectForKey:key];
430 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
432 NSLog(@"WB:Debug: _UIImageAtPath(\"%@\", %@)", name, bundle);
433 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
434 image = CachedImageAtPath(path);
436 image = __UIImageAtPath(name, bundle);
437 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
442 MSHook(UIImage *, _UIApplicationImageWithName, NSString *name) {
443 NSBundle *bundle = [NSBundle mainBundle];
445 NSLog(@"WB:Debug: _UIApplicationImageWithName(\"%@\", %@)", name, bundle);
446 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
447 return CachedImageAtPath(path);
448 return __UIApplicationImageWithName(name);
451 #define WBDelegate(delegate) \
452 - (NSMethodSignature*) methodSignatureForSelector:(SEL)sel { \
454 NSLog(@"WB:MS:%s:(%s)", class_getName([self class]), sel_getName(sel)); \
455 if (NSMethodSignature *sig = [delegate methodSignatureForSelector:sel]) \
457 NSLog(@"WB:Error: [%s methodSignatureForSelector:(%s)]", class_getName([self class]), sel_getName(sel)); \
461 - (void) forwardInvocation:(NSInvocation*)inv { \
462 SEL sel = [inv selector]; \
463 if ([delegate respondsToSelector:sel]) \
464 [inv invokeWithTarget:delegate]; \
466 NSLog(@"WB:Error: [%s forwardInvocation:(%s)]", class_getName([self class]), sel_getName(sel)); \
469 MSHook(NSString *, NSBundle$pathForResource$ofType$, NSBundle *self, SEL sel, NSString *resource, NSString *type) {
470 NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
472 NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
473 if (NSString *path = $pathForFile$inBundle$(file, self, false))
475 return _NSBundle$pathForResource$ofType$(self, sel, resource, type);
478 void $setBarStyle$_(NSString *name, int &style) {
480 NSLog(@"WB:Debug:%@Style:%d", name, style);
481 NSNumber *number = nil;
483 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style-%d", name, style]];
485 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style", name]];
487 style = [number intValue];
489 NSLog(@"WB:Debug:%@Style=%d", name, style);
493 MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *self, SEL sel, CGRect rect) {
494 NSBundle *bundle([NSBundle mainBundle]);
496 CFLocaleRef locale(CFLocaleCopyCurrent());
497 CFDateFormatterRef formatter(CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle));
500 CFDateRef now(CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()));
502 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NUMBER_FORMAT" value:@"" table:@"SpringBoard"]);
503 CFStringRef date(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
504 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NAME_FORMAT" value:@"" table:@"SpringBoard"]);
505 CFStringRef day(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
509 CFRelease(formatter);
511 NSString *datestyle(@""
512 "font-family: Helvetica; "
513 "font-weight: bold; "
519 NSString *daystyle(@""
520 "font-family: Helvetica; "
521 "font-weight: bold; "
524 "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px; "
527 if (NSString *style = [Info_ objectForKey:@"CalendarIconDateStyle"])
528 datestyle = [datestyle stringByAppendingString:style];
529 if (NSString *style = [Info_ objectForKey:@"CalendarIconDayStyle"])
530 daystyle = [daystyle stringByAppendingString:style];
532 float width([self bounds].size.width);
534 CGSize datesize = [(NSString *)date sizeWithStyle:datestyle forWidth:(width + leeway)];
535 CGSize daysize = [(NSString *)day sizeWithStyle:daystyle forWidth:(width + leeway)];
537 [(NSString *)date drawAtPoint:CGPointMake(
538 (width + 1 - datesize.width) / 2, (71 - datesize.height) / 2
539 ) withStyle:datestyle];
541 [(NSString *)day drawAtPoint:CGPointMake(
542 (width + 1 - daysize.width) / 2, (16 - daysize.height) / 2
543 ) withStyle:daystyle];
549 /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) {
552 if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"])
553 style = [number intValue];
555 if (UIColor *color = [Info_ colorForKey:@"NavigationBarTint"])
558 return [self wb$initWithFrame:frame withBarStyle:style withTintColor:tint];
561 /*static id UINavigationBar$initWithCoder$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame, NSCoder *coder) {
562 self = [self wb$initWithCoder:coder];
565 UINavigationBar$setBarStyle$_(self);
569 static id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame) {
570 self = [self wb$initWithFrame:frame];
573 UINavigationBar$setBarStyle$_(self);
577 MSHook(void, UIToolbar$setBarStyle$, UIToolbar *self, SEL sel, int style) {
578 $setBarStyle$_(@"Toolbar", style);
579 return _UIToolbar$setBarStyle$(self, sel, style);
582 MSHook(void, UINavigationBar$setBarStyle$, UINavigationBar *self, SEL sel, int style) {
583 $setBarStyle$_(@"NavigationBar", style);
584 return _UINavigationBar$setBarStyle$(self, sel, style);
587 MSHook(void, SBButtonBar$didMoveToSuperview, UIView *self, SEL sel) {
588 [[self superview] setBackgroundColor:[UIColor clearColor]];
589 _SBButtonBar$didMoveToSuperview(self, sel);
592 MSHook(void, SBStatusBarContentsView$didMoveToSuperview, UIView *self, SEL sel) {
593 [[self superview] setBackgroundColor:[UIColor clearColor]];
594 _SBStatusBarContentsView$didMoveToSuperview(self, sel);
597 MSHook(UIImage *, UIImage$defaultDesktopImage, UIImage *self, SEL sel) {
599 NSLog(@"WB:Debug:DefaultDesktopImage");
600 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"LockBackground.png", @"LockBackground.jpg", nil]))
601 return [UIImage imageWithContentsOfFile:path];
602 return _UIImage$defaultDesktopImage(self, sel);
605 static NSArray *Wallpapers_;
606 static NSString *WallpaperFile_;
607 static UIImageView *WallpaperImage_;
608 static UIWebDocumentView *WallpaperPage_;
609 static NSURL *WallpaperURL_;
611 #define _release(object) \
612 do if (object != nil) { \
617 void DumpHierarchy(UIView *view, unsigned index = 0, unsigned indent = 0) {
618 NSLog(@"%*s|%2d:%s", indent * 3, "", index, class_getName([view class]));
620 for (UIView *child in [view subviews])
621 DumpHierarchy(child, index++, indent + 1);
624 MSHook(id, SBUIController$init, SBUIController *self, SEL sel) {
625 self = _SBUIController$init(self, sel);
629 UIWindow *&_window(MSHookIvar<UIWindow *>(self, "_window"));
630 UIView *&_contentView(MSHookIvar<UIView *>(self, "_contentView"));
632 UIView *content([[[UIView alloc] initWithFrame:[_contentView frame]] autorelease]);
633 [content setBackgroundColor:[_contentView backgroundColor]];
634 [_contentView setBackgroundColor:[UIColor clearColor]];
635 [_contentView setFrame:[content bounds]];
636 [_window setContentView:content];
638 _release(WallpaperFile_);
639 _release(WallpaperImage_);
640 _release(WallpaperPage_);
641 _release(WallpaperURL_);
643 if (NSString *theme = $getTheme$(Wallpapers_, true)) {
644 NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"];
645 if ([Manager_ fileExistsAtPath:mp4]) {
649 static AVController *controller_(nil);
650 if (controller_ == nil) {
651 AVQueue *queue([AVQueue avQueue]);
652 controller_ = [[AVController avControllerWithQueue:queue error:&error] retain];
655 AVQueue *queue([controller_ queue]);
657 UIView *video([[[UIView alloc] initWithFrame:[_contentView bounds]] autorelease]);
658 [controller_ setLayer:[video _layer]];
660 AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]);
661 [queue appendItem:item error:&error];
663 [controller_ play:&error];
664 #elif UseMPMoviePlayerController
665 NSURL *url([NSURL fileURLWithPath:mp4]);
666 MPMoviePlayerController *controller = [[MPMoviePlayerController alloc] initWithContentURL:url];
667 controller.movieControlMode = MPMovieControlModeHidden;
670 MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[_contentView bounds]] autorelease];
671 [video setMovieWithPath:mp4];
672 [video setRepeatMode:1];
673 [video setRepeatGap:-1];
674 [video playFromBeginning];;
677 [content addSubview:video];
680 NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"];
681 NSString *jpg = [theme stringByAppendingPathComponent:@"Wallpaper.jpg"];
684 if ([Manager_ fileExistsAtPath:png])
686 else if ([Manager_ fileExistsAtPath:jpg])
692 image = [[UIImage alloc] initWithContentsOfFile:path];
694 image = [image autorelease];
698 WallpaperFile_ = [path retain];
699 WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
700 [content addSubview:WallpaperImage_];
703 NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"];
704 if ([Manager_ fileExistsAtPath:html]) {
705 CGRect bounds = [content bounds];
707 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
708 [view setAutoresizes:true];
710 WallpaperPage_ = [view retain];
711 WallpaperURL_ = [[NSURL fileURLWithPath:html] retain];
713 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
715 [[view webView] setDrawsBackground:false];
716 [view setBackgroundColor:[UIColor clearColor]];
718 [content addSubview:view];
722 for (size_t i(0), e([themes_ count]); i != e; ++i) {
723 NSString *theme = [themes_ objectAtIndex:(e - i - 1)];
724 NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"];
725 if ([Manager_ fileExistsAtPath:html]) {
726 CGRect bounds = [content bounds];
728 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
729 [view setAutoresizes:true];
731 NSURL *url = [NSURL fileURLWithPath:html];
732 [view loadRequest:[NSURLRequest requestWithURL:url]];
734 [[view webView] setDrawsBackground:false];
735 [view setBackgroundColor:[UIColor clearColor]];
737 [content addSubview:view];
741 [content addSubview:_contentView];
742 DumpHierarchy(_window);
747 MSHook(void, SBAwayView$updateDesktopImage$, SBAwayView *self, SEL sel, UIImage *image) {
748 NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]);
749 UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
751 if (path != nil && _backgroundView != nil)
754 _SBAwayView$updateDesktopImage$(self, sel, image);
757 CGRect bounds = [self bounds];
759 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
760 [view setAutoresizes:true];
762 if (WallpaperPage_ != nil)
763 [WallpaperPage_ release];
764 WallpaperPage_ = [view retain];
766 if (WallpaperURL_ != nil)
767 [WallpaperURL_ release];
768 WallpaperURL_ = [[NSURL fileURLWithPath:path] retain];
770 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
772 [[view webView] setDrawsBackground:false];
773 [view setBackgroundColor:[UIColor clearColor]];
775 [self insertSubview:view aboveSubview:_backgroundView];
779 /*extern "C" CGColorRef CGGStateGetSystemColor(void *);
780 extern "C" CGColorRef CGGStateGetFillColor(void *);
781 extern "C" CGColorRef CGGStateGetStrokeColor(void *);
782 extern "C" NSString *UIStyleStringFromColor(CGColorRef);*/
784 /* WBTimeLabel {{{ */
785 @interface WBTimeLabel : NSProxy {
787 _transient SBStatusBarTimeView *view_;
790 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view;
794 @implementation WBTimeLabel
801 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view {
802 time_ = [time retain];
809 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
810 if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
811 BOOL &_mode(MSHookIvar<BOOL>(view_, "_mode"));;
813 [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
814 "font-family: Helvetica; "
815 "font-weight: bold; "
818 "%@", _mode ? @"white" : @"black", custom]];
823 return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
828 /* WBBadgeLabel {{{ */
829 @interface WBBadgeLabel : NSProxy {
833 - (id) initWithBadge:(NSString *)badge;
837 @implementation WBBadgeLabel
844 - (id) initWithBadge:(NSString *)badge {
845 badge_ = [badge retain];
851 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
852 if (NSString *custom = [Info_ objectForKey:@"BadgeStyle"]) {
853 [badge_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
854 "font-family: Helvetica; "
855 "font-weight: bold; "
863 return [badge_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
869 MSHook(void, SBIcon$setAlpha$, SBIcon *self, SEL sel, float alpha) {
870 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
871 alpha = [number floatValue];
872 return _SBIcon$setAlpha$(self, sel, alpha);
875 MSHook(id, SBIconBadge$initWithBadge$, SBIconBadge *self, SEL sel, NSString *badge) {
876 if ((self = _SBIconBadge$initWithBadge$(self, sel, badge)) != nil) {
877 id &_badge(MSHookIvar<id>(self, "_badge"));
879 if (id label = [[WBBadgeLabel alloc] initWithBadge:[_badge autorelease]])
884 void SBStatusBarController$setStatusBarMode(int &mode) {
886 NSLog(@"WB:Debug:setStatusBarMode:%d", mode);
887 if (mode < 100) // 104:hidden 105:glowing
888 if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"])
889 mode = [number intValue];
892 /*MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int animation) {
893 NSLog(@"mode:%d orientation:%d duration:%f animation:%d", mode, orientation, duration, animation);
894 SBStatusBarController$setStatusBarMode(mode);
895 return _SBStatusBarController$setStatusBarMode$orientation$duration$animation$(self, sel, mode, orientation, duration, animation);
898 MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int fenceID, int animation) {
899 NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d", mode, orientation, duration, fenceID, animation);
900 SBStatusBarController$setStatusBarMode(mode);
901 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, fenceID, animation);
904 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) {
905 NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d startTime:%f", mode, orientation, duration, fenceID, animation, startTime);
906 SBStatusBarController$setStatusBarMode(mode);
907 NSLog(@"mode=%u", mode);
908 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$(self, sel, mode, orientation, duration, fenceID, animation, startTime);
911 /*MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) {
912 if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"])
913 mode = [number intValue];
914 return _SBStatusBarContentsView$initWithStatusBar$mode$(self, sel, bar, mode);
917 MSHook(NSString *, SBStatusBarOperatorNameView$operatorNameStyle, SBStatusBarOperatorNameView *self, SEL sel) {
918 NSString *style(_SBStatusBarOperatorNameView$operatorNameStyle(self, sel));
920 NSLog(@"operatorNameStyle= %@", style);
921 if (NSString *custom = [Info_ objectForKey:@"OperatorNameStyle"])
922 style = [NSString stringWithFormat:@"%@; %@", style, custom];
926 MSHook(void, SBStatusBarOperatorNameView$setOperatorName$fullSize$, SBStatusBarOperatorNameView *self, SEL sel, NSString *name, BOOL full) {
928 NSLog(@"setOperatorName:\"%@\" fullSize:%u", name, full);
929 return _SBStatusBarOperatorNameView$setOperatorName$fullSize$(self, sel, name, NO);
932 // XXX: replace this with [SBStatusBarTimeView tile]
933 MSHook(void, SBStatusBarTimeView$drawRect$, SBStatusBarTimeView *self, SEL sel, CGRect rect) {
934 id &_time(MSHookIvar<id>(self, "_time"));
935 if (_time != nil && [_time class] != [WBTimeLabel class])
936 object_setInstanceVariable(self, "_time", reinterpret_cast<void *>([[WBTimeLabel alloc] initWithTime:[_time autorelease] view:self]));
937 return _SBStatusBarTimeView$drawRect$(self, sel, rect);
940 @interface UIView (WinterBoard)
941 - (bool) wb$isWBImageView;
944 @implementation UIView (WinterBoard)
946 - (bool) wb$isWBImageView {
952 @interface WBImageView : UIImageView {
955 - (bool) wb$isWBImageView;
956 - (void) wb$updateFrame;
959 @implementation WBImageView
961 - (bool) wb$isWBImageView {
965 - (void) wb$updateFrame {
966 CGRect frame([self frame]);
969 for (UIView *view(self); ; ) {
970 view = [view superview];
973 frame.origin.y -= [view frame].origin.y;
976 [self setFrame:frame];
981 MSHook(void, SBIconList$setFrame$, SBIconList *self, SEL sel, CGRect frame) {
982 NSArray *subviews([self subviews]);
983 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
984 if (view != nil && [view wb$isWBImageView])
985 [view wb$updateFrame];
986 _SBIconList$setFrame$(self, sel, frame);
989 MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *self, SEL sel) {
990 SBIconModel *&_iconModel(MSHookIvar<SBIconModel *>(self, "_iconModel"));
991 NSArray *lists([_iconModel iconLists]);
993 for (unsigned i(0), e([lists count]); i != e; ++i)
994 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Page%u.png", i]])) {
995 SBIconList *list([lists objectAtIndex:i]);
996 NSArray *subviews([list subviews]);
998 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
999 if (view == nil || ![view wb$isWBImageView]) {
1000 view = [[[WBImageView alloc] init] autorelease];
1001 [list insertSubview:view atIndex:0];
1004 UIImage *image([UIImage imageWithContentsOfFile:path]);
1005 [view setImage:image];
1006 [view wb$updateFrame];
1009 return _SBIconController$noteNumberOfIconListsChanged(self, sel);
1012 MSHook(id, SBIconLabel$initWithSize$label$, SBIconLabel *self, SEL sel, CGSize size, NSString *label) {
1013 self = _SBIconLabel$initWithSize$label$(self, sel, size, label);
1015 [self setClipsToBounds:NO];
1019 MSHook(void, SBIconLabel$setInDock$, SBIconLabel *self, SEL sel, BOOL docked) {
1020 id &_label(MSHookIvar<id>(self, "_label"));
1021 if (![Info_ boolForKey:@"UndockedIconLabels"])
1023 if (_label != nil && [_label respondsToSelector:@selector(setInDock:)])
1024 [_label setInDock:docked];
1025 return _SBIconLabel$setInDock$(self, sel, docked);
1028 MSHook(NSString *, NSBundle$localizedStringForKey$value$table$, NSBundle *self, SEL sel, NSString *key, NSString *value, NSString *table) {
1029 NSString *identifier = [self bundleIdentifier];
1030 NSLocale *locale = [NSLocale currentLocale];
1031 NSString *language = [locale objectForKey:NSLocaleLanguageCode];
1033 NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language);
1034 NSString *file = table == nil ? @"Localizable" : table;
1035 NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file];
1036 NSDictionary *strings;
1037 if ((strings = [Strings_ objectForKey:name]) != nil) {
1038 if (static_cast<id>(strings) != [NSNull null]) strings:
1039 if (NSString *value = [strings objectForKey:key])
1041 } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
1044 if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
1045 [Strings_ setObject:[strings autorelease] forKey:name];
1049 [Strings_ setObject:[NSNull null] forKey:name];
1050 return _NSBundle$localizedStringForKey$value$table$(self, sel, key, value, table);
1053 @class WebCoreFrameBridge;
1054 MSHook(CGSize, WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$, WebCoreFrameBridge *self, SEL sel, id node, float width) {
1057 void **core(reinterpret_cast<void **>([node _node]));
1058 if (core == NULL || core[6] == NULL)
1060 return _WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(self, sel, node, width);
1063 MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
1064 CGRect bounds = [self bounds];
1066 static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
1069 Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
1070 docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
1072 NSString *label(MSHookIvar<NSString *>(self, "_label"));
1074 NSString *style = [NSString stringWithFormat:@""
1075 "font-family: Helvetica; "
1076 "font-weight: bold; "
1079 "", docked ? @"white" : @"#b3b3b3"];
1082 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
1084 bool ellipsis(false);
1085 float max = 75, width;
1087 width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
1090 size_t length([label length]);
1091 float spacing((width - max) / (length - 1));
1093 if (spacing > 1.25) {
1095 label = [label substringToIndex:(length - 1)];
1099 style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
1103 label = [label stringByAppendingString:@"..."];
1105 if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
1106 style = [style stringByAppendingString:custom];
1108 CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];
1109 [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
1112 MSHook(void, mSMSMessageTranscriptController$loadView, mSMSMessageTranscriptController *self, SEL sel) {
1113 _mSMSMessageTranscriptController$loadView(self, sel);
1115 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
1116 if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
1117 [image autorelease];
1118 UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
1119 UIView *parent([_transcriptLayer superview]);
1120 UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]);
1121 [parent insertSubview:background belowSubview:_transcriptLayer];
1122 [_transcriptLayer setBackgroundColor:[UIColor clearColor]];
1126 MSHook(UIImage *, _UIImageWithName, NSString *name) {
1127 int id(_UISharedImageNameGetIdentifier(name));
1129 NSLog(@"WB:Debug: _UIImageWithName(\"%@\", %d)", name, id);
1132 return _UIImageAtPath(name, _UIKitBundle());
1134 NSNumber *key([NSNumber numberWithInt:id]);
1135 UIImage *image = [UIImages_ objectForKey:key];
1137 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
1138 if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {
1139 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
1141 [image autorelease];
1144 image = _UISharedImageWithIdentifier(id);
1145 [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1150 MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
1151 NSString *key = [NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name];
1152 UIImage *image = [PathImages_ objectForKey:key];
1154 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
1156 NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);
1157 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {
1158 image = [[UIImage alloc] initWithContentsOfFile:path];
1160 [image autorelease];
1163 image = __UIImageWithNameInDomain(name, domain);
1164 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1168 MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
1169 if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
1170 name = [font UTF8String];
1171 return _GSFontCreateWithName(name, traits, size);
1174 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
1175 #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
1177 bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
1179 MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
1180 bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
1182 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);
1185 NSString *path = [NSString stringWithUTF8String:a1];
1186 if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
1187 NSString *file = [path substringFromIndex:31];
1188 for (NSString *theme in themes_) {
1189 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
1190 if ([Manager_ fileExistsAtPath:path]) {
1191 strcpy(a1, [path UTF8String]);
1200 static void ChangeWallpaper(
1201 CFNotificationCenterRef center,
1205 CFDictionaryRef info
1208 NSLog(@"WB:Debug:ChangeWallpaper!");
1211 if (WallpaperFile_ != nil) {
1212 image = [[UIImage alloc] initWithContentsOfFile:WallpaperFile_];
1214 image = [image autorelease];
1217 if (WallpaperImage_ != nil)
1218 [WallpaperImage_ setImage:image];
1219 if (WallpaperPage_ != nil)
1220 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
1224 #define WBRename(name, sel, imp) \
1225 _ ## name ## $ ## imp = MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp)
1227 extern "C" void WBInitialize() {
1228 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1230 NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);
1232 NSLog(@"WB:Notice: WinterBoard");
1235 memset(nl, 0, sizeof(nl));
1237 nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName";
1238 nl[1].n_un.n_name = (char *) "__UIImageAtPath";
1239 nl[2].n_un.n_name = (char *) "__UIImageRefAtPath";
1240 nl[3].n_un.n_name = (char *) "__UIImageWithNameInDomain";
1241 nl[4].n_un.n_name = (char *) "__UIKitBundle";
1242 nl[5].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";
1243 nl[6].n_un.n_name = (char *) "__UISharedImageWithIdentifier";
1247 _UIApplicationImageWithName = (UIImage *(*)(NSString *)) nl[0].n_value;
1248 _UIImageAtPath = (UIImage *(*)(NSString *, NSBundle *)) nl[1].n_value;
1249 _UIImageRefAtPath = (CGImageRef (*)(NSString *, bool, UIImageOrientation *)) nl[2].n_value;
1250 _UIImageWithNameInDomain = (UIImage *(*)(NSString *, NSString *)) nl[3].n_value;
1251 _UIKitBundle = (NSBundle *(*)()) nl[4].n_value;
1252 _UISharedImageNameGetIdentifier = (int (*)(NSString *)) nl[5].n_value;
1253 _UISharedImageWithIdentifier = (UIImage *(*)(int)) nl[6].n_value;
1255 MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
1256 MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath);
1257 MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
1258 MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
1260 MSHookFunction(&GSFontCreateWithName, &$GSFontCreateWithName, &_GSFontCreateWithName);
1262 if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {
1264 memset(nl, 0, sizeof(nl));
1265 nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb";
1266 nlist(AudioToolbox, nl);
1267 _Z24GetFileNameForThisActionmPcRb = (bool (*)(unsigned long, char *, bool &)) nl[0].n_value;
1268 MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &__Z24GetFileNameForThisActionmPcRb);
1271 $NSBundle = objc_getClass("NSBundle");
1273 _NSBundle$localizedStringForKey$value$table$ = MSHookMessage($NSBundle, @selector(localizedStringForKey:value:table:), &$NSBundle$localizedStringForKey$value$table$);
1274 _NSBundle$pathForResource$ofType$ = MSHookMessage($NSBundle, @selector(pathForResource:ofType:), &$NSBundle$pathForResource$ofType$);
1276 $UIImage = objc_getClass("UIImage");
1277 $UINavigationBar = objc_getClass("UINavigationBar");
1278 $UIToolbar = objc_getClass("UIToolbar");
1280 _UIImage$defaultDesktopImage = MSHookMessage(object_getClass($UIImage), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage);
1282 //WBRename("UINavigationBar", @selector(initWithCoder:", (IMP) &UINavigationBar$initWithCoder$);
1283 //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
1285 _UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$);
1286 _UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$);
1288 Manager_ = [[NSFileManager defaultManager] retain];
1289 UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1290 PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1291 Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0];
1292 Bundles_ = [[NSMutableDictionary alloc] initWithCapacity:2];
1293 Themed_ = [[NSMutableDictionary alloc] initWithCapacity:128];
1295 themes_ = [[NSMutableArray alloc] initWithCapacity:8];
1297 if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
1298 [settings autorelease];
1300 if (NSNumber *debug = [settings objectForKey:@"Debug"])
1301 Debug_ = [debug boolValue];
1303 NSArray *themes = [settings objectForKey:@"Themes"];
1305 if (NSString *theme = [settings objectForKey:@"Theme"])
1306 themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
1308 [NSNumber numberWithBool:true], @"Active",
1311 for (NSDictionary *theme in themes) {
1312 NSNumber *active = [theme objectForKey:@"Active"];
1313 if (![active boolValue])
1316 NSString *name = [theme objectForKey:@"Name"];
1320 NSString *theme = nil;
1322 #define testForTheme(format...) \
1323 if (theme == nil) { \
1324 NSString *path = [NSString stringWithFormat:format]; \
1325 if ([Manager_ fileExistsAtPath:path]) { \
1326 [themes_ addObject:path]; \
1331 testForTheme(@"/Library/Themes/%@.theme", name)
1332 testForTheme(@"/Library/Themes/%@", name)
1333 testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)
1337 Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
1339 for (NSString *theme in themes_)
1340 if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]]) {
1342 for (NSString *key in [info allKeys])
1343 if ([Info_ objectForKey:key] == nil)
1344 [Info_ setObject:[info objectForKey:key] forKey:key];
1347 if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
1348 Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
1349 _mSMSMessageTranscriptController$loadView = MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), &$mSMSMessageTranscriptController$loadView);
1350 } else if ([identifier isEqualToString:@"com.apple.springboard"]) {
1351 CFNotificationCenterAddObserver(
1352 CFNotificationCenterGetDarwinNotifyCenter(),
1353 NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0
1356 NSBundle *MediaPlayer = [NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"];
1357 if (MediaPlayer != nil)
1360 $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
1361 $MPVideoView = objc_getClass("MPVideoView");
1362 $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
1364 $SBApplication = objc_getClass("SBApplication");
1365 $SBApplicationIcon = objc_getClass("SBApplicationIcon");
1366 $SBAwayView = objc_getClass("SBAwayView");
1367 $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
1368 $SBButtonBar = objc_getClass("SBButtonBar");
1369 $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
1370 $SBIcon = objc_getClass("SBIcon");
1371 $SBIconBadge = objc_getClass("SBIconBadge");
1372 $SBIconController = objc_getClass("SBIconController");
1373 $SBIconLabel = objc_getClass("SBIconLabel");
1374 $SBIconList = objc_getClass("SBIconList");
1375 $SBIconModel = objc_getClass("SBIconModel");
1376 //$SBImageCache = objc_getClass("SBImageCache");
1377 $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
1378 $SBStatusBarController = objc_getClass("SBStatusBarController");
1379 $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
1380 $SBStatusBarTimeView = objc_getClass("SBStatusBarTimeView");
1381 $SBUIController = objc_getClass("SBUIController");
1382 $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon");
1384 WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$);
1386 WBRename(SBApplication, pathForIcon, pathForIcon);
1387 WBRename(SBApplicationIcon, icon, icon);
1388 WBRename(SBBookmarkIcon, icon, icon);
1389 WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview);
1390 WBRename(SBCalendarIconContentsView, drawRect:, drawRect$);
1391 WBRename(SBIcon, setAlpha:, setAlpha$);
1392 WBRename(SBIconBadge, initWithBadge:, initWithBadge$);
1393 WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged);
1394 WBRename(SBUIController, init, init);
1395 WBRename(SBWidgetApplicationIcon, icon, icon);
1397 WBRename(SBIconLabel, drawRect:, drawRect$);
1398 WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
1399 WBRename(SBIconLabel, setInDock:, setInDock$);
1401 WBRename(SBIconList, setFrame:, setFrame$);
1403 WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
1404 WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
1406 //WBRename(SBImageCache, initWithName:forImageWidth:imageHeight:initialCapacity:, initWithName$forImageWidth$imageHeight$initialCapacity$);
1408 WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
1409 WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
1410 //WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
1411 //WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:animation:, setStatusBarMode$orientation$duration$animation$);
1412 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$);
1413 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:startTime:, setStatusBarMode$orientation$duration$fenceID$animation$startTime$);
1414 WBRename(SBStatusBarOperatorNameView, operatorNameStyle, operatorNameStyle);
1415 WBRename(SBStatusBarOperatorNameView, setOperatorName:fullSize:, setOperatorName$fullSize$);
1416 WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
1418 English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
1419 Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
1422 Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
1424 if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
1425 [Info_ setObject:[NSNumber numberWithBool:(
1426 $getTheme$(Wallpapers_) == nil ||
1427 [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
1428 [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
1429 )] forKey:@"UndockedIconLabels"];
1432 NSLog(@"WB:Debug:Info = %@", [Info_ description]);