From 23672b395e60e5a76f7ba01ba0b7ac7cf7957525 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 3 Feb 2008 12:47:52 +0000 Subject: Renaming folder structure, added settings icon, and fixed crash bug for everyone but me. --- Cydia.mm | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'Cydia.mm') diff --git a/Cydia.mm b/Cydia.mm index 9796f46..7ecd9a5 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -178,6 +178,23 @@ static NSMutableDictionary *Metadata_; static NSMutableDictionary *Packages_; static NSDate *now_; +NSString *GetLastUpdate() { + NSDate *update = [Metadata_ objectForKey:@"LastUpdate"]; + + if (update == nil) + return @"Never or Unknown"; + + CFLocaleRef locale = CFLocaleCopyCurrent(); + CFDateFormatterRef formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterMediumStyle, kCFDateFormatterMediumStyle); + CFStringRef formatted = CFDateFormatterCreateStringWithDate(NULL, formatter, (CFDateRef) update); + + CFRelease(formatter); + CFRelease(formatted); + CFRelease(locale); + + return [(NSString *) formatted autorelease]; +} + @protocol ProgressDelegate - (void) setError:(NSString *)error; - (void) setTitle:(NSString *)title; @@ -590,17 +607,7 @@ inline float interpolate(float begin, float end, float fraction) { } - (void) setPrompt { - NSDate *update = [Metadata_ objectForKey:@"LastUpdate"]; - - CFLocaleRef locale = CFLocaleCopyCurrent(); - CFDateFormatterRef formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterMediumStyle, kCFDateFormatterMediumStyle); - CFStringRef formatted = CFDateFormatterCreateStringWithDate(NULL, formatter, (CFDateRef) update); - - [navbar_ setPrompt:[NSString stringWithFormat:@"Last Updated: %@", (NSString *) formatted]]; - - CFRelease(formatter); - CFRelease(formatted); - CFRelease(locale); + [navbar_ setPrompt:[NSString stringWithFormat:@"Last Updated: %@", GetLastUpdate()]]; } @end @@ -898,6 +905,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) { NSString *tagline_; NSString *icon_; NSString *bundle_; + NSString *website_; } - (void) dealloc; @@ -922,6 +930,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) { - (NSString *) tagline; - (NSString *) icon; - (NSString *) bundle; +- (NSString *) website; - (BOOL) matches:(NSString *)text; @@ -978,6 +987,9 @@ NSString *Scour(const char *field, const char *begin, const char *end) { bundle_ = Scour("Bundle", begin, end); if (bundle_ != nil) bundle_ = [bundle_ retain]; + website_ = Scour("Website", begin, end); + if (website_ != nil) + website_ = [website_ retain]; NSMutableDictionary *metadata = [Packages_ objectForKey:id_]; if (metadata == nil) { @@ -1074,6 +1086,10 @@ NSString *Scour(const char *field, const char *begin, const char *end) { return bundle_; } +- (NSString *) website { + return website_; +} + - (BOOL) matches:(NSString *)text { if (text == nil) return NO; @@ -3142,17 +3158,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) { } - (void) setPrompt { - NSDate *update = [Metadata_ objectForKey:@"LastUpdate"]; - - CFLocaleRef locale = CFLocaleCopyCurrent(); - CFDateFormatterRef formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterMediumStyle, kCFDateFormatterMediumStyle); - CFStringRef formatted = CFDateFormatterCreateStringWithDate(NULL, formatter, (CFDateRef) update); - - [navbar_ setPrompt:[NSString stringWithFormat:@"Last Updated: %@", (NSString *) formatted]]; - - CFRelease(formatter); - CFRelease(formatted); - CFRelease(locale); + [navbar_ setPrompt:[NSString stringWithFormat:@"Last Updated: %@", GetLastUpdate()]]; } - (void) resolve { -- cgit v1.2.3