#include <apt-pkg/sptr.h>
#include <sys/sysctl.h>
+#include <notify.h>
extern "C" {
#include <mach-o/nlist.h>
/* }}} */
static const int PulseInterval_ = 50000;
+
+const char *Firmware_ = NULL;
const char *Machine_ = NULL;
const char *SerialNumber_ = NULL;
+unsigned Major_;
+unsigned Minor_;
+unsigned BugFix_;
+
+#define FW_LEAST(major, minor, bugfix) \
+ (major > Major_ || major == Major_ && \
+ (minor > Minor_ || minor == Minor_ && \
+ bugfix >= BugFix_))
+
bool bootstrap_ = false;
static NSMutableDictionary *Metadata_;
NSString *name_;
NSString *tagline_;
NSString *icon_;
- NSString *bundle_;
NSString *website_;
}
- (NSString *) name;
- (NSString *) tagline;
- (NSString *) icon;
-- (NSString *) bundle;
- (NSString *) website;
- (BOOL) matches:(NSString *)text;
[tagline_ release];
if (icon_ != nil)
[icon_ release];
- if (bundle_ != nil)
- [bundle_ release];
[super dealloc];
}
icon_ = Scour("Icon", begin, end);
if (icon_ != nil)
icon_ = [icon_ retain];
- bundle_ = Scour("Bundle", begin, end);
- if (bundle_ != nil)
- bundle_ = [bundle_ retain];
website_ = Scour("Website", begin, end);
if (website_ != nil)
website_ = [website_ retain];
}
- (NSString *) index {
- return [[[self name] substringToIndex:1] uppercaseString];
+ NSString *index = [[[self name] substringToIndex:1] uppercaseString];
+ return [index length] != 0 && isalpha([index characterAtIndex:0]) ? index : @"123";
}
- (NSDate *) seen {
return icon_;
}
-- (NSString *) bundle {
- return bundle_;
-}
-
- (NSString *) website {
return website_;
}
NSRange range;
+ range = [[self id] rangeOfString:text options:NSCaseInsensitiveSearch];
+ if (range.location != NSNotFound)
+ return YES;
+
range = [[self name] rangeOfString:text options:NSCaseInsensitiveSearch];
if (range.location != NSNotFound)
return YES;
}
- (NSComparisonResult) compareByName:(Package *)package {
- return [[self name] caseInsensitiveCompare:[package name]];
+ NSString *lhs = [self name];
+ NSString *rhs = [package name];
+
+ if ([lhs length] != 0 && [rhs length] != 0) {
+ unichar lhc = [lhs characterAtIndex:0];
+ unichar rhc = [rhs characterAtIndex:0];
+
+ if (isalpha(lhc) && !isalpha(rhc))
+ return NSOrderedAscending;
+ else if (!isalpha(lhc) && isalpha(rhc))
+ return NSOrderedDescending;
+ }
+
+ return [lhs caseInsensitiveCompare:rhs];
}
- (NSComparisonResult) compareBySectionAndName:(Package *)package {
- (void) tableRowSelected:(NSNotification *)notification {
int row = [table_ selectedRow];
+ NSString *website = [package_ website];
- if (row == ([package_ website] == nil ? 8 : 9)) {
+ if (row == (website == nil ? 8 : 9))
[delegate_ openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@",
[[package_ maintainer] email],
[[NSString stringWithFormat:@"regarding apt package \"%@\"", [package_ name]] stringByAddingPercentEscapes]
]]];
- }
+ else if (website != nil && row == 3)
+ [delegate_ openURL:[NSURL URLWithString:website]];
}
- (Package *) package {
[version_ setBackgroundColor:clear];
[version_ setFont:large];
- description_ = [[UITextLabel alloc] initWithFrame:CGRectMake(13, 35, 315, 20)];
+ description_ = [[UITextLabel alloc] initWithFrame:CGRectMake(13, 35, 280, 20)];
[description_ setBackgroundColor:clear];
[description_ setFont:small];
else if (package_ != nil)
++views;
- if (nsection != nil)
+ if (table_ != nil && section_ == nil)
+ [table_ setPackages:packages_];
+ else if (nsection != nil)
[table_ setPackages:[nsection packages]];
else if (section_ != nil)
++views;
timeoutInterval:30.0
];
+ [request addValue:[NSString stringWithCString:Firmware_] forHTTPHeaderField:@"X-Firmware"];
[request addValue:[NSString stringWithCString:Machine_] forHTTPHeaderField:@"X-Machine"];
[request addValue:[NSString stringWithCString:SerialNumber_] forHTTPHeaderField:@"X-Serial-Number"];
- (void) applicationWillSuspend {
if (restart_)
system("launchctl stop com.apple.SpringBoard");
+
[super applicationWillSuspend];
}
[self reloadData:NO];
Package *package([database_ packageWithName:@"cydia"]);
- NSString *application = package == nil ? @"Cydia" : [NSString stringWithFormat:@"Cydia/%@", [package installed]];
+ NSString *application = package == nil ? @"Cydia" : [NSString
+ stringWithFormat:@"Cydia/%@",
+ [package installed]
+ ];
WebView *webview = [webview_ webView];
[webview setApplicationNameForUserAgent:application];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ if (NSDictionary *sysver = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]) {
+ if (NSString *prover = [sysver valueForKey:@"ProductVersion"]) {
+ Firmware_ = strdup([prover cString]);
+ NSArray *versions = [prover componentsSeparatedByString:@"."];
+ int count = [versions count];
+ Major_ = count > 0 ? [[versions objectAtIndex:0] intValue] : 0;
+ Minor_ = count > 1 ? [[versions objectAtIndex:0] intValue] : 0;
+ BugFix_ = count > 2 ? [[versions objectAtIndex:0] intValue] : 0;
+ }
+ }
+
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = new char[size];