summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm102
1 files changed, 59 insertions, 43 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index a6b61fe..1acb5ea 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -1338,6 +1338,7 @@ static void PackageImport(const void *key, const void *value, void *context) {
- (NSString *) depictionForPackage:(NSString *)package;
- (NSString *) supportForPackage:(NSString *)package;
+- (metaIndex *) metaIndex;
- (NSDictionary *) record;
- (BOOL) trusted;
@@ -1426,6 +1427,10 @@ static void PackageImport(const void *key, const void *value, void *context) {
return ![[self _attributeKeys] containsObject:[NSString stringWithUTF8String:name]] && [super isKeyExcludedFromWebScript:name];
}
+- (metaIndex *) metaIndex {
+ return index_;
+}
+
- (void) setMetaIndex:(metaIndex *)index inPool:(apr_pool_t *)pool {
[self _clear];
@@ -2373,7 +2378,7 @@ struct PackageNameOrdering :
_end
_profile(Package$initWithVersion$Section)
- section_ = iterator.Section();
+ section_ = version_.Section();
_end
_profile(Package$initWithVersion$Flags)
@@ -3539,29 +3544,47 @@ class CydiaLogCleaner :
NSString *title(UCLocalize("DATABASE"));
+ list_ = new pkgSourceList();
+ if ([self popErrorWithTitle:title forOperation:list_->ReadMainList()])
+ return;
+
+ for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) {
+ Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:pool_] autorelease]);
+ [sourceList_ addObject:object];
+ }
+
_trace();
OpProgress progress;
- while (!cache_.Open(progress, true)) { pop:
- std::string error;
- bool warning(!_error->PopMessage(error));
- lprintf("cache_.Open():[%s]\n", error.c_str());
-
- if (error == "dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. ")
- [delegate_ repairWithSelector:@selector(configure)];
- else if (error == "The package lists or status file could not be parsed or opened.")
- [delegate_ repairWithSelector:@selector(update)];
- // else if (error == "Could not get lock /var/lib/dpkg/lock - open (35 Resource temporarily unavailable)")
- // else if (error == "Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)")
- // else if (error == "Malformed Status line")
- // else if (error == "The list of sources could not be read.")
- else {
+ open:
+ if (!cache_.Open(progress, true)) {
+ // XXX: what if there are errors, but Open() == true? this should be merged with popError:
+ while (!_error->empty()) {
+ std::string error;
+ bool warning(!_error->PopMessage(error));
+
+ lprintf("cache_.Open():[%s]\n", error.c_str());
+
[delegate_ addProgressEventOnMainThread:[CydiaProgressEvent eventWithMessage:[NSString stringWithUTF8String:error.c_str()] ofType:(warning ? kCydiaProgressEventTypeWarning : kCydiaProgressEventTypeError)] forTask:title];
- return;
+
+ SEL repair(NULL);
+ if (false);
+ else if (error == "dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. ")
+ repair = @selector(configure);
+ //else if (error == "The package lists or status file could not be parsed or opened.")
+ // repair = @selector(update);
+ // else if (error == "Could not get lock /var/lib/dpkg/lock - open (35 Resource temporarily unavailable)")
+ // else if (error == "Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)")
+ // else if (error == "Malformed Status line")
+ // else if (error == "The list of sources could not be read.")
+
+ if (repair != NULL) {
+ _error->Discard();
+ [delegate_ repairWithSelector:repair];
+ goto open;
+ }
}
- if (warning)
- goto pop;
- _error->Discard();
+ return;
}
_trace();
@@ -3575,10 +3598,6 @@ class CydiaLogCleaner :
fetcher_ = new pkgAcquire(&status_);
lock_ = NULL;
- list_ = new pkgSourceList();
- if ([self popErrorWithTitle:title forOperation:list_->ReadMainList()])
- return;
-
if (cache_->DelCount() != 0 || cache_->InstCount() != 0) {
[delegate_ addProgressEventOnMainThread:[CydiaProgressEvent eventWithMessage:UCLocalize("COUNTS_NONZERO_EX") ofType:kCydiaProgressEventTypeError] forTask:title];
return;
@@ -3600,11 +3619,9 @@ class CydiaLogCleaner :
return;
}
- for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) {
- Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:pool_] autorelease]);
- [sourceList_ addObject:object];
-
- std::vector<pkgIndexFile *> *indices = (*source)->GetIndexFiles();
+ for (Source *object in (id) sourceList_) {
+ metaIndex *source([object metaIndex]);
+ std::vector<pkgIndexFile *> *indices = source->GetIndexFiles();
for (std::vector<pkgIndexFile *>::const_iterator index = indices->begin(); index != indices->end(); ++index)
// XXX: this could be more intelligent
if (dynamic_cast<debPackagesIndex *>(*index) != NULL) {
@@ -5324,12 +5341,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
] autorelease];
}
-- (void) uicache {
- _trace();
- system("su -c /usr/bin/uicache mobile");
- _trace();
-}
-
- (void) invoke:(NSInvocation *)invocation withTitle:(NSString *)title {
UpdateExternalStatus(1);
@@ -5407,11 +5418,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
case 4: [progress_ setFinish:UCLocalize("REBOOT_DEVICE")]; break;
}
- UIProgressHUD *hud([delegate_ addProgressHUD]);
- [hud setText:UCLocalize("LOADING")];
- [self yieldToSelector:@selector(uicache)];
- [delegate_ removeProgressHUD:hud];
-
UpdateExternalStatus(Finish_ == 0 ? 0 : 2);
[progress_ setRunning:false];
@@ -8910,10 +8916,6 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi
@synchronized (database_) {
era_ = [database_ era];
- pkgSourceList list;
- if ([database_ popErrorWithTitle:UCLocalize("SOURCES") forOperation:list.ReadMainList()])
- return;
-
sources_ = [NSMutableArray arrayWithCapacity:16];
[sources_ addObjectsFromArray:[database_ sources]];
_trace();
@@ -9686,9 +9688,23 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi
}
}
+- (void) _uicache {
+ _trace();
+ system("su -c /usr/bin/uicache mobile");
+ _trace();
+}
+
+- (void) uicache {
+ UIProgressHUD *hud([self addProgressHUD]);
+ [hud setText:UCLocalize("LOADING")];
+ [self yieldToSelector:@selector(_uicache)];
+ [self removeProgressHUD:hud];
+}
+
- (void) perform_ {
[database_ perform];
[self performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES];
+ [self performSelectorOnMainThread:@selector(uicache) withObject:nil waitUntilDone:YES];
}
- (void) confirmWithNavigationController:(UINavigationController *)navigation {