From: Jay Freeman (saurik) Date: Sun, 3 Aug 2008 09:47:19 +0000 (+0000) Subject: Added .artwork theming. X-Git-Tag: v0.9.3900~90 X-Git-Url: https://git.saurik.com/winterboard.git/commitdiff_plain/2435118f6fc7577432f004087aeed17ee0bc4c20 Added .artwork theming. --- diff --git a/Library.mm b/Library.mm index 1f00ced..194a6d2 100644 --- a/Library.mm +++ b/Library.mm @@ -40,13 +40,20 @@ #include #include +extern "C" { + #include +} + #import +#import #import #import #import #import +#import + #import #import #import @@ -83,18 +90,18 @@ void WBInject(const char *classname, const char *oldname, IMP newimp, const char if (_class == nil) return; if (!class_addMethod(_class, sel_registerName(oldname), newimp, type)) - NSLog(@"WB: failed to inject [%s %s]", classname, oldname); + NSLog(@"WB:Error: failed to inject [%s %s]", classname, oldname); } void WBRename(const char *classname, const char *oldname, IMP newimp) { Class _class = objc_getClass(classname); if (_class == nil) { - NSLog(@"WB: cannot find class [%s]", classname); + NSLog(@"WB:Warning: cannot find class [%s]", classname); return; } Method method = class_getInstanceMethod(_class, sel_getUid(oldname)); if (method == nil) { - NSLog(@"WB: cannot find method [%s %s]", classname, oldname); + NSLog(@"WB:Warning: cannot find method [%s %s]", classname, oldname); return; } size_t namelen = strlen(oldname); @@ -103,7 +110,7 @@ void WBRename(const char *classname, const char *oldname, IMP newimp) { memcpy(newname + sizeof(WBPrefix) - 1, oldname, namelen + 1); const char *type = method_getTypeEncoding(method); if (!class_addMethod(_class, sel_registerName(newname), method_getImplementation(method), type)) - NSLog(@"WB: failed to rename [%s %s]", classname, oldname); + NSLog(@"WB:Error: failed to rename [%s %s]", classname, oldname); unsigned int count; Method *methods = class_copyMethodList(_class, &count); for (unsigned int index(0); index != count; ++index) @@ -111,7 +118,7 @@ void WBRename(const char *classname, const char *oldname, IMP newimp) { goto found; if (newimp != NULL) if (!class_addMethod(_class, sel_getUid(oldname), newimp, type)) - NSLog(@"WB: failed to rename [%s %s]", classname, oldname); + NSLog(@"WB:Error: failed to rename [%s %s]", classname, oldname); goto done; found: if (newimp != NULL) @@ -134,6 +141,10 @@ void WBRename(const char *classname, const char *oldname, IMP newimp) { - (id) wb_initWithFrame:(CGRect)frame withBarStyle:(int)style withTintColor:(UIColor *)color; @end +NSMutableDictionary **ImageMap_; + +bool Debug_; + NSFileManager *Manager_; NSDictionary *Info_; NSString *theme_; @@ -164,7 +175,8 @@ NSString *SBApplication$pathForIcon(SBApplication *self, SEL sel) { } NSString *NSBundle$pathForResource$ofType$(NSBundle *self, SEL sel, NSString *resource, NSString *type) { - NSLog(@"WB: NSBundle(%@) pathForResource:%@ ofType:%@", [self bundleIdentifier], resource, type); + if (Debug_) + NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@.%@\"]", [self bundleIdentifier], resource, type); if (theme_ != nil) { NSString *identifier = [self bundleIdentifier]; @@ -173,7 +185,6 @@ NSString *NSBundle$pathForResource$ofType$(NSBundle *self, SEL sel, NSString *path = [NSString stringWithFormat:@"%@/Bundles/%@/%@.%@", theme_, identifier, resource, type]; if ([Manager_ fileExistsAtPath:path]) return path; - NSLog(@"p...%@ (%u)", path, [Manager_ fileExistsAtPath:path]); } if ([resource isEqualToString:@"SBDockBG"] && [type isEqualToString:@"png"]) { @@ -263,11 +274,37 @@ id SBContentLayer$initWithSize$(SBContentLayer *self, SEL sel, CGSi return self; } +extern "C" void FindMappedImages(void); +extern "C" NSData *UIImagePNGRepresentation(UIImage *); + extern "C" void WBInitialize() { - NSLog(@"WB: installing WinterBoard..."); + NSLog(@"WB:Notice: Installing WinterBoard..."); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + struct nlist nl[3]; + memset(nl, 0, sizeof(nl)); + nl[0].n_un.n_name = (char *) "___mappedImages"; + nl[1].n_un.n_name = (char *) "__UISharedImageInitialize"; + nlist("/System/Library/Frameworks/UIKit.framework/UIKit", nl); + ImageMap_ = (id *) nl[0].n_value; + void (*__UISharedImageInitialize)(bool) = (void (*)(bool)) nl[1].n_value; + + __UISharedImageInitialize(false); + + /*NSArray *keys = [*ImageMap_ allKeys]; + for (int i(0), e([keys count]); i != e; ++i) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *key = [keys objectAtIndex:i]; + CGImageRef ref = (CGImageRef) [*ImageMap_ objectForKey:key]; + UIImage *image = [UIImage imageWithCGImage:ref]; + NSData *data = UIImagePNGRepresentation(image); + [data writeToFile:[NSString stringWithFormat:@"/tmp/pwnr/%@", key] atomically:YES]; + [pool release]; + }*/ + + Manager_ = [[NSFileManager defaultManager] retain]; + WBRename("SBApplication", "pathForIcon", (IMP) &SBApplication$pathForIcon); WBRename("NSBundle", "pathForResource:ofType:", (IMP) &NSBundle$pathForResource$ofType$); WBRename("SBAppWindow", "setBackgroundColor:", (IMP) &SBAppWindow$setBackgroundColor$); @@ -277,8 +314,6 @@ extern "C" void WBInitialize() { WBRename("UINavigationBar", "setBarStyle:", (IMP) &UINavigationBar$setBarStyle$); //WBRename("UINavigationBarBackground", "initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$); - Manager_ = [[NSFileManager defaultManager] retain]; - if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()]]) { [settings autorelease]; NSString *name = [settings objectForKey:@"Theme"]; @@ -302,6 +337,17 @@ extern "C" void WBInitialize() { if ([Manager_ fileExistsAtPath:path]) Wallpaper_ = [path retain]; + NSString *folder = [NSString stringWithFormat:@"%@/UIImages", theme_]; + if (NSArray *images = [Manager_ contentsOfDirectoryAtPath:folder error:NULL]) + for (int i(0), e = [images count]; i != e; ++i) { + NSString *name = [images objectAtIndex:i]; + if (![name hasSuffix:@".png"]) + continue; + NSString *path = [NSString stringWithFormat:@"%@/%@", folder, name]; + UIImage *image = [UIImage imageWithContentsOfFile:path]; + [*ImageMap_ setObject:(id)[image imageRef] forKey:name]; + } + Info_ = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme_]]; if (Info_ == nil) { //LabelColor_ = [UIColor whiteColor]; diff --git a/control b/control index 85bd389..6d3a9d2 100644 --- a/control +++ b/control @@ -3,9 +3,13 @@ Priority: optional Section: Themes Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.2499-2 -Description: open-source SummerBoard replacement - This tool lets you apply SummerBoard themes. Themes are taken from /Library/Themes (or, now, the older SummerBoard folder). Right now the tool is /very/ simplistic: I spent a single night coding it so that we would have some stronger theme support on iPhone 2.x. After you install or uninstall this package you will have to reboot your phone to it to take effect. More work will be done on this package in the very near future to make it actually have an interface ;P. (Also, the wallpaper is cut off at the bottom under the dock. I'm working on that still.) +Version: 0.9.2500-1 +Description: more powerful, open-source SummerBoard + This tool lets you apply SummerBoard themes. Themes are taken from /Library/Themes (or, now, the older SummerBoard folder). Right now the tool is /very/ simplistic: I have spent about a day coding it so that we would have some stronger theme support on iPhone 2.x. After you install or uninstall this package you will have to /reboot/ (seriously, REBOOT) your phone to it to take effect. + + More work will be done on this package in the very near future to make it actually have an interface ;P. (Also, the wallpaper is cut off at the bottom under the dock. I'm working on that still. That has to be done special on 2.x.) + + WinterBoard is /much/ more powerful than SummerBoard and lets you theme almost any graphic on the system. You can even easily theme .artwork files without having to hack their contents. Instructions on how this works will be posted soon on the More Information page. Name: WinterBoard Provides: theme-manager Author: Jay Freeman (saurik) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..9a06187 Binary files /dev/null and b/icon.png differ diff --git a/makefile b/makefile index e31d086..66ba1fc 100644 --- a/makefile +++ b/makefile @@ -22,7 +22,7 @@ package: mkdir -p winterboard/Library/Themes cp -a Nature winterboard/Library/Themes/com.saurik.WinterBoard.Nature cp -a control preinst postinst prerm winterboard/DEBIAN - cp -a Test.sh WinterBoard.dylib WinterBoard Info.plist ../pledit/pledit winterboard/Applications/WinterBoard.app - dpkg-deb -b winterboard winterboard_0.9.2499-2_iphoneos-arm.deb + cp -a Test.sh icon.png WinterBoard.dylib WinterBoard Info.plist ../pledit/pledit winterboard/Applications/WinterBoard.app + dpkg-deb -b winterboard winterboard_0.9.2500-1_iphoneos-arm.deb .PHONY: all clean package