-- (int) numberOfGroupsInPreferencesTable:(UIPreferencesTable *)table {
- int number = 2;
- if ([package_ installed] != nil)
- ++number;
- if ([package_ source] != nil)
- ++number;
- return number;
-}
-
-- (NSString *) preferencesTable:(UIPreferencesTable *)table titleForGroup:(int)group {
- if (group-- == 0)
- return nil;
- else if ([package_ installed] != nil && group-- == 0)
- return @"Installed Package";
- else if (group-- == 0)
- return @"Package Details";
- else if ([package_ source] != nil && group-- == 0)
- return @"Source Information";
- else _assert(false);
-}
-
-- (float) preferencesTable:(UIPreferencesTable *)table heightForRow:(int)row inGroup:(int)group withProposedHeight:(float)proposed {
- if (description_ == nil || group != 0 || row != ([package_ author] == nil ? 1 : 2))
- return proposed;
- else
- return [description_ visibleTextRect].size.height + TextViewOffset_;
-}
-
-- (int) preferencesTable:(UIPreferencesTable *)table numberOfRowsInGroup:(int)group {
- if (group-- == 0) {
- int number = 1;
- if ([package_ author] != nil)
- ++number;
- if (description_ != nil)
- ++number;
- if ([package_ website] != nil)
- ++number;
- return number;
- } else if ([package_ installed] != nil && group-- == 0)
- return 2;
- else if (group-- == 0) {
- int number = 2;
- if ([package_ size] != 0)
- ++number;
- if ([package_ maintainer] != nil)
- ++number;
- if ([package_ sponsor] != nil)
- ++number;
- if ([package_ relationships] != nil)
- ++number;
- if ([[package_ source] trusted])
- ++number;
- return number;
- } else if ([package_ source] != nil && group-- == 0) {
- Source *source = [package_ source];
- NSString *description = [source description];
- int number = 1;
- if (description != nil && ![description isEqualToString:[source label]])
- ++number;
- if ([source origin] != nil)
- ++number;
- return number;
- } else _assert(false);
-}
-
-- (UIPreferencesTableCell *) preferencesTable:(UIPreferencesTable *)table cellForRow:(int)row inGroup:(int)group {
- UIPreferencesTableCell *cell = [[[UIPreferencesTableCell alloc] init] autorelease];
- [cell setShowSelection:NO];
-
- if (group-- == 0) {
- if (false) {
- } else if (row-- == 0) {
- [cell setTitle:[package_ name]];
- [cell setValue:[package_ latest]];
- } else if ([package_ author] != nil && row-- == 0) {
- [cell setTitle:@"Author"];
- [cell setValue:[[package_ author] name]];
- [cell setShowDisclosure:YES];
- [cell setShowSelection:YES];
- } else if (description_ != nil && row-- == 0) {
- [cell addSubview:description_];
- } else if ([package_ website] != nil && row-- == 0) {
- [cell setTitle:@"More Information"];
- [cell setShowDisclosure:YES];
- [cell setShowSelection:YES];
- } else _assert(false);
- } else if ([package_ installed] != nil && group-- == 0) {
- if (false) {
- } else if (row-- == 0) {
- [cell setTitle:@"Version"];
- NSString *installed([package_ installed]);
- [cell setValue:(installed == nil ? @"n/a" : installed)];
- } else if (row-- == 0) {
- [cell setTitle:@"Filesystem Content"];
- [cell setShowDisclosure:YES];
- [cell setShowSelection:YES];
- } else _assert(false);
- } else if (group-- == 0) {
- if (false) {
- } else if (row-- == 0) {
- [cell setTitle:@"Identifier"];
- [cell setValue:[package_ id]];
- } else if (row-- == 0) {
- [cell setTitle:@"Section"];
- NSString *section([package_ section]);
- [cell setValue:(section == nil ? @"n/a" : section)];
- } else if ([package_ size] != 0 && row-- == 0) {
- [cell setTitle:@"Expanded Size"];
- [cell setValue:SizeString([package_ size])];
- } else if ([package_ maintainer] != nil && row-- == 0) {
- [cell setTitle:@"Maintainer"];
- [cell setValue:[[package_ maintainer] name]];
- [cell setShowDisclosure:YES];
- [cell setShowSelection:YES];
- } else if ([package_ sponsor] != nil && row-- == 0) {
- [cell setTitle:@"Sponsor"];
- [cell setValue:[[package_ sponsor] name]];
- [cell setShowDisclosure:YES];
- [cell setShowSelection:YES];
- } else if ([package_ relationships] != nil && row-- == 0) {
- [cell setTitle:@"Package Relationships"];
- [cell setShowDisclosure:YES];
- [cell setShowSelection:YES];
- } else if ([[package_ source] trusted] && row-- == 0) {
- [cell setIcon:[UIImage applicationImageNamed:@"trusted.png"]];
- [cell setValue:@"This package has been signed."];
- } else _assert(false);
- } else if ([package_ source] != nil && group-- == 0) {
- Source *source = [package_ source];
- NSString *description = [source description];
-
- if (false) {
- } else if (row-- == 0) {
- NSString *label = [source label];
- if (label == nil)
- label = [source uri];
- [cell setTitle:label];
- [cell setValue:[source version]];
- } else if (description != nil && ![description isEqualToString:[source label]] && row-- == 0) {
- [cell setValue:description];
- } else if ([source origin] != nil && row-- == 0) {
- [cell setTitle:@"Origin"];
- [cell setValue:[source origin]];
- } else _assert(false);
- } else _assert(false);
-
- return cell;
-}
-
-- (BOOL) canSelectRow:(int)row {
- return YES;
-}
-
-- (void) tableRowSelected:(NSNotification *)notification {
- int row = [table_ selectedRow];
- if (row == INT_MAX)
- return;
-
- #define _else else goto _label; return; } _label:
-
- if (true) {
- if (row-- == 0) {
- } else if (row-- == 0) {
- } else if ([package_ author] != nil && row-- == 0) {
- [delegate_ openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@",
- [[package_ author] email],
- [[NSString stringWithFormat:@"regarding apt package \"%@\"",
- [package_ name]
- ] stringByAddingPercentEscapes]
- ]]];
- } else if (description_ != nil && row-- == 0) {
- } else if ([package_ website] != nil && row-- == 0) {
- NSURL *url = [NSURL URLWithString:[package_ website]];
- BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
- [browser setDelegate:delegate_];
- [book_ pushPage:browser];
- [browser loadURL:url];
- } _else if ([package_ installed] != nil) {
- if (row-- == 0) {
- } else if (row-- == 0) {
- } else if (row-- == 0) {
- FileTable *files = [[[FileTable alloc] initWithBook:book_ database:database_] autorelease];
- [files setDelegate:delegate_];
- [files setPackage:package_];
- [book_ pushPage:files];
- } _else if (true) {
- if (row-- == 0) {
- } else if (row-- == 0) {
- } else if (row-- == 0) {
- } else if ([package_ size] != 0 && row-- == 0) {
- } else if ([package_ maintainer] != nil && row-- == 0) {
- [delegate_ openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@",
- [[package_ maintainer] email],
- [[NSString stringWithFormat:@"regarding apt package \"%@\"",
- [package_ name]
- ] stringByAddingPercentEscapes]
- ]]];
- } else if ([package_ sponsor] != nil && row-- == 0) {
- NSURL *url = [NSURL URLWithString:[[package_ sponsor] email]];
- BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
- [browser setDelegate:delegate_];
- [book_ pushPage:browser];
- [browser loadURL:url];
- } else if ([package_ relationships] != nil && row-- == 0) {
- } else if ([[package_ source] trusted] && row-- == 0) {
- } _else if ([package_ source] != nil) {
- Source *source = [package_ source];
- NSString *description = [source description];
-
- if (row-- == 0) {
- } else if (row-- == 0) {
- } else if (description != nil && ![description isEqualToString:[source label]] && row-- == 0) {
- } else if ([source origin] != nil && row-- == 0) {
- } _else _assert(false);
-
- #undef _else
-}
-