marinofaggiana 5 жил өмнө
parent
commit
def694c6f7

+ 1 - 14
iOSClient/AppDelegate.m

@@ -36,7 +36,7 @@
 
 @class NCViewerRichdocument;
 
-@interface AppDelegate () <UNUserNotificationCenterDelegate, CCLoginDelegate, NCLoginWebDelegate>
+@interface AppDelegate () <UNUserNotificationCenterDelegate>
 {
 PKPushRegistry *pushRegistry;
 }
@@ -306,7 +306,6 @@ PKPushRegistry *pushRegistry;
                 
                 self.activeLoginWeb.urlBase = [[NCBrandOptions sharedInstance] loginBaseUrl];
                 self.activeLoginWeb.loginType = loginType;
-                self.activeLoginWeb.delegate = delegate;
 
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                     [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
@@ -329,7 +328,6 @@ PKPushRegistry *pushRegistry;
                     self.activeLoginWeb.urlBase = self.activeUrl;
                 }
                 self.activeLoginWeb.loginType = loginType;
-                self.activeLoginWeb.delegate = delegate;
                 
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                     [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
@@ -342,7 +340,6 @@ PKPushRegistry *pushRegistry;
             
             self.activeLoginWeb.urlBase = [[NCBrandOptions sharedInstance] loginBaseUrl];
             self.activeLoginWeb.loginType = loginType;
-            self.activeLoginWeb.delegate = delegate;
             
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                 [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
@@ -353,7 +350,6 @@ PKPushRegistry *pushRegistry;
             if (!(_activeLogin.isViewLoaded && _activeLogin.view.window)) {
                 
                 _activeLogin = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"CCLoginNextcloud"];
-                _activeLogin.delegate = delegate;
                 _activeLogin.loginType = loginType;
                 
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
@@ -364,15 +360,6 @@ PKPushRegistry *pushRegistry;
     }
 }
 
-- (void)loginSuccess
-{
-    //
-}
-- (void)loginWebDismiss
-{
-    [self startTimerErrorNetworking];
-}
-
 - (void)startTimerErrorNetworking
 {
     self.timerErrorNetworking = [NSTimer scheduledTimerWithTimeInterval:k_timerErrorNetworking target:self selector:@selector(checkErrorNetworking) userInfo:nil repeats:YES];

+ 0 - 8
iOSClient/Login/CCLogin.h

@@ -30,16 +30,8 @@
 @class NCLoginWeb;
 @class NCLoginQRCode;
 
-@protocol CCLoginDelegate <NSObject>
-
-- (void)loginSuccess;
-
-@end
-
 @interface CCLogin : UIViewController <UITextFieldDelegate, CCCertificateDelegate>
 
-@property (nonatomic, weak) id <CCLoginDelegate> delegate;
-
 @property (nonatomic, weak) IBOutlet UIImageView *imageBrand;
 
 @property (nonatomic, weak) IBOutlet UITextField *user;

+ 5 - 12
iOSClient/Login/CCLogin.m

@@ -191,9 +191,9 @@
             if (_user.hidden && _password.hidden && versionMajor >= k_flow_version_available) {
                 
                 appDelegate.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
+                appDelegate.activeLoginWeb.delegate = self;
                 appDelegate.activeLoginWeb.urlBase = self.baseUrl.text;
                 appDelegate.activeLoginWeb.loginType = _loginType;
-                appDelegate.activeLoginWeb.delegate = self;
                 
                 [self presentViewController:appDelegate.activeLoginWeb animated:YES completion:nil];
             }
@@ -304,13 +304,8 @@
 #pragma mark === NCLoginWebDelegate ===
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)loginSuccess
-{
-    [self.delegate loginSuccess];
-}
-
 - (void)loginWebDismiss
-{   
+{
     [self dismissViewControllerAnimated:YES completion:nil];
 }
 
@@ -363,7 +358,7 @@
                     // Setting appDelegate active account
                     [appDelegate settingActiveAccount:account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:token];
                     
-                    [self.delegate loginSuccess];
+                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
                     
                     [self dismissViewControllerAnimated:YES completion:nil];
                     
@@ -383,7 +378,7 @@
                     // Setting appDelegate active account
                     [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
                     
-                    [self.delegate loginSuccess];
+                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
                     
                     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
                         [self dismissViewControllerAnimated:YES completion:nil];
@@ -428,8 +423,7 @@
                     // Setting appDelegate active account
                     [appDelegate settingActiveAccount:account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:password];
                     
-                    [self.delegate loginSuccess:_loginType];
-                    
+         
                     [self dismissViewControllerAnimated:YES completion:nil];
                     
                 } else {
@@ -450,7 +444,6 @@
                     // Setting appDelegate active account
                     [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
                     
-                    [self.delegate loginSuccess:_loginType];
                     
                     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
                         [self dismissViewControllerAnimated:YES completion:nil];

+ 18 - 3
iOSClient/Login/NCLoginWeb.swift

@@ -24,7 +24,6 @@
 import Foundation
 
 @objc protocol NCLoginWebDelegate: class {
-    func loginSuccess()
     @objc optional func loginWebDismiss()
 }
 
@@ -69,6 +68,20 @@ class NCLoginWeb: UIViewController {
         loadWebPage(webView: webView!, url: URL(string: urlBase)!)
     }
     
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+        
+        // Stop timer error network
+        appDelegate.timerErrorNetworking.invalidate()
+    }
+    
+    override func viewDidDisappear(_ animated: Bool) {
+        super.viewDidDisappear(animated)
+        
+        // Start timer error network
+        appDelegate.startTimerErrorNetworking()
+    }
+    
     func loadWebPage(webView: WKWebView, url: URL)  {
         
         let language = NSLocale.preferredLanguages[0] as String
@@ -136,8 +149,9 @@ extension NCLoginWeb: WKNavigationDelegate {
                         CCUtility.setPassword(account, password: token)
                         appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: appDelegate.activeUserID, activePassword: token)
                         
+                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
+                        
                         self.dismiss(animated: true) {
-                            self.delegate?.loginSuccess()
                             self.delegate?.loginWebDismiss?()
                         }
                     }
@@ -163,8 +177,9 @@ extension NCLoginWeb: WKNavigationDelegate {
                         
                         appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: token)
                         
+                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
+                        
                         self.dismiss(animated: true) {
-                            self.delegate?.loginSuccess()
                             self.delegate?.loginWebDismiss?()
                         }
                     }

+ 1 - 11
iOSClient/Main/CCMain.m

@@ -36,7 +36,7 @@
 #import "NCNetworkingEndToEnd.h"
 #import "PKDownloadButton.h"
 
-@interface CCMain () <UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, CCLoginDelegate, NCLoginWebDelegate, NCSelectDelegate, UITextFieldDelegate>
+@interface CCMain () <UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, NCSelectDelegate, UITextFieldDelegate>
 {
     AppDelegate *appDelegate;
         
@@ -308,7 +308,6 @@
 //
 // Callers :
 //
-// loginSuccess (delagate)
 // ChangeDefaultAccount (delegate)
 // Split : inizialize
 // Settings Advanced : removeAllFiles
@@ -915,15 +914,6 @@
     }
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === Delegate Login ===
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)loginSuccess
-{
-   [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
-}
-
 #pragma mark -
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Peek & Pop  =====

+ 1 - 8
iOSClient/Main/CCMore.swift

@@ -24,7 +24,7 @@
 
 import UIKit
 
-class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLoginDelegate, NCLoginWebDelegate {
+class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
 
     @IBOutlet weak var themingBackground: UIImageView!
     @IBOutlet weak var disclosureIndicator: UIImageView!
@@ -480,13 +480,6 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
         
         self.navigationController?.pushViewController(controller, animated: true)
     }
-    
-    func loginSuccess() {
-        
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
-        
-        appDelegate.selectedTabBarController(Int(k_tabBarApplicationIndexFile))        
-    }
 }
 
 class CCCellMore: UITableViewCell {

+ 1 - 10
iOSClient/Main/CCSplit.m

@@ -27,7 +27,7 @@
 #import "NCAutoUpload.h"
 #import "NCBridgeSwift.h"
 
-@interface CCSplit () <CCLoginDelegate, NCLoginWebDelegate>
+@interface CCSplit ()
 {
     AppDelegate *appDelegate;
     BOOL prevRunningInFullScreen;
@@ -175,15 +175,6 @@
     }
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === Delegate Login ===
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)loginSuccess
-{
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Split View Controller =====
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 10
iOSClient/Settings/CCManageAccount.m

@@ -29,7 +29,7 @@
 
 #define actionSheetCancellaAccount 1
 
-@interface CCManageAccount () <CCLoginDelegate, NCLoginWebDelegate>
+@interface CCManageAccount ()
 {
     AppDelegate *appDelegate;
 }
@@ -388,15 +388,6 @@
     }
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === Delegate Login ===
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)loginSuccess
-{
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Add Account ===
 #pragma --------------------------------------------------------------------------------------------