소스 검색

networkLogin : add alert view if the protocol are not selected for saving or connecting

Pierre SAGASPE 7 년 전
부모
커밋
529bf307e5
1개의 변경된 파일22개의 추가작업 그리고 2개의 파일을 삭제
  1. 22 2
      Sources/LocalNetworkConnectivity/VLCNetworkLoginViewController.m

+ 22 - 2
Sources/LocalNetworkConnectivity/VLCNetworkLoginViewController.m

@@ -188,6 +188,9 @@
 
 - (void)saveLoginDataSource:(VLCNetworkLoginDataSourceLogin *)dataSource
 {
+    if (!self.protocolSelected)
+        return;
+
     VLCNetworkServerLoginInformation *login = dataSource.loginInformation;
     // TODO: move somewere else?
     // Normalize Plex login
@@ -213,6 +216,9 @@
 
 - (void)connectLoginDataSource:(VLCNetworkLoginDataSourceLogin *)dataSource
 {
+    if (!self.protocolSelected)
+        return;
+
     VLCNetworkServerLoginInformation *loginInformation = dataSource.loginInformation;
     self.loginInformation = loginInformation;
 
@@ -222,8 +228,7 @@
         _activityBackgroundView.hidden = NO;
         [_activityIndicator startAnimating];
 
-        [self performSelectorInBackground:@selector(_plexLogin)
-                               withObject:nil];
+        [self performSelectorInBackground:@selector(_plexLogin) withObject:nil];
     } else {
         [self.delegate loginWithLoginViewController:self loginInfo:dataSource.loginInformation];
     }
@@ -231,6 +236,21 @@
     [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
 }
 
+- (BOOL)protocolSelected
+{
+    if (self.protocolDataSource.protocol == VLCServerProtocolUndefined) {
+        VLCAlertView *alertView = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
+                                                              message:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
+                                                    cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
+                                                    otherButtonTitles:nil];
+        [alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
+        [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
+        return NO;
+    }
+
+    return YES;
+}
+
 #pragma mark - VLCNetworkLoginDataSourceSavedLoginsDelegate
 - (void)loginsDataSource:(VLCNetworkLoginDataSourceSavedLogins *)dataSource selectedLogin:(VLCNetworkServerLoginInformation *)login
 {