]> git.saurik.com Git - winterboard.git/blob - Library.mm
Add backwards compatibility mode for Icons/SMS.png, remove English_ in not SummerBoar...
[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 NSString *datestyle(@""
596 "font-family: Helvetica; "
597 "font-weight: bold; "
598 "font-size: 39px; "
599 "color: #333333; "
600 "alpha: 1.0; "
601 "");
602
603 NSString *daystyle(@""
604 "font-family: Helvetica; "
605 "font-weight: bold; "
606 "font-size: 9px; "
607 "color: white; "
608 "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px; "
609 "");
610
611 if (NSString *style = [Info_ objectForKey:@"CalendarIconDateStyle"])
612 datestyle = [datestyle stringByAppendingString:style];
613 if (NSString *style = [Info_ objectForKey:@"CalendarIconDayStyle"])
614 daystyle = [daystyle stringByAppendingString:style];
615
616 float width([self bounds].size.width);
617 float leeway(10);
618 CGSize datesize = [(NSString *)date sizeWithStyle:datestyle forWidth:(width + leeway)];
619 CGSize daysize = [(NSString *)day sizeWithStyle:daystyle forWidth:(width + leeway)];
620
621 unsigned base($GSFontGetUseLegacyFontMetrics() ? 71 : 70);
622
623 [(NSString *)date drawAtPoint:CGPointMake(
624 (width + 1 - datesize.width) / 2, (base - datesize.height) / 2
625 ) withStyle:datestyle];
626
627 [(NSString *)day drawAtPoint:CGPointMake(
628 (width + 1 - daysize.width) / 2, (16 - daysize.height) / 2
629 ) withStyle:daystyle];
630
631 CFRelease(date);
632 CFRelease(day);
633 }
634
635 /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) {
636 _trace();
637
638 if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"])
639 style = [number intValue];
640
641 if (UIColor *color = [Info_ wb$colorForKey:@"NavigationBarTint"])
642 tint = color;
643
644 return [self wb$initWithFrame:frame withBarStyle:style withTintColor:tint];
645 }*/
646
647 /*static id UINavigationBar$initWithCoder$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame, NSCoder *coder) {
648 self = [self wb$initWithCoder:coder];
649 if (self == nil)
650 return nil;
651 UINavigationBar$setBarStyle$_(self);
652 return self;
653 }
654
655 static id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame) {
656 self = [self wb$initWithFrame:frame];
657 if (self == nil)
658 return nil;
659 UINavigationBar$setBarStyle$_(self);
660 return self;
661 }*/
662
663 MSHook(void, UIToolbar$setBarStyle$, UIToolbar *self, SEL sel, int style) {
664 $setBarStyle$_(@"Toolbar", style);
665 return _UIToolbar$setBarStyle$(self, sel, style);
666 }
667
668 MSHook(void, UINavigationBar$setBarStyle$, UINavigationBar *self, SEL sel, int style) {
669 $setBarStyle$_(@"NavigationBar", style);
670 return _UINavigationBar$setBarStyle$(self, sel, style);
671 }
672
673 MSHook(void, SBButtonBar$didMoveToSuperview, UIView *self, SEL sel) {
674 [[self superview] setBackgroundColor:[UIColor clearColor]];
675 _SBButtonBar$didMoveToSuperview(self, sel);
676 }
677
678 MSHook(void, SBStatusBarContentsView$didMoveToSuperview, UIView *self, SEL sel) {
679 [[self superview] setBackgroundColor:[UIColor clearColor]];
680 _SBStatusBarContentsView$didMoveToSuperview(self, sel);
681 }
682
683 MSHook(UIImage *, UIImage$defaultDesktopImage, UIImage *self, SEL sel) {
684 if (Debug_)
685 NSLog(@"WB:Debug:DefaultDesktopImage");
686 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"LockBackground.png", @"LockBackground.jpg", nil]))
687 return [UIImage imageWithContentsOfFile:path];
688 return _UIImage$defaultDesktopImage(self, sel);
689 }
690
691 static NSArray *Wallpapers_;
692 static NSString *WallpaperFile_;
693 static UIImageView *WallpaperImage_;
694 static UIWebDocumentView *WallpaperPage_;
695 static NSURL *WallpaperURL_;
696
697 #define _release(object) \
698 do if (object != nil) { \
699 [object release]; \
700 object = nil; \
701 } while (false)
702
703 MSHook(id, SBUIController$init, SBUIController *self, SEL sel) {
704 self = _SBUIController$init(self, sel);
705 if (self == nil)
706 return nil;
707
708 UIWindow *&_window(MSHookIvar<UIWindow *>(self, "_window"));
709 UIView *&_contentLayer(MSHookIvar<UIView *>(self, "_contentLayer"));
710 UIView *&_contentView(MSHookIvar<UIView *>(self, "_contentView"));
711
712 UIView *layer;
713 if (&_contentLayer != NULL)
714 layer = _contentLayer;
715 else if (&_contentView != NULL)
716 layer = _contentView;
717 else
718 layer = nil;
719
720 UIView *content([[[UIView alloc] initWithFrame:[layer frame]] autorelease]);
721 [content setBackgroundColor:[layer backgroundColor]];
722 [layer setBackgroundColor:[UIColor clearColor]];
723 [layer setFrame:[content bounds]];
724 [_window setContentView:content];
725
726 _release(WallpaperFile_);
727 _release(WallpaperImage_);
728 _release(WallpaperPage_);
729 _release(WallpaperURL_);
730
731 if (NSString *theme = $getTheme$(Wallpapers_, true)) {
732 NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"];
733 if ([Manager_ fileExistsAtPath:mp4]) {
734 #if UseAVController
735 NSError *error;
736
737 static AVController *controller_(nil);
738 if (controller_ == nil) {
739 AVQueue *queue([AVQueue avQueue]);
740 controller_ = [[AVController avControllerWithQueue:queue error:&error] retain];
741 }
742
743 AVQueue *queue([controller_ queue]);
744
745 UIView *video([[[UIView alloc] initWithFrame:[content bounds]] autorelease]);
746 [controller_ setLayer:[video _layer]];
747
748 AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]);
749 [queue appendItem:item error:&error];
750
751 [controller_ play:&error];
752 #elif UseMPMoviePlayerController
753 NSURL *url([NSURL fileURLWithPath:mp4]);
754 MPMoviePlayerController *controller = [[$MPMoviePlayerController alloc] initWithContentURL:url];
755 controller.movieControlMode = MPMovieControlModeHidden;
756 [controller play];
757 #else
758 MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[content bounds]] autorelease];
759 [video setMovieWithPath:mp4];
760 [video setRepeatMode:1];
761 [video setRepeatGap:-1];
762 [video playFromBeginning];;
763 #endif
764
765 [content addSubview:video];
766 }
767
768 NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"];
769 NSString *jpg = [theme stringByAppendingPathComponent:@"Wallpaper.jpg"];
770
771 NSString *path;
772 if ([Manager_ fileExistsAtPath:png])
773 path = png;
774 else if ([Manager_ fileExistsAtPath:jpg])
775 path = jpg;
776 else path = nil;
777
778 UIImage *image;
779 if (path != nil) {
780 image = [[UIImage alloc] initWithContentsOfFile:path];
781 if (image != nil)
782 image = [image autorelease];
783 } else image = nil;
784
785 if (image != nil) {
786 WallpaperFile_ = [path retain];
787 WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
788 if (NSNumber *number = [Info_ objectForKey:@"WallpaperAlpha"])
789 [WallpaperImage_ setAlpha:[number floatValue]];
790 [content addSubview:WallpaperImage_];
791 }
792
793 NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"];
794 if ([Manager_ fileExistsAtPath:html]) {
795 CGRect bounds = [content bounds];
796
797 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
798 [view setAutoresizes:true];
799
800 WallpaperPage_ = [view retain];
801 WallpaperURL_ = [[NSURL fileURLWithPath:html] retain];
802
803 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
804
805 [view setBackgroundColor:[UIColor clearColor]];
806 if ([view respondsToSelector:@selector(setDrawsBackground:)])
807 [view setDrawsBackground:NO];
808 [[view webView] setDrawsBackground:NO];
809
810 [content addSubview:view];
811 }
812 }
813
814 for (size_t i(0), e([themes_ count]); i != e; ++i) {
815 NSString *theme = [themes_ objectAtIndex:(e - i - 1)];
816 NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"];
817 if ([Manager_ fileExistsAtPath:html]) {
818 CGRect bounds = [content bounds];
819
820 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
821 [view setAutoresizes:true];
822
823 NSURL *url = [NSURL fileURLWithPath:html];
824 [view loadRequest:[NSURLRequest requestWithURL:url]];
825
826 [view setBackgroundColor:[UIColor clearColor]];
827 if ([view respondsToSelector:@selector(setDrawsBackground:)])
828 [view setDrawsBackground:NO];
829 [[view webView] setDrawsBackground:NO];
830
831 [content addSubview:view];
832 }
833 }
834
835 [content addSubview:layer];
836
837 return self;
838 }
839
840 MSHook(void, SBAwayView$updateDesktopImage$, SBAwayView *self, SEL sel, UIImage *image) {
841 NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]);
842 UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
843
844 if (path != nil && _backgroundView != nil)
845 path = nil;
846
847 _SBAwayView$updateDesktopImage$(self, sel, image);
848
849 if (path != nil) {
850 CGRect bounds = [self bounds];
851
852 UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
853 [view setAutoresizes:true];
854
855 if (WallpaperPage_ != nil)
856 [WallpaperPage_ release];
857 WallpaperPage_ = [view retain];
858
859 if (WallpaperURL_ != nil)
860 [WallpaperURL_ release];
861 WallpaperURL_ = [[NSURL fileURLWithPath:path] retain];
862
863 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
864
865 [[view webView] setDrawsBackground:false];
866 [view setBackgroundColor:[UIColor clearColor]];
867
868 [self insertSubview:view aboveSubview:_backgroundView];
869 }
870 }
871
872 /*extern "C" CGColorRef CGGStateGetSystemColor(void *);
873 extern "C" CGColorRef CGGStateGetFillColor(void *);
874 extern "C" CGColorRef CGGStateGetStrokeColor(void *);
875 extern "C" NSString *UIStyleStringFromColor(CGColorRef);*/
876
877 /* WBTimeLabel {{{ */
878 @interface WBTimeLabel : NSProxy {
879 NSString *time_;
880 _transient SBStatusBarTimeView *view_;
881 }
882
883 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view;
884
885 @end
886
887 @implementation WBTimeLabel
888
889 - (void) dealloc {
890 [time_ release];
891 [super dealloc];
892 }
893
894 - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view {
895 time_ = [time retain];
896 view_ = view;
897 return self;
898 }
899
900 - (NSString *) description {
901 return time_;
902 }
903
904 WBDelegate(time_)
905
906 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
907 if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
908 BOOL &_mode(MSHookIvar<BOOL>(view_, "_mode"));;
909
910 [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
911 "font-family: Helvetica; "
912 "font-weight: bold; "
913 "font-size: 14px; "
914 "color: %@; "
915 "%@", _mode ? @"white" : @"black", custom]];
916
917 return CGSizeZero;
918 }
919
920 return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
921 }
922
923 @end
924 /* }}} */
925 /* WBBadgeLabel {{{ */
926 @interface WBBadgeLabel : NSProxy {
927 NSString *badge_;
928 }
929
930 - (id) initWithBadge:(NSString *)badge;
931 - (NSString *) description;
932
933 @end
934
935 @implementation WBBadgeLabel
936
937 - (void) dealloc {
938 [badge_ release];
939 [super dealloc];
940 }
941
942 - (id) initWithBadge:(NSString *)badge {
943 badge_ = [badge retain];
944 return self;
945 }
946
947 - (NSString *) description {
948 return [badge_ description];
949 }
950
951 WBDelegate(badge_)
952
953 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
954 if (NSString *custom = [Info_ objectForKey:@"BadgeStyle"]) {
955 [badge_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
956 "font-family: Helvetica; "
957 "font-weight: bold; "
958 "font-size: 17px; "
959 "color: white; "
960 "%@", custom]];
961
962 return CGSizeZero;
963 }
964
965 return [badge_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
966 }
967
968 @end
969 /* }}} */
970
971 MSHook(void, SBIcon$setAlpha$, SBIcon *self, SEL sel, float alpha) {
972 if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
973 alpha = [number floatValue];
974 return _SBIcon$setAlpha$(self, sel, alpha);
975 }
976
977 MSHook(id, SBIconBadge$initWithBadge$, SBIconBadge *self, SEL sel, NSString *badge) {
978 if ((self = _SBIconBadge$initWithBadge$(self, sel, badge)) != nil) {
979 id &_badge(MSHookIvar<id>(self, "_badge"));
980 if (_badge != nil)
981 if (id label = [[WBBadgeLabel alloc] initWithBadge:[_badge autorelease]])
982 _badge = label;
983 } return self;
984 }
985
986 void SBStatusBarController$setStatusBarMode(int &mode) {
987 if (Debug_)
988 NSLog(@"WB:Debug:setStatusBarMode:%d", mode);
989 if (mode < 100) // 104:hidden 105:glowing
990 if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"])
991 mode = [number intValue];
992 }
993
994 /*MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, double duration, int animation) {
995 NSLog(@"mode:%d orientation:%d duration:%f animation:%d", mode, orientation, duration, animation);
996 SBStatusBarController$setStatusBarMode(mode);
997 return _SBStatusBarController$setStatusBarMode$orientation$duration$animation$(self, sel, mode, orientation, duration, animation);
998 }*/
999
1000 MSHook(void, SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$, SBStatusBarController *self, SEL sel, int mode, int orientation, float duration, int fenceID, int animation) {
1001 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d", mode, orientation, duration, fenceID, animation);
1002 SBStatusBarController$setStatusBarMode(mode);
1003 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(self, sel, mode, orientation, duration, fenceID, animation);
1004 }
1005
1006 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) {
1007 //NSLog(@"mode:%d orientation:%d duration:%f fenceID:%d animation:%d startTime:%f", mode, orientation, duration, fenceID, animation, startTime);
1008 SBStatusBarController$setStatusBarMode(mode);
1009 //NSLog(@"mode=%u", mode);
1010 return _SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$startTime$(self, sel, mode, orientation, duration, fenceID, animation, startTime);
1011 }
1012
1013 /*MSHook(id, SBStatusBarContentsView$initWithStatusBar$mode$, SBStatusBarContentsView *self, SEL sel, id bar, int mode) {
1014 if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"])
1015 mode = [number intValue];
1016 return _SBStatusBarContentsView$initWithStatusBar$mode$(self, sel, bar, mode);
1017 }*/
1018
1019 MSHook(NSString *, SBStatusBarOperatorNameView$operatorNameStyle, SBStatusBarOperatorNameView *self, SEL sel) {
1020 NSString *style(_SBStatusBarOperatorNameView$operatorNameStyle(self, sel));
1021 if (Debug_)
1022 NSLog(@"operatorNameStyle= %@", style);
1023 if (NSString *custom = [Info_ objectForKey:@"OperatorNameStyle"])
1024 style = [NSString stringWithFormat:@"%@; %@", style, custom];
1025 return style;
1026 }
1027
1028 MSHook(void, SBStatusBarOperatorNameView$setOperatorName$fullSize$, SBStatusBarOperatorNameView *self, SEL sel, NSString *name, BOOL full) {
1029 if (Debug_)
1030 NSLog(@"setOperatorName:\"%@\" fullSize:%u", name, full);
1031 return _SBStatusBarOperatorNameView$setOperatorName$fullSize$(self, sel, name, NO);
1032 }
1033
1034 // XXX: replace this with [SBStatusBarTimeView tile]
1035 MSHook(void, SBStatusBarTimeView$drawRect$, SBStatusBarTimeView *self, SEL sel, CGRect rect) {
1036 id &_time(MSHookIvar<id>(self, "_time"));
1037 if (_time != nil && [_time class] != [WBTimeLabel class])
1038 object_setInstanceVariable(self, "_time", reinterpret_cast<void *>([[WBTimeLabel alloc] initWithTime:[_time autorelease] view:self]));
1039 return _SBStatusBarTimeView$drawRect$(self, sel, rect);
1040 }
1041
1042 @interface UIView (WinterBoard)
1043 - (bool) wb$isWBImageView;
1044 - (void) wb$logHierarchy;
1045 @end
1046
1047 @implementation UIView (WinterBoard)
1048
1049 - (bool) wb$isWBImageView {
1050 return false;
1051 }
1052
1053 - (void) wb$logHierarchy {
1054 WBLogHierarchy(self);
1055 }
1056
1057 @end
1058
1059 @interface WBImageView : UIImageView {
1060 }
1061
1062 - (bool) wb$isWBImageView;
1063 - (void) wb$updateFrame;
1064 @end
1065
1066 @implementation WBImageView
1067
1068 - (bool) wb$isWBImageView {
1069 return true;
1070 }
1071
1072 - (void) wb$updateFrame {
1073 CGRect frame([self frame]);
1074 frame.origin.y = 0;
1075
1076 for (UIView *view(self); ; ) {
1077 view = [view superview];
1078 if (view == nil)
1079 break;
1080 frame.origin.y -= [view frame].origin.y;
1081 }
1082
1083 [self setFrame:frame];
1084 }
1085
1086 @end
1087
1088 MSHook(void, SBIconList$setFrame$, SBIconList *self, SEL sel, CGRect frame) {
1089 NSArray *subviews([self subviews]);
1090 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1091 if (view != nil && [view wb$isWBImageView])
1092 [view wb$updateFrame];
1093 _SBIconList$setFrame$(self, sel, frame);
1094 }
1095
1096 MSHook(void, SBIconController$noteNumberOfIconListsChanged, SBIconController *self, SEL sel) {
1097 SBIconModel *&_iconModel(MSHookIvar<SBIconModel *>(self, "_iconModel"));
1098 NSArray *lists([_iconModel iconLists]);
1099
1100 for (unsigned i(0), e([lists count]); i != e; ++i)
1101 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Page%u.png", i]])) {
1102 SBIconList *list([lists objectAtIndex:i]);
1103 NSArray *subviews([list subviews]);
1104
1105 WBImageView *view([subviews count] == 0 ? nil : [subviews objectAtIndex:0]);
1106 if (view == nil || ![view wb$isWBImageView]) {
1107 view = [[[WBImageView alloc] init] autorelease];
1108 [list insertSubview:view atIndex:0];
1109 }
1110
1111 UIImage *image([UIImage imageWithContentsOfFile:path]);
1112
1113 CGRect frame([view frame]);
1114 frame.size = [image size];
1115 [view setFrame:frame];
1116
1117 [view setImage:image];
1118 [view wb$updateFrame];
1119 }
1120
1121 return _SBIconController$noteNumberOfIconListsChanged(self, sel);
1122 }
1123
1124 MSHook(id, SBIconLabel$initWithSize$label$, SBIconLabel *self, SEL sel, CGSize size, NSString *label) {
1125 self = _SBIconLabel$initWithSize$label$(self, sel, size, label);
1126 if (self != nil)
1127 [self setClipsToBounds:NO];
1128 return self;
1129 }
1130
1131 MSHook(void, SBIconLabel$setInDock$, SBIconLabel *self, SEL sel, BOOL docked) {
1132 id &_label(MSHookIvar<id>(self, "_label"));
1133 if (![Info_ wb$boolForKey:@"UndockedIconLabels"])
1134 docked = true;
1135 if (_label != nil && [_label respondsToSelector:@selector(setInDock:)])
1136 [_label setInDock:docked];
1137 return _SBIconLabel$setInDock$(self, sel, docked);
1138 }
1139
1140 MSHook(NSString *, NSBundle$localizedStringForKey$value$table$, NSBundle *self, SEL sel, NSString *key, NSString *value, NSString *table) {
1141 NSString *identifier = [self bundleIdentifier];
1142 NSLocale *locale = [NSLocale currentLocale];
1143 NSString *language = [locale objectForKey:NSLocaleLanguageCode];
1144 if (Debug_)
1145 NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language);
1146 NSString *file = table == nil ? @"Localizable" : table;
1147 NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file];
1148 NSDictionary *strings;
1149 if ((strings = [Strings_ objectForKey:name]) != nil) {
1150 if (static_cast<id>(strings) != [NSNull null]) strings:
1151 if (NSString *value = [strings objectForKey:key])
1152 return value;
1153 } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
1154 language, file
1155 ], self, false)) {
1156 if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
1157 [Strings_ setObject:[strings autorelease] forKey:name];
1158 goto strings;
1159 } else goto null;
1160 } else null:
1161 [Strings_ setObject:[NSNull null] forKey:name];
1162 return _NSBundle$localizedStringForKey$value$table$(self, sel, key, value, table);
1163 }
1164
1165 @class WebCoreFrameBridge;
1166 MSHook(CGSize, WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$, WebCoreFrameBridge *self, SEL sel, id node, float width) {
1167 if (node == nil)
1168 return CGSizeZero;
1169 void **core(reinterpret_cast<void **>([node _node]));
1170 if (core == NULL || core[6] == NULL)
1171 return CGSizeZero;
1172 return _WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(self, sel, node, width);
1173 }
1174
1175 MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
1176 CGRect bounds = [self bounds];
1177
1178 static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
1179
1180 BOOL docked;
1181 Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
1182 docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
1183
1184 NSString *label(MSHookIvar<NSString *>(self, "_label"));
1185
1186 NSString *style = [NSString stringWithFormat:@""
1187 "font-family: Helvetica; "
1188 "font-weight: bold; "
1189 "font-size: 11px; "
1190 "color: %@; "
1191 "", docked ? @"white" : @"#b3b3b3"];
1192
1193 if (docked)
1194 style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
1195
1196 bool ellipsis(false);
1197 float max = 75, width;
1198 width:
1199 width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
1200
1201 if (width > max) {
1202 size_t length([label length]);
1203 float spacing((width - max) / (length - 1));
1204
1205 if (spacing > 1.25) {
1206 ellipsis = true;
1207 label = [label substringToIndex:(length - 1)];
1208 goto width;
1209 }
1210
1211 style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
1212 }
1213
1214 if (ellipsis)
1215 label = [label stringByAppendingString:@"..."];
1216
1217 if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
1218 style = [style stringByAppendingString:custom];
1219
1220 CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];
1221 [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
1222 }
1223
1224 MSHook(void, CKMessageCell$addBalloonView$, id self, SEL sel, CKBalloonView *balloon) {
1225 _CKMessageCell$addBalloonView$(self, sel, balloon);
1226 [balloon setBackgroundColor:[UIColor clearColor]];
1227 }
1228
1229 MSHook(id, CKMessageCell$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1230 if ((self = _CKMessageCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1231 [[self contentView] setBackgroundColor:[UIColor clearColor]];
1232 } return self;
1233 }
1234
1235 MSHook(id, CKTimestampView$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
1236 if ((self = _CKTimestampView$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
1237 UILabel *&_label(MSHookIvar<UILabel *>(self, "_label"));
1238 [_label setBackgroundColor:[UIColor clearColor]];
1239 } return self;
1240 }
1241
1242 MSHook(void, CKTranscriptTableView$setSeparatorStyle$, id self, SEL sel, int style) {
1243 _CKTranscriptTableView$setSeparatorStyle$(self, sel, UITableViewCellSeparatorStyleNone);
1244 }
1245
1246 MSHook(id, CKTranscriptTableView$initWithFrame$style$, id self, SEL sel, CGRect frame, int style) {
1247 _trace();
1248 if ((self = _CKTranscriptTableView$initWithFrame$style$(self, sel, frame, style)) != nil) {
1249 [self setSeparatorStyle:UITableViewCellSeparatorStyleNone];
1250 } return self;
1251 }
1252
1253 MSHook(void, TranscriptController$loadView, mSMSMessageTranscriptController *self, SEL sel) {
1254 _TranscriptController$loadView(self, sel);
1255
1256 if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
1257 if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
1258 [image autorelease];
1259
1260 UIView *&_transcriptTable(MSHookIvar<UIView *>(self, "_transcriptTable"));
1261 UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
1262 UIView *table;
1263 if (&_transcriptTable != NULL)
1264 table = _transcriptTable;
1265 else if (&_transcriptLayer != NULL)
1266 table = _transcriptLayer;
1267 else
1268 table = nil;
1269
1270 UIView *placard(table != nil ? [table superview] : MSHookIvar<UIView *>(self, "_backPlacard"));
1271 UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]);
1272
1273 if (table == nil)
1274 [placard insertSubview:background atIndex:0];
1275 else {
1276 [table setBackgroundColor:[UIColor clearColor]];
1277 [placard insertSubview:background belowSubview:table];
1278 }
1279 }
1280 }
1281
1282 MSHook(UIImage *, _UIImageWithName, NSString *name) {
1283 int id(_UISharedImageNameGetIdentifier(name));
1284 if (Debug_)
1285 NSLog(@"WB:Debug: _UIImageWithName(\"%@\": %d)", name, id);
1286
1287 if (id == -1)
1288 return _UIImageAtPath(name, _UIKitBundle());
1289 else {
1290 NSNumber *key([NSNumber numberWithInt:id]);
1291 UIImage *image = [UIImages_ objectForKey:key];
1292 if (image != nil)
1293 return reinterpret_cast<id>(image) == [NSNull null] ? _UISharedImageWithIdentifier(id) : image;
1294 if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {
1295 image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
1296 if (image != nil)
1297 [image autorelease];
1298 }
1299 [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1300 return image == nil ? _UISharedImageWithIdentifier(id) : image;
1301 }
1302 }
1303
1304 MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
1305 NSString *key([NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name]);
1306 UIImage *image([PathImages_ objectForKey:key]);
1307 if (image != nil)
1308 return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithNameInDomain(name, domain) : image;
1309 if (Debug_)
1310 NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);
1311 if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {
1312 image = [[UIImage alloc] initWithContentsOfFile:path];
1313 if (image != nil)
1314 [image autorelease];
1315 }
1316 [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
1317 return image == nil ? __UIImageWithNameInDomain(name, domain) : image;
1318 }
1319
1320 MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
1321 if (Debug_)
1322 NSLog(@"WB:Debug: GSFontCreateWithName(\"%s\", %f)", name, size);
1323 if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
1324 name = [font UTF8String];
1325 return _GSFontCreateWithName(name, traits, size);
1326 }
1327
1328 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
1329 #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
1330
1331 bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
1332
1333 MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
1334 if (Debug_)
1335 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %p, %u)", a0, a1, a2);
1336 bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
1337 if (Debug_)
1338 NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);
1339
1340 if (value) {
1341 NSString *path = [NSString stringWithUTF8String:a1];
1342 if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
1343 NSString *file = [path substringFromIndex:31];
1344 for (NSString *theme in themes_) {
1345 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
1346 if ([Manager_ fileExistsAtPath:path]) {
1347 strcpy(a1, [path UTF8String]);
1348 continue;
1349 }
1350 }
1351 }
1352 }
1353 return value;
1354 }
1355
1356 static void ChangeWallpaper(
1357 CFNotificationCenterRef center,
1358 void *observer,
1359 CFStringRef name,
1360 const void *object,
1361 CFDictionaryRef info
1362 ) {
1363 if (Debug_)
1364 NSLog(@"WB:Debug:ChangeWallpaper!");
1365
1366 UIImage *image;
1367 if (WallpaperFile_ != nil) {
1368 image = [[UIImage alloc] initWithContentsOfFile:WallpaperFile_];
1369 if (image != nil)
1370 image = [image autorelease];
1371 } else image = nil;
1372
1373 if (WallpaperImage_ != nil)
1374 [WallpaperImage_ setImage:image];
1375 if (WallpaperPage_ != nil)
1376 [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
1377
1378 }
1379
1380 #define WBRename(name, sel, imp) \
1381 _ ## name ## $ ## imp = MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp)
1382
1383 template <typename Type_>
1384 static void nlset(Type_ &function, struct nlist *nl, size_t index) {
1385 struct nlist &name(nl[index]);
1386 uintptr_t value(name.n_value);
1387 if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
1388 value |= 0x00000001;
1389 function = reinterpret_cast<Type_>(value);
1390 }
1391
1392 template <typename Type_>
1393 static void dlset(Type_ &function, const char *name) {
1394 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
1395 }
1396
1397 extern "C" void WBInitialize() {
1398 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
1399
1400 NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);
1401
1402 NSLog(@"WB:Notice: WinterBoard");
1403
1404 dlset(_GSFontGetUseLegacyFontMetrics, "GSFontGetUseLegacyFontMetrics");
1405
1406 struct nlist nl[8];
1407
1408 memset(nl, 0, sizeof(nl));
1409 nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName";
1410 nl[1].n_un.n_name = (char *) "__UIImageAtPath";
1411 nl[2].n_un.n_name = (char *) "__UIImageRefAtPath";
1412 nl[3].n_un.n_name = (char *) "__UIImageWithNameInDomain";
1413 nl[4].n_un.n_name = (char *) "__UIKitBundle";
1414 nl[5].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";
1415 nl[6].n_un.n_name = (char *) "__UISharedImageWithIdentifier";
1416 nlist(UIKit, nl);
1417
1418 nlset(_UIApplicationImageWithName, nl, 0);
1419 nlset(_UIImageAtPath, nl, 1);
1420 nlset(_UIImageRefAtPath, nl, 2);
1421 nlset(_UIImageWithNameInDomain, nl, 3);
1422 nlset(_UIKitBundle, nl, 4);
1423 nlset(_UISharedImageNameGetIdentifier, nl, 5);
1424 nlset(_UISharedImageWithIdentifier, nl, 6);
1425
1426 MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
1427 MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath);
1428 MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
1429 MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
1430
1431 MSHookFunction(&GSFontCreateWithName, &$GSFontCreateWithName, &_GSFontCreateWithName);
1432
1433 if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {
1434 struct nlist nl[2];
1435 memset(nl, 0, sizeof(nl));
1436 nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb";
1437 nlist(AudioToolbox, nl);
1438 nlset(_Z24GetFileNameForThisActionmPcRb, nl, 0);
1439 MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &__Z24GetFileNameForThisActionmPcRb);
1440 }
1441
1442 $NSBundle = objc_getClass("NSBundle");
1443
1444 _NSBundle$localizedStringForKey$value$table$ = MSHookMessage($NSBundle, @selector(localizedStringForKey:value:table:), &$NSBundle$localizedStringForKey$value$table$);
1445 _NSBundle$pathForResource$ofType$ = MSHookMessage($NSBundle, @selector(pathForResource:ofType:), &$NSBundle$pathForResource$ofType$);
1446
1447 $UIImage = objc_getClass("UIImage");
1448 $UINavigationBar = objc_getClass("UINavigationBar");
1449 $UIToolbar = objc_getClass("UIToolbar");
1450
1451 _UIImage$defaultDesktopImage = MSHookMessage(object_getClass($UIImage), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage);
1452
1453 //WBRename("UINavigationBar", @selector(initWithCoder:), (IMP) &UINavigationBar$initWithCoder$);
1454 //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:), (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
1455
1456 _UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$);
1457 _UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$);
1458
1459 Manager_ = [[NSFileManager defaultManager] retain];
1460 UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1461 PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];
1462 Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0];
1463 Bundles_ = [[NSMutableDictionary alloc] initWithCapacity:2];
1464 Themed_ = [[NSMutableDictionary alloc] initWithCapacity:128];
1465
1466 themes_ = [[NSMutableArray alloc] initWithCapacity:8];
1467
1468 if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
1469 if (NSNumber *value = [settings objectForKey:@"SummerBoard"])
1470 SummerBoard_ = [value boolValue];
1471 if (NSNumber *value = [settings objectForKey:@"Debug"])
1472 Debug_ = [value boolValue];
1473
1474 NSArray *themes([settings objectForKey:@"Themes"]);
1475 if (themes == nil)
1476 if (NSString *theme = [settings objectForKey:@"Theme"])
1477 themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
1478 theme, @"Name",
1479 [NSNumber numberWithBool:true], @"Active",
1480 nil]];
1481
1482 if (themes != nil)
1483 for (NSDictionary *theme in themes) {
1484 NSNumber *active([theme objectForKey:@"Active"]);
1485 if (![active boolValue])
1486 continue;
1487
1488 NSString *name([theme objectForKey:@"Name"]);
1489 if (name == nil)
1490 continue;
1491
1492 NSString *theme(nil);
1493
1494 #define testForTheme(format...) \
1495 if (theme == nil) { \
1496 NSString *path = [NSString stringWithFormat:format]; \
1497 if ([Manager_ fileExistsAtPath:path]) { \
1498 [themes_ addObject:path]; \
1499 continue; \
1500 } \
1501 }
1502
1503 testForTheme(@"/Library/Themes/%@.theme", name)
1504 testForTheme(@"/Library/Themes/%@", name)
1505 testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)
1506
1507 }
1508 }
1509
1510 Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
1511
1512 for (NSString *theme in themes_)
1513 if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])
1514 for (NSString *key in [info allKeys])
1515 if ([Info_ objectForKey:key] == nil)
1516 [Info_ setObject:[info objectForKey:key] forKey:key];
1517
1518 bool sms($getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]) != nil);
1519
1520 if ([NSBundle bundleWithIdentifier:@"com.apple.chatkit"])
1521 if (sms) {
1522 $CKMessageCell = objc_getClass("CKMessageCell");
1523 _CKMessageCell$addBalloonView$ = MSHookMessage($CKMessageCell, @selector(addBalloonView:), &$CKMessageCell$addBalloonView$);
1524 _CKMessageCell$initWithStyle$reuseIdentifier$ = MSHookMessage($CKMessageCell, @selector(initWithStyle:reuseIdentifier:), &$CKMessageCell$initWithStyle$reuseIdentifier$);
1525
1526 $CKTranscriptTableView = objc_getClass("CKTranscriptTableView");
1527 _CKTranscriptTableView$setSeparatorStyle$ = MSHookMessage($CKTranscriptTableView, @selector(setSeparatorStyle:), &$CKTranscriptTableView$setSeparatorStyle$);
1528 _CKTranscriptTableView$initWithFrame$style$ = MSHookMessage($CKTranscriptTableView, @selector(initWithFrame:style:), &$CKTranscriptTableView$initWithFrame$style$);
1529
1530 $CKTimestampView = objc_getClass("CKTimestampView");
1531 _CKTimestampView$initWithStyle$reuseIdentifier$ = MSHookMessage($CKTimestampView, @selector(initWithStyle:reuseIdentifier:), &$CKTimestampView$initWithStyle$reuseIdentifier$);
1532
1533 $CKTranscriptController = objc_getClass("CKTranscriptController");
1534 _TranscriptController$loadView = MSHookMessage($CKTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1535 }
1536
1537 if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
1538 if (sms) {
1539 if (_TranscriptController$loadView == NULL) {
1540 Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
1541 _TranscriptController$loadView = MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), &$TranscriptController$loadView);
1542 }
1543 }
1544 } else if ([identifier isEqualToString:@"com.apple.springboard"]) {
1545 CFNotificationCenterAddObserver(
1546 CFNotificationCenterGetDarwinNotifyCenter(),
1547 NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0
1548 );
1549
1550 /*
1551 if ($getTheme$([NSArray arrayWithObjects:@"Wallpaper.mp4"]) != nil) {
1552 NSBundle *MediaPlayer([NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"]);
1553 if (MediaPlayer != nil)
1554 [MediaPlayer load];
1555
1556 $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
1557 $MPVideoView = objc_getClass("MPVideoView");
1558 }*/
1559
1560 $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
1561
1562 $SBApplication = objc_getClass("SBApplication");
1563 $SBApplicationIcon = objc_getClass("SBApplicationIcon");
1564 $SBAwayView = objc_getClass("SBAwayView");
1565 $SBBookmarkIcon = objc_getClass("SBBookmarkIcon");
1566 $SBButtonBar = objc_getClass("SBButtonBar");
1567 $SBCalendarIconContentsView = objc_getClass("SBCalendarIconContentsView");
1568 $SBIcon = objc_getClass("SBIcon");
1569 $SBIconBadge = objc_getClass("SBIconBadge");
1570 $SBIconController = objc_getClass("SBIconController");
1571 $SBIconLabel = objc_getClass("SBIconLabel");
1572 $SBIconList = objc_getClass("SBIconList");
1573 $SBIconModel = objc_getClass("SBIconModel");
1574 //$SBImageCache = objc_getClass("SBImageCache");
1575 $SBSearchView = objc_getClass("SBSearchView");
1576 $SBSearchTableViewCell = objc_getClass("SBSearchTableViewCell");
1577 $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
1578 $SBStatusBarController = objc_getClass("SBStatusBarController");
1579 $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
1580 $SBStatusBarTimeView = objc_getClass("SBStatusBarTimeView");
1581 $SBUIController = objc_getClass("SBUIController");
1582 $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon");
1583
1584 WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$);
1585
1586 if (SummerBoard_) {
1587 WBRename(SBApplication, pathForIcon, pathForIcon);
1588 WBRename(SBApplicationIcon, icon, icon);
1589 }
1590
1591 WBRename(SBBookmarkIcon, icon, icon);
1592 WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview);
1593 WBRename(SBCalendarIconContentsView, drawRect:, drawRect$);
1594 WBRename(SBIcon, setAlpha:, setAlpha$);
1595 WBRename(SBIconBadge, initWithBadge:, initWithBadge$);
1596 WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged);
1597 WBRename(SBUIController, init, init);
1598 WBRename(SBWidgetApplicationIcon, icon, icon);
1599
1600 WBRename(SBIconLabel, drawRect:, drawRect$);
1601 WBRename(SBIconLabel, initWithSize:label:, initWithSize$label$);
1602 WBRename(SBIconLabel, setInDock:, setInDock$);
1603
1604 WBRename(SBIconList, setFrame:, setFrame$);
1605
1606 WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
1607 WBRename(SBIconModel, cacheImagesForIcon:, cacheImagesForIcon$);
1608 WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
1609 WBRename(SBIconModel, getCachedImagedForIcon:smallIcon:, getCachedImagedForIcon$smallIcon$);
1610
1611 WBRename(SBSearchView, initWithFrame:, initWithFrame$);
1612 WBRename(SBSearchTableViewCell, drawRect:, drawRect$);
1613 WBRename(SBSearchTableViewCell, initWithStyle:reuseIdentifier:, initWithStyle$reuseIdentifier$);
1614
1615 //WBRename(SBImageCache, initWithName:forImageWidth:imageHeight:initialCapacity:, initWithName$forImageWidth$imageHeight$initialCapacity$);
1616
1617 WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
1618 WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
1619 //WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
1620 //WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:animation:, setStatusBarMode$orientation$duration$animation$);
1621 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:, setStatusBarMode$orientation$duration$fenceID$animation$);
1622 WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:fenceID:animation:startTime:, setStatusBarMode$orientation$duration$fenceID$animation$startTime$);
1623 WBRename(SBStatusBarOperatorNameView, operatorNameStyle, operatorNameStyle);
1624 WBRename(SBStatusBarOperatorNameView, setOperatorName:fullSize:, setOperatorName$fullSize$);
1625 WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
1626
1627 if (SummerBoard_)
1628 English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
1629
1630 Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
1631 }
1632
1633 Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
1634
1635 if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
1636 [Info_ setObject:[NSNumber numberWithBool:(
1637 $getTheme$(Wallpapers_) == nil ||
1638 [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
1639 [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
1640 )] forKey:@"UndockedIconLabels"];
1641
1642 if (Debug_)
1643 NSLog(@"WB:Debug:Info = %@", [Info_ description]);
1644
1645 [pool release];
1646 }