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