Procházet zdrojové kódy

share stored LAN servers across devices

Felix Paul Kühne před 9 roky
rodič
revize
175d3f0fc8

+ 8 - 4
Sources/LocalNetworkConnectivity/VLCNetworkLoginViewController.m

@@ -97,11 +97,13 @@
         [self protocolSelectionChanged:nil];
     }
 
-    // persistent state
+    NSUbiquitousKeyValueStore *ukvStore = [NSUbiquitousKeyValueStore defaultStore];
+    [ukvStore synchronize];
+    _serverList = [NSMutableArray arrayWithArray:[ukvStore arrayForKey:kVLCStoredServerList]];
+
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    _serverList = [NSMutableArray arrayWithArray:[defaults objectForKey:kVLCStoredServerList]];
 
-    if (_serverList.count == 0) {
+    if (![defaults boolForKey:kVLCMigratedToUbiquitousStoredServerList]) {
         /* we need to migrate from previous, insecure storage fields */
         NSArray *ftpServerList = [defaults objectForKey:kVLCFTPServer];
         NSArray *ftpLoginList = [defaults objectForKey:kVLCFTPLogin];
@@ -123,7 +125,9 @@
                 [_serverList addObject:[NSString stringWithFormat:@"plex://%@:%@", plexServerList[i], plexPortList[i]]];
             }
         }
-        [defaults setObject:_serverList forKey:kVLCStoredServerList];
+        [ukvStore setArray:_serverList forKey:kVLCStoredServerList];
+        [ukvStore synchronize];
+        [defaults setBool:YES forKey:kVLCMigratedToUbiquitousStoredServerList];
         [defaults synchronize];
     }
 

+ 1 - 0
Sources/VLCConstants.h

@@ -85,6 +85,7 @@
 #define WifiInterfaceName @"en0"
 #endif
 
+#define kVLCMigratedToUbiquitousStoredServerList @"kVLCMigratedToUbiquitousStoredServerList"
 #define kVLCStoredServerList @"kVLCStoredServerList"
 #define kVLCStoreDropboxCredentials @"kVLCStoreDropboxCredentials"
 #define kVLCStoreOneDriveCredentials @"kVLCStoreOneDriveCredentials"