File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,10 +14,24 @@ @implementation ProfileManager {
1414
1515+ (Configuration *)configuration {
1616 NSData *data = [[NSUserDefaults standardUserDefaults ] dataForKey: CONFIG_DATA_KEY];
17+ Configuration *configuration;
1718 if (data == nil ) {
18- // TODO load data from old version
19+ // upgrade data from old version
20+ configuration = [[Configuration alloc ] init ];
21+ configuration.profiles = [[NSMutableArray alloc ] initWithCapacity: 16 ];
22+ if ([ShadowsocksRunner isUsingPublicServer ]) {
23+ configuration.current = -1 ;
24+ } else {
25+ configuration.current = 0 ;
26+ Profile *profile = [[Profile alloc ] init ];
27+ profile.server = [ShadowsocksRunner configForKey: kShadowsocksIPKey ];
28+ profile.serverPort = [[ShadowsocksRunner configForKey: kShadowsocksPortKey ] integerValue ];
29+ profile.password = [ShadowsocksRunner configForKey: kShadowsocksPasswordKey ];
30+ profile.method = [ShadowsocksRunner configForKey: kShadowsocksEncryptionKey ];
31+ [((NSMutableArray *)configuration.profiles) addObject: profile];
32+ }
33+ return configuration;
1934 }
20- Configuration *configuration;
2135 if (data == nil ) {
2236 // load default configuration
2337 configuration = [[Configuration alloc ] init ];
You can’t perform that action at this time.
0 commit comments