- (NSString *) stringByAddingPercentEscapesIncludingReserved {
return [(id)CFURLCreateStringByAddingPercentEscapes(
- kCFAllocatorDefault,
+ kCFAllocatorDefault,
(CFStringRef) self,
NULL,
CFSTR(";/?:@&=+$,"),
- (void) removeProgressHUD:(UIProgressHUD *)hud;
- (UCViewController *) pageForPackage:(NSString *)name;
- (PackageController *) packageController;
+- (void) showActionSheet:(UIActionSheet *)sheet fromItem:(UIBarButtonItem *)item;
@end
/* }}} */
- (id) invokeDefaultMethodWithArguments:(NSArray *)args {
[self dismissModalViewControllerAnimated:YES];
[delegate_ cancelAndClear:NO];
-
+
return nil;
}
if (issues_ == nil && ![self isLoading]) [[self navigationItem] setRightBarButtonItem:rightItem];
else [super applyRightButton];
#else
- [[self navigationItem] setRightBarButtonItem:nil];
+ [[self navigationItem] setRightBarButtonItem:nil];
#endif
[rightItem release];
}
(bounds.size.width - prgsize.width) / 2,
bounds.size.height - prgsize.height - 64
}, prgsize};
-
+
float closewidth = bounds.size.width - 20;
if (closewidth > 300) closewidth = 300;
[super viewDidAppear:animated];
[[self navigationItem] setHidesBackButton:YES];
[[[self navigationController] navigationBar] setBarStyle:UIBarStyleBlack];
-
+
[self positionViews];
}
- (void) drawContentRect:(CGRect)rect {
BOOL selected = [self isSelected];
-
+
[icon_ drawInRect:CGRectMake(8, 7, 32, 32)];
if (selected)
@end
/* }}} */
/* Package Controller {{{ */
-@interface PackageController : CYBrowserController {
+@interface PackageController : CYBrowserController <
+ UIActionSheetDelegate
+> {
_transient Database *database_;
Package *package_;
NSString *name_;
NSString *buttonName = [buttons_ objectAtIndex:button];
[self _clickButtonWithName:buttonName];
}
-
+
[sheet dismissWithClickedButtonIndex:-1 animated:YES];
}
}
}
#if !AlwaysReload
-- (void) _actionButtonClicked {
+- (void) _customButtonClicked {
int count([buttons_ count]);
if (count == 0)
return;
[sheet setCancelButtonIndex:[sheet numberOfButtons] - 1];
}
[sheet setContext:@"modify"];
-
+
[delegate_ showActionSheet:sheet fromItem:[[self navigationItem] rightBarButtonItem]];
}
}
-- (void) actionButtonClicked {
- // Wait until it's done loading.
+- (void) customButtonClicked {
+ // Wait until it's done loading.
if (![self isLoading])
- [self _actionButtonClicked];
+ [self _customButtonClicked];
}
- (void) reloadButtonClicked {
initWithTitle:count == 0 ? nil : count != 1 ? UCLocalize("MODIFY") : [buttons_ objectAtIndex:0]
style:UIBarButtonItemStylePlain
target:self
- action:@selector(actionButtonClicked)
+ action:@selector(customButtonClicked)
];
if (![self isLoading]) [[self navigationItem] setRightBarButtonItem:actionItem];
- else [super applyRightButton];
+ else [super applyRightButton];
[actionItem release];
}
- (id) initWithDatabase:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object;
@end
-
+
@implementation FilteredPackageController
- (void) dealloc {
[packages_ release];
[title_ release];
-
+
[super dealloc];
}
}
@end
-
+
/* }}} */
/* Add Source Controller {{{ */
- (void) setSource:(Source *)source {
[self clearSource];
-
+
if (icon_ == nil)
icon_ = [UIImage applicationImageNamed:[NSString stringWithFormat:@"Sources/%@.png", [source host]]];
if (icon_ == nil)
SourceCell *cell = (SourceCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil) cell = [[[SourceCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease];
[cell setSource:[self sourceAtIndexPath:indexPath]];
-
+
return cell;
}
if ((self = [super init]) != nil) {
[[self navigationItem] setTitle:UCLocalize("SOURCES")];
[self updateButtonsForEditingStatus:NO animated:NO];
-
+
database_ = database;
sources_ = [[NSMutableArray arrayWithCapacity:16] retain];
];
[[self navigationItem] setRightBarButtonItem:rightItem animated:animated];
[rightItem release];
-
+
if (IsWildcat_ && !editing) {
UIBarButtonItem *settingsItem = [[UIBarButtonItem alloc]
initWithTitle:UCLocalize("SETTINGS")
- (void) editButtonClicked {
[list_ setEditing:![list_ isEditing] animated:YES];
-
+
[self updateButtonsForEditingStatus:[list_ isEditing] animated:YES];
}
- (id) init {
if ((self = [super init]) != nil) {
[[self navigationItem] setTitle:UCLocalize("MANAGE")];
-
+
UIBarButtonItem *settingsItem = [[UIBarButtonItem alloc]
initWithTitle:UCLocalize("SETTINGS")
style:UIBarButtonItemStylePlain
];
[[self navigationItem] setLeftBarButtonItem:settingsItem];
[settingsItem release];
-
+
[self queueStatusDidChange];
} return self;
}
action:@selector(queueButtonClicked)
];
[[self navigationItem] setRightBarButtonItem:queueItem];
-
+
[queueItem release];
} else {
[[self navigationItem] setRightBarButtonItem:nil];
frame.origin.x = [self frame].size.width - frame.size.width - 5;
frame.origin.y = ([self frame].size.height - frame.size.height) / 2;
[cancel_ setFrame:frame];
-
+
CGSize prgsize = {75, 100};
CGRect prgrect = {{
[self frame].size.width - prgsize.width - 10,
([self frame].size.height - prgsize.height) / 2
} , prgsize};
[progress_ setFrame:prgrect];
-
+
CGSize indsize([UIProgressIndicator defaultSizeForStyle:[indicator_ activityIndicatorViewStyle]]);
unsigned indoffset = ([self frame].size.height - indsize.height) / 2;
CGRect indrect = {{indoffset, indoffset}, indsize};
[indicator_ setFrame:indrect];
-
+
CGSize prmsize = {215, indsize.height + 4};
CGRect prmrect = {{
indoffset * 2 + indsize.width,
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
-
+
[self positionViews];
}
[progress_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin];
[progress_ setStyle:0];
[self addSubview:progress_];
-
+
cancel_ = [[UINavigationButton alloc] initWithTitle:UCLocalize("CANCEL") style:UINavigationButtonStyleHighlighted];
[cancel_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
[cancel_ addTarget:delegate action:@selector(cancelPressed) forControlEvents:UIControlEventTouchUpInside];
[cancel_ setBarStyle:barstyle];
-
+
[self positionViews];
} return self;
}
Database *database_;
}
-@end
+@end
@implementation CYTabBarController
[list_ reloadData];
else
[delegate_ updateData];
-
+
[[self navigationItem] setTitle:editing_ ? UCLocalize("SECTION_VISIBILITY") : UCLocalize("SECTIONS")];
[[[self navigationItem] rightBarButtonItem] setTitle:[sections_ count] == 0 ? nil : editing_ ? UCLocalize("DONE") : UCLocalize("EDIT")];
[[[self navigationItem] rightBarButtonItem] setStyle:editing_ ? UIBarButtonItemStyleDone : UIBarButtonItemStylePlain];
}
- (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- if (!search_) {
+ [super viewDidAppear:animated];
+ if (!search_) {
search_ = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, [[self view] bounds].size.width, 44.0f)];
[search_ layoutSubviews];
[search_ setPlaceholder:UCLocalize("SEARCH_EX")];
[ignoredSwitch_ release];
[subscribedCell_ release];
[ignoredCell_ release];
-
+
[super dealloc];
}
switch ([indexPath row]) {
case 0: return subscribedCell_;
case 1: return ignoredCell_;
-
+
_nodefault
}
[table_ release];
[segment_ release];
[container_ release];
-
+
[super dealloc];
}
if ((self = [super init])) {
database_ = database;
roledelegate_ = delegate;
-
+
[[self navigationItem] setTitle:UCLocalize("WHO_ARE_YOU")];
-
+
NSArray *items = [NSArray arrayWithObjects:
- UCLocalize("USER"),
+ UCLocalize("USER"),
UCLocalize("HACKER"),
UCLocalize("DEVELOPER"),
nil];
segment_ = [[UISegmentedControl alloc] initWithItems:items];
container_ = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, 44.0f)];
[container_ addSubview:segment_];
-
+
int index = -1;
if ([Role_ isEqualToString:@"User"]) index = 0;
if ([Role_ isEqualToString:@"Hacker"]) index = 1;
[segment_ setSelectedSegmentIndex:index];
[self showDoneButton];
}
-
+
[segment_ addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
[self resizeSegmentedControl];
-
+
table_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStyleGrouped];
[table_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[table_ setDelegate:self];
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
-
+
[self resizeSegmentedControl];
}
- (void) save {
NSString *role = nil;
-
+
switch ([segment_ selectedSegmentIndex]) {
case 0: role = @"User"; break;
case 1: role = @"Hacker"; break;
if (![role isEqualToString:Role_]) {
Role_ = role;
-
+
Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
Role_, @"Role",
nil];
[Metadata_ setObject:Settings_ forKey:@"Settings"];
Changed_ = true;
-
+
[roledelegate_ updateData];
}
}
}
- (NSString *) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
- if (section == 1)
+ if (section == 1)
return UCLocalize("ROLE_EX");
- if (section == 4)
+ if (section == 4)
return [NSString stringWithFormat:
@"%@: %@\n%@: %@\n%@: %@",
- UCLocalize("USER"), UCLocalize("USER_EX"),
- UCLocalize("HACKER"), UCLocalize("HACKER_EX"),
+ UCLocalize("USER"), UCLocalize("USER_EX"),
+ UCLocalize("HACKER"), UCLocalize("HACKER_EX"),
UCLocalize("DEVELOPER"), UCLocalize("DEVELOPER_EX")
];
else return nil;
- (void) beginUpdate {
[self dropBar:YES];
[refreshbar_ start];
-
+
updating_ = true;
-
+
[NSThread
detachNewThreadSelector:@selector(performUpdate)
toTarget:self
- (void) completeUpdate {
updating_ = false;
-
+
[self raiseBar:YES];
[refreshbar_ stop];
[updatedelegate_ performSelector:@selector(reloadData) withObject:nil afterDelay:0];
[self raiseBar:NO];
[self dropBar:NO];
}
-
+
// XXX: fix Apple's layout bug
[[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
if ([[controller tabBarItem] tag] == tag) return i;
i += 1;
}
-
+
return -1;
}
- (void) _refreshIfPossible {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
Reachability* reachability = [Reachability reachabilityWithHostName:@"cydia.saurik.com"];
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
-
+
if (loaded_ || ManualRefresh || remoteHostStatus == NotReachable) loaded:
[self performSelectorOnMainThread:@selector(_loaded) withObject:nil waitUntilDone:NO];
else {
NSString *badge([[NSNumber numberWithInt:changes] stringValue]);
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setBadgeValue:badge];
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setAnimatedBadge:YES];
-
+
if ([self respondsToSelector:@selector(setApplicationBadge:)])
[self setApplicationBadge:badge];
else
} else {
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setBadgeValue:nil];
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kChangesTag]] tabBarItem] setAnimatedBadge:NO];
-
+
if ([self respondsToSelector:@selector(removeApplicationBadge)])
[self removeApplicationBadge];
else // XXX: maybe use setApplicationBadgeString also?
- (void) confirmWithNavigationController:(UINavigationController *)navigation {
ProgressController *progress = [[[ProgressController alloc] initWithDatabase:database_ delegate:self] autorelease];
-
+
if (navigation != nil) {
[navigation pushViewController:progress animated:YES];
} else {
if (IsWildcat_) [navigation setModalPresentationStyle:UIModalPresentationFormSheet];
[container_ presentModalViewController:navigation animated:YES];
}
-
+
[progress
detachNewThreadSelector:@selector(perform)
toTarget:database_
return installed_;
}
-- (void) tabBarController:(id)tabBarController didSelectViewController:(UIViewController *)viewController {
+- (void) tabBarController:(id)tabBarController didSelectViewController:(UIViewController *)viewController {
int tag = [[viewController tabBarItem] tag];
if (tag == tag_) {
[(CYNavigationController *)[tabbar_ selectedViewController] popToRootViewControllerAnimated:YES];
}
[self updateData];
-
+
Queuing_ = false;
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:nil];
[queueDelegate_ queueStatusDidChange];*/
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:UCLocalize("Q_D")];
[(CYNavigationController *)[tabbar_ selectedViewController] reloadData];
-
+
[queueDelegate_ queueStatusDidChange];
}
}
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
NSString *context([alert context]);
-
+
if ([context isEqualToString:@"fixhalf"]) {
if (button == [alert firstOtherButtonIndex]) {
@synchronized (self) {
}
}
-- (void) applicationWillResignActive:(UIApplication *)application {
+- (void) applicationWillResignActive:(UIApplication *)application {
// Stop refreshing if you get a phone call or lock the device.
if ([container_ updating]) [container_ cancelUpdate];
-
+
if ([[self superclass] instancesRespondToSelector:@selector(applicationWillResignActive:)])
[super applicationWillResignActive:application];
}
_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("INSTALLED") image:[UIImage applicationImageNamed:@"manage.png"] tag:kInstalledTag] autorelease] atIndex:3];
} else {
[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)];
[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_);