marinofaggiana 5 lat temu
rodzic
commit
95cad7a4a0

+ 2 - 2
iOSClient/Share/NCShare.swift

@@ -156,11 +156,11 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
     
     /// MARK: - NCShareNetworkingDelegate
     
-    func readShareCompleted(errorCode: Int) {
+    func readShareCompleted() {
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil, userInfo: nil)
     }
     
-    func shareCompleted(errorCode: Int) {
+    func shareCompleted() {
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil, userInfo: nil)
     }
     

+ 2 - 2
iOSClient/Share/NCShareLinkMenuView.swift

@@ -248,11 +248,11 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     
     // MARK: - Delegate networking
     
-    func readShareCompleted(errorCode: Int) {
+    func readShareCompleted() {
         reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
     }
     
-    func shareCompleted(errorCode: Int) {
+    func shareCompleted() {
         unLoad()
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil, userInfo: nil)
     }

+ 26 - 4
iOSClient/Share/NCShareNetworking.swift

@@ -50,7 +50,7 @@ class NCShareNetworking: NSObject {
             } else {
                 self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
             }
-            self.delegate?.readShareCompleted(errorCode: errorCode)
+            self.delegate?.readShareCompleted()
         })
     }
     
@@ -67,7 +67,7 @@ class NCShareNetworking: NSObject {
                     } else {
                         self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
                     }
-                    self.delegate?.shareCompleted(errorCode: errorCode)
+                    self.delegate?.shareCompleted()
                 })
             } else {
                 NCUtility.sharedInstance.stopActivityIndicator()
@@ -115,11 +115,33 @@ class NCShareNetworking: NSObject {
             }
         })
     }
+    
+    func shareUserAndGroup(name: String, shareeType: Int, permission: Int, metadata: tableMetadata) {
+        NCUtility.sharedInstance.startActivityIndicator(view: view, bottom: 0)
+        let fileName = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl)!
+        OCNetworking.sharedManager()?.shareUserGroup(withAccount: account, userOrGroup: name, fileName: fileName, permission: permission, shareeType: shareeType, completion: { (account, message, errorCode) in
+            if errorCode == 0 {
+                OCNetworking.sharedManager()?.readShare(withAccount: account, completion: { (account, items, message, errorCode) in
+                    NCUtility.sharedInstance.stopActivityIndicator()
+                    if errorCode == 0 {
+                        let itemsOCSharedDto = items as! [OCSharedDto]
+                        NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
+                    } else {
+                        self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
+                    }
+                    self.delegate?.shareCompleted()
+                })
+            } else {
+                NCUtility.sharedInstance.stopActivityIndicator()
+                self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
+            }
+        })
+    }
 }
 
 protocol NCShareNetworkingDelegate {
-    func readShareCompleted(errorCode: Int)
-    func shareCompleted(errorCode: Int)
+    func readShareCompleted()
+    func shareCompleted()
     func unShareCompleted()
     func updateShareWithError(idRemoteShared: Int)
     func getUserAndGroup(items: [OCShareUser]?)

+ 2 - 2
iOSClient/Share/NCShareUserMenuView.swift

@@ -184,11 +184,11 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     
     // MARK: - Delegate networking
     
-    func readShareCompleted(errorCode: Int) {
+    func readShareCompleted() {
         reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
     }
     
-    func shareCompleted(errorCode: Int) {
+    func shareCompleted() {
         unLoad()
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil, userInfo: nil)
     }