Browse Source

share test

marinofaggiana 4 years ago
parent
commit
7c0026dcb6

+ 1 - 1
iOSClient/CCGlobal.h

@@ -68,7 +68,7 @@
 #define k_flowEndpoint                                  @"/index.php/login/flow"
 
 // Avatar
-#define k_avatar_size                                   128
+#define k_avatar_size                                   129
 
 // Passphrase test EndToEnd Encryption
 #define k_passphrase_test                               @"more over television factory tendency independence international intellectual impress interest sentence pony"

+ 13 - 16
iOSClient/Database/NCDatabase.swift

@@ -361,39 +361,36 @@ class tablePhotoLibrary: Object {
 class tableShare: Object {
     
     @objc dynamic var account = ""
-    @objc dynamic var displayNameFileOwner = ""
-    @objc dynamic var displayNameOwner = ""
-    @objc dynamic var isDirectory: Bool = false
+    @objc dynamic var canEdit: Bool = false
+    @objc dynamic var canDelete: Bool = false
+    @objc dynamic var date: NSDate? = nil
+    @objc dynamic var displaynameFileOwner = ""
+    @objc dynamic var displaynameOwner = ""
     @objc dynamic var expirationDate: NSDate? = nil
     @objc dynamic var fileName = ""
-    @objc dynamic var fileParent = ""
+    @objc dynamic var fileParent: Int = 0
     @objc dynamic var fileSource: Int = 0
     @objc dynamic var fileTarget = ""
     @objc dynamic var hideDownload: Bool = false
-    @objc dynamic var idRemoteShared: Int = 0
+    @objc dynamic var idShare: Int = 0
     @objc dynamic var itemSource: Int = 0
+    @objc dynamic var itemType = ""
     @objc dynamic var label = ""
-    @objc dynamic var mailSend: Int = 0
+    @objc dynamic var mailSend: Bool = false
     @objc dynamic var mimeType = ""
     @objc dynamic var note = ""
-    @objc dynamic var path = ""
     @objc dynamic var parent: Int = 0
+    @objc dynamic var path = ""
     @objc dynamic var permissions: Int = 0
     @objc dynamic var serverUrl = ""
-    @objc dynamic var sharedDate: NSDate? = nil
     @objc dynamic var shareType: Int = 0
     @objc dynamic var shareWith = ""
-    @objc dynamic var shareWithDisplayName = ""
+    @objc dynamic var shareWithDisplayname = ""
     @objc dynamic var storage: Int = 0
-    @objc dynamic var storageID = ""
+    @objc dynamic var storageId = ""
     @objc dynamic var token = ""
-    @objc dynamic var uidOwner = ""
     @objc dynamic var uidFileOwner = ""
-    @objc dynamic var url = ""
-    
-    override static func primaryKey() -> String {
-        return "idRemoteShared"
-    }
+    @objc dynamic var uidOwner = ""
 }
 
 class tableTag: Object {

+ 46 - 46
iOSClient/Database/NCManageDatabase.swift

@@ -99,7 +99,7 @@ class NCManageDatabase: NSObject {
                         migration.deleteData(forType: tableTrash.className())
                     }
                     
-                    if oldSchemaVersion < 120 {
+                    if oldSchemaVersion < 128 {
                         migration.deleteData(forType: tableE2eEncryptionLock.className())
                         migration.deleteData(forType: tableCapabilities.className())
                         migration.deleteData(forType: tableComments.className())
@@ -107,6 +107,10 @@ class NCManageDatabase: NSObject {
                         migration.deleteData(forType: tableDirectory.className())
                     }
                     
+                    if oldSchemaVersion < 129 {
+                        migration.deleteData(forType: tableShare.className())
+                    }
+                    
                 }, shouldCompactOnLaunch: { totalBytes, usedBytes in
                     
                     // totalBytes refers to the size of the file on disk in bytes (data + free space)
@@ -2571,16 +2575,15 @@ class NCManageDatabase: NSObject {
     //MARK: -
     //MARK: Table Share
     
-    #if !EXTENSION
-    @objc func addShare(account: String, activeUrl: String, items: [OCSharedDto]) -> [tableShare] {
+    @objc func addShare(account: String, activeUrl: String, shares: [NCCommunicationShare]) -> [tableShare] {
         
         let realm = try! Realm()
         realm.beginWrite()
 
-        for sharedDto in items {
+        for share in shares {
             
             let addObject = tableShare()
-            let fullPath = CCUtility.getHomeServerUrlActiveUrl(activeUrl) + "\(sharedDto.path!)"
+            let fullPath = CCUtility.getHomeServerUrlActiveUrl(activeUrl) + "/" + share.path
             let fileName = NSString(string: fullPath).lastPathComponent
             var serverUrl = NSString(string: fullPath).substring(to: (fullPath.count - fileName.count - 1))
             if serverUrl.hasSuffix("/") {
@@ -2588,38 +2591,38 @@ class NCManageDatabase: NSObject {
             }
             
             addObject.account = account
-            addObject.displayNameFileOwner = sharedDto.displayNameFileOwner
-            addObject.displayNameOwner = sharedDto.displayNameOwner
-            if sharedDto.expirationDate > 0 {
-                addObject.expirationDate =  Date(timeIntervalSince1970: TimeInterval(sharedDto.expirationDate)) as NSDate
-            }
-            addObject.fileParent = sharedDto.fileParent
-            addObject.fileTarget = sharedDto.fileTarget
-            addObject.hideDownload = sharedDto.hideDownload
-            addObject.idRemoteShared = sharedDto.idRemoteShared
-            addObject.isDirectory = sharedDto.isDirectory
-            addObject.itemSource = sharedDto.itemSource
-            addObject.label = sharedDto.label
-            addObject.mailSend = sharedDto.mailSend
-            addObject.mimeType = sharedDto.mimeType
-            addObject.note = sharedDto.note
-            addObject.path = sharedDto.path
-            addObject.permissions = sharedDto.permissions
-            addObject.parent = sharedDto.parent
-            addObject.sharedDate = Date(timeIntervalSince1970: TimeInterval(sharedDto.sharedDate)) as NSDate
-            addObject.shareType = sharedDto.shareType
-            addObject.shareWith = sharedDto.shareWith
-            addObject.shareWithDisplayName = sharedDto.shareWithDisplayName
-            addObject.storage = sharedDto.storage
-            addObject.storageID = sharedDto.storageID
-            addObject.token = sharedDto.token
-            addObject.url = sharedDto.url
-            addObject.uidOwner = sharedDto.uidOwner
-            addObject.uidFileOwner = sharedDto.uidFileOwner
-            
             addObject.fileName = fileName
             addObject.serverUrl = serverUrl
             
+            addObject.canEdit = share.canEdit
+            addObject.canDelete = share.canDelete
+            addObject.date = share.date
+            addObject.displaynameFileOwner = share.displaynameFileOwner
+            addObject.displaynameOwner = share.displaynameOwner
+            addObject.expirationDate =  share.expirationDate
+            addObject.fileParent = share.fileParent
+            addObject.fileSource = share.fileSource
+            addObject.fileTarget = share.fileTarget
+            addObject.hideDownload = share.hideDownload
+            addObject.idShare = share.idShare
+            addObject.itemSource = share.itemSource
+            addObject.itemType = share.itemType
+            addObject.label = share.label
+            addObject.mailSend = share.mailSend
+            addObject.mimeType = share.mimeType
+            addObject.note = share.note
+            addObject.parent = share.parent
+            addObject.path = share.path
+            addObject.permissions = share.permissions
+            addObject.shareType = share.shareType
+            addObject.shareWith = share.shareWith
+            addObject.shareWithDisplayname = share.shareWithDisplayname
+            addObject.storage = share.storage
+            addObject.storageId = share.storageId
+            addObject.token = share.token
+            addObject.uidOwner = share.uidOwner
+            addObject.uidFileOwner = share.uidFileOwner
+            
             realm.add(addObject, update: .all)
         }
         
@@ -2631,20 +2634,18 @@ class NCManageDatabase: NSObject {
         
         return self.getTableShares(account: account)
     }
-    #endif
     
     @objc func getTableShares(account: String) -> [tableShare] {
         
         let realm = try! Realm()
         realm.refresh()
         
-        let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idRemoteShared", ascending: false)]
+        let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idShare", ascending: false)]
         let results = realm.objects(tableShare.self).filter("account == %@", account).sorted(by: sortProperties)
         
         return Array(results.map { tableShare.init(value:$0) })
     }
     
-    #if !EXTENSION
     func getTableShares(metadata: tableMetadata) -> (firstShareLink: tableShare?,  share: [tableShare]?) {
         
         let realm = try! Realm()
@@ -2652,23 +2653,22 @@ class NCManageDatabase: NSObject {
         
         let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idRemoteShared", ascending: false)]
         
-        let firstShareLink = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND shareType == %d", metadata.account, metadata.serverUrl, metadata.fileName, Int(shareTypeLink.rawValue)).first
+        let firstShareLink = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND shareType == 3", metadata.account, metadata.serverUrl, metadata.fileName).first
         if firstShareLink == nil {
             let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", metadata.account, metadata.serverUrl, metadata.fileName).sorted(by: sortProperties)
             return(firstShareLink: firstShareLink, share: Array(results.map { tableShare.init(value:$0) }))
         } else {
-            let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND idRemoteShared != %d", metadata.account, metadata.serverUrl, metadata.fileName, firstShareLink!.idRemoteShared).sorted(by: sortProperties)
+            let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND idShare != %d", metadata.account, metadata.serverUrl, metadata.fileName, firstShareLink!.idShare).sorted(by: sortProperties)
             return(firstShareLink: firstShareLink, share: Array(results.map { tableShare.init(value:$0) }))
         }
     }
-    #endif
     
-    func getTableShare(account: String, idRemoteShared: Int) -> tableShare? {
+    func getTableShare(account: String, idShare: Int) -> tableShare? {
         
         let realm = try! Realm()
         realm.refresh()
         
-        guard let result = realm.objects(tableShare.self).filter("account = %@ AND idRemoteShared = %d", account, idRemoteShared).first else {
+        guard let result = realm.objects(tableShare.self).filter("account = %@ AND idShare = %d", account, idShare).first else {
             return nil
         }
         
@@ -2680,7 +2680,7 @@ class NCManageDatabase: NSObject {
         let realm = try! Realm()
         realm.refresh()
         
-        let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idRemoteShared", ascending: false)]
+        let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idShare", ascending: false)]
         let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@", account, serverUrl).sorted(by: sortProperties)
 
         return Array(results.map { tableShare.init(value:$0) })
@@ -2691,19 +2691,19 @@ class NCManageDatabase: NSObject {
         let realm = try! Realm()
         realm.refresh()
         
-        let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idRemoteShared", ascending: false)]
+        let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idShare", ascending: false)]
         let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", account, serverUrl, fileName).sorted(by: sortProperties)
         
         return Array(results.map { tableShare.init(value:$0) })
     }
     
-    @objc func deleteTableShare(account: String, idRemoteShared: Int) {
+    @objc func deleteTableShare(account: String, idShare: Int) {
         
         let realm = try! Realm()
         
         realm.beginWrite()
         
-        let result = realm.objects(tableShare.self).filter("account == %@ AND idRemoteShared == %d", account, idRemoteShared)
+        let result = realm.objects(tableShare.self).filter("account == %@ AND idShare == %d", account, idShare)
         realm.delete(result)
         
         do {

+ 9 - 10
iOSClient/Networking/NCService.swift

@@ -161,18 +161,17 @@ class NCService: NSObject {
                 let isFilesSharingEnabled = NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
                 if (isFilesSharingEnabled && self.appDelegate.activeMain != nil) {
                     
-                    OCNetworking.sharedManager()?.readShare(withAccount: account, completion: { (account, items, message, errorCode) in
-                        if errorCode == 0 && account == self.appDelegate.activeAccount {
-                            
-                            let itemsOCSharedDto = items as! [OCSharedDto]
-                            NCManageDatabase.sharedInstance.deleteTableShare(account: account!)
-                            self.appDelegate.shares = NCManageDatabase.sharedInstance.addShare(account: account!, activeUrl: self.appDelegate.activeUrl, items: itemsOCSharedDto)
-                            
+                    NCCommunication.shared.readShares { (account, shares, errorCode, ErrorDescription) in
+                        if errorCode == 0 {
+                            NCManageDatabase.sharedInstance.deleteTableShare(account: account)
+                            if shares != nil {
+//                                self.appDelegate.shares
+                                _ = NCManageDatabase.sharedInstance.addShare(account: account, activeUrl: self.appDelegate.activeUrl, shares: shares!)
+                            }
                         } else {
-                            
-                            NCContentPresenter.shared.messageNotification("_share_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                            NCContentPresenter.shared.messageNotification("_share_", description: ErrorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
                         }
-                    })
+                    }
                 }
             
                 // NCTextObtainEditorDetails

+ 1 - 1
iOSClient/Networking/OCNetworking.h

@@ -38,7 +38,7 @@
 
 #pragma mark ===== Share =====
 
-- (void)readShareWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSArray *items, NSString *message, NSInteger errorCode))completion;
+//- (void)readShareWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSArray *items, NSString *message, NSInteger errorCode))completion;
 - (void)readShareWithAccount:(NSString *)account path:(NSString *)path completion:(void (^)(NSString *account, NSArray *items, NSString *message, NSInteger errorCode))completion;
 - (void)shareWithAccount:(NSString *)account fileName:(NSString *)fileName password:(NSString *)password permission:(NSInteger)permission hideDownload:(BOOL)hideDownload completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 - (void)shareUserGroupWithAccount:(NSString *)account userOrGroup:(NSString *)userOrGroup fileName:(NSString *)fileName permission:(NSInteger)permission shareeType:(NSInteger)shareeType completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;

+ 2 - 2
iOSClient/Share/NCShare.swift

@@ -203,7 +203,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
             permission = UtilsFramework.getPermissionsValue(byCanEdit: false, andCanCreate: false, andCanChange: false, andCanDelete: false, andCanShare: canShare, andIsFolder: metadata.directory)
         }
         
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     func tapMenu(with tableShare: tableShare?, sender: Any) {
@@ -361,7 +361,7 @@ extension NCShare: UITableViewDataSource {
                 
                 cell.tableShare = tableShare
                 cell.delegate = self
-                cell.labelTitle.text = tableShare.shareWithDisplayName
+                cell.labelTitle.text = tableShare.shareWithDisplayname
                 cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
                 cell.labelCanEdit.text = NSLocalizedString("_share_permission_edit_", comment: "")
                 cell.labelCanEdit.textColor = NCBrandColor.sharedInstance.textView

+ 4 - 4
iOSClient/Share/NCShareCommon.swift

@@ -75,7 +75,7 @@ class NCShareCommon: NSObject {
         shareLinkMenuView.metadata = metadata
         shareLinkMenuView.viewWindow = viewWindow
         shareLinkMenuView.shareViewController = shareViewController
-        shareLinkMenuView.reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
+        shareLinkMenuView.reloadData(idShare: tableShare?.idShare ?? 0)
         shareLinkMenuView.translatesAutoresizingMaskIntoConstraints = false
         viewWindow.addSubview(shareLinkMenuView)
         
@@ -119,7 +119,7 @@ class NCShareCommon: NSObject {
         shareUserMenuView.metadata = metadata
         shareUserMenuView.viewWindow = viewWindow
         shareUserMenuView.shareViewController = shareViewController
-        shareUserMenuView.reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
+        shareUserMenuView.reloadData(idShare: tableShare?.idShare ?? 0)
         shareUserMenuView.translatesAutoresizingMaskIntoConstraints = false
         viewWindow.addSubview(shareUserMenuView)
 
@@ -183,8 +183,8 @@ class NCShareCommon: NSObject {
         
         if tableShare.token.hasPrefix("http://") || tableShare.token.hasPrefix("https://") {
             url = tableShare.token
-        } else if tableShare.url != "" {
-            url = tableShare.url
+        } else if tableShare.path != "" {
+            url = tableShare.path
         } else {
             url = appDelegate.activeUrl + "/" + k_share_link_middle_part_url_after_version_8 + tableShare.token
         }

+ 17 - 17
iOSClient/Share/NCShareLinkMenuView.swift

@@ -146,10 +146,10 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         viewWindow = nil
     }
     
-    func reloadData(idRemoteShared: Int) {
+    func reloadData(idShare: Int) {
         
         guard let metadata = self.metadata else { return }
-        tableShare = NCManageDatabase.sharedInstance.getTableShare(account: metadata.account, idRemoteShared: idRemoteShared)
+        tableShare = NCManageDatabase.sharedInstance.getTableShare(account: metadata.account, idShare: idShare)
         guard let tableShare = self.tableShare else { return }
 
         if metadata.directory {
@@ -223,7 +223,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         calendar = nil
         viewWindowCalendar = nil
         
-        reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
+        reloadData(idShare: tableShare?.idShare ?? 0)
     }
     
     func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
@@ -246,7 +246,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             permission = UtilsFramework.getPermissionsValue(byCanEdit: false, andCanCreate: false, andCanChange: false, andCanDelete: false, andCanShare: false, andIsFolder: metadata.directory)
         }
         
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     // Read Only (directory)
@@ -259,7 +259,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         if sender.isOn && permission != tableShare.permissions {
             switchAllowUploadAndEditing.setOn(false, animated: false)
             switchFileDrop.setOn(false, animated: false)
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+//            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
         } else {
             sender.setOn(true, animated: false)
         }
@@ -275,7 +275,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         if sender.isOn && permission != tableShare.permissions {
             switchReadOnly.setOn(false, animated: false)
             switchFileDrop.setOn(false, animated: false)
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+//            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
         } else {
             sender.setOn(true, animated: false)
         }
@@ -290,7 +290,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         if sender.isOn && permission != tableShare.permissions {
             switchReadOnly.setOn(false, animated: false)
             switchAllowUploadAndEditing.setOn(false, animated: false)
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+//            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
         } else {
             sender.setOn(true, animated: false)
         }
@@ -301,7 +301,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         
         guard let tableShare = self.tableShare else { return }
 
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: nil, hideDownload: sender.isOn)
+//        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: nil, hideDownload: sender.isOn)
     }
     
     // Password protect
@@ -314,7 +314,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             fieldPasswordProtect.text = ""
             fieldPasswordProtect.becomeFirstResponder()
         } else {
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: "", permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+//            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: "", permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
         }
     }
     
@@ -322,7 +322,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         
         guard let tableShare = self.tableShare else { return }
 
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: fieldPasswordProtect.text, permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+//        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: fieldPasswordProtect.text, permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     // Set expiration date
@@ -334,7 +334,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             fieldSetExpirationDate.isEnabled = true
             fieldSetExpirationDate(sender: fieldSetExpirationDate)
         } else {
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload)
+//            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload)
         }
     }
     
@@ -356,7 +356,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         guard let tableShare = self.tableShare else { return }
         if fieldNoteToRecipient.text == nil { return }
         
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload)
+//        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     // Delete share link
@@ -364,7 +364,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         
         guard let tableShare = self.tableShare else { return }
         
-        networking?.unShare(idRemoteShared: tableShare.idRemoteShared)
+//        networking?.unShare(idRemoteShared: tableShare.idRemoteShared)
     }
     
     // Add another link
@@ -376,7 +376,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     // MARK: - Delegate networking
     
     func readShareCompleted() {
-        reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
+        reloadData(idShare: tableShare?.idShare ?? 0)
     }
     
     func shareCompleted() {
@@ -389,8 +389,8 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
     }
     
-    func updateShareWithError(idRemoteShared: Int) {
-        reloadData(idRemoteShared: idRemoteShared)
+    func updateShareWithError(idShare: Int) {
+        reloadData(idShare: idShare)
     }
     
     func getUserAndGroup(items: [OCShareUser]?) { }
@@ -414,7 +414,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
 
             dateFormatter.dateFormat = "YYYY-MM-dd"
             let expirationTime = dateFormatter.string(from: date)
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload)
+//            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload)
         }
     }
     

+ 14 - 14
iOSClient/Share/NCShareNetworking.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import Foundation
+import NCCommunication
 
 class NCShareNetworking: NSObject {
     
@@ -42,18 +43,17 @@ class NCShareNetworking: NSObject {
     
     func readShare() {
         NCUtility.sharedInstance.startActivityIndicator(view: view)
-        OCNetworking.sharedManager()?.readShare(withAccount: metadata.account, path: CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl), completion: { (account, items, message, errorCode) in
+        NCCommunication.shared.readShares(path: CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl)) { (account, shares, errorCode, errorDescription) in
             NCUtility.sharedInstance.stopActivityIndicator()
-            if errorCode == 0 {
-                let itemsOCSharedDto = items as! [OCSharedDto]
-                self.appDelegate.shares = NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
+             if errorCode == 0 && shares != nil {
+                self.appDelegate.shares = NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, shares: shares!)
                 self.appDelegate.activeMain?.tableView?.reloadData()
                 self.appDelegate.activeFavorites?.tableView?.reloadData()
             } else {
-                NCContentPresenter.shared.messageNotification("_share_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
+                NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
             }
             self.delegate?.readShareCompleted()
-        })
+        }
     }
     
     func share(password: String, permission: Int, hideDownload: Bool) {
@@ -80,20 +80,20 @@ class NCShareNetworking: NSObject {
         })
     }
     
-    func unShare(idRemoteShared: Int) {
+    func unShare(idShare: Int) {
         NCUtility.sharedInstance.startActivityIndicator(view: view)
-        OCNetworking.sharedManager()?.unshareAccount(metadata.account, shareID: idRemoteShared, completion: { (account, message, errorCode) in
+        NCCommunication.shared.deleteShare(idShare: idShare) { (account, errorCode, errorDescription) in
             NCUtility.sharedInstance.stopActivityIndicator()
             if errorCode == 0 {
-                NCManageDatabase.sharedInstance.deleteTableShare(account: account!, idRemoteShared: idRemoteShared)
+                NCManageDatabase.sharedInstance.deleteTableShare(account: account, idShare: idShare)
                 self.delegate?.unShareCompleted()
             } else {
-                NCContentPresenter.shared.messageNotification("_share_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
+                NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
             }
-        })
+        }
     }
     
-    func updateShare(idRemoteShared: Int, password: String?, permission: Int, note: String?, expirationTime: String?, hideDownload: Bool) {
+    func updateShare(idShare: Int, password: String?, permission: Int, note: String?, expirationTime: String?, hideDownload: Bool) {
         NCUtility.sharedInstance.startActivityIndicator(view: view)
         OCNetworking.sharedManager()?.shareUpdateAccount(metadata.account, shareID: idRemoteShared, password: password, note:note, permission: permission, expirationTime: expirationTime, hideDownload: hideDownload, completion: { (account, message, errorCode) in
             NCUtility.sharedInstance.stopActivityIndicator()
@@ -101,7 +101,7 @@ class NCShareNetworking: NSObject {
                 self.readShare()
             } else {
                 NCContentPresenter.shared.messageNotification("_share_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
-                self.delegate?.updateShareWithError(idRemoteShared: idRemoteShared)
+                self.delegate?.updateShareWithError(idShare: idShare)
             }
         })
     }
@@ -151,6 +151,6 @@ protocol NCShareNetworkingDelegate {
     func readShareCompleted()
     func shareCompleted()
     func unShareCompleted()
-    func updateShareWithError(idRemoteShared: Int)
+    func updateShareWithError(idShare: Int)
     func getUserAndGroup(items: [OCShareUser]?)
 }

+ 14 - 14
iOSClient/Share/NCShareUserMenuView.swift

@@ -124,10 +124,10 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         viewWindow = nil
     }
     
-    func reloadData(idRemoteShared: Int) {
+    func reloadData(idShare: Int) {
         
         guard let metadata = self.metadata else { return }
-        tableShare = NCManageDatabase.sharedInstance.getTableShare(account: metadata.account, idRemoteShared: idRemoteShared)
+        tableShare = NCManageDatabase.sharedInstance.getTableShare(account: metadata.account, idShare: idShare)
         guard let tableShare = self.tableShare else { return }
 
         // Can reshare (file)
@@ -175,7 +175,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         calendar = nil
         viewWindowCalendar = nil
         
-        reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
+        reloadData(idShare: tableShare?.idShare ?? 0)
     }
     
     func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
@@ -215,7 +215,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             }
         }
         
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     @IBAction func switchCanCreate(sender: UISwitch) {
@@ -230,7 +230,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
 
         let permission = UtilsFramework.getPermissionsValue(byCanEdit: canEdit, andCanCreate: sender.isOn, andCanChange: canChange, andCanDelete: canDelete, andCanShare: canShare, andIsFolder: metadata.directory)
 
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     @IBAction func switchCanChange(sender: UISwitch) {
@@ -245,7 +245,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         
         let permission = UtilsFramework.getPermissionsValue(byCanEdit: canEdit, andCanCreate: canCreate, andCanChange: sender.isOn, andCanDelete: canDelete, andCanShare: canShare, andIsFolder: metadata.directory)
 
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     @IBAction func switchCanDelete(sender: UISwitch) {
@@ -260,7 +260,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         
         let permission = UtilsFramework.getPermissionsValue(byCanEdit: canEdit, andCanCreate: canCreate, andCanChange: canChange, andCanDelete: sender.isOn, andCanShare: canShare, andIsFolder: metadata.directory)
 
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     // Set expiration date
@@ -272,7 +272,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             fieldSetExpirationDate.isEnabled = true
             fieldSetExpirationDate(sender: fieldSetExpirationDate)
         } else {
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload)
+            //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload)
         }
     }
     
@@ -294,7 +294,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         guard let tableShare = self.tableShare else { return }
         if fieldNoteToRecipient.text == nil { return }
         
-        networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
     // Unshare
@@ -302,13 +302,13 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         
         guard let tableShare = self.tableShare else { return }
         
-        networking?.unShare(idRemoteShared: tableShare.idRemoteShared)
+        //networking?.unShare(idRemoteShared: tableShare.idRemoteShared)
     }
     
     // MARK: - Delegate networking
     
     func readShareCompleted() {
-        reloadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
+        reloadData(idShare: tableShare?.idShare ?? 0)
     }
     
     func shareCompleted() {
@@ -321,8 +321,8 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataNCShare), object: nil, userInfo: nil)
     }
     
-    func updateShareWithError(idRemoteShared: Int) {
-        reloadData(idRemoteShared: idRemoteShared)
+    func updateShareWithError(idShare: Int) {
+        reloadData(idShare: idShare)
     }
     
     func getUserAndGroup(items: [OCShareUser]?) { }
@@ -346,7 +346,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             
             dateFormatter.dateFormat = "YYYY-MM-dd"
             let expirationTime = dateFormatter.string(from: date)
-            networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload)
+            //networking?.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload)
         }
     }