summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorGrant Paul <chpwn@chpwn.com>2011-02-18 01:25:29 -0800
committerGrant Paul <chpwn@chpwn.com>2011-02-18 01:25:29 -0800
commitd669236d8282c4a509c16ae0082ebfcb0090ff22 (patch)
tree8780dea4cf54c09d6402e848b5a418a9c109f407 /MobileCydia.mm
parent017b54a23d9e45398d90c494cfa35588702898d8 (diff)
Factor out source discovery.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm30
1 files changed, 13 insertions, 17 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 4d9fe2e..3d2e83d 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -1329,6 +1329,7 @@ typedef std::map< unsigned long, _H<Source> > SourceMap;
- (pkgSourceList &) list;
- (NSArray *) packages;
- (NSArray *) sources;
+- (Source *) sourceWithKey:(NSString *)key;
- (void) reloadData;
- (void) configure;
@@ -3201,6 +3202,13 @@ static NSString *Warning_;
return sources;
}
+- (Source *) sourceWithKey:(NSString *)key {
+ for (Source *source in [self sources]) {
+ if ([[source key] isEqualToString:key])
+ return source;
+ } return nil;
+}
+
- (bool) popErrorWithTitle:(NSString *)title {
bool fatal(false);
std::string message;
@@ -7666,16 +7674,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
}
- (void) reloadData {
- NSArray *sources = [database_ sources];
- for (Source *source in sources) {
- if ([[source key] isEqual:key_]) {
- source_ = source;
- [key_ release];
- key_ = [[source key] retain];
- break;
- }
- }
-
+ source_ = [database_ sourceWithKey:key_];
+ [key_ release];
+ key_ = [[source_ key] retain];
[self setObject:source_];
[super reloadData];
@@ -9007,13 +9008,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
controller = [[[SourcesController alloc] initWithDatabase:database_] autorelease];
[(SourcesController *)controller showAddSourcePrompt];
} else {
- NSArray *sources = [database_ sources];
- for (Source *source in sources) {
- if ([[source key] isEqual:argument]) {
- controller = [[[SourceController alloc] initWithDatabase:database_ source:source] autorelease];
- break;
- }
- }
+ Source *source = [database_ sourceWithKey:argument];
+ controller = [[[SourceController alloc] initWithDatabase:database_ source:source] autorelease];
}
}