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