bool Debug_ = false;
bool Engineer_ = false;
+bool SummerBoard_ = true;
static UIImage *(*_UIApplicationImageWithName)(NSString *name);
static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path);
[names addObject:[NSString stringWithFormat:@"Bundles/com.apple.MobileSMS/%@", file]];
else if ([identifier isEqualToString:@"com.apple.calculator"])
[names addObject:[NSString stringWithFormat:@"Files/Applications/Calculator.app/%@", file]];
- else if (![identifier isEqualToString:@"com.apple.springboard"]);
+ else if (![identifier isEqualToString:@"com.apple.springboard"] || !SummerBoard_);
remapResourceName(@"FSO_BG.png", @"StatusBar")
remapResourceName(@"SBDockBG.png", @"Dock")
remapResourceName(@"SBWeatherCelsius.png", @"Icons/Weather")
NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
+ /* XXX: I might need to keep this for backwards compatibility
if (identifier != nil)
[names addObject:[NSString stringWithFormat:@"Bundles/%@/icon.png", identifier]];
if (folder != nil)
- [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]];
+ [names addObject:[NSString stringWithFormat:@"Folders/%@/icon.png", folder]]; */
#define testForIcon(Name) \
if (NSString *name = Name) \
[controller_ play:&error];
#elif UseMPMoviePlayerController
NSURL *url([NSURL fileURLWithPath:mp4]);
- MPMoviePlayerController *controller = [[MPMoviePlayerController alloc] initWithContentURL:url];
+ MPMoviePlayerController *controller = [[$MPMoviePlayerController alloc] initWithContentURL:url];
controller.movieControlMode = MPMovieControlModeHidden;
[controller play];
#else
}
extern "C" void WBInitialize() {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);
_UIImage$defaultDesktopImage = MSHookMessage(object_getClass($UIImage), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage);
- //WBRename("UINavigationBar", @selector(initWithCoder:", (IMP) &UINavigationBar$initWithCoder$);
- //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
+ //WBRename("UINavigationBar", @selector(initWithCoder:), (IMP) &UINavigationBar$initWithCoder$);
+ //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:), (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
_UINavigationBar$setBarStyle$ = MSHookMessage($UINavigationBar, @selector(setBarStyle:), &$UINavigationBar$setBarStyle$);
_UIToolbar$setBarStyle$ = MSHookMessage($UIToolbar, @selector(setBarStyle:), &$UIToolbar$setBarStyle$);
themes_ = [[NSMutableArray alloc] initWithCapacity:8];
- if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
- [settings autorelease];
+ if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
+ if (NSNumber *value = [settings objectForKey:@"SummerBoard"])
+ SummerBoard_ = [value boolValue];
+ if (NSNumber *value = [settings objectForKey:@"Debug"])
+ Debug_ = [value boolValue];
- if (NSNumber *debug = [settings objectForKey:@"Debug"])
- Debug_ = [debug boolValue];
-
- NSArray *themes = [settings objectForKey:@"Themes"];
+ NSArray *themes([settings objectForKey:@"Themes"]);
if (themes == nil)
if (NSString *theme = [settings objectForKey:@"Theme"])
themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
theme, @"Name",
[NSNumber numberWithBool:true], @"Active",
nil]];
+
if (themes != nil)
for (NSDictionary *theme in themes) {
- NSNumber *active = [theme objectForKey:@"Active"];
+ NSNumber *active([theme objectForKey:@"Active"]);
if (![active boolValue])
continue;
- NSString *name = [theme objectForKey:@"Name"];
+ NSString *name([theme objectForKey:@"Name"]);
if (name == nil)
continue;
- NSString *theme = nil;
+ NSString *theme(nil);
#define testForTheme(format...) \
if (theme == nil) { \
testForTheme(@"/Library/Themes/%@.theme", name)
testForTheme(@"/Library/Themes/%@", name)
testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)
+
}
}
Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
for (NSString *theme in themes_)
- if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]]) {
- [info autorelease];
+ if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])
for (NSString *key in [info allKeys])
if ([Info_ objectForKey:key] == nil)
[Info_ setObject:[info objectForKey:key] forKey:key];
- }
bool sms($getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]) != nil);
NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0
);
- NSBundle *MediaPlayer = [NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"];
- if (MediaPlayer != nil)
- [MediaPlayer load];
+ /*
+ if ($getTheme$([NSArray arrayWithObjects:@"Wallpaper.mp4"]) != nil) {
+ NSBundle *MediaPlayer([NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"]);
+ if (MediaPlayer != nil)
+ [MediaPlayer load];
+
+ $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
+ $MPVideoView = objc_getClass("MPVideoView");
+ }*/
- $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
- $MPVideoView = objc_getClass("MPVideoView");
$WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
$SBApplication = objc_getClass("SBApplication");
WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$);
- WBRename(SBApplication, pathForIcon, pathForIcon);
- WBRename(SBApplicationIcon, icon, icon);
+ if (SummerBoard_) {
+ WBRename(SBApplication, pathForIcon, pathForIcon);
+ WBRename(SBApplicationIcon, icon, icon);
+ }
+
WBRename(SBBookmarkIcon, icon, icon);
WBRename(SBButtonBar, didMoveToSuperview, didMoveToSuperview);
WBRename(SBCalendarIconContentsView, drawRect:, drawRect$);
static NSMutableDictionary *_settings;
static NSString *_plist;
+/* [NSObject yieldToSelector:(withObject:)] {{{*/
+@interface NSObject (wb$yieldToSelector)
+- (id) wb$yieldToSelector:(SEL)selector withObject:(id)object;
+- (id) wb$yieldToSelector:(SEL)selector;
+@end
+
+@implementation NSObject (Cydia)
+
+- (void) wb$doNothing {
+}
+
+- (void) wb$_yieldToContext:(NSMutableArray *)context {
+ NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
+
+ SEL selector(reinterpret_cast<SEL>([[context objectAtIndex:0] pointerValue]));
+ id object([[context objectAtIndex:1] nonretainedObjectValue]);
+ volatile bool &stopped(*reinterpret_cast<bool *>([[context objectAtIndex:2] pointerValue]));
+
+ /* XXX: deal with exceptions */
+ id value([self performSelector:selector withObject:object]);
+
+ NSMethodSignature *signature([self methodSignatureForSelector:selector]);
+ [context removeAllObjects];
+ if ([signature methodReturnLength] != 0 && value != nil)
+ [context addObject:value];
+
+ stopped = true;
+
+ [self
+ performSelectorOnMainThread:@selector(wb$doNothing)
+ withObject:nil
+ waitUntilDone:NO
+ ];
+
+ [pool release];
+}
+
+- (id) wb$yieldToSelector:(SEL)selector withObject:(id)object {
+ /*return [self performSelector:selector withObject:object];*/
+
+ volatile bool stopped(false);
+
+ NSMutableArray *context([NSMutableArray arrayWithObjects:
+ [NSValue valueWithPointer:selector],
+ [NSValue valueWithNonretainedObject:object],
+ [NSValue valueWithPointer:const_cast<bool *>(&stopped)],
+ nil]);
+
+ NSThread *thread([[[NSThread alloc]
+ initWithTarget:self
+ selector:@selector(wb$_yieldToContext:)
+ object:context
+ ] autorelease]);
+
+ [thread start];
+
+ NSRunLoop *loop([NSRunLoop currentRunLoop]);
+ NSDate *future([NSDate distantFuture]);
+
+ while (!stopped && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
+
+ return [context count] == 0 ? nil : [context objectAtIndex:0];
+}
+
+- (id) wb$yieldToSelector:(SEL)selector {
+ return [self wb$yieldToSelector:selector withObject:nil];
+}
+
+@end
+/* }}} */
+
/* Theme Settings Controller {{{ */
@interface WBSThemesController: PSViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *_tableView;
[super dealloc];
}
+- (void) _optimizeThemes {
+ system("/usr/libexec/winterboard/Optimize");
+}
+
+- (void) optimizeThemes {
+ UIView *view([self view]);
+ UIWindow *window([view window]);
+
+ UIProgressHUD *hud([[[UIProgressHUD alloc] initWithWindow:window] autorelease]);
+ [hud setText:@"Reticulating Splines\nPlease Wait (Minutes)"];
+
+ [window setUserInteractionEnabled:NO];
+
+ [window addSubview:hud];
+ [hud show:YES];
+ [self wb$yieldToSelector:@selector(_optimizeThemes)];
+ [hud removeFromSuperview];
+
+ [window setUserInteractionEnabled:YES];
+
+ [self settingsChanged];
+}
+
- (void) suspend {
if (!settingsChanged)
return;