File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,24 @@ @implementation ProfileManager {
14
14
15
15
+ (Configuration *)configuration {
16
16
NSData *data = [[NSUserDefaults standardUserDefaults ] dataForKey: CONFIG_DATA_KEY];
17
+ Configuration *configuration;
17
18
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;
19
34
}
20
- Configuration *configuration;
21
35
if (data == nil ) {
22
36
// load default configuration
23
37
configuration = [[Configuration alloc ] init ];
You can’t perform that action at this time.
0 commit comments