@end
/* }}} */
+#ifdef SRK_ASPEN
+#define UITable UITableView
+#endif
+
/* Reset View (UIView) {{{ */
@interface UIView (CYResetView)
- (void) resetViewAnimated:(BOOL)animated;
pkgSourceList *list_;
NSMutableDictionary *sources_;
+ NSMutableArray *packages_;
id delegate_;
Status status_;
- (pkgRecords *) records;
- (pkgProblemResolver *) resolver;
- (pkgAcquire &) fetcher;
+- (NSArray *) packages;
- (void) reloadData;
- (void) prepare;
- (NSString *) latest;
- (NSString *) installed;
- (BOOL) upgradable;
+- (BOOL) essential;
+- (BOOL) broken;
- (NSString *) id;
- (NSString *) name;
}
- (BOOL) upgradable {
- NSString *installed = [self installed];
- return installed != nil && [[self latest] compare:installed] != NSOrderedSame ? YES : NO;
+ if (NSString *installed = [self installed])
+ return [[self latest] compare:installed] != NSOrderedSame ? YES : NO;
+ else
+ return [self essential];
+}
+
+- (BOOL) essential {
+ return (iterator_->Flags & pkgCache::Flag::Essential) == 0 ? NO : YES;
+}
+
+- (BOOL) broken {
+ return (*[database_ cache])[iterator_].InstBroken();
}
- (NSString *) id {
lock_ = NULL;
sources_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
+ packages_ = [[NSMutableArray arrayWithCapacity:16] retain];
int fds[2];
return *fetcher_;
}
+- (NSArray *) packages {
+ return packages_;
+}
+
- (void) reloadData {
_error->Discard();
delete list_;
forKey:[NSNumber numberWithLong:reinterpret_cast<uintptr_t>(*index)]
];
}
+
+ [packages_ removeAllObjects];
+ for (pkgCache::PkgIterator iterator = cache_->PkgBegin(); !iterator.end(); ++iterator)
+ if (Package *package = [Package packageWithIterator:iterator database:self])
+ [packages_ addObject:package];
}
- (void) prepare {
now_ = [NSDate date];
- NSMutableArray *packages = [NSMutableArray arrayWithCapacity:count];
- for (pkgCache::PkgIterator iterator = [database_ cache]->PkgBegin(); !iterator.end(); ++iterator)
- if (Package *package = [Package packageWithIterator:iterator database:database_])
- [packages addObject:package];
+ NSArray *packages = [database_ packages];
[install_ setPackages:packages];
[changes_ setPackages:packages];
- (void) perform {
[database_ prepare];
- confirm_ = [[ConfirmationView alloc] initWithView:underlay_ database:database_ delegate:self];
+
+ if ([database_ cache]->BrokenCount() == 0)
+ confirm_ = [[ConfirmationView alloc] initWithView:underlay_ database:database_ delegate:self];
+ else {
+ NSMutableArray *broken = [NSMutableArray arrayWithCapacity:16];
+ NSArray *packages = [database_ packages];
+
+ for (size_t i(0); i != [packages count]; ++i) {
+ Package *package = [packages objectAtIndex:i];
+ if ([package broken])
+ [broken addObject:[package name]];
+ }
+
+ UIAlertSheet *sheet = [[[UIAlertSheet alloc]
+ initWithTitle:[NSString stringWithFormat:@"%d Broken Packages", [database_ cache]->BrokenCount()]
+ buttons:[NSArray arrayWithObjects:@"Okay", nil]
+ defaultButtonIndex:0
+ delegate:self
+ context:self
+ ] autorelease];
+
+ [sheet setBodyText:[NSString stringWithFormat:@"The following packages have unmet dependencies:\n\n%@", [broken componentsJoinedByString:@"\n"]]];
+ [sheet popupAlertAnimated:YES];
+
+ [self reloadData:NO];
+ }
}
- (void) upgrade {