#include "CyteKit/WebViewController.h"
#include "iPhonePrivate.h"
+#include <Menes/ObjectHandle.h>
//#include <QuartzCore/CALayer.h>
// XXX: fix the minimum requirement
@end
/* }}} */
-@implementation CyteWebViewController
+@implementation CyteWebViewController {
+ _H<CyteWebView, 1> webview_;
+ _transient UIScrollView *scroller_;
+
+ _H<UIActivityIndicatorView> indicator_;
+ _H<IndirectDelegate, 1> indirect_;
+ _H<NSURLAuthenticationChallenge> challenge_;
+
+ bool error_;
+ _H<NSURLRequest> request_;
+ bool ready_;
+
+ _transient NSNumber *sensitive_;
+ _H<NSURL> appstore_;
+
+ _H<NSString> title_;
+ _H<NSMutableSet> loading_;
+
+ _H<NSMutableSet> registered_;
+ _H<NSTimer> timer_;
+
+ // XXX: NSString * or UIImage *
+ _H<NSObject> custom_;
+ _H<NSString> style_;
+
+ _H<WebScriptObject> function_;
+
+ float width_;
+ Class class_;
+
+ _H<UIBarButtonItem> reloaditem_;
+ _H<UIBarButtonItem> loadingitem_;
+
+ bool visible_;
+ bool hidesNavigationBar_;
+ bool allowsNavigationAction_;
+}
#if ShowInternals
#include "CyteKit/UCInternal.h"
[loading_ removeAllObjects];
if ([self retainsNetworkActivityIndicator])
- [delegate_ releaseNetworkActivityIndicator];
+ [self.delegate releaseNetworkActivityIndicator];
}
}
return (CyteWebView *) [self view];
}
+- (CyteWebViewController *) indirect {
+ return (CyteWebViewController *) (IndirectDelegate *) indirect_;
+}
+
- (NSURL *) URLWithURL:(NSURL *)url {
return url;
}
request_ = request;
}
+- (NSURLRequest *) request {
+ return request_;
+}
+
- (void) setURL:(NSURL *)url {
[self setURL:url withReferrer:nil];
}
NSURL *url([request URL]);
// XXX: filter to internal usage?
- CyteViewController *page([delegate_ pageForURL:url forExternal:NO withReferrer:referrer]);
+ CyteViewController *page([self.delegate pageForURL:url forExternal:NO withReferrer:referrer]);
if (page == nil) {
CyteWebViewController *browser([[[class_ alloc] init] autorelease]);
page = browser;
}
- [page setDelegate:delegate_];
- [page setPageColor:color_];
+ [page setDelegate:self.delegate];
+ [page setPageColor:self.pageColor];
if (!pop) {
[[self navigationItem] setTitle:title_];
} else {
UINavigationController *navigation([[[UINavigationController alloc] initWithRootViewController:page] autorelease]);
- [navigation setDelegate:delegate_];
+ [navigation setDelegate:self.delegate];
[[page navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("CLOSE")
return;
if ([name isEqualToString:@"_open"])
- [delegate_ openURL:url];
+ [self.delegate openURL:url];
else {
NSString *scheme([[url scheme] lowercaseString]);
if ([scheme isEqualToString:@"mailto"])
}
[super setPageColor:uic];
- [scroller_ setBackgroundColor:color_];
+ [scroller_ setBackgroundColor:self.pageColor];
break;
}
}
} else if ([context isEqualToString:@"itmsappss"]) {
if (button == [alert cancelButtonIndex]) {
} else if (button == [alert firstOtherButtonIndex]) {
- [delegate_ openURL:appstore_];
+ [self.delegate openURL:appstore_];
}
[alert dismissWithClickedButtonIndex:-1 animated:YES];
return;
if ([self retainsNetworkActivityIndicator])
- [delegate_ retainNetworkActivityIndicator];
+ [self.delegate retainNetworkActivityIndicator];
[self didStartLoading];
}
[[self navigationItem] setTitle:title_];
if ([self retainsNetworkActivityIndicator])
- [delegate_ releaseNetworkActivityIndicator];
+ [self.delegate releaseNetworkActivityIndicator];
[self didFinishLoading];
}
[webview_ setBackgroundColor:nil];
[scroller_ setFixedBackgroundPattern:YES];
- [scroller_ setBackgroundColor:color_];
+ [scroller_ setBackgroundColor:self.pageColor];
[scroller_ setClipsSubviews:YES];
[scroller_ setBounces:YES];
#include "Substrate.hpp"
#include "Menes/Menes.h"
-#include "CyteKit/IndirectDelegate.h"
#include "CyteKit/RegEx.hpp"
#include "CyteKit/TableViewCell.h"
#include "CyteKit/TabBarController.h"
_transient id delegate_;
}
-- (id) initWithDelegate:(IndirectDelegate *)indirect;
+- (id) initWithDelegate:(CyteWebViewController *)indirect;
@end
/* Web Scripting {{{ */
@implementation CydiaObject
-- (id) initWithDelegate:(IndirectDelegate *)indirect {
+- (id) initWithDelegate:(CyteWebViewController *)indirect {
if ((self = [super init]) != nil) {
- indirect_ = (CyteWebViewController *) indirect;
+ indirect_ = indirect;
} return self;
}
@implementation CydiaWebViewController
- (NSURL *) navigationURL {
- return request_ == nil ? nil : [NSURL URLWithString:[NSString stringWithFormat:@"cydia://url/%@", [[request_ URL] absoluteString]]];
+ if (NSURLRequest *request = self.request)
+ return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://url/%@", [[request URL] absoluteString]]];
+ else
+ return nil;
}
+ (void) _initialize {
- (id) init {
if ((self = [super initWithWidth:0 ofClass:[CydiaWebViewController class]]) != nil) {
- cydia_ = [[[CydiaObject alloc] initWithDelegate:indirect_] autorelease];
+ cydia_ = [[[CydiaObject alloc] initWithDelegate:self.indirect] autorelease];
} return self;
}
- (void) complete {
if (substrate_)
RestartSubstrate_ = true;
- [delegate_ confirmWithNavigationController:[self navigationController]];
+ [self.delegate confirmWithNavigationController:[self navigationController]];
}
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
}
- (void) _doContinue {
- [delegate_ cancelAndClear:NO];
+ [self.delegate cancelAndClear:NO];
[self dismissModalViewControllerAnimated:YES];
}
#endif
- (void) cancelButtonClicked {
- [delegate_ cancelAndClear:YES];
+ [self.delegate cancelAndClear:YES];
[self dismissModalViewControllerAnimated:YES];
}
- (id) initWithDatabase:(Database *)database delegate:(id)delegate {
if ((self = [super init]) != nil) {
database_ = database;
- delegate_ = delegate;
+ self.delegate = delegate;
[database_ setProgressDelegate:self];
UpdateExternalStatus(0);
if (Finish_ > 1)
- [delegate_ saveState];
+ [self.delegate saveState];
switch (Finish_) {
case 0:
- [delegate_ returnToCydia];
+ [self.delegate returnToCydia];
break;
case 1:
- [delegate_ terminateWithSuccess];
- /*if ([delegate_ respondsToSelector:@selector(suspendWithAnimation:)])
- [delegate_ suspendWithAnimation:YES];
+ [self.delegate terminateWithSuccess];
+ /*if ([self.delegate respondsToSelector:@selector(suspendWithAnimation:)])
+ [self.delegate suspendWithAnimation:YES];
else
- [delegate_ suspend];*/
+ [self.delegate suspend];*/
break;
case 2:
goto reload;
reload: {
- UIProgressHUD *hud([delegate_ addProgressHUD]);
+ UIProgressHUD *hud([self.delegate addProgressHUD]);
[hud setText:UCLocalize("LOADING")];
- [delegate_ performSelector:@selector(reloadSpringBoard) withObject:nil afterDelay:0.5];
+ [self.delegate performSelector:@selector(reloadSpringBoard) withObject:nil afterDelay:0.5];
return;
}
UIView *content([self contentView]);
CGRect bounds([content bounds]);
- content_ = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
- [content_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
- [content addSubview:content_];
+ self.content = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
+ [self.content setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
+ [content addSubview:self.content];
- [content_ setDelegate:self];
- [content_ setOpaque:YES];
+ [self.content setDelegate:self];
+ [self.content setOpaque:YES];
} return self;
}
placard_ = nil;
if (package == nil)
- [content_ setBackgroundColor:[UIColor whiteColor]];
+ [self.content setBackgroundColor:[UIColor whiteColor]];
else {
[package parse];
placard = nil;
}
- [content_ setBackgroundColor:color];
+ [self.content setBackgroundColor:color];
if (placard != nil)
placard_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/%@.png", App_, placard]];
}
[self setNeedsDisplay];
- [content_ setNeedsDisplay];
+ [self.content setNeedsDisplay];
}
- (void) drawSummaryContentRect:(CGRect)rect {
- bool highlighted(highlighted_);
+ bool highlighted(self.highlighted);
float width([self bounds].size.width);
if (icon_ != nil) {
}
- (void) drawNormalContentRect:(CGRect)rect {
- bool highlighted(highlighted_);
+ bool highlighted(self.highlighted);
float width([self bounds].size.width);
if (icon_ != nil) {
UIView *content([self contentView]);
CGRect bounds([content bounds]);
- content_ = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
- [content_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
- [content addSubview:content_];
- [content_ setBackgroundColor:[UIColor whiteColor]];
+ self.content = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
+ [self.content setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
+ [content addSubview:self.content];
+ [self.content setBackgroundColor:[UIColor whiteColor]];
- [content_ setDelegate:self];
+ [self.content setDelegate:self];
} return self;
}
[self setAccessoryType:editing ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator];
[self setSelectionStyle:editing ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleBlue];
- [content_ setNeedsDisplay];
+ [self.content setNeedsDisplay];
}
- (void) setFrame:(CGRect)frame {
}
- (void) drawContentRect:(CGRect)rect {
- bool highlighted(highlighted_ && !editing_);
+ bool highlighted(self.highlighted && !editing_);
[icon_ drawInRect:CGRectMake(7, 7, 32, 32)];
}
- (void) _clickButtonWithPackage:(Package *)package {
- [delegate_ installPackage:package];
+ [self.delegate installPackage:package];
}
- (void) _clickButtonWithName:(NSString *)name {
if ([name isEqualToString:@"CLEAR"])
- return [delegate_ clearPackage:package_];
+ return [self.delegate clearPackage:package_];
else if ([name isEqualToString:@"REMOVE"])
- return [delegate_ removePackage:package_];
+ return [self.delegate removePackage:package_];
else if ([name isEqualToString:@"DOWNGRADE"]) {
sheet_ = [[[UIActionSheet alloc]
initWithTitle:nil
[sheet_ addButtonWithTitle:[version latest]];
[sheet_ setContext:@"version"];
- [delegate_ showActionSheet:sheet_ fromItem:[[self navigationItem] rightBarButtonItem]];
+ [self.delegate showActionSheet:sheet_ fromItem:[[self navigationItem] rightBarButtonItem]];
return;
}
else if ([name isEqualToString:@"UPGRADE"]);
else _assert(false);
- [delegate_ installPackage:package_];
+ [self.delegate installPackage:package_];
}
- (void) actionSheet:(UIActionSheet *)sheet clickedButtonAtIndex:(NSInteger)button {
[sheet_ addButtonWithTitle:button];
[sheet_ setContext:@"modify"];
- [delegate_ showActionSheet:sheet_ fromItem:[[self navigationItem] rightBarButtonItem]];
+ [self.delegate showActionSheet:sheet_ fromItem:[[self navigationItem] rightBarButtonItem]];
}
}
}
- (id) initWithDatabase:(Database *)database title:(NSString *)title;
-- (void) setDelegate:(id)delegate;
- (void) resetCursor;
- (void) clearData;
- (void) didSelectPackage:(Package *)package {
CYPackageController *view([[[CYPackageController alloc] initWithDatabase:database_ forPackage:[package id] withReferrer:[[self referrerURL] absoluteString]] autorelease]);
- [view setDelegate:delegate_];
+ [view setDelegate:self.delegate];
[[self navigationController] pushViewController:view animated:YES];
}
[super releaseSubviews];
}
-- (void) setDelegate:(id)delegate {
- delegate_ = delegate;
-}
-
- (bool) shouldYield {
return false;
}
if (![self shouldBlock])
hud = nil;
else {
- hud = [delegate_ addProgressHUD];
+ hud = [self.delegate addProgressHUD];
[hud setText:UCLocalize("LOADING")];
}
packages = [self yieldToSelector:@selector(_reloadPackages)];
if (hud != nil)
- [delegate_ removeProgressHUD:hud];
+ [self.delegate removeProgressHUD:hud];
} while (reloading_ == 2);
} else {
packages = [self _reloadPackages];
if (editing)
[list_ reloadData];
else
- [delegate_ updateData];
+ [self.delegate updateData];
[self updateNavigationItem];
}
source:[self source]
section:[section name]
] autorelease];
- [controller setDelegate:delegate_];
+ [controller setDelegate:self.delegate];
[[self navigationController] pushViewController:controller animated:YES];
}
}
- (void) setLeftBarButtonItem {
- if ([delegate_ updating])
+ if ([self.delegate updating])
[[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("CANCEL")
style:UIBarButtonItemStyleDone
}
- (void) refreshButtonClicked {
- if ([delegate_ requestUpdate])
+ if ([self.delegate requestUpdate])
[self setLeftBarButtonItem];
}
- (void) cancelButtonClicked {
- [delegate_ cancelUpdate];
+ [self.delegate cancelUpdate];
}
- (void) upgradeButtonClicked {
- [delegate_ distUpgrade];
+ [self.delegate distUpgrade];
[[self navigationItem] setRightBarButtonItem:nil animated:YES];
}
if (package_ == nil)
return;
if ([package_ setSubscribed:value])
- [delegate_ updateData];
+ [self.delegate updateData];
}
- (void) _updateIgnored {
[invocation setTarget:self];
[invocation setSelector:@selector(_updateIgnored)];
- [delegate_ reloadDataWithInvocation:invocation];
+ [self.delegate reloadDataWithInvocation:invocation];
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
#if !AlwaysReload
- (void) queueButtonClicked {
- [delegate_ queue];
+ [self.delegate queue];
}
#endif
- (void) _setImage:(NSArray *)data {
if ([url_ isEqual:[data objectAtIndex:0]]) {
icon_ = [data objectAtIndex:1];
- [content_ setNeedsDisplay];
+ [self.content setNeedsDisplay];
}
}
origin_ = [source name];
label_ = [source rooturi];
- [content_ setNeedsDisplay];
+ [self.content setNeedsDisplay];
url_ = [source iconURL];
[NSThread detachNewThreadSelector:@selector(_setSource:) toTarget:self withObject:url_];
icon_ = [UIImage imageNamed:@"folder.png"];
origin_ = UCLocalize("ALL_SOURCES");
label_ = UCLocalize("ALL_SOURCES_EX");
- [content_ setNeedsDisplay];
+ [self.content setNeedsDisplay];
}
- (SourceCell *) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
UIView *content([self contentView]);
CGRect bounds([content bounds]);
- content_ = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
- [content_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
- [content_ setBackgroundColor:[UIColor whiteColor]];
- [content addSubview:content_];
+ self.content = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
+ [self.content setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
+ [self.content setBackgroundColor:[UIColor whiteColor]];
+ [content addSubview:self.content];
- [content_ setDelegate:self];
- [content_ setOpaque:YES];
+ [self.content setDelegate:self];
+ [self.content setOpaque:YES];
indicator_ = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGraySmall] autorelease];
[indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin];// | UIViewAutoresizingFlexibleBottomMargin];
[content addSubview:indicator_];
- [[content_ layer] setContentsGravity:kCAGravityTopLeft];
+ [[self.content layer] setContentsGravity:kCAGravityTopLeft];
} return self;
}
}
- (void) drawContentRect:(CGRect)rect {
- bool highlighted(highlighted_);
+ bool highlighted(self.highlighted);
float width(rect.size.width);
if (icon_ != nil) {
source:[self sourceAtIndexPath:indexPath]
] autorelease]);
- [controller setDelegate:delegate_];
+ [controller setDelegate:self.delegate];
[[self navigationController] pushViewController:controller animated:YES];
}
[Sources_ removeObjectForKey:[source key]];
- [delegate_ syncData];
+ [self.delegate syncData];
}
}
}
- (void) complete {
- [delegate_ addTrivialSource:href_];
+ [self.delegate addTrivialSource:href_];
href_ = nil;
- [delegate_ syncData];
+ [self.delegate syncData];
}
- (NSString *) getWarning {
) {
NSString *warning(cydia_ ? [self yieldToSelector:@selector(getWarning)] : nil);
- [delegate_ releaseNetworkActivityIndicator];
+ [self.delegate releaseNetworkActivityIndicator];
- [delegate_ removeProgressHUD:hud_];
+ [self.delegate removeProgressHUD:hud_];
hud_ = nil;
if (cydia_) {
cydia_ = false;
// XXX: this is stupid
- hud_ = [delegate_ addProgressHUD];
+ hud_ = [self.delegate addProgressHUD];
[hud_ setText:UCLocalize("VERIFYING_URL")];
- [delegate_ retainNetworkActivityIndicator];
+ [self.delegate retainNetworkActivityIndicator];
} break;
case 0:
target:self
action:@selector(addButtonClicked)
] autorelease] animated:animated];
- else if ([delegate_ updating])
+ else if ([self.delegate updating])
[[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("CANCEL")
style:UIBarButtonItemStyleDone
}
- (void) refreshButtonClicked {
- if ([delegate_ requestUpdate])
+ if ([self.delegate requestUpdate])
[self updateButtonsForEditingStatusAnimated:YES];
}
- (void) cancelButtonClicked {
- [delegate_ cancelUpdate];
+ [self.delegate cancelUpdate];
}
- (void) editButtonClicked {