]>
Commit | Line | Data |
---|---|---|
eaa9f122 JF |
1 | #include <strings.h> |
2 | #include <Sources.h> | |
3 | ||
4 | #include <UIKit/UIKit.h> | |
5 | #include <CydiaSubstrate/CydiaSubstrate.h> | |
6 | #include "CyteKit/PerlCompatibleRegEx.hpp" | |
7 | ||
8 | _H<NSMutableDictionary> Sources_; | |
9 | _H<NSString> CydiaSource_; | |
10 | bool Changed_; | |
11 | ||
12 | _H<NSString> Firmware_; | |
13 | ||
14 | int main(int argc, const char *argv[]) { | |
15 | if (argc < 2 || strcmp(argv[1], "configure") != 0) | |
16 | return 0; | |
17 | ||
18 | NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); | |
19 | ||
20 | Pcre pattern("^([0-9]+\\.[0-9]+)"); | |
21 | ||
22 | if (pattern([[UIDevice currentDevice] systemVersion])) | |
23 | Firmware_ = pattern[1]; | |
24 | ||
25 | NSDictionary *metadata([[[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"] autorelease]); | |
26 | NSUInteger version(0); | |
27 | ||
28 | if (metadata != nil) { | |
29 | Sources_ = [metadata objectForKey:@"Sources"]; | |
30 | CydiaSource_ = [metadata objectForKey:@"CydiaSource"]; | |
31 | ||
32 | if (NSNumber *number = [metadata objectForKey:@"Version"]) | |
33 | version = [number unsignedIntValue]; | |
34 | } | |
35 | ||
36 | if (CydiaSource_ == nil) | |
37 | CydiaSource_ = @"apt.saurik.com"; | |
38 | ||
39 | if (Sources_ == nil) | |
40 | Sources_ = [NSMutableDictionary dictionaryWithCapacity:8]; | |
41 | ||
42 | if (version == 0) { | |
43 | CydiaAddSource(@"http://apt.thebigboss.org/repofiles/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]); | |
44 | CydiaAddSource(@"http://apt.modmyi.com/", @"stable", [NSMutableArray arrayWithObject:@"main"]); | |
45 | CydiaAddSource(@"http://cydia.zodttd.com/repo/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]); | |
46 | CydiaAddSource(@"http://repo666.ultrasn0w.com/", @"./"); | |
47 | } | |
48 | ||
49 | CydiaWriteSources(); | |
50 | ||
51 | [pool release]; | |
52 | return 0; | |
53 | } |