From 18159e09e7085546f2afd4ca195f553c1d212d13 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 16 Oct 2008 21:57:50 +0000 Subject: [PATCH] Added icons to sources. --- Cydia.app/package.html | 6 +++++- Cydia.app/package.js | 3 +++ Cydia.mm | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Cydia.app/package.html b/Cydia.app/package.html index 7c589678..0c7762e4 100644 --- a/Cydia.app/package.html +++ b/Cydia.app/package.html @@ -279,7 +279,11 @@
-
+
+ + +
+
diff --git a/Cydia.app/package.js b/Cydia.app/package.js index 1a8fc92b..3117a576 100644 --- a/Cydia.app/package.js +++ b/Cydia.app/package.js @@ -178,6 +178,9 @@ $(function () { $(".source").remove(); $(".trusted").remove(); } else { + var host = source.host; + + $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host)); $("#source-name").html(source.name); if (source.trusted) diff --git a/Cydia.mm b/Cydia.mm index 5742a76d..b7622dfe 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -261,10 +261,10 @@ extern NSString * const kCAFilterNearest; #define lprintf(args...) fprintf(stderr, args) -#define ForRelease 0 +#define ForRelease 1 #define ForSaurik 1 && !ForRelease #define RecycleWebViews 0 -#define AlwaysReload 0 && !ForRelease +#define AlwaysReload 1 && !ForRelease /* Radix Sort {{{ */ @interface NSMutableArray (Radix) @@ -5636,6 +5636,22 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { NSData *data(UIImagePNGRepresentation(icon)); + NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]); + [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed]; + [client URLProtocol:self didLoadData:data]; + [client URLProtocolDidFinishLoading:self]; + } else if ([command isEqualToString:@"source-icon"]) { + if (path == nil) + goto fail; + path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSString *source(Simplify(path)); + + UIImage *icon([UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sources/%@.png", App_, source]]); + if (icon == nil) + icon = [UIImage applicationImageNamed:@"unknown.png"]; + + NSData *data(UIImagePNGRepresentation(icon)); + NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]); [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed]; [client URLProtocol:self didLoadData:data]; -- 2.45.2