NSLog(@"%s(%g,%g)+(%g,%g)", fix, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
}
+static _finline NSString *CydiaURL(NSString *path) {
+ char page[25];
+ page[0] = 'h'; page[1] = 't'; page[2] = 't'; page[3] = 'p'; page[4] = ':';
+ page[5] = '/'; page[6] = '/'; page[7] = 'c'; page[8] = 'y'; page[9] = 'd';
+ page[10] = 'i'; page[11] = 'a'; page[12] = '.'; page[13] = 's'; page[14] = 'a';
+ page[15] = 'u'; page[16] = 'r'; page[17] = 'i'; page[18] = 'k'; page[19] = '.';
+ page[20] = 'c'; page[21] = 'o'; page[22] = 'm'; page[23] = '/'; page[24] = '\0';
+ return [[NSString stringWithUTF8String:page] stringByAppendingString:path];
+}
+
/* [NSObject yieldToSelector:(withObject:)] {{{*/
@interface NSObject (Cydia)
- (id) yieldToSelector:(SEL)selector withObject:(id)object;
@end
/* }}} */
+@interface CYActionSheet : UIActionSheet {
+ unsigned button_;
+}
+
+- (int) yieldToPopupAlertAnimated:(BOOL)animated;
+@end
+
+@implementation CYActionSheet
+
+- (id) initWithTitle:(NSString *)title buttons:(NSArray *)buttons defaultButtonIndex:(int)index {
+ if ((self = [super initWithTitle:title buttons:buttons defaultButtonIndex:index delegate:self context:nil]) != nil) {
+ } return self;
+}
+
+- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
+ button_ = button;
+}
+
+- (int) yieldToPopupAlertAnimated:(BOOL)animated {
+ button_ = 0;
+ [self popupAlertAnimated:animated];
+ NSRunLoop *loop([NSRunLoop currentRunLoop]);
+ NSDate *future([NSDate distantFuture]);
+ while (button_ == 0 && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
+ return button_;
+}
+
+@end
+
/* NSForcedOrderingSearch doesn't work on the iPhone */
static const NSStringCompareOptions MatchCompareOptions_ = NSLiteralSearch | NSCaseInsensitiveSearch;
static const NSStringCompareOptions LaxCompareOptions_ = NSNumericSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch | NSCaseInsensitiveSearch;
#define HistogramInsertionSort (0 && !ForRelease)
#define ProfileTimes (0 && !ForRelease)
#define ForSaurik (0 && !ForRelease)
-#define LogBrowser (1 && !ForRelease)
+#define LogBrowser (0 && !ForRelease)
#define TrackResize (0 && !ForRelease)
-#define ManualRefresh (1 && !ForRelease)
+#define ManualRefresh (0 && !ForRelease)
#define ShowInternals (0 && !ForRelease)
#define IgnoreInstall (0 && !ForRelease)
#define RecycleWebViews 0
static NSString *Home_;
static BOOL Advanced_;
-static BOOL Loaded_;
static BOOL Ignored_;
static UIFont *Font12_;
@interface NSObject (ProgressDelegate)
@end
-@implementation NSObject(ProgressDelegate)
-
-- (void) _setProgressError:(NSArray *)args {
- [self performSelector:@selector(setProgressError:forPackage:)
- withObject:[args objectAtIndex:0]
- withObject:([args count] == 1 ? nil : [args objectAtIndex:1])
- ];
-}
-
-@end
-
@protocol ProgressDelegate
-- (void) setProgressError:(NSString *)error forPackage:(NSString *)id;
+- (void) setProgressError:(NSString *)error withTitle:(NSString *)id;
- (void) setProgressTitle:(NSString *)title;
- (void) setProgressPercent:(float)percent;
- (void) startProgress;
delegate_ = delegate;
}
+ NSObject<ProgressDelegate> *getDelegate() const {
+ return delegate_;
+ }
+
virtual bool MediaChange(std::string media, std::string drive) {
return false;
}
virtual void Fetch(pkgAcquire::ItemDesc &item) {
//NSString *name([NSString stringWithUTF8String:item.ShortDesc.c_str()]);
- [delegate_ setProgressTitle:[NSString stringWithFormat:UCLocalize("DOWNLOADING"), [NSString stringWithUTF8String:item.ShortDesc.c_str()]]];
+ [delegate_ setProgressTitle:[NSString stringWithFormat:UCLocalize("DOWNLOADING_"), [NSString stringWithUTF8String:item.ShortDesc.c_str()]]];
}
virtual void Done(pkgAcquire::ItemDesc &item) {
NSArray *fields([description componentsSeparatedByString:@" "]);
NSString *source([fields count] == 0 ? nil : [fields objectAtIndex:0]);
- [delegate_ performSelectorOnMainThread:@selector(_setProgressError:)
+ [delegate_ performSelectorOnMainThread:@selector(_setProgressErrorPackage:)
withObject:[NSArray arrayWithObjects:
[NSString stringWithUTF8String:error.c_str()],
source,
protected:
virtual void Update() {
- if (abs(Percent - percent_) > 2) {
- NSLog(@"%s:%s:%f", Op.c_str(), SubOp.c_str(), Percent);
+ /*if (abs(Percent - percent_) > 2)
+ //NSLog(@"%s:%s:%f", Op.c_str(), SubOp.c_str(), Percent);
percent_ = Percent;
- }
+ }*/
/*[delegate_ setProgressTitle:[NSString stringWithUTF8String:Op.c_str()]];
[delegate_ setProgressPercent:(Percent / 100)];*/
delegate_ = delegate;
}
+ id getDelegate() const {
+ return delegate_;
+ }
+
virtual void Done() {
- NSLog(@"DONE");
+ //NSLog(@"DONE");
//[delegate_ setProgressPercent:1];
}
};
- (void) reloadData;
- (void) configure;
-- (void) prepare;
+- (bool) prepare;
- (void) perform;
-- (void) upgrade;
+- (bool) upgrade;
- (void) update;
- (void) setVisible;
-- (NSString *) updateWithStatus:(Status &)status;
+- (void) updateWithStatus:(Status &)status;
- (void) setDelegate:(id)delegate;
- (Source *) getSource:(pkgCache::PkgFileIterator)file;
+@end
+/* }}} */
+/* Delegate Helpers {{{ */
+@implementation NSObject(ProgressDelegate)
+
+- (void) _setProgressErrorPackage:(NSArray *)args {
+ [self performSelector:@selector(setProgressError:forPackage:)
+ withObject:[args objectAtIndex:0]
+ withObject:([args count] == 1 ? nil : [args objectAtIndex:1])
+ ];
+}
+
+- (void) _setProgressErrorTitle:(NSArray *)args {
+ [self performSelector:@selector(setProgressError:withTitle:)
+ withObject:[args objectAtIndex:0]
+ withObject:([args count] == 1 ? nil : [args objectAtIndex:1])
+ ];
+}
+
+- (void) _setProgressError:(NSString *)error withTitle:(NSString *)title {
+ [self performSelectorOnMainThread:@selector(_setProgressErrorTitle:)
+ withObject:[NSArray arrayWithObjects:error, title, nil]
+ waitUntilDone:YES
+ ];
+}
+
+- (void) setProgressError:(NSString *)error forPackage:(NSString *)id {
+ Package *package = id == nil ? nil : [[Database sharedInstance] packageWithName:id];
+ // XXX: holy typecast batman!
+ [(id<ProgressDelegate>)self setProgressError:error withTitle:(package == nil ? id : [package name])];
+}
+
@end
/* }}} */
- (bool) isUnfilteredAndSearchedForBy:(NSString *)search;
- (bool) isInstalledAndVisible:(NSNumber *)number;
-- (bool) isVisiblyUninstalledInSection:(NSString *)section;
+- (bool) isVisibleInSection:(NSString *)section;
- (bool) isVisibleInSource:(Source *)source;
@end
return @"UPGRADE";
case 2:
return @"NEW_INSTALL";
- default:
- _assert(false);
+ _nodefault
}
- default:
- _assert(false);
+ _nodefault
}
}
return (![number boolValue] || [self visible]) && ![self uninstalled];
}
-- (bool) isVisiblyUninstalledInSection:(NSString *)name {
+- (bool) isVisibleInSection:(NSString *)name {
NSString *section = [self section];
return
- [self visible] &&
- [self uninstalled] && (
+ [self visible] && (
name == nil ||
section == nil && [name length] == 0 ||
[name isEqualToString:section]
@end
/* }}} */
+static NSString *Colon_;
+static NSString *Error_;
+static NSString *Warning_;
+
/* Database Implementation {{{ */
@implementation Database
}
}
- _assert(false);
+ _assume(false);
}
- (void) _readStatus:(NSNumber *)fd { _pooled
while (std::getline(is, line)) {
const char *data(line.c_str());
- size_t size = line.size();
+ size_t size(line.size());
lprintf("S:%s\n", data);
if (conffile_r(data, size)) {
NSString *string = pmstatus_r[4];
if (type == "pmerror")
- [delegate_ performSelectorOnMainThread:@selector(_setProgressError:)
+ [delegate_ performSelectorOnMainThread:@selector(_setProgressErrorPackage:)
withObject:[NSArray arrayWithObjects:string, id, nil]
waitUntilDone:YES
];
[delegate_ setProgressTitle:string];
} else if (type == "pmconffile")
[delegate_ setConfigurationData:string];
- else _assert(false);
- } else _assert(false);
+ else
+ lprintf("E:unknown pmstatus\n");
+ } else
+ lprintf("E:unknown status\n");
}
- _assert(false);
+ _assume(false);
}
- (void) _readOutput:(NSNumber *)fd { _pooled
[delegate_ addProgressOutput:[NSString stringWithUTF8String:line.c_str()]];
}
- _assert(false);
+ _assume(false);
}
- (FILE *) input {
return issues;
}
+- (bool) popErrorWithTitle:(NSString *)title {
+ bool fatal(false);
+ std::string message;
+
+ while (!_error->empty()) {
+ std::string error;
+ bool warning(!_error->PopMessage(error));
+ if (!warning)
+ fatal = true;
+ for (;;) {
+ size_t size(error.size());
+ if (size == 0 || error[size - 1] != '\n')
+ break;
+ error.resize(size - 1);
+ }
+ lprintf("%c:[%s]\n", warning ? 'W' : 'E', error.c_str());
+
+ if (!message.empty())
+ message += "\n\n";
+ message += error;
+ }
+
+ if (!message.empty())
+ [delegate_ _setProgressError:[NSString stringWithUTF8String:message.c_str()] withTitle:[NSString stringWithFormat:Colon_, fatal ? Error_ : Warning_, title]];
+
+ return fatal;
+}
+
+- (bool) popErrorWithTitle:(NSString *)title forOperation:(bool)success {
+ return [self popErrorWithTitle:title] || !success;
+}
+
- (void) reloadData { _pooled
@synchronized ([Database class]) {
-
@synchronized (self) {
++era_;
}
if (chk != -1)
close(chk);
+ NSString *title(UCLocalize("DATABASE"));
+
_trace();
- if (!cache_.Open(progress_, true)) {
+ if (!cache_.Open(progress_, true)) { pop:
std::string error;
- if (!_error->PopMessage(error))
- _assert(false);
- _error->Discard();
+ 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. ")
// else if (error == "Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)")
// else if (error == "Could not get lock /var/lib/dpkg/lock - open (35 Resource temporarily unavailable)")
// else if (error == "The list of sources could not be read.")
- else _assert(false);
+ else
+ [delegate_ _setProgressError:[NSString stringWithUTF8String:error.c_str()] withTitle:[NSString stringWithFormat:Colon_, warning ? Warning_ : Error_, title]];
+ if (warning)
+ goto pop;
+ _error->Discard();
return;
}
_trace();
lock_ = NULL;
list_ = new pkgSourceList();
- _assert(list_->ReadMainList());
+ if ([self popErrorWithTitle:title forOperation:list_->ReadMainList()])
+ return;
+
+ if (cache_->DelCount() != 0 || cache_->InstCount() != 0) {
+ [delegate_ _setProgressError:@"COUNTS_NONZERO_EX" withTitle:title];
+ return;
+ }
- _assert(cache_->DelCount() == 0 && cache_->InstCount() == 0);
- _assert(pkgApplyStatus(cache_));
+ if ([self popErrorWithTitle:title forOperation:pkgApplyStatus(cache_)])
+ return;
if (cache_->BrokenCount() != 0) {
- _assert(pkgFixBroken(cache_));
- _assert(cache_->BrokenCount() == 0);
- _assert(pkgMinimizeUpgrade(cache_));
+ if ([self popErrorWithTitle:title forOperation:pkgFixBroken(cache_)])
+ return;
+
+ if (cache_->BrokenCount() != 0) {
+ [delegate_ _setProgressError:@"STILL_BROKEN_EX" withTitle:title];
+ return;
+ }
+
+ if ([self popErrorWithTitle:title forOperation:pkgMinimizeUpgrade(cache_)])
+ return;
}
_trace();
system([dpkg UTF8String]);
}
-- (void) clean {
+- (bool) clean {
+ // XXX: I don't remember this condition
if (lock_ != NULL)
- return;
+ return false;
FileFd Lock;
Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"));
- _assert(!_error->PendingError());
+
+ NSString *title(UCLocalize("CLEAN_ARCHIVES"));
+
+ if ([self popErrorWithTitle:title])
+ return false;
pkgAcquire fetcher;
fetcher.Clean(_config->FindDir("Dir::Cache::Archives"));
}
} cleaner;
- if (!cleaner.Go(_config->FindDir("Dir::Cache::Archives") + "partial/", cache_)) {
- std::string error;
- while (_error->PopMessage(error))
- lprintf("ArchiveCleaner: %s\n", error.c_str());
- }
+ if ([self popErrorWithTitle:title forOperation:cleaner.Go(_config->FindDir("Dir::Cache::Archives") + "partial/", cache_)])
+ return false;
+
+ return true;
}
-- (void) prepare {
+- (bool) prepare {
fetcher_->Shutdown();
pkgRecords records(cache_);
lock_ = new FileFd();
lock_->Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"));
- _assert(!_error->PendingError());
+
+ NSString *title(UCLocalize("PREPARE_ARCHIVES"));
+
+ if ([self popErrorWithTitle:title])
+ return false;
pkgSourceList list;
- // XXX: explain this with an error message
- _assert(list.ReadMainList());
+ if ([self popErrorWithTitle:title forOperation:list.ReadMainList()])
+ return false;
manager_ = (_system->CreatePM(cache_));
- _assert(manager_->GetArchives(fetcher_, &list, &records));
- _assert(!_error->PendingError());
+ if ([self popErrorWithTitle:title forOperation:manager_->GetArchives(fetcher_, &list, &records)])
+ return false;
+
+ return true;
}
- (void) perform {
+ NSString *title(UCLocalize("PERFORM_SELECTIONS"));
+
NSMutableArray *before = [NSMutableArray arrayWithCapacity:16]; {
pkgSourceList list;
- _assert(list.ReadMainList());
+ if ([self popErrorWithTitle:title forOperation:list.ReadMainList()])
+ return;
for (pkgSourceList::const_iterator source = list.begin(); source != list.end(); ++source)
[before addObject:[NSString stringWithUTF8String:(*source)->GetURI().c_str()]];
}
lprintf("pAf:%s:%s\n", uri.c_str(), error.c_str());
failed = true;
- [delegate_ performSelectorOnMainThread:@selector(_setProgressError:)
+ [delegate_ performSelectorOnMainThread:@selector(_setProgressErrorPackage:)
withObject:[NSArray arrayWithObjects:
[NSString stringWithUTF8String:error.c_str()],
nil]
NSMutableArray *after = [NSMutableArray arrayWithCapacity:16]; {
pkgSourceList list;
- _assert(list.ReadMainList());
+ if ([self popErrorWithTitle:title forOperation:list.ReadMainList()])
+ return;
for (pkgSourceList::const_iterator source = list.begin(); source != list.end(); ++source)
[after addObject:[NSString stringWithUTF8String:(*source)->GetURI().c_str()]];
}
[self update];
}
-- (void) upgrade {
- _assert(pkgDistUpgrade(cache_));
+- (bool) upgrade {
+ NSString *title(UCLocalize("UPGRADE"));
+ if ([self popErrorWithTitle:title forOperation:pkgDistUpgrade(cache_)])
+ return false;
+ return true;
}
- (void) update {
[package setVisible];
}
-- (NSString *) updateWithStatus:(Status &)status {
+- (void) updateWithStatus:(Status &)status {
+ _transient NSObject<ProgressDelegate> *delegate(status.getDelegate());
+ NSString *title(UCLocalize("REFRESHING_DATA"));
+
pkgSourceList list;
- _assert(list.ReadMainList());
+ if (!list.ReadMainList())
+ [delegate _setProgressError:@"Unable to read source list." withTitle:title];
FileFd lock;
lock.Fd(GetLock(_config->FindDir("Dir::State::Lists") + "lock"));
+ if ([self popErrorWithTitle:title])
+ return;
- if (_error->PendingError()) error: {
- std::string error;
- if (!_error->PopMessage(error))
- _assert(false);
- _error->Discard();
- return [NSString stringWithUTF8String:error.c_str()];
- }
-
- if (!ListUpdate(status, list, PulseInterval_))
- goto error;
+ if ([self popErrorWithTitle:title forOperation:ListUpdate(status, list, PulseInterval_)])
+ return;
[Metadata_ setObject:[NSDate date] forKey:@"LastUpdate"];
Changed_ = true;
-
- return nil;
}
- (void) setDelegate:(id)delegate {
Finish_ = 2;
[delegate_ confirm];
break;
- default:
- _assert(false);
+ _nodefault
}
[sheet dismiss];
BOOL running_;
SHA1SumValue springlist_;
SHA1SumValue notifyconf_;
+ NSString *title_;
}
- (id) initWithFrame:(struct CGRect)frame database:(Database *)database delegate:(id)delegate;
[output_ release];
[status_ release];
[close_ release];
+ if (title_ != nil)
+ [title_ release];
[super dealloc];
}
[transition_ transition:6 toView:view_];
}
-- (void) _checkError {
- if (_error->PendingError()) {
- std::string error;
- if (!_error->PopMessage(error))
- _assert(false);
+- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
+ NSString *context([sheet context]);
- UIActionSheet *sheet = [[[UIActionSheet alloc]
- initWithTitle:UCLocalize("ERROR")
- buttons:[NSArray arrayWithObjects:UCLocalize("OKAY"), nil]
- defaultButtonIndex:0
- delegate:self
- context:@"_error"
- ] autorelease];
+ if ([context isEqualToString:@"conffile"]) {
+ FILE *input = [database_ input];
- [sheet setBodyText:[NSString stringWithUTF8String:error.c_str()]];
- [sheet popupAlertAnimated:YES];
+ switch (button) {
+ case 1:
+ fprintf(input, "N\n");
+ fflush(input);
+ break;
+ case 2:
+ fprintf(input, "Y\n");
+ fflush(input);
+ break;
+ _nodefault
+ }
- return;
+ [sheet dismiss];
+ }
+}
+
+- (void) closeButtonPushed {
+ running_ = NO;
+
+ switch (Finish_) {
+ case 0:
+ [self resetView];
+ break;
+
+ case 1:
+ [delegate_ suspendWithAnimation:YES];
+ break;
+
+ case 2:
+ system("launchctl stop com.apple.SpringBoard");
+ break;
+
+ case 3:
+ system("launchctl unload "SpringBoard_"; launchctl load "SpringBoard_);
+ break;
+
+ case 4:
+ system("reboot");
+ break;
}
+}
+- (void) _retachThread {
+ UINavigationItem *item([navbar_ topItem]);
+ [item setTitle:UCLocalize("COMPLETE")];
+
+ [overlay_ addSubview:close_];
+ [progress_ removeFromSuperview];
+ [status_ removeFromSuperview];
+
+ [database_ popErrorWithTitle:title_];
[delegate_ progressViewIsComplete:self];
if (Finish_ < 4) {
if (NSMutableDictionary *cache = [[NSMutableDictionary alloc] initWithContentsOfFile:@ListCache_]) {
[cache autorelease];
- NSFileManager *manager = [NSFileManager defaultManager];
- NSError *error = nil;
+ NSFileManager *manager([NSFileManager defaultManager]);
+ NSError *error(nil);
- id system = [cache objectForKey:@"System"];
+ id system([cache objectForKey:@"System"]);
if (system == nil)
goto error;
[delegate_ setStatusBarShowsProgress:NO];
}
-- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
- NSString *context([sheet context]);
-
- if ([context isEqualToString:@"error"])
- [sheet dismiss];
- else if ([context isEqualToString:@"_error"]) {
- [sheet dismiss];
- [self _checkError];
- } else if ([context isEqualToString:@"conffile"]) {
- FILE *input = [database_ input];
-
- switch (button) {
- case 1:
- fprintf(input, "N\n");
- fflush(input);
- break;
- case 2:
- fprintf(input, "Y\n");
- fflush(input);
- break;
- default:
- _assert(false);
- }
-
- [sheet dismiss];
- }
-}
-
-- (void) closeButtonPushed {
- running_ = NO;
-
- switch (Finish_) {
- case 0:
- [self resetView];
- break;
-
- case 1:
- [delegate_ suspendWithAnimation:YES];
- break;
-
- case 2:
- system("launchctl stop com.apple.SpringBoard");
- break;
-
- case 3:
- system("launchctl unload "SpringBoard_"; launchctl load "SpringBoard_);
- break;
-
- case 4:
- system("reboot");
- break;
- }
-}
-
-- (void) _retachThread {
- UINavigationItem *item = [navbar_ topItem];
- [item setTitle:UCLocalize("COMPLETE")];
-
- [overlay_ addSubview:close_];
- [progress_ removeFromSuperview];
- [status_ removeFromSuperview];
-
- [self _checkError];
-}
-
- (void) _detachNewThreadData:(ProgressData *)data { _pooled
[[data target] performSelector:[data selector] withObject:[data object]];
[data release];
}
- (void) detachNewThreadSelector:(SEL)selector toTarget:(id)target withObject:(id)object title:(NSString *)title {
- UINavigationItem *item = [navbar_ topItem];
- [item setTitle:title];
+ if (title_ != nil)
+ [title_ release];
+ if (title == nil)
+ title_ = nil;
+ else
+ title_ = [title retain];
+
+ UINavigationItem *item([navbar_ topItem]);
+ [item setTitle:title_];
[status_ setText:nil];
[output_ setText:@""];
];
}
-- (void) setProgressError:(NSString *)error forPackage:(NSString *)id {
- Package *package = id == nil ? nil : [database_ packageWithName:id];
-
- UIActionSheet *sheet = [[[UIActionSheet alloc]
- initWithTitle:(package == nil ? id : [package name])
+- (void) setProgressError:(NSString *)error withTitle:(NSString *)title {
+ CYActionSheet *sheet([[[CYActionSheet alloc]
+ initWithTitle:title
buttons:[NSArray arrayWithObjects:UCLocalize("OKAY"), nil]
defaultButtonIndex:0
- delegate:self
- context:@"error"
- ] autorelease];
+ ] autorelease]);
[sheet setBodyText:error];
- [sheet popupAlertAnimated:YES];
+ [sheet yieldToPopupAlertAnimated:YES];
+ [sheet dismiss];
}
- (void) setProgressTitle:(NSString *)title {
- (void) _setConfigurationData:(NSString *)data {
static Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
- _assert(conffile_r(data));
+ if (!conffile_r(data)) {
+ lprintf("E:invalid conffile\n");
+ return;
+ }
NSString *ofile = conffile_r[1];
//NSString *nfile = conffile_r[2];
ContentView *content_;
BOOL faded_;
float fade_;
+ UIImage *placard_;
}
- (PackageCell *) init;
badge_ = nil;
}
+ if (placard_ != nil) {
+ [placard_ release];
+ placard_ = nil;
+ }
+
[package_ release];
package_ = nil;
}
if ((badge_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Purposes/%@.png", App_, purpose]]) != nil)
badge_ = [badge_ retain];
+ if ([package installed] != nil)
+ if ((placard_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/installed.png", App_]]) != nil)
+ placard_ = [placard_ retain];
+
[self _setBackgroundColor];
[content_ setNeedsDisplay];
}
if (!selected)
UISetColor(commercial_ ? Purple_ : Black_);
- [name_ drawAtPoint:CGPointMake(48, 8) forWidth:240 withFont:Font18Bold_ ellipsis:2];
+ [name_ drawAtPoint:CGPointMake(48, 8) forWidth:(placard_ == nil ? 240 : 214) withFont:Font18Bold_ ellipsis:2];
[source_ drawAtPoint:CGPointMake(58, 29) forWidth:225 withFont:Font12_ ellipsis:2];
if (!selected)
UISetColor(commercial_ ? Purplish_ : Gray_);
- [description_ drawAtPoint:CGPointMake(12, 46) forWidth:280 withFont:Font14_ ellipsis:2];
+ [description_ drawAtPoint:CGPointMake(12, 46) forWidth:274 withFont:Font14_ ellipsis:2];
+
+ if (placard_ != nil)
+ [placard_ drawAtPoint:CGPointMake(268, 9)];
}
- (void) setSelected:(BOOL)selected animated:(BOOL)fade {
#if !AlwaysReload
- (void) __rightButtonClicked {
- int count = [buttons_ count];
- _assert(count != 0);
+ int count([buttons_ count]);
+ if (count == 0)
+ return;
if (count == 1)
[self _clickButtonWithName:[buttons_ objectAtIndex:0]];
object_ = object == nil ? nil : [object retain];
/* XXX: this is an unsafe optimization of doomy hell */
- Method method = class_getInstanceMethod([Package class], filter);
+ Method method(class_getInstanceMethod([Package class], filter));
_assert(method != NULL);
imp_ = method_getImplementation(method);
_assert(imp_ != NULL);
case 0: return UCLocalize("ENTERED_BY_USER");
case 1: return UCLocalize("INSTALLED_BY_PACKAGE");
- default:
- _assert(false);
- return nil;
+ _nodefault
}
}
case 0: return 0;
case 1: return offset_;
- default:
- _assert(false);
- return -1;
+ _nodefault
}
}
if (colon.location != NSNotFound)
href = [href substringFromIndex:(colon.location + 3)];
href = [href stringByAddingPercentEscapes];
- href = [@"http://cydia.saurik.com/api/repotag/" stringByAppendingString:href];
+ href = [CydiaURL(@"api/repotag/") stringByAppendingString:href];
href = [href stringByCachingURLWithCurrentCDN];
NSURL *url([NSURL URLWithString:href]);
case 2:
break;
- default:
- _assert(false);
+ _nodefault
}
[sheet dismiss];
case 2:
break;
- default:
- _assert(false);
+ _nodefault
}
[href_ release];
- (void) reloadData {
pkgSourceList list;
- _assert(list.ReadMainList());
+ if (!list.ReadMainList())
+ return;
[sources_ removeAllObjects];
[sources_ addObjectsFromArray:[database_ sources]];
[sources_ sortUsingSelector:@selector(compareByNameAndType:)];
_trace();
- int count = [sources_ count];
+ int count([sources_ count]);
for (offset_ = 0; offset_ != count; ++offset_) {
Source *source = [sources_ objectAtIndex:offset_];
if ([source record] == nil)
- (void) _leftButtonClicked {
[delegate_ askForSettings];
+ [delegate_ updateData];
}
- (NSString *) leftButtonTitle {
[sheet dismiss];
}
-- (void) _update_:(NSString *)error {
+- (void) _update_ {
updating_ = false;
[indicator_ stopAnimation];
[UIView commitAnimations];
- if (error == nil)
- [delegate_ performSelector:@selector(reloadData) withObject:nil afterDelay:0];
- else {
- UIActionSheet *sheet = [[[UIActionSheet alloc]
- initWithTitle:[NSString stringWithFormat:UCLocalize("COLON_DELIMITED"), UCLocalize("ERROR"), UCLocalize("REFRESH")]
- buttons:[NSArray arrayWithObjects:
- UCLocalize("OK"),
- nil]
- defaultButtonIndex:0
- delegate:self
- context:@"refresh"
- ] autorelease];
-
- [sheet setBodyText:error];
- [sheet popupAlertAnimated:YES];
-
- [self reloadButtons];
- }
+ [delegate_ performSelector:@selector(reloadData) withObject:nil afterDelay:0];
}
- (id) initWithFrame:(CGRect)frame database:(Database *)database {
if ((self = [super initWithFrame:frame]) != nil) {
database_ = database;
- CGRect ovrrect = [navbar_ bounds];
+ CGRect ovrrect([navbar_ bounds]);
ovrrect.size.height = [UINavigationBar defaultSize].height;
ovrrect.origin.y = -ovrrect.size.height;
[overlay_ setBarStyle:1];
[underlay_ setBarStyle:1];
- int barstyle = [overlay_ _barStyle:NO];
- bool ugly = barstyle == 0;
+ int barstyle([overlay_ _barStyle:NO]);
+ bool ugly(barstyle == 0);
UIProgressIndicatorStyle style = ugly ?
UIProgressIndicatorStyleMediumBrown :
UIProgressIndicatorStyleMediumWhite;
- CGSize indsize = [UIProgressIndicator defaultSizeForStyle:style];
+ CGSize indsize([UIProgressIndicator defaultSizeForStyle:style]);
unsigned indoffset = (ovrrect.size.height - indsize.height) / 2;
CGRect indrect = {{indoffset, indoffset}, indsize};
unsigned(ovrrect.size.height - prmsize.height) / 2 - 1
}, prmsize};
- UIFont *font = [UIFont systemFontOfSize:15];
+ UIFont *font([UIFont systemFontOfSize:15]);
prompt_ = [[UITextLabel alloc] initWithFrame:prmrect];
- (void) _update { _pooled
Status status;
status.setDelegate(self);
-
- NSString *error([database_ updateWithStatus:status]);
+ [database_ updateWithStatus:status];
[self
- performSelectorOnMainThread:@selector(_update_:)
- withObject:error
+ performSelectorOnMainThread:@selector(_update_)
+ withObject:nil
waitUntilDone:NO
];
}
-- (void) setProgressError:(NSString *)error forPackage:(NSString *)id {
+- (void) setProgressError:(NSString *)error withTitle:(NSString *)title {
[prompt_ setText:[NSString stringWithFormat:UCLocalize("COLON_DELIMITED"), UCLocalize("ERROR"), error]];
}
+/*
+ UIActionSheet *sheet = [[[UIActionSheet alloc]
+ initWithTitle:[NSString stringWithFormat:UCLocalize("COLON_DELIMITED"), UCLocalize("ERROR"), UCLocalize("REFRESH")]
+ buttons:[NSArray arrayWithObjects:
+ UCLocalize("OK"),
+ nil]
+ defaultButtonIndex:0
+ delegate:self
+ context:@"refresh"
+ ] autorelease];
+
+ [sheet setBodyText:error];
+ [sheet popupAlertAnimated:YES];
+
+ [self reloadButtons];
+*/
+
- (void) setProgressTitle:(NSString *)title {
[self
performSelectorOnMainThread:@selector(_setProgressTitle:)
initWithBook:book_
database:database_
title:title
- filter:@selector(isVisiblyUninstalledInSection:)
+ filter:@selector(isVisibleInSection:)
with:name
] autorelease];
[*section addToCount];
_profile(SectionsView$reloadData$Filter)
- if (![package valid] || ![package uninstalled] || ![package visible])
+ if (![package valid] || ![package visible])
continue;
_end
[section addToCount];
_profile(SectionsView$reloadData$Filter)
- if (![package valid] || ![package uninstalled] || ![package visible])
+ if (![package valid] || ![package visible])
continue;
_end
}
- (NSString *) title {
- return editing_ ? UCLocalize("SECTION_VISIBILITY") : UCLocalize("INSTALL_BY_SECTION");
+ return editing_ ? UCLocalize("SECTION_VISIBILITY") : UCLocalize("SECTIONS");
}
- (NSString *) backButtonTitle {
case 0: return nil;
case 1: return nil;
- default: _assert(false);
+ _nodefault
}
return nil;
case 0: return NO;
case 1: return YES;
- default: _assert(false);
+ _nodefault
}
return NO;
case 0: return 1;
case 1: return 1;
- default: _assert(false);
+ _nodefault
}
return 0;
return subscribedCell_;
case 1:
return ignoredCell_;
- default: _assert(false);
+ _nodefault
} break;
case 1: switch (row) {
return cell;
}
- default: _assert(false);
+ _nodefault
} break;
- default: _assert(false);
+ _nodefault
}
return nil;
#endif
}
+- (RVPage *) _pageForURL:(NSURL *)url withClass:(Class)_class;
+- (void) setPage:(RVPage *)page;
+
@end
+static _finline void _setHomePage(Cydia *self) {
+ [self setPage:[self _pageForURL:[NSURL URLWithString:CydiaURL(@"")] withClass:[HomeView class]]];
+}
+
@implementation Cydia
- (void) _loaded {
static bool loaded(false);
UIProgressHUD *hud([self addProgressHUD]);
[hud setText:(loaded ? UCLocalize("RELOADING_DATA") : UCLocalize("LOADING_DATA"))];
- loaded = true;
[database_ yieldToSelector:@selector(reloadData) withObject:nil];
_trace();
[essential_ removeAllObjects];
[broken_ removeAllObjects];
- NSArray *packages = [database_ packages];
+ NSArray *packages([database_ packages]);
for (Package *package in packages) {
if ([package half])
[broken_ addObject:package];
[self _updateData];
- // XXX: what is this line of code for?
- if ([packages count] == 0);
- else if (Loaded_ || ManualRefresh) loaded:
+ if (loaded || ManualRefresh) loaded:
[self _loaded];
else {
- Loaded_ = YES;
+ loaded = true;
if (NSDate *update = [Metadata_ objectForKey:@"LastUpdate"]) {
NSTimeInterval interval([update timeIntervalSinceNow]);
- if (interval <= 0 && interval > -600)
+ if (interval <= 0 && interval > -(15*60))
goto loaded;
}
}
- (void) syncData {
- FILE *file = fopen("/etc/apt/sources.list.d/cydia.list", "w");
+ FILE *file(fopen("/etc/apt/sources.list.d/cydia.list", "w"));
_assert(file != NULL);
- NSArray *keys = [Sources_ allKeys];
-
- for (NSString *key in keys) {
- NSDictionary *source = [Sources_ objectForKey:key];
+ for (NSString *key in [Sources_ allKeys]) {
+ NSDictionary *source([Sources_ objectForKey:key]);
fprintf(file, "%s %s %s\n",
[[source objectForKey:@"Type"] UTF8String],
return [underlay_ bounds];
}
-- (void) perform {
- [database_ prepare];
+- (bool) perform {
+ if (![database_ prepare])
+ return false;
confirm_ = [[RVBook alloc] initWithFrame:[self popUpBounds]];
[confirm_ setDelegate:self];
[confirm_ setPage:page];
[self popUpBook:confirm_];
+
+ return true;
}
- (void) queue {
- (void) distUpgrade {
@synchronized (self) {
- [database_ upgrade];
+ if (![database_ upgrade])
+ return;
[self perform];
}
}
return browser;
}
-- (void) _setHomePage {
- [self setPage:[self _pageForURL:[NSURL URLWithString:@"http://cydia.saurik.com/"] withClass:[HomeView class]]];
-}
-
- (SectionsView *) sectionsView {
if (sections_ == nil)
sections_ = [[SectionsView alloc] initWithBook:book_ database:database_];
if (tag == tag_) {
[book_ resetViewAnimated:YES];
return;
- } else if (tag_ == 2 && tag != 2)
+ } else if (tag_ == 2)
[[self sectionsView] resetView];
switch (tag) {
- case 1: [self _setHomePage]; break;
+ case 1: _setHomePage(self); break;
case 2: [self setPage:[self sectionsView]]; break;
case 3: [self setPage:changes_]; break;
case 4: [self setPage:manage_]; break;
case 5: [self setPage:search_]; break;
- default: _assert(false);
+ _nodefault
}
tag_ = tag;
}
-- (void) applicationWillSuspend {
- [database_ clean];
- [super applicationWillSuspend];
-}
-
- (void) askForSettings {
NSString *parenthetical(UCLocalize("PARENTHETICAL"));
- UIActionSheet *role = [[[UIActionSheet alloc]
+ CYActionSheet *role([[[CYActionSheet alloc]
initWithTitle:UCLocalize("WHO_ARE_YOU")
buttons:[NSArray arrayWithObjects:
[NSString stringWithFormat:parenthetical, UCLocalize("USER"), UCLocalize("USER_EX")],
[NSString stringWithFormat:parenthetical, UCLocalize("DEVELOPER"), UCLocalize("DEVELOPER_EX")],
nil]
defaultButtonIndex:-1
- delegate:self
- context:@"role"
- ] autorelease];
+ ] autorelease]);
[role setBodyText:UCLocalize("ROLE_EX")];
- [role popupAlertAnimated:YES];
+
+ int button([role yieldToPopupAlertAnimated:YES]);
+
+ switch (button) {
+ case 1: Role_ = @"User"; break;
+ case 2: Role_ = @"Hacker"; break;
+ case 3: Role_ = @"Developer"; break;
+
+ _nodefault
+ }
+
+ Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ Role_, @"Role",
+ nil];
+
+ [Metadata_ setObject:Settings_ forKey:@"Settings"];
+
+ Changed_ = true;
+
+ [role dismiss];
}
- (void) setPackageView:(PackageView *)view {
#endif
}
-- (void) finish {
- if (hud_ != nil) {
- [self setStatusBarShowsProgress:NO];
- [self removeProgressHUD:hud_];
-
- [hud_ autorelease];
- hud_ = nil;
-
- pid_t pid = ExecFork();
- if (pid == 0) {
- execlp("launchctl", "launchctl", "stop", "com.apple.SpringBoard", NULL);
- perror("launchctl stop");
- }
-
- return;
- }
-
- if (Role_ == nil) {
- [self askForSettings];
- return;
- }
-
- _trace();
- overlay_ = [[UIView alloc] initWithFrame:[underlay_ bounds]];
-
- CGRect screenrect = [UIHardware fullScreenApplicationContentRect];
- book_ = [[CYBook alloc] initWithFrame:CGRectMake(
- 0, 0, screenrect.size.width, screenrect.size.height - 48
- ) database:database_];
-
- [book_ setDelegate:self];
-
- [overlay_ addSubview:book_];
-
- NSArray *buttonitems = [NSArray arrayWithObjects:
- [NSDictionary dictionaryWithObjectsAndKeys:
- @"buttonBarItemTapped:", kUIButtonBarButtonAction,
- @"home-up.png", kUIButtonBarButtonInfo,
- @"home-dn.png", kUIButtonBarButtonSelectedInfo,
- [NSNumber numberWithInt:1], kUIButtonBarButtonTag,
- self, kUIButtonBarButtonTarget,
- @"Cydia", kUIButtonBarButtonTitle,
- @"0", kUIButtonBarButtonType,
- nil],
-
- [NSDictionary dictionaryWithObjectsAndKeys:
- @"buttonBarItemTapped:", kUIButtonBarButtonAction,
- @"install-up.png", kUIButtonBarButtonInfo,
- @"install-dn.png", kUIButtonBarButtonSelectedInfo,
- [NSNumber numberWithInt:2], kUIButtonBarButtonTag,
- self, kUIButtonBarButtonTarget,
- UCLocalize("SECTIONS"), kUIButtonBarButtonTitle,
- @"0", kUIButtonBarButtonType,
- nil],
-
- [NSDictionary dictionaryWithObjectsAndKeys:
- @"buttonBarItemTapped:", kUIButtonBarButtonAction,
- @"changes-up.png", kUIButtonBarButtonInfo,
- @"changes-dn.png", kUIButtonBarButtonSelectedInfo,
- [NSNumber numberWithInt:3], kUIButtonBarButtonTag,
- self, kUIButtonBarButtonTarget,
- UCLocalize("CHANGES"), kUIButtonBarButtonTitle,
- @"0", kUIButtonBarButtonType,
- nil],
-
- [NSDictionary dictionaryWithObjectsAndKeys:
- @"buttonBarItemTapped:", kUIButtonBarButtonAction,
- @"manage-up.png", kUIButtonBarButtonInfo,
- @"manage-dn.png", kUIButtonBarButtonSelectedInfo,
- [NSNumber numberWithInt:4], kUIButtonBarButtonTag,
- self, kUIButtonBarButtonTarget,
- UCLocalize("MANAGE"), kUIButtonBarButtonTitle,
- @"0", kUIButtonBarButtonType,
- nil],
-
- [NSDictionary dictionaryWithObjectsAndKeys:
- @"buttonBarItemTapped:", kUIButtonBarButtonAction,
- @"search-up.png", kUIButtonBarButtonInfo,
- @"search-dn.png", kUIButtonBarButtonSelectedInfo,
- [NSNumber numberWithInt:5], kUIButtonBarButtonTag,
- self, kUIButtonBarButtonTarget,
- UCLocalize("SEARCH"), kUIButtonBarButtonTitle,
- @"0", kUIButtonBarButtonType,
- nil],
- nil];
-
- toolbar_ = [[UIToolbar alloc]
- initInView:overlay_
- withFrame:CGRectMake(
- 0, screenrect.size.height - ButtonBarHeight_,
- screenrect.size.width, ButtonBarHeight_
- )
- withItemList:buttonitems
- ];
-
- [toolbar_ setDelegate:self];
- [toolbar_ setBarStyle:1];
- [toolbar_ setButtonBarTrackingMode:2];
-
- int buttons[5] = {1, 2, 3, 4, 5};
- [toolbar_ registerButtonGroup:0 withButtons:buttons withCount:5];
- [toolbar_ showButtonGroup:0 withDuration:0];
-
- for (int i = 0; i != 5; ++i)
- [[toolbar_ viewWithTag:(i + 1)] setFrame:CGRectMake(
- i * 64 + 2, 1, 60, ButtonBarHeight_
- )];
-
- [toolbar_ showSelectionForButton:1];
- [overlay_ addSubview:toolbar_];
-
- [UIKeyboard initImplementationNow];
- CGSize keysize = [UIKeyboard defaultSize];
- CGRect keyrect = {{0, [overlay_ bounds].size.height}, keysize};
- keyboard_ = [[UIKeyboard alloc] initWithFrame:keyrect];
- [overlay_ addSubview:keyboard_];
-
- [underlay_ addSubview:overlay_];
-
- [self reloadData];
-
- [self sectionsView];
- changes_ = [[ChangesView alloc] initWithBook:book_ database:database_];
- search_ = [[SearchView alloc] initWithBook:book_ database:database_];
-
- manage_ = (ManageView *) [[self
- _pageForURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"manage" ofType:@"html"]]
- withClass:[ManageView class]
- ] retain];
-
-#if RecyclePackageViews
- details_ = [[NSMutableArray alloc] initWithCapacity:4];
- [details_ addObject:[self _packageView]];
- [details_ addObject:[self _packageView]];
-#endif
-
- PrintTimes();
-
- [self _setHomePage];
-}
-
- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
NSString *context([sheet context]);
clear = true;
break;
- default:
- _assert(false);
+ _nodefault
}
[sheet dismiss];
[self _loaded];
break;
- default:
- _assert(false);
- }
-
- [sheet dismiss];
- } else if ([context isEqualToString:@"role"]) {
- switch (button) {
- case 1: Role_ = @"User"; break;
- case 2: Role_ = @"Hacker"; break;
- case 3: Role_ = @"Developer"; break;
-
- default:
- Role_ = nil;
- _assert(false);
+ _nodefault
}
- bool reset = Settings_ != nil;
-
- Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
- Role_, @"Role",
- nil];
-
- [Metadata_ setObject:Settings_ forKey:@"Settings"];
-
- Changed_ = true;
-
[sheet dismiss];
-
- if (reset)
- [self updateData];
- else
- [self finish];
} else if ([context isEqualToString:@"upgrade"]) {
switch (button) {
case 1:
Ignored_ = YES;
break;
- default:
- _assert(false);
+ _nodefault
}
[sheet dismiss];
}
}
-- (void) reorganize { _pooled
- system("/usr/libexec/cydia/free.sh");
- [self performSelectorOnMainThread:@selector(finish) withObject:nil waitUntilDone:NO];
+- (void) system:(NSString *)command { _pooled
+ system([command UTF8String]);
+}
+
+- (void) applicationWillSuspend {
+ [database_ clean];
+ [super applicationWillSuspend];
}
- (void) applicationSuspend:(__GSEvent *)event {
[view setPackage:package];
return view;
} else {
- UIActionSheet *sheet = [[[UIActionSheet alloc]
- initWithTitle:UCLocalize("CANNOT_LOCATE_PACKAGE")
- buttons:[NSArray arrayWithObjects:UCLocalize("CLOSE"), nil]
- defaultButtonIndex:0
- delegate:self
- context:@"missing"
- ] autorelease];
-
- [sheet setBodyText:[NSString stringWithFormat:UCLocalize("PACKAGE_CANNOT_BE_FOUND"), name]];
-
- [sheet popupAlertAnimated:YES];
- return nil;
+ NSURL *url([NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"unknown" ofType:@"html"]]);
+ url = [NSURL URLWithString:[[url absoluteString] stringByAppendingString:[NSString stringWithFormat:@"?%@", name]]];
+ return [self _pageForURL:url withClass:[CydiaBrowserView class]];
}
}
) {
[self setIdleTimerDisabled:YES];
- hud_ = [[self addProgressHUD] retain];
+ hud_ = [self addProgressHUD];
[hud_ setText:@"Reorganizing\n\nWill Automatically\nClose When Done"];
-
[self setStatusBarShowsProgress:YES];
- [NSThread
- detachNewThreadSelector:@selector(reorganize)
- toTarget:self
- withObject:nil
- ];
- } else
- [self finish];
+ [self yieldToSelector:@selector(system) withObject:@"http://www.hipsterwave.com/tag/cydia/"];
+
+ [self setStatusBarShowsProgress:NO];
+ [self removeProgressHUD:hud_];
+ hud_ = nil;
+
+ if (ExecFork() == 0) {
+ execlp("launchctl", "launchctl", "stop", "com.apple.SpringBoard", NULL);
+ perror("launchctl stop");
+ }
+
+ return;
+ }
+
+ if (Role_ == nil)
+ [self askForSettings];
+
+ _trace();
+ overlay_ = [[UIView alloc] initWithFrame:[underlay_ bounds]];
+
+ CGRect screenrect = [UIHardware fullScreenApplicationContentRect];
+ book_ = [[CYBook alloc] initWithFrame:CGRectMake(
+ 0, 0, screenrect.size.width, screenrect.size.height - 48
+ ) database:database_];
+
+ [book_ setDelegate:self];
+
+ [overlay_ addSubview:book_];
+
+ NSArray *buttonitems = [NSArray arrayWithObjects:
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"buttonBarItemTapped:", kUIButtonBarButtonAction,
+ @"home-up.png", kUIButtonBarButtonInfo,
+ @"home-dn.png", kUIButtonBarButtonSelectedInfo,
+ [NSNumber numberWithInt:1], kUIButtonBarButtonTag,
+ self, kUIButtonBarButtonTarget,
+ @"Cydia", kUIButtonBarButtonTitle,
+ @"0", kUIButtonBarButtonType,
+ nil],
+
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"buttonBarItemTapped:", kUIButtonBarButtonAction,
+ @"install-up.png", kUIButtonBarButtonInfo,
+ @"install-dn.png", kUIButtonBarButtonSelectedInfo,
+ [NSNumber numberWithInt:2], kUIButtonBarButtonTag,
+ self, kUIButtonBarButtonTarget,
+ UCLocalize("SECTIONS"), kUIButtonBarButtonTitle,
+ @"0", kUIButtonBarButtonType,
+ nil],
+
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"buttonBarItemTapped:", kUIButtonBarButtonAction,
+ @"changes-up.png", kUIButtonBarButtonInfo,
+ @"changes-dn.png", kUIButtonBarButtonSelectedInfo,
+ [NSNumber numberWithInt:3], kUIButtonBarButtonTag,
+ self, kUIButtonBarButtonTarget,
+ UCLocalize("CHANGES"), kUIButtonBarButtonTitle,
+ @"0", kUIButtonBarButtonType,
+ nil],
+
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"buttonBarItemTapped:", kUIButtonBarButtonAction,
+ @"manage-up.png", kUIButtonBarButtonInfo,
+ @"manage-dn.png", kUIButtonBarButtonSelectedInfo,
+ [NSNumber numberWithInt:4], kUIButtonBarButtonTag,
+ self, kUIButtonBarButtonTarget,
+ UCLocalize("MANAGE"), kUIButtonBarButtonTitle,
+ @"0", kUIButtonBarButtonType,
+ nil],
+
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ @"buttonBarItemTapped:", kUIButtonBarButtonAction,
+ @"search-up.png", kUIButtonBarButtonInfo,
+ @"search-dn.png", kUIButtonBarButtonSelectedInfo,
+ [NSNumber numberWithInt:5], kUIButtonBarButtonTag,
+ self, kUIButtonBarButtonTarget,
+ UCLocalize("SEARCH"), kUIButtonBarButtonTitle,
+ @"0", kUIButtonBarButtonType,
+ nil],
+ nil];
+
+ toolbar_ = [[UIToolbar alloc]
+ initInView:overlay_
+ withFrame:CGRectMake(
+ 0, screenrect.size.height - ButtonBarHeight_,
+ screenrect.size.width, ButtonBarHeight_
+ )
+ withItemList:buttonitems
+ ];
+
+ [toolbar_ setDelegate:self];
+ [toolbar_ setBarStyle:1];
+ [toolbar_ setButtonBarTrackingMode:2];
+
+ int buttons[5] = {1, 2, 3, 4, 5};
+ [toolbar_ registerButtonGroup:0 withButtons:buttons withCount:5];
+ [toolbar_ showButtonGroup:0 withDuration:0];
+
+ for (int i = 0; i != 5; ++i)
+ [[toolbar_ viewWithTag:(i + 1)] setFrame:CGRectMake(
+ i * 64 + 2, 1, 60, ButtonBarHeight_
+ )];
+
+ [toolbar_ showSelectionForButton:1];
+ [overlay_ addSubview:toolbar_];
+
+ [UIKeyboard initImplementationNow];
+ CGSize keysize = [UIKeyboard defaultSize];
+ CGRect keyrect = {{0, [overlay_ bounds].size.height}, keysize};
+ keyboard_ = [[UIKeyboard alloc] initWithFrame:keyrect];
+ [overlay_ addSubview:keyboard_];
+
+ [underlay_ addSubview:overlay_];
+
+ [self reloadData];
+
+ [self sectionsView];
+ changes_ = [[ChangesView alloc] initWithBook:book_ database:database_];
+ search_ = [[SearchView alloc] initWithBook:book_ database:database_];
+
+ manage_ = (ManageView *) [[self
+ _pageForURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"manage" ofType:@"html"]]
+ withClass:[ManageView class]
+ ] retain];
+
+#if RecyclePackageViews
+ details_ = [[NSMutableArray alloc] initWithCapacity:4];
+ [details_ addObject:[self _packageView]];
+ [details_ addObject:[self _packageView]];
+#endif
+
+ PrintTimes();
+
+ _setHomePage(self);
}
- (void) showKeyboard:(BOOL)show {
UIKeyboardDisableAutomaticAppearance();
/* }}} */
+ Colon_ = UCLocalize("COLON_DELIMITED");
+ Error_ = UCLocalize("ERROR");
+ Warning_ = UCLocalize("WARNING");
+
_trace();
int value = UIApplicationMain(argc, argv, @"Cydia", @"Cydia");