瀏覽代碼

Add message warning for ownCloud and for unsupported Nextcloud

Marino Faggiana 6 年之前
父節點
當前提交
4f93127de9
共有 3 個文件被更改,包括 29 次插入7 次删除
  1. 4 0
      iOSClient/CCGlobal.h
  2. 24 7
      iOSClient/Networking/NCService.swift
  3. 1 0
      iOSClient/Supporting Files/en.lproj/Localizable.strings

+ 4 - 0
iOSClient/CCGlobal.h

@@ -297,6 +297,10 @@
 #define k_action_MOD                                    1
 #define k_action_DEL                                    2
 
+// Nextcloud unsupported
+#define k_nextcloud_unsupported                         12
+
+
 // -----------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------
 

+ 24 - 7
iOSClient/Networking/NCService.swift

@@ -44,12 +44,13 @@ class NCService: NSObject, OCNetworkingDelegate {
         self.requestUserProfile()
         self.requestServerCapabilities()
         self.requestActivityServer()
+        self.requestServerStatus()
     }
 
     //MARK: -
     //MARK: Internal request Service API NC
     
-    @objc private func requestServerCapabilities() {
+    private func requestServerCapabilities() {
         
         if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
             return
@@ -63,7 +64,7 @@ class NCService: NSObject, OCNetworkingDelegate {
         appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
     }
     
-    @objc private func requestUserProfile() {
+    private func requestUserProfile() {
         
         if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
             return
@@ -77,7 +78,7 @@ class NCService: NSObject, OCNetworkingDelegate {
         appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
     }
     
-    @objc private func requestActivityServer() {
+    private func requestActivityServer() {
         
         if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) {
             return
@@ -107,6 +108,22 @@ class NCService: NSObject, OCNetworkingDelegate {
         //appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
     }
     
+    private func requestServerStatus() {
+
+        let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
+        ocNetworking?.serverStatus(appDelegate.activeUrl, success: { (serverProductName, versionMajor, versionMicro, versionMinor) in
+            
+            if serverProductName == "owncloud" {
+                self.appDelegate.messageNotification("_warning_", description: "_warning_owncloud_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: Int(k_CCErrorInternalError))
+            } else if versionMajor <= k_nextcloud_unsupported {
+                self.appDelegate.messageNotification("_warning_", description: "_warning_unsupported_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: Int(k_CCErrorInternalError))
+            }
+            
+        }, failure: { (message, errorCode) in
+            //
+        })
+    }
+    
     //MARK: -
     //MARK: Delegate Service API NC
     
@@ -220,7 +237,7 @@ class NCService: NSObject, OCNetworkingDelegate {
         }
     }
     
-    @objc func getUserProfileSuccessFailure(_ metadataNet: CCMetadataNet!, userProfile: OCUserProfile?, message: String?, errorCode: Int) {
+   func getUserProfileSuccessFailure(_ metadataNet: CCMetadataNet!, userProfile: OCUserProfile?, message: String?, errorCode: Int) {
         
         // Check Active Account
         if (metadataNet.account != appDelegate.activeAccount) {
@@ -286,7 +303,7 @@ class NCService: NSObject, OCNetworkingDelegate {
         }
     }
     
-    @objc func getExternalSitesServerSuccessFailure(_ metadataNet: CCMetadataNet!, listOfExternalSites: [Any]?, message: String?, errorCode: Int) {
+    func getExternalSitesServerSuccessFailure(_ metadataNet: CCMetadataNet!, listOfExternalSites: [Any]?, message: String?, errorCode: Int) {
         
         // Check Active Account
         if (metadataNet.account != appDelegate.activeAccount) {
@@ -313,7 +330,7 @@ class NCService: NSObject, OCNetworkingDelegate {
         }
     }
     
-    @objc func getActivityServerSuccessFailure(_ metadataNet: CCMetadataNet!, listOfActivity: [Any]?, message: String?, errorCode: Int) {
+    func getActivityServerSuccessFailure(_ metadataNet: CCMetadataNet!, listOfActivity: [Any]?, message: String?, errorCode: Int) {
         
         // Check Active Account
         if (metadataNet.account != appDelegate.activeAccount) {
@@ -340,7 +357,7 @@ class NCService: NSObject, OCNetworkingDelegate {
         }
     }
     
-    @objc func getNotificationServerSuccessFailure(_ metadataNet: CCMetadataNet!, listOfNotifications: [Any]?, message: String?, errorCode: Int) {
+    func getNotificationServerSuccessFailure(_ metadataNet: CCMetadataNet!, listOfNotifications: [Any]?, message: String?, errorCode: Int) {
     
         // Check Active Account
         if (metadataNet.account != appDelegate.activeAccount) {

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -62,6 +62,7 @@
 "_scan_fingerprint_"        = "Scan fingerprint to authenticate";
 "_no_active_account_"       = "No account found";
 "_info_"                    = "Info";
+"_warning_"                 = "Warning";
 "_email_"                   = "Email";
 "_save_exit_"               = "Do you want to exit without saving?";
 "_video_"                   = "Video";