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