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.
38 #define _trace() NSLog(@"WB:_trace(%u)", __LINE__);
41 #import <CoreFoundation/CoreFoundation.h>
42 #import <Foundation/Foundation.h>
43 #import <CoreGraphics/CoreGraphics.h>
45 #import <Celestial/AVController.h>
46 #import <Celestial/AVItem.h>
47 #import <Celestial/AVQueue.h>
49 #include <substrate.h>
51 #import <UIKit/UIKit.h>
53 #import <SpringBoard/SBApplication.h>
54 #import <SpringBoard/SBApplicationIcon.h>
55 #import <SpringBoard/SBAppWindow.h>
56 #import <SpringBoard/SBBookmarkIcon.h>
57 #import <SpringBoard/SBButtonBar.h>
58 #import <SpringBoard/SBCalendarIconContentsView.h>
59 #import <SpringBoard/SBContentLayer.h>
60 #import <SpringBoard/SBIconController.h>
61 #import <SpringBoard/SBIconLabel.h>
62 #import <SpringBoard/SBIconModel.h>
63 #import <SpringBoard/SBSlidingAlertDisplay.h>
64 #import <SpringBoard/SBStatusBarContentsView.h>
65 #import <SpringBoard/SBStatusBarController.h>
66 #import <SpringBoard/SBStatusBarOperatorNameView.h>
67 #import <SpringBoard/SBStatusBarTimeView.h>
68 #import <SpringBoard/SBUIController.h>
69 #import <SpringBoard/SBWidgetApplicationIcon.h>
71 #import <MobileSMS/mSMSMessageTranscriptController.h>
73 #import <MediaPlayer/MPMoviePlayerController.h>
74 #import <MediaPlayer/MPVideoView.h>
75 #import <MediaPlayer/MPVideoView-PlaybackControl.h>
77 #import <CoreGraphics/CGGeometry.h>
79 extern "C" void __clear_cache (char *beg, char *end);
85 Class $MPMoviePlayerController;
87 Class $WebCoreFrameBridge;
92 Class $UINavigationBar;
96 Class $SBApplicationIcon;
97 Class $SBBookmarkIcon;
99 Class $SBCalendarIconContentsView;
100 Class $SBContentLayer;
102 Class $SBIconController;
105 Class $SBSlidingAlertDisplay;
106 Class $SBStatusBarContentsView;
107 Class $SBStatusBarController;
108 Class $SBStatusBarOperatorNameView;
109 Class $SBStatusBarTimeView;
110 Class $SBWidgetApplicationIcon;
112 @interface NSDictionary (WinterBoard)
113 - (UIColor *) colorForKey:(NSString *)key;
114 - (BOOL) boolForKey:(NSString *)key;
117 @implementation NSDictionary (WinterBoard)
119 - (UIColor *) colorForKey:(NSString *)key {
120 NSString *value = [self objectForKey:key];
127 - (BOOL) boolForKey:(NSString *)key {
128 if (NSString *value = [self objectForKey:key])
129 return [value boolValue];
136 bool Engineer_ = false;
138 static UIImage *(*_UIApplicationImageWithName)(NSString *name);
139 static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path);
140 static CGImageRef (*_UIImageRefAtPath)(NSString *name, bool cache, UIImageOrientation *orientation);
141 static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain);
142 static NSBundle *(*_UIKitBundle)();
143 static void (*_UISharedImageInitialize)(bool);
144 static int (*_UISharedImageNameGetIdentifier)(NSString *);
145 static UIImage *(*_UISharedImageWithIdentifier)(int);
147 static NSMutableDictionary *UIImages_;
148 static NSMutableDictionary *PathImages_;
149 static NSMutableDictionary *Cache_;
150 static NSMutableDictionary *Strings_;
151 static NSMutableDictionary *Themed_;
152 static NSMutableDictionary *Bundles_;
154 static NSFileManager *Manager_;
155 static NSDictionary *English_;
156 static NSMutableDictionary *Info_;
157 static NSMutableArray *themes_;
159 static NSString *$getTheme$(NSArray *files, bool parent = false) {
161 if (NSString *path = [Themed_ objectForKey:files])
162 return reinterpret_cast<id>(path) == [NSNull null] ? nil : path;
165 NSLog(@"WB:Debug: %@", [files description]);
169 for (NSString *theme in themes_)
170 for (NSString *file in files) {
171 path = [NSString stringWithFormat:@"%@/%@", theme, file];
172 if ([Manager_ fileExistsAtPath:path]) {
173 path = parent ? theme : path;
181 [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast<id>(path)) forKey:files];
185 static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui) {
186 NSString *identifier = [bundle bundleIdentifier];
187 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
189 if (identifier != nil)
190 [names addObject:[NSString stringWithFormat:@"Bundles/%@/%@", identifier, file]];
191 if (NSString *folder = [[bundle bundlePath] lastPathComponent])
192 [names addObject:[NSString stringWithFormat:@"Folders/%@/%@", folder, file]];
194 [names addObject:[NSString stringWithFormat:@"UIImages/%@", file]];
196 #define remapResourceName(oldname, newname) \
197 else if ([file isEqualToString:oldname]) \
198 [names addObject:[NSString stringWithFormat:@"%@.png", newname]]; \
200 if (identifier == nil);
201 else if ([identifier isEqualToString:@"com.apple.calculator"])
202 [names addObject:[NSString stringWithFormat:@"Files/Applications/Calculator.app/%@", file]];
203 else if (![identifier isEqualToString:@"com.apple.springboard"]);
204 remapResourceName(@"FSO_BG.png", @"StatusBar")
205 remapResourceName(@"SBDockBG.png", @"Dock")
206 remapResourceName(@"SBWeatherCelsius.png", @"Icons/Weather")
208 if (NSString *path = $getTheme$(names))
213 static NSString *$pathForIcon$(SBApplication *self) {
214 NSString *identifier = [self bundleIdentifier];
215 NSString *path = [self path];
216 NSString *folder = [path lastPathComponent];
217 NSString *dname = [self displayName];
218 NSString *didentifier = [self displayIdentifier];
221 NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier);
223 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
225 if (identifier != nil)
226 [names addObject:[NSString stringWithFormat:@"Bundles/%@/icon.png", identifier]];
228 [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]];
230 #define testForIcon(Name) \
231 if (NSString *name = Name) \
232 [names addObject:[NSString stringWithFormat:@"Icons/%@.png", name]];
234 testForIcon(identifier);
237 if (didentifier != nil) {
238 testForIcon([English_ objectForKey:didentifier]);
240 NSArray *parts = [didentifier componentsSeparatedByString:@"-"];
241 if ([parts count] != 1)
242 if (NSDictionary *english = [[[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingString:@"/English.lproj/UIRoleDisplayNames.strings"]] autorelease])
243 testForIcon([english objectForKey:[parts lastObject]]);
246 if (NSString *path = $getTheme$(names))
251 @interface NSBundle (WinterBoard)
252 + (NSBundle *) wb$bundleWithFile:(NSString *)path;
255 @implementation NSBundle (WinterBoard)
257 + (NSBundle *) wb$bundleWithFile:(NSString *)path {
258 path = [path stringByDeletingLastPathComponent];
259 if (path == nil || [path length] == 0 || [path isEqualToString:@"/"])
262 NSBundle *bundle([Bundles_ objectForKey:path]);
263 if (reinterpret_cast<id>(bundle) == [NSNull null])
265 else if (bundle == nil) {
266 if ([Manager_ fileExistsAtPath:[path stringByAppendingPathComponent:@"Info.plist"]])
267 bundle = [NSBundle bundleWithPath:path];
269 bundle = [NSBundle wb$bundleWithFile:path];
271 NSLog(@"WB:Debug:PathBundle(%@, %@)", path, bundle);
272 [Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast<id>(bundle)) forKey:path];
280 @interface NSString (WinterBoard)
281 - (NSString *) wb$themedPath;
284 @implementation NSString (WinterBoard)
286 - (NSString *) wb$themedPath {
288 NSLog(@"WB:Debug:Bypass(\"%@\")", self);
290 if (NSBundle *bundle = [NSBundle wb$bundleWithFile:self]) {
291 NSString *file([self stringByResolvingSymlinksInPath]);
292 NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]);
293 if ([file hasPrefix:prefix]) {
294 NSUInteger length([prefix length]);
295 if (length != [file length])
296 if (NSString *path = $pathForFile$inBundle$([file substringFromIndex:(length + 1)], bundle, false))
306 MSHook(void, SBIconModel$cacheImageForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
307 _SBIconModel$cacheImageForIcon$(self, sel, icon);
308 NSString *key([icon displayIdentifier]);
310 if (UIImage *image = [icon icon]) {
311 CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB());
312 CGRect rect = {CGPointMake(1, 1), [image size]};
313 CGSize size = {rect.size.width + 2, rect.size.height + 2};
315 CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
316 CGColorSpaceRelease(space);
318 CGContextDrawImage(context, rect, [image CGImage]);
319 CGImageRef ref(CGBitmapContextCreateImage(context));
320 CGContextRelease(context);
322 UIImage *image([UIImage imageWithCGImage:ref]);
325 [Cache_ setObject:image forKey:key];
329 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
330 NSString *key([icon displayIdentifier]);
331 if (UIImage *image = [Cache_ objectForKey:key])
334 return _SBIconModel$getCachedImagedForIcon$(self, sel, icon);
337 MSHook(UIImage *, SBApplicationIcon$icon, SBApplicationIcon *self, SEL sel) {
338 if (![Info_ boolForKey:@"ComposeStoreIcons"])
339 if (NSString *path = $pathForIcon$([self application]))
340 return [UIImage imageWithContentsOfFile:path];
341 return _SBApplicationIcon$icon(self, sel);
344 MSHook(UIImage *, SBWidgetApplicationIcon$icon, SBWidgetApplicationIcon *self, SEL sel) {
346 NSLog(@"WB:Debug:Widget(%@:%@)", [self displayIdentifier], [self displayName]);
347 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
348 return [UIImage imageWithContentsOfFile:path];
349 return _SBWidgetApplicationIcon$icon(self, sel);
352 MSHook(UIImage *, SBBookmarkIcon$icon, SBBookmarkIcon *self, SEL sel) {
354 NSLog(@"WB:Debug:Bookmark(%@:%@)", [self displayIdentifier], [self displayName]);
355 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
356 return [UIImage imageWithContentsOfFile:path];
357 return _SBBookmarkIcon$icon(self, sel);
360 MSHook(NSString *, SBApplication$pathForIcon, SBApplication *self, SEL sel) {
361 if (NSString *path = $pathForIcon$(self))
363 return _SBApplication$pathForIcon(self, sel);
366 static UIImage *CachedImageAtPath(NSString *path) {
367 path = [path stringByResolvingSymlinksInPath];
368 UIImage *image = [PathImages_ objectForKey:path];
370 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
371 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
373 image = [image autorelease];
374 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:path];
378 MSHook(CGImageRef, _UIImageRefAtPath, NSString *name, bool cache, UIImageOrientation *orientation) {
380 NSLog(@"WB:Debug: _UIImageRefAtPath(\"%@\", %s)", name, cache ? "true" : "false");
381 return __UIImageRefAtPath([name wb$themedPath], cache, orientation);
384 /*MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) {
386 return __UIImageAtPath(name, nil);
388 NSString *key = [NSString stringWithFormat:@"B:%@/%@", [bundle bundleIdentifier], name];
389 UIImage *image = [PathImages_ objectForKey:key];
391 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
393 NSLog(@"WB:Debug: _UIImageAtPath(\"%@\", %@)", name, bundle);
394 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
395 image = CachedImageAtPath(path);
397 image = __UIImageAtPath(name, bundle);
398 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
403 MSHook(UIImage *, _UIApplicationImageWithName, NSString *name) {
404 NSBundle *bundle = [NSBundle mainBundle];
406 NSLog(@"WB:Debug: _UIApplicationImageWithName(\"%@\", %@)", name, bundle);
407 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
408 return CachedImageAtPath(path);
409 return __UIApplicationImageWithName(name);
412 #define WBDelegate(delegate) \
413 - (NSMethodSignature*) methodSignatureForSelector:(SEL)sel { \
415 NSLog(@"WB:MS:%s:(%s)", class_getName([self class]), sel_getName(sel)); \
416 if (NSMethodSignature *sig = [delegate methodSignatureForSelector:sel]) \
418 NSLog(@"WB:Error: [%s methodSignatureForSelector:(%s)]", class_getName([self class]), sel_getName(sel)); \
422 - (void) forwardInvocation:(NSInvocation*)inv { \
423 SEL sel = [inv selector]; \
424 if ([delegate respondsToSelector:sel]) \
425 [inv invokeWithTarget:delegate]; \
427 NSLog(@"WB:Error: [%s forwardInvocation:(%s)]", class_getName([self class]), sel_getName(sel)); \
430 MSHook(NSString *, NSBundle$pathForResource$ofType$, NSBundle *self, SEL sel, NSString *resource, NSString *type) {
431 NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
433 NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
434 if (NSString *path = $pathForFile$inBundle$(file, self, false))
436 return _NSBundle$pathForResource$ofType$(self, sel, resource, type);
439 void $setBarStyle$_(NSString *name, int &style) {
441 NSLog(@"WB:Debug:%@Style:%d", name, style);
442 NSNumber *number = nil;
444 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style-%d", name, style]];
446 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style", name]];
448 style = [number intValue];
450 NSLog(@"WB:Debug:%@Style=%d", name, style);
454 MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *self, SEL sel, CGRect rect) {
455 NSBundle *bundle([NSBundle mainBundle]);
457 CFLocaleRef locale(CFLocaleCopyCurrent());
458 CFDateFormatterRef formatter(CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle));
461 CFDateRef now(CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()));
463 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NUMBER_FORMAT" value:@"" table:@"SpringBoard"]);
464 CFStringRef date(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
465 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NAME_FORMAT" value:@"" table:@"SpringBoard"]);
466 CFStringRef day(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
470 CFRelease(formatter);
472 NSString *datestyle(@""
473 "font-family: Helvetica; "
474 "font-weight: bold; "
480 NSString *daystyle(@""
481 "font-family: Helvetica; "
482 "font-weight: bold; "
485 "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px; "
488 if (NSString *style = [Info_ objectForKey:@"CalendarIconDateStyle"])
489 datestyle = [datestyle stringByAppendingString:style];
490 if (NSString *style = [Info_ objectForKey:@"CalendarIconDayStyle"])
491 daystyle = [daystyle stringByAppendingString:style];
493 float width([self bounds].size.width);
495 CGSize datesize = [(NSString *)date sizeWithStyle:datestyle forWidth:(width + leeway)];
496 CGSize daysize = [(NSString *)day sizeWithStyle:daystyle forWidth:(width + leeway)];
498 [(NSString *)date drawAtPoint:CGPointMake(
499 (width + 1 - datesize.width) / 2, (71 - datesize.height) / 2
500 ) withStyle:datestyle];
502 [(NSString *)day drawAtPoint:CGPointMake(
503 (width + 1 - daysize.width) / 2, (16 - daysize.height) / 2
504 ) withStyle:daystyle];
510 /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) {
513 if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"])
514 style = [number intValue];
516 if (UIColor *color = [Info_ colorForKey:@"NavigationBarTint"])
519 return [self wb$initWithFrame:frame withBarStyle:style withTintColor:tint];
522 /*static id UINavigationBar$initWithCoder$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame, NSCoder *coder) {
523 self = [self wb$initWithCoder:coder];
526 UINavigationBar$setBarStyle$_(self);
530 static id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame) {
531 self = [self wb$initWithFrame:frame];
534 UINavigationBar$setBarStyle$_(self);
538 MSHook(void, UIToolbar$setBarStyle$, UIToolbar *self, SEL sel, int style) {
539 $setBarStyle$_(@"Toolbar", style);
540 return _UIToolbar$setBarStyle$(self, sel, style);
543 MSHook(void, UINavigationBar$setBarStyle$, UINavigationBar *self, SEL sel, int style) {
544 $setBarStyle$_(@"NavigationBar", style);
545 return _UINavigationBar$setBarStyle$(self, sel, style);
548 MSHook(void, SBButtonBar$didMoveToSuperview, UIView *self, SEL sel) {
549 [[self superview] setBackgroundColor:[UIColor clearColor]];
550 _SBButtonBar$didMoveToSuperview(self, sel);
553 MSHook(void, SBStatusBarContentsView$didMoveToSuperview, UIView *self, SEL sel) {
554 [[self superview] setBackgroundColor:[UIColor clearColor]];
555 _SBStatusBarContentsView$didMoveToSuperview(self, sel);
558 MSHook(UIImage *, UIImage$defaultDesktopImage, UIImage *self, SEL sel) {
560 NSLog(@"WB:Debug:DefaultDesktopImage");
561 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"LockBackground.png", @"LockBackground.jpg", nil]))
562 return [UIImage imageWithContentsOfFile:path];
563 return _UIImage$defaultDesktopImage(self, sel);
566 static NSArray *Wallpapers_;
567 static NSString *WallpaperFile_;
568 static UIImageView *WallpaperImage_;
569 static UIWebDocumentView *WallpaperPage_;
570 static NSURL *WallpaperURL_;
572 #define _release(object) \
573 do if (object != nil) { \
578 MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize size) {
579 self = _SBContentLayer$initWithSize$(self, sel, size);
583 _release(WallpaperFile_);
584 _release(WallpaperImage_);
585 _release(WallpaperPage_);
586 _release(WallpaperURL_);
588 if (NSString *theme = $getTheme$(Wallpapers_, true)) {
589 NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"];
590 if ([Manager_ fileExistsAtPath:mp4]) {
594 static AVController *controller_(nil);
595 if (controller_ == nil) {
596 AVQueue *queue([AVQueue avQueue]);
597 controller_ = [[AVController avControllerWithQueue:queue error:&error] retain];
600 AVQueue *queue([controller_ queue]);
602 UIView *video([[[UIView alloc] initWithFrame:[self bounds]] autorelease]);
603 [controller_ setLayer:[video _layer]];
605 AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]);
606 [queue appendItem:item error:&error];
608 [controller_ play:&error];
609 #elif UseMPMoviePlayerController
610 NSURL *url([NSURL fileURLWithPath:mp4]);
611 MPMoviePlayerController *controller = [[MPMoviePlayerController alloc] initWithContentURL:url];
612 controller.movieControlMode = MPMovieControlModeHidden;
615 MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[self bounds]] autorelease];
616 [video setMovieWithPath:mp4];
617 [video setRepeatMode:1];
618 [video setRepeatGap:-1];
619 [video playFromBeginning];;
622 [self addSubview:video];
625 NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"];
626 NSString *jpg = [theme stringByAppendingPathComponent:@"Wallpaper.jpg"];
629 if ([Manager_ fileExistsAtPath:png])
631 else if ([Manager_ fileExistsAtPath:jpg])
637 image = [[UIImage alloc] initWithContentsOfFile:path];
639 image = [image autorelease];
643 WallpaperFile_ = [path retain];
644 WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
645 [self addSubview:WallpaperImage_];
648 NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"];
649 if ([Manager_ fileExistsAtPath:html]) {
650 CGRect bounds = [self bounds];
652 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
653 [view setAutoresizes:true];
655 WallpaperPage_ = [view retain];
656 WallpaperURL_ = [[NSURL fileURLWithPath:html] retain];
658 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
660 [[view webView] setDrawsBackground:false];
661 [view setBackgroundColor:[UIColor clearColor]];
663 [self addSubview:view];
667 for (size_t i(0), e([themes_ count]); i != e; ++i) {
668 NSString *theme = [themes_ objectAtIndex:(e - i - 1)];
669 NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"];
670 if ([Manager_ fileExistsAtPath:html]) {
671 CGRect bounds = [self bounds];
673 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
674 [view setAutoresizes:true];
676 NSURL *url = [NSURL fileURLWithPath:html];
677 [view loadRequest:[NSURLRequest requestWithURL:url]];
679 [[view webView] setDrawsBackground:false];
680 [view setBackgroundColor:[UIColor clearColor]];
682 [self addSubview:view];
689 MSHook(void, SBSlidingAlertDisplay$updateDesktopImage$, SBSlidingAlertDisplay *self, SEL sel, UIImage *image) {
690 NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]);
691 UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
693 if (path != nil && _backgroundView != nil)
696 _SBSlidingAlertDisplay$updateDesktopImage$(self, sel, image);
699 CGRect bounds = [self bounds];
701 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
702 [view setAutoresizes:true];
704 if (WallpaperPage_ != nil)
705 [WallpaperPage_ release];
706 WallpaperPage_ = [view retain];
708 if (WallpaperURL_ != nil)
709 [WallpaperURL_ release];
710 WallpaperURL_ = [[NSURL fileURLWithPath:path] retain];
712 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
714 [[view webView] setDrawsBackground:false];
715 [view setBackgroundColor:[UIColor clearColor]];
717 [self insertSubview:view aboveSubview:_backgroundView];
721 /*extern "C" CGColorRef CGGStateGetSystemColor(void *);
722 extern "C" CGColorRef CGGStateGetFillColor(void *);
723 extern "C" CGColorRef CGGStateGetStrokeColor(void *);
724 extern "C" NSString *UIStyleStringFromColor(CGColorRef);*/
726 /* WBTimeLabel {{{ */
727 @interface WBTimeLabel : NSProxy {
729 _transient SBStatusBarTimeView *view_;
732 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view;
736 @implementation WBTimeLabel
743 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view {
744 time_ = [time retain];
751 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
752 if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
753 BOOL &_mode(MSHookIvar<BOOL>(view_, "_mode"));;
755 [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
756 "font-family: Helvetica; "
757 "font-weight: bold; "
760 "%@", _mode ? @"white" : @"black", custom]];
765 return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
770 /* WBBadgeLabel {{{ */
771 @interface WBBadgeLabel : NSProxy {
775 - (id) initWithBadge:(NSString *)badge;
779 @implementation WBBadgeLabel
786 - (id) initWithBadge:(NSString *)badge {
787 badge_ = [badge retain];
793 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
794 if (NSString *custom = [Info_ objectForKey:@"BadgeStyle"]) {
795 [badge_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
796 "font-family: Helvetica; "
797 "font-weight: bold; "
805 return [badge_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
811 MSHook(id, SBIconBadge$initWithBadge$, SBIconBadge *self, SEL sel, NSString *badge) {
812 if ((self = _SBIconBadge$initWithBadge$(self, sel, badge)) != nil) {
813 id &_badge(MSHookIvar<id>(self, "_badge"));
815 if (id label = [[WBBadgeLabel alloc] initWithBadge:[_badge autorelease]])
820 MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int id, int animation) {
822 NSLog(@"WB:Debug:setStatusBarMode:%d", mode);
823 if (mode < 100) // 104:hidden 105:glowing
824 if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"])
825 mode = [number intValue];
826 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, id, animation);
829 MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) {
830 if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"])
831 mode = [number intValue];
832 return _SBStatusBarContentsView$initWithStatusBar$mode$(self, sel, bar, mode);
835 MSHook(NSString *, SBStatusBarOperatorNameView$operatorNameStyle, SBStatusBarOperatorNameView *self, SEL sel) {
836 NSString *style(_SBStatusBarOperatorNameView$operatorNameStyle(self, sel));
838 NSLog(@"operatorNameStyle= %@", style);
839 if (NSString *custom = [Info_ objectForKey:@"OperatorNameStyle"])
840 style = [NSString stringWithFormat:@"%@; %@", style, custom];
844 MSHook(void, SBStatusBarOperatorNameView$setOperatorName$fullSize$, SBStatusBarOperatorNameView *self, SEL sel, NSString *name, BOOL full) {
846 NSLog(@"setOperatorName:\"%@\" fullSize:%u", name, full);
847 return _SBStatusBarOperatorNameView$setOperatorName$fullSize$(self, sel, name, NO);
850 // XXX: replace this with [SBStatusBarTimeView tile]
851 MSHook(void, SBStatusBarTimeView$drawRect$, SBStatusBarTimeView *self, SEL sel, CGRect rect) {
852 id &_time(MSHookIvar<id>(self, "_time"));
853 if (_time != nil && [_time class] != [WBTimeLabel class])
854 object_setInstanceVariable(self, "_time", reinterpret_cast<void *>([[WBTimeLabel alloc] initWithTime:[_time autorelease] view:self]));
855 return _SBStatusBarTimeView$drawRect$(self, sel, rect);
858 @interface UIView (WinterBoard)
859 - (bool) wb$isImageView;
862 @implementation UIView (WinterBoard)
864 - (bool) wb$isImageView {
870 @interface UIImageView (WinterBoard)
871 - (bool) wb$isImageView;
874 @implementation UIImageView (WinterBoard)
876 - (bool) wb$isImageView {
882 MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *self, SEL sel) {
883 SBIconModel *&_iconModel(MSHookIvar<SBIconModel *>(self, "_iconModel"));
884 NSArray *lists([_iconModel iconLists]);
886 for (unsigned i(0), e([lists count]); i != e; ++i)
887 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Page%u.png", i]])) {
888 SBIconList *list([lists objectAtIndex:i]);
889 NSArray *subviews([list subviews]);
890 UIImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
891 if (view == nil || ![view wb$isImageView]) {
892 view = [[[UIImageView alloc] init] autorelease];
893 [list insertSubview:view atIndex:0];
895 UIImage *image([UIImage imageWithContentsOfFile:path]);
896 [view setImage:image];
899 return _SBIconController$noteNumberOfIconListsChanged(self, sel);
902 MSHook(id, SBIconLabel$initWithSize$label$, SBIconLabel *self, SEL sel, CGSize size, NSString *label) {
903 self = _SBIconLabel$initWithSize$label$(self, sel, size, label);
905 [self setClipsToBounds:NO];
909 MSHook(void, SBIconLabel$setInDock$, SBIconLabel *self, SEL sel, BOOL docked) {
910 id &_label(MSHookIvar<id>(self, "_label"));
911 if (![Info_ boolForKey:@"UndockedIconLabels"])
913 if (_label != nil && [_label respondsToSelector:@selector(setInDock:)])
914 [_label setInDock:docked];
915 return _SBIconLabel$setInDock$(self, sel, docked);
918 MSHook(NSString *, NSBundle$localizedStringForKey$value$table$, NSBundle *self, SEL sel, NSString *key, NSString *value, NSString *table) {
919 NSString *identifier = [self bundleIdentifier];
920 NSLocale *locale = [NSLocale currentLocale];
921 NSString *language = [locale objectForKey:NSLocaleLanguageCode];
923 NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language);
924 NSString *file = table == nil ? @"Localizable" : table;
925 NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file];
926 NSDictionary *strings;
927 if ((strings = [Strings_ objectForKey:name]) != nil) {
928 if (static_cast<id>(strings) != [NSNull null]) strings:
929 if (NSString *value = [strings objectForKey:key])
931 } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
934 if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
935 [Strings_ setObject:[strings autorelease] forKey:name];
939 [Strings_ setObject:[NSNull null] forKey:name];
940 return _NSBundle$localizedStringForKey$value$table$(self, sel, key, value, table);
943 @class WebCoreFrameBridge;
944 MSHook(CGSize, WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$, WebCoreFrameBridge *self, SEL sel, id node, float width) {
947 void **core(reinterpret_cast<void **>([node _node]));
948 if (core == NULL || core[6] == NULL)
950 return _WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(self, sel, node, width);
953 MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
954 CGRect bounds = [self bounds];
956 static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
959 Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
960 docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
962 NSString *label(MSHookIvar<NSString *>(self, "_label"));
964 NSString *style = [NSString stringWithFormat:@""
965 "font-family: Helvetica; "
966 "font-weight: bold; "
969 "", docked ? @"white" : @"#b3b3b3"];
972 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
974 bool ellipsis(false);
975 float max = 75, width;
977 width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
980 size_t length([label length]);
981 float spacing((width - max) / (length - 1));
983 if (spacing > 1.25) {
985 label = [label substringToIndex:(length - 1)];
989 style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
993 label = [label stringByAppendingString:@"..."];
995 if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
996 style = [style stringByAppendingString:custom];
998 CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];
999 [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
1002 MSHook(void, mSMSMessageTranscriptController$loadView, mSMSMessageTranscriptController *self, SEL sel) {
1003 _mSMSMessageTranscriptController$loadView(self, sel);
1005 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
1006 if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
1007 [image autorelease];
1008 UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
1009 UIView *parent([_transcriptLayer superview]);
1010 UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]);
1011 [parent insertSubview:background belowSubview:_transcriptLayer];
1012 [_transcriptLayer setBackgroundColor:[UIColor clearColor]];
1016 MSHook(UIImage *, _UIImageWithName, NSString *name) {
1017 int id(_UISharedImageNameGetIdentifier(name));
1019 NSLog(@"WB:Debug: _UIImageWithName(\"%@\", %d)", name, id);
1022 return _UIImageAtPath(name, _UIKitBundle());
1024 NSNumber *key([NSNumber numberWithInt:id]);
1025 UIImage *image = [UIImages_ objectForKey:key];
1027 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
1028 if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {
1029 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
1031 [image autorelease];
1034 image = _UISharedImageWithIdentifier(id);
1035 [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1040 MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
1041 NSString *key = [NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name];
1042 UIImage *image = [PathImages_ objectForKey:key];
1044 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
1046 NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);
1047 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {
1048 image = [[UIImage alloc] initWithContentsOfFile:path];
1050 [image autorelease];
1053 image = __UIImageWithNameInDomain(name, domain);
1054 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1058 MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
1059 if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
1060 name = [font UTF8String];
1061 return _GSFontCreateWithName(name, traits, size);
1064 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
1065 #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
1067 bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
1069 MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
1070 bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
1072 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);
1075 NSString *path = [NSString stringWithUTF8String:a1];
1076 if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
1077 NSString *file = [path substringFromIndex:31];
1079 for (NSString *theme in themes_) {
1080 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
1081 if ([Manager_ fileExistsAtPath:path]) {
1082 strcpy(a1, [path UTF8String]);
1091 static void ChangeWallpaper(
1092 CFNotificationCenterRef center,
1096 CFDictionaryRef info
1099 NSLog(@"WB:Debug:ChangeWallpaper!");
1102 if (WallpaperFile_ != nil) {
1103 image = [[UIImage alloc] initWithContentsOfFile:WallpaperFile_];
1105 image = [image autorelease];
1108 if (WallpaperImage_ != nil)
1109 [WallpaperImage_ setImage:image];
1110 if (WallpaperPage_ != nil)
1111 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
1115 #define WBRename(name, sel, imp) \
1116 _ ## name ## $ ## imp = MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp)
1118 extern "C" void WBInitialize() {
1119 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1121 NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);
1123 NSLog(@"WB:Notice: WinterBoard");
1126 memset(nl, 0, sizeof(nl));
1128 nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName";
1129 nl[1].n_un.n_name = (char *) "__UIImageAtPath";
1130 nl[2].n_un.n_name = (char *) "__UIImageRefAtPath";
1131 nl[3].n_un.n_name = (char *) "__UIImageWithNameInDomain";
1132 nl[4].n_un.n_name = (char *) "__UIKitBundle";
1133 nl[5].n_un.n_name = (char *) "__UISharedImageInitialize";
1134 nl[6].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";
1135 nl[7].n_un.n_name = (char *) "__UISharedImageWithIdentifier";
1139 _UIApplicationImageWithName = (UIImage *(*)(NSString *)) nl[0].n_value;
1140 _UIImageAtPath = (UIImage *(*)(NSString *, NSBundle *)) nl[1].n_value;
1141 _UIImageRefAtPath = (CGImageRef (*)(NSString *, bool, UIImageOrientation *)) nl[2].n_value;
1142 _UIImageWithNameInDomain = (UIImage *(*)(NSString *, NSString *)) nl[3].n_value;
1143 _UIKitBundle = (NSBundle *(*)()) nl[4].n_value;
1144 _UISharedImageInitialize = (void (*)(bool)) nl[5].n_value;
1145 _UISharedImageNameGetIdentifier = (int (*)(NSString *)) nl[6].n_value;
1146 _UISharedImageWithIdentifier = (UIImage *(*)(int)) nl[7].n_value;
1148 MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
1149 MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath);
1150 MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
1151 MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
1153 MSHookFunction(&GSFontCreateWithName, &$GSFontCreateWithName, &_GSFontCreateWithName);
1155 if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {
1157 memset(nl, 0, sizeof(nl));
1158 nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb";
1159 nlist(AudioToolbox, nl);
1160 _Z24GetFileNameForThisActionmPcRb = (bool (*)(unsigned long, char *, bool &)) nl[0].n_value;
1161 MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &__Z24GetFileNameForThisActionmPcRb);
1164 $NSBundle = objc_getClass("NSBundle");
1166 _NSBundle$localizedStringForKey$value$table$ = MSHookMessage($NSBundle, @selector(localizedStringForKey:value:table:), &$NSBundle$localizedStringForKey$value$table$);
1167 _NSBundle$pathForResource$ofType$ = MSHookMessage($NSBundle, @selector(pathForResource:ofType:), &$NSBundle$pathForResource$ofType$);
1169 $UIImage = objc_getClass("UIImage");
1170 $UINavigationBar = objc_getClass("UINavigationBar");
1171 $UIToolbar = objc_getClass("UIToolbar");
1173 _UIImage$defaultDesktopImage = MSHookMessage(object_getClass($UIImage), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage);
1175 //WBRename("UINavigationBar", @selector(initWithCoder:", (IMP) &UINavigationBar$initWithCoder$);
1176 //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
1178 _UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$);
1179 _UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$);
1181 _UISharedImageInitialize(false);
1183 Manager_ = [[NSFileManager defaultManager] retain];
1184 UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1185 PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1186 Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0];
1187 Bundles_ = [[NSMutableDictionary alloc] initWithCapacity:2];
1188 Themed_ = [[NSMutableDictionary alloc] initWithCapacity:128];
1190 themes_ = [[NSMutableArray alloc] initWithCapacity:8];
1192 if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
1193 [settings autorelease];
1195 if (NSNumber *debug = [settings objectForKey:@"Debug"])
1196 Debug_ = [debug boolValue];
1198 NSArray *themes = [settings objectForKey:@"Themes"];
1200 if (NSString *theme = [settings objectForKey:@"Theme"])
1201 themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
1203 [NSNumber numberWithBool:true], @"Active",
1206 for (NSDictionary *theme in themes) {
1207 NSNumber *active = [theme objectForKey:@"Active"];
1208 if (![active boolValue])
1211 NSString *name = [theme objectForKey:@"Name"];
1215 NSString *theme = nil;
1217 #define testForTheme(format...) \
1218 if (theme == nil) { \
1219 NSString *path = [NSString stringWithFormat:format]; \
1220 if ([Manager_ fileExistsAtPath:path]) { \
1221 [themes_ addObject:path]; \
1226 testForTheme(@"/Library/Themes/%@.theme", name)
1227 testForTheme(@"/Library/Themes/%@", name)
1228 testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)
1232 Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
1234 for (NSString *theme in themes_)
1235 if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])
1236 for (NSString *key in [info allKeys])
1237 if ([Info_ objectForKey:key] == nil)
1238 [Info_ setObject:[info objectForKey:key] forKey:key];
1240 if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
1241 Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
1242 _mSMSMessageTranscriptController$loadView = MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), &$mSMSMessageTranscriptController$loadView);
1243 } else if ([identifier isEqualToString:@"com.apple.springboard"]) {
1244 CFNotificationCenterAddObserver(
1245 CFNotificationCenterGetDarwinNotifyCenter(),
1246 NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0
1249 NSBundle *MediaPlayer = [NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"];
1250 if (MediaPlayer != nil)
1253 $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
1254 $MPVideoView = objc_getClass("MPVideoView");
1255 $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
1257 $SBApplication = objc_getClass("SBApplication");
1258 $SBApplicationIcon = objc_getClass("SBApplicationIcon");
1259 $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
1260 $SBButtonBar = objc_getClass("SBButtonBar");
1261 $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
1262 $SBContentLayer = objc_getClass("SBContentLayer");
1263 $SBIconBadge = objc_getClass("SBIconBadge");
1264 $SBIconController = objc_getClass("SBIconController");
1265 $SBIconLabel = objc_getClass("SBIconLabel");
1266 $SBIconModel = objc_getClass("SBIconModel");
1267 $SBSlidingAlertDisplay = objc_getClass("SBSlidingAlertDisplay");
1268 $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
1269 $SBStatusBarController = objc_getClass("SBStatusBarController");
1270 $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
1271 $SBStatusBarTimeView = objc_getClass("SBStatusBarTimeView");
1272 $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon");
1274 WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$);
1276 WBRename(SBApplication, pathForIcon, pathForIcon);
1277 WBRename(SBApplicationIcon, icon, icon);
1278 WBRename(SBBookmarkIcon, icon, icon);
1279 WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview);
1280 WBRename(SBCalendarIconContentsView, drawRect:, drawRect$);
1281 WBRename(SBContentLayer, initWithSize:, initWithSize$);
1282 WBRename(SBIconBadge, initWithBadge:, initWithBadge$);
1283 WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged);
1284 WBRename(SBWidgetApplicationIcon, icon, icon);
1286 WBRename(SBIconLabel, drawRect:, drawRect$);
1287 WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
1288 WBRename(SBIconLabel, setInDock:, setInDock$);
1290 WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
1291 WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
1293 WBRename(SBSlidingAlertDisplay, updateDesktopImage:, updateDesktopImage$);
1294 WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
1295 WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
1296 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$);
1297 WBRename(SBStatusBarOperatorNameView, operatorNameStyle, operatorNameStyle);
1298 WBRename(SBStatusBarOperatorNameView, setOperatorName:fullSize:, setOperatorName$fullSize$);
1299 WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
1301 English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
1302 if (English_ != nil)
1303 English_ = [English_ retain];
1305 Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
1308 Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
1310 if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
1311 [Info_ setObject:[NSNumber numberWithBool:(
1312 $getTheme$(Wallpapers_) == nil ||
1313 [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
1314 [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
1315 )] forKey:@"UndockedIconLabels"];
1318 NSLog(@"WB:Debug:Info = %@", [Info_ description]);