- case 2: role = @"Developer"; break;
-
- _nodefault
- }
-
- if (![role isEqualToString:Role_]) {
- bool rolling(Role_ == nil);
- Role_ = role;
-
- Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
- Role_, @"Role",
- nil];
-
- [Metadata_ setObject:Settings_ forKey:@"Settings"];
-
- Changed_ = true;
-
- if (rolling)
- [roledelegate_ loadData];
- else
- [roledelegate_ updateData];
- }
-}
-
-- (void) segmentChanged:(UISegmentedControl *)control {
- [self showDoneButton];
-}
-
-- (void) doneButtonClicked {
- [self save];
- [[self navigationController] dismissModalViewControllerAnimated:YES];
-}
-
-- (void) showDoneButton {
- UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]
- initWithTitle:UCLocalize("DONE")
- style:UIBarButtonItemStyleDone
- target:self
- action:@selector(doneButtonClicked)
- ];
- [[self navigationItem] setRightBarButtonItem:rightItem animated:[[self navigationItem] rightBarButtonItem] == nil];
- [rightItem release];
-}
-
-- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
- // XXX: For not having a single cell in the table, this sure is a lot of sections.
- return 6;
-}
-
-- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 0; // :(
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- return nil; // This method is required by the protocol.
-}
-
-- (NSString *) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
- if (section == 1)
- return UCLocalize("ROLE_EX");
- if (section == 4)
- return [NSString stringWithFormat:
- @"%@: %@\n%@: %@\n%@: %@",
- UCLocalize("USER"), UCLocalize("USER_EX"),
- UCLocalize("HACKER"), UCLocalize("HACKER_EX"),
- UCLocalize("DEVELOPER"), UCLocalize("DEVELOPER_EX")
- ];
- else return nil;
-}
-
-- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- if (section == 3) return 44.0f;
- else return 0;
-}
-
-- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- if (section == 3) return container_;
- else return nil;
-}
-
-@end
-/* }}} */
-/* Stash Controller {{{ */
-@interface CYStashController : CYViewController {
- UIActivityIndicatorView *spinner_;
- UILabel *status_;
- UILabel *caption_;
-}
-@end
-
-@implementation CYStashController
-- (id) init {
- if ((self = [super init])) {
- [[self view] setBackgroundColor:[UIColor viewFlipsideBackgroundColor]];
-
- spinner_ = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- CGRect spinrect = [spinner_ frame];
- spinrect.origin.x = ([[self view] frame].size.width / 2) - (spinrect.size.width / 2);
- spinrect.origin.y = [[self view] frame].size.height - 80.0f;
- [spinner_ setFrame:spinrect];
- [spinner_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin];
- [[self view] addSubview:spinner_];
- [spinner_ release];
- [spinner_ startAnimating];
-
- CGRect captrect;
- captrect.size.width = [[self view] frame].size.width;
- captrect.size.height = 40.0f;
- captrect.origin.x = 0;
- captrect.origin.y = ([[self view] frame].size.height / 2) - (captrect.size.height * 2);
- caption_ = [[UILabel alloc] initWithFrame:captrect];
- [caption_ setText:@"Initializing Filesystem"];
- [caption_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
- [caption_ setFont:[UIFont boldSystemFontOfSize:28.0f]];
- [caption_ setTextColor:[UIColor whiteColor]];
- [caption_ setBackgroundColor:[UIColor clearColor]];
- [caption_ setShadowColor:[UIColor blackColor]];
- [caption_ setTextAlignment:UITextAlignmentCenter];
- [[self view] addSubview:caption_];
- [caption_ release];
-
- CGRect statusrect;
- statusrect.size.width = [[self view] frame].size.width;
- statusrect.size.height = 30.0f;
- statusrect.origin.x = 0;
- statusrect.origin.y = ([[self view] frame].size.height / 2) - statusrect.size.height;
- status_ = [[UILabel alloc] initWithFrame:statusrect];
- [status_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin];
- [status_ setText:@"(Cydia will exit when complete.)"];
- [status_ setFont:[UIFont systemFontOfSize:16.0f]];
- [status_ setTextColor:[UIColor whiteColor]];
- [status_ setBackgroundColor:[UIColor clearColor]];
- [status_ setShadowColor:[UIColor blackColor]];
- [status_ setTextAlignment:UITextAlignmentCenter];
- [[self view] addSubview:status_];
- [status_ release];
- } return self;
-}
-
-- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
- return IsWildcat_ || orientation == UIInterfaceOrientationPortrait;
-}
-@end
-/* }}} */
-
-/* Cydia Container {{{ */
-@interface CYContainer : UIViewController <ProgressDelegate> {
- _transient Database *database_;
- RefreshBar *refreshbar_;
-
- bool dropped_;
- bool updating_;
- id updatedelegate_;
- UITabBarController *root_;
-}
-
-- (void) setTabBarController:(UITabBarController *)controller;
-
-- (void) dropBar:(BOOL)animated;
-- (void) beginUpdate;
-- (void) raiseBar:(BOOL)animated;
-- (BOOL) updating;
-
-@end
-
-@implementation CYContainer
-
-- (BOOL) _reallyWantsFullScreenLayout {
- return YES;
-}
-
-// NOTE: UIWindow only sends the top controller these messages,
-// So we have to forward them on.
-
-- (void) viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- [root_ viewDidAppear:animated];
-}
-
-- (void) viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [root_ viewWillAppear:animated];
-}
-
-- (void) viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
- [root_ viewDidDisappear:animated];
-}
-
-- (void) viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [root_ viewWillDisappear:animated];
-}
-
-- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
- return IsWildcat_ || orientation == UIInterfaceOrientationPortrait;
-}
-
-- (void) setTabBarController:(UITabBarController *)controller {
- root_ = controller;
- [[self view] addSubview:[root_ view]];
-}
-
-- (void) setUpdate:(NSDate *)date {
- [self beginUpdate];
-}
-
-- (void) beginUpdate {
- [self dropBar:YES];
- [refreshbar_ start];
-
- updating_ = true;
-
- [NSThread
- detachNewThreadSelector:@selector(performUpdate)
- toTarget:self
- withObject:nil
- ];
-}
-
-- (void) performUpdate { _pooled
- Status status;
- status.setDelegate(self);
- [database_ updateWithStatus:status];
-
- [self
- performSelectorOnMainThread:@selector(completeUpdate)
- withObject:nil
- waitUntilDone:NO
- ];
-}
-
-- (void) completeUpdate {
- if (!updating_) return;
- updating_ = false;
-
- [self raiseBar:YES];
- [refreshbar_ stop];
- [updatedelegate_ performSelector:@selector(reloadData) withObject:nil afterDelay:0];
-}
-
-- (void) cancelUpdate {
- updating_ = false;
- [self raiseBar:YES];
- [refreshbar_ stop];
- [updatedelegate_ performSelector:@selector(updateData) withObject:nil afterDelay:0];
-}
-
-- (void) cancelPressed {
- [self cancelUpdate];
-}
-
-- (BOOL) updating {
- return updating_;
-}
-
-- (void) setProgressError:(NSString *)error withTitle:(NSString *)title {
- [refreshbar_ setPrompt:[NSString stringWithFormat:UCLocalize("COLON_DELIMITED"), UCLocalize("ERROR"), error]];
-}
-
-- (void) startProgress {
-}
-
-- (void) setProgressTitle:(NSString *)title {
- [self
- performSelectorOnMainThread:@selector(_setProgressTitle:)
- withObject:title
- waitUntilDone:YES
- ];
-}
-
-- (bool) isCancelling:(size_t)received {
- return !updating_;
-}
-
-- (void) setProgressPercent:(float)percent {
- [self
- performSelectorOnMainThread:@selector(_setProgressPercent:)
- withObject:[NSNumber numberWithFloat:percent]
- waitUntilDone:YES
- ];
-}
-
-- (void) addProgressOutput:(NSString *)output {
- [self
- performSelectorOnMainThread:@selector(_addProgressOutput:)
- withObject:output
- waitUntilDone:YES
- ];
-}
-
-- (void) _setProgressTitle:(NSString *)title {
- [refreshbar_ setPrompt:title];
-}
-
-- (void) _setProgressPercent:(NSNumber *)percent {
- [refreshbar_ setProgress:[percent floatValue]];
-}
-
-- (void) _addProgressOutput:(NSString *)output {
-}
-
-- (void) setUpdateDelegate:(id)delegate {
- updatedelegate_ = delegate;
-}