#include "Menes/Menes.h"
#include "CyteKit/PerlCompatibleRegEx.hpp"
+#include "CyteKit/TableViewCell.h"
#include "CyteKit/WebScriptObject-Cyte.h"
#include "CyteKit/WebViewController.h"
#include "CyteKit/stringWithUTF8Bytes.h"
static const NSStringCompareOptions LaxCompareOptions_ = NSNumericSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch | NSCaseInsensitiveSearch;
static const CFStringCompareFlags LaxCompareFlags_ = kCFCompareCaseInsensitive | kCFCompareNonliteral | kCFCompareLocalized | kCFCompareNumerically | kCFCompareWidthInsensitive | kCFCompareForcedOrdering;
-/* Radix Sort {{{ */
-typedef uint32_t (*SKRadixFunction)(id, void *);
-
-@interface NSMutableArray (Radix)
-- (void) radixSortUsingFunction:(SKRadixFunction)function withContext:(void *)argument;
-@end
-
-struct RadixItem_ {
- size_t index;
- uint32_t key;
-};
-
-@implementation NSMutableArray (Radix)
-
-- (void) radixSortUsingFunction:(SKRadixFunction)function withContext:(void *)argument {
- size_t count([self count]);
- struct RadixItem_ *swap(new RadixItem_[count * 2]);
-
- for (size_t i(0); i != count; ++i) {
- RadixItem_ &item(swap[i]);
- item.index = i;
-
- id object([self objectAtIndex:i]);
- item.key = function(object, argument);
- }
-
- struct RadixItem_ *lhs(swap), *rhs(swap + count);
-
- static const size_t width = 32;
- static const size_t bits = 11;
- static const size_t slots = 1 << bits;
- static const size_t passes = (width + (bits - 1)) / bits;
-
- size_t *hist(new size_t[slots]);
-
- for (size_t pass(0); pass != passes; ++pass) {
- memset(hist, 0, sizeof(size_t) * slots);
-
- for (size_t i(0); i != count; ++i) {
- uint32_t key(lhs[i].key);
- key >>= pass * bits;
- key &= _not(uint32_t) >> width - bits;
- ++hist[key];
- }
-
- size_t offset(0);
- for (size_t i(0); i != slots; ++i) {
- size_t local(offset);
- offset += hist[i];
- hist[i] = local;
- }
-
- for (size_t i(0); i != count; ++i) {
- uint32_t key(lhs[i].key);
- key >>= pass * bits;
- key &= _not(uint32_t) >> width - bits;
- rhs[hist[key]++] = lhs[i];
- }
-
- RadixItem_ *tmp(lhs);
- lhs = rhs;
- rhs = tmp;
- }
-
- delete [] hist;
-
- const void **values(new const void *[count]);
- for (size_t i(0); i != count; ++i)
- values[i] = [self objectAtIndex:lhs[i].index];
- CFArrayReplaceValues((CFMutableArrayRef) self, CFRangeMake(0, count), values, count);
- delete [] values;
-
- delete [] swap;
-}
-
-@end
-/* }}} */
/* Insertion Sort {{{ */
CFIndex SKBSearch_(const void *element, CFIndex elementSize, const void *list, CFIndex count, CFComparatorFunction comparator, void *context) {
@end
/* }}} */
-@interface NSInvocation (Cydia)
-+ (NSInvocation *) invocationWithSelector:(SEL)selector forTarget:(id)target;
-@end
-
-@implementation NSInvocation (Cydia)
-
-+ (NSInvocation *) invocationWithSelector:(SEL)selector forTarget:(id)target {
- NSInvocation *invocation([NSInvocation invocationWithMethodSignature:[target methodSignatureForSelector:selector]]);
- [invocation setTarget:target];
- [invocation setSelector:selector];
- return invocation;
-}
-
-@end
-
NSUInteger DOMNodeList$countByEnumeratingWithState$objects$count$(DOMNodeList *self, SEL sel, NSFastEnumerationState *state, id *objects, NSUInteger count) {
size_t length([self length] - state->state);
if (length <= 0)
/* Mime Addresses {{{ */
@interface Address : NSObject {
- NSString *name_;
- NSString *address_;
+ _H<NSString> name_;
+ _H<NSString> address_;
}
- (NSString *) name;
@implementation Address
-- (void) dealloc {
- [name_ release];
- if (address_ != nil)
- [address_ release];
- [super dealloc];
-}
-
- (NSString *) name {
return name_;
}
}
- (void) setAddress:(NSString *)address {
- if (address_ != nil)
- [address_ autorelease];
- if (address == nil)
- address_ = nil;
- else
- address_ = [address retain];
+ address_ = address;
}
+ (Address *) addressWithString:(NSString *)string {
static Pcre address_r("^\"?(.*)\"? <([^>]*)>$");
if (address_r(data, size)) {
- name_ = [address_r[1] retain];
- address_ = [address_r[2] retain];
+ name_ = address_r[1];
+ address_ = address_r[2];
} else {
- name_ = [string retain];
+ name_ = string;
address_ = nil;
}
} return self;
static BOOL Advanced_;
static BOOL Ignored_;
-static UIFont *Font12_;
-static UIFont *Font12Bold_;
-static UIFont *Font14_;
-static UIFont *Font18Bold_;
-static UIFont *Font22Bold_;
+static _H<UIFont> Font12_;
+static _H<UIFont> Font12Bold_;
+static _H<UIFont> Font14_;
+static _H<UIFont> Font18Bold_;
+static _H<UIFont> Font22Bold_;
static const char *Machine_ = NULL;
static NSString *System_ = nil;
static NSString *SerialNumber_ = nil;
static NSString *ChipID_ = nil;
+static NSString *BBSNum_ = nil;
static _H<NSString> Token_;
static NSString *UniqueID_ = nil;
static NSString *PLMN_ = nil;
static CGFloat ScreenScale_;
static NSString *Idiom_;
-static NSMutableDictionary *SessionData_;
-static NSObject *HostConfig_;
-static NSMutableSet *BridgedHosts_;
-static NSMutableSet *PipelinedHosts_;
+static _H<NSMutableDictionary> SessionData_;
+static _H<NSObject> HostConfig_;
+static _H<NSMutableSet> BridgedHosts_;
+static _H<NSMutableSet> PipelinedHosts_;
static NSString *kCydiaProgressEventTypeError = @"Error";
static NSString *kCydiaProgressEventTypeInformation = @"Information";
return hidden == nil || ![hidden boolValue];
}
+static NSObject *CYIOGetValue(const char *path, NSString *property) {
+ io_registry_entry_t entry(IORegistryEntryFromPath(kIOMasterPortDefault, path));
+ if (entry == MACH_PORT_NULL)
+ return nil;
+
+ CFTypeRef value(IORegistryEntryCreateCFProperty(entry, (CFStringRef) property, kCFAllocatorDefault, 0));
+ IOObjectRelease(entry);
+
+ if (value == NULL)
+ return nil;
+ return [(id) value autorelease];
+}
+
+static NSString *CYHex(NSData *data, bool reverse = false) {
+ if (data == nil)
+ return nil;
+
+ size_t length([data length]);
+ uint8_t bytes[length];
+ [data getBytes:bytes];
+
+ char string[length * 2 + 1];
+ for (size_t i(0); i != length; ++i)
+ sprintf(string + i * 2, "%.2x", bytes[reverse ? length - i - 1 : i]);
+
+ return [NSString stringWithUTF8String:string];
+}
+
@class Cydia;
/* Delegate Prototypes {{{ */
pkgSourceList *list_;
SourceMap sourceMap_;
- NSMutableArray *sourceList_;
+ _H<NSMutableArray> sourceList_;
CFMutableArrayRef packages_;
authority_ = nil;
}
-- (void) dealloc {
- // XXX: this is a very inefficient way to call these deconstructors
- [self _clear];
- [super dealloc];
-}
-
+ (NSArray *) _attributeKeys {
return [NSArray arrayWithObjects:
@"distribution",
/* }}} */
/* CydiaOperation Class {{{ */
@interface CydiaOperation : NSObject {
- NSString *operator_;
- NSString *value_;
+ _H<NSString> operator_;
+ _H<NSString> value_;
}
- (NSString *) operator;
@implementation CydiaOperation
-- (void) dealloc {
- [operator_ release];
- [value_ release];
- [super dealloc];
-}
-
- (id) initWithOperator:(const char *)_operator value:(const char *)value {
if ((self = [super init]) != nil) {
- operator_ = [[NSString alloc] initWithUTF8String:_operator];
- value_ = [[NSString alloc] initWithUTF8String:value];
+ operator_ = [NSString stringWithUTF8String:_operator];
+ value_ = [NSString stringWithUTF8String:value];
} return self;
}
/* }}} */
/* CydiaClause Class {{{ */
@interface CydiaClause : NSObject {
- NSString *package_;
- CydiaOperation *version_;
+ _H<NSString> package_;
+ _H<CydiaOperation> version_;
}
- (NSString *) package;
@implementation CydiaClause
-- (void) dealloc {
- [package_ release];
- [version_ release];
- [super dealloc];
-}
-
- (id) initWithIterator:(pkgCache::DepIterator &)dep {
if ((self = [super init]) != nil) {
- package_ = [[NSString alloc] initWithUTF8String:dep.TargetPkg().Name()];
+ package_ = [NSString stringWithUTF8String:dep.TargetPkg().Name()];
if (const char *version = dep.TargetVer())
- version_ = [[CydiaOperation alloc] initWithOperator:dep.CompType() value:version];
+ version_ = [[[CydiaOperation alloc] initWithOperator:dep.CompType() value:version] autorelease];
else
- version_ = [[NSNull null] retain];
+ version_ = (id) [NSNull null];
} return self;
}
/* }}} */
/* CydiaRelation Class {{{ */
@interface CydiaRelation : NSObject {
- NSString *relationship_;
- NSMutableArray *clauses_;
+ _H<NSString> relationship_;
+ _H<NSMutableArray> clauses_;
}
- (NSString *) relationship;
@implementation CydiaRelation
-- (void) dealloc {
- [relationship_ release];
- [clauses_ release];
- [super dealloc];
-}
-
- (id) initWithIterator:(pkgCache::DepIterator &)dep {
if ((self = [super init]) != nil) {
- relationship_ = [[NSString alloc] initWithUTF8String:dep.DepType()];
- clauses_ = [[NSMutableArray alloc] initWithCapacity:8];
+ relationship_ = [NSString stringWithUTF8String:dep.DepType()];
+ clauses_ = [NSMutableArray arrayWithCapacity:8];
pkgCache::DepIterator start;
pkgCache::DepIterator end;
const char *section_;
_transient NSString *section$_;
- Source *source_;
+ _H<Source> source_;
PackageValue *metadata_;
ParsedPackage *parsed_;
- NSMutableArray *tags_;
+ _H<NSMutableArray> tags_;
}
- (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database;
- (void) dealloc {
if (parsed_ != NULL)
delete parsed_;
- if (source_ != nil)
- [source_ release];
- if (tags_ != nil)
- [tags_ release];
[super dealloc];
}
_profile(Package$initWithVersion$Tags)
pkgCache::TagIterator tag(iterator.TagList());
if (!tag.end()) {
- tags_ = [[NSMutableArray alloc] initWithCapacity:8];
+ tags_ = [NSMutableArray arrayWithCapacity:8];
do {
const char *name(tag.Name());
[tags_ addObject:[(NSString *)CYStringCreate(name) autorelease]];
if ([database_ era] != era_ || file_.end())
source_ = (Source *) [NSNull null];
else
- source_ = [([database_ getSource:file_.File()] ?: (Source *) [NSNull null]) retain];
+ source_ = [database_ getSource:file_.File()] ?: (Source *) [NSNull null];
}
}
}
- (NSString *) primaryPurpose {
- for (NSString *tag in tags_)
+ for (NSString *tag in (NSArray *) tags_)
if ([tag hasPrefix:@"purpose::"])
return [tag substringFromIndex:9];
return nil;
- (NSArray *) purposes {
NSMutableArray *purposes([NSMutableArray arrayWithCapacity:2]);
- for (NSString *tag in tags_)
+ for (NSString *tag in (NSArray *) tags_)
if ([tag hasPrefix:@"purpose::"])
[purposes addObject:[tag substringFromIndex:9]];
return [purposes count] == 0 ? nil : purposes;
/* }}} */
/* Section Class {{{ */
@interface Section : NSObject {
- NSString *name_;
+ _H<NSString> name_;
unichar index_;
size_t row_;
size_t count_;
- NSString *localized_;
+ _H<NSString> localized_;
}
- (NSComparisonResult) compareByLocalized:(Section *)section;
@implementation Section
-- (void) dealloc {
- [name_ release];
- if (localized_ != nil)
- [localized_ release];
- [super dealloc];
-}
-
- (NSComparisonResult) compareByLocalized:(Section *)section {
NSString *lhs(localized_);
NSString *rhs([section localized]);
- (Section *) initWithName:(NSString *)name localized:(NSString *)localized {
if ((self = [self initWithName:name localize:NO]) != nil) {
if (localized != nil)
- localized_ = [localized retain];
+ localized_ = localized;
} return self;
}
- (Section *) initWithName:(NSString *)name row:(size_t)row localize:(BOOL)localize {
if ((self = [super init]) != nil) {
- name_ = [name retain];
+ name_ = name;
index_ = '\0';
row_ = row;
if (localize)
- localized_ = [LocalizeSection(name_) retain];
+ localized_ = LocalizeSection(name_);
} return self;
}
/* XXX: localize the index thingees */
- (Section *) initWithIndex:(unichar)index row:(size_t)row {
if ((self = [super init]) != nil) {
- name_ = [[NSString stringWithCharacters:&index length:1] retain];
+ name_ = [NSString stringWithCharacters:&index length:1];
index_ = index;
row_ = row;
} return self;
static NSString *Error_;
static NSString *Warning_;
+class CydiaLogCleaner :
+ public pkgArchiveCleaner
+{
+ protected:
+ virtual void Erase(const char *File, std::string Pkg, std::string Ver, struct stat &St) {
+ unlink(File);
+ }
+};
+
/* Database Implementation {{{ */
@implementation Database
+ (Database *) sharedInstance {
- static Database *instance;
+ static _H<Database> instance;
if (instance == nil)
- instance = [[Database alloc] init];
+ instance = [[[Database alloc] init] autorelease];
return instance;
}
- (void) dealloc {
// XXX: actually implement this thing
_assert(false);
- [sourceList_ release];
[self releasePackages];
apr_pool_destroy(pool_);
NSRecycleZone(zone_);
capacity += 1024;
packages_ = CFArrayCreateMutable(kCFAllocatorDefault, capacity, NULL);
- sourceList_ = [[NSMutableArray alloc] initWithCapacity:16];
+ sourceList_ = [NSMutableArray arrayWithCapacity:16];
int fds[2];
{
/*std::vector<Package *> packages;
packages.reserve(std::max(10000U, [packages_ count] + 1000));
- [packages_ release];
packages_ = nil;*/
_trace();
for (pkgCache::PkgIterator iterator = cache_->PkgBegin(); !iterator.end(); ++iterator)
if (Package *package = [Package packageWithIterator:iterator withZone:zone_ inPool:pool_ database:self])
//packages.push_back(package);
- CFArrayAppendValue(packages_, [package retain]);
+ CFArrayAppendValue(packages_, CFRetain(package));
_trace();
packages_ = [[NSArray alloc] initWithObjects:&packages.front() count:packages.size()];
_trace();*/
- [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<SKRadixFunction>(&PackagePrefixRadix) withContext:reinterpret_cast<void *>(16)];
- [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<SKRadixFunction>(&PackagePrefixRadix) withContext:reinterpret_cast<void *>(4)];
- [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<SKRadixFunction>(&PackagePrefixRadix) withContext:reinterpret_cast<void *>(0)];
+ [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<MenesRadixSortFunction>(&PackagePrefixRadix) withContext:reinterpret_cast<void *>(16)];
+ [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<MenesRadixSortFunction>(&PackagePrefixRadix) withContext:reinterpret_cast<void *>(4)];
+ [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<MenesRadixSortFunction>(&PackagePrefixRadix) withContext:reinterpret_cast<void *>(0)];
/*_trace();
PrintTimes();
pkgAcquire fetcher;
fetcher.Clean(_config->FindDir("Dir::Cache::Archives"));
- class LogCleaner :
- public pkgArchiveCleaner
- {
- protected:
- virtual void Erase(const char *File, std::string Pkg, std::string Ver, struct stat &St) {
- unlink(File);
- }
- } cleaner;
-
+ CydiaLogCleaner cleaner;
if ([self popErrorWithTitle:title forOperation:cleaner.Go(_config->FindDir("Dir::Cache::Archives") + "partial/", cache_)])
return false;
bool success(ListUpdate(status, list, PulseInterval_));
if (status.WasCancelled())
_error->Discard();
- else
+ else {
[self popErrorWithTitle:title forOperation:success];
+ [Metadata_ setObject:[NSDate date] forKey:@"LastUpdate"];
+ Changed_ = true;
+ }
[delegate_ performSelectorOnMainThread:@selector(releaseNetworkActivityIndicator) withObject:nil waitUntilDone:YES];
-
- [Metadata_ setObject:[NSDate date] forKey:@"LastUpdate"];
- Changed_ = true;
}
- (void) setDelegate:(NSObject<DatabaseDelegate> *)delegate {
@end
/* }}} */
-static NSMutableSet *Diversions_;
+static _H<NSMutableSet> Diversions_;
@interface Diversion : NSObject {
Pcre pattern_;
divert:
NSString *href([url absoluteString]);
- for (Diversion *diversion in Diversions_)
+ for (Diversion *diversion in (id) Diversions_)
if (NSString *diverted = [diversion divert:href]) {
#if !ForRelease
NSLog(@"div: %@", diverted);
@end
@interface CydiaObject : NSObject {
- id indirect_;
+ _H<IndirectDelegate> indirect_;
_transient id delegate_;
}
@end
@interface CydiaWebViewController : CyteWebViewController {
- CydiaObject *cydia_;
+ _H<CydiaObject> cydia_;
}
+ (void) addDiversion:(Diversion *)diversion;
/* Web Scripting {{{ */
@implementation CydiaObject
-- (void) dealloc {
- [indirect_ release];
- [super dealloc];
-}
-
- (id) initWithDelegate:(IndirectDelegate *)indirect {
if ((self = [super init]) != nil) {
- indirect_ = [indirect retain];
+ indirect_ = indirect;
} return self;
}
+ (NSArray *) _attributeKeys {
return [NSArray arrayWithObjects:
+ @"bbsnum",
@"device",
@"ecid",
@"firmware",
return (id) PLMN_ ?: [NSNull null];
}
+- (NSString *) bbsnum {
+ return (id) BBSNum_ ?: [NSNull null];
+}
+
- (NSString *) ecid {
return (id) ChipID_ ?: [NSNull null];
}
return @"getKernelString";
else if (selector == @selector(getInstalledPackages))
return @"getInstalledPackages";
+ else if (selector == @selector(getIORegistryEntry::))
+ return @"getIORegistryEntry";
else if (selector == @selector(getLocaleIdentifier))
return @"getLocaleIdentifier";
else if (selector == @selector(getPreferredLanguages))
return [NSString stringWithCString:value];
}
+- (NSObject *) getIORegistryEntry:(NSString *)path :(NSString *)entry {
+ NSObject *value(CYIOGetValue([path UTF8String], entry));
+
+ if (value != nil)
+ if ([value isKindOfClass:[NSData class]])
+ value = CYHex((NSData *) value);
+
+ return value;
+}
+
- (id) getSessionValue:(NSString *)key {
@synchronized (SessionData_) {
return [SessionData_ objectForKey:key];
/* Cydia Browser Controller {{{ */
@implementation CydiaWebViewController
-- (void) dealloc {
- [cydia_ release];
- [super dealloc];
-}
-
- (NSURL *) navigationURL {
- return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://url/%@", [[request_ URL] absoluteString]]];
+ return request_ == nil ? nil : [NSURL URLWithString:[NSString stringWithFormat:@"cydia://url/%@", [[request_ URL] absoluteString]]];
}
+ (void) initialize {
- Diversions_ = [[NSMutableSet alloc] initWithCapacity:0];
+ Diversions_ = [NSMutableSet setWithCapacity:0];
}
+ (void) addDiversion:(Diversion *)diversion {
- (id) init {
if ((self = [super initWithWidth:0 ofClass:[CydiaWebViewController class]]) != nil) {
- cydia_ = [[CydiaObject alloc] initWithDelegate:indirect_];
+ cydia_ = [[[CydiaObject alloc] initWithDelegate:indirect_] autorelease];
WebView *webview([[webview_ _documentView] webView]);
@interface ConfirmationController : CydiaWebViewController {
_transient Database *database_;
- UIAlertView *essential_;
+ _H<UIAlertView> essential_;
- NSDictionary *changes_;
- NSMutableArray *issues_;
- NSDictionary *sizes_;
+ _H<NSDictionary> changes_;
+ _H<NSMutableArray> issues_;
+ _H<NSDictionary> sizes_;
BOOL substrate_;
}
@implementation ConfirmationController
-- (void) dealloc {
- [changes_ release];
- [issues_ release];
- [sizes_ release];
-
- if (essential_ != nil)
- [essential_ release];
-
- [super dealloc];
-}
-
- (void) complete {
if (substrate_)
RestartSubstrate_ = true;
[super webView:view didClearWindowObject:window forFrame:frame];
[window setValue:[[NSDictionary dictionaryWithObjectsAndKeys:
- changes_, @"changes",
- issues_, @"issues",
- sizes_, @"sizes",
+ (id) changes_, @"changes",
+ (id) issues_, @"issues",
+ (id) sizes_, @"sizes",
self, @"queue",
nil] Cydia$webScriptObjectInContext:window] forKey:@"cydiaConfirm"];
}
NSArray *packages([database_ packages]);
pkgDepCache::Policy *policy([database_ policy]);
- issues_ = [[NSMutableArray arrayWithCapacity:4] retain];
+ issues_ = [NSMutableArray arrayWithCapacity:4];
for (Package *package in packages) {
pkgCache::PkgIterator iterator([package iterator]);
else if (Advanced_) {
NSString *parenthetical(UCLocalize("PARENTHETICAL"));
- essential_ = [[UIAlertView alloc]
+ essential_ = [[[UIAlertView alloc]
initWithTitle:UCLocalize("REMOVING_ESSENTIALS")
message:UCLocalize("REMOVING_ESSENTIALS_EX")
delegate:self
otherButtonTitles:
[NSString stringWithFormat:parenthetical, UCLocalize("FORCE_REMOVAL"), UCLocalize("UNSAFE")],
nil
- ];
+ ] autorelease];
[essential_ setContext:@"remove"];
} else {
- essential_ = [[UIAlertView alloc]
+ essential_ = [[[UIAlertView alloc]
initWithTitle:UCLocalize("UNABLE_TO_COMPLY")
message:UCLocalize("UNABLE_TO_COMPLY_EX")
delegate:self
cancelButtonTitle:UCLocalize("OKAY")
otherButtonTitles:nil
- ];
+ ] autorelease];
[essential_ setContext:@"unable"];
}
- changes_ = [[NSDictionary alloc] initWithObjectsAndKeys:
+ changes_ = [NSDictionary dictionaryWithObjectsAndKeys:
installs, @"installs",
reinstalls, @"reinstalls",
upgrades, @"upgrades",
removes, @"removes",
nil];
- sizes_ = [[NSDictionary alloc] initWithObjectsAndKeys:
+ sizes_ = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:[database_ fetcher].FetchNeeded()], @"downloading",
[NSNumber numberWithInteger:[database_ fetcher].PartialPresent()], @"resuming",
nil];
[self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/#!/confirm/", UI_]]];
-
- [[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
- initWithTitle:UCLocalize("CANCEL")
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(cancelButtonClicked)
- ] autorelease]];
} return self;
}
+- (UIBarButtonItem *) leftButton {
+ return [[[UIBarButtonItem alloc]
+ initWithTitle:UCLocalize("CANCEL")
+ style:UIBarButtonItemStylePlain
+ target:self
+ action:@selector(cancelButtonClicked)
+ ] autorelease];
+}
+
#if !AlwaysReload
- (void) applyRightButton {
if ([issues_ count] == 0 && ![self isLoading])
[super dealloc];
}
-- (void) updateCancel {
- [[self navigationItem] setLeftBarButtonItem:(cancel_ == 1 ? [[[UIBarButtonItem alloc]
+- (UIBarButtonItem *) leftButton {
+ return cancel_ == 1 ? [[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("CANCEL")
style:UIBarButtonItemStylePlain
target:self
action:@selector(cancel)
- ] autorelease] : nil)];
+ ] autorelease] : nil;
+}
+
+- (void) updateCancel {
+ [super applyLeftButton];
}
- (id) initWithDatabase:(Database *)database delegate:(id)delegate {
@end
/* }}} */
-/* Cell Content View {{{ */
-@protocol ContentDelegate
-- (void) drawContentRect:(CGRect)rect;
-@end
-
-@interface ContentView : UIView {
- _transient id<ContentDelegate> delegate_;
-}
-
-@end
-
-@implementation ContentView
-
-- (id) initWithFrame:(CGRect)frame {
- if ((self = [super initWithFrame:frame]) != nil) {
- [self setNeedsDisplayOnBoundsChange:YES];
- } return self;
-}
-
-- (void) setDelegate:(id<ContentDelegate>)delegate {
- delegate_ = delegate;
-}
-
-- (void) drawRect:(CGRect)rect {
- [super drawRect:rect];
- [delegate_ drawContentRect:rect];
-}
-
-@end
-/* }}} */
-/* Cydia TableView Cell {{{ */
-@interface CYTableViewCell : UITableViewCell {
- ContentView *content_;
- bool highlighted_;
-}
-
-@end
-
-@implementation CYTableViewCell
-
-- (void) dealloc {
- [content_ release];
- [super dealloc];
-}
-
-- (void) _updateHighlightColorsForView:(id)view highlighted:(BOOL)highlighted {
- //NSLog(@"_updateHighlightColorsForView:%@ highlighted:%s [content_=%@]", view, highlighted ? "YES" : "NO", content_);
-
- if (view == content_) {
- //NSLog(@"_updateHighlightColorsForView:content_ highlighted:%s", highlighted ? "YES" : "NO", content_);
- highlighted_ = highlighted;
- }
-
- [super _updateHighlightColorsForView:view highlighted:highlighted];
-}
-
-- (void) setSelected:(BOOL)selected animated:(BOOL)animated {
- //NSLog(@"setSelected:%s animated:%s", selected ? "YES" : "NO", animated ? "YES" : "NO");
- highlighted_ = selected;
-
- [super setSelected:selected animated:animated];
- [content_ setNeedsDisplay];
-}
-
-@end
-/* }}} */
-
/* Package Cell {{{ */
@interface PackageCell : CYTableViewCell <
- ContentDelegate
+ CyteTableViewCellDelegate
> {
- UIImage *icon_;
- NSString *name_;
- NSString *description_;
+ _H<UIImage> icon_;
+ _H<NSString> name_;
+ _H<NSString> description_;
bool commercial_;
- NSString *source_;
- UIImage *badge_;
- Package *package_;
- UIImage *placard_;
+ _H<NSString> source_;
+ _H<UIImage> badge_;
+ _H<Package> package_;
+ _H<UIImage> placard_;
+ bool summarized_;
}
- (PackageCell *) init;
-- (void) setPackage:(Package *)package;
+- (void) setPackage:(Package *)package asSummary:(bool)summary;
- (void) drawContentRect:(CGRect)rect;
@implementation PackageCell
-- (void) clearPackage {
- if (icon_ != nil) {
- [icon_ release];
- icon_ = nil;
- }
-
- if (name_ != nil) {
- [name_ release];
- name_ = nil;
- }
-
- if (description_ != nil) {
- [description_ release];
- description_ = nil;
- }
-
- if (source_ != nil) {
- [source_ release];
- source_ = nil;
- }
-
- if (badge_ != nil) {
- [badge_ release];
- badge_ = nil;
- }
-
- if (placard_ != nil) {
- [placard_ release];
- placard_ = nil;
- }
-
- [package_ release];
- package_ = nil;
-}
-
-- (void) dealloc {
- [self clearPackage];
- [super dealloc];
-}
-
- (PackageCell *) init {
CGRect frame(CGRectMake(0, 0, 320, 74));
if ((self = [super initWithFrame:frame reuseIdentifier:@"Package"]) != nil) {
UIView *content([self contentView]);
CGRect bounds([content bounds]);
- content_ = [[ContentView alloc] initWithFrame:bounds];
+ content_ = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
[content_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[content addSubview:content_];
}
- (NSString *) accessibilityLabel {
- return [NSString stringWithFormat:UCLocalize("COLON_DELIMITED"), name_, description_];
+ return [NSString stringWithFormat:UCLocalize("COLON_DELIMITED"), (id) name_, (id) description_];
}
-- (void) setPackage:(Package *)package {
- [self clearPackage];
+- (void) setPackage:(Package *)package asSummary:(bool)summary {
+ summarized_ = summary;
+
+ icon_ = nil;
+ name_ = nil;
+ description_ = nil;
+ source_ = nil;
+ badge_ = nil;
+ placard_ = nil;
+ package_ = nil;
+
[package parse];
Source *source = [package source];
- icon_ = [[package icon] retain];
- name_ = [[package name] retain];
+ icon_ = [package icon];
+ name_ = [package name];
if (IsWildcat_)
description_ = [package longDescription];
if (description_ == nil)
description_ = [package shortDescription];
- if (description_ != nil)
- description_ = [description_ retain];
commercial_ = [package isCommercial];
- package_ = [package retain];
+ package_ = package;
NSString *label = nil;
bool trusted = false;
from = [NSString stringWithFormat:UCLocalize("PARENTHETICAL"), from, section];
}
- from = [NSString stringWithFormat:UCLocalize("FROM"), from];
- source_ = [from retain];
+ source_ = [NSString stringWithFormat:UCLocalize("FROM"), from];
if (NSString *purpose = [package primaryPurpose])
- if ((badge_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Purposes/%@.png", App_, purpose]]) != nil)
- badge_ = [badge_ retain];
+ badge_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Purposes/%@.png", App_, purpose]];
UIColor *color;
NSString *placard;
[content_ setBackgroundColor:color];
if (placard != nil)
- if ((placard_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/%@.png", App_, placard]]) != nil)
- placard_ = [placard_ retain];
+ placard_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/%@.png", App_, placard]];
[self setNeedsDisplay];
[content_ setNeedsDisplay];
}
-- (void) drawContentRect:(CGRect)rect {
+- (void) drawSummaryContentRect:(CGRect)rect {
bool highlighted(highlighted_);
float width([self bounds].size.width);
-#if 0
- CGContextRef context(UIGraphicsGetCurrentContext());
- [([[self selectedBackgroundView] superview] != nil ? [UIColor clearColor] : [self backgroundColor]) set];
- CGContextFillRect(context, rect);
-#endif
+ if (icon_ != nil) {
+ CGRect rect;
+ rect.size = [(UIImage *) icon_ size];
+
+ rect.size.width /= 4;
+ rect.size.height /= 4;
+
+ rect.origin.x = 14 - rect.size.width / 4;
+ rect.origin.y = 14 - rect.size.height / 4;
+
+ [icon_ drawInRect:rect];
+ }
+
+ if (badge_ != nil) {
+ CGRect rect;
+ rect.size = [(UIImage *) badge_ size];
+
+ rect.size.width /= 4;
+ rect.size.height /= 4;
+
+ rect.origin.x = 20 - rect.size.width / 4;
+ rect.origin.y = 20 - rect.size.height / 4;
+
+ [badge_ drawInRect:rect];
+ }
+
+ if (highlighted)
+ UISetColor(White_);
+
+ if (!highlighted)
+ UISetColor(commercial_ ? Purple_ : Black_);
+ [name_ drawAtPoint:CGPointMake(36, 8) forWidth:(width - (placard_ == nil ? 68 : 94)) withFont:Font18Bold_ lineBreakMode:UILineBreakModeTailTruncation];
+
+ if (placard_ != nil)
+ [placard_ drawAtPoint:CGPointMake(width - 52, 9)];
+}
+
+- (void) drawNormalContentRect:(CGRect)rect {
+ bool highlighted(highlighted_);
+ float width([self bounds].size.width);
if (icon_ != nil) {
CGRect rect;
- rect.size = [icon_ size];
+ rect.size = [(UIImage *) icon_ size];
rect.size.width /= 2;
rect.size.height /= 2;
if (badge_ != nil) {
CGRect rect;
- rect.size = [badge_ size];
+ rect.size = [(UIImage *) badge_ size];
rect.size.width /= 2;
rect.size.height /= 2;
[placard_ drawAtPoint:CGPointMake(width - 52, 9)];
}
+- (void) drawContentRect:(CGRect)rect {
+ if (summarized_)
+ [self drawSummaryContentRect:rect];
+ else
+ [self drawNormalContentRect:rect];
+}
+
@end
/* }}} */
/* Section Cell {{{ */
@interface SectionCell : CYTableViewCell <
- ContentDelegate
+ CyteTableViewCellDelegate
> {
- NSString *basic_;
- NSString *section_;
- NSString *name_;
- NSString *count_;
- UIImage *icon_;
- UISwitch *switch_;
+ _H<NSString> basic_;
+ _H<NSString> section_;
+ _H<NSString> name_;
+ _H<NSString> count_;
+ _H<UIImage> icon_;
+ _H<UISwitch> switch_;
BOOL editing_;
}
@implementation SectionCell
-- (void) clearSection {
- if (basic_ != nil) {
- [basic_ release];
- basic_ = nil;
- }
-
- if (section_ != nil) {
- [section_ release];
- section_ = nil;
- }
-
- if (name_ != nil) {
- [name_ release];
- name_ = nil;
- }
-
- if (count_ != nil) {
- [count_ release];
- count_ = nil;
- }
-}
-
-- (void) dealloc {
- [self clearSection];
- [icon_ release];
- [switch_ release];
- [super dealloc];
-}
-
- (id) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) != nil) {
- icon_ = [[UIImage applicationImageNamed:@"folder.png"] retain];
- switch_ = [[UISwitch alloc] initWithFrame:CGRectMake(218, 9, 60, 25)];
+ icon_ = [UIImage applicationImageNamed:@"folder.png"];
+ switch_ = [[[UISwitch alloc] initWithFrame:CGRectMake(218, 9, 60, 25)] autorelease];
[switch_ addTarget:self action:@selector(onSwitch:) forEvents:UIControlEventValueChanged];
UIView *content([self contentView]);
CGRect bounds([content bounds]);
- content_ = [[ContentView alloc] initWithFrame:bounds];
+ content_ = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
[content_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[content addSubview:content_];
[content_ setBackgroundColor:[UIColor whiteColor]];
editing_ = editing;
}
- [self clearSection];
+ basic_ = nil;
+ section_ = nil;
+ name_ = nil;
+ count_ = nil;
if (section == nil) {
- name_ = [UCLocalize("ALL_PACKAGES") retain];
+ name_ = UCLocalize("ALL_PACKAGES");
count_ = nil;
} else {
basic_ = [section name];
- if (basic_ != nil)
- basic_ = [basic_ retain];
-
section_ = [section localized];
- if (section_ != nil)
- section_ = [section_ retain];
- name_ = [(section_ == nil || [section_ length] == 0 ? UCLocalize("NO_SECTION") : section_) retain];
- count_ = [[NSString stringWithFormat:@"%d", [section count]] retain];
+ name_ = section_ == nil || [section_ length] == 0 ? UCLocalize("NO_SECTION") : (NSString *) section_;
+ count_ = [NSString stringWithFormat:@"%d", [section count]];
if (editing_)
[switch_ setOn:(isSectionVisible(basic_) ? 1 : 0) animated:NO];
UITableViewDelegate
> {
_transient Database *database_;
- Package *package_;
- NSString *name_;
- NSMutableArray *files_;
- UITableView *list_;
+ _H<Package> package_;
+ _H<NSString> name_;
+ _H<NSMutableArray> files_;
+ _H<UITableView> list_;
}
- (id) initWithDatabase:(Database *)database;
@implementation FileTable
- (void) dealloc {
- [self releaseSubviews];
-
- [package_ release];
- [name_ release];
- [files_ release];
-
+ [(UITableView *) list_ setDataSource:nil];
+ [list_ setDelegate:nil];
[super dealloc];
}
- (void) loadView {
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
- list_ = [[UITableView alloc] initWithFrame:[[self view] bounds]];
+ list_ = [[[UITableView alloc] initWithFrame:[[self view] bounds]] autorelease];
[list_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[list_ setRowHeight:24.0f];
- [list_ setDataSource:self];
+ [(UITableView *) list_ setDataSource:self];
[list_ setDelegate:self];
[[self view] addSubview:list_];
}
}
- (void) releaseSubviews {
- [list_ release];
list_ = nil;
}
if ((self = [super init]) != nil) {
database_ = database;
- files_ = [[NSMutableArray arrayWithCapacity:32] retain];
+ files_ = [NSMutableArray arrayWithCapacity:32];
} return self;
}
- (void) setPackage:(Package *)package {
- if (package_ != nil) {
- [package_ autorelease];
- package_ = nil;
- }
-
- if (name_ != nil) {
- [name_ release];
- name_ = nil;
- }
+ package_ = nil;
+ name_ = nil;
[files_ removeAllObjects];
if (package != nil) {
- package_ = [package retain];
- name_ = [[package id] retain];
+ package_ = package;
+ name_ = [package id];
if (NSArray *files = [package files])
[files_ addObjectsFromArray:files];
> {
_transient Database *database_;
unsigned era_;
- NSMutableArray *packages_;
- NSMutableArray *sections_;
- UITableView *list_;
- NSMutableArray *index_;
- NSMutableDictionary *indices_;
- NSString *title_;
+ _H<NSMutableArray> packages_;
+ _H<NSMutableArray> sections_;
+ _H<UITableView> list_;
+ _H<NSMutableArray> index_;
+ _H<NSMutableDictionary> indices_;
+ _H<NSString> title_;
}
- (id) initWithDatabase:(Database *)database title:(NSString *)title;
- (void) setDelegate:(id)delegate;
- (void) resetCursor;
+- (void) clearData;
@end
@implementation PackageListController
- (void) dealloc {
- [packages_ release];
- [sections_ release];
- [list_ release];
- [index_ release];
- [indices_ release];
- [title_ release];
-
+ [list_ setDataSource:nil];
+ [list_ setDelegate:nil];
[super dealloc];
}
+- (bool) isSummarized {
+ return false;
+}
+
- (void) deselectWithAnimation:(BOOL)animated {
[list_ deselectRowAtIndexPath:[list_ indexPathForSelectedRow] animated:animated];
}
PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]);
if (cell == nil)
cell = [[[PackageCell alloc] init] autorelease];
- [cell setPackage:[self packageAtIndexPath:path]];
+ [cell setPackage:[self packageAtIndexPath:path] asSummary:[self isSummarized]];
return cell;
}
}
- (NSArray *) sectionIndexTitlesForTableView:(UITableView *)tableView {
- // XXX: is 20 the most optimal number here?
- return [packages_ count] > 20 ? index_ : nil;
+ if ([self isSummarized])
+ return nil;
+
+ return index_;
}
- (NSInteger) tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
return index;
}
+- (void) updateHeight {
+ [list_ setRowHeight:([self isSummarized] ? 38 : 73)];
+}
+
- (id) initWithDatabase:(Database *)database title:(NSString *)title {
if ((self = [super init]) != nil) {
database_ = database;
#if TryIndexedCollation
if ([[self class] hasIndexedCollation])
- index_ = [[[objc_getClass("UILocalizedIndexedCollation") currentCollation] sectionIndexTitles] retain]
+ index_ = [[objc_getClass("UILocalizedIndexedCollation") currentCollation] sectionIndexTitles];
else
#endif
- index_ = [[NSMutableArray alloc] initWithCapacity:32];
+ index_ = [NSMutableArray arrayWithCapacity:32];
- indices_ = [[NSMutableDictionary alloc] initWithCapacity:32];
+ indices_ = [NSMutableDictionary dictionaryWithCapacity:32];
- packages_ = [[NSMutableArray arrayWithCapacity:16] retain];
- sections_ = [[NSMutableArray arrayWithCapacity:16] retain];
+ packages_ = [NSMutableArray arrayWithCapacity:16];
+ sections_ = [NSMutableArray arrayWithCapacity:16];
- list_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStylePlain];
+ list_ = [[[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStylePlain] autorelease];
[list_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
- [list_ setRowHeight:73];
[[self view] addSubview:list_];
- [list_ setDataSource:self];
+ // XXX: is 20 the most optimal number here?
+ [list_ setSectionIndexMinimumDisplayRowCount:20];
+
+ [(UITableView *) list_ setDataSource:self];
[list_ setDelegate:self];
+
+ [self updateHeight];
} return self;
}
return true;
}
-- (void) reloadData {
- [super reloadData];
-
- era_ = [database_ era];
- NSArray *packages = [database_ packages];
+- (bool) shouldYield {
+ return false;
+}
+- (void) _reloadPackages:(NSArray *)packages {
[packages_ removeAllObjects];
[sections_ removeAllObjects];
if ([self hasPackage:package])
[packages_ addObject:package];
_end
+}
+
+- (void) _reloadData {
+ era_ = [database_ era];
+ NSArray *packages = [database_ packages];
+
+ if ([self shouldYield]) {
+ UIProgressHUD *hud([delegate_ addProgressHUD]);
+ [hud setText:UCLocalize("LOADING")];
+ [self yieldToSelector:@selector(_reloadPackages:) withObject:packages];
+ [delegate_ removeProgressHUD:hud];
+ } else {
+ [self _reloadPackages:packages];
+ }
[indices_ removeAllObjects];
{
[index_ removeAllObjects];
+ bool summary([self isSummarized]);
+ if (summary) {
+ section = [[[Section alloc] initWithName:nil localize:false] autorelease];
+ [sections_ addObject:section];
+ }
+
_profile(PackageTable$reloadData$Section)
for (size_t offset(0), end([packages_ count]); offset != end; ++offset) {
Package *package;
index = [package index];
_end
- if (section == nil || [section index] != index) {
+ if (!summary && (section == nil || [section index] != index)) {
_profile(PackageTable$reloadData$Section$Allocate)
section = [[[Section alloc] initWithIndex:index row:offset] autorelease];
_end
_end
}
+ [self updateHeight];
+
_profile(PackageTable$reloadData$List)
+ [(UITableView *) list_ setDataSource:self];
[list_ reloadData];
_end
}
+- (void) reloadData {
+ [super reloadData];
+ [self performSelector:@selector(_reloadData) withObject:nil afterDelay:0];
+}
+
- (void) resetCursor {
- [list_ scrollRectToVisible:CGRectMake(0, 0, 0, 0) animated:NO];
+ [list_ scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
+}
+
+- (void) clearData {
+ [self updateHeight];
+
+ [list_ setDataSource:nil];
+ [list_ reloadData];
+
+ [self resetCursor];
}
@end
@interface FilteredPackageListController : PackageListController {
SEL filter_;
IMP imp_;
- id object_;
+ _H<NSObject> object_;
}
- (void) setObject:(id)object;
- (void) setObject:(id)object forFilter:(SEL)filter;
+- (SEL) filter;
+- (void) setFilter:(SEL)filter;
+
- (id) initWithDatabase:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object;
@end
@implementation FilteredPackageListController
-- (void) dealloc {
- if (object_ != nil)
- [object_ release];
- [super dealloc];
+- (SEL) filter {
+ return filter_;
}
- (void) setFilter:(SEL)filter {
}
- (void) setObject:(id)object {
- if (object_ != nil)
- [object_ release];
- if (object == nil)
- object_ = nil;
- else
- object_ = [object retain];
+ object_ = object;
}
- (void) setObject:(id)object forFilter:(SEL)filter {
[alert show];
}
-- (void) viewDidLoad {
- [super viewDidLoad];
-
- [[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
+- (UIBarButtonItem *) leftButton {
+ return [[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("ABOUT")
style:UIBarButtonItemStylePlain
target:self
action:@selector(aboutButtonClicked)
- ] autorelease]];
+ ] autorelease];
}
- (void) unloadData {
return [NSURL URLWithString:@"cydia://manage"];
}
-- (void) viewDidLoad {
- [super viewDidLoad];
-
- [[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
+- (UIBarButtonItem *) leftButton {
+ return [[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("SETTINGS")
style:UIBarButtonItemStylePlain
target:self
action:@selector(settingsButtonClicked)
- ] autorelease]];
-
- [self queueStatusDidChange];
+ ] autorelease];
}
- (void) settingsButtonClicked {
[delegate_ showSettings];
}
-#if !AlwaysReload
- (void) queueButtonClicked {
[delegate_ queue];
}
-- (void) applyLoadingTitle {
- // Disable "Loading" title.
-}
-
-- (void) applyRightButton {
- // Disable right button.
+- (UIBarButtonItem *) customButton {
+ return Queuing_ ? [[[UIBarButtonItem alloc]
+ initWithTitle:UCLocalize("QUEUE")
+ style:UIBarButtonItemStyleDone
+ target:self
+ action:@selector(queueButtonClicked)
+ ] autorelease] : [super customButton];
}
-#endif
- (void) queueStatusDidChange {
-#if !AlwaysReload
- if (!IsWildcat_ && Queuing_) {
- [[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc]
- initWithTitle:UCLocalize("QUEUE")
- style:UIBarButtonItemStyleDone
- target:self
- action:@selector(queueButtonClicked)
- ] autorelease]];
- } else {
- [[self navigationItem] setRightBarButtonItem:nil];
- }
-#endif
+ [self applyRightButton];
}
- (bool) isLoading {
- // Never show as loading.
- return false;
+ return !Queuing_ && [super isLoading];
}
@end
/* Refresh Bar {{{ */
@interface RefreshBar : UINavigationBar {
- UIProgressIndicator *indicator_;
- UITextLabel *prompt_;
- UIProgressBar *progress_;
- UINavigationButton *cancel_;
+ _H<UIProgressIndicator> indicator_;
+ _H<UITextLabel> prompt_;
+ _H<UIProgressBar> progress_;
+ _H<UINavigationButton> cancel_;
}
@end
@implementation RefreshBar
-- (void) dealloc {
- [indicator_ release];
- [prompt_ release];
- [progress_ release];
- [cancel_ release];
- [super dealloc];
-}
-
- (void) positionViews {
CGRect frame = [cancel_ frame];
frame.size = [cancel_ sizeThatFits:frame.size];
UIProgressIndicatorStyleMediumBrown :
UIProgressIndicatorStyleMediumWhite;
- indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectZero];
- [indicator_ setStyle:style];
+ indicator_ = [[[UIProgressIndicator alloc] initWithFrame:CGRectZero] autorelease];
+ [(UIProgressIndicator *) indicator_ setStyle:style];
[indicator_ startAnimation];
[self addSubview:indicator_];
- prompt_ = [[UITextLabel alloc] initWithFrame:CGRectZero];
+ prompt_ = [[[UITextLabel alloc] initWithFrame:CGRectZero] autorelease];
[prompt_ setColor:[UIColor colorWithCGColor:(ugly ? Blueish_ : Off_)]];
[prompt_ setBackgroundColor:[UIColor clearColor]];
[prompt_ setFont:[UIFont systemFontOfSize:15]];
[self addSubview:prompt_];
- progress_ = [[UIProgressBar alloc] initWithFrame:CGRectZero];
+ progress_ = [[[UIProgressBar alloc] initWithFrame:CGRectZero] autorelease];
[progress_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin];
- [progress_ setStyle:0];
+ [(UIProgressBar *) progress_ setStyle:0];
[self addSubview:progress_];
- cancel_ = [[UINavigationButton alloc] initWithTitle:UCLocalize("CANCEL") style:UINavigationButtonStyleHighlighted];
+ cancel_ = [[[UINavigationButton alloc] initWithTitle:UCLocalize("CANCEL") style:UINavigationButtonStyleHighlighted] autorelease];
[cancel_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
[cancel_ addTarget:delegate action:@selector(cancelPressed) forControlEvents:UIControlEventTouchUpInside];
[cancel_ setBarStyle:barstyle];
ProgressDelegate
> {
_transient Database *database_;
- RefreshBar *refreshbar_;
+ _H<RefreshBar> refreshbar_;
bool dropped_;
bool updating_;
// XXX: ok, "updatedelegate_"?...
_transient NSObject<CydiaDelegate> *updatedelegate_;
- id root_;
- UIViewController *remembered_;
+ _H<UIViewController> remembered_;
_transient UIViewController *transient_;
}
NSMutableArray *controllers = [[self viewControllers] mutableCopy];
if (transient != nil) {
if (transient_ == nil)
- remembered_ = [[controllers objectAtIndex:0] retain];
+ remembered_ = [controllers objectAtIndex:0];
transient_ = transient;
[transient_ setTabBarItem:[remembered_ tabBarItem]];
[controllers replaceObjectAtIndex:0 withObject:transient_];
[remembered_ setTabBarItem:[transient_ tabBarItem]];
transient_ = transient;
[controllers replaceObjectAtIndex:0 withObject:remembered_];
- [remembered_ release];
remembered_ = nil;
[self setViewControllers:controllers];
[self revealTabBarSelection];
}
- (void) dealloc {
- [refreshbar_ release];
+ [refreshbar_ setDelegate:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
[[self view] setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
- refreshbar_ = [[RefreshBar alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, [UINavigationBar defaultSize].height) delegate:self];
+ refreshbar_ = [[[RefreshBar alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, [UINavigationBar defaultSize].height) delegate:self] autorelease];
} return self;
}
}
- (void) beginUpdate {
- [refreshbar_ start];
+ [(RefreshBar *) refreshbar_ start];
[self dropBar:YES];
[updatedelegate_ retainNetworkActivityIndicator];
// Ensure bar has the proper width for our view, it might have changed
barframe.size.width = viewframe.size.width;
[refreshbar_ setFrame:barframe];
-
- // XXX: fix Apple's layout bug
- [[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
- (void) raiseBar:(BOOL)animated {
if (animated)
[UIView commitAnimations];
-
- // XXX: fix Apple's layout bug
- // SRK [[self selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
-#if 0
-- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
- // XXX: fix Apple's layout bug
- // SRK [[self selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
-}
-#endif
-
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
bool dropped(dropped_);
if (dropped)
[self dropBar:NO];
-
- // XXX: fix Apple's layout bug
- // SRK [[self selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
- (void) statusBarFrameChanged:(NSNotification *)notification {
Package *package([database packageWithName:path]);
if (package == nil)
goto fail;
+ [package parse];
UIImage *icon([package icon]);
[self _returnPNGWithImage:icon forRequest:request];
} else if ([command isEqualToString:@"source-icon"]) {
UITableViewDelegate
> {
_transient Database *database_;
- NSMutableArray *sections_;
- NSMutableArray *filtered_;
- UITableView *list_;
+ _H<NSMutableArray> sections_;
+ _H<NSMutableArray> filtered_;
+ _H<UITableView> list_;
}
- (id) initWithDatabase:(Database *)database;
@implementation SectionsController
-- (void) dealloc {
- [self releaseSubviews];
- [sections_ release];
- [filtered_ release];
-
- [super dealloc];
-}
-
- (NSURL *) navigationURL {
return [NSURL URLWithString:@"cydia://sections"];
}
- (void) loadView {
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
- list_ = [[UITableView alloc] initWithFrame:[[self view] bounds]];
+ list_ = [[[UITableView alloc] initWithFrame:[[self view] bounds]] autorelease];
[list_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[list_ setRowHeight:45.0f];
- [list_ setDataSource:self];
+ [(UITableView *) list_ setDataSource:self];
[list_ setDelegate:self];
[[self view] addSubview:list_];
}
}
- (void) releaseSubviews {
- [list_ release];
list_ = nil;
}
if ((self = [super init]) != nil) {
database_ = database;
- sections_ = [[NSMutableArray arrayWithCapacity:16] retain];
- filtered_ = [[NSMutableArray arrayWithCapacity:16] retain];
+ sections_ = [NSMutableArray arrayWithCapacity:16];
+ filtered_ = [NSMutableArray arrayWithCapacity:16];
} return self;
}
[sections_ sortUsingSelector:@selector(compareByLocalized:)];
- for (Section *section in sections_) {
+ for (Section *section in (id) sections_) {
size_t count([section row]);
if (count == 0)
continue;
_transient Database *database_;
unsigned era_;
CFMutableArrayRef packages_;
- NSMutableArray *sections_;
- UITableView *list_;
+ _H<NSMutableArray> sections_;
+ _H<UITableView> list_;
unsigned upgrades_;
}
@implementation ChangesController
- (void) dealloc {
- [self releaseSubviews];
CFRelease(packages_);
- [sections_ release];
-
[super dealloc];
}
PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]);
if (cell == nil)
cell = [[[PackageCell alloc] init] autorelease];
- [cell setPackage:[self packageAtIndexPath:path]];
+ [cell setPackage:[self packageAtIndexPath:path] asSummary:false];
return cell;
}
- (void) loadView {
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
- list_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStylePlain];
+ list_ = [[[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStylePlain] autorelease];
[list_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[list_ setRowHeight:73];
- [list_ setDataSource:self];
+ [(UITableView *) list_ setDataSource:self];
[list_ setDelegate:self];
[[self view] addSubview:list_];
}
}
- (void) releaseSubviews {
- [list_ release];
list_ = nil;
}
database_ = database;
packages_ = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL);
- sections_ = [[NSMutableArray arrayWithCapacity:16] retain];
+ sections_ = [NSMutableArray arrayWithCapacity:16];
} return self;
}
_end
_trace();
_profile(ChangesController$_reloadPackages$radixSort)
- [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<SKRadixFunction>(&PackageChangesRadix) withContext:NULL];
+ [(NSMutableArray *) packages_ radixSortUsingFunction:reinterpret_cast<MenesRadixSortFunction>(&PackageChangesRadix) withContext:NULL];
_end
_trace();
}
era_ = [database_ era];
NSArray *packages = [database_ packages];
- [sections_ removeAllObjects];
-
#if 1
UIProgressHUD *hud([delegate_ addProgressHUD]);
[hud setText:UCLocalize("LOADING")];
[self _reloadPackages:packages];
#endif
+ [sections_ removeAllObjects];
+
Section *upgradable = [[[Section alloc] initWithName:UCLocalize("AVAILABLE_UPGRADES") localize:NO] autorelease];
Section *ignored = nil;
Section *section = nil;
return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://search/%@", [search_ text]]];
}
-- (void) searchBarSearchButtonClicked:(UISearchBar *)searchBar {
+- (void) useSearch {
[self setObject:[search_ text] forFilter:@selector(isUnfilteredAndSearchedForBy:)];
- [search_ resignFirstResponder];
+ [self clearData];
+ [self reloadData];
+}
+
+- (void) viewWillAppear:(BOOL)animated {
+ [super viewWillAppear:animated];
+
+ if ([self filter] == @selector(isUnfilteredAndSelectedForBy:))
+ [self useSearch];
+}
+
+- (void) searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
+ [self setObject:[search_ text] forFilter:@selector(isUnfilteredAndSelectedForBy:)];
+ [self clearData];
[self reloadData];
}
+- (void) searchBarButtonClicked:(UISearchBar *)searchBar {
+ [search_ resignFirstResponder];
+ [self useSearch];
+}
+
+- (void) searchBarCancelButtonClicked:(UISearchBar *)searchBar {
+ [search_ setText:@""];
+ [self searchBarButtonClicked:searchBar];
+}
+
+- (void) searchBarSearchButtonClicked:(UISearchBar *)searchBar {
+ [self searchBarButtonClicked:searchBar];
+}
+
- (void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)text {
[self setObject:text forFilter:@selector(isUnfilteredAndSelectedForBy:)];
[self reloadData];
}
+- (bool) shouldYield {
+ return [self filter] == @selector(isUnfilteredAndSearchedForBy:);
+}
+
+- (bool) isSummarized {
+ return [self filter] == @selector(isUnfilteredAndSelectedForBy:);
+}
+
- (id) initWithDatabase:(Database *)database query:(NSString *)query {
if ((self = [super initWithDatabase:database title:UCLocalize("SEARCH") filter:@selector(isUnfilteredAndSearchedForBy:) with:query])) {
search_ = [[[UISearchBar alloc] init] autorelease];
UITableViewDelegate
> {
_transient Database *database_;
- NSString *name_;
- Package *package_;
- UITableView *table_;
- UISwitch *subscribedSwitch_;
- UISwitch *ignoredSwitch_;
- UITableViewCell *subscribedCell_;
- UITableViewCell *ignoredCell_;
+ _H<NSString> name_;
+ _H<Package> package_;
+ _H<UITableView> table_;
+ _H<UISwitch> subscribedSwitch_;
+ _H<UISwitch> ignoredSwitch_;
+ _H<UITableViewCell> subscribedCell_;
+ _H<UITableViewCell> ignoredCell_;
}
- (id) initWithDatabase:(Database *)database package:(NSString *)package;
@implementation PackageSettingsController
-- (void) dealloc {
- [self releaseSubviews];
- [name_ release];
- [package_ release];
-
- [super dealloc];
-}
-
- (NSURL *) navigationURL {
return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://package/%@/settings", [package_ id]]];
}
- (void) loadView {
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
- table_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStyleGrouped];
+ table_ = [[[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStyleGrouped] autorelease];
[table_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
- [table_ setDataSource:self];
+ [(UITableView *) table_ setDataSource:self];
[table_ setDelegate:self];
[[self view] addSubview:table_];
- subscribedSwitch_ = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
+ subscribedSwitch_ = [[[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 20)] autorelease];
[subscribedSwitch_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
[subscribedSwitch_ addTarget:self action:@selector(onSubscribed:) forEvents:UIControlEventValueChanged];
- ignoredSwitch_ = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
+ ignoredSwitch_ = [[[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 20)] autorelease];
[ignoredSwitch_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
[ignoredSwitch_ addTarget:self action:@selector(onIgnored:) forEvents:UIControlEventValueChanged];
- subscribedCell_ = [[UITableViewCell alloc] init];
+ subscribedCell_ = [[[UITableViewCell alloc] init] autorelease];
[subscribedCell_ setText:UCLocalize("SHOW_ALL_CHANGES")];
[subscribedCell_ setAccessoryView:subscribedSwitch_];
[subscribedCell_ setSelectionStyle:UITableViewCellSelectionStyleNone];
- ignoredCell_ = [[UITableViewCell alloc] init];
+ ignoredCell_ = [[[UITableViewCell alloc] init] autorelease];
[ignoredCell_ setText:UCLocalize("IGNORE_UPGRADES")];
[ignoredCell_ setAccessoryView:ignoredSwitch_];
[ignoredCell_ setSelectionStyle:UITableViewCellSelectionStyleNone];
}
- (void) releaseSubviews {
- [ignoredCell_ release];
ignoredCell_ = nil;
-
- [subscribedCell_ release];
subscribedCell_ = nil;
-
- [table_ release];
table_ = nil;
-
- [ignoredSwitch_ release];
ignoredSwitch_ = nil;
-
- [subscribedSwitch_ release];
subscribedSwitch_ = nil;
}
- (id) initWithDatabase:(Database *)database package:(NSString *)package {
if ((self = [super init]) != nil) {
database_ = database;
- name_ = [package retain];
+ name_ = package;
} return self;
}
- (void) reloadData {
[super reloadData];
- if (package_ != nil)
- [package_ autorelease];
package_ = [database_ packageWithName:name_];
if (package_ != nil) {
- package_ = [package_ retain];
[subscribedSwitch_ setOn:([package_ subscribed] ? 1 : 0) animated:NO];
[ignoredSwitch_ setOn:([package_ ignored] ? 1 : 0) animated:NO];
} // XXX: what now, G?
/* Source Cell {{{ */
@interface SourceCell : CYTableViewCell <
- ContentDelegate
+ CyteTableViewCellDelegate
> {
- UIImage *icon_;
- NSString *origin_;
- NSString *label_;
+ _H<UIImage> icon_;
+ _H<NSString> origin_;
+ _H<NSString> label_;
}
- (void) setSource:(Source *)source;
@implementation SourceCell
-- (void) clearSource {
- [icon_ release];
- [origin_ release];
- [label_ release];
-
- icon_ = nil;
- origin_ = nil;
- label_ = nil;
-}
-
- (void) setSource:(Source *)source {
- [self clearSource];
-
+ icon_ = nil;
if (icon_ == nil)
icon_ = [UIImage applicationImageNamed:[NSString stringWithFormat:@"Sources/%@.png", [source host]]];
if (icon_ == nil)
icon_ = [UIImage applicationImageNamed:@"unknown.png"];
- icon_ = [icon_ retain];
- origin_ = [[source name] retain];
- label_ = [[source uri] retain];
+ origin_ = [source name];
+ label_ = [source uri];
[content_ setNeedsDisplay];
}
-- (void) dealloc {
- [self clearSource];
- [super dealloc];
-}
-
- (SourceCell *) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) != nil) {
UIView *content([self contentView]);
CGRect bounds([content bounds]);
- content_ = [[ContentView alloc] initWithFrame:bounds];
+ content_ = [[[CyteTableViewCellContentView alloc] initWithFrame:bounds] autorelease];
[content_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[content_ setBackgroundColor:[UIColor whiteColor]];
[content addSubview:content_];
/* Source Controller {{{ */
@interface SourceController : FilteredPackageListController {
_transient Source *source_;
- NSString *key_;
+ _H<NSString> key_;
}
- (id) initWithDatabase:(Database *)database source:(Source *)source;
- (id) initWithDatabase:(Database *)database source:(Source *)source {
if ((self = [super initWithDatabase:database title:[source label] filter:@selector(isVisibleInSource:) with:source]) != nil) {
source_ = source;
- key_ = [[source key] retain];
+ key_ = [source key];
} return self;
}
- (void) reloadData {
source_ = [database_ sourceWithKey:key_];
- [key_ release];
- key_ = [[source_ key] retain];
+ key_ = [source_ key];
[self setObject:source_];
[[self navigationItem] setTitle:[source_ label]];
UITableViewDelegate
> {
_transient Database *database_;
- UITableView *list_;
- NSMutableArray *sources_;
+ _H<UITableView> list_;
+ _H<NSMutableArray> sources_;
int offset_;
- NSString *href_;
- UIProgressHUD *hud_;
- NSError *error_;
+ _H<NSString> href_;
+ _H<UIProgressHUD> hud_;
+ _H<NSError> error_;
//NSURLConnection *installer_;
NSURLConnection *trivial_;
}
- (void) dealloc {
- [self releaseSubviews];
-
- [href_ release];
- [hud_ release];
- [error_ release];
-
//[self _releaseConnection:installer_];
[self _releaseConnection:trivial_];
[self _releaseConnection:trivial_gz_];
[self _releaseConnection:trivial_bz2_];
//[self _releaseConnection:automatic_];
- [sources_ release];
[super dealloc];
}
}
- (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
- Source *source = [self sourceAtIndexPath:indexPath];
- [Sources_ removeObjectForKey:[source key]];
- [delegate_ syncData];
+ if (editingStyle == UITableViewCellEditingStyleDelete) {
+ Source *source = [self sourceAtIndexPath:indexPath];
+ [Sources_ removeObjectForKey:[source key]];
+ [delegate_ syncData];
+ }
}
- (void) complete {
trivial_bz2_ == nil &&
trivial_gz_ == nil
) {
+ [delegate_ releaseNetworkActivityIndicator];
+
+ [delegate_ removeProgressHUD:hud_];
+ hud_ = nil;
+
bool defer(false);
if (cydia_) {
[alert show];
}
- [delegate_ releaseNetworkActivityIndicator];
-
- [delegate_ removeProgressHUD:hud_];
- [hud_ autorelease];
- hud_ = nil;
-
- if (!defer) {
- [href_ release];
- href_ = nil;
- }
-
- if (error_ != nil) {
- [error_ release];
- error_ = nil;
- }
+ href_ = nil;
+ error_ = nil;
}
}
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
lprintf("connection:\"%s\" didFailWithError:\"%s\"", [href_ UTF8String], [[error localizedDescription] UTF8String]);
- if (error_ != nil)
- error_ = [error retain];
+ error_ = error;
[self _endConnection:connection];
}
href_ = [href stringByAppendingString:@"/"];
else
href_ = href;
- href_ = [href_ retain];
trivial_ = [[self _requestHRef:[href_ stringByAppendingString:@"Packages"] method:@"HEAD"] retain];
trivial_bz2_ = [[self _requestHRef:[href_ stringByAppendingString:@"Packages.bz2"] method:@"HEAD"] retain];
cydia_ = false;
// XXX: this is stupid
- hud_ = [[delegate_ addProgressHUD] retain];
+ hud_ = [delegate_ addProgressHUD];
[hud_ setText:UCLocalize("VERIFYING_URL")];
[delegate_ retainNetworkActivityIndicator];
} break;
_nodefault
}
- [href_ release];
href_ = nil;
[alert dismissWithClickedButtonIndex:-1 animated:YES];
- (void) loadView {
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
- list_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStylePlain];
+ list_ = [[[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStylePlain] autorelease];
[list_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[list_ setRowHeight:56];
- [list_ setDataSource:self];
+ [(UITableView *) list_ setDataSource:self];
[list_ setDelegate:self];
[[self view] addSubview:list_];
}
}
- (void) releaseSubviews {
- [list_ release];
list_ = nil;
}
- (id) initWithDatabase:(Database *)database {
if ((self = [super init]) != nil) {
database_ = database;
- sources_ = [[NSMutableArray arrayWithCapacity:16] retain];
+ sources_ = [NSMutableArray arrayWithCapacity:16];
} return self;
}
] autorelease];
[alert setContext:@"source"];
- [alert setTransform:CGAffineTransformTranslate([alert transform], 0.0, 100.0)];
[alert setNumberOfRows:1];
[alert addTextFieldWithValue:@"http://" label:@""];
_transient Database *database_;
// XXX: ok, "roledelegate_"?...
_transient id roledelegate_;
- UITableView *table_;
- UISegmentedControl *segment_;
- UIView *container_;
+ _H<UITableView> table_;
+ _H<UISegmentedControl> segment_;
+ _H<UIView> container_;
}
- (void) showDoneButton;
@implementation SettingsController
-- (void) dealloc {
- [self releaseSubviews];
-
- [super dealloc];
-}
-
- (void) loadView {
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
- table_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStyleGrouped];
+ table_ = [[[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStyleGrouped] autorelease];
[table_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
[table_ setDelegate:self];
- [table_ setDataSource:self];
+ [(UITableView *) table_ setDataSource:self];
[[self view] addSubview:table_];
NSArray *items = [NSArray arrayWithObjects:
UCLocalize("HACKER"),
UCLocalize("DEVELOPER"),
nil];
- segment_ = [[UISegmentedControl alloc] initWithItems:items];
- container_ = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, 44.0f)];
+ segment_ = [[[UISegmentedControl alloc] initWithItems:items] autorelease];
+ container_ = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, 44.0f)] autorelease];
[container_ addSubview:segment_];
}
}
- (void) releaseSubviews {
- [table_ release];
table_ = nil;
-
- [segment_ release];
segment_ = nil;
-
- [container_ release];
container_ = nil;
}
/* }}} */
/* Stash Controller {{{ */
@interface StashController : CyteViewController {
- UIActivityIndicatorView *spinner_;
- UILabel *status_;
- UILabel *caption_;
+ _H<UIActivityIndicatorView> spinner_;
+ _H<UILabel> status_;
+ _H<UILabel> caption_;
}
@end
@implementation StashController
-- (void) dealloc {
- [self releaseSubviews];
-
- [super dealloc];
-}
-
- (void) loadView {
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
[[self view] setBackgroundColor:[UIColor viewFlipsideBackgroundColor]];
[[self view] addSubview:status_];
}
-- (void) releaseSubviews {
- [spinner_ release];
- spinner_ = nil;
+@end
+/* }}} */
+
+@interface CYURLCache : SDURLCache {
+}
+
+@end
- [status_ release];
- status_ = nil;
+@implementation CYURLCache
- [caption_ release];
- caption_ = nil;
+- (void) logEvent:(NSString *)event forRequest:(NSURLRequest *)request {
+#if !ForRelease
+ if (false);
+ else if ([event isEqualToString:@"no-cache"])
+ event = @"!!!";
+ else if ([event isEqualToString:@"store"])
+ event = @">>>";
+ else if ([event isEqualToString:@"invalid"])
+ event = @"???";
+ else if ([event isEqualToString:@"memory"])
+ event = @"mem";
+ else if ([event isEqualToString:@"disk"])
+ event = @"ssd";
+ else if ([event isEqualToString:@"miss"])
+ event = @"---";
+
+ NSLog(@"%@: %@", event, [[request URL] absoluteString]);
+#endif
}
@end
-/* }}} */
@interface Cydia : UIApplication <
ConfirmationControllerDelegate,
UINavigationControllerDelegate,
UITabBarControllerDelegate
> {
- // XXX: evaluate all fields for _transient
-
- UIWindow *window_;
- CYTabBarController *tabbar_;
- CYEmulatedLoadingController *emulated_;
+ _H<UIWindow> window_;
+ _H<CYTabBarController> tabbar_;
+ _H<CYEmulatedLoadingController> emulated_;
- NSMutableArray *essential_;
- NSMutableArray *broken_;
+ _H<NSMutableArray> essential_;
+ _H<NSMutableArray> broken_;
Database *database_;
- NSURL *starturl_;
+ _H<NSURL> starturl_;
unsigned locked_;
unsigned activity_;
- StashController *stash_;
+ _H<StashController> stash_;
bool loaded_;
}
[window_ addSubview:[tabbar_ view]];
[[emulated_ view] removeFromSuperview];
- [emulated_ release];
emulated_ = nil;
[window_ setUserInteractionEnabled:YES];
}
} else if ([context isEqualToString:@"fixhalf"]) {
if (button == [alert cancelButtonIndex]) {
@synchronized (self) {
- for (Package *broken in broken_) {
+ for (Package *broken in (id) broken_) {
[broken remove];
NSString *id = [broken id];
} else if ([context isEqualToString:@"upgrade"]) {
if (button == [alert firstOtherButtonIndex]) {
@synchronized (self) {
- for (Package *essential in essential_)
+ for (Package *essential in (id) essential_)
[essential install];
[self resolve];
- (void) applicationOpenURL:(NSURL *)url {
[super applicationOpenURL:url];
- if (!loaded_) starturl_ = [url retain];
- else [self openCydiaURL:url forExternal:YES];
+ if (!loaded_)
+ starturl_ = url;
+ else
+ [self openCydiaURL:url forExternal:YES];
}
- (void) applicationWillResignActive:(UIApplication *)application {
- (void) addStashController {
++locked_;
- stash_ = [[StashController alloc] init];
+ stash_ = [[[StashController alloc] init] autorelease];
[window_ addSubview:[stash_ view]];
}
- (void) removeStashController {
[[stash_ view] removeFromSuperview];
- [stash_ release];
+ stash_ = nil;
--locked_;
}
}
- (void) setupViewControllers {
- tabbar_ = [[CYTabBarController alloc] initWithDatabase:database_];
+ tabbar_ = [[[CYTabBarController alloc] initWithDatabase:database_] autorelease];
NSMutableArray *items([NSMutableArray arrayWithObjects:
[[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage applicationImageNamed:@"home.png"] tag:0] autorelease],
[BridgedHosts_ addObject:[[NSURL URLWithString:CydiaURL(@"")] host]];
}
- [NSURLCache setSharedURLCache:[[[SDURLCache alloc]
+ [NSURLCache setSharedURLCache:[[[CYURLCache alloc]
initWithMemoryCapacity:524288
diskCapacity:10485760
diskPath:[NSString stringWithFormat:@"%@/Library/Caches/com.saurik.Cydia/SDURLCache", @"/var/root"]
[NSURLProtocol registerClass:[CydiaURLProtocol class]];
- Font12_ = [[UIFont systemFontOfSize:12] retain];
- Font12Bold_ = [[UIFont boldSystemFontOfSize:12] retain];
- Font14_ = [[UIFont systemFontOfSize:14] retain];
- Font18Bold_ = [[UIFont boldSystemFontOfSize:18] retain];
- Font22Bold_ = [[UIFont boldSystemFontOfSize:22] retain];
+ // this would disallow http{,s} URLs from accessing this data
+ //[WebView registerURLSchemeAsLocal:@"cydia"];
- essential_ = [[NSMutableArray alloc] initWithCapacity:4];
- broken_ = [[NSMutableArray alloc] initWithCapacity:4];
+ Font12_ = [UIFont systemFontOfSize:12];
+ Font12Bold_ = [UIFont boldSystemFontOfSize:12];
+ Font14_ = [UIFont systemFontOfSize:14];
+ Font18Bold_ = [UIFont boldSystemFontOfSize:18];
+ Font22Bold_ = [UIFont boldSystemFontOfSize:22];
+
+ essential_ = [NSMutableArray arrayWithCapacity:4];
+ broken_ = [NSMutableArray arrayWithCapacity:4];
// XXX: I really need this thing... like, seriously... I'm sorry
[[[CydiaWebViewController alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/appcache/", UI_]]] reloadData];
- window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ window_ = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[window_ orderFront:self];
[window_ makeKey:self];
[window_ setHidden:NO];
[window_ setUserInteractionEnabled:NO];
[self setupViewControllers];
- emulated_ = [[CYEmulatedLoadingController alloc] initWithDatabase:database_];
+ emulated_ = [[[CYEmulatedLoadingController alloc] initWithDatabase:database_] autorelease];
[window_ addSubview:[emulated_ view]];
[self performSelector:@selector(loadData) withObject:nil afterDelay:0];
// (Try to) show the startup URL.
if (starturl_ != nil) {
[self openCydiaURL:starturl_ forExternal:NO];
- [starturl_ release];
starturl_ = nil;
}
}
NSLog(@"unknown UIUserInterfaceIdiom!");
}
- SessionData_ = [[NSMutableDictionary alloc] initWithCapacity:4];
+ SessionData_ = [NSMutableDictionary dictionaryWithCapacity:4];
- HostConfig_ = [[NSObject alloc] init];
+ HostConfig_ = [[[NSObject alloc] init] autorelease];
@synchronized (HostConfig_) {
BridgedHosts_ = [NSMutableSet setWithCapacity:4];
PipelinedHosts_ = [NSMutableSet setWithCapacity:4];
else
Machine_ = machine;
- if (CFMutableDictionaryRef dict = IOServiceMatching("IOPlatformExpertDevice")) {
- if (io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, dict)) {
- if (CFTypeRef serial = IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0)) {
- SerialNumber_ = [NSString stringWithString:(NSString *)serial];
- CFRelease(serial);
- }
-
- if (CFTypeRef ecid = IORegistryEntrySearchCFProperty(service, kIODeviceTreePlane, CFSTR("unique-chip-id"), kCFAllocatorDefault, kIORegistryIterateRecursively)) {
- NSData *data((NSData *) ecid);
- size_t length([data length]);
- uint8_t bytes[length];
- [data getBytes:bytes];
- char string[length * 2 + 1];
- for (size_t i(0); i != length; ++i)
- sprintf(string + i * 2, "%.2X", bytes[length - i - 1]);
- ChipID_ = [NSString stringWithUTF8String:string];
- CFRelease(ecid);
- }
-
- IOObjectRelease(service);
- }
- }
+ SerialNumber_ = (NSString *) CYIOGetValue("IOService:/", @"IOPlatformSerialNumber");
+ ChipID_ = [CYHex((NSData *) CYIOGetValue("IODeviceTree:/chosen", @"unique-chip-id"), true) uppercaseString];
+ BBSNum_ = CYHex((NSData *) CYIOGetValue("IOService:/AppleARMPE/baseband", @"snum"), false);
UniqueID_ = [[UIDevice currentDevice] uniqueIdentifier];