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