Browse Source

clear code

marinofaggiana 5 years ago
parent
commit
757a59d5cc

+ 1 - 1
iOSClient/AppDelegate.m

@@ -328,7 +328,7 @@ PKPushRegistry *pushRegistry;
     
     // check certificate untrusted (-1202)
     if ([CCUtility getCertificateError:self.activeAccount]) {
-        [[CCCertificate sharedManager] presentViewControllerCertificateWithAccount:self.activeAccount delegate:self];
+        [[CCCertificate sharedManager] presentViewControllerCertificateWithAccount:self.activeAccount viewController:self.window.rootViewController delegate:self];
     }
 }
 

+ 1 - 1
iOSClient/Library/SwiftWebVC/SwiftModalWebVC.swift

@@ -85,7 +85,7 @@ extension SwiftModalWebVC: SwiftWebVCDelegate {
     }
     
     public func didFinishLoading(success: Bool) {
-        print("Finished loading. Success: \(success).")
+        //print("Finished loading. Success: \(success).")
     }
     
     public func didFinishLoading(success: Bool, url: URL) {

+ 1 - 1
iOSClient/Login/CCLogin.m

@@ -213,7 +213,7 @@
             
             if (errorCode == NSURLErrorServerCertificateUntrusted) {
                 
-                [[CCCertificate sharedManager] presentViewControllerCertificateWithAccount:nil delegate:self];
+                [[CCCertificate sharedManager] presentViewControllerCertificateWithAccount:nil viewController:self delegate:self];
                 
             } else {
                 

+ 2 - 2
iOSClient/Login/CCLoginWeb.swift

@@ -65,7 +65,7 @@ public class CCLoginWeb: UIViewController {
 extension CCLoginWeb: SwiftModalWebVCDelegate {
     
     public func didStartLoading() {
-        print("Started loading.")
+        //print("Started loading.")
     }
     
     public func didReceiveServerRedirectForProvisionalNavigation(url: URL) {
@@ -145,7 +145,7 @@ extension CCLoginWeb: SwiftModalWebVCDelegate {
     }
 
     public func didFinishLoading(success: Bool, url: URL) {
-        print("Finished loading. Success: \(success).")
+        //print("Finished loading. Success: \(success).")
     }
     
     public func webDismiss() {

+ 4 - 4
iOSClient/Main/CCMore.swift

@@ -481,7 +481,7 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
 extension CCMore: SwiftModalWebVCDelegate, SwiftWebVCDelegate{
     
     public func didStartLoading() {
-        print("Started loading.")
+        //print("Started loading.")
     }
     
     public func didReceiveServerRedirectForProvisionalNavigation(url: URL) {
@@ -500,15 +500,15 @@ extension CCMore: SwiftModalWebVCDelegate, SwiftWebVCDelegate{
     }
     
     public func didFinishLoading(success: Bool) {
-        print("Finished loading. Success: \(success).")
+        //print("Finished loading. Success: \(success).")
     }
     
     public func didFinishLoading(success: Bool, url: URL) {
-        print("Finished loading. Success: \(success).")
+        //print("Finished loading. Success: \(success).")
     }
     
     public func webDismiss() {
-        print("Web dismiss.")
+        //print("Web dismiss.")
     }
 }
 

+ 1 - 1
iOSClient/Security/CCCertificate.h

@@ -41,7 +41,7 @@
 - (BOOL)acceptCertificate;
 - (void)saveCertificate:(SecTrustRef) trust withName:(NSString *) certName;
 
-- (void)presentViewControllerCertificateWithAccount:(NSString *)account delegate:(id)delegate;
+- (void)presentViewControllerCertificateWithAccount:(NSString *)account viewController:(UIViewController *)viewController delegate:(id)delegate;
 
 @end
 

+ 5 - 2
iOSClient/Security/CCCertificate.m

@@ -140,11 +140,14 @@ static SecCertificateRef SecTrustGetLeafCertificate(SecTrustRef trust)
     X509_free(x509cert);
 }
 
-- (void)presentViewControllerCertificateWithAccount:(NSString *)account delegate:(id)delegate
+- (void)presentViewControllerCertificateWithAccount:(NSString *)account viewController:(UIViewController *)viewController delegate:(id)delegate
 {
     AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     _delegate = delegate;
     
+    if (![viewController isKindOfClass:[UIViewController class]])
+        return;
+    
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
     
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_ssl_certificate_untrusted_", nil) message:NSLocalizedString(@"_connect_server_anyway_", nil)  preferredStyle:UIAlertControllerStyleAlert];
@@ -167,7 +170,7 @@ static SecCertificateRef SecTrustGetLeafCertificate(SecTrustRef trust)
                 [self.delegate trustedCerticateDenied];
         }]];
         
-        [appDelegate.window.rootViewController presentViewController:alertController animated:YES completion:^{
+        [viewController presentViewController:alertController animated:YES completion:^{
             // Stop timer error network
             [appDelegate.timerErrorNetworking invalidate];
         }];