]> git.saurik.com Git - winterboard.git/blob - Library.mm
Fix the display identifier bug reported by Surenix.
[winterboard.git] / Library.mm
1 /* WinterBoard - Theme Manager for the iPhone
2 * Copyright (C) 2008-2010 Jay Freeman (saurik)
3 */
4
5 /*
6 * Redistribution and use in source and binary
7 * forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
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
17 * distribution.
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.
21 *
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.
36 */
37
38 #include <sys/time.h>
39
40 struct timeval _ltv;
41 bool _itv;
42
43 #define _trace() do { \
44 struct timeval _ctv; \
45 gettimeofday(&_ctv, NULL); \
46 if (!_itv) { \
47 _itv = true; \
48 _ltv = _ctv; \
49 } \
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__\
54 ); \
55 _ltv = _ctv; \
56 } while (false)
57
58 #define _transient
59
60 #import <CoreFoundation/CoreFoundation.h>
61 #import <Foundation/Foundation.h>
62 #import <CoreGraphics/CoreGraphics.h>
63
64 #import <Celestial/AVController.h>
65 #import <Celestial/AVItem.h>
66 #import <Celestial/AVQueue.h>
67
68 #include <substrate.h>
69
70 #import <UIKit/UIKit.h>
71
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 // XXX: #import <SpringBoard/SBSearchView.h>
85 #import <SpringBoard/SBSearchTableViewCell.h>
86 #import <SpringBoard/SBStatusBarContentsView.h>
87 #import <SpringBoard/SBStatusBarController.h>
88 #import <SpringBoard/SBStatusBarOperatorNameView.h>
89 #import <SpringBoard/SBStatusBarTimeView.h>
90 #import <SpringBoard/SBUIController.h>
91 #import <SpringBoard/SBWidgetApplicationIcon.h>
92
93 #import <MobileSMS/mSMSMessageTranscriptController.h>
94
95 #import <MediaPlayer/MPMoviePlayerController.h>
96 #import <MediaPlayer/MPVideoView.h>
97 #import <MediaPlayer/MPVideoView-PlaybackControl.h>
98
99 #import <CoreGraphics/CGGeometry.h>
100
101 #import <ChatKit/CKMessageCell.h>
102
103 extern "C" void __clear_cache (char *beg, char *end);
104
105 @protocol WinterBoard
106 - (void *) _node;
107 @end
108
109 Class $MPMoviePlayerController;
110 Class $MPVideoView;
111 Class $WebCoreFrameBridge;
112
113 Class $NSBundle;
114
115 Class $UIImage;
116 Class $UINavigationBar;
117 Class $UIToolbar;
118
119 Class $CKMessageCell;
120 Class $CKTimestampView;
121 Class $CKTranscriptController;
122 Class $CKTranscriptTableView;
123
124 Class $SBApplication;
125 Class $SBApplicationIcon;
126 Class $SBAwayView;
127 Class $SBBookmarkIcon;
128 Class $SBButtonBar;
129 Class $SBCalendarIconContentsView;
130 Class $SBIcon;
131 Class $SBIconBadge;
132 Class $SBIconController;
133 Class $SBIconLabel;
134 Class $SBIconList;
135 Class $SBIconModel;
136 //Class $SBImageCache;
137 Class $SBSearchView;
138 Class $SBSearchTableViewCell;
139 Class $SBStatusBarContentsView;
140 Class $SBStatusBarController;
141 Class $SBStatusBarOperatorNameView;
142 Class $SBStatusBarTimeView;
143 Class $SBUIController;
144 Class $SBWidgetApplicationIcon;
145
146 @interface NSDictionary (WinterBoard)
147 - (UIColor *) wb$colorForKey:(NSString *)key;
148 - (BOOL) wb$boolForKey:(NSString *)key;
149 @end
150
151 @implementation NSDictionary (WinterBoard)
152
153 - (UIColor *) wb$colorForKey:(NSString *)key {
154 NSString *value = [self objectForKey:key];
155 if (value == nil)
156 return nil;
157 /* XXX: incorrect */
158 return nil;
159 }
160
161 - (BOOL) wb$boolForKey:(NSString *)key {
162 if (NSString *value = [self objectForKey:key])
163 return [value boolValue];
164 return false;
165 }
166
167 @end
168
169 static BOOL (*_GSFontGetUseLegacyFontMetrics)();
170 #define $GSFontGetUseLegacyFontMetrics() \
171 (_GSFontGetUseLegacyFontMetrics == NULL ? YES : _GSFontGetUseLegacyFontMetrics())
172
173 bool Debug_ = false;
174 bool Engineer_ = false;
175
176 static UIImage *(*_UIApplicationImageWithName)(NSString *name);
177 static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path);
178 static CGImageRef (*_UIImageRefAtPath)(NSString *name, bool cache, UIImageOrientation *orientation);
179 static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain);
180 static NSBundle *(*_UIKitBundle)();
181 static int (*_UISharedImageNameGetIdentifier)(NSString *);
182 static UIImage *(*_UISharedImageWithIdentifier)(int);
183
184 static NSMutableDictionary *UIImages_;
185 static NSMutableDictionary *PathImages_;
186 static NSMutableDictionary *Cache_;
187 static NSMutableDictionary *Strings_;
188 static NSMutableDictionary *Themed_;
189 static NSMutableDictionary *Bundles_;
190
191 static NSFileManager *Manager_;
192 static NSDictionary *English_;
193 static NSMutableDictionary *Info_;
194 static NSMutableArray *themes_;
195
196 static NSString *$getTheme$(NSArray *files, bool parent = false) {
197 if (!parent)
198 if (NSString *path = [Themed_ objectForKey:files])
199 return reinterpret_cast<id>(path) == [NSNull null] ? nil : path;
200
201 if (Debug_)
202 NSLog(@"WB:Debug: %@", [files description]);
203
204 NSString *path;
205
206 for (NSString *theme in themes_)
207 for (NSString *file in files) {
208 path = [NSString stringWithFormat:@"%@/%@", theme, file];
209 if ([Manager_ fileExistsAtPath:path]) {
210 path = parent ? theme : path;
211 goto set;
212 }
213 }
214
215 path = nil;
216 set:
217 if (!parent)
218 [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast<id>(path)) forKey:files];
219 return path;
220 }
221
222 static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui) {
223 NSString *identifier = [bundle bundleIdentifier];
224 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
225
226 if (identifier != nil)
227 [names addObject:[NSString stringWithFormat:@"Bundles/%@/%@", identifier, file]];
228 if (NSString *folder = [[bundle bundlePath] lastPathComponent])
229 [names addObject:[NSString stringWithFormat:@"Folders/%@/%@", folder, file]];
230 if (ui)
231 [names addObject:[NSString stringWithFormat:@"UIImages/%@", file]];
232
233 #define remapResourceName(oldname, newname) \
234 else if ([file isEqualToString:oldname]) \
235 [names addObject:[NSString stringWithFormat:@"%@.png", newname]]; \
236
237 if (identifier == nil);
238 else if ([identifier isEqualToString:@"com.apple.chatkit"])
239 [names addObject:[NSString stringWithFormat:@"Bundles/com.apple.MobileSMS/%@", file]];
240 else if ([identifier isEqualToString:@"com.apple.calculator"])
241 [names addObject:[NSString stringWithFormat:@"Files/Applications/Calculator.app/%@", file]];
242 else if (![identifier isEqualToString:@"com.apple.springboard"]);
243 remapResourceName(@"FSO_BG.png", @"StatusBar")
244 remapResourceName(@"SBDockBG.png", @"Dock")
245 remapResourceName(@"SBWeatherCelsius.png", @"Icons/Weather")
246
247 if (NSString *path = $getTheme$(names))
248 return path;
249 return nil;
250 }
251
252 static NSString *$pathForIcon$(SBApplication *self) {
253 NSString *identifier = [self bundleIdentifier];
254 NSString *path = [self path];
255 NSString *folder = [path lastPathComponent];
256 NSString *dname = [self displayName];
257 NSString *didentifier = [self displayIdentifier];
258
259 if (Debug_)
260 NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier);
261
262 NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
263
264 if (identifier != nil)
265 [names addObject:[NSString stringWithFormat:@"Bundles/%@/icon.png", identifier]];
266 if (folder != nil)
267 [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]];
268
269 #define testForIcon(Name) \
270 if (NSString *name = Name) \
271 [names addObject:[NSString stringWithFormat:@"Icons/%@.png", name]];
272
273 if (![didentifier isEqualToString:identifier])
274 testForIcon(didentifier);
275 testForIcon(identifier);
276 testForIcon(dname);
277
278 if (didentifier != nil) {
279 testForIcon([English_ objectForKey:didentifier]);
280
281 NSArray *parts = [didentifier componentsSeparatedByString:@"-"];
282 if ([parts count] != 1)
283 if (NSDictionary *english = [[[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingString:@"/English.lproj/UIRoleDisplayNames.strings"]] autorelease])
284 testForIcon([english objectForKey:[parts lastObject]]);
285 }
286
287 if (NSString *path = $getTheme$(names))
288 return path;
289 return nil;
290 }
291
292 @interface NSBundle (WinterBoard)
293 + (NSBundle *) wb$bundleWithFile:(NSString *)path;
294 @end
295
296 @implementation NSBundle (WinterBoard)
297
298 + (NSBundle *) wb$bundleWithFile:(NSString *)path {
299 path = [path stringByDeletingLastPathComponent];
300 if (path == nil || [path length] == 0 || [path isEqualToString:@"/"])
301 return nil;
302
303 NSBundle *bundle([Bundles_ objectForKey:path]);
304 if (reinterpret_cast<id>(bundle) == [NSNull null])
305 return nil;
306 else if (bundle == nil) {
307 if ([Manager_ fileExistsAtPath:[path stringByAppendingPathComponent:@"Info.plist"]])
308 bundle = [NSBundle bundleWithPath:path];
309 if (bundle == nil)
310 bundle = [NSBundle wb$bundleWithFile:path];
311 if (Debug_)
312 NSLog(@"WB:Debug:PathBundle(%@, %@)", path, bundle);
313 [Bundles_ setObject:(bundle == nil ? [NSNull null] : reinterpret_cast<id>(bundle)) forKey:path];
314 }
315
316 return bundle;
317 }
318
319 @end
320
321 @interface NSString (WinterBoard)
322 - (NSString *) wb$themedPath;
323 @end
324
325 @implementation NSString (WinterBoard)
326
327 - (NSString *) wb$themedPath {
328 if (Debug_)
329 NSLog(@"WB:Debug:Bypass(\"%@\")", self);
330
331 if (NSBundle *bundle = [NSBundle wb$bundleWithFile:self]) {
332 NSString *file([self stringByResolvingSymlinksInPath]);
333 NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]);
334 if ([file hasPrefix:prefix]) {
335 NSUInteger length([prefix length]);
336 if (length != [file length])
337 if (NSString *path = $pathForFile$inBundle$([file substringFromIndex:(length + 1)], bundle, false))
338 return path;
339 }
340 }
341
342 return self;
343 }
344
345 @end
346
347 void WBLogRect(const char *tag, struct CGRect rect) {
348 NSLog(@"%s:{%f,%f+%f,%f}", tag, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
349 }
350
351 void WBLogHierarchy(UIView *view, unsigned index = 0, unsigned indent = 0) {
352 CGRect frame([view frame]);
353 NSLog(@"%*s|%2d:%p:%s : {%f,%f+%f,%f} (%@)", indent * 3, "", index, view, class_getName([view class]), frame.origin.x, frame.origin.y, frame.size.width, frame.size.height, [view backgroundColor]);
354 index = 0;
355 for (UIView *child in [view subviews])
356 WBLogHierarchy(child, index++, indent + 1);
357 }
358
359 UIImage *$cacheForImage$(UIImage *image) {
360 CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB());
361 CGRect rect = {CGPointMake(1, 1), [image size]};
362 CGSize size = {rect.size.width + 2, rect.size.height + 2};
363
364 CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
365 CGColorSpaceRelease(space);
366
367 CGContextDrawImage(context, rect, [image CGImage]);
368 CGImageRef ref(CGBitmapContextCreateImage(context));
369 CGContextRelease(context);
370
371 UIImage *cache([UIImage imageWithCGImage:ref]);
372 CGImageRelease(ref);
373
374 return cache;
375 }
376
377 /*MSHook(id, SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$, SBImageCache *self, SEL sel, NSString *name, unsigned width, unsigned height, unsigned capacity) {
378 //if ([name isEqualToString:@"icons"]) return nil;
379 return _SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$(self, sel, name, width, height, capacity);
380 }*/
381
382 MSHook(void, SBIconModel$cacheImageForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
383 NSString *key([icon displayIdentifier]);
384
385 if (UIImage *image = [icon icon]) {
386 CGSize size = [image size];
387 if (size.width != 59 || size.height != 60) {
388 UIImage *cache($cacheForImage$(image));
389 [Cache_ setObject:cache forKey:key];
390 return;
391 }
392 }
393
394 _SBIconModel$cacheImageForIcon$(self, sel, icon);
395 }
396
397 MSHook(void, SBIconModel$cacheImagesForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
398 /* XXX: do I /really/ have to do this? figure out how to cache the small icon! */
399 _SBIconModel$cacheImagesForIcon$(self, sel, icon);
400
401 NSString *key([icon displayIdentifier]);
402
403 if (UIImage *image = [icon icon]) {
404 CGSize size = [image size];
405 if (size.width != 59 || size.height != 60) {
406 UIImage *cache($cacheForImage$(image));
407 [Cache_ setObject:cache forKey:key];
408 return;
409 }
410 }
411 }
412
413 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
414 NSString *key([icon displayIdentifier]);
415 if (UIImage *image = [Cache_ objectForKey:key])
416 return image;
417 else
418 return _SBIconModel$getCachedImagedForIcon$(self, sel, icon);
419 }
420
421 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$smallIcon$, SBIconModel *self, SEL sel, SBIcon *icon, BOOL small) {
422 if (small)
423 return _SBIconModel$getCachedImagedForIcon$smallIcon$(self, sel, icon, small);
424 NSString *key([icon displayIdentifier]);
425 if (UIImage *image = [Cache_ objectForKey:key])
426 return image;
427 else
428 return _SBIconModel$getCachedImagedForIcon$smallIcon$(self, sel, icon, small);
429 }
430
431 MSHook(id, SBSearchView$initWithFrame$, id /* XXX: SBSearchView */ self, SEL sel, struct CGRect frame) {
432 if ((self = _SBSearchView$initWithFrame$(self, sel, frame)) != nil) {
433 [self setBackgroundColor:[UIColor clearColor]];
434 for (UIView *child in [self subviews])
435 [child setBackgroundColor:[UIColor clearColor]];
436 } return self;
437 }
438
439 MSHook(id, SBSearchTableViewCell$initWithStyle$reuseIdentifier$, SBSearchTableViewCell *self, SEL sel, int style, NSString *reuse) {
440 if ((self = _SBSearchTableViewCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
441 [self setBackgroundColor:[UIColor clearColor]];
442 } return self;
443 }
444
445 MSHook(void, SBSearchTableViewCell$drawRect$, SBSearchTableViewCell *self, SEL sel, struct CGRect rect, BOOL selected) {
446 _SBSearchTableViewCell$drawRect$(self, sel, rect, selected);
447 float inset([self edgeInset]);
448 [[UIColor clearColor] set];
449 UIRectFill(CGRectMake(0, 0, inset, rect.size.height));
450 UIRectFill(CGRectMake(rect.size.width - inset, 0, inset, rect.size.height));
451 }
452
453 MSHook(UIImage *, SBApplicationIcon$icon, SBApplicationIcon *self, SEL sel) {
454 if (![Info_ wb$boolForKey:@"ComposeStoreIcons"])
455 if (NSString *path = $pathForIcon$([self application]))
456 return [UIImage imageWithContentsOfFile:path];
457 return _SBApplicationIcon$icon(self, sel);
458 }
459
460 MSHook(UIImage *, SBWidgetApplicationIcon$icon, SBWidgetApplicationIcon *self, SEL sel) {
461 if (Debug_)
462 NSLog(@"WB:Debug:Widget(%@:%@)", [self displayIdentifier], [self displayName]);
463 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
464 return [UIImage imageWithContentsOfFile:path];
465 return _SBWidgetApplicationIcon$icon(self, sel);
466 }
467
468 MSHook(UIImage *, SBBookmarkIcon$icon, SBBookmarkIcon *self, SEL sel) {
469 if (Debug_)
470 NSLog(@"WB:Debug:Bookmark(%@:%@)", [self displayIdentifier], [self displayName]);
471 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
472 return [UIImage imageWithContentsOfFile:path];
473 return _SBBookmarkIcon$icon(self, sel);
474 }
475
476 MSHook(NSString *, SBApplication$pathForIcon, SBApplication *self, SEL sel) {
477 if (NSString *path = $pathForIcon$(self))
478 return path;
479 return _SBApplication$pathForIcon(self, sel);
480 }
481
482 static UIImage *CachedImageAtPath(NSString *path) {
483 path = [path stringByResolvingSymlinksInPath];
484 UIImage *image = [PathImages_ objectForKey:path];
485 if (image != nil)
486 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
487 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
488 if (image != nil)
489 image = [image autorelease];
490 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:path];
491 return image;
492 }
493
494 MSHook(CGImageRef, _UIImageRefAtPath, NSString *name, bool cache, UIImageOrientation *orientation) {
495 if (Debug_)
496 NSLog(@"WB:Debug: _UIImageRefAtPath(\"%@\", %s)", name, cache ? "true" : "false");
497 return __UIImageRefAtPath([name wb$themedPath], cache, orientation);
498 }
499
500 /*MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) {
501 if (bundle == nil)
502 return __UIImageAtPath(name, nil);
503 else {
504 NSString *key = [NSString stringWithFormat:@"B:%@/%@", [bundle bundleIdentifier], name];
505 UIImage *image = [PathImages_ objectForKey:key];
506 if (image != nil)
507 return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;
508 if (Debug_)
509 NSLog(@"WB:Debug: _UIImageAtPath(\"%@\", %@)", name, bundle);
510 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
511 image = CachedImageAtPath(path);
512 if (image == nil)
513 image = __UIImageAtPath(name, bundle);
514 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
515 return image;
516 }
517 }*/
518
519 MSHook(UIImage *, _UIApplicationImageWithName, NSString *name) {
520 NSBundle *bundle = [NSBundle mainBundle];
521 if (Debug_)
522 NSLog(@"WB:Debug: _UIApplicationImageWithName(\"%@\", %@)", name, bundle);
523 if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
524 return CachedImageAtPath(path);
525 return __UIApplicationImageWithName(name);
526 }
527
528 #define WBDelegate(delegate) \
529 - (NSMethodSignature*) methodSignatureForSelector:(SEL)sel { \
530 if (Engineer_) \
531 NSLog(@"WB:MS:%s:(%s)", class_getName([self class]), sel_getName(sel)); \
532 if (NSMethodSignature *sig = [delegate methodSignatureForSelector:sel]) \
533 return sig; \
534 NSLog(@"WB:Error: [%s methodSignatureForSelector:(%s)]", class_getName([self class]), sel_getName(sel)); \
535 return nil; \
536 } \
537 \
538 - (void) forwardInvocation:(NSInvocation*)inv { \
539 SEL sel = [inv selector]; \
540 if ([delegate respondsToSelector:sel]) \
541 [inv invokeWithTarget:delegate]; \
542 else \
543 NSLog(@"WB:Error: [%s forwardInvocation:(%s)]", class_getName([self class]), sel_getName(sel)); \
544 }
545
546 MSHook(NSString *, NSBundle$pathForResource$ofType$, NSBundle *self, SEL sel, NSString *resource, NSString *type) {
547 NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
548 if (Debug_)
549 NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
550 if (NSString *path = $pathForFile$inBundle$(file, self, false))
551 return path;
552 return _NSBundle$pathForResource$ofType$(self, sel, resource, type);
553 }
554
555 void $setBarStyle$_(NSString *name, int &style) {
556 if (Debug_)
557 NSLog(@"WB:Debug:%@Style:%d", name, style);
558 NSNumber *number = nil;
559 if (number == nil)
560 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style-%d", name, style]];
561 if (number == nil)
562 number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style", name]];
563 if (number != nil) {
564 style = [number intValue];
565 if (Debug_)
566 NSLog(@"WB:Debug:%@Style=%d", name, style);
567 }
568 }
569
570 MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *self, SEL sel, CGRect rect) {
571 NSBundle *bundle([NSBundle mainBundle]);
572
573 CFLocaleRef locale(CFLocaleCopyCurrent());
574 CFDateFormatterRef formatter(CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle));
575 CFRelease(locale);
576
577 CFDateRef now(CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()));
578
579 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NUMBER_FORMAT" value:@"" table:@"SpringBoard"]);
580 CFStringRef date(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
581 CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NAME_FORMAT" value:@"cccc" table:@"SpringBoard"]);
582 CFStringRef day(CFDateFormatterCreateStringWithDate(NULL, formatter, now));
583
584 CFRelease(now);
585
586 CFRelease(formatter);
587
588 NSString *datestyle(@""
589 "font-family: Helvetica; "
590 "font-weight: bold; "
591 "font-size: 39px; "
592 "color: #333333; "
593 "alpha: 1.0; "
594 "");
595
596 NSString *daystyle(@""
597 "font-family: Helvetica; "
598 "font-weight: bold; "
599 "font-size: 9px; "
600 "color: white; "
601 "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px; "
602 "");
603
604 if (NSString *style = [Info_ objectForKey:@"CalendarIconDateStyle"])
605 datestyle = [datestyle stringByAppendingString:style];
606 if (NSString *style = [Info_ objectForKey:@"CalendarIconDayStyle"])
607 daystyle = [daystyle stringByAppendingString:style];
608
609 float width([self bounds].size.width);
610 float leeway(10);
611 CGSize datesize = [(NSString *)date sizeWithStyle:datestyle forWidth:(width + leeway)];
612 CGSize daysize = [(NSString *)day sizeWithStyle:daystyle forWidth:(width + leeway)];
613
614 unsigned base($GSFontGetUseLegacyFontMetrics() ? 71 : 70);
615
616 [(NSString *)date drawAtPoint:CGPointMake(
617 (width + 1 - datesize.width) / 2, (base - datesize.height) / 2
618 ) withStyle:datestyle];
619
620 [(NSString *)day drawAtPoint:CGPointMake(
621 (width + 1 - daysize.width) / 2, (16 - daysize.height) / 2
622 ) withStyle:daystyle];
623
624 CFRelease(date);
625 CFRelease(day);
626 }
627
628 /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) {
629 _trace();
630
631 if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"])
632 style = [number intValue];
633
634 if (UIColor *color = [Info_ wb$colorForKey:@"NavigationBarTint"])
635 tint = color;
636
637 return [self wb$initWithFrame:frame withBarStyle:style withTintColor:tint];
638 }*/
639
640 /*static id UINavigationBar$initWithCoder$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame, NSCoder *coder) {
641 self = [self wb$initWithCoder:coder];
642 if (self == nil)
643 return nil;
644 UINavigationBar$setBarStyle$_(self);
645 return self;
646 }
647
648 static id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame) {
649 self = [self wb$initWithFrame:frame];
650 if (self == nil)
651 return nil;
652 UINavigationBar$setBarStyle$_(self);
653 return self;
654 }*/
655
656 MSHook(void, UIToolbar$setBarStyle$, UIToolbar *self, SEL sel, int style) {
657 $setBarStyle$_(@"Toolbar", style);
658 return _UIToolbar$setBarStyle$(self, sel, style);
659 }
660
661 MSHook(void, UINavigationBar$setBarStyle$, UINavigationBar *self, SEL sel, int style) {
662 $setBarStyle$_(@"NavigationBar", style);
663 return _UINavigationBar$setBarStyle$(self, sel, style);
664 }
665
666 MSHook(void, SBButtonBar$didMoveToSuperview, UIView *self, SEL sel) {
667 [[self superview] setBackgroundColor:[UIColor clearColor]];
668 _SBButtonBar$didMoveToSuperview(self, sel);
669 }
670
671 MSHook(void, SBStatusBarContentsView$didMoveToSuperview, UIView *self, SEL sel) {
672 [[self superview] setBackgroundColor:[UIColor clearColor]];
673 _SBStatusBarContentsView$didMoveToSuperview(self, sel);
674 }
675
676 MSHook(UIImage *, UIImage$defaultDesktopImage, UIImage *self, SEL sel) {
677 if (Debug_)
678 NSLog(@"WB:Debug:DefaultDesktopImage");
679 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"LockBackground.png", @"LockBackground.jpg", nil]))
680 return [UIImage imageWithContentsOfFile:path];
681 return _UIImage$defaultDesktopImage(self, sel);
682 }
683
684 static NSArray *Wallpapers_;
685 static NSString *WallpaperFile_;
686 static UIImageView *WallpaperImage_;
687 static UIWebDocumentView *WallpaperPage_;
688 static NSURL *WallpaperURL_;
689
690 #define _release(object) \
691 do if (object != nil) { \
692 [object release]; \
693 object = nil; \
694 } while (false)
695
696 MSHook(id, SBUIController$init, SBUIController *self, SEL sel) {
697 self = _SBUIController$init(self, sel);
698 if (self == nil)
699 return nil;
700
701 UIWindow *&_window(MSHookIvar<UIWindow *>(self, "_window"));
702 UIView *&_contentLayer(MSHookIvar<UIView *>(self, "_contentLayer"));
703 UIView *&_contentView(MSHookIvar<UIView *>(self, "_contentView"));
704
705 UIView *layer;
706 if (&_contentLayer != NULL)
707 layer = _contentLayer;
708 else if (&_contentView != NULL)
709 layer = _contentView;
710 else
711 layer = nil;
712
713 UIView *content([[[UIView alloc] initWithFrame:[layer frame]] autorelease]);
714 [content setBackgroundColor:[layer backgroundColor]];
715 [layer setBackgroundColor:[UIColor clearColor]];
716 [layer setFrame:[content bounds]];
717 [_window setContentView:content];
718
719 _release(WallpaperFile_);
720 _release(WallpaperImage_);
721 _release(WallpaperPage_);
722 _release(WallpaperURL_);
723
724 if (NSString *theme = $getTheme$(Wallpapers_, true)) {
725 NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"];
726 if ([Manager_ fileExistsAtPath:mp4]) {
727 #if UseAVController
728 NSError *error;
729
730 static AVController *controller_(nil);
731 if (controller_ == nil) {
732 AVQueue *queue([AVQueue avQueue]);
733 controller_ = [[AVController avControllerWithQueue:queue error:&error] retain];
734 }
735
736 AVQueue *queue([controller_ queue]);
737
738 UIView *video([[[UIView alloc] initWithFrame:[content bounds]] autorelease]);
739 [controller_ setLayer:[video _layer]];
740
741 AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]);
742 [queue appendItem:item error:&error];
743
744 [controller_ play:&error];
745 #elif UseMPMoviePlayerController
746 NSURL *url([NSURL fileURLWithPath:mp4]);
747 MPMoviePlayerController *controller = [[MPMoviePlayerController alloc] initWithContentURL:url];
748 controller.movieControlMode = MPMovieControlModeHidden;
749 [controller play];
750 #else
751 MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[content bounds]] autorelease];
752 [video setMovieWithPath:mp4];
753 [video setRepeatMode:1];
754 [video setRepeatGap:-1];
755 [video playFromBeginning];;
756 #endif
757
758 [content addSubview:video];
759 }
760
761 NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"];
762 NSString *jpg = [theme stringByAppendingPathComponent:@"Wallpaper.jpg"];
763
764 NSString *path;
765 if ([Manager_ fileExistsAtPath:png])
766 path = png;
767 else if ([Manager_ fileExistsAtPath:jpg])
768 path = jpg;
769 else path = nil;
770
771 UIImage *image;
772 if (path != nil) {
773 image = [[UIImage alloc] initWithContentsOfFile:path];
774 if (image != nil)
775 image = [image autorelease];
776 } else image = nil;
777
778 if (image != nil) {
779 WallpaperFile_ = [path retain];
780 WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
781 if (NSNumber *number = [Info_ objectForKey:@"WallpaperAlpha"])
782 [WallpaperImage_ setAlpha:[number floatValue]];
783 [content addSubview:WallpaperImage_];
784 }
785
786 NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"];
787 if ([Manager_ fileExistsAtPath:html]) {
788 CGRect bounds = [content bounds];
789
790 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
791 [view setAutoresizes:true];
792
793 WallpaperPage_ = [view retain];
794 WallpaperURL_ = [[NSURL fileURLWithPath:html] retain];
795
796 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
797
798 [view setBackgroundColor:[UIColor clearColor]];
799 if ([view respondsToSelector:@selector(setDrawsBackground:)])
800 [view setDrawsBackground:NO];
801 [[view webView] setDrawsBackground:NO];
802
803 [content addSubview:view];
804 }
805 }
806
807 for (size_t i(0), e([themes_ count]); i != e; ++i) {
808 NSString *theme = [themes_ objectAtIndex:(e - i - 1)];
809 NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"];
810 if ([Manager_ fileExistsAtPath:html]) {
811 CGRect bounds = [content bounds];
812
813 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
814 [view setAutoresizes:true];
815
816 NSURL *url = [NSURL fileURLWithPath:html];
817 [view loadRequest:[NSURLRequest requestWithURL:url]];
818
819 [view setBackgroundColor:[UIColor clearColor]];
820 if ([view respondsToSelector:@selector(setDrawsBackground:)])
821 [view setDrawsBackground:NO];
822 [[view webView] setDrawsBackground:NO];
823
824 [content addSubview:view];
825 }
826 }
827
828 [content addSubview:layer];
829
830 return self;
831 }
832
833 MSHook(void, SBAwayView$updateDesktopImage$, SBAwayView *self, SEL sel, UIImage *image) {
834 NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]);
835 UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
836
837 if (path != nil && _backgroundView != nil)
838 path = nil;
839
840 _SBAwayView$updateDesktopImage$(self, sel, image);
841
842 if (path != nil) {
843 CGRect bounds = [self bounds];
844
845 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
846 [view setAutoresizes:true];
847
848 if (WallpaperPage_ != nil)
849 [WallpaperPage_ release];
850 WallpaperPage_ = [view retain];
851
852 if (WallpaperURL_ != nil)
853 [WallpaperURL_ release];
854 WallpaperURL_ = [[NSURL fileURLWithPath:path] retain];
855
856 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
857
858 [[view webView] setDrawsBackground:false];
859 [view setBackgroundColor:[UIColor clearColor]];
860
861 [self insertSubview:view aboveSubview:_backgroundView];
862 }
863 }
864
865 /*extern "C" CGColorRef CGGStateGetSystemColor(void *);
866 extern "C" CGColorRef CGGStateGetFillColor(void *);
867 extern "C" CGColorRef CGGStateGetStrokeColor(void *);
868 extern "C" NSString *UIStyleStringFromColor(CGColorRef);*/
869
870 /* WBTimeLabel {{{ */
871 @interface WBTimeLabel : NSProxy {
872 NSString *time_;
873 _transient SBStatusBarTimeView *view_;
874 }
875
876 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view;
877
878 @end
879
880 @implementation WBTimeLabel
881
882 - (void) dealloc {
883 [time_ release];
884 [super dealloc];
885 }
886
887 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view {
888 time_ = [time retain];
889 view_ = view;
890 return self;
891 }
892
893 - (NSString *) description {
894 return time_;
895 }
896
897 WBDelegate(time_)
898
899 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
900 if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
901 BOOL &_mode(MSHookIvar<BOOL>(view_, "_mode"));;
902
903 [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
904 "font-family: Helvetica; "
905 "font-weight: bold; "
906 "font-size: 14px; "
907 "color: %@; "
908 "%@", _mode ? @"white" : @"black", custom]];
909
910 return CGSizeZero;
911 }
912
913 return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
914 }
915
916 @end
917 /* }}} */
918 /* WBBadgeLabel {{{ */
919 @interface WBBadgeLabel : NSProxy {
920 NSString *badge_;
921 }
922
923 - (id) initWithBadge:(NSString *)badge;
924 - (NSString *) description;
925
926 @end
927
928 @implementation WBBadgeLabel
929
930 - (void) dealloc {
931 [badge_ release];
932 [super dealloc];
933 }
934
935 - (id) initWithBadge:(NSString *)badge {
936 badge_ = [badge retain];
937 return self;
938 }
939
940 - (NSString *) description {
941 return [badge_ description];
942 }
943
944 WBDelegate(badge_)
945
946 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
947 if (NSString *custom = [Info_ objectForKey:@"BadgeStyle"]) {
948 [badge_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
949 "font-family: Helvetica; "
950 "font-weight: bold; "
951 "font-size: 17px; "
952 "color: white; "
953 "%@", custom]];
954
955 return CGSizeZero;
956 }
957
958 return [badge_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
959 }
960
961 @end
962 /* }}} */
963
964 MSHook(void, SBIcon$setAlpha$, SBIcon *self, SEL sel, float alpha) {
965 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
966 alpha = [number floatValue];
967 return _SBIcon$setAlpha$(self, sel, alpha);
968 }
969
970 MSHook(id, SBIconBadge$initWithBadge$, SBIconBadge *self, SEL sel, NSString *badge) {
971 if ((self = _SBIconBadge$initWithBadge$(self, sel, badge)) != nil) {
972 id &_badge(MSHookIvar<id>(self, "_badge"));
973 if (_badge != nil)
974 if (id label = [[WBBadgeLabel alloc] initWithBadge:[_badge autorelease]])
975 _badge = label;
976 } return self;
977 }
978
979 void SBStatusBarController$setStatusBarMode(int &mode) {
980 if (Debug_)
981 NSLog(@"WB:Debug:setStatusBarMode:%d", mode);
982 if (mode < 100) // 104:hidden 105:glowing
983 if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"])
984 mode = [number intValue];
985 }
986
987 /*MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int animation) {
988 NSLog(@"mode:%d orientation:%d duration:%f animation:%d", mode, orientation, duration, animation);
989 SBStatusBarController$setStatusBarMode(mode);
990 return _SBStatusBarController$setStatusBarMode$orientation$duration$animation$(self, sel, mode, orientation, duration, animation);
991 }*/
992
993 MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int fenceID, int animation) {
994 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d", mode, orientation, duration, fenceID, animation);
995 SBStatusBarController$setStatusBarMode(mode);
996 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, fenceID, animation);
997 }
998
999 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) {
1000 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d startTime:%f", mode, orientation, duration, fenceID, animation, startTime);
1001 SBStatusBarController$setStatusBarMode(mode);
1002 //NSLog(@"mode=%u", mode);
1003 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$(self, sel, mode, orientation, duration, fenceID, animation, startTime);
1004 }
1005
1006 /*MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) {
1007 if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"])
1008 mode = [number intValue];
1009 return _SBStatusBarContentsView$initWithStatusBar$mode$(self, sel, bar, mode);
1010 }*/
1011
1012 MSHook(NSString *, SBStatusBarOperatorNameView$operatorNameStyle, SBStatusBarOperatorNameView *self, SEL sel) {
1013 NSString *style(_SBStatusBarOperatorNameView$operatorNameStyle(self, sel));
1014 if (Debug_)
1015 NSLog(@"operatorNameStyle= %@", style);
1016 if (NSString *custom = [Info_ objectForKey:@"OperatorNameStyle"])
1017 style = [NSString stringWithFormat:@"%@; %@", style, custom];
1018 return style;
1019 }
1020
1021 MSHook(void, SBStatusBarOperatorNameView$setOperatorName$fullSize$, SBStatusBarOperatorNameView *self, SEL sel, NSString *name, BOOL full) {
1022 if (Debug_)
1023 NSLog(@"setOperatorName:\"%@\" fullSize:%u", name, full);
1024 return _SBStatusBarOperatorNameView$setOperatorName$fullSize$(self, sel, name, NO);
1025 }
1026
1027 // XXX: replace this with [SBStatusBarTimeView tile]
1028 MSHook(void, SBStatusBarTimeView$drawRect$, SBStatusBarTimeView *self, SEL sel, CGRect rect) {
1029 id &_time(MSHookIvar<id>(self, "_time"));
1030 if (_time != nil && [_time class] != [WBTimeLabel class])
1031 object_setInstanceVariable(self, "_time", reinterpret_cast<void *>([[WBTimeLabel alloc] initWithTime:[_time autorelease] view:self]));
1032 return _SBStatusBarTimeView$drawRect$(self, sel, rect);
1033 }
1034
1035 @interface UIView (WinterBoard)
1036 - (bool) wb$isWBImageView;
1037 - (void) wb$logHierarchy;
1038 @end
1039
1040 @implementation UIView (WinterBoard)
1041
1042 - (bool) wb$isWBImageView {
1043 return false;
1044 }
1045
1046 - (void) wb$logHierarchy {
1047 WBLogHierarchy(self);
1048 }
1049
1050 @end
1051
1052 @interface WBImageView : UIImageView {
1053 }
1054
1055 - (bool) wb$isWBImageView;
1056 - (void) wb$updateFrame;
1057 @end
1058
1059 @implementation WBImageView
1060
1061 - (bool) wb$isWBImageView {
1062 return true;
1063 }
1064
1065 - (void) wb$updateFrame {
1066 CGRect frame([self frame]);
1067 frame.origin.y = 0;
1068
1069 for (UIView *view(self); ; ) {
1070 view = [view superview];
1071 if (view == nil)
1072 break;
1073 frame.origin.y -= [view frame].origin.y;
1074 }
1075
1076 [self setFrame:frame];
1077 }
1078
1079 @end
1080
1081 MSHook(void, SBIconList$setFrame$, SBIconList *self, SEL sel, CGRect frame) {
1082 NSArray *subviews([self subviews]);
1083 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1084 if (view != nil && [view wb$isWBImageView])
1085 [view wb$updateFrame];
1086 _SBIconList$setFrame$(self, sel, frame);
1087 }
1088
1089 MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *self, SEL sel) {
1090 SBIconModel *&_iconModel(MSHookIvar<SBIconModel *>(self, "_iconModel"));
1091 NSArray *lists([_iconModel iconLists]);
1092
1093 for (unsigned i(0), e([lists count]); i != e; ++i)
1094 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Page%u.png", i]])) {
1095 SBIconList *list([lists objectAtIndex:i]);
1096 NSArray *subviews([list subviews]);
1097
1098 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1099 if (view == nil || ![view wb$isWBImageView]) {
1100 view = [[[WBImageView alloc] init] autorelease];
1101 [list insertSubview:view atIndex:0];
1102 }
1103
1104 UIImage *image([UIImage imageWithContentsOfFile:path]);
1105
1106 CGRect frame([view frame]);
1107 frame.size = [image size];
1108 [view setFrame:frame];
1109
1110 [view setImage:image];
1111 [view wb$updateFrame];
1112 }
1113
1114 return _SBIconController$noteNumberOfIconListsChanged(self, sel);
1115 }
1116
1117 MSHook(id, SBIconLabel$initWithSize$label$, SBIconLabel *self, SEL sel, CGSize size, NSString *label) {
1118 self = _SBIconLabel$initWithSize$label$(self, sel, size, label);
1119 if (self != nil)
1120 [self setClipsToBounds:NO];
1121 return self;
1122 }
1123
1124 MSHook(void, SBIconLabel$setInDock$, SBIconLabel *self, SEL sel, BOOL docked) {
1125 id &_label(MSHookIvar<id>(self, "_label"));
1126 if (![Info_ wb$boolForKey:@"UndockedIconLabels"])
1127 docked = true;
1128 if (_label != nil && [_label respondsToSelector:@selector(setInDock:)])
1129 [_label setInDock:docked];
1130 return _SBIconLabel$setInDock$(self, sel, docked);
1131 }
1132
1133 MSHook(NSString *, NSBundle$localizedStringForKey$value$table$, NSBundle *self, SEL sel, NSString *key, NSString *value, NSString *table) {
1134 NSString *identifier = [self bundleIdentifier];
1135 NSLocale *locale = [NSLocale currentLocale];
1136 NSString *language = [locale objectForKey:NSLocaleLanguageCode];
1137 if (Debug_)
1138 NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language);
1139 NSString *file = table == nil ? @"Localizable" : table;
1140 NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file];
1141 NSDictionary *strings;
1142 if ((strings = [Strings_ objectForKey:name]) != nil) {
1143 if (static_cast<id>(strings) != [NSNull null]) strings:
1144 if (NSString *value = [strings objectForKey:key])
1145 return value;
1146 } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
1147 language, file
1148 ], self, false)) {
1149 if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
1150 [Strings_ setObject:[strings autorelease] forKey:name];
1151 goto strings;
1152 } else goto null;
1153 } else null:
1154 [Strings_ setObject:[NSNull null] forKey:name];
1155 return _NSBundle$localizedStringForKey$value$table$(self, sel, key, value, table);
1156 }
1157
1158 @class WebCoreFrameBridge;
1159 MSHook(CGSize, WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$, WebCoreFrameBridge *self, SEL sel, id node, float width) {
1160 if (node == nil)
1161 return CGSizeZero;
1162 void **core(reinterpret_cast<void **>([node _node]));
1163 if (core == NULL || core[6] == NULL)
1164 return CGSizeZero;
1165 return _WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(self, sel, node, width);
1166 }
1167
1168 MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
1169 CGRect bounds = [self bounds];
1170
1171 static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
1172
1173 BOOL docked;
1174 Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
1175 docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
1176
1177 NSString *label(MSHookIvar<NSString *>(self, "_label"));
1178
1179 NSString *style = [NSString stringWithFormat:@""
1180 "font-family: Helvetica; "
1181 "font-weight: bold; "
1182 "font-size: 11px; "
1183 "color: %@; "
1184 "", docked ? @"white" : @"#b3b3b3"];
1185
1186 if (docked)
1187 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
1188
1189 bool ellipsis(false);
1190 float max = 75, width;
1191 width:
1192 width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
1193
1194 if (width > max) {
1195 size_t length([label length]);
1196 float spacing((width - max) / (length - 1));
1197
1198 if (spacing > 1.25) {
1199 ellipsis = true;
1200 label = [label substringToIndex:(length - 1)];
1201 goto width;
1202 }
1203
1204 style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
1205 }
1206
1207 if (ellipsis)
1208 label = [label stringByAppendingString:@"..."];
1209
1210 if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
1211 style = [style stringByAppendingString:custom];
1212
1213 CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];
1214 [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
1215 }
1216
1217 MSHook(void, CKMessageCell$addBalloonView$, id self, SEL sel, CKBalloonView *balloon) {
1218 _CKMessageCell$addBalloonView$(self, sel, balloon);
1219 [balloon setBackgroundColor:[UIColor clearColor]];
1220 }
1221
1222 MSHook(id, CKMessageCell$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1223 if ((self = _CKMessageCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1224 [[self contentView] setBackgroundColor:[UIColor clearColor]];
1225 } return self;
1226 }
1227
1228 MSHook(id, CKTimestampView$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1229 if ((self = _CKTimestampView$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1230 UILabel *&_label(MSHookIvar<UILabel *>(self, "_label"));
1231 [_label setBackgroundColor:[UIColor clearColor]];
1232 } return self;
1233 }
1234
1235 MSHook(void, CKTranscriptTableView$setSeparatorStyle$, id self, SEL sel, int style) {
1236 _CKTranscriptTableView$setSeparatorStyle$(self, sel, UITableViewCellSeparatorStyleNone);
1237 }
1238
1239 MSHook(id, CKTranscriptTableView$initWithFrame$style$, id self, SEL sel, CGRect frame, int style) {
1240 _trace();
1241 if ((self = _CKTranscriptTableView$initWithFrame$style$(self, sel, frame, style)) != nil) {
1242 [self setSeparatorStyle:UITableViewCellSeparatorStyleNone];
1243 } return self;
1244 }
1245
1246 MSHook(void, TranscriptController$loadView, mSMSMessageTranscriptController *self, SEL sel) {
1247 _TranscriptController$loadView(self, sel);
1248
1249 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
1250 if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
1251 [image autorelease];
1252
1253 UIView *&_transcriptTable(MSHookIvar<UIView *>(self, "_transcriptTable"));
1254 UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
1255 UIView *table;
1256 if (&_transcriptTable != NULL)
1257 table = _transcriptTable;
1258 else if (&_transcriptLayer != NULL)
1259 table = _transcriptLayer;
1260 else
1261 table = nil;
1262
1263 UIView *placard(table != nil ? [table superview] : MSHookIvar<UIView *>(self, "_backPlacard"));
1264 UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]);
1265
1266 if (table == nil)
1267 [placard insertSubview:background atIndex:0];
1268 else {
1269 [table setBackgroundColor:[UIColor clearColor]];
1270 [placard insertSubview:background belowSubview:table];
1271 }
1272 }
1273 }
1274
1275 MSHook(UIImage *, _UIImageWithName, NSString *name) {
1276 int id(_UISharedImageNameGetIdentifier(name));
1277 if (Debug_)
1278 NSLog(@"WB:Debug: _UIImageWithName(\"%@\": %d)", name, id);
1279
1280 if (id == -1)
1281 return _UIImageAtPath(name, _UIKitBundle());
1282 else {
1283 NSNumber *key([NSNumber numberWithInt:id]);
1284 UIImage *image = [UIImages_ objectForKey:key];
1285 if (image != nil)
1286 return reinterpret_cast<id>(image) == [NSNull null] ? _UISharedImageWithIdentifier(id) : image;
1287 if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {
1288 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
1289 if (image != nil)
1290 [image autorelease];
1291 }
1292 [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1293 return image == nil ? _UISharedImageWithIdentifier(id) : image;
1294 }
1295 }
1296
1297 MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
1298 NSString *key([NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name]);
1299 UIImage *image([PathImages_ objectForKey:key]);
1300 if (image != nil)
1301 return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithNameInDomain(name, domain) : image;
1302 if (Debug_)
1303 NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);
1304 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {
1305 image = [[UIImage alloc] initWithContentsOfFile:path];
1306 if (image != nil)
1307 [image autorelease];
1308 }
1309 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1310 return image == nil ? __UIImageWithNameInDomain(name, domain) : image;
1311 }
1312
1313 MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
1314 if (Debug_)
1315 NSLog(@"WB:Debug: GSFontCreateWithName(\"%s\", %f)", name, size);
1316 if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
1317 name = [font UTF8String];
1318 return _GSFontCreateWithName(name, traits, size);
1319 }
1320
1321 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
1322 #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
1323
1324 bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
1325
1326 MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
1327 if (Debug_)
1328 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %p, %u)", a0, a1, a2);
1329 bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
1330 if (Debug_)
1331 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);
1332
1333 if (value) {
1334 NSString *path = [NSString stringWithUTF8String:a1];
1335 if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
1336 NSString *file = [path substringFromIndex:31];
1337 for (NSString *theme in themes_) {
1338 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
1339 if ([Manager_ fileExistsAtPath:path]) {
1340 strcpy(a1, [path UTF8String]);
1341 continue;
1342 }
1343 }
1344 }
1345 }
1346 return value;
1347 }
1348
1349 static void ChangeWallpaper(
1350 CFNotificationCenterRef center,
1351 void *observer,
1352 CFStringRef name,
1353 const void *object,
1354 CFDictionaryRef info
1355 ) {
1356 if (Debug_)
1357 NSLog(@"WB:Debug:ChangeWallpaper!");
1358
1359 UIImage *image;
1360 if (WallpaperFile_ != nil) {
1361 image = [[UIImage alloc] initWithContentsOfFile:WallpaperFile_];
1362 if (image != nil)
1363 image = [image autorelease];
1364 } else image = nil;
1365
1366 if (WallpaperImage_ != nil)
1367 [WallpaperImage_ setImage:image];
1368 if (WallpaperPage_ != nil)
1369 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
1370
1371 }
1372
1373 #define WBRename(name, sel, imp) \
1374 _ ## name ## $ ## imp = MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp)
1375
1376 template <typename Type_>
1377 static void nlset(Type_ &function, struct nlist *nl, size_t index) {
1378 struct nlist &name(nl[index]);
1379 uintptr_t value(name.n_value);
1380 if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
1381 value |= 0x00000001;
1382 function = reinterpret_cast<Type_>(value);
1383 }
1384
1385 template <typename Type_>
1386 static void dlset(Type_ &function, const char *name) {
1387 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
1388 }
1389
1390 extern "C" void WBInitialize() {
1391 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1392
1393 NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);
1394
1395 NSLog(@"WB:Notice: WinterBoard");
1396
1397 dlset(_GSFontGetUseLegacyFontMetrics, "GSFontGetUseLegacyFontMetrics");
1398
1399 struct nlist nl[8];
1400
1401 memset(nl, 0, sizeof(nl));
1402 nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName";
1403 nl[1].n_un.n_name = (char *) "__UIImageAtPath";
1404 nl[2].n_un.n_name = (char *) "__UIImageRefAtPath";
1405 nl[3].n_un.n_name = (char *) "__UIImageWithNameInDomain";
1406 nl[4].n_un.n_name = (char *) "__UIKitBundle";
1407 nl[5].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";
1408 nl[6].n_un.n_name = (char *) "__UISharedImageWithIdentifier";
1409 nlist(UIKit, nl);
1410
1411 nlset(_UIApplicationImageWithName, nl, 0);
1412 nlset(_UIImageAtPath, nl, 1);
1413 nlset(_UIImageRefAtPath, nl, 2);
1414 nlset(_UIImageWithNameInDomain, nl, 3);
1415 nlset(_UIKitBundle, nl, 4);
1416 nlset(_UISharedImageNameGetIdentifier, nl, 5);
1417 nlset(_UISharedImageWithIdentifier, nl, 6);
1418
1419 MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
1420 MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath);
1421 MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
1422 MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
1423
1424 MSHookFunction(&GSFontCreateWithName, &$GSFontCreateWithName, &_GSFontCreateWithName);
1425
1426 if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {
1427 struct nlist nl[2];
1428 memset(nl, 0, sizeof(nl));
1429 nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb";
1430 nlist(AudioToolbox, nl);
1431 nlset(_Z24GetFileNameForThisActionmPcRb, nl, 0);
1432 MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &__Z24GetFileNameForThisActionmPcRb);
1433 }
1434
1435 $NSBundle = objc_getClass("NSBundle");
1436
1437 _NSBundle$localizedStringForKey$value$table$ = MSHookMessage($NSBundle, @selector(localizedStringForKey:value:table:), &$NSBundle$localizedStringForKey$value$table$);
1438 _NSBundle$pathForResource$ofType$ = MSHookMessage($NSBundle, @selector(pathForResource:ofType:), &$NSBundle$pathForResource$ofType$);
1439
1440 $UIImage = objc_getClass("UIImage");
1441 $UINavigationBar = objc_getClass("UINavigationBar");
1442 $UIToolbar = objc_getClass("UIToolbar");
1443
1444 _UIImage$defaultDesktopImage = MSHookMessage(object_getClass($UIImage), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage);
1445
1446 //WBRename("UINavigationBar", @selector(initWithCoder:", (IMP) &UINavigationBar$initWithCoder$);
1447 //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
1448
1449 _UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$);
1450 _UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$);
1451
1452 Manager_ = [[NSFileManager defaultManager] retain];
1453 UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1454 PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1455 Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0];
1456 Bundles_ = [[NSMutableDictionary alloc] initWithCapacity:2];
1457 Themed_ = [[NSMutableDictionary alloc] initWithCapacity:128];
1458
1459 themes_ = [[NSMutableArray alloc] initWithCapacity:8];
1460
1461 if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
1462 [settings autorelease];
1463
1464 if (NSNumber *debug = [settings objectForKey:@"Debug"])
1465 Debug_ = [debug boolValue];
1466
1467 NSArray *themes = [settings objectForKey:@"Themes"];
1468 if (themes == nil)
1469 if (NSString *theme = [settings objectForKey:@"Theme"])
1470 themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
1471 theme, @"Name",
1472 [NSNumber numberWithBool:true], @"Active",
1473 nil]];
1474 if (themes != nil)
1475 for (NSDictionary *theme in themes) {
1476 NSNumber *active = [theme objectForKey:@"Active"];
1477 if (![active boolValue])
1478 continue;
1479
1480 NSString *name = [theme objectForKey:@"Name"];
1481 if (name == nil)
1482 continue;
1483
1484 NSString *theme = nil;
1485
1486 #define testForTheme(format...) \
1487 if (theme == nil) { \
1488 NSString *path = [NSString stringWithFormat:format]; \
1489 if ([Manager_ fileExistsAtPath:path]) { \
1490 [themes_ addObject:path]; \
1491 continue; \
1492 } \
1493 }
1494
1495 testForTheme(@"/Library/Themes/%@.theme", name)
1496 testForTheme(@"/Library/Themes/%@", name)
1497 testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)
1498 }
1499 }
1500
1501 Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
1502
1503 for (NSString *theme in themes_)
1504 if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]]) {
1505 [info autorelease];
1506 for (NSString *key in [info allKeys])
1507 if ([Info_ objectForKey:key] == nil)
1508 [Info_ setObject:[info objectForKey:key] forKey:key];
1509 }
1510
1511 bool sms($getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]) != nil);
1512
1513 if ([NSBundle bundleWithIdentifier:@"com.apple.chatkit"])
1514 if (sms) {
1515 $CKMessageCell = objc_getClass("CKMessageCell");
1516 _CKMessageCell$addBalloonView$ = MSHookMessage($CKMessageCell, @selector(addBalloonView:), &$CKMessageCell$addBalloonView$);
1517 _CKMessageCell$initWithStyle$reuseIdentifier$ = MSHookMessage($CKMessageCell, @selector(initWithStyle:reuseIdentifier:), &$CKMessageCell$initWithStyle$reuseIdentifier$);
1518
1519 $CKTranscriptTableView = objc_getClass("CKTranscriptTableView");
1520 _CKTranscriptTableView$setSeparatorStyle$ = MSHookMessage($CKTranscriptTableView, @selector(setSeparatorStyle:), &$CKTranscriptTableView$setSeparatorStyle$);
1521 _CKTranscriptTableView$initWithFrame$style$ = MSHookMessage($CKTranscriptTableView, @selector(initWithFrame:style:), &$CKTranscriptTableView$initWithFrame$style$);
1522
1523 $CKTimestampView = objc_getClass("CKTimestampView");
1524 _CKTimestampView$initWithStyle$reuseIdentifier$ = MSHookMessage($CKTimestampView, @selector(initWithStyle:reuseIdentifier:), &$CKTimestampView$initWithStyle$reuseIdentifier$);
1525
1526 $CKTranscriptController = objc_getClass("CKTranscriptController");
1527 _TranscriptController$loadView = MSHookMessage($CKTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1528 }
1529
1530 if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
1531 if (sms) {
1532 if (_TranscriptController$loadView == NULL) {
1533 Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
1534 _TranscriptController$loadView = MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1535 }
1536 }
1537 } else if ([identifier isEqualToString:@"com.apple.springboard"]) {
1538 CFNotificationCenterAddObserver(
1539 CFNotificationCenterGetDarwinNotifyCenter(),
1540 NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0
1541 );
1542
1543 NSBundle *MediaPlayer = [NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"];
1544 if (MediaPlayer != nil)
1545 [MediaPlayer load];
1546
1547 $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
1548 $MPVideoView = objc_getClass("MPVideoView");
1549 $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
1550
1551 $SBApplication = objc_getClass("SBApplication");
1552 $SBApplicationIcon = objc_getClass("SBApplicationIcon");
1553 $SBAwayView = objc_getClass("SBAwayView");
1554 $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
1555 $SBButtonBar = objc_getClass("SBButtonBar");
1556 $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
1557 $SBIcon = objc_getClass("SBIcon");
1558 $SBIconBadge = objc_getClass("SBIconBadge");
1559 $SBIconController = objc_getClass("SBIconController");
1560 $SBIconLabel = objc_getClass("SBIconLabel");
1561 $SBIconList = objc_getClass("SBIconList");
1562 $SBIconModel = objc_getClass("SBIconModel");
1563 //$SBImageCache = objc_getClass("SBImageCache");
1564 $SBSearchView = objc_getClass("SBSearchView");
1565 $SBSearchTableViewCell = objc_getClass("SBSearchTableViewCell");
1566 $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
1567 $SBStatusBarController = objc_getClass("SBStatusBarController");
1568 $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
1569 $SBStatusBarTimeView = objc_getClass("SBStatusBarTimeView");
1570 $SBUIController = objc_getClass("SBUIController");
1571 $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon");
1572
1573 WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$);
1574
1575 WBRename(SBApplication, pathForIcon, pathForIcon);
1576 WBRename(SBApplicationIcon, icon, icon);
1577 WBRename(SBBookmarkIcon, icon, icon);
1578 WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview);
1579 WBRename(SBCalendarIconContentsView, drawRect:, drawRect$);
1580 WBRename(SBIcon, setAlpha:, setAlpha$);
1581 WBRename(SBIconBadge, initWithBadge:, initWithBadge$);
1582 WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged);
1583 WBRename(SBUIController, init, init);
1584 WBRename(SBWidgetApplicationIcon, icon, icon);
1585
1586 WBRename(SBIconLabel, drawRect:, drawRect$);
1587 WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
1588 WBRename(SBIconLabel, setInDock:, setInDock$);
1589
1590 WBRename(SBIconList, setFrame:, setFrame$);
1591
1592 WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
1593 WBRename(SBIconModel, cacheImagesForIcon:, cacheImagesForIcon$);
1594 WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
1595 WBRename(SBIconModel, getCachedImagedForIcon:smallIcon:, getCachedImagedForIcon$smallIcon$);
1596
1597 WBRename(SBSearchView, initWithFrame:, initWithFrame$);
1598 WBRename(SBSearchTableViewCell, drawRect:, drawRect$);
1599 WBRename(SBSearchTableViewCell, initWithStyle:reuseIdentifier:, initWithStyle$reuseIdentifier$);
1600
1601 //WBRename(SBImageCache, initWithName:forImageWidth:imageHeight:initialCapacity:, initWithName$forImageWidth$imageHeight$initialCapacity$);
1602
1603 WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
1604 WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
1605 //WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
1606 //WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:animation:, setStatusBarMode$orientation$duration$animation$);
1607 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$);
1608 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:startTime:, setStatusBarMode$orientation$duration$fenceID$animation$startTime$);
1609 WBRename(SBStatusBarOperatorNameView, operatorNameStyle, operatorNameStyle);
1610 WBRename(SBStatusBarOperatorNameView, setOperatorName:fullSize:, setOperatorName$fullSize$);
1611 WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
1612
1613 English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
1614 Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
1615 }
1616
1617 Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
1618
1619 if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
1620 [Info_ setObject:[NSNumber numberWithBool:(
1621 $getTheme$(Wallpapers_) == nil ||
1622 [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
1623 [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
1624 )] forKey:@"UndockedIconLabels"];
1625
1626 if (Debug_)
1627 NSLog(@"WB:Debug:Info = %@", [Info_ description]);
1628
1629 [pool release];
1630 }