#warnings > div > label {
color: red;
}
+
+ #boundry {
+ float: left;
+ width: 60px;
+ }
+
+ #icon {
+ height: 59px;
+ max-width: 60px;
+ width: auto;
+ }
+
+ #reflection {
+ height: 59px;
+ max-width: 60px;
+ opacity: 0.4;
+ position: absolute;
+ -webkit-transform: matrix(1, 0, 0, -1, 0, 0);
+ width: auto;
+ }
+
+ #id {
+ white-space: nowrap;
+ }
+
+ #header {
+ background: transparent;
+ border: none;
+ }
+
+ #header > div {
+ padding: 0;
+ margin-left: 2px;
+ }
+
+ #content {
+ float: right;
+ margin: auto 0;
+ }
+
+ #content > div {
+ margin: 8px;
+ }
+
+ #name {
+ font-weight: bold;
+ }
+
+ #latest {
+ color: #335588;
+ }
</style>
</head><body><div class="page">
<div class="dialog">
<div class="panel">
-<fieldset>
- <div>
- <img id="icon" class="icon"/>
- <label id="name"></label>
- <div id="latest"></div>
+<fieldset id="header">
+ <div class="clearfix">
+ <div id="boundry">
+ <img id="icon"/>
+ <!--img id="reflection"/-->
+ </div>
+
+ <div id="content">
+ <div id="name"></div>
+ <div id="latest"></div>
+ </div>
</div>
</fieldset>
<fieldset id="actions">
+ <a id="settings">
+ <img class="icon" src="settings.png"/>
+ <label>Change Package Settings</label>
+ </a>
+
<a id="author-href" class="author">
<img id="author-icon" class="icon" src="email.png"/>
<label>Author</label>
<div id="author"></div>
</a>
+ <div class="commercial">
+ <img class="icon" src="commercial.png"/>
+ <label>This is a commercial package!</label>
+ </div>
+
+ <a class="console" href="console.html">
+ <img class="icon" src="console.png"/>
+ <label>This is a console application!</label>
+ </a>
+
<a id="application">
<img class="icon"/>
<label class="application"></label>
<hr id="upper-bar" class="depiction"/-->
-<div id="depiction" class="depiction"><!--iframe
+<div id="depiction" class="depiction"><iframe
id="depiction-src"
frameborder="0"
width="320"
height="0"
target="_top"
onLoad="loaded()"
-></iframe--></div>
+></iframe></div>
<!--hr id="lower-bar" class="depiction"/-->
<div id="installed"></div>
</div>
- <a id="files-href"><label>Filesystem Content</label></a>
+ <a id="files-href">
+ <img class="icon" src="filesystem.png"/>
+ <label>Filesystem Content</label>
+ </a>
</fieldset>
<label>Package Details</label>
</div>
<div class="size">
+ <img class="icon" src="expanded.png"/>
<label>Expanded Size</label>
<div id="size"></div>
</div>
</a>
<a id="sponsor-href" class="sponsor">
+ <img class="icon" src="web.png"/>
<label>Sponsor</label>
<div id="sponsor"></div>
</a>
- <a class="trusted" id="trusted">
+ <!--a class="trusted" id="trusted">
<img class="icon" src="trusted.png">
- <label>View Package Signature</label>
- </a>
+ <label>View Repository Signature</label>
+ </a-->
+
+ <div class="trusted">
+ <img class="icon" src="trusted.png">
+ <label></label>
+ <div>This package has been signed.</div>
+ </div>
</fieldset>
<label class="source">Source Information</label>
var regarding = encodeURIComponent("Cydia/APT: " + name);
$("#icon").src("cydia://package-icon/" + idc);
+ $("#reflection").src("cydia://package-icon/" + idc);
+
$("#name").html(name);
$("#latest").html(package.latest);
+ $("#settings").href("cydia://package-settings/" + idc);
+
var warnings = package.warnings;
var length = warnings == null ? 0 : warnings.length;
if (length == 0)
var applications = package.applications;
var length = applications == null ? 0 : applications.length;
- if (length == 0)
- $(".applications").remove();
- else {
+
+ var child = $("#application");
+ child.remove();
+
+ /*if (length != 0) {
var parent = $("#actions");
- var child = $("#application");
- child.remove();
for (var i = 0; i != length; ++i) {
var application = applications[i];
clone.href("cydia://launch/" + application[0]);
clone.xpath("label").html("Run " + $.xml(application[1]));
clone.xpath("img").src(application[2]);
- console.log(0);
}
- }
+ }*/
+
+ var purposes = package.purposes;
+ var commercial = false;
+ var _console = false;
+ if (purposes != null)
+ for (var i = 0, e = purposes.length; i != e; ++i) {
+ var purpose = purposes[i];
+ if (purpose == "commercial")
+ commercial = true;
+ else if (purpose == "console")
+ _console = true;
+ }
+ if (!commercial)
+ $(".commercial").remove();
+ if (!_console)
+ $(".console").remove();
var author = package.author;
if (author == null)
$("#files-href").href("cydia://files/" + idc);
}
- $("#id").html(id);
+ var nid = $("#id");
+ nid.html(id);
+ var width = nid.width();
+
+ if (width > 240) {
+ var spacing = (240.0 - nid.width()) / (id.length - 1) + "px";
+ nid.css("letter-spacing", spacing);
+ }
var section = package.section;
if (section == null)
$("#source-name").html(source.name);
if (source.trusted)
- /*$("#trusted").href("cydia:///" + idc)*/;
+ $("#trusted").href("cydia://package-signature/" + idc);
else
$(".trusted").remove();
FILE *input_;
}
++ (Database *) sharedInstance;
+
- (void) _readCydia:(NSNumber *)fd;
- (void) _readStatus:(NSNumber *)fd;
- (void) _readOutput:(NSNumber *)fd;
- (Package *) packageWithName:(NSString *)name;
-- (Database *) init;
- (pkgCacheFile &) cache;
- (pkgDepCache::Policy *) policy;
- (pkgRecords *) records;
- (NSString *) id;
- (NSString *) name;
- (NSString *) tagline;
-- (NSString *) icon;
+- (UIImage *) icon;
- (NSString *) homepage;
- (NSString *) depiction;
- (Address *) author;
- (bool) hasSupportingRole;
- (BOOL) hasTag:(NSString *)tag;
- (NSString *) primaryPurpose;
+- (NSArray *) purposes;
- (NSComparisonResult) compareByName:(Package *)package;
- (NSComparisonResult) compareBySection:(Package *)package;
}
+ (NSArray *) _attributeKeys {
- return [NSArray arrayWithObjects:@"applications", @"author", @"depiction", @"description", @"essential", @"homepage", @"icon", @"id", @"installed", @"latest", @"maintainer", @"name", @"section", @"size", @"source", @"sponsor", @"tagline", @"warnings", nil];
+ return [NSArray arrayWithObjects:@"applications", @"author", @"depiction", @"description", @"essential", @"homepage", @"icon", @"id", @"installed", @"latest", @"maintainer", @"name", @"purposes", @"section", @"size", @"source", @"sponsor", @"tagline", @"warnings", nil];
}
- (NSArray *) attributeKeys {
return tagline_;
}
-- (NSString *) icon {
- return icon_;
+- (UIImage *) icon {
+ NSString *section = [self section];
+ if (section != nil)
+ section = Simplify(section);
+
+ UIImage *icon(nil);
+ if (NSString *icon = icon_)
+ icon = [UIImage imageAtPath:[icon_ substringFromIndex:6]];
+ if (icon == nil) if (section != nil)
+ icon = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]];
+ if (icon == nil) if (source_ != nil) if (NSString *icon = [source_ defaultIcon])
+ icon = [UIImage imageAtPath:[icon substringFromIndex:6]];
+ if (icon == nil)
+ icon = [UIImage applicationImageNamed:@"unknown.png"];
+ return icon;
}
- (NSString *) homepage {
return nil;
}
+- (NSArray *) purposes {
+ NSMutableArray *purposes([NSMutableArray arrayWithCapacity:2]);
+ for (NSString *tag in tags_)
+ if ([tag hasPrefix:@"purpose::"])
+ [purposes addObject:[tag substringFromIndex:9]];
+ return [purposes count] == 0 ? nil : purposes;
+}
+
- (NSComparisonResult) compareByName:(Package *)package {
NSString *lhs = [self name];
NSString *rhs = [package name];
/* Database Implementation {{{ */
@implementation Database
++ (Database *) sharedInstance {
+ static Database *instance;
+ if (instance == nil)
+ instance = [[Database alloc] init];
+ return instance;
+}
+
- (void) dealloc {
_assert(false);
[super dealloc];
[super dealloc];
}
-#include "internals.h"
-
- (void) mailComposeControllerWillAttemptToSend:(MailComposeController *)controller {
NSLog(@"will");
}
@end
@interface ConfirmationView : BrowserView {
+ _transient Database *database_;
UIActionSheet *essential_;
NSArray *changes_;
NSArray *issues_;
}
- (id) initWithBook:(RVBook *)book database:(Database *)database {
- if ((self = [super initWithBook:book database:database]) != nil) {
+ if ((self = [super initWithBook:book]) != nil) {
+ database_ = database;
+
NSMutableArray *installing = [NSMutableArray arrayWithCapacity:16];
NSMutableArray *reinstalling = [NSMutableArray arrayWithCapacity:16];
NSMutableArray *upgrading = [NSMutableArray arrayWithCapacity:16];
if (section != nil)
section = Simplify(section);
- icon_ = nil;
- if (NSString *icon = [package icon])
- icon_ = [UIImage imageAtPath:[icon substringFromIndex:6]];
- if (icon_ == nil) if (section != nil)
- icon_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]];
- if (icon_ == nil) if (NSString *icon = [source defaultIcon])
- icon_ = [UIImage imageAtPath:[icon substringFromIndex:6]];
- if (icon_ == nil)
- icon_ = [UIImage applicationImageNamed:@"unknown.png"];
-
- icon_ = [icon_ retain];
+ icon_ = [[package icon] retain];
name_ = [[package name] retain];
description_ = [[package tagline] retain];
/* }}} */
/* Package View {{{ */
@interface PackageView : BrowserView {
+ _transient Database *database_;
Package *package_;
NSString *name_;
NSMutableArray *buttons_;
}
- (id) initWithBook:(RVBook *)book database:(Database *)database {
- if ((self = [super initWithBook:book database:database]) != nil) {
+ if ((self = [super initWithBook:book]) != nil) {
database_ = database;
buttons_ = [[NSMutableArray alloc] initWithCapacity:4];
} return self;
if ([href hasPrefix:@"apptapp://package/"])
page = [delegate_ pageForPackage:[href substringFromIndex:18]];
- else if ([scheme isEqualToString:@"cydia"])
+ else if ([scheme isEqualToString:@"cydia"]) {
page = [delegate_ pageForURL:url hasTag:NULL];
- else if (![scheme isEqualToString:@"apptapp"])
+ if (page == nil)
+ return false;
+ } else if (![scheme isEqualToString:@"apptapp"])
return false;
if (page != nil)
- (WebView *) _createWebViewWithRequest:(NSURLRequest *)request pushed:(BOOL)pushed {
[self setBackButtonTitle:title_];
- BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
+ BrowserView *browser = [[[BrowserView alloc] initWithBook:book_] autorelease];
[browser setDelegate:delegate_];
if (pushed) {
#endif
}
-- (id) initWithBook:(RVBook *)book database:(Database *)database {
+- (id) initWithBook:(RVBook *)book {
if ((self = [super initWithBook:book]) != nil) {
- database_ = database;
loading_ = false;
struct CGRect bounds = [self bounds];
indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 12, indsize.width, indsize.height)];
[indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
- Package *package([database_ packageWithName:@"cydia"]);
+ Package *package([[Database sharedInstance] packageWithName:@"cydia"]);
NSString *application = package == nil ? @"Cydia" : [NSString
stringWithFormat:@"Cydia/%@",
[package installed]
@end
+@interface CydiaURLProtocol : NSURLProtocol {
+}
+
+@end
+
+@implementation CydiaURLProtocol
+
++ (BOOL) canInitWithRequest:(NSURLRequest *)request {
+ NSURL *url([request URL]);
+ if (url == nil)
+ return NO;
+ NSString *scheme([[url scheme] lowercaseString]);
+ if (scheme == nil || ![scheme isEqualToString:@"cydia"])
+ return NO;
+ return YES;
+}
+
++ (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
+ return request;
+}
+
+- (void) startLoading {
+ id<NSURLProtocolClient> client([self client]);
+ NSURLRequest *request([self request]);
+
+ NSURL *url([request URL]);
+ NSString *href([url absoluteString]);
+
+ NSString *path([href substringFromIndex:8]);
+ NSRange slash([path rangeOfString:@"/"]);
+
+ NSString *command;
+ if (slash.location == NSNotFound) {
+ command = path;
+ path = nil;
+ } else {
+ command = [path substringToIndex:slash.location];
+ path = [path substringFromIndex:(slash.location + 1)];
+ }
+
+ Database *database([Database sharedInstance]);
+
+ if ([command isEqualToString:@"package-icon"]) {
+ if (path == nil)
+ goto fail;
+ Package *package([database packageWithName:path]);
+ if (package == nil)
+ goto fail;
+
+ NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
+
+ UIImage *icon([package icon]);
+ NSData *data(UIImagePNGRepresentation(icon));
+
+ [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
+ [client URLProtocol:self didLoadData:data];
+ [client URLProtocolDidFinishLoading:self];
+ } else fail: {
+ [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
+ }
+}
+
+- (void) stopLoading {
+}
+
+@end
+
+@interface SignatureView : BrowserView {
+ _transient Database *database_;
+ NSString *package_;
+}
+
+- (id) initWithBook:(RVBook *)book database:(Database *)database package:(NSString *)package;
+
+@end
+
+@implementation SignatureView
+
+- (void) dealloc {
+ [package_ release];
+ [super dealloc];
+}
+
+- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+ // XXX: dude!
+ [super webView:sender didClearWindowObject:window forFrame:frame];
+}
+
+- (id) initWithBook:(RVBook *)book database:(Database *)database package:(NSString *)package {
+ if ((self = [super initWithBook:book]) != nil) {
+ database_ = database;
+ package_ = [package retain];
+ [self reloadData];
+ } return self;
+}
+
+- (void) reloadData {
+ [self loadURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"signature" ofType:@"html"]]];
+}
+
+@end
+
@interface Cydia : UIApplication <
ConfirmationViewDelegate,
ProgressViewDelegate,
}
- (RVPage *) _pageForURL:(NSURL *)url withClass:(Class)_class {
- BrowserView *browser = [[[_class alloc] initWithBook:book_ database:database_] autorelease];
+ BrowserView *browser = [[[_class alloc] initWithBook:book_] autorelease];
[browser loadURL:url];
return browser;
}
return [self _pageForURL:[NSURL URLWithString:[href substringFromIndex:12]] withClass:[BrowserView class]];
else if ([href hasPrefix:@"cydia://launch/"])
[self launchApplicationWithIdentifier:[href substringFromIndex:15] suspended:NO];
+ else if ([href hasPrefix:@"cydia://package-signature/"])
+ return [[[SignatureView alloc] initWithBook:book_ database:database_ package:[href substringFromIndex:26]] autorelease];
else if ([href hasPrefix:@"cydia://package/"])
return [self pageForPackage:[href substringFromIndex:16]];
else if ([href hasPrefix:@"cydia://files/"]) {
essential_ = [[NSMutableArray alloc] initWithCapacity:4];
broken_ = [[NSMutableArray alloc] initWithCapacity:4];
+ [NSURLProtocol registerClass:[CydiaURLProtocol class]];
+
CGRect screenrect = [UIHardware fullScreenApplicationContentRect];
window_ = [[UIWindow alloc] initWithContentRect:screenrect];
[window_ makeKey:self];
[window_ setHidden:NO];
- database_ = [[Database alloc] init];
+ database_ = [Database sharedInstance];
progress_ = [[ProgressView alloc] initWithFrame:[window_ bounds] database:database_ delegate:self];
[database_ setDelegate:progress_];
[window_ setContentView:progress_];
}
+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector {
- NSLog(@"exc:%s", sel_getName(selector));
return selector != @selector(supports:);
}