static const NSUInteger UIViewAutoresizingFlexibleBoth(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
-void NSLogPoint(const char *fix, const CGPoint &point) {
- NSLog(@"%s(%g,%g)", fix, point.x, point.y);
-}
-
-void NSLogRect(const char *fix, const CGRect &rect) {
- NSLog(@"%s(%g,%g)+(%g,%g)", fix, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-}
-
static _finline NSString *CydiaURL(NSString *path) {
char page[25];
page[0] = 'h'; page[1] = 't'; page[2] = 't'; page[3] = 'p'; page[4] = ':';
@end
/* }}} */
-/* Cydia Action Sheet {{{ */
-@interface CYActionSheet : UIAlertView {
+/* Cydia Alert View {{{ */
+@interface CYAlertView : UIAlertView {
unsigned button_;
}
- (int) yieldToPopupAlertAnimated:(BOOL)animated;
@end
-@implementation CYActionSheet
+@implementation CYAlertView
- (id) initWithTitle:(NSString *)title buttons:(NSArray *)buttons defaultButtonIndex:(int)index {
if ((self = [super init])) {
static const NSStringCompareOptions LaxCompareOptions_ = NSNumericSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch | NSCaseInsensitiveSearch;
static const CFStringCompareFlags LaxCompareFlags_ = kCFCompareCaseInsensitive | kCFCompareNonliteral | kCFCompareLocalized | kCFCompareNumerically | kCFCompareWidthInsensitive | kCFCompareForcedOrdering;
-/* Information Dictionaries {{{ */
-@interface NSMutableArray (Cydia)
-- (void) addInfoDictionary:(NSDictionary *)info;
-@end
-
-@implementation NSMutableArray (Cydia)
-
-- (void) addInfoDictionary:(NSDictionary *)info {
- [self addObject:info];
-}
-
-@end
-
-@interface NSMutableDictionary (Cydia)
-- (void) addInfoDictionary:(NSDictionary *)info;
-@end
-
-@implementation NSMutableDictionary (Cydia)
-
-- (void) addInfoDictionary:(NSDictionary *)info {
- [self setObject:info forKey:[info objectForKey:@"CFBundleIdentifier"]];
-}
-
-@end
-/* }}} */
-
#define lprintf(args...) fprintf(stderr, args)
#define ForRelease 1
static Cytore::File<MetaValue> MetaFile_;
// }}}
// Cytore Helper Functions {{{
-static PackageValue *PackageFind(const char *name, size_t length) {
+static PackageValue *PackageFind(const char *name, size_t length, bool *fail = NULL) {
SplitHash nhash = { hashlittle(name, length) };
PackageValue *metadata;
*offset = MetaFile_.New<PackageValue>(length + 1);
metadata = &MetaFile_.Get(*offset);
+ if (metadata == NULL) {
+ if (fail != NULL)
+ *fail = true;
+
+ metadata = new PackageValue();
+ memset(metadata, 0, sizeof(*metadata));
+ }
+
memcpy(metadata->name_, name, length + 1);
metadata->nhash_ = nhash.u16[1];
} else {
}
static void PackageImport(const void *key, const void *value, void *context) {
+ bool &fail(*reinterpret_cast<bool *>(context));
+
char buffer[1024];
if (!CFStringGetCString((CFStringRef) key, buffer, sizeof(buffer), kCFStringEncodingUTF8)) {
NSLog(@"failed to import package %@", key);
return;
}
- PackageValue *metadata(PackageFind(buffer, strlen(buffer)));
+ PackageValue *metadata(PackageFind(buffer, strlen(buffer), &fail));
NSDictionary *package((NSDictionary *) value);
if (NSNumber *subscribed = [package objectForKey:@"IsSubscribed"])
[[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("CANCEL")
- // OLD: [NSString stringWithFormat:UCLocalize("SLASH_DELIMITED"), UCLocalize("CANCEL"), UCLocalize("QUEUE")]
style:UIBarButtonItemStylePlain
target:self
action:@selector(cancelButtonClicked)
if (issues_ == nil && ![self isLoading])
[[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("CONFIRM")
- style:UIBarButtonItemStylePlain
+ style:UIBarButtonItemStyleDone
target:self
action:@selector(confirmButtonClicked)
] autorelease]];
}
- (void) setProgressError:(NSString *)error withTitle:(NSString *)title {
- CYActionSheet *sheet([[[CYActionSheet alloc]
+ CYAlertView *sheet([[[CYAlertView alloc]
initWithTitle:title
buttons:[NSArray arrayWithObjects:UCLocalize("OKAY"), nil]
defaultButtonIndex:0
_trace();
if (Packages_ != nil) {
- CFDictionaryApplyFunction((CFDictionaryRef) Packages_, &PackageImport, NULL);
+ bool fail(false);
+ CFDictionaryApplyFunction((CFDictionaryRef) Packages_, &PackageImport, &fail);
_trace();
- [Metadata_ removeObjectForKey:@"Packages"];
- Packages_ = nil;
- Changed_ = true;
+
+ if (!fail) {
+ [Metadata_ removeObjectForKey:@"Packages"];
+ Packages_ = nil;
+ Changed_ = true;
+ }
}
Finishes_ = [NSArray arrayWithObjects:@"return", @"reopen", @"restart", @"reload", @"reboot", nil];