]>
Commit | Line | Data |
---|---|---|
d5168fd6 JF |
1 | /* WinterBoard - Theme Manager for the iPhone |
2 | * Copyright (C) 2008 Jay Freeman (saurik) | |
3 | */ | |
4 | ||
5 | /* | |
6 | * Redistribution and use in source and binary | |
7 | * forms, with or without modification, are permitted | |
8 | * provided that the following conditions are met: | |
9 | * | |
10 | * 1. Redistributions of source code must retain the | |
11 | * above copyright notice, this list of conditions | |
12 | * and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the | |
14 | * above copyright notice, this list of conditions | |
15 | * and the following disclaimer in the documentation | |
16 | * and/or other materials provided with the | |
17 | * distribution. | |
18 | * 3. The name of the author may not be used to endorse | |
19 | * or promote products derived from this software | |
20 | * without specific prior written permission. | |
21 | * | |
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' | |
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | |
24 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE | |
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
32 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
33 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
35 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | |
37 | ||
889cb4f2 | 38 | #define _trace() NSLog(@"WB:_trace(%u)", __LINE__); |
ca13798d | 39 | #define _transient |
62b2dbad | 40 | |
e6f0817b | 41 | #import <CoreFoundation/CoreFoundation.h> |
d5168fd6 | 42 | #import <Foundation/Foundation.h> |
2435118f | 43 | #import <CoreGraphics/CoreGraphics.h> |
d5168fd6 | 44 | |
2acbe5b8 JF |
45 | #include <substrate.h> |
46 | ||
4668cd8e | 47 | #import <UIKit/UIKit.h> |
d5168fd6 JF |
48 | |
49 | #import <SpringBoard/SBApplication.h> | |
394d1eb5 | 50 | #import <SpringBoard/SBApplicationIcon.h> |
d5168fd6 | 51 | #import <SpringBoard/SBAppWindow.h> |
502d350e | 52 | #import <SpringBoard/SBBookmarkIcon.h> |
62b2dbad | 53 | #import <SpringBoard/SBButtonBar.h> |
e6f0817b | 54 | #import <SpringBoard/SBCalendarIconContentsView.h> |
d5168fd6 | 55 | #import <SpringBoard/SBContentLayer.h> |
95a5777b | 56 | #import <SpringBoard/SBIconController.h> |
889cb4f2 | 57 | #import <SpringBoard/SBIconLabel.h> |
502d350e | 58 | #import <SpringBoard/SBSlidingAlertDisplay.h> |
08454e3a | 59 | #import <SpringBoard/SBStatusBarContentsView.h> |
d5fb6e01 | 60 | #import <SpringBoard/SBStatusBarController.h> |
4668cd8e | 61 | #import <SpringBoard/SBStatusBarOperatorNameView.h> |
08454e3a | 62 | #import <SpringBoard/SBStatusBarTimeView.h> |
d5168fd6 JF |
63 | #import <SpringBoard/SBUIController.h> |
64 | ||
4668cd8e JF |
65 | #import <MobileSMS/mSMSMessageTranscriptController.h> |
66 | ||
d5fb6e01 JF |
67 | #import <MediaPlayer/MPVideoView.h> |
68 | #import <MediaPlayer/MPVideoView-PlaybackControl.h> | |
69 | ||
d5168fd6 JF |
70 | #import <CoreGraphics/CGGeometry.h> |
71 | ||
95a5777b JF |
72 | extern "C" void __clear_cache (char *beg, char *end); |
73 | ||
74 | Class $MPVideoView; | |
75 | ||
26c43b47 JF |
76 | @interface NSDictionary (WinterBoard) |
77 | - (UIColor *) colorForKey:(NSString *)key; | |
889cb4f2 | 78 | - (BOOL) boolForKey:(NSString *)key; |
26c43b47 JF |
79 | @end |
80 | ||
81 | @implementation NSDictionary (WinterBoard) | |
82 | ||
83 | - (UIColor *) colorForKey:(NSString *)key { | |
84 | NSString *value = [self objectForKey:key]; | |
85 | if (value == nil) | |
86 | return nil; | |
87 | /* XXX: incorrect */ | |
88 | return nil; | |
89 | } | |
90 | ||
889cb4f2 JF |
91 | - (BOOL) boolForKey:(NSString *)key { |
92 | if (NSString *value = [self objectForKey:key]) | |
93 | return [value boolValue]; | |
95a5777b | 94 | return false; |
889cb4f2 JF |
95 | } |
96 | ||
26c43b47 JF |
97 | @end |
98 | ||
f22a8989 | 99 | bool Debug_ = false; |
e6f0817b | 100 | bool Engineer_ = false; |
889cb4f2 | 101 | |
d5168fd6 | 102 | @protocol WinterBoard |
4668cd8e JF |
103 | - (void) wb$setOperatorName:(NSString *)name fullSize:(BOOL)full; |
104 | - (NSString *) wb$operatorNameStyle; | |
105 | - (void) wb$loadView; | |
2acbe5b8 JF |
106 | - (NSString *) wb$localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)table; |
107 | - (id) wb$initWithBadge:(id)badge; | |
108 | - (void) wb$cacheImageForIcon:(SBIcon *)icon; | |
109 | - (UIImage *) wb$getCachedImagedForIcon:(SBIcon *)icon; | |
110 | - (CGSize) wb$renderedSizeOfNode:(id)node constrainedToWidth:(float)width; | |
7ff778ee | 111 | - (void *) _node; |
2acbe5b8 JF |
112 | - (void) wb$updateDesktopImage:(UIImage *)image; |
113 | - (UIImage *) wb$defaultDesktopImage; | |
114 | - (NSString *) wb$pathForIcon; | |
115 | - (NSString *) wb$pathForResource:(NSString *)resource ofType:(NSString *)type; | |
116 | - (id) wb$init; | |
117 | - (id) wb$layer; | |
118 | - (id) wb$initWithSize:(CGSize)size; | |
119 | - (id) wb$initWithSize:(CGSize)size label:(NSString *)label; | |
120 | - (id) wb$initWithFrame:(CGRect)frame; | |
121 | - (id) wb$initWithCoder:(NSCoder *)coder; | |
122 | - (void) wb$setFrame:(CGRect)frame; | |
123 | - (void) wb$drawRect:(CGRect)rect; | |
124 | - (void) wb$setBackgroundColor:(id)color; | |
125 | - (void) wb$setAlpha:(float)value; | |
126 | - (void) wb$setBarStyle:(int)style; | |
127 | - (id) wb$initWithFrame:(CGRect)frame withBarStyle:(int)style withTintColor:(UIColor *)color; | |
128 | - (void) wb$setOpaque:(BOOL)opaque; | |
129 | - (void) wb$setInDock:(BOOL)docked; | |
130 | - (void) wb$didMoveToSuperview; | |
131 | + (UIImage *) wb$imageNamed:(NSString *)name inBundle:(NSBundle *)bundle; | |
132 | + (UIImage *) wb$applicationImageNamed:(NSString *)name; | |
133 | - (NSDictionary *) wb$infoDictionary; | |
134 | - (UIImage *) wb$icon; | |
135 | - (void) wb$appendIconList:(SBIconList *)list; | |
136 | - (id) wb$initWithStatusBar:(id)bar mode:(int)mode; | |
137 | - (id) wb$initWithMode:(int)mode orientation:(int)orientation; | |
138 | - (id) wb$imageAtPath:(NSString *)path; | |
139 | - (id) wb$initWithContentsOfFile:(NSString *)file; | |
140 | - (id) wb$initWithContentsOfFile:(NSString *)file cache:(BOOL)cache; | |
141 | - (void) wb$setStatusBarMode:(int)mode orientation:(int)orientation duration:(float)duration fenceID:(int)id animation:(int)animation; | |
d5168fd6 JF |
142 | @end |
143 | ||
502d350e JF |
144 | static NSMutableDictionary *UIImages_; |
145 | static NSMutableDictionary *PathImages_; | |
4668cd8e JF |
146 | static NSMutableDictionary *Cache_; |
147 | static NSMutableDictionary *Strings_; | |
2435118f | 148 | |
502d350e JF |
149 | static NSFileManager *Manager_; |
150 | static NSDictionary *English_; | |
151 | static NSMutableDictionary *Info_; | |
152 | static NSMutableArray *themes_; | |
d5168fd6 | 153 | |
4668cd8e | 154 | static NSString *$getTheme$(NSArray *files, bool parent = false) { |
2acbe5b8 JF |
155 | if (Debug_) |
156 | NSLog(@"WB:Debug: %@", [files description]); | |
157 | ||
502d350e JF |
158 | for (NSString *theme in themes_) |
159 | for (NSString *file in files) { | |
160 | NSString *path([NSString stringWithFormat:@"%@/%@", theme, file]); | |
161 | if ([Manager_ fileExistsAtPath:path]) | |
4668cd8e | 162 | return parent ? theme : path; |
502d350e JF |
163 | } |
164 | ||
165 | return nil; | |
166 | } | |
167 | ||
168 | static NSString *$pathForIcon$(SBApplication<WinterBoard> *self) { | |
2acbe5b8 JF |
169 | NSString *identifier = [self bundleIdentifier]; |
170 | NSString *path = [self path]; | |
171 | NSString *folder = [path lastPathComponent]; | |
172 | NSString *dname = [self displayName]; | |
173 | NSString *didentifier = [self displayIdentifier]; | |
d5fb6e01 | 174 | |
2acbe5b8 JF |
175 | if (Debug_) |
176 | NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier); | |
62b2dbad | 177 | |
2acbe5b8 | 178 | NSMutableArray *names = [NSMutableArray arrayWithCapacity:8]; |
d5fb6e01 | 179 | |
2acbe5b8 JF |
180 | if (identifier != nil) |
181 | [names addObject:[NSString stringWithFormat:@"Bundles/%@/icon.png", identifier]]; | |
182 | if (folder != nil) | |
183 | [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]]; | |
889cb4f2 | 184 | |
2acbe5b8 JF |
185 | #define testForIcon(Name) \ |
186 | if (NSString *name = Name) \ | |
187 | [names addObject:[NSString stringWithFormat:@"Icons/%@.png", name]]; | |
ca13798d | 188 | |
2acbe5b8 JF |
189 | testForIcon(identifier); |
190 | testForIcon(dname); | |
889cb4f2 | 191 | |
2acbe5b8 JF |
192 | if (didentifier != nil) { |
193 | testForIcon([English_ objectForKey:didentifier]); | |
889cb4f2 | 194 | |
2acbe5b8 JF |
195 | NSArray *parts = [didentifier componentsSeparatedByString:@"-"]; |
196 | if ([parts count] != 1) | |
197 | if (NSDictionary *english = [[[NSDictionary alloc] initWithContentsOfFile:[path stringByAppendingString:@"/English.lproj/UIRoleDisplayNames.strings"]] autorelease]) | |
198 | testForIcon([english objectForKey:[parts lastObject]]); | |
d5fb6e01 | 199 | } |
889cb4f2 | 200 | |
2acbe5b8 JF |
201 | if (NSString *path = $getTheme$(names)) |
202 | return path; | |
394d1eb5 JF |
203 | return nil; |
204 | } | |
205 | ||
4e0efa01 | 206 | static void SBIconModel$cacheImageForIcon$(SBIconModel<WinterBoard> *self, SEL sel, SBIcon *icon) { |
2acbe5b8 | 207 | [self wb$cacheImageForIcon:icon]; |
4e0efa01 | 208 | NSString *key([icon displayIdentifier]); |
2acbe5b8 JF |
209 | |
210 | if (UIImage *image = [icon icon]) { | |
211 | CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB()); | |
212 | CGRect rect = {CGPointMake(1, 1), [image size]}; | |
213 | CGSize size = {rect.size.width + 2, rect.size.height + 2}; | |
214 | ||
215 | CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst)); | |
216 | CGColorSpaceRelease(space); | |
217 | ||
218 | CGContextDrawImage(context, rect, [image CGImage]); | |
219 | CGImageRef ref(CGBitmapContextCreateImage(context)); | |
220 | CGContextRelease(context); | |
221 | ||
222 | UIImage *image([UIImage imageWithCGImage:ref]); | |
223 | CGImageRelease(ref); | |
224 | ||
225 | [Cache_ setObject:image forKey:key]; | |
226 | } | |
4e0efa01 JF |
227 | } |
228 | ||
229 | static UIImage *SBIconModel$getCachedImagedForIcon$(SBIconModel<WinterBoard> *self, SEL sel, SBIcon *icon) { | |
230 | NSString *key([icon displayIdentifier]); | |
231 | if (UIImage *image = [Cache_ objectForKey:key]) | |
232 | return image; | |
233 | else | |
2acbe5b8 | 234 | return [self wb$getCachedImagedForIcon:icon]; |
4e0efa01 JF |
235 | } |
236 | ||
394d1eb5 | 237 | static UIImage *SBApplicationIcon$icon(SBApplicationIcon<WinterBoard> *self, SEL sel) { |
d5fb6e01 | 238 | if (![Info_ boolForKey:@"ComposeStoreIcons"]) |
56539693 | 239 | if (NSString *path = $pathForIcon$([self application])) |
2acbe5b8 JF |
240 | return [UIImage imageWithContentsOfFile:path]; |
241 | return [self wb$icon]; | |
394d1eb5 JF |
242 | } |
243 | ||
502d350e JF |
244 | static UIImage *SBBookmarkIcon$icon(SBBookmarkIcon<WinterBoard> *self, SEL sel) { |
245 | if (Debug_) | |
246 | NSLog(@"WB:Debug:Bookmark(%@:%@)", [self displayIdentifier], [self displayName]); | |
247 | if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]])) | |
2acbe5b8 JF |
248 | return [UIImage imageWithContentsOfFile:path]; |
249 | return [self wb$icon]; | |
502d350e JF |
250 | } |
251 | ||
394d1eb5 | 252 | static NSString *SBApplication$pathForIcon(SBApplication<WinterBoard> *self, SEL sel) { |
d5fb6e01 JF |
253 | if (NSString *path = $pathForIcon$(self)) |
254 | return path; | |
2acbe5b8 | 255 | return [self wb$pathForIcon]; |
d5168fd6 JF |
256 | } |
257 | ||
502d350e | 258 | static NSString *$pathForFile$inBundle$(NSString *file, NSBundle<WinterBoard> *bundle, bool ui) { |
2acbe5b8 JF |
259 | NSString *identifier = [bundle bundleIdentifier]; |
260 | NSMutableArray *names = [NSMutableArray arrayWithCapacity:8]; | |
261 | ||
262 | if (identifier != nil) | |
263 | [names addObject:[NSString stringWithFormat:@"Bundles/%@/%@", identifier, file]]; | |
264 | if (NSString *folder = [[bundle bundlePath] lastPathComponent]) | |
265 | [names addObject:[NSString stringWithFormat:@"Folders/%@/%@", folder, file]]; | |
266 | if (ui) | |
7dd9f26e | 267 | [names addObject:[NSString stringWithFormat:@"UIImages/%@", file]]; |
2acbe5b8 JF |
268 | |
269 | #define remapResourceName(oldname, newname) \ | |
270 | else if ([file isEqualToString:oldname]) \ | |
271 | [names addObject:[NSString stringWithFormat:@"%@.png", newname]]; \ | |
272 | ||
273 | if (identifier == nil); | |
274 | else if ([identifier isEqualToString:@"com.apple.calculator"]) | |
275 | [names addObject:[NSString stringWithFormat:@"Files/Applications/Calculator.app/%@", file]]; | |
276 | else if (![identifier isEqualToString:@"com.apple.springboard"]); | |
277 | remapResourceName(@"FSO_BG.png", @"StatusBar") | |
278 | remapResourceName(@"SBDockBG.png", @"Dock") | |
279 | remapResourceName(@"SBWeatherCelsius.png", @"Icons/Weather") | |
280 | ||
281 | if (NSString *path = $getTheme$(names)) | |
282 | return path; | |
889cb4f2 JF |
283 | return nil; |
284 | } | |
285 | ||
95a5777b JF |
286 | static UIImage *CachedImageAtPath(NSString *path) { |
287 | UIImage *image = [PathImages_ objectForKey:path]; | |
288 | if (image != nil) | |
289 | return reinterpret_cast<id>(image) == [NSNull null] ? nil : image; | |
2acbe5b8 | 290 | image = [[UIImage alloc] wb$initWithContentsOfFile:path cache:true]; |
95a5777b JF |
291 | if (image != nil) |
292 | image = [image autorelease]; | |
293 | [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:path]; | |
294 | return image; | |
295 | } | |
296 | ||
394d1eb5 | 297 | static UIImage *UIImage$imageNamed$inBundle$(Class<WinterBoard> self, SEL sel, NSString *name, NSBundle *bundle) { |
e6f0817b | 298 | NSString *key = [NSString stringWithFormat:@"B:%@/%@", [bundle bundleIdentifier], name]; |
95a5777b JF |
299 | UIImage *image = [PathImages_ objectForKey:key]; |
300 | if (image != nil) | |
301 | return reinterpret_cast<id>(image) == [NSNull null] ? nil : image; | |
889cb4f2 JF |
302 | if (Debug_) |
303 | NSLog(@"WB:Debug: [UIImage(%@) imageNamed:\"%@\"]", [bundle bundleIdentifier], name); | |
95a5777b JF |
304 | if (NSString *path = $pathForFile$inBundle$(name, bundle, false)) |
305 | image = CachedImageAtPath(path); | |
306 | if (image == nil) | |
2acbe5b8 | 307 | image = [self wb$imageNamed:name inBundle:bundle]; |
95a5777b JF |
308 | [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key]; |
309 | return image; | |
889cb4f2 JF |
310 | } |
311 | ||
394d1eb5 | 312 | static UIImage *UIImage$imageNamed$(Class<WinterBoard> self, SEL sel, NSString *name) { |
889cb4f2 JF |
313 | return UIImage$imageNamed$inBundle$(self, sel, name, [NSBundle mainBundle]); |
314 | } | |
315 | ||
d5fb6e01 JF |
316 | static UIImage *UIImage$applicationImageNamed$(Class<WinterBoard> self, SEL sel, NSString *name) { |
317 | NSBundle *bundle = [NSBundle mainBundle]; | |
318 | if (Debug_) | |
319 | NSLog(@"WB:Debug: [UIImage(%@) applicationImageNamed:\"%@\"]", [bundle bundleIdentifier], name); | |
95a5777b JF |
320 | if (NSString *path = $pathForFile$inBundle$(name, bundle, false)) |
321 | return CachedImageAtPath(path); | |
2acbe5b8 | 322 | return [self wb$applicationImageNamed:name]; |
d5fb6e01 JF |
323 | } |
324 | ||
502d350e | 325 | @interface NSString (WinterBoard) |
2acbe5b8 | 326 | - (NSString *) wb$themedPath; |
502d350e JF |
327 | @end |
328 | ||
329 | @implementation NSString (WinterBoard) | |
330 | ||
2acbe5b8 | 331 | - (NSString *) wb$themedPath { |
e6f0817b JF |
332 | if (Debug_) |
333 | NSLog(@"WB:Debug:Bypass(\"%@\")", self); | |
2acbe5b8 JF |
334 | |
335 | if (NSBundle *bundle = [NSBundle mainBundle]) { | |
336 | NSString *prefix([bundle bundlePath]); | |
337 | if ([self hasPrefix:prefix]) { | |
338 | NSUInteger length([prefix length]); | |
339 | if (length != [self length]) | |
340 | if (NSString *path = $pathForFile$inBundle$([self substringFromIndex:(length + 1)], bundle, false)) | |
341 | return path; | |
342 | } | |
343 | } | |
344 | ||
502d350e JF |
345 | return self; |
346 | } | |
347 | ||
348 | @end | |
349 | ||
502d350e JF |
350 | #define WBDelegate(delegate) \ |
351 | - (NSMethodSignature*) methodSignatureForSelector:(SEL)sel { \ | |
352 | if (Engineer_) \ | |
353 | NSLog(@"WB:MS:%s:(%s)", class_getName([self class]), sel_getName(sel)); \ | |
354 | if (NSMethodSignature *sig = [delegate methodSignatureForSelector:sel]) \ | |
355 | return sig; \ | |
356 | NSLog(@"WB:Error: [%s methodSignatureForSelector:(%s)]", class_getName([self class]), sel_getName(sel)); \ | |
357 | return nil; \ | |
358 | } \ | |
359 | \ | |
360 | - (void) forwardInvocation:(NSInvocation*)inv { \ | |
361 | SEL sel = [inv selector]; \ | |
362 | if ([delegate respondsToSelector:sel]) \ | |
363 | [inv invokeWithTarget:delegate]; \ | |
364 | else \ | |
365 | NSLog(@"WB:Error: [%s forwardInvocation:(%s)]", class_getName([self class]), sel_getName(sel)); \ | |
366 | } | |
367 | ||
394d1eb5 | 368 | static NSString *NSBundle$pathForResource$ofType$(NSBundle<WinterBoard> *self, SEL sel, NSString *resource, NSString *type) { |
889cb4f2 JF |
369 | NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type]; |
370 | if (Debug_) | |
371 | NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file); | |
95a5777b | 372 | if (NSString *path = $pathForFile$inBundle$(file, self, false)) |
ca13798d | 373 | return path; |
2acbe5b8 | 374 | return [self wb$pathForResource:resource ofType:type]; |
d5168fd6 JF |
375 | } |
376 | ||
502d350e | 377 | static bool $setBarStyle$_(NSString *name, UIView<WinterBoard> *self, int style) { |
95a5777b JF |
378 | if (Debug_) |
379 | NSLog(@"WB:Debug:%@Style:%d", name, style); | |
380 | NSNumber *number = nil; | |
381 | if (number == nil) | |
382 | number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style-%d", name, style]]; | |
383 | if (number == nil) | |
384 | number = [Info_ objectForKey:[NSString stringWithFormat:@"%@Style", name]]; | |
385 | if (number == nil) | |
386 | return false; | |
387 | else { | |
388 | style = [number intValue]; | |
389 | if (Debug_) | |
390 | NSLog(@"WB:Debug:%@Style=%d", name, style); | |
2acbe5b8 | 391 | [self wb$setBarStyle:style]; |
d5fb6e01 | 392 | return true; |
26c43b47 | 393 | } |
26c43b47 JF |
394 | } |
395 | ||
e6f0817b | 396 | static void SBCalendarIconContentsView$drawRect$(SBCalendarIconContentsView<WinterBoard> *self, SEL sel, CGRect rect) { |
4668cd8e JF |
397 | NSBundle *bundle([NSBundle mainBundle]); |
398 | ||
e6f0817b JF |
399 | CFLocaleRef locale(CFLocaleCopyCurrent()); |
400 | CFDateFormatterRef formatter(CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle)); | |
401 | CFRelease(locale); | |
402 | ||
403 | CFDateRef now(CFDateCreate(NULL, CFAbsoluteTimeGetCurrent())); | |
404 | ||
4668cd8e | 405 | CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NUMBER_FORMAT" value:@"" table:@"SpringBoard"]); |
e6f0817b | 406 | CFStringRef date(CFDateFormatterCreateStringWithDate(NULL, formatter, now)); |
4668cd8e | 407 | CFDateFormatterSetFormat(formatter, (CFStringRef) [bundle localizedStringForKey:@"CALENDAR_ICON_DAY_NAME_FORMAT" value:@"" table:@"SpringBoard"]); |
e6f0817b JF |
408 | CFStringRef day(CFDateFormatterCreateStringWithDate(NULL, formatter, now)); |
409 | ||
410 | CFRelease(now); | |
411 | ||
412 | CFRelease(formatter); | |
413 | ||
414 | NSString *datestyle(@"" | |
415 | "font-family: Helvetica; " | |
416 | "font-weight: bold; " | |
417 | "font-size: 39px; " | |
418 | "color: #333333; " | |
419 | "alpha: 1.0; " | |
420 | ""); | |
421 | ||
422 | NSString *daystyle(@"" | |
423 | "font-family: Helvetica; " | |
424 | "font-weight: bold; " | |
425 | "font-size: 9px; " | |
426 | "color: white; " | |
427 | "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px; " | |
428 | ""); | |
429 | ||
430 | if (NSString *style = [Info_ objectForKey:@"CalendarIconDateStyle"]) | |
431 | datestyle = [datestyle stringByAppendingString:style]; | |
432 | if (NSString *style = [Info_ objectForKey:@"CalendarIconDayStyle"]) | |
433 | daystyle = [daystyle stringByAppendingString:style]; | |
434 | ||
cf31d246 | 435 | float width([self bounds].size.width); |
4668cd8e JF |
436 | float leeway(10); |
437 | CGSize datesize = [(NSString *)date sizeWithStyle:datestyle forWidth:(width + leeway)]; | |
438 | CGSize daysize = [(NSString *)day sizeWithStyle:daystyle forWidth:(width + leeway)]; | |
e6f0817b JF |
439 | |
440 | [(NSString *)date drawAtPoint:CGPointMake( | |
4668cd8e | 441 | (width + 1 - datesize.width) / 2, (71 - datesize.height) / 2 |
e6f0817b JF |
442 | ) withStyle:datestyle]; |
443 | ||
444 | [(NSString *)day drawAtPoint:CGPointMake( | |
4668cd8e | 445 | (width + 1 - daysize.width) / 2, (16 - daysize.height) / 2 |
e6f0817b JF |
446 | ) withStyle:daystyle]; |
447 | ||
448 | CFRelease(date); | |
449 | CFRelease(day); | |
450 | } | |
451 | ||
502d350e | 452 | /*static id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) { |
26c43b47 JF |
453 | _trace(); |
454 | ||
d5fb6e01 JF |
455 | if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"]) |
456 | style = [number intValue]; | |
26c43b47 | 457 | |
d5fb6e01 JF |
458 | if (UIColor *color = [Info_ colorForKey:@"NavigationBarTint"]) |
459 | tint = color; | |
26c43b47 | 460 | |
2acbe5b8 | 461 | return [self wb$initWithFrame:frame withBarStyle:style withTintColor:tint]; |
26c43b47 JF |
462 | }*/ |
463 | ||
502d350e | 464 | /*static id UINavigationBar$initWithCoder$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame, NSCoder *coder) { |
2acbe5b8 | 465 | self = [self wb$initWithCoder:coder]; |
26c43b47 JF |
466 | if (self == nil) |
467 | return nil; | |
468 | UINavigationBar$setBarStyle$_(self); | |
469 | return self; | |
470 | } | |
471 | ||
502d350e | 472 | static id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRect frame) { |
2acbe5b8 | 473 | self = [self wb$initWithFrame:frame]; |
26c43b47 JF |
474 | if (self == nil) |
475 | return nil; | |
476 | UINavigationBar$setBarStyle$_(self); | |
477 | return self; | |
478 | }*/ | |
479 | ||
95a5777b JF |
480 | static void UIToolbar$setBarStyle$(UIToolbar<WinterBoard> *self, SEL sel, int style) { |
481 | if ($setBarStyle$_(@"Toolbar", self, style)) | |
482 | return; | |
2acbe5b8 | 483 | return [self wb$setBarStyle:style]; |
95a5777b JF |
484 | } |
485 | ||
486 | static void UINavigationBar$setBarStyle$(UINavigationBar<WinterBoard> *self, SEL sel, int style) { | |
487 | if ($setBarStyle$_(@"NavigationBar", self, style)) | |
26c43b47 | 488 | return; |
2acbe5b8 | 489 | return [self wb$setBarStyle:style]; |
26c43b47 JF |
490 | } |
491 | ||
394d1eb5 | 492 | static void $didMoveToSuperview(SBButtonBar<WinterBoard> *self, SEL sel) { |
2acbe5b8 JF |
493 | [[self superview] setBackgroundColor:[UIColor clearColor]]; |
494 | [self wb$didMoveToSuperview]; | |
08454e3a | 495 | } |
62b2dbad | 496 | |
502d350e | 497 | static id UIImage$imageAtPath$(NSObject<WinterBoard> *self, SEL sel, NSString *path) { |
2acbe5b8 | 498 | return [self wb$imageAtPath:[path wb$themedPath]]; |
502d350e | 499 | } |
d5fb6e01 | 500 | |
502d350e | 501 | static id $initWithContentsOfFile$(NSObject<WinterBoard> *self, SEL sel, NSString *file) { |
2acbe5b8 | 502 | return [self wb$initWithContentsOfFile:[file wb$themedPath]]; |
394d1eb5 JF |
503 | } |
504 | ||
502d350e | 505 | static id UIImage$initWithContentsOfFile$cache$(UIImage<WinterBoard> *self, SEL sel, NSString *file, BOOL cache) { |
2acbe5b8 | 506 | return [self wb$initWithContentsOfFile:[file wb$themedPath] cache:cache]; |
502d350e JF |
507 | } |
508 | ||
509 | static UIImage *UIImage$defaultDesktopImage$(UIImage<WinterBoard> *self, SEL sel) { | |
510 | if (Debug_) | |
511 | NSLog(@"WB:Debug:DefaultDesktopImage"); | |
512 | if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"LockBackground.png", @"LockBackground.jpg", nil])) | |
2acbe5b8 JF |
513 | return [UIImage imageWithContentsOfFile:path]; |
514 | return [self wb$defaultDesktopImage]; | |
502d350e JF |
515 | } |
516 | ||
4668cd8e JF |
517 | static NSArray *Wallpapers_; |
518 | static NSString *WallpaperFile_; | |
502d350e JF |
519 | static UIImageView *WallpaperImage_; |
520 | static UIWebDocumentView *WallpaperPage_; | |
521 | static NSURL *WallpaperURL_; | |
95a5777b | 522 | |
4668cd8e JF |
523 | #define _release(object) \ |
524 | do if (object != nil) { \ | |
525 | [object release]; \ | |
526 | object = nil; \ | |
527 | } while (false) | |
528 | ||
394d1eb5 | 529 | static id SBContentLayer$initWithSize$(SBContentLayer<WinterBoard> *self, SEL sel, CGSize size) { |
2acbe5b8 | 530 | self = [self wb$initWithSize:size]; |
d5168fd6 JF |
531 | if (self == nil) |
532 | return nil; | |
533 | ||
4668cd8e JF |
534 | _release(WallpaperFile_); |
535 | _release(WallpaperImage_); | |
536 | _release(WallpaperPage_); | |
537 | _release(WallpaperURL_); | |
538 | ||
539 | if (NSString *theme = $getTheme$(Wallpapers_, true)) { | |
540 | NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"]; | |
541 | if ([Manager_ fileExistsAtPath:mp4]) { | |
542 | MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[self bounds]] autorelease]; | |
543 | [video setMovieWithPath:mp4]; | |
544 | [video setRepeatMode:1]; | |
545 | [video setRepeatGap:0]; | |
546 | [self addSubview:video]; | |
547 | [video playFromBeginning];; | |
548 | } | |
d5fb6e01 | 549 | |
4668cd8e JF |
550 | NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"]; |
551 | NSString *jpg = [theme stringByAppendingPathComponent:@"Wallpaper.jpg"]; | |
95a5777b | 552 | |
4668cd8e JF |
553 | NSString *path; |
554 | if ([Manager_ fileExistsAtPath:png]) | |
555 | path = png; | |
556 | else if ([Manager_ fileExistsAtPath:jpg]) | |
557 | path = jpg; | |
558 | else path = nil; | |
d5fb6e01 | 559 | |
4668cd8e JF |
560 | UIImage *image; |
561 | if (path != nil) { | |
562 | image = [[UIImage alloc] wb$initWithContentsOfFile:path]; | |
563 | if (image != nil) | |
564 | image = [image autorelease]; | |
565 | } else image = nil; | |
394d1eb5 | 566 | |
4668cd8e JF |
567 | if (image != nil) { |
568 | WallpaperFile_ = [path retain]; | |
569 | WallpaperImage_ = [[UIImageView alloc] initWithImage:image]; | |
570 | [self addSubview:WallpaperImage_]; | |
571 | } | |
394d1eb5 | 572 | |
4668cd8e JF |
573 | NSString *html = [theme stringByAppendingPathComponent:@"Wallpaper.html"]; |
574 | if ([Manager_ fileExistsAtPath:html]) { | |
575 | CGRect bounds = [self bounds]; | |
502d350e | 576 | |
4668cd8e JF |
577 | UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]); |
578 | [view setAutoresizes:true]; | |
502d350e | 579 | |
4668cd8e JF |
580 | WallpaperPage_ = [view retain]; |
581 | WallpaperURL_ = [[NSURL fileURLWithPath:html] retain]; | |
394d1eb5 | 582 | |
4668cd8e JF |
583 | [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]]; |
584 | ||
585 | [[view webView] setDrawsBackground:false]; | |
586 | [view setBackgroundColor:[UIColor clearColor]]; | |
394d1eb5 | 587 | |
4668cd8e JF |
588 | [self addSubview:view]; |
589 | } | |
08454e3a | 590 | } |
d5168fd6 | 591 | |
5e5c7190 JF |
592 | for (size_t i(0), e([themes_ count]); i != e; ++i) { |
593 | NSString *theme = [themes_ objectAtIndex:(e - i - 1)]; | |
594 | NSString *html = [theme stringByAppendingPathComponent:@"Widget.html"]; | |
595 | if ([Manager_ fileExistsAtPath:html]) { | |
596 | CGRect bounds = [self bounds]; | |
597 | ||
598 | UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]); | |
599 | [view setAutoresizes:true]; | |
600 | ||
601 | NSURL *url = [NSURL fileURLWithPath:html]; | |
602 | [view loadRequest:[NSURLRequest requestWithURL:url]]; | |
603 | ||
604 | [[view webView] setDrawsBackground:false]; | |
605 | [view setBackgroundColor:[UIColor clearColor]]; | |
606 | ||
607 | [self addSubview:view]; | |
608 | } | |
609 | } | |
610 | ||
d5168fd6 JF |
611 | return self; |
612 | } | |
613 | ||
502d350e JF |
614 | static void SBSlidingAlertDisplay$updateDesktopImage$(SBSlidingAlertDisplay<WinterBoard> *self, SEL sel, UIImage *image) { |
615 | NSString *path = $getTheme$([NSArray arrayWithObject:@"LockBackground.html"]); | |
2acbe5b8 | 616 | UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView")); |
502d350e | 617 | |
2acbe5b8 JF |
618 | if (path != nil && _backgroundView != nil) |
619 | path = nil; | |
502d350e | 620 | |
2acbe5b8 | 621 | [self wb$updateDesktopImage:image]; |
502d350e JF |
622 | |
623 | if (path != nil) { | |
624 | CGRect bounds = [self bounds]; | |
625 | ||
2acbe5b8 | 626 | UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]); |
502d350e JF |
627 | [view setAutoresizes:true]; |
628 | ||
629 | if (WallpaperPage_ != nil) | |
630 | [WallpaperPage_ release]; | |
631 | WallpaperPage_ = [view retain]; | |
632 | ||
633 | if (WallpaperURL_ != nil) | |
634 | [WallpaperURL_ release]; | |
635 | WallpaperURL_ = [[NSURL fileURLWithPath:path] retain]; | |
636 | ||
637 | [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]]; | |
638 | ||
639 | [[view webView] setDrawsBackground:false]; | |
2acbe5b8 | 640 | [view setBackgroundColor:[UIColor clearColor]]; |
502d350e | 641 | |
2acbe5b8 | 642 | [self insertSubview:view aboveSubview:_backgroundView]; |
ca13798d | 643 | } |
502d350e | 644 | } |
ca13798d | 645 | |
95a5777b | 646 | /*extern "C" CGColorRef CGGStateGetSystemColor(void *); |
ca13798d JF |
647 | extern "C" CGColorRef CGGStateGetFillColor(void *); |
648 | extern "C" CGColorRef CGGStateGetStrokeColor(void *); | |
95a5777b | 649 | extern "C" NSString *UIStyleStringFromColor(CGColorRef);*/ |
ca13798d | 650 | |
cd6ad593 JF |
651 | /* WBTimeLabel {{{ */ |
652 | @interface WBTimeLabel : NSProxy { | |
ca13798d JF |
653 | NSString *time_; |
654 | _transient SBStatusBarTimeView *view_; | |
889cb4f2 JF |
655 | } |
656 | ||
ca13798d | 657 | - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view; |
889cb4f2 JF |
658 | |
659 | @end | |
660 | ||
cd6ad593 | 661 | @implementation WBTimeLabel |
889cb4f2 JF |
662 | |
663 | - (void) dealloc { | |
ca13798d | 664 | [time_ release]; |
889cb4f2 JF |
665 | [super dealloc]; |
666 | } | |
667 | ||
ca13798d JF |
668 | - (id) initWithTime:(NSString *)time view:(SBStatusBarTimeView *)view { |
669 | time_ = [time retain]; | |
670 | view_ = view; | |
889cb4f2 JF |
671 | return self; |
672 | } | |
673 | ||
ca13798d JF |
674 | WBDelegate(time_) |
675 | ||
676 | - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode { | |
d5fb6e01 | 677 | if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) { |
2acbe5b8 | 678 | BOOL &_mode(MSHookIvar<BOOL>(view_, "_mode"));; |
d5fb6e01 JF |
679 | |
680 | [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@"" | |
681 | "font-family: Helvetica; " | |
682 | "font-weight: bold; " | |
683 | "font-size: 14px; " | |
684 | "color: %@; " | |
2acbe5b8 | 685 | "%@", _mode ? @"white" : @"black", custom]]; |
d5fb6e01 JF |
686 | |
687 | return CGSizeZero; | |
688 | } | |
ca13798d JF |
689 | |
690 | return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode]; | |
889cb4f2 JF |
691 | } |
692 | ||
cd6ad593 JF |
693 | @end |
694 | /* }}} */ | |
695 | /* WBBadgeLabel {{{ */ | |
696 | @interface WBBadgeLabel : NSProxy { | |
697 | NSString *badge_; | |
698 | } | |
699 | ||
700 | - (id) initWithBadge:(NSString *)badge; | |
701 | ||
ca13798d JF |
702 | @end |
703 | ||
cd6ad593 JF |
704 | @implementation WBBadgeLabel |
705 | ||
706 | - (void) dealloc { | |
707 | [badge_ release]; | |
708 | [super dealloc]; | |
889cb4f2 JF |
709 | } |
710 | ||
cd6ad593 JF |
711 | - (id) initWithBadge:(NSString *)badge { |
712 | badge_ = [badge retain]; | |
713 | return self; | |
714 | } | |
715 | ||
716 | WBDelegate(badge_) | |
717 | ||
718 | - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode { | |
719 | if (NSString *custom = [Info_ objectForKey:@"BadgeStyle"]) { | |
720 | [badge_ drawAtPoint:point withStyle:[NSString stringWithFormat:@"" | |
721 | "font-family: Helvetica; " | |
722 | "font-weight: bold; " | |
723 | "font-size: 17px; " | |
724 | "color: white; " | |
725 | "%@", custom]]; | |
726 | ||
727 | return CGSizeZero; | |
728 | } | |
729 | ||
730 | return [badge_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode]; | |
731 | } | |
ca13798d JF |
732 | |
733 | @end | |
cd6ad593 JF |
734 | /* }}} */ |
735 | ||
736 | static id SBIconBadge$initWithBadge$(SBIconBadge<WinterBoard> *self, SEL sel, NSString *badge) { | |
2acbe5b8 JF |
737 | if ((self = [self wb$initWithBadge:badge]) != nil) { |
738 | id &_badge(MSHookIvar<id>(self, "_badge")); | |
739 | if (_badge != nil) | |
740 | if (id label = [[WBBadgeLabel alloc] initWithBadge:[_badge autorelease]]) | |
741 | _badge = label; | |
cd6ad593 JF |
742 | } return self; |
743 | } | |
ca13798d | 744 | |
d5fb6e01 | 745 | static void SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(SBStatusBarController<WinterBoard> *self, SEL sel, int mode, int orientation, float duration, int id, int animation) { |
95a5777b JF |
746 | if (Debug_) |
747 | NSLog(@"WB:Debug:setStatusBarMode:%d", mode); | |
502d350e | 748 | if (mode < 100) // 104:hidden 105:glowing |
95a5777b JF |
749 | if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"]) |
750 | mode = [number intValue]; | |
2acbe5b8 | 751 | return [self wb$setStatusBarMode:mode orientation:orientation duration:duration fenceID:id animation:animation]; |
d5fb6e01 JF |
752 | } |
753 | ||
d5fb6e01 JF |
754 | static id SBStatusBarContentsView$initWithStatusBar$mode$(SBStatusBarContentsView<WinterBoard> *self, SEL sel, id bar, int mode) { |
755 | if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"]) | |
756 | mode = [number intValue]; | |
2acbe5b8 | 757 | return [self wb$initWithStatusBar:bar mode:mode]; |
d5fb6e01 JF |
758 | } |
759 | ||
4668cd8e JF |
760 | static NSString *SBStatusBarOperatorNameView$operatorNameStyle(SBStatusBarOperatorNameView<WinterBoard> *self, SEL sel, NSString *name, BOOL full) { |
761 | NSString *style([self wb$operatorNameStyle]); | |
762 | if (Debug_) | |
763 | NSLog(@"operatorNameStyle= %@", style); | |
764 | if (NSString *custom = [Info_ objectForKey:@"OperatorNameStyle"]) | |
765 | style = [NSString stringWithFormat:@"%@; %@", style, custom]; | |
766 | return style; | |
767 | } | |
768 | ||
769 | static void SBStatusBarOperatorNameView$setOperatorName$fullSize$(SBStatusBarOperatorNameView<WinterBoard> *self, SEL sel, NSString *name, BOOL full) { | |
770 | if (Debug_) | |
771 | NSLog(@"setOperatorName:\"%@\" fullSize:%u", name, full); | |
772 | [self wb$setOperatorName:name fullSize:NO]; | |
773 | } | |
774 | ||
394d1eb5 | 775 | static void SBStatusBarTimeView$drawRect$(SBStatusBarTimeView<WinterBoard> *self, SEL sel, CGRect rect) { |
2acbe5b8 JF |
776 | id &_time(MSHookIvar<id>(self, "_time")); |
777 | if (_time != nil && [_time class] != [WBTimeLabel class]) | |
778 | object_setInstanceVariable(self, "_time", reinterpret_cast<void *>([[WBTimeLabel alloc] initWithTime:[_time autorelease] view:self])); | |
779 | return [self wb$drawRect:rect]; | |
ca13798d JF |
780 | } |
781 | ||
95a5777b JF |
782 | static void SBIconController$appendIconList$(SBIconController<WinterBoard> *self, SEL sel, SBIconList *list) { |
783 | if (Debug_) | |
784 | NSLog(@"appendIconList:%@", list); | |
2acbe5b8 | 785 | return [self wb$appendIconList:list]; |
95a5777b JF |
786 | } |
787 | ||
cf31d246 | 788 | static id SBIconLabel$initWithSize$label$(SBIconLabel<WinterBoard> *self, SEL sel, CGSize size, NSString *label) { |
2acbe5b8 | 789 | self = [self wb$initWithSize:size label:label]; |
cf31d246 JF |
790 | if (self != nil) |
791 | [self setClipsToBounds:NO]; | |
792 | return self; | |
793 | } | |
794 | ||
394d1eb5 | 795 | static void SBIconLabel$setInDock$(SBIconLabel<WinterBoard> *self, SEL sel, BOOL docked) { |
2acbe5b8 | 796 | id &_label(MSHookIvar<id>(self, "_label")); |
d5fb6e01 | 797 | if (![Info_ boolForKey:@"UndockedIconLabels"]) |
95a5777b | 798 | docked = true; |
2acbe5b8 JF |
799 | if (_label != nil && [_label respondsToSelector:@selector(setInDock:)]) |
800 | [_label setInDock:docked]; | |
801 | return [self wb$setInDock:docked]; | |
889cb4f2 JF |
802 | } |
803 | ||
4fa950df JF |
804 | static NSString *NSBundle$localizedStringForKey$value$table$(NSBundle<WinterBoard> *self, SEL sel, NSString *key, NSString *value, NSString *table) { |
805 | NSString *identifier = [self bundleIdentifier]; | |
806 | NSLocale *locale = [NSLocale currentLocale]; | |
807 | NSString *language = [locale objectForKey:NSLocaleLanguageCode]; | |
2acbe5b8 | 808 | if (Debug_) |
4fa950df JF |
809 | NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language); |
810 | NSString *file = table == nil ? @"Localizable" : table; | |
811 | NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file]; | |
812 | NSDictionary *strings; | |
813 | if ((strings = [Strings_ objectForKey:name]) != nil) { | |
814 | if (static_cast<id>(strings) != [NSNull null]) strings: | |
815 | if (NSString *value = [strings objectForKey:key]) | |
816 | return value; | |
817 | } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings", | |
818 | language, file | |
819 | ], self, false)) { | |
820 | if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) { | |
821 | [Strings_ setObject:[strings autorelease] forKey:name]; | |
822 | goto strings; | |
823 | } else goto null; | |
824 | } else null: | |
825 | [Strings_ setObject:[NSNull null] forKey:name]; | |
2acbe5b8 | 826 | return [self wb$localizedStringForKey:key value:value table:table]; |
4fa950df JF |
827 | } |
828 | ||
7ff778ee JF |
829 | @class WebCoreFrameBridge; |
830 | static CGSize WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(WebCoreFrameBridge<WinterBoard> *self, SEL sel, id node, float width) { | |
831 | if (node == nil) | |
832 | return CGSizeZero; | |
833 | void **core(reinterpret_cast<void **>([node _node])); | |
834 | if (core == NULL || core[6] == NULL) | |
835 | return CGSizeZero; | |
2acbe5b8 | 836 | return [self wb$renderedSizeOfNode:node constrainedToWidth:width]; |
7ff778ee JF |
837 | } |
838 | ||
cf31d246 JF |
839 | static void SBIconLabel$drawRect$(SBIconLabel<WinterBoard> *self, SEL sel, CGRect rect) { |
840 | CGRect bounds = [self bounds]; | |
e6f0817b | 841 | |
a3fa54a5 JF |
842 | static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL); |
843 | ||
cf31d246 | 844 | BOOL docked; |
a3fa54a5 JF |
845 | Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked)); |
846 | docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0; | |
cf31d246 | 847 | |
2acbe5b8 | 848 | NSString *&label(MSHookIvar<NSString *>(self, "_label")); |
cf31d246 JF |
849 | |
850 | NSString *style = [NSString stringWithFormat:@"" | |
851 | "font-family: Helvetica; " | |
852 | "font-weight: bold; " | |
853 | "font-size: 11px; " | |
854 | "color: %@; " | |
855 | "", docked ? @"white" : @"#b3b3b3"]; | |
856 | ||
857 | if (docked) | |
858 | style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "]; | |
859 | float max = 75, width = [label sizeWithStyle:style forWidth:320].width; | |
860 | if (width > max) | |
861 | style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", ((width - max) / ([label length] - 1))]]; | |
862 | if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")]) | |
863 | style = [style stringByAppendingString:custom]; | |
864 | ||
865 | CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width]; | |
866 | [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style]; | |
889cb4f2 JF |
867 | } |
868 | ||
4668cd8e JF |
869 | void mSMSMessageTranscriptController$loadView(mSMSMessageTranscriptController<WinterBoard> *self, SEL sel) { |
870 | [self wb$loadView]; | |
871 | if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil])) | |
872 | if (UIImage *image = [[UIImage alloc] wb$initWithContentsOfFile:path]) { | |
873 | [image autorelease]; | |
874 | UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer")); | |
875 | UIView *parent([_transcriptLayer superview]); | |
876 | UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]); | |
877 | [parent insertSubview:background belowSubview:_transcriptLayer]; | |
878 | [_transcriptLayer setBackgroundColor:[UIColor clearColor]]; | |
879 | } | |
880 | } | |
881 | ||
2435118f JF |
882 | extern "C" void FindMappedImages(void); |
883 | extern "C" NSData *UIImagePNGRepresentation(UIImage *); | |
884 | ||
2acbe5b8 JF |
885 | //static CGImageRef *(*_UIImageRefAtPath)(NSString *path, bool cache, UIImageOrientation *orientation); |
886 | //_UIImageRefAtPath = (CGImageRef *(*)(NSString *, bool, UIImageOrientation *)) nl[3].n_value; | |
887 | ||
95a5777b | 888 | static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path); |
95a5777b | 889 | static UIImage *(*_UIImageWithName)(NSString *name); |
e6f0817b | 890 | static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain); |
95a5777b JF |
891 | static NSBundle *(*_UIKitBundle)(); |
892 | static void (*_UISharedImageInitialize)(bool); | |
893 | static int (*_UISharedImageNameGetIdentifier)(NSString *); | |
894 | static UIImage *(*_UISharedImageWithIdentifier)(int); | |
895 | ||
896 | static UIImage *$_UIImageWithName(NSString *name) { | |
897 | int id(_UISharedImageNameGetIdentifier(name)); | |
898 | if (Debug_) | |
899 | NSLog(@"WB:Debug: UIImageWithName(\"%@\", %d)", name, id); | |
900 | ||
901 | if (id == -1) | |
902 | return _UIImageAtPath(name, _UIKitBundle()); | |
903 | else { | |
904 | NSNumber *key([NSNumber numberWithInt:id]); | |
905 | UIImage *image = [UIImages_ objectForKey:key]; | |
906 | if (image != nil) | |
907 | return reinterpret_cast<id>(image) == [NSNull null] ? nil : image; | |
908 | if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) { | |
2acbe5b8 | 909 | image = [[UIImage alloc] wb$initWithContentsOfFile:path]; |
95a5777b JF |
910 | if (image != nil) |
911 | [image autorelease]; | |
912 | } | |
913 | if (image == nil) | |
914 | image = _UISharedImageWithIdentifier(id); | |
915 | [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key]; | |
916 | return image; | |
917 | } | |
918 | } | |
919 | ||
e6f0817b JF |
920 | static UIImage *$_UIImageWithNameInDomain(NSString *name, NSString *domain) { |
921 | NSString *key = [NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name]; | |
922 | UIImage *image = [PathImages_ objectForKey:key]; | |
923 | if (image != nil) | |
924 | return reinterpret_cast<id>(image) == [NSNull null] ? nil : image; | |
95a5777b | 925 | if (Debug_) |
e6f0817b JF |
926 | NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain); |
927 | if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) { | |
2acbe5b8 | 928 | image = [[UIImage alloc] wb$initWithContentsOfFile:path]; |
e6f0817b JF |
929 | if (image != nil) |
930 | [image autorelease]; | |
95a5777b | 931 | } |
e6f0817b JF |
932 | if (image == nil) |
933 | image = _UIImageWithNameInDomain(name, domain); | |
934 | [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key]; | |
935 | return image; | |
95a5777b JF |
936 | } |
937 | ||
95a5777b JF |
938 | #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox" |
939 | #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit" | |
940 | ||
95a5777b JF |
941 | static bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long, char *, bool &); |
942 | ||
943 | static bool $_Z24GetFileNameForThisActionmPcRb(unsigned long a0, char *a1, bool &a2) { | |
944 | bool value = _Z24GetFileNameForThisActionmPcRb(a0, a1, a2); | |
945 | if (Debug_) | |
946 | NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value); | |
947 | ||
948 | if (value) { | |
949 | NSString *path = [NSString stringWithUTF8String:a1]; | |
950 | if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) { | |
951 | NSString *file = [path substringFromIndex:31]; | |
952 | NSLog(@"%@", file); | |
953 | for (NSString *theme in themes_) { | |
954 | NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]); | |
955 | if ([Manager_ fileExistsAtPath:path]) { | |
956 | strcpy(a1, [path UTF8String]); | |
957 | continue; | |
958 | } | |
959 | } | |
960 | } | |
961 | } | |
962 | return value; | |
963 | } | |
964 | ||
965 | static void ChangeWallpaper( | |
966 | CFNotificationCenterRef center, | |
967 | void *observer, | |
968 | CFStringRef name, | |
969 | const void *object, | |
970 | CFDictionaryRef info | |
971 | ) { | |
972 | if (Debug_) | |
973 | NSLog(@"WB:Debug:ChangeWallpaper!"); | |
502d350e | 974 | |
95a5777b | 975 | UIImage *image; |
4668cd8e JF |
976 | if (WallpaperFile_ != nil) { |
977 | image = [[UIImage alloc] wb$initWithContentsOfFile:WallpaperFile_]; | |
95a5777b JF |
978 | if (image != nil) |
979 | image = [image autorelease]; | |
980 | } else image = nil; | |
502d350e JF |
981 | |
982 | if (WallpaperImage_ != nil) | |
983 | [WallpaperImage_ setImage:image]; | |
984 | if (WallpaperPage_ != nil) | |
985 | [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]]; | |
986 | ||
95a5777b | 987 | } |
394d1eb5 | 988 | |
4668cd8e JF |
989 | #define Prefix_ "wb$" |
990 | ||
e6f0817b | 991 | void WBRename(bool instance, const char *name, SEL sel, IMP imp) { |
4668cd8e JF |
992 | if (Class _class = objc_getClass(name)) { |
993 | if (!instance) | |
994 | _class = object_getClass(_class); | |
995 | MSHookMessage(_class, sel, imp, Prefix_); | |
996 | } else if (Debug_) | |
997 | NSLog(@"WB:Warning: cannot find class [%s]", name); | |
e6f0817b JF |
998 | } |
999 | ||
d5168fd6 | 1000 | extern "C" void WBInitialize() { |
d5168fd6 JF |
1001 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
1002 | ||
2acbe5b8 | 1003 | NSString *identifier([[NSBundle mainBundle] bundleIdentifier]); |
394d1eb5 | 1004 | |
2acbe5b8 | 1005 | NSLog(@"WB:Notice: WinterBoard"); |
95a5777b | 1006 | |
2acbe5b8 | 1007 | struct nlist nl[8]; |
95a5777b | 1008 | memset(nl, 0, sizeof(nl)); |
394d1eb5 | 1009 | |
2acbe5b8 JF |
1010 | nl[0].n_un.n_name = (char *) "__UIImageAtPath"; |
1011 | nl[1].n_un.n_name = (char *) "__UIImageWithName"; | |
1012 | nl[2].n_un.n_name = (char *) "__UIImageWithNameInDomain"; | |
1013 | nl[3].n_un.n_name = (char *) "__UIKitBundle"; | |
1014 | nl[4].n_un.n_name = (char *) "__UISharedImageInitialize"; | |
1015 | nl[5].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier"; | |
1016 | nl[6].n_un.n_name = (char *) "__UISharedImageWithIdentifier"; | |
95a5777b JF |
1017 | |
1018 | nlist(UIKit, nl); | |
1019 | ||
2acbe5b8 JF |
1020 | _UIImageAtPath = (UIImage *(*)(NSString *, NSBundle *)) nl[0].n_value; |
1021 | _UIImageWithName = (UIImage *(*)(NSString *)) nl[1].n_value; | |
1022 | _UIImageWithNameInDomain = (UIImage *(*)(NSString *, NSString *)) nl[2].n_value; | |
1023 | _UIKitBundle = (NSBundle *(*)()) nl[3].n_value; | |
1024 | _UISharedImageInitialize = (void (*)(bool)) nl[4].n_value; | |
1025 | _UISharedImageNameGetIdentifier = (int (*)(NSString *)) nl[5].n_value; | |
1026 | _UISharedImageWithIdentifier = (UIImage *(*)(int)) nl[6].n_value; | |
95a5777b | 1027 | |
e6f0817b JF |
1028 | MSHookFunction(_UIImageWithName, &$_UIImageWithName, &_UIImageWithName); |
1029 | MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &_UIImageWithNameInDomain); | |
95a5777b JF |
1030 | |
1031 | if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) { | |
1032 | struct nlist nl[2]; | |
1033 | memset(nl, 0, sizeof(nl)); | |
1034 | nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb"; | |
1035 | nlist(AudioToolbox, nl); | |
1036 | _Z24GetFileNameForThisActionmPcRb = (bool (*)(unsigned long, char *, bool &)) nl[0].n_value; | |
e6f0817b | 1037 | MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &_Z24GetFileNameForThisActionmPcRb); |
95a5777b | 1038 | } |
2435118f | 1039 | |
e6f0817b JF |
1040 | WBRename(false, "UIImage", @selector(applicationImageNamed:), (IMP) &UIImage$applicationImageNamed$); |
1041 | WBRename(false, "UIImage", @selector(defaultDesktopImage), (IMP) &UIImage$defaultDesktopImage$); | |
1042 | WBRename(false, "UIImage", @selector(imageAtPath:), (IMP) &UIImage$imageAtPath$); | |
1043 | WBRename(false, "UIImage", @selector(imageNamed:), (IMP) &UIImage$imageNamed$); | |
1044 | WBRename(false, "UIImage", @selector(imageNamed:inBundle:), (IMP) &UIImage$imageNamed$inBundle$); | |
1045 | ||
1046 | //WBRename("UINavigationBar", @selector(initWithCoder:", (IMP) &UINavigationBar$initWithCoder$); | |
1047 | //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$); | |
e6f0817b | 1048 | |
4fa950df | 1049 | WBRename(true, "NSBundle", @selector(localizedStringForKey:value:table:), (IMP) &NSBundle$localizedStringForKey$value$table$); |
e6f0817b JF |
1050 | WBRename(true, "NSBundle", @selector(pathForResource:ofType:), (IMP) &NSBundle$pathForResource$ofType$); |
1051 | ||
1052 | WBRename(true, "UIImage", @selector(initWithContentsOfFile:), (IMP) &$initWithContentsOfFile$); | |
1053 | WBRename(true, "UIImage", @selector(initWithContentsOfFile:cache:), (IMP) &UIImage$initWithContentsOfFile$cache$); | |
1054 | WBRename(true, "UINavigationBar", @selector(setBarStyle:), (IMP) &UINavigationBar$setBarStyle$); | |
1055 | WBRename(true, "UIToolbar", @selector(setBarStyle:), (IMP) &UIToolbar$setBarStyle$); | |
1056 | ||
502d350e JF |
1057 | _UISharedImageInitialize(false); |
1058 | ||
502d350e JF |
1059 | Manager_ = [[NSFileManager defaultManager] retain]; |
1060 | UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16]; | |
1061 | PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16]; | |
4fa950df | 1062 | Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0]; |
502d350e | 1063 | |
d5fb6e01 | 1064 | themes_ = [[NSMutableArray alloc] initWithCapacity:8]; |
26c43b47 | 1065 | |
d5fb6e01 | 1066 | if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) { |
62b2dbad | 1067 | [settings autorelease]; |
62b2dbad | 1068 | |
95a5777b JF |
1069 | if (NSNumber *debug = [settings objectForKey:@"Debug"]) |
1070 | Debug_ = [debug boolValue]; | |
1071 | ||
d5fb6e01 JF |
1072 | NSArray *themes = [settings objectForKey:@"Themes"]; |
1073 | if (themes == nil) | |
1074 | if (NSString *theme = [settings objectForKey:@"Theme"]) | |
1075 | themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys: | |
1076 | theme, @"Name", | |
95a5777b | 1077 | [NSNumber numberWithBool:true], @"Active", |
d5fb6e01 JF |
1078 | nil]]; |
1079 | if (themes != nil) | |
1080 | for (NSDictionary *theme in themes) { | |
1081 | NSNumber *active = [theme objectForKey:@"Active"]; | |
1082 | if (![active boolValue]) | |
1083 | continue; | |
26c43b47 | 1084 | |
d5fb6e01 JF |
1085 | NSString *name = [theme objectForKey:@"Name"]; |
1086 | if (name == nil) | |
1087 | continue; | |
1088 | ||
1089 | NSString *theme = nil; | |
1090 | ||
95a5777b JF |
1091 | #define testForTheme(format...) \ |
1092 | if (theme == nil) { \ | |
1093 | NSString *path = [NSString stringWithFormat:format]; \ | |
1094 | if ([Manager_ fileExistsAtPath:path]) { \ | |
1095 | [themes_ addObject:path]; \ | |
1096 | continue; \ | |
1097 | } \ | |
d5fb6e01 | 1098 | } |
d5fb6e01 | 1099 | |
95a5777b JF |
1100 | testForTheme(@"/Library/Themes/%@.theme", name) |
1101 | testForTheme(@"/Library/Themes/%@", name) | |
1102 | testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name) | |
d5fb6e01 | 1103 | } |
26c43b47 JF |
1104 | } |
1105 | ||
d5fb6e01 JF |
1106 | Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain]; |
1107 | ||
95a5777b | 1108 | for (NSString *theme in themes_) |
d5fb6e01 JF |
1109 | if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]]) |
1110 | for (NSString *key in [info allKeys]) | |
1111 | if ([Info_ objectForKey:key] == nil) | |
1112 | [Info_ setObject:[info objectForKey:key] forKey:key]; | |
95a5777b | 1113 | |
4668cd8e JF |
1114 | if ([identifier isEqualToString:@"com.apple.MobileSMS"]) { |
1115 | Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController"); | |
1116 | MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), (IMP) &mSMSMessageTranscriptController$loadView, Prefix_); | |
1117 | } else if ([identifier isEqualToString:@"com.apple.springboard"]) { | |
95a5777b JF |
1118 | CFNotificationCenterAddObserver( |
1119 | CFNotificationCenterGetDarwinNotifyCenter(), | |
1120 | NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0 | |
1121 | ); | |
62b2dbad | 1122 | |
2acbe5b8 JF |
1123 | NSBundle *MediaPlayer = [NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"]; |
1124 | if (MediaPlayer != nil) | |
1125 | [MediaPlayer load]; | |
1126 | ||
1127 | $MPVideoView = objc_getClass("MPVideoView"); | |
1128 | ||
1129 | WBRename(true, "WebCoreFrameBridge", @selector(renderedSizeOfNode:constrainedToWidth:), (IMP) &WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$); | |
1130 | ||
1131 | WBRename(true, "SBApplication", @selector(pathForIcon), (IMP) &SBApplication$pathForIcon); | |
1132 | WBRename(true, "SBApplicationIcon", @selector(icon), (IMP) &SBApplicationIcon$icon); | |
1133 | WBRename(true, "SBBookmarkIcon", @selector(icon), (IMP) &SBBookmarkIcon$icon); | |
1134 | WBRename(true, "SBButtonBar", @selector(didMoveToSuperview), (IMP) &$didMoveToSuperview); | |
1135 | WBRename(true, "SBCalendarIconContentsView", @selector(drawRect:), (IMP) &SBCalendarIconContentsView$drawRect$); | |
1136 | WBRename(true, "SBContentLayer", @selector(initWithSize:), (IMP) &SBContentLayer$initWithSize$); | |
1137 | WBRename(true, "SBIconBadge", @selector(initWithBadge:), (IMP) &SBIconBadge$initWithBadge$); | |
1138 | WBRename(true, "SBIconController", @selector(appendIconList:), (IMP) &SBIconController$appendIconList$); | |
1139 | WBRename(true, "SBIconLabel", @selector(drawRect:), (IMP) &SBIconLabel$drawRect$); | |
1140 | WBRename(true, "SBIconLabel", @selector(initWithSize:label:), (IMP) &SBIconLabel$initWithSize$label$); | |
1141 | WBRename(true, "SBIconLabel", @selector(setInDock:), (IMP) &SBIconLabel$setInDock$); | |
1142 | WBRename(true, "SBIconModel", @selector(cacheImageForIcon:), (IMP) &SBIconModel$cacheImageForIcon$); | |
1143 | WBRename(true, "SBIconModel", @selector(getCachedImagedForIcon:), (IMP) &SBIconModel$getCachedImagedForIcon$); | |
1144 | ||
1145 | WBRename(true, "SBSlidingAlertDisplay", @selector(updateDesktopImage:), (IMP) &SBSlidingAlertDisplay$updateDesktopImage$); | |
1146 | WBRename(true, "SBStatusBarContentsView", @selector(didMoveToSuperview), (IMP) &$didMoveToSuperview); | |
1147 | WBRename(true, "SBStatusBarContentsView", @selector(initWithStatusBar:mode:), (IMP) &SBStatusBarContentsView$initWithStatusBar$mode$); | |
1148 | WBRename(true, "SBStatusBarController", @selector(setStatusBarMode:orientation:duration:fenceID:animation:), (IMP) &SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$); | |
4668cd8e JF |
1149 | WBRename(true, "SBStatusBarOperatorNameView", @selector(operatorNameStyle), (IMP) &SBStatusBarOperatorNameView$operatorNameStyle); |
1150 | WBRename(true, "SBStatusBarOperatorNameView", @selector(setOperatorName:fullSize:), (IMP) &SBStatusBarOperatorNameView$setOperatorName$fullSize$); | |
2acbe5b8 JF |
1151 | WBRename(true, "SBStatusBarTimeView", @selector(drawRect:), (IMP) &SBStatusBarTimeView$drawRect$); |
1152 | ||
1153 | English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"]; | |
1154 | if (English_ != nil) | |
1155 | English_ = [English_ retain]; | |
1156 | ||
1157 | Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64]; | |
1158 | } | |
1159 | ||
4668cd8e JF |
1160 | Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain]; |
1161 | ||
f22a8989 JF |
1162 | if ([Info_ objectForKey:@"UndockedIconLabels"] == nil) |
1163 | [Info_ setObject:[NSNumber numberWithBool:( | |
4668cd8e | 1164 | $getTheme$(Wallpapers_) == nil || |
f22a8989 JF |
1165 | [Info_ objectForKey:@"DockedIconLabelStyle"] != nil || |
1166 | [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil | |
1167 | )] forKey:@"UndockedIconLabels"]; | |
1168 | ||
d5fb6e01 JF |
1169 | if (Debug_) |
1170 | NSLog(@"WB:Debug:Info = %@", [Info_ description]); | |
1171 | ||
d5168fd6 JF |
1172 | [pool release]; |
1173 | } |