From 7398a38978644e7d9123ec01f0403ce15d9c821e Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 21 Jan 2009 13:10:03 +0000 Subject: [PATCH] Limited parallelism, fixed nil storage, updated style, and added progress huds. --- Cydia.app/menes/style.css | 120 ++++++++++++++++++++++++++++++++------ Cydia.app/storage.js | 2 + Cydia.mm | 118 ++++++++++++++++++++++++------------- control | 2 +- 4 files changed, 182 insertions(+), 60 deletions(-) diff --git a/Cydia.app/menes/style.css b/Cydia.app/menes/style.css index d9915c98..cf664140 100644 --- a/Cydia.app/menes/style.css +++ b/Cydia.app/menes/style.css @@ -252,31 +252,67 @@ list > fieldset > textarea { border-bottom: 1px solid #e0e0e0; } -fieldset > a, +fieldset > a:not([type="ad"]), fieldset > div, fieldset > textarea { - min-height: 42px; /* XXX: small differences due to font bugs */ padding: 13px 14px 11px 14px; } -panel > fieldset > a.thumb:first-child > div:first-of-type { +fieldset > a[type="ad"] { + /* XXX: small differences due to font bugs */ + padding: 4px 4px 2px 5px; +} + +panel > fieldset > a[type="ad"]:first-child > div:first-of-type, +panel > fieldset > a[type="thumb"]:first-child > div:first-of-type { -webkit-border-top-left-radius: 9px; } -panel > fieldset > a.thumb:last-child > div:first-of-type { +panel > fieldset > a[type="ad"]:last-child > div:first-of-type, +panel > fieldset > a[type="thumb"]:last-child > div:first-of-type { -webkit-border-bottom-left-radius: 9px; } -list > fieldset > a.thumb > div:first-of-type { +fieldset > a[type="ad"] > div:first-of-type { + border: 1px solid #999999; +} + +list > fieldset > a[type="thumb"] > div:first-of-type { border: 1px solid #e0e0e0; } -panel > fieldset > a.thumb > div:first-of-type { +panel > fieldset > a[type="thumb"] > div:first-of-type { border: 1px solid #999999; } -fieldset > a.thumb > div:first-of-type { +div[tile] { + float: right; + height: 30px; + width: 30px; +} + +div[tile="app"] { background-image: url(http://cache.saurik.com/cydia/tile/app.png); } +div[tile="call"] { background-image: url(http://cache.saurik.com/cydia/tile/call.png); } +div[tile="map"] { background-image: url(http://cache.saurik.com/cydia/tile/map.png); } +div[tile="media"] { background-image: url(http://cache.saurik.com/cydia/tile/media.png); } +div[tile="music"] { background-image: url(http://cache.saurik.com/cydia/tile/video.png); } +div[tile="site"] { background-image: url(http://cache.saurik.com/cydia/tile/site.png); } + +fieldset > a[type="ad"] > div:first-of-type { + background-repeat: no-repeat; + background-position: center center; + border-right: none; + display: inline-block; + height: 40px; + line-height: 38px; + /* XXX: small differences due to font bugs */ + /* XXX: 1px difference due to border stupidity */ + margin: -5px 5px -3px -6px; + width: 40px; +} + +fieldset > a[type="thumb"] > div:first-of-type { background-repeat: no-repeat; background-position: center center; display: inline-block; @@ -337,7 +373,7 @@ fieldset > div > select { /* Chevrons {{{ */ -fieldset > a[href], +fieldset > a[href]:not([type="ad"]), fieldset > div > select { background-repeat: no-repeat; background-image: url(chevron.png); @@ -417,7 +453,11 @@ fieldset > div > div { width: 273px; } -fieldset > a:not(.thumb) > div { +fieldset > a[type="ad"] > div:nth-of-type(2) { + width: 218px; +} + +fieldset > a:not([type]) > div { width: 250px; } @@ -429,17 +469,17 @@ fieldset > a > img.icon + div { width: 221px; } -fieldset > a.thumb > div:nth-of-type(2) > label:only-of-type { +fieldset > a[type="thumb"] > div:nth-of-type(2) > label:only-of-type { position: relative; top: 10px; } -fieldset > a.thumb > div:nth-of-type(2) > label:nth-of-type(2) { +fieldset > a[type="thumb"] > div:nth-of-type(2) > label:nth-of-type(2) { display: block; margin-top: 2px; } -fieldset > a.thumb > div:nth-of-type(2) { +fieldset > a[type="thumb"] > div:nth-of-type(2) { vertical-align: top; width: 193px; } @@ -451,12 +491,12 @@ fieldset > div > div > label:first-of-type { font-weight: bold; } -list > fieldset > a:not(.thumb) > div > label:nth-of-type(2), +list > fieldset > a:not([type]) > div > label:nth-of-type(2), list > fieldset > div > div > label:nth-of-type(2) { margin-left: 94px; } -panel > fieldset > a:not(.thumb) > div > label:nth-of-type(2), +panel > fieldset > a:not([type]) > div > label:nth-of-type(2), panel > fieldset > div > div > label:nth-of-type(2) { float: right; text-align: right; @@ -469,15 +509,61 @@ panel > img { width: 300px; } -fieldset > a.thumb:first-child > back { +fieldset > a[type="ad"] { +} + +fieldset > a[type="ad"] > div:nth-of-type(2) { + position: relative; + vertical-align: top; +} + +fieldset > a[type="ad"] > div > label:nth-of-type(1) { + color: #2d2d50; + font-size: 13px; + font-weight: bold; + line-height: 15px; +} + +fieldset > a[type="ad"] > div > label:nth-of-type(2) { + position: absolute; + top: 17px; + left: 156px; + font-size: 9.5px; + font-weight: normal; +} + +fieldset.half > a { + background: none; + background-position-x: 120px; +} + +fieldset.half > a > img.icon + div { + width: 65px; +} + +fieldset.right { + float: right; + margin-left: 10px; +} + +block + fieldset.right, +fieldset + fieldset.right { + margin-top: 0; +} + +fieldset.half { + width: 146px; +} + +fieldset > a[type="thumb"]:first-child > back { -webkit-border-top-right-radius: 9px; } -fieldset > a.thumb:last-child > back { +fieldset > a[type="thumb"]:last-child > back { -webkit-border-bottom-right-radius: 9px; } -fieldset > a.thumb > back { +fieldset > a[type="thumb"] > back { background-repeat: no-repeat; border: 1px solid #999999; display: block; diff --git a/Cydia.app/storage.js b/Cydia.app/storage.js index 02dc51b7..73d5de7b 100644 --- a/Cydia.app/storage.js +++ b/Cydia.app/storage.js @@ -57,6 +57,8 @@ var setup = function (name, root, folders) { for (var i = 0; i != folders.length; ++i) { var folder = folders[i]; var usage = cydia.du(folder[1]); + if (usage == null) + usage = 0; var color = colors[i + 2]; var percent = usage / kb; list(legend, color, folder[0], percent); diff --git a/Cydia.mm b/Cydia.mm index a4b2e600..f64b9e4d 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -172,6 +172,56 @@ void NSLogRect(const char *fix, const CGRect &rect) { NSLog(@"%s(%g,%g)+(%g,%g)", fix, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); } +@interface NSObject (Cydia) +- (void) yieldToSelector:(SEL)selector withObject:(id)object; +@end + +@implementation NSObject (Cydia) + +- (void) doNothing { +} + +- (void) _yieldToContext:(NSArray *)context { _pooled + SEL selector(reinterpret_cast([[context objectAtIndex:0] pointerValue])); + id object([[context objectAtIndex:1] nonretainedObjectValue]); + volatile bool &stopped(*reinterpret_cast([[context objectAtIndex:2] pointerValue])); + + [self performSelector:selector withObject:object]; + + stopped = true; + + [self + performSelectorOnMainThread:@selector(doNothing) + withObject:nil + waitUntilDone:NO + ]; +} + +- (void) yieldToSelector:(SEL)selector withObject:(id)object { + volatile bool stopped(false); + + NSArray *context([NSArray arrayWithObjects: + [NSValue valueWithPointer:selector], + [NSValue valueWithNonretainedObject:object], + [NSValue valueWithPointer:const_cast(&stopped)], + nil]); + + NSThread *thread([[[NSThread alloc] + initWithTarget:self + selector:@selector(_yieldToContext:) + object:context + ] autorelease]); + + [thread start]; + + NSRunLoop *loop([NSRunLoop currentRunLoop]); + NSDate *future([NSDate distantFuture]); + + while (!stopped && [loop runMode:NSDefaultRunLoopMode beforeDate:future]); +} + +@end + /* NSForcedOrderingSearch doesn't work on the iPhone */ static const NSStringCompareOptions BaseCompareOptions_ = NSNumericSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch; static const NSStringCompareOptions ForcedCompareOptions_ = BaseCompareOptions_; @@ -759,6 +809,7 @@ bool isSectionVisible(NSString *section) { - (void) syncData; - (void) askForSettings; - (UIProgressHUD *) addProgressHUD; +- (void) removeProgressHUD:(UIProgressHUD *)hud; - (RVPage *) pageForURL:(NSURL *)url hasTag:(int *)tag; - (RVPage *) pageForPackage:(NSString *)name; - (void) openMailToURL:(NSURL *)url; @@ -1604,7 +1655,7 @@ class Progress : bool value; if (current.end()) - value = essential && [self essential]; + value = essential && [self essential] && [self visible]; else value = !version_.end() && version_ != current;// && (!essential || ![database_ cache][iterator_].Keep()); return value; @@ -2331,7 +2382,7 @@ static NSArray *Finishes_; return issues; } -- (void) reloadData { +- (void) reloadData { _pooled _error->Discard(); delete list_; @@ -2410,6 +2461,9 @@ static NSArray *Finishes_; _trace(); [packages_ sortUsingSelector:@selector(compareByName:)]; _trace(); + + _config->Set("Acquire::http::Timeout", 15); + _config->Set("Acquire::http::MaxParallel", 4); } - (void) configure { @@ -2970,8 +3024,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { SHA1SumValue springlist_; SHA1SumValue notifyconf_; SHA1SumValue sandplate_; - size_t received_; - NSTimeInterval last_; } - (void) transitionViewDidComplete:(UITransitionView*)view fromView:(UIView*)from toView:(UIView*)to; @@ -3281,9 +3333,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [output_ setText:@""]; [progress_ setProgress:0]; - received_ = 0; - last_ = 0;//[NSDate timeIntervalSinceReferenceDate]; - [close_ removeFromSuperview]; [overlay_ addSubview:progress_]; [overlay_ addSubview:status_]; @@ -3377,7 +3426,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) startProgress { - last_ = [NSDate timeIntervalSinceReferenceDate]; } - (void) addProgressOutput:(NSString *)output { @@ -3389,15 +3437,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (bool) isCancelling:(size_t)received { - if (last_ != 0) { - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - if (received_ != received) { - received_ = received; - last_ = now; - } else if (now - last_ > 30) - return true; - } - return false; } @@ -4463,9 +4502,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { trivial_gz_ == nil ) { [delegate_ setStatusBarShowsProgress:NO]; + [delegate_ removeProgressHUD:hud_]; - [hud_ show:NO]; - [hud_ removeFromSuperview]; [hud_ autorelease]; hud_ = nil; @@ -4563,7 +4601,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { trivial_ = false; - hud_ = [delegate_ addProgressHUD]; + hud_ = [[delegate_ addProgressHUD] retain]; [hud_ setText:@"Verifying URL"]; } break; @@ -4862,8 +4900,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { UIProgressBar *progress_; UINavigationButton *cancel_; bool updating_; - size_t received_; - NSTimeInterval last_; } - (id) initWithFrame:(CGRect)frame database:(Database *)database; @@ -4913,8 +4949,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [prompt_ setText:@"Updating Database"]; [progress_ setProgress:0]; - received_ = 0; - last_ = [NSDate timeIntervalSinceReferenceDate]; updating_ = true; [overlay_ addSubview:cancel_]; @@ -5078,12 +5112,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (bool) isCancelling:(size_t)received { - NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - if (received_ != received) { - received_ = received; - last_ = now; - } else if (now - last_ > 15) - return true; return !updating_; } @@ -6193,12 +6221,15 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) _reloadData { - /*UIProgressHUD *hud = [[UIProgressHUD alloc] initWithWindow:window_]; + UIView *block(); + + UIProgressHUD *hud([self addProgressHUD]); [hud setText:@"Reloading Data"]; - [overlay_ addSubview:hud]; - [hud show:YES];*/ - [database_ reloadData]; + [database_ yieldToSelector:@selector(reloadData) withObject:nil]; + _trace(); + + [self removeProgressHUD:hud]; size_t changes(0); @@ -6246,9 +6277,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [book_ update]; } - - /*[hud show:NO]; - [hud removeFromSuperview];*/ } - (void) _saveConfig { @@ -6476,9 +6504,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) finish { if (hud_ != nil) { [self setStatusBarShowsProgress:NO]; + [self removeProgressHUD:hud_]; - [hud_ show:NO]; - [hud_ removeFromSuperview]; [hud_ autorelease]; hud_ = nil; @@ -6724,12 +6751,19 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (UIProgressHUD *) addProgressHUD { - UIProgressHUD *hud = [[UIProgressHUD alloc] initWithWindow:window_]; + UIProgressHUD *hud([[[UIProgressHUD alloc] initWithWindow:window_] autorelease]); + [window_ setUserInteractionEnabled:NO]; [hud show:YES]; - [underlay_ addSubview:hud]; + [progress_ addSubview:hud]; return hud; } +- (void) removeProgressHUD:(UIProgressHUD *)hud { + [hud show:NO]; + [hud removeFromSuperview]; + [window_ setUserInteractionEnabled:YES]; +} + - (void) openMailToURL:(NSURL *)url { // XXX: this makes me sad #if 0 @@ -6867,7 +6901,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { ) { [self setIdleTimerDisabled:YES]; - hud_ = [self addProgressHUD]; + hud_ = [[self addProgressHUD] retain]; [hud_ setText:@"Reorganizing\n\nWill Automatically\nClose When Done"]; [self setStatusBarShowsProgress:YES]; diff --git a/control b/control index 81f29b7c..e036c0e9 100644 --- a/control +++ b/control @@ -4,7 +4,7 @@ Priority: required Section: Packaging Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 1.0.2684-39 +Version: 1.0.2698-41 Replaces: com.sosiphone.addcydia Depends: apt, darwintools, pcre, shell-cmds Conflicts: com.sosiphone.addcydia -- 2.45.2