summaryrefslogtreecommitdiff
path: root/Cydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-10-14 22:53:14 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2010-09-30 07:08:50 +0000
commitdec6029f07c75ffe08b7edcfa26455c3ee7692e8 (patch)
tree5fc3e3edacba51afde847f04deaf0626b8dae71c /Cydia.mm
parent807ae6d7d376189cbf17271686d8389c541c7975 (diff)
Sections should have icons displayed, too.
Diffstat (limited to 'Cydia.mm')
-rw-r--r--Cydia.mm37
1 files changed, 30 insertions, 7 deletions
diff --git a/Cydia.mm b/Cydia.mm
index 8d48ac0..f94557a 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -1170,6 +1170,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
- (pkgCache::PkgIterator) iterator;
- (NSString *) section;
+- (NSString *) simpleSection;
+
- (Address *) maintainer;
- (size_t) size;
- (NSString *) description;
@@ -1425,6 +1427,14 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
return section_;
}
+- (NSString *) simpleSection {
+ if (NSString *section = [self section])
+ return Simplify(section);
+ else
+ return nil;
+
+}
+
- (Address *) maintainer {
if (file_.end())
return nil;
@@ -1594,9 +1604,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
}
- (UIImage *) icon {
- NSString *section = [self section];
- if (section != nil)
- section = Simplify(section);
+ NSString *section = [self simpleSection];
UIImage *icon(nil);
if (NSString *icon = icon_)
@@ -3366,9 +3374,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[self clearPackage];
Source *source = [package source];
- NSString *section = [package section];
- if (section != nil)
- section = Simplify(section);
+ NSString *section = [package simpleSection];
icon_ = [[package icon] retain];
@@ -5447,15 +5453,32 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
if ([command isEqualToString:@"package-icon"]) {
if (path == nil)
goto fail;
+ path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
Package *package([database packageWithName:path]);
if (package == nil)
goto fail;
+ UIImage *icon([package icon]);
+
+ 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:@"section-icon"]) {
+ if (path == nil)
+ goto fail;
+ path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ NSString *section(Simplify(path));
+
+ UIImage *icon([UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]]);
+ if (icon == nil)
+ icon = [UIImage applicationImageNamed:@"unknown.png"];
- UIImage *icon([package icon]);
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];