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