+@end
+/* }}} */
+
+/* Source {{{ */
+@interface Source : NSObject {
+ NSString *description_;
+ NSString *label_;
+ NSString *origin_;
+
+ NSString *uri_;
+ NSString *distribution_;
+ NSString *type_;
+
+ BOOL trusted_;
+}
+
+- (void) dealloc;
+
+- (Source *) initWithMetaIndex:(metaIndex *)index;
+
+- (BOOL) trusted;
+
+- (NSString *) uri;
+- (NSString *) distribution;
+- (NSString *) type;
+
+- (NSString *) description;
+- (NSString *) label;
+- (NSString *) origin;
+@end
+
+@implementation Source
+
+- (void) dealloc {
+ [uri_ release];
+ [distribution_ release];
+ [type_ release];
+
+ if (description_ != nil)
+ [description_ release];
+ if (label_ != nil)
+ [label_ release];
+ if (origin_ != nil)
+ [origin_ release];
+
+ [super dealloc];
+}
+
+- (Source *) initWithMetaIndex:(metaIndex *)index {
+ if ((self = [super init]) != nil) {
+ trusted_ = index->IsTrusted();
+
+ uri_ = [[NSString stringWithCString:index->GetURI().c_str()] retain];
+ distribution_ = [[NSString stringWithCString:index->GetDist().c_str()] retain];
+ type_ = [[NSString stringWithCString:index->GetType()] retain];
+
+ description_ = nil;
+ label_ = nil;
+ origin_ = nil;
+
+ debReleaseIndex *dindex(dynamic_cast<debReleaseIndex *>(index));
+ if (dindex != NULL) {
+ std::ifstream release(dindex->MetaIndexFile("Release").c_str());
+ std::string line;
+ while (std::getline(release, line)) {
+ std::string::size_type colon(line.find(':'));
+ if (colon == std::string::npos)
+ continue;
+
+ std::string name(line.substr(0, colon));
+ std::string value(line.substr(colon + 1));
+ while (!value.empty() && value[0] == ' ')
+ value = value.substr(1);
+
+ if (name == "Description")
+ description_ = [[NSString stringWithCString:value.c_str()] retain];
+ else if (name == "Label")
+ label_ = [[NSString stringWithCString:value.c_str()] retain];
+ else if (name == "Origin")
+ origin_ = [[NSString stringWithCString:value.c_str()] retain];
+ }
+ }
+ } return self;
+}
+
+- (BOOL) trusted {
+ return trusted_;
+}
+
+- (NSString *) uri {
+ return uri_;
+}
+
+- (NSString *) distribution {
+ return distribution_;
+}
+
+- (NSString *) type {
+ return type_;
+}
+
+- (NSString *) description {
+ return description_;
+}
+
+- (NSString *) label {
+ return label_;
+}
+
+- (NSString *) origin {
+ return origin_;
+}
+
+@end
+/* }}} */
+/* Source Cell {{{ */
+@interface SourceCell : UITableCell {
+ UITextLabel *description_;
+ UIRightTextLabel *label_;
+ UITextLabel *origin_;
+}
+
+- (void) dealloc;
+
+- (SourceCell *) initWithSource:(Source *)source;
+
+- (void) _setSelected:(float)fraction;
+- (void) setSelected:(BOOL)selected;
+- (void) setSelected:(BOOL)selected withFade:(BOOL)fade;
+- (void) _setSelectionFadeFraction:(float)fraction;
+
+@end
+
+@implementation SourceCell
+
+- (void) dealloc {
+ [description_ release];
+ [label_ release];
+ [origin_ release];
+ [super dealloc];
+}
+
+- (SourceCell *) initWithSource:(Source *)source {
+ if ((self = [super init]) != nil) {
+ GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 20);
+ GSFontRef small = GSFontCreateWithName("Helvetica", kGSFontTraitNone, 14);
+
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+ float clear[] = {0, 0, 0, 0};
+
+ NSString *description = [source description];
+ if (description == nil)
+ description = [source uri];
+
+ description_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 7, 270, 25)];
+ [description_ setBackgroundColor:CGColorCreate(space, clear)];
+ [description_ setFont:bold];
+ [description_ setText:description];
+
+ NSString *label = [source label];
+ if (label == nil)
+ label = [source type];
+
+ label_ = [[UIRightTextLabel alloc] initWithFrame:CGRectMake(290, 32, 90, 25)];
+ [label_ setBackgroundColor:CGColorCreate(space, clear)];
+ [label_ setFont:small];
+ [label_ setText:label];
+
+ NSString *origin = [source origin];
+ if (origin == nil)
+ origin = [source distribution];
+
+ origin_ = [[UITextLabel alloc] initWithFrame:CGRectMake(13, 35, 315, 20)];
+ [origin_ setBackgroundColor:CGColorCreate(space, clear)];
+ [origin_ setFont:small];
+ [origin_ setText:origin];
+
+ [self addSubview:description_];
+ [self addSubview:label_];
+ [self addSubview:origin_];
+
+ CFRelease(small);
+ CFRelease(bold);
+ } return self;
+}
+
+- (void) _setSelected:(float)fraction {
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+
+ float black[] = {
+ interpolate(0.0, 1.0, fraction),
+ interpolate(0.0, 1.0, fraction),
+ interpolate(0.0, 1.0, fraction),
+ 1.0};
+
+ float blue[] = {
+ interpolate(0.2, 1.0, fraction),
+ interpolate(0.2, 1.0, fraction),
+ interpolate(1.0, 1.0, fraction),
+ 1.0};
+
+ float gray[] = {
+ interpolate(0.4, 1.0, fraction),
+ interpolate(0.4, 1.0, fraction),
+ interpolate(0.4, 1.0, fraction),
+ 1.0};
+
+ [description_ setColor:CGColorCreate(space, black)];
+ [label_ setColor:CGColorCreate(space, blue)];
+ [origin_ setColor:CGColorCreate(space, gray)];
+}
+
+- (void) setSelected:(BOOL)selected {
+ [self _setSelected:(selected ? 1.0 : 0.0)];
+ [super setSelected:selected];
+}
+
+- (void) setSelected:(BOOL)selected withFade:(BOOL)fade {
+ if (!fade)
+ [self _setSelected:(selected ? 1.0 : 0.0)];
+ [super setSelected:selected withFade:fade];
+}
+
+- (void) _setSelectionFadeFraction:(float)fraction {
+ [self _setSelected:fraction];
+ [super _setSelectionFadeFraction:fraction];
+}
+