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