|
@@ -20,6 +20,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
import Foundation
|
|
|
import NCCommunication
|
|
|
|
|
@@ -48,8 +50,6 @@ class NCShareNetworking: NSObject {
|
|
|
if errorCode == 0 && shares != nil {
|
|
|
NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, shares: shares!)
|
|
|
self.appDelegate.shares = NCManageDatabase.sharedInstance.getTableShares(account: self.metadata.account)
|
|
|
- self.appDelegate.activeMain?.tableView?.reloadData()
|
|
|
- self.appDelegate.activeFavorites?.tableView?.reloadData()
|
|
|
} else {
|
|
|
NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
|
|
|
}
|
|
@@ -57,7 +57,7 @@ class NCShareNetworking: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func shareLink(password: String?) {
|
|
|
+ func createShareLink(password: String?) {
|
|
|
NCUtility.sharedInstance.startActivityIndicator(view: view)
|
|
|
let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl)!
|
|
|
NCCommunication.shared.createShareLink(path: filenamePath, password: password) { (account, share, errorCode, errorDescription) in
|
|
@@ -65,7 +65,6 @@ class NCShareNetworking: NSObject {
|
|
|
if errorCode == 0 && share != nil {
|
|
|
NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, shares: [share!])
|
|
|
self.appDelegate.shares = NCManageDatabase.sharedInstance.getTableShares(account: self.metadata.account)
|
|
|
- NotificationCenter.default.postOnMainThread(name: k_notificationCenter_reloadDataSource, userInfo: ["serverUrl":self.metadata.serverUrl])
|
|
|
} else if errorCode != 0 {
|
|
|
NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
|
|
|
}
|
|
@@ -73,6 +72,22 @@ class NCShareNetworking: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func createShare(name: String, shareType: Int, metadata: tableMetadata) {
|
|
|
+ NCUtility.sharedInstance.startActivityIndicator(view: view)
|
|
|
+ let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl)!
|
|
|
+ var permission: Int = 1
|
|
|
+ if metadata.directory { permission = Int(k_max_folder_share_permission) } else { permission = Int(k_max_file_share_permission) }
|
|
|
+ NCCommunication.shared.createShare(path: filenamePath, shareType: shareType, shareWith: name, permissions: permission) { (account, share, errorCode, errorDescription) in
|
|
|
+ NCUtility.sharedInstance.stopActivityIndicator()
|
|
|
+ if errorCode == 0 && share != nil {
|
|
|
+ NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, shares: [share!])
|
|
|
+ self.appDelegate.shares = NCManageDatabase.sharedInstance.getTableShares(account: self.metadata.account)
|
|
|
+ } else {
|
|
|
+ NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
func unShare(idShare: Int) {
|
|
|
NCUtility.sharedInstance.startActivityIndicator(view: view)
|
|
|
NCCommunication.shared.deleteShare(idShare: idShare) { (account, errorCode, errorDescription) in
|
|
@@ -113,22 +128,6 @@ class NCShareNetworking: NSObject {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- func share(name: String, shareType: Int, metadata: tableMetadata) {
|
|
|
- NCUtility.sharedInstance.startActivityIndicator(view: view)
|
|
|
- let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl)!
|
|
|
- var permission: Int = 1
|
|
|
- if metadata.directory { permission = Int(k_max_folder_share_permission) } else { permission = Int(k_max_file_share_permission) }
|
|
|
- NCCommunication.shared.createShare(path: filenamePath, shareType: shareType, shareWith: name, permissions: permission) { (account, share, errorCode, errorDescription) in
|
|
|
- NCUtility.sharedInstance.stopActivityIndicator()
|
|
|
- if errorCode == 0 && share != nil {
|
|
|
- NCManageDatabase.sharedInstance.addShare(account: self.metadata.account, activeUrl: self.activeUrl, shares: [share!])
|
|
|
- self.appDelegate.shares = NCManageDatabase.sharedInstance.getTableShares(account: self.metadata.account)
|
|
|
- } else {
|
|
|
- NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: 0)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
protocol NCShareNetworkingDelegate {
|