marinofaggiana преди 4 години
родител
ревизия
0342da04ee

+ 17 - 3
iOSClient/AppDelegate.swift

@@ -76,7 +76,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     
     // MARK: -
 
-    func openLoginView(viewController: UIViewController, selector: Int, openLoginWeb: Bool) {
+    func openLoginView(viewController: UIViewController?, selector: Int, openLoginWeb: Bool) {
         
     }
 
@@ -89,13 +89,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         if account == "" { return }
         
         // check unauthorized server (401)
-        if CCUtility.getPasscode()?.cont == 0 {
-            openLoginView(viewController: window.rootViewController, selector: NCBrandGlobal.shared.introLogin, openLoginWeb: true)
+        if CCUtility.getPasscode()?.count == 0 {
+            openLoginView(viewController: window?.rootViewController, selector: NCBrandGlobal.shared.introLogin, openLoginWeb: true)
         }
         
         // check certificate untrusted (-1202)
         if CCUtility.getCertificateError(account) {
             
+            let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_untrusted_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
+                        
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
+                NCNetworking.shared.writeCertificate(directoryCertificate: CCUtility.getDirectoryCerificates())
+                self.startTimerErrorNetworking()
+            }))
+            
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .default, handler: { action in
+                self.startTimerErrorNetworking()
+            }))
+            
+            window?.rootViewController?.present(alertController, animated: true, completion: {
+                self.timerErrorNetworking?.invalidate()
+            })
         }
     }
     

+ 4 - 5
iOSClient/Brand/Intro/NCIntroViewController.swift

@@ -34,6 +34,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
     @IBOutlet weak var pageControl: UIPageControl!
 
     @objc var delegate: NCIntroViewController?
+    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private let titles = [NSLocalizedString("_intro_1_title_", comment: ""), NSLocalizedString("_intro_2_title_", comment: ""), NSLocalizedString("_intro_3_title_", comment: ""), NSLocalizedString("_intro_4_title_", comment: "")]
     private let images = [UIImage(named: "intro1"), UIImage(named: "intro2"), UIImage(named: "intro3"), UIImage(named: "intro4")]
     private var timerAutoScroll: Timer?
@@ -163,22 +164,20 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
     }
 
     @IBAction func login(_ sender: Any) {
-        (UIApplication.shared.delegate as! AppDelegate).openLoginView(navigationController, selector: NCBrandGlobal.shared.introLogin, openLoginWeb: false)
+        appDelegate.openLoginView(viewController: navigationController, selector: NCBrandGlobal.shared.introLogin, openLoginWeb: false)
     }
 
     @IBAction func signup(_ sender: Any) {
-        (UIApplication.shared.delegate as! AppDelegate).openLoginView(navigationController, selector: NCBrandGlobal.shared.introSignup, openLoginWeb: false)
+        appDelegate.openLoginView(viewController: navigationController, selector: NCBrandGlobal.shared.introSignup, openLoginWeb: false)
     }
 
     @IBAction func host(_ sender: Any) {
-        let appDelegate = UIApplication.shared.delegate as? AppDelegate
-
         let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as? NCBrowserWeb
 
         browserWebVC?.urlBase = NCBrandOptions.shared.linkLoginHost
 
         if let browserWebVC = browserWebVC {
-            appDelegate?.window.rootViewController?.present(browserWebVC, animated: true)
+            appDelegate.window?.rootViewController?.present(browserWebVC, animated: true)
         }
     }
 }

+ 2 - 2
iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -458,9 +458,9 @@ extension NCCollectionViewCommon {
                 title: NSLocalizedString("_copy_file_", comment: ""),
                 icon: UIImage(named: "copy")!.image(color: NCBrandColor.shared.icon, size: 50),
                 action: { menuAction in
-                    self.appDelegate.pasteboardOcIds.removeAllObjects()
+                    self.appDelegate.pasteboardOcIds.removeAll()
                     for ocId in selectOcId {
-                        self.appDelegate.pasteboardOcIds.add(ocId)
+                        self.appDelegate.pasteboardOcIds.append(ocId)
                     }
                     NCCollectionCommon.shared.copyPasteboard()
                     self.tapSelect(sender: self)

+ 2 - 2
iOSClient/Networking/NCNetworking.swift

@@ -183,7 +183,7 @@ import Queuer
         return trusted
     }
     
-    @objc func wrtiteCertificate(directoryCertificate: String) {
+    @objc func writeCertificate(directoryCertificate: String) {
         
         let stringDate: String = String(Date().timeIntervalSince1970)
         let certificateAtPath = directoryCertificate + "/tmp.der"
@@ -525,7 +525,7 @@ import Queuer
                 self.getOcIdInBackgroundSession { (listOcId) in
                     if listOcId.count == 0 && self.uploadRequest.count == 0 {
                         let appDelegate = UIApplication.shared.delegate as! AppDelegate
-                        appDelegate.networkingAutoUpload.startProcess()
+                        appDelegate.networkingAutoUpload?.startProcess()
                     }
                 }
                 CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensMode) in };

+ 1 - 2
iOSClient/ScanDocument/ScanCollectionView.swift

@@ -33,7 +33,6 @@ class DragDropViewController: UIViewController {
     private var imagesDestination: [UIImage] = []
     private var itemsDestination: [String] = []
     
-    //AppDelegate
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
     //MARK: Outlets
@@ -117,7 +116,7 @@ class DragDropViewController: UIViewController {
         if imagesDestination.count > 0 {
             
             var images: [UIImage] = []
-            var serverUrl = appDelegate.activeServerUrl!
+            var serverUrl = appDelegate.activeServerUrl
 
             for image in imagesDestination {
                 images.append(filter(image: image)!)