/* Miscellaneous Messages {{{ */
@interface WebView
- (void) setApplicationNameForUserAgent:(NSString *)applicationName;
+- (id) frameLoadDelegate;
+- (void) setFrameLoadDelegate:(id)delegate;
@end
@interface NSString (Cydia)
/* Reset View {{{ */
@interface ResetView : UIView {
+ UIPushButton *configure_;
UIPushButton *reload_;
NSMutableArray *views_;
UINavigationBar *navbar_;
- (id) initWithFrame:(CGRect)frame;
- (void) setDelegate:(id)delegate;
+
+- (void) configurePushed;
- (void) reloadPushed;
- (void) pushView:(UIView *)view withTitle:(NSString *)title backButtonTitle:(NSString *)back rightButton:(NSString *)right;
- (void) popViews:(unsigned)views;
-- (void) resetView;
+- (void) resetView:(BOOL)clear;
- (void) _resetView;
- (void) setPrompt;
@end
@implementation ResetView
- (void) dealloc {
+ [configure_ release];
[reload_ release];
[transition_ release];
[navbar_ release];
[views_ removeLastObject];
UIView *view([views_ lastObject]);
[view resetViewAnimated:!resetting_];
- if (!resetting_)
- [transition_ transition:2 toView:view];
- if ([views_ count] == 1)
+ if (!resetting_) {
+ [transition_ transition:2 toView:view];
[self _resetView];
+ }
}
- (id) initWithFrame:(CGRect)frame {
bounds.origin.x, bounds.origin.y + navsize.height, bounds.size.width, bounds.size.height - navsize.height
)];
- //reload_ = [[UIPushButton alloc] initWithFrame:CGRectMake(284, 8, 29, 23)];
- reload_ = [[UIPushButton alloc] initWithFrame:CGRectMake(282, 5, 29, 23)];
+ //configure_ = [[UIPushButton alloc] initWithFrame:CGRectMake(15, 9, 17, 18)];
+ configure_ = [[UIPushButton alloc] initWithFrame:CGRectMake(10, 9, 17, 18)];
+ [configure_ setShowPressFeedback:YES];
+ [configure_ setImage:[UIImage applicationImageNamed:@"configure.png"]];
+ [configure_ addTarget:self action:@selector(configurePushed) forEvents:1];
+
+ //reload_ = [[UIPushButton alloc] initWithFrame:CGRectMake(288, 5, 18, 22)];
+ reload_ = [[UIPushButton alloc] initWithFrame:CGRectMake(293, 5, 18, 22)];
[reload_ setShowPressFeedback:YES];
[reload_ setImage:[UIImage applicationImageNamed:@"reload.png"]];
[reload_ addTarget:self action:@selector(reloadPushed) forEvents:1];
+ [navbar_ addSubview:configure_];
[navbar_ addSubview:reload_];
[self addSubview:transition_];
delegate_ = delegate;
}
+- (void) configurePushed {
+}
+
- (void) reloadPushed {
[delegate_ update];
}
[navbar_ popNavigationItem];
resetting_ = false;
+ [self _resetView];
[transition_ transition:2 toView:[views_ lastObject]];
}
-- (void) resetView {
+- (void) resetView:(BOOL)clear {
resetting_ = true;
- if ([[navbar_ navigationItems] count] == 1)
- [self _resetView];
- else do
- [navbar_ popNavigationItem];
- while ([[navbar_ navigationItems] count] != 1);
+
+ if ([views_ count] > 1) {
+ [navbar_ disableAnimation];
+ while ([views_ count] != (clear ? 1 : 2))
+ [navbar_ popNavigationItem];
+ [navbar_ enableAnimation];
+ if (!clear)
+ [navbar_ popNavigationItem];
+ }
+
resetting_ = false;
- [transition_ transition:0 toView:[views_ lastObject]];
+ [self _resetView];
+ [transition_ transition:(clear ? 0 : 2) toView:[views_ lastObject]];
}
- (void) _resetView {
@end
@implementation ConfirmationView
+#include "internals.h"
- (void) dealloc {
[transition_ release];
- (int) preferencesTable:(UIPreferencesTable *)table numberOfRowsInGroup:(int)group {
switch (group) {
- case 0: return 2;
+ case 0: return [package_ website] == nil ? 2 : 3;
case 1: return 5;
case 2: return 0;
[cell addSubview:description_];
break;
+ case 2:
+ [cell setTitle:@"More Information"];
+ [cell setShowDisclosure:YES];
+ [cell setShowSelection:YES];
+ break;
+
default: _assert(false);
} break;
}
- (void) tableRowSelected:(NSNotification *)notification {
- printf("%d\n", [table_ selectedRow]);
switch ([table_ selectedRow]) {
case 8:
[delegate_ openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@",
[view_ setPackage:npackage];
else if (package_ != nil)
[self popViews:1];
- if ([views_ count] == 1)
- [self _resetView];
+ [self _resetView];
[self setPrompt];
}
- (void) _resetView {
- [navbar_ showButtonsWithLeftTitle:(count_ == 0 ? nil : @"Upgrade All") rightTitle:nil];
+ if ([views_ count] == 1)
+ [navbar_ showButtonsWithLeftTitle:(count_ == 0 ? nil : @"Upgrade All") rightTitle:nil];
}
- (size_t) count {
/* XXX: for the love of god just fix this */
[navbar_ removeFromSuperview];
+ [reload_ removeFromSuperview];
+ [configure_ removeFromSuperview];
[self addSubview:navbar_];
+ [self addSubview:reload_];
+ [self addSubview:configure_];
} return self;
}
SearchView *search_;
bool restart_;
+ unsigned tag_;
UIKeyboard *keyboard_;
}
- (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old;
+- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame;
+
- (void) applicationWillSuspend;
- (void) applicationDidFinishLaunching:(id)unused;
@end
@implementation Cydia
+#include "internals.h"
- (void) loadNews {
NSMutableURLRequest *request = [NSMutableURLRequest
[request addValue:[NSString stringWithCString:SerialNumber_] forHTTPHeaderField:@"X-Serial-Number"];
[webview_ loadRequest:request];
- [indicator_ startAnimation];
}
- (void) reloadData:(BOOL)reset {
[changes_ setPackages:packages];
[manage_ setPackages:packages];
[search_ setPackages:packages];
- //[self setPrompt];
if (size_t count = [changes_ count]) {
NSString *badge([[NSNumber numberWithInt:count] stringValue]);
- (void) buttonBarItemTapped:(id)sender {
UIView *view;
+ unsigned tag = [sender tag];
- switch ([sender tag]) {
+ switch (tag) {
case 1: view = featured_; break;
case 2: view = install_; break;
case 3: view = changes_; break;
_assert(false);
}
- if ([view respondsToSelector:@selector(resetView)])
- [(id) view resetView];
+ if ([view respondsToSelector:@selector(resetView:)])
+ [(id) view resetView:(tag == tag_ ? NO : YES)];
+ tag_ = tag;
[transition_ transition:0 toView:view];
}
-- (void) view:(UIView *)view didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
+- (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
[scroller_ setContentSize:frame.size];
[indicator_ stopAnimation];
}
+- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
+ [navbar_ setPrompt:title];
+}
+
+- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
+ [navbar_ setPrompt:@"Loading..."];
+ [indicator_ startAnimation];
+}
+
- (void) applicationWillSuspend {
if (restart_)
system("launchctl stop com.apple.SpringBoard");
+ [super applicationWillSuspend];
}
- (void) applicationDidFinishLaunching:(id)unused {
confirm_ = nil;
restart_ = false;
+ tag_ = 1;
CGRect screenrect = [UIHardware fullScreenApplicationContentRect];
window_ = [[UIWindow alloc] initWithContentRect:screenrect];
[navbar_ setBarStyle:1];
[navbar_ setDelegate:self];
- [navbar_ setPrompt:@"Welcome to Cydia Packager"];
[navbar_ showButtonsWithLeftTitle:@"About" rightTitle:@"Reload"];
[scroller_ setScrollDecelerationFactor:0.99];
[scroller_ setDelegate:self];
- webview_ = [[UIWebView alloc] initWithFrame:[scroller_ bounds]];
+ CGRect webrect = [scroller_ bounds];
+ webrect.size.height = 0;
+
+ webview_ = [[UIWebView alloc] initWithFrame:webrect];
[scroller_ addSubview:webview_];
[webview_ setTilingEnabled:YES];
Package *package([database_ packageWithName:@"cydia"]);
NSString *application = package == nil ? @"Cydia" : [NSString stringWithFormat:@"Cydia/%@", [package installed]];
+
WebView *webview = [webview_ webView];
[webview setApplicationNameForUserAgent:application];
+ [webview setFrameLoadDelegate:self];
url_ = [NSURL URLWithString:@"http://cydia.saurik.com/"];
[self loadNews];