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