From 2435118f6fc7577432f004087aeed17ee0bc4c20 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 3 Aug 2008 09:47:19 +0000 Subject: [PATCH] Added .artwork theming. --- Library.mm | 66 +++++++++++++++++++++++++++++++++++++++++++++-------- control | 10 +++++--- icon.png | Bin 0 -> 7075 bytes makefile | 4 ++-- 4 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 icon.png 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 0000000000000000000000000000000000000000..9a061874b46be191a16ea74bfd858b55337c172b GIT binary patch literal 7075 zcmV;U8(idxP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p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PXPxlJ2hq5snPKhpFMcz6VE*0^bPb49h@Guob+u&?7_Ta^=EBc&{*r0ZP)LN!@jho zMg}CxwFcJ@!%RxDs_VM``)4mKyY+JYgO{Iud-eTO3t`}`hk>_bthp4qFc7Maeq!3V z^e`|6jG|Q0vYb4SLMi9gs^6aRxr0x=yvGzRsz=Eocou3O@WRlqp>+vZ2iAa1paQtj z8DOsx+X1pbzY)A2$QwnZZoPYZI|(NN;2D8xK-CCXMgBj8pG2Mi9{^D$4cfEuvNQky N002ovPDHLkV1nj7lBECu literal 0 HcmV?d00001 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 -- 2.45.2