#include <Cytore.hpp>
#include "UICaboodle/BrowserView.h"
+#include "SDURLCache/SDURLCache.h"
#include "substrate.h"
/* }}} */
- (void) syncData;
- (void) showSettings;
- (UIProgressHUD *) addProgressHUD;
-- (BOOL) hudIsShowing;
- (void) removeProgressHUD:(UIProgressHUD *)hud;
- (CYViewController *) pageForPackage:(NSString *)name;
- (PackageController *) packageController;
UITableViewDelegate
> {
_transient Database *database_;
+ unsigned era_;
NSMutableArray *packages_;
NSMutableArray *sections_;
UITableView *list_;
}
- (Package *) packageAtIndexPath:(NSIndexPath *)path {
+@synchronized (database_) {
+ if ([database_ era] != era_)
+ return nil;
+
Section *section([sections_ objectAtIndex:[path section]]);
NSInteger row([path row]);
Package *package([packages_ objectAtIndex:([section row] + row)]);
- return package;
-}
+ return [[package retain] autorelease];
+} }
- (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {
PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]);
}
- (void) reloadData {
+ era_ = [database_ era];
NSArray *packages = [database_ packages];
[packages_ removeAllObjects];
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
- return ![updatedelegate_ hudIsShowing] && (IsWildcat_ || orientation == UIInterfaceOrientationPortrait);
+ return IsWildcat_ || orientation == UIInterfaceOrientationPortrait;
}
- (void) setUpdate:(NSDate *)date {
UITableViewDelegate
> {
_transient Database *database_;
+ unsigned era_;
CFMutableArrayRef packages_;
NSMutableArray *sections_;
UITableView *list_;
}
- (Package *) packageAtIndexPath:(NSIndexPath *)path {
+@synchronized (database_) {
+ if ([database_ era] != era_)
+ return nil;
+
Section *section([sections_ objectAtIndex:[path section]]);
NSInteger row([path row]);
- return [self packageAtIndex:([section row] + row)];
-}
+ return [[[self packageAtIndex:([section row] + row)] retain] autorelease];
+} }
- (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {
PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]);
}
- (void) reloadData {
+ era_ = [database_ era];
NSArray *packages = [database_ packages];
CFArrayRemoveAllValues(packages_);
Database *database_;
int tag_;
- int hudcount_;
+ unsigned locked_;
NSURL *starturl_;
SectionsController *sections_;
withObject:nil
title:UCLocalize("RUNNING")
];
+
+ ++locked_;
}
- (void) progressControllerIsComplete:(ProgressController *)progress {
+ --locked_;
[self complete];
}
[super applicationWillSuspend];
}
-- (BOOL) hudIsShowing {
- return (hudcount_ > 0);
-}
-
-- (void) applicationSuspend:(__GSEvent *)event {
+- (BOOL) isSafeToSuspend {
// Use external process status API internally.
// This is probably a really bad idea.
+ // XXX: what is the point of this? does this solve anything at all?
uint64_t status = 0;
int notify_token;
if (notify_register_check("com.saurik.Cydia.status", ¬ify_token) == NOTIFY_STATUS_OK) {
notify_cancel(notify_token);
}
- if (![self hudIsShowing] && status == 0)
+ return locked_ == 0 && status == 0;
+}
+
+- (void) applicationSuspend:(__GSEvent *)event {
+ if ([self isSafeToSuspend])
[super applicationSuspend:event];
}
- (void) _animateSuspension:(BOOL)arg0 duration:(double)arg1 startTime:(double)arg2 scale:(float)arg3 {
- if (![self hudIsShowing])
+ if ([self isSafeToSuspend])
[super _animateSuspension:arg0 duration:arg1 startTime:arg2 scale:arg3];
}
- (void) _setSuspended:(BOOL)value {
- if (![self hudIsShowing])
+ if ([self isSafeToSuspend])
[super _setSuspended:value];
}
while ([target modalViewController] != nil) target = [target modalViewController];
[[target view] addSubview:hud];
- hudcount_++;
+ ++locked_;
return hud;
}
[hud show:NO];
[hud removeFromSuperview];
[window_ setUserInteractionEnabled:YES];
- hudcount_--;
+ --locked_;
}
- (CYViewController *) pageForPackage:(NSString *)name {
}
- (void) addStashController {
+ ++locked_;
stash_ = [[CYStashController alloc] init];
[window_ addSubview:[stash_ view]];
}
- (void) removeStashController {
[[stash_ view] removeFromSuperview];
[stash_ release];
+ --locked_;
}
- (void) stash {
- (void) applicationDidFinishLaunching:(id)unused {
_trace();
+ [NSURLCache setSharedURLCache:[[[SDURLCache alloc]
+ initWithMemoryCapacity:524288
+ diskCapacity:10485760
+ diskPath:[NSString stringWithFormat:@"%@/Library/Caches/com.saurik.Cydia/SDURLCache", @"/var/root"]
+ ] autorelease]];
+
[CYBrowserController _initialize];
[NSURLProtocol registerClass:[CydiaURLProtocol class]];