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