static NSMutableDictionary *_settings;
static NSString *_plist;
+void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) {
+ NSArray *themes([[NSFileManager defaultManager] contentsOfDirectoryAtPath:folder error:NULL]);
+ for (NSString *theme in themes) {
+ if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/Info.plist", folder, theme]]) {
+ if (NSArray *version = [info objectForKey:@"CoreFoundationVersion"]) {
+ size_t count([version count]);
+ if (count == 0 || count > 2)
+ continue;
+
+ double lower([[version objectAtIndex:0] doubleValue]);
+ if (kCFCoreFoundationVersionNumber < lower)
+ continue;
+
+ if (count != 1) {
+ double upper([[version objectAtIndex:1] doubleValue]);
+ if (upper <= kCFCoreFoundationVersionNumber)
+ continue;
+ }
+ }
+ }
+
+ [themesOnDisk addObject:theme];
+ }
+}
+
/* [NSObject yieldToSelector:(withObject:)] {{{*/
@interface NSObject (wb$yieldToSelector)
- (id) wb$yieldToSelector:(SEL)selector withObject:(id)object;
/* }}} */
/* Theme Settings Controller {{{ */
+@interface WBSThemesTableViewCell : UITableViewCell {
+}
+
+@end
+
+@implementation WBSThemesTableViewCell
+
+- (id) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuse {
+ if ((self = [super initWithFrame:frame reuseIdentifier:reuse]) != nil) {
+ } return self;
+}
+
+- (void) setTheme:(NSDictionary *)theme {
+ self.text = [theme objectForKey:@"Name"];
+ self.hidesAccessoryWhenEditing = NO;
+ NSNumber *active([theme objectForKey:@"Active"]);
+ BOOL inactive(active == nil || ![active boolValue]);
+ [self setImage:(inactive ? uncheckedImage : checkImage)];
+}
+
+@end
+
@interface WBSThemesController: PSViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *_tableView;
NSMutableArray *_themes;
@property (nonatomic, retain) NSMutableArray *themes;
-+ (void) load;
-
- (id) initForContentSize:(CGSize)size;
- (id) view;
- (id) navigationTitle;
@synthesize themes = _themes;
-+ (void) load {
++ (void) initialize {
NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
checkImage = [_UIImageWithName(@"UIPreferencesBlueCheck.png") retain];
uncheckedImage = [[UIImage imageWithContentsOfFile:@"/System/Library/PreferenceBundles/WinterBoardSettings.bundle/SearchResultsCheckmarkClear.png"] retain];
}
NSMutableArray *themesOnDisk([NSMutableArray array]);
-
- [themesOnDisk
- addObjectsFromArray:[[NSFileManager defaultManager]
- contentsOfDirectoryAtPath:@"/Library/Themes" error:NULL]
- ];
-
- [themesOnDisk addObjectsFromArray:[[NSFileManager defaultManager]
- contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()]
- error:NULL
- ]];
+ AddThemes(themesOnDisk, @"/Library/Themes");
+ AddThemes(themesOnDisk, [NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()]);
for (int i = 0, count = [themesOnDisk count]; i < count; i++) {
NSString *theme = [themesOnDisk objectAtIndex:i];
}
- (id) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThemeCell"];
+ WBSThemesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThemeCell"];
if (!cell) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100) reuseIdentifier:@"ThemeCell"] autorelease];
+ cell = [[[WBSThemesTableViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100) reuseIdentifier:@"ThemeCell"] autorelease];
//[cell setTableViewStyle:UITableViewCellStyleDefault];
}
NSDictionary *theme([_themes objectAtIndex:indexPath.row]);
- cell.text = [theme objectForKey:@"Name"];
- cell.hidesAccessoryWhenEditing = NO;
- NSNumber *active([theme objectForKey:@"Active"]);
- BOOL inactive(active == nil || ![active boolValue]);
- [cell setImage:(inactive ? uncheckedImage : checkImage)];
+ [cell setTheme:theme];
return cell;
}
system("rm -rf /User/Library/Caches/com.apple.IconsCache");
system("rm -rf /User/Library/Caches/com.apple.newsstand");
system("rm -rf /User/Library/Caches/com.apple.springboard.sharedimagecache");
+ system("rm -rf /User/Library/Caches/com.apple.UIStatusBar");
+
+ system("rm -rf /User/Library/Caches/BarDialer");
+ system("rm -rf /User/Library/Caches/BarDialer_selected");
+ system("rm -rf /User/Library/Caches/BarRecents");
+ system("rm -rf /User/Library/Caches/BarRecents_selected");
+ system("rm -rf /User/Library/Caches/BarVM");
+ system("rm -rf /User/Library/Caches/BarVM_selected");
system("killall -9 lsd");
}
- (id) specifiers {
- if (!_specifiers)
- _specifiers = [[self loadSpecifiersFromPlistName:@"WinterBoard" target:self] retain];
+ if (!_specifiers) {
+ NSMutableArray *specifiers([NSMutableArray array]);
+ for (PSSpecifier *specifier in [self loadSpecifiersFromPlistName:@"WinterBoard" target:self]) {
+ if (NSArray *version = [specifier propertyForKey:@"wb$filter"]) {
+ size_t count([version count]);
+ if (count == 0 || count > 2)
+ continue;
+
+ double lower([[version objectAtIndex:0] doubleValue]);
+ if (kCFCoreFoundationVersionNumber < lower)
+ continue;
+
+ if (count != 1) {
+ double upper([[version objectAtIndex:1] doubleValue]);
+ if (upper <= kCFCoreFoundationVersionNumber)
+ continue;
+ }
+ }
+ [specifiers addObject:specifier];
+ }
+ _specifiers = [specifiers retain];
+ }
return _specifiers;
}