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