marinofaggiana %!s(int64=4) %!d(string=hai) anos
pai
achega
09c3a0ff8f
Modificáronse 2 ficheiros con 96 adicións e 0 borrados
  1. 4 0
      Nextcloud.xcodeproj/project.pbxproj
  2. 92 0
      iOSClient/Login/NCLogin.swift

+ 4 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -282,6 +282,7 @@
 		F7C40BF32199978B0004137E /* MBProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7C40BF22199978B0004137E /* MBProgressHUD.framework */; };
 		F7C4D88D2534887E00C142DA /* Parchment in Frameworks */ = {isa = PBXBuildFile; productRef = F7C4D88C2534887E00C142DA /* Parchment */; };
 		F7C7B489245EBA4100D93E60 /* NCViewerQuickLook.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */; };
+		F7C91C9925E6946D005D2490 /* NCLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C91C9825E6946D005D2490 /* NCLogin.swift */; };
 		F7C9322625E39D4A000A14C2 /* NCGlobal.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C9322525E39D4A000A14C2 /* NCGlobal.swift */; };
 		F7C9322725E39D4A000A14C2 /* NCGlobal.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C9322525E39D4A000A14C2 /* NCGlobal.swift */; };
 		F7C9322825E39D4A000A14C2 /* NCGlobal.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C9322525E39D4A000A14C2 /* NCGlobal.swift */; };
@@ -658,6 +659,7 @@
 		F7C742C01E7BD01F00D9C973 /* iOSClient.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = iOSClient.entitlements; sourceTree = "<group>"; };
 		F7C742D01E7BD35B00D9C973 /* Share.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Share.entitlements; sourceTree = "<group>"; };
 		F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerQuickLook.swift; sourceTree = "<group>"; };
+		F7C91C9825E6946D005D2490 /* NCLogin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCLogin.swift; sourceTree = "<group>"; };
 		F7C9322525E39D4A000A14C2 /* NCGlobal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCGlobal.swift; sourceTree = "<group>"; };
 		F7C9555221F0C4CA0024296E /* NCActivity.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCActivity.storyboard; sourceTree = "<group>"; };
 		F7C9555421F0C5470024296E /* NCActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivity.swift; sourceTree = "<group>"; };
@@ -1240,6 +1242,7 @@
 				F7BF1B3F1D51E893000854F6 /* CCLogin.h */,
 				F7BF1B401D51E893000854F6 /* CCLogin.m */,
 				F7DBC37B23325E01001A85BA /* NCAppConfigView.swift */,
+				F7C91C9825E6946D005D2490 /* NCLogin.swift */,
 				F7AE00F4230D5F9E007ACF8A /* NCLoginWeb.swift */,
 				F745B252222D88AE00346520 /* NCLoginQRCode.swift */,
 			);
@@ -2076,6 +2079,7 @@
 				F749C10B23C4A5340027D966 /* NCIntroCollectionViewCell.swift in Sources */,
 				F718C24E254D507B00C5C256 /* NCViewerImageDetailView.swift in Sources */,
 				F7381EE1218218C9000B1560 /* NCOffline.swift in Sources */,
+				F7C91C9925E6946D005D2490 /* NCLogin.swift in Sources */,
 				F78071091EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */,
 				F765F73125237E3F00391DBE /* NCRecent.swift in Sources */,
 				F76B3CCE1EAE01BD00921AC9 /* NCBrand.swift in Sources */,

+ 92 - 0
iOSClient/Login/NCLogin.swift

@@ -0,0 +1,92 @@
+//
+//  NCLogin.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 24/02/21.
+//  Copyright © 2021 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import Foundation
+import NCCommunication
+
+class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
+    
+    @IBOutlet weak var imageBrand: UIImageView!
+    
+    @IBOutlet weak var baseUrl: UITextField!
+    @IBOutlet weak var user: UITextField!
+    @IBOutlet weak var password: UITextField!
+
+    @IBOutlet weak var imageBaseUrl: UIImageView!
+    @IBOutlet weak var imageUser: UIImageView!
+    @IBOutlet weak var imagePassword: UIImageView!
+
+    @IBOutlet weak var activity: UIActivityIndicatorView!
+
+    @IBOutlet weak var login: UIButton!
+    @IBOutlet weak var toggleVisiblePassword: UIButton!
+    @IBOutlet weak var loginTypeView: UIButton!
+    
+    @IBOutlet weak var qrCode: UIButton!
+
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
+
+    // MARK: - Life Cycle
+
+    
+    
+    // MARK: - QRCode
+
+    func dismissQRCode(_ value: String?, metadataType: String?) {
+        
+        guard var value = value else { return }
+        
+        let protocolLogin = NCBrandOptions.shared.webLoginAutenticationProtocol + "login/"
+        
+        if value.hasPrefix("protocolLogin") && value.contains("user:") && value.contains("password:") && value.contains("server:") {
+            
+            value = value.replacingOccurrences(of: protocolLogin, with: "")
+            let valueArray = value.components(separatedBy: "&")
+            if valueArray.count == 3 {
+                user.text = valueArray[0].replacingOccurrences(of: "user:", with: "")
+                password.text = valueArray[1].replacingOccurrences(of: "password:", with: "")
+                baseUrl.text = valueArray[2].replacingOccurrences(of: "server:", with: "")
+                
+                // Check whether baseUrl contain protocol. If not add https:// by default.
+                if (baseUrl.text?.hasPrefix("https") ?? false) == false && (baseUrl.text?.hasPrefix("http") ?? false) == false {
+                    self.baseUrl.text = "https://" + (self.baseUrl.text ?? "")
+                }
+                
+                login.isEnabled = false
+                activity.startAnimating()
+                
+                let webDAV = NCUtilityFileSystem.shared.getWebDAV(account: appDelegate.account)
+                let serverUrl = (baseUrl.text ?? "") + "/" + webDAV
+                
+                NCCommunication.shared.checkServer(serverUrl: serverUrl) { (errorCode, errorDescription) in
+                    
+                    self.activity.stopAnimating()
+                    self.login.isEnabled = true
+                    
+                    // [self afterLoginWithUrl:url user:user token:token errorCode:errorCode message:errorDescription];
+                }
+            }
+        }
+    }
+}