summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-07 09:09:22 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-08 01:50:05 -0800
commit8252b666246879752a14fcf55e1debbb63da9d92 (patch)
tree6e656d9b656341f572fbb2600e591d3b97d3f7d4 /MobileCydia.mm
parent7d9d4da29ec5839a72894fa1a93adc811e1d2f46 (diff)
Initial implementation of CydiaIcon.png.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm40
1 files changed, 35 insertions, 5 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 366e070..ae3fc4c 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -1261,6 +1261,7 @@ static void PackageImport(const void *key, const void *value, void *context) {
CYString uri_;
CYString distribution_;
CYString type_;
+ CYString base_;
CYString version_;
_H<NSString> host_;
@@ -1285,6 +1286,9 @@ static void PackageImport(const void *key, const void *value, void *context) {
- (NSString *) uri;
- (NSString *) distribution;
- (NSString *) type;
+
+- (NSString *) base;
+
- (NSString *) key;
- (NSString *) host;
@@ -1305,6 +1309,8 @@ static void PackageImport(const void *key, const void *value, void *context) {
distribution_.clear();
type_.clear();
+ base_.clear();
+
description_.clear();
label_.clear();
origin_.clear();
@@ -1353,6 +1359,8 @@ static void PackageImport(const void *key, const void *value, void *context) {
debReleaseIndex *dindex(dynamic_cast<debReleaseIndex *>(index));
if (dindex != NULL) {
+ base_.set(pool, dindex->MetaIndexURI(""));
+
FileFd fd;
if (!fd.Open(dindex->MetaIndexFile("Release"), FileFd::ReadOnly))
_error->Discard();
@@ -1457,6 +1465,10 @@ static void PackageImport(const void *key, const void *value, void *context) {
return type_;
}
+- (NSString *) base {
+ return base_;
+}
+
- (NSString *) key {
return [NSString stringWithFormat:@"%@:%@:%@", (NSString *) type_, (NSString *) uri_, (NSString *) distribution_];
}
@@ -7645,17 +7657,35 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@implementation SourceCell
+- (void) _setImage:(UIImage *)image {
+ icon_ = image;
+ [content_ setNeedsDisplay];
+}
+
+- (void) _setSource:(Source *)source {
+ NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
+
+ if (NSString *base = [source base])
+ if ([base length] != 0) {
+ NSURL *url([NSURL URLWithString:[base stringByAppendingString:@"CydiaIcon.png"]]);
+
+ if (NSData *data = [NSData dataWithContentsOfURL:url])
+ if (UIImage *image = [UIImage imageWithData:data])
+ [self performSelectorOnMainThread:@selector(_setImage:) withObject:image waitUntilDone:NO];
+ }
+
+ [pool release];
+}
+
- (void) setSource:(Source *)source {
- icon_ = nil;
- if (icon_ == nil)
- icon_ = [UIImage applicationImageNamed:[NSString stringWithFormat:@"Sources/%@.png", [source host]]];
- if (icon_ == nil)
- icon_ = [UIImage applicationImageNamed:@"unknown.png"];
+ icon_ = [UIImage applicationImageNamed:@"unknown.png"];
origin_ = [source name];
label_ = [source uri];
[content_ setNeedsDisplay];
+
+ [NSThread detachNewThreadSelector:@selector(_setSource:) toTarget:self withObject:source];
}
- (SourceCell *) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {