#define USE_SYSTEM_MALLOC 1
/* #include Directives {{{ */
-#import "UICaboodle/UCPlatform.h"
-#import "UICaboodle/UCLocalize.h"
+#include "UICaboodle/UCPlatform.h"
+#include "UICaboodle/UCLocalize.h"
#include <objc/objc.h>
#include <objc/runtime.h>
#include <CoreGraphics/CoreGraphics.h>
-#include <GraphicsServices/GraphicsServices.h>
#include <Foundation/Foundation.h>
#if 0
#include <CoreFoundation/CFPriv.h>
#include <CoreFoundation/CFUniChar.h>
-#import <UIKit/UIKit.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+
+#include <UIKit/UIKit.h>
+#include "iPhonePrivate.h"
+
+#include <IOKit/IOKitLib.h>
#include <WebCore/WebCoreThread.h>
-#import <WebKit/WebDefaultUIKitDelegate.h>
#include <algorithm>
#include <iomanip>
#include <sys/param.h>
#include <sys/mount.h>
+#include <fcntl.h>
#include <notify.h>
#include <dlfcn.h>
#include <ext/hash_map>
-#include <notify.h>
-
-#import "UICaboodle/BrowserView.h"
-#import "UICaboodle/ResetView.h"
+#include "UICaboodle/BrowserView.h"
-#import "substrate.h"
-
-// Apple's sample Reachability code, ASPL licensed.
-#import "Reachability.h"
-/* }}} */
-
-/* Header Fixes and Updates {{{ */
-typedef enum {
- UIModalPresentationFullScreen = 0,
- UIModalPresentationPageSheet,
- UIModalPresentationFormSheet,
- UIModalPresentationCurrentContext,
-} UIModalPresentationStyle;
-
-@interface UIAlertView (Private)
-- (void)setNumberOfRows:(int)rows;
-- (void)setContext:(id)context;
-- (id)context;
-@end
-
-@interface UIViewController (UIKit)
-- (id)navigationItem;
-- (id)navigationController;
-- (id)tabBarItem;
-@end
-
-@interface UITabBarController : UIViewController {
- id _tabBar;
- id _containerView;
- id _viewControllerTransitionView;
- id _viewControllers;
- id _tabBarItemsToViewControllers;
- id _selectedViewController;
- id _moreNavigationController;
- id _customizableViewControllers;
- id _delegate;
- id _selectedViewControllerDuringWillAppear;
- id _transientViewController;
- unsigned int isShowingMoreItem:1;
- unsigned int needsToRebuildItems:1;
- unsigned int isBarHidden:1;
- unsigned int editButtonOnLeft:1;
-}
-@end
+#include "substrate.h"
/* }}} */
/* Profiler {{{ */
} return self;
}
-- (void)_updateFrameForDisplay {
+- (void) _updateFrameForDisplay {
[super _updateFrameForDisplay];
if ([self cancelButtonIndex] == -1) {
NSArray *buttons = [self buttons];
#define lprintf(args...) fprintf(stderr, args)
-#define ForRelease 0
+#define ForRelease 1
#define TraceLogging (1 && !ForRelease)
#define HistogramInsertionSort (0 && !ForRelease)
#define ProfileTimes (0 && !ForRelease)
@end
/* }}} */
-NSUInteger WebScriptObject$countByEnumeratingWithState$objects$count$(WebScriptObject *self, SEL sel, NSFastEnumerationState *state, id *objects, NSUInteger count) {
+@implementation WebScriptObject (NSFastEnumeration)
+
+- (NSUInteger) countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)objects count:(NSUInteger)count {
size_t length([self count] - state->state);
if (length <= 0)
return 0;
return length;
}
+@end
+
NSUInteger DOMNodeList$countByEnumeratingWithState$objects$count$(DOMNodeList *self, SEL sel, NSFastEnumerationState *state, id *objects, NSUInteger count) {
size_t length([self length] - state->state);
if (length <= 0)
return length;
}
-@interface NSString (UIKit)
-- (NSString *) stringByAddingPercentEscapes;
-@end
-
/* Cydia NSString Additions {{{ */
@interface NSString (Cydia)
+ (NSString *) stringWithUTF8BytesNoCopy:(const char *)bytes length:(int)length;
- (NSString *) stringByAddingPercentEscapesIncludingReserved {
return [(id)CFURLCreateStringByAddingPercentEscapes(
- kCFAllocatorDefault,
+ kCFAllocatorDefault,
(CFStringRef) self,
NULL,
CFSTR(";/?:@&=+$,"),
@end
/* }}} */
/* CoreGraphics Primitives {{{ */
-class CGColor {
+class CYColor {
private:
CGColorRef color_;
public:
- CGColor() :
+ CYColor() :
color_(NULL)
{
}
- CGColor(CGColorSpaceRef space, float red, float green, float blue, float alpha) :
+ CYColor(CGColorSpaceRef space, float red, float green, float blue, float alpha) :
color_(NULL)
{
Set(space, red, green, blue, alpha);
CGColorRelease(color_);
}
- ~CGColor() {
+ ~CYColor() {
Clear();
}
void Set(CGColorSpaceRef space, float red, float green, float blue, float alpha) {
Clear();
float color[] = {red, green, blue, alpha};
- color_ = CGColorCreate(space, color);
+ color_ = CGColorCreate(space, (CGFloat *) color);
}
operator CGColorRef() {
static bool Queuing_;
-static CGColor Blue_;
-static CGColor Blueish_;
-static CGColor Black_;
-static CGColor Off_;
-static CGColor White_;
-static CGColor Gray_;
-static CGColor Green_;
-static CGColor Purple_;
-static CGColor Purplish_;
+static CYColor Blue_;
+static CYColor Blueish_;
+static CYColor Black_;
+static CYColor Off_;
+static CYColor White_;
+static CYColor Gray_;
+static CYColor Green_;
+static CYColor Purple_;
+static CYColor Purplish_;
static UIColor *InstallingColor_;
static UIColor *RemovingColor_;
static UIFont *Font22Bold_;
static const char *Machine_ = NULL;
-static const NSString *System_ = NULL;
-static const NSString *SerialNumber_ = nil;
-static const NSString *ChipID_ = nil;
-static const NSString *Token_ = nil;
-static const NSString *UniqueID_ = nil;
-static const NSString *Build_ = nil;
-static const NSString *Product_ = nil;
-static const NSString *Safari_ = nil;
+static NSString *System_ = nil;
+static NSString *SerialNumber_ = nil;
+static NSString *ChipID_ = nil;
+static NSString *Token_ = nil;
+static NSString *UniqueID_ = nil;
+static NSString *Build_ = nil;
+static NSString *Product_ = nil;
+static NSString *Safari_ = nil;
static CFLocaleRef Locale_;
static NSArray *Languages_;
- (void) installPackage:(Package *)package;
- (void) installPackages:(NSArray *)packages;
- (void) removePackage:(Package *)package;
+- (void) beginUpdate;
+- (BOOL) updating;
- (void) distUpgrade;
+- (void) loadData;
- (void) updateData;
- (void) syncData;
- (void) showSettings;
- (UIProgressHUD *) addProgressHUD;
- (void) removeProgressHUD:(UIProgressHUD *)hud;
-- (UIViewController *) pageForPackage:(NSString *)name;
+- (CYViewController *) pageForPackage:(NSString *)name;
- (PackageController *) packageController;
+- (void) showActionSheet:(UIActionSheet *)sheet fromItem:(UIBarButtonItem *)item;
@end
/* }}} */
@end
/* }}} */
/* Delegate Helpers {{{ */
-@implementation NSObject(ProgressDelegate)
+@implementation NSObject (ProgressDelegate)
- (void) _setProgressErrorPackage:(NSArray *)args {
[self performSelector:@selector(setProgressError:forPackage:)
- (void) setProgressError:(NSString *)error forPackage:(NSString *)id {
Package *package = id == nil ? nil : [[Database sharedInstance] packageWithName:id];
- // XXX: holy typecast batman!
- [self setProgressError:error withTitle:(package == nil ? id : [package name])];
+
+ [self performSelector:@selector(setProgressError:withTitle:)
+ withObject:error
+ withObject:(package == nil ? id : [package name])
+ ];
}
@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"];
return iterator.end() ? nil : [Package packageWithIterator:iterator withZone:NULL inPool:pool_ database:self];
} }
-- (Database *) init {
+- (id) init {
if ((self = [super init]) != nil) {
policy_ = NULL;
records_ = NULL;
return;
if ([self popErrorWithTitle:title forOperation:ListUpdate(status, list, PulseInterval_)])
- /* XXX: ignore this because users suck and don't understand why refreshing is important: return */;
+ /* XXX: ignore this because users suck and don't understand why refreshing is important: return */
+ /* XXX: why the hell is an empty if statement a clang error? */ (void) 0;
[Metadata_ setObject:[NSDate date] forKey:@"LastUpdate"];
Changed_ = true;
id values[count];
for (unsigned i(0); i != count; ++i)
values[i] = [arguments objectAtIndex:i];
- return [[[NSString alloc] initWithFormat:format arguments:reinterpret_cast<va_list>(values)] autorelease];
+ return [[[NSString alloc] initWithFormat:format arguments:*(reinterpret_cast<va_list *>(&values))] autorelease];
}
- (NSString *) localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)table {
@end
/* }}} */
-/* Cydia View Controller {{{ */
-@interface CYViewController : UCViewController { }
-@end
-
-@implementation CYViewController
-@end
-/* }}} */
-
+/* Cydia Browser Controller {{{ */
@interface CYBrowserController : BrowserController {
CydiaObject *cydia_;
}
}
@end
+/* }}} */
+/* Confirmation {{{ */
@protocol ConfirmationControllerDelegate
- (void) cancelAndClear:(bool)clear;
- (void) confirmWithNavigationController:(UINavigationController *)navigation;
- (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];
}
[database_ setDelegate:self];
delegate_ = delegate;
- [[self view] setBackgroundColor:(CGColor *)[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f]];
+ [[self view] setBackgroundColor:[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f]];
progress_ = [[UIProgressBar alloc] init];
[progress_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin)];
(bounds.size.width - prgsize.width) / 2,
bounds.size.height - prgsize.height - 64
}, prgsize};
-
+
float closewidth = bounds.size.width - 20;
if (closewidth > 300) closewidth = 300;
- (void) viewWillAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[self navigationItem] setHidesBackButton:YES];
- [[[self navigationController] navigationBar] setBarStyle:1];
-
+ [[[self navigationController] navigationBar] setBarStyle:UIBarStyleBlack];
+
[self positionViews];
}
/* }}} */
/* Cell Content View {{{ */
+@protocol ContentDelegate
+- (void) drawContentRect:(CGRect)rect;
+@end
+
@interface ContentView : UIView {
- _transient id delegate_;
+ _transient id<ContentDelegate> delegate_;
}
@end
} return self;
}
-- (void) setDelegate:(id)delegate {
+- (void) setDelegate:(id<ContentDelegate>)delegate {
delegate_ = delegate;
}
@end
/* }}} */
/* Package Cell {{{ */
-@interface PackageCell : UITableViewCell {
+@interface PackageCell : UITableViewCell <
+ ContentDelegate
+> {
UIImage *icon_;
NSString *name_;
NSString *description_;
if (!selected)
UISetColor(commercial_ ? Purple_ : Black_);
- [name_ drawAtPoint:CGPointMake(48, 8) forWidth:(width - (placard_ == nil ? 80 : 106)) withFont:Font18Bold_ ellipsis:2];
- [source_ drawAtPoint:CGPointMake(58, 29) forWidth:(width - 95) withFont:Font12_ ellipsis:2];
+ [name_ drawAtPoint:CGPointMake(48, 8) forWidth:(width - (placard_ == nil ? 80 : 106)) withFont:Font18Bold_ lineBreakMode:UILineBreakModeTailTruncation];
+ [source_ drawAtPoint:CGPointMake(58, 29) forWidth:(width - 95) withFont:Font12_ lineBreakMode:UILineBreakModeTailTruncation];
if (!selected)
UISetColor(commercial_ ? Purplish_ : Gray_);
- [description_ drawAtPoint:CGPointMake(12, 46) forWidth:(width - 46) withFont:Font14_ ellipsis:2];
+ [description_ drawAtPoint:CGPointMake(12, 46) forWidth:(width - 46) withFont:Font14_ lineBreakMode:UILineBreakModeTailTruncation];
if (placard_ != nil)
[placard_ drawAtPoint:CGPointMake(width - 52, 9)];
@end
/* }}} */
/* Section Cell {{{ */
-@interface SectionCell : UITableViewCell {
+@interface SectionCell : UITableViewCell <
+ ContentDelegate
+> {
NSString *basic_;
NSString *section_;
NSString *name_;
BOOL editing_;
}
-- (id) init;
- (void) setSection:(Section *)section editing:(BOOL)editing;
@end
[switch_ setOn:(isSectionVisible(basic_) ? 1 : 0) animated:NO];
}
- [self setAccessoryType:editing ? 0 : 1 /*UITableViewCellAccessoryDisclosureIndicator*/];
+ [self setAccessoryType:editing ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator];
[content_ setNeedsDisplay];
}
- (void) drawContentRect:(CGRect)rect {
BOOL selected = [self isSelected];
-
+
[icon_ drawInRect:CGRectMake(8, 7, 32, 32)];
if (selected)
if (editing_)
width -= 87;
- [name_ drawAtPoint:CGPointMake(48, 9) forWidth:(width - 70) withFont:Font22Bold_ ellipsis:2];
+ [name_ drawAtPoint:CGPointMake(48, 9) forWidth:(width - 70) withFont:Font22Bold_ lineBreakMode:UILineBreakModeTailTruncation];
CGSize size = [count_ sizeWithFont:Font14_];
/* }}} */
/* File Table {{{ */
-@interface FileTable : CYViewController {
+@interface FileTable : CYViewController <
+ UITableViewDataSource,
+ UITableViewDelegate
+> {
_transient Database *database_;
Package *package_;
NSString *name_;
[super dealloc];
}
-- (int) tableView:(UITableView *)tableView numberOfRowsInSection:(int)section {
+- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return files_ == nil ? 0 : [files_ count];
}
[cell setFont:[UIFont systemFontOfSize:16]];
}
[cell setText:[files_ objectAtIndex:indexPath.row]];
- [cell setSelectionStyle:0 /*UITableViewCellSelectionStyleNone*/];
+ [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
@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];
- } else {
- [super alertSheet:sheet clickedButtonAtIndex:button];
}
}
}
#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.
- 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;
}
@end
/* }}} */
/* Package Table {{{ */
-@interface PackageTable : UIView {
+@interface PackageTable : UIView <
+ UITableViewDataSource,
+ UITableViewDelegate
+> {
_transient Database *database_;
NSMutableArray *packages_;
NSMutableArray *sections_;
}
- (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {
- PackageCell *cell([table dequeueReusableCellWithIdentifier:@"Package"]);
+ PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]);
if (cell == nil)
cell = [[[PackageCell alloc] init] autorelease];
[cell setPackage:[self packageAtIndexPath:path]];
- (id) initWithDatabase:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object;
@end
-
+
@implementation FilteredPackageController
- (void) dealloc {
[packages_ release];
[title_ release];
-
+
[super dealloc];
}
[[self navigationController] pushViewController:view animated:YES];
}
-- (id) title { return title_; }
+- (NSString *) title { return title_; }
- (id) initWithDatabase:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object {
if ((self = [super init]) != nil) {
}
@end
-
+
/* }}} */
/* Add Source Controller {{{ */
@end
/* }}} */
/* Source Cell {{{ */
-@interface SourceCell : UITableViewCell {
+@interface SourceCell : UITableViewCell <
+ ContentDelegate
+> {
UIImage *icon_;
NSString *origin_;
NSString *description_;
- (void) setSource:(Source *)source {
[self clearSource];
-
+
if (icon_ == nil)
icon_ = [UIImage applicationImageNamed:[NSString stringWithFormat:@"Sources/%@.png", [source host]]];
if (icon_ == nil)
if (!selected)
UISetColor(Black_);
- [origin_ drawAtPoint:CGPointMake(48, 8) forWidth:(width - 80) withFont:Font18Bold_ ellipsis:2];
+ [origin_ drawAtPoint:CGPointMake(48, 8) forWidth:(width - 80) withFont:Font18Bold_ lineBreakMode:UILineBreakModeTailTruncation];
if (!selected)
UISetColor(Blue_);
- [label_ drawAtPoint:CGPointMake(58, 29) forWidth:(width - 95) withFont:Font12_ ellipsis:2];
+ [label_ drawAtPoint:CGPointMake(58, 29) forWidth:(width - 95) withFont:Font12_ lineBreakMode:UILineBreakModeTailTruncation];
if (!selected)
UISetColor(Gray_);
- [description_ drawAtPoint:CGPointMake(12, 46) forWidth:(width - 40) withFont:Font14_ ellipsis:2];
+ [description_ drawAtPoint:CGPointMake(12, 46) forWidth:(width - 40) withFont:Font14_ lineBreakMode:UILineBreakModeTailTruncation];
}
@end
/* }}} */
/* Source Table {{{ */
-@interface SourceTable : CYViewController {
+@interface SourceTable : CYViewController <
+ UITableViewDataSource,
+ UITableViewDelegate
+> {
_transient Database *database_;
UITableView *list_;
NSMutableArray *sources_;
- (id) initWithDatabase:(Database *)database;
+- (void) updateButtonsForEditingStatus:(BOOL)editing animated:(BOOL)animated;
+
@end
@implementation SourceTable
[list_ deselectRowAtIndexPath:[list_ indexPathForSelectedRow] animated:animated];
}
-- (int) numberOfSectionsInTableView:(UITableView *)tableView {
+- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return offset_ == 0 ? 1 : 2;
}
-- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(int)section {
+- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
switch (section + (offset_ == 0 ? 1 : 0)) {
case 0: return UCLocalize("ENTERED_BY_USER");
case 1: return UCLocalize("INSTALLED_BY_PACKAGE");
}
}
-- (int) tableView:(UITableView *)tableView numberOfRowsInSection:(int)section {
+- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
int count = [sources_ count];
switch (section) {
case 0: return (offset_ == 0 ? count : offset_);
SourceCell *cell = (SourceCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil) cell = [[[SourceCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease];
[cell setSource:[self sourceAtIndexPath:indexPath]];
-
+
return cell;
}
-- (int) tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {
- return 1; //UITableViewCellAccessoryDisclosureIndicator?
+- (UITableViewCellAccessoryType) tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {
+ return UITableViewCellAccessoryDisclosureIndicator;
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self _endConnection:connection];
}
-- (id)title { return UCLocalize("SOURCES"); }
+- (NSString *) title { return UCLocalize("SOURCES"); }
- (NSURLConnection *) _requestHRef:(NSString *)href method:(NSString *)method {
NSMutableURLRequest *request = [NSMutableURLRequest
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) initWithDatabase:(Database *)database;
+- (void) updateRoleButton;
+- (void) queueStatusDidChange;
+
@end
@implementation InstalledController
[super dealloc];
}
-- (id) title { return UCLocalize("INSTALLED"); }
+- (NSString *) title { return UCLocalize("INSTALLED"); }
- (id) initWithDatabase:(Database *)database {
if ((self = [super initWithDatabase:database title:UCLocalize("INSTALLED") filter:@selector(isInstalledAndVisible:) with:[NSNumber numberWithBool:YES]]) != nil) {
@interface ManageController : CYBrowserController {
}
+- (void) queueStatusDidChange;
@end
@implementation ManageController
- (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];
}
[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self setTintColor:[UIColor colorWithRed:0.23 green:0.23 blue:0.23 alpha:1]];
- [self setBarStyle:1];
+ [self setBarStyle:UIBarStyleBlack];
- int barstyle([self _barStyle:NO]);
- bool ugly(barstyle == 0);
+ UIBarStyle barstyle([self _barStyle:NO]);
+ bool ugly(barstyle == UIBarStyleDefault);
UIProgressIndicatorStyle style = ugly ?
UIProgressIndicatorStyleMediumBrown :
[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;
}
@end
/* }}} */
+@class CYNavigationController;
+
/* Cydia Tab Bar Controller {{{ */
@interface CYTabBarController : UITabBarController {
Database *database_;
}
-@end
+@end
@implementation CYTabBarController
- (void) reloadData {
size_t count([[self viewControllers] count]);
for (size_t i(0); i != count; ++i) {
- UIViewController *page([[self viewControllers] objectAtIndex:(count - i - 1)]);
+ CYNavigationController *page([[self viewControllers] objectAtIndex:(count - i - 1)]);
[page reloadData];
}
}
-- (id) initWithDatabase: (Database *)database {
+- (id) initWithDatabase:(Database *)database {
if ((self = [super init]) != nil) {
database_ = database;
} return self;
/* }}} */
/* Cydia Navigation Controller {{{ */
-@interface CYNavigationController : UINavigationController <
- ProgressDelegate
-> {
+@interface CYNavigationController : UINavigationController {
_transient Database *database_;
- id delegate_;
+ id<UINavigationControllerDelegate> delegate_;
}
- (id) initWithDatabase:(Database *)database;
- (void) reloadData {
size_t count([[self viewControllers] count]);
for (size_t i(0); i != count; ++i) {
- UIViewController *page([[self viewControllers] objectAtIndex:(count - i - 1)]);
+ CYViewController *page([[self viewControllers] objectAtIndex:(count - i - 1)]);
[page reloadData];
}
}
-- (void) setDelegate:(id)delegate {
+- (void) setDelegate:(id<UINavigationControllerDelegate>)delegate {
delegate_ = delegate;
}
/* }}} */
/* Sections Controller {{{ */
-@interface SectionsController : CYViewController {
+@interface SectionsController : CYViewController <
+ UITableViewDataSource,
+ UITableViewDelegate
+> {
_transient Database *database_;
NSMutableArray *sections_;
NSMutableArray *filtered_;
- (void) reloadData;
- (void) resetView;
+- (void) editButtonClicked;
+
@end
@implementation SectionsController
return section;
}
-- (int) tableView:(UITableView *)tableView numberOfRowsInSection:(int)section {
+- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return editing_ ? [sections_ count] : [filtered_ count] + 1;
}
[[self navigationController] pushViewController:table animated:YES];
}
-- (id) title { return UCLocalize("SECTIONS"); }
+- (NSString *) title { return UCLocalize("SECTIONS"); }
- (id) initWithDatabase:(Database *)database {
if ((self = [super init]) != nil) {
[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];
@end
/* }}} */
/* Changes Controller {{{ */
-@interface ChangesController : CYViewController {
+@interface ChangesController : CYViewController <
+ UITableViewDataSource,
+ UITableViewDelegate
+> {
_transient Database *database_;
NSMutableArray *packages_;
NSMutableArray *sections_;
}
- (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {
- PackageCell *cell([table dequeueReusableCellWithIdentifier:@"Package"]);
+ PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]);
if (cell == nil)
cell = [[[PackageCell alloc] init] autorelease];
[cell setPackage:[self packageAtIndexPath:path]];
}
- (void) refreshButtonClicked {
- [[UIApplication sharedApplication] beginUpdate];
+ [delegate_ beginUpdate];
[[self navigationItem] setLeftBarButtonItem:nil];
}
[delegate_ distUpgrade];
}
-- (id) title { return UCLocalize("CHANGES"); }
+- (NSString *) title { return UCLocalize("CHANGES"); }
- (id) initWithDatabase:(Database *)database delegate:(id)delegate {
if ((self = [super init]) != nil) {
target:self
action:@selector(refreshButtonClicked)
];
- if (![[UIApplication sharedApplication] updating]) [[self navigationItem] setLeftBarButtonItem:leftItem];
+ if (![delegate_ updating]) [[self navigationItem] setLeftBarButtonItem:leftItem];
[leftItem release];
}
@end
/* }}} */
/* Search Controller {{{ */
-@interface SearchController : FilteredPackageController {
- id search_;
+@interface SearchController : FilteredPackageController <
+ UISearchBarDelegate
+> {
+ UISearchBar *search_;
}
- (id) initWithDatabase:(Database *)database;
[super dealloc];
}
-- (void) searchBarSearchButtonClicked:(id)searchBar {
+- (void) searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[packages_ setObject:[search_ text] forFilter:@selector(isUnfilteredAndSearchedForBy:)];
[search_ resignFirstResponder];
[self reloadData];
}
-- (void) searchBar:(id)searchBar textDidChange:(NSString *)text {
+- (void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)text {
[packages_ setObject:text forFilter:@selector(isUnfilteredAndSelectedForBy:)];
[self reloadData];
}
-- (id) title { return nil; }
+- (NSString *) title { return nil; }
- (id) initWithDatabase:(Database *)database {
return [super initWithDatabase:database title:UCLocalize("SEARCH") filter:@selector(isUnfilteredAndSearchedForBy:) with:nil];
}
- (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- if (!search_) {
- search_ = [[objc_getClass("UISearchBar") alloc] initWithFrame:CGRectMake(0, 0, [[self view] bounds].size.width, 44.0f)];
+ [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")];
UITextField *textField = [search_ searchField];
@end
/* }}} */
/* Settings Controller {{{ */
-@interface SettingsController : CYViewController {
+@interface SettingsController : CYViewController <
+ UITableViewDataSource,
+ UITableViewDelegate
+> {
_transient Database *database_;
NSString *name_;
Package *package_;
[ignoredSwitch_ release];
[subscribedCell_ release];
[ignoredCell_ release];
-
+
[super dealloc];
}
switch ([indexPath row]) {
case 0: return subscribedCell_;
case 1: return ignoredCell_;
-
+
_nodefault
}
return nil;
}
-- (id) title { return UCLocalize("SETTINGS"); }
+- (NSString *) title { return UCLocalize("SETTINGS"); }
- (id) initWithDatabase:(Database *)database package:(NSString *)package {
if ((self = [super init])) {
@end
/* }}} */
/* Role Controller {{{ */
-@interface RoleController : CYViewController {
+@interface RoleController : CYViewController <
+ UITableViewDataSource,
+ UITableViewDelegate
+> {
_transient Database *database_;
id roledelegate_;
UITableView *table_;
UISegmentedControl *segment_;
UIView *container_;
}
+
+- (void) showDoneButton;
+- (void) resizeSegmentedControl;
+
@end
@implementation RoleController
[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;
-
+ NSString *role(nil);
+
switch ([segment_ selectedSegmentIndex]) {
case 0: role = @"User"; break;
case 1: role = @"Hacker"; break;
}
if (![role isEqualToString:Role_]) {
+ bool rolling(Role_ == nil);
Role_ = role;
-
+
Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
Role_, @"Role",
nil];
[Metadata_ setObject:Settings_ forKey:@"Settings"];
Changed_ = true;
-
- [roledelegate_ updateData];
+
+ if (rolling)
+ [roledelegate_ loadData];
+ else
+ [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;
bool dropped_;
bool updating_;
id updatedelegate_;
- UIViewController *root_;
+ UITabBarController *root_;
}
+- (void) setTabBarController:(UITabBarController *)controller;
+
+- (void) dropBar:(BOOL)animated;
+- (void) beginUpdate;
+- (void) raiseBar:(BOOL)animated;
+
@end
@implementation CYContainer
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
- return YES; /* XXX: return YES; */
+ return IsWildcat_;
}
-- (void) setRootController:(UIViewController *)controller {
+- (void) setTabBarController:(UITabBarController *)controller {
root_ = controller;
[[self view] addSubview:[root_ view]];
}
- (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];
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];
[self raiseBar:NO];
[self dropBar:NO];
}
-
+
// XXX: fix Apple's layout bug
[[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
[super dealloc];
}
-- (id) initWithDatabase: (Database *)database {
+- (id) initWithDatabase:(Database *)database {
if ((self = [super init]) != nil) {
database_ = database;
@interface Cydia : UIApplication <
ConfirmationControllerDelegate,
ProgressControllerDelegate,
- CydiaDelegate
+ CydiaDelegate,
+ UINavigationControllerDelegate
> {
UIWindow *window_;
CYContainer *container_;
bool loaded_;
}
-- (UIViewController *) _pageForURL:(NSURL *)url withClass:(Class)_class;
-- (void) setPage:(UIViewController *)page;
+- (CYViewController *) _pageForURL:(NSURL *)url withClass:(Class)_class;
+- (void) setPage:(CYViewController *)page;
+- (void) loadData;
@end
if (tag_ != 4 && search_ != nil)
[search_ reloadData];
- [[tabbar_ selectedViewController] reloadData];
+ [(CYNavigationController *)[tabbar_ selectedViewController] reloadData];
}
- (int)indexOfTabWithTag:(int)tag {
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:
+
+ SCNetworkReachabilityFlags flags; {
+ SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(NULL, "cydia.saurik.com"));
+ SCNetworkReachabilityGetFlags(reachability, &flags);
+ CFRelease(reachability);
+ }
+
+ // XXX: this elaborate mess is what Apple is using to determine this? :(
+ // XXX: do we care if the user has to intervene? maybe that's ok?
+ bool reachable(
+ (flags & kSCNetworkReachabilityFlagsReachable) != 0 && (
+ (flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0 || (
+ (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0 ||
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0
+ ) && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0 ||
+ (flags & kSCNetworkReachabilityFlagsIsWWAN) != 0
+ )
+ );
+
+ if (loaded_ || ManualRefresh || !reachable) loaded:
[self performSelectorOnMainThread:@selector(_loaded) withObject:nil waitUntilDone:NO];
else {
loaded_ = true;
}
- (void) _reloadData {
- UIView *block();
-
UIProgressHUD *hud([self addProgressHUD]);
[hud setText:(loaded_ ? UCLocalize("RELOADING_DATA") : UCLocalize("LOADING_DATA"))];
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?
[self _saveConfig];
ProgressController *progress = [[[ProgressController alloc] initWithDatabase:database_ delegate:self] autorelease];
- UINavigationController *navigation = [[[CYNavigationController alloc] initWithRootViewController:progress] autorelease];
+ CYNavigationController *navigation = [[[CYNavigationController alloc] initWithRootViewController:progress] autorelease];
if (IsWildcat_) [navigation setModalPresentationStyle:UIModalPresentationFormSheet];
[container_ presentModalViewController:navigation animated:YES];
ConfirmationController *page([[[ConfirmationController alloc] initWithDatabase:database_] autorelease]);
[page setDelegate:self];
- id confirm_ = [[CYNavigationController alloc] initWithRootViewController:page];
+ CYNavigationController *confirm_ = [[CYNavigationController alloc] initWithRootViewController:page];
[confirm_ setDelegate:self];
if (IsWildcat_) [confirm_ setModalPresentationStyle:UIModalPresentationFormSheet];
- (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_
[self complete];
}
-- (void) setPage:(UIViewController *)page {
+- (void) setPage:(CYViewController *)page {
[page setDelegate:self];
- UINavigationController *navController = [tabbar_ selectedViewController];
+ CYNavigationController *navController = (CYNavigationController *) [tabbar_ selectedViewController];
[navController setViewControllers:[NSArray arrayWithObject:page] animated:NO];
- for (UIViewController *page in [tabbar_ viewControllers]) {
+ for (CYNavigationController *page in [tabbar_ viewControllers]) {
if (page != navController) [page setViewControllers:nil];
}
}
-- (UIViewController *) _pageForURL:(NSURL *)url withClass:(Class)_class {
+- (CYViewController *) _pageForURL:(NSURL *)url withClass:(Class)_class {
CYBrowserController *browser = [[[_class alloc] init] autorelease];
[browser loadURL:url];
return browser;
return installed_;
}
-- (void) tabBarController:(id)tabBarController didSelectViewController:(UIViewController *)viewController {
+- (void) tabBarController:(id)tabBarController didSelectViewController:(UIViewController *)viewController {
int tag = [[viewController tabBarItem] tag];
if (tag == tag_) {
- [[tabbar_ selectedViewController] popToRootViewControllerAnimated:YES];
+ [(CYNavigationController *)[tabbar_ selectedViewController] popToRootViewControllerAnimated:YES];
return;
} else if (tag_ == 1) {
[[self sectionsController] resetView];
- (void) cancelAndClear:(bool)clear {
@synchronized (self) {
if (clear) {
- /* XXX: clear marks instead of reloading data */
- /*pkgCacheFile &cache([database_ cache]);
+ // Clear all marks.
+ pkgCacheFile &cache([database_ cache]);
for (pkgCache::PkgIterator iterator = cache->PkgBegin(); !iterator.end(); ++iterator) {
- if (!cache[iterator].Keep()) cache->MarkKeep(iterator, false, false);
+ // Unmark method taken from Synaptic Package Manager.
+ // Thanks for being sane, unlike Aptitude.
+ if (!cache[iterator].Keep()) {
+ cache->MarkKeep(iterator, false);
+ cache->SetReInstall(iterator, false);
+ }
}
- [self updateData];
-
+ // Stop queuing, and let the appropriate controller know it.
Queuing_ = false;
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:nil];
- [queueDelegate_ queueStatusDidChange];*/
- [self reloadData];
+ [queueDelegate_ queueStatusDidChange];
} else {
+ // Start queuing, and let the controllers know.
Queuing_ = true;
[[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:UCLocalize("Q_D")];
- [[tabbar_ selectedViewController] reloadData];
-
+ [(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) {
[window_ setUserInteractionEnabled:YES];
}
-- (UIViewController *) pageForPackage:(NSString *)name {
+- (CYViewController *) pageForPackage:(NSString *)name {
if (Package *package = [database_ packageWithName:name]) {
PackageController *view([self packageController]);
[view setPackage:package];
}
}
-- (UIViewController *) pageForURL:(NSURL *)url hasTag:(int *)tag {
+- (CYViewController *) pageForURL:(NSURL *)url hasTag:(int *)tag {
if (tag != NULL)
*tag = -1;
- (void) applicationOpenURL:(NSURL *)url {
[super applicationOpenURL:url];
int tag;
- if (UIViewController *page = [self pageForURL:url hasTag:&tag]) {
+ if (CYViewController *page = [self pageForURL:url hasTag:&tag]) {
[self setPage:page];
tag_ = tag;
[tabbar_ setSelectedViewController:(tag_ == -1 ? nil : [[tabbar_ viewControllers] objectAtIndex:tag_])];
}
}
-- (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];
}
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("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 (int 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_];
container_ = [[CYContainer alloc] initWithDatabase:database_];
[container_ setUpdateDelegate:self];
- [container_ setRootController:tabbar_];
+ [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);
}
}
PackageName = reinterpret_cast<CYString &(*)(Package *, SEL)>(method_getImplementation(class_getInstanceMethod([Package class], @selector(cyname))));
/* Library Hacks {{{ */
- class_addMethod(objc_getClass("WebScriptObject"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &WebScriptObject$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16");
class_addMethod(objc_getClass("DOMNodeList"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &DOMNodeList$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16");
$WebDefaultUIKitDelegate = objc_getClass("WebDefaultUIKitDelegate");
Warning_ = UCLocalize("WARNING");
_trace();
- int value = UIApplicationMain(argc, argv, @"Cydia", @"Cydia");
+ int value(UIApplicationMain(argc, argv, @"Cydia", @"Cydia"));
CGColorSpaceRelease(space_);
CFRelease(Locale_);