#define lprintf(args...) fprintf(stderr, args)
-#define ForRelease 0
+#define ForRelease 1
#define TraceLogging (1 && !ForRelease)
#define HistogramInsertionSort (0 && !ForRelease)
#define ProfileTimes (0 && !ForRelease)
- (void) beginUpdate;
- (BOOL) updating;
- (void) distUpgrade;
+- (void) loadData;
- (void) updateData;
- (void) syncData;
- (void) showSettings;
- (void) removeProgressHUD:(UIProgressHUD *)hud;
- (UCViewController *) pageForPackage:(NSString *)name;
- (PackageController *) packageController;
+- (void) showActionSheet:(UIActionSheet *)sheet fromItem:(UIBarButtonItem *)item;
@end
/* }}} */
UIImage *icon(nil);
if (!icon_.empty())
if ([icon_ hasPrefix:@"file:///"])
+ // XXX: correct escaping
icon = [UIImage imageAtPath:[icon_ substringFromIndex:7]];
if (icon == nil) if (section != nil)
icon = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]];
if (icon == nil) if (source_ != nil) if (NSString *dicon = [source_ defaultIcon])
if ([dicon hasPrefix:@"file:///"])
+ // XXX: correct escaping
icon = [UIImage imageAtPath:[dicon substringFromIndex:7]];
if (icon == nil)
icon = [UIImage applicationImageNamed:@"unknown.png"];
@implementation CYViewController
@end
/* }}} */
-
+/* Cydia Browser Controller {{{ */
@interface CYBrowserController : BrowserController {
CydiaObject *cydia_;
}
}
@end
+/* }}} */
+/* Confirmation {{{ */
@protocol ConfirmationControllerDelegate
- (void) cancelAndClear:(bool)clear;
- (void) confirmWithNavigationController:(UINavigationController *)navigation;
@end
/* }}} */
/* Package Controller {{{ */
-@interface PackageController : CYBrowserController {
+@interface PackageController : CYBrowserController <
+ UIActionSheetDelegate
+> {
_transient Database *database_;
Package *package_;
NSString *name_;
}
#if !AlwaysReload
-- (void) _actionButtonClicked {
+- (void) _customButtonClicked {
int count([buttons_ count]);
if (count == 0)
return;
}
}
-- (void) actionButtonClicked {
- // Wait until it's done loading.
- if (![self isLoading])
- [self _actionButtonClicked];
+// We don't want to allow non-commercial packages to do custom things to the install button,
+// so it must call customButtonClicked with a custom commercial_ == 1 fallthrough.
+- (void) customButtonClicked {
+ if (commercial_)
+ [super customButtonClicked];
+ else
+ [self _customButtonClicked];
}
- (void) reloadButtonClicked {
- (void) applyLoadingTitle {
// Don't show "Loading" as the title. Ever.
}
+
+- (UIBarButtonItem *) rightButton {
+ int count = [buttons_ count];
+ return [[[UIBarButtonItem alloc]
+ initWithTitle:count == 0 ? nil : count != 1 ? UCLocalize("MODIFY") : [buttons_ objectAtIndex:0]
+ style:UIBarButtonItemStylePlain
+ target:self
+ action:@selector(customButtonClicked)
+ ] autorelease];
+}
#endif
- (id) initWithDatabase:(Database *)database {
}
}
-- (void) applyRightButton {
- int count = [buttons_ count];
- UIBarButtonItem *actionItem = [[UIBarButtonItem alloc]
- initWithTitle:count == 0 ? nil : count != 1 ? UCLocalize("MODIFY") : [buttons_ objectAtIndex:0]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(actionButtonClicked)
- ];
- if (![self isLoading]) [[self navigationItem] setRightBarButtonItem:actionItem];
- else [super applyRightButton];
- [actionItem release];
-}
-
- (bool) isLoading {
return commercial_ ? [super isLoading] : false;
}
}
}
-- (id) initWithDatabase: (Database *)database {
+- (id) initWithDatabase:(Database *)database {
if ((self = [super init]) != nil) {
database_ = database;
} return self;
}
- (void) save {
- NSString *role = nil;
+ NSString *role(nil);
switch ([segment_ selectedSegmentIndex]) {
case 0: role = @"User"; break;
}
if (![role isEqualToString:Role_]) {
+ bool rolling(Role_ == nil);
Role_ = role;
Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
Changed_ = true;
- [roledelegate_ updateData];
+ if (rolling)
+ [roledelegate_ loadData];
+ else
+ [roledelegate_ updateData];
}
}
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
- return YES; /* XXX: return YES; */
+ return IsWildcat_;
}
- (void) setTabBarController:(UITabBarController *)controller {
if (animated) [UIView beginAnimations:nil context:NULL];
CGRect barframe = [refreshbar_ frame];
CGRect viewframe = [[root_ view] frame];
- viewframe.origin.y += barframe.size.height + 20.0f;
- viewframe.size.height -= barframe.size.height + 20.0f;
+ viewframe.origin.y += barframe.size.height;
+ viewframe.size.height -= barframe.size.height;
[[root_ view] setFrame:viewframe];
if (animated) [UIView commitAnimations];
if (animated) [UIView beginAnimations:nil context:NULL];
CGRect barframe = [refreshbar_ frame];
CGRect viewframe = [[root_ view] frame];
- viewframe.origin.y -= barframe.size.height + 20.0f;
- viewframe.size.height += barframe.size.height + 20.0f;
+ viewframe.origin.y -= barframe.size.height;
+ viewframe.size.height += barframe.size.height;
[[root_ view] setFrame:viewframe];
if (animated) [UIView commitAnimations];
- (UCViewController *) _pageForURL:(NSURL *)url withClass:(Class)_class;
- (void) setPage:(UCViewController *)page;
+- (void) loadData;
@end
}
- (void) _reloadData {
- UIView *block();
-
UIProgressHUD *hud([self addProgressHUD]);
[hud setText:(loaded_ ? UCLocalize("RELOADING_DATA") : UCLocalize("LOADING_DATA"))];
return;
}
- if (Role_ == nil)
- [self showSettings];
-
_trace();
- NSMutableArray *controllers = [NSMutableArray array];
- [controllers addObject:[[CYNavigationController alloc] initWithDatabase:database_]];
- [controllers addObject:[[CYNavigationController alloc] initWithDatabase:database_]];
- [controllers addObject:[[CYNavigationController alloc] initWithDatabase:database_]];
- if (IsWildcat_) [controllers addObject:[[CYNavigationController alloc] initWithDatabase:database_]];
- [controllers addObject:[[CYNavigationController alloc] initWithDatabase:database_]];
- [controllers addObject:[[CYNavigationController alloc] initWithDatabase:database_]];
-
- NSMutableArray *items = [NSMutableArray arrayWithObjects:
+ NSMutableArray *items([NSMutableArray arrayWithObjects:
[[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage applicationImageNamed:@"home.png"] tag:kCydiaTag] autorelease],
[[[UITabBarItem alloc] initWithTitle:UCLocalize("SECTIONS") image:[UIImage applicationImageNamed:@"install.png"] tag:kSectionsTag] autorelease],
[[[UITabBarItem alloc] initWithTitle:UCLocalize("CHANGES") image:[UIImage applicationImageNamed:@"changes.png"] tag:kChangesTag] autorelease],
[[[UITabBarItem alloc] initWithTitle:UCLocalize("SEARCH") image:[UIImage applicationImageNamed:@"search.png"] tag:kSearchTag] autorelease],
- nil
- ];
+ nil]);
if (IsWildcat_) {
[items insertObject:[[[UITabBarItem alloc] initWithTitle:UCLocalize("SOURCES") image:[UIImage applicationImageNamed:@"source.png"] tag:kSourcesTag] autorelease] atIndex:3];
[items insertObject:[[[UITabBarItem alloc] initWithTitle:UCLocalize("MANAGE") image:[UIImage applicationImageNamed:@"manage.png"] tag:kManageTag] autorelease] atIndex:3];
}
- for (size_t i(0); i != [items count]; i++)
- [[controllers objectAtIndex:i] setTabBarItem:[items objectAtIndex:i]];
+ NSMutableArray *controllers([NSMutableArray array]);
+
+ for (UITabBarItem *item in items) {
+ CYNavigationController *controller([[[CYNavigationController alloc] initWithDatabase:database_] autorelease]);
+ [controller setTabBarItem:item];
+ [controllers addObject:controller];
+ }
tabbar_ = [[CYTabBarController alloc] initWithDatabase:database_];
[tabbar_ setViewControllers:controllers];
[container_ setUpdateDelegate:self];
[container_ setTabBarController:tabbar_];
[window_ addSubview:[container_ view]];
- [[tabbar_ view] setFrame:CGRectMake(0, -20.0f, [window_ bounds].size.width, [window_ bounds].size.height)];
+
+ [self performSelector:@selector(loadData) withObject:nil afterDelay:0];
+}
+
+- (void) loadData {
+ if (Role_ == nil) {
+ [self showSettings];
+ return;
+ }
[UIKeyboard initImplementationNow];
Class $UIHardware;
-MSHook(void, UIHardware$_playSystemSound$, Class self, SEL _cmd, int soundIndex) {
- switch (soundIndex) {
+MSHook(void, UIHardware$_playSystemSound$, Class self, SEL _cmd, int sound) {
+ switch (sound) {
case 1104: // Keyboard Button Clicked
case 1105: // Keyboard Delete Repeated
- if (!shouldPlayKeyboardSounds) {
- NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.preferences.sounds.plist"];
- shouldPlayKeyboardSounds = [[dict objectForKey:@"keyboard"] ?: (id)kCFBooleanTrue retain];
- [dict release];
+ if (shouldPlayKeyboardSounds == nil) {
+ NSDictionary *dict([[[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.preferences.sounds.plist"] autorelease]);
+ shouldPlayKeyboardSounds = [([dict objectForKey:@"keyboard"] ?: (id) kCFBooleanTrue) retain];
}
+
if (![shouldPlayKeyboardSounds boolValue])
break;
+
default:
- _UIHardware$_playSystemSound$(self, _cmd, soundIndex);
+ _UIHardware$_playSystemSound$(self, _cmd, sound);
}
}
Warning_ = UCLocalize("WARNING");
_trace();
- int value = UIApplicationMain(argc, argv, @"Cydia", @"Cydia");
+ int value(UIApplicationMain(argc, argv, @"Cydia", @"Cydia"));
CGColorSpaceRelease(space_);
CFRelease(Locale_);