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