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