NCShare+NCCellDelegate.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // NCShare+NCCellDelegate.swift
  3. // Nextcloud
  4. //
  5. // Created by Henrik Storch on 03.01.22.
  6. // Copyright © 2022 Henrik Storch. All rights reserved.
  7. //
  8. // Author Henrik Storch <henrik.storch@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UIKit
  24. // MARK: - NCCell Delegates
  25. extension NCShare: NCShareLinkCellDelegate, NCShareUserCellDelegate {
  26. func copyInternalLink(sender: Any) {
  27. guard let metadata = self.metadata else { return }
  28. let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
  29. NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName, account: metadata.account) { _, metadata, error in
  30. if error == .success, let metadata = metadata {
  31. let internalLink = metadata.urlBase + "/index.php/f/" + metadata.fileId
  32. self.shareCommon.copyLink(link: internalLink, viewController: self, sender: sender)
  33. } else {
  34. NCContentPresenter().showError(error: error)
  35. }
  36. }
  37. }
  38. func tapCopy(with tableShare: tableShare?, sender: Any) {
  39. guard let tableShare = tableShare else {
  40. return copyInternalLink(sender: sender)
  41. }
  42. shareCommon.copyLink(link: tableShare.url, viewController: self, sender: sender)
  43. }
  44. func tapMenu(with tableShare: tableShare?, sender: Any) {
  45. if let tableShare = tableShare {
  46. self.toggleShareMenu(for: tableShare)
  47. } else {
  48. self.makeNewLinkShare()
  49. }
  50. }
  51. func showProfile(with tableShare: tableShare?, sender: Any) {
  52. guard let tableShare else { return }
  53. showProfileMenu(userId: tableShare.shareWith, session: session)
  54. }
  55. func quickStatus(with tableShare: tableShare?, sender: Any) {
  56. guard let tableShare,
  57. let metadata,
  58. tableShare.shareType != NCPermissions().permissionDefaultFileRemoteShareNoSupportShareOption else { return }
  59. self.toggleUserPermissionMenu(isDirectory: metadata.directory, tableShare: tableShare)
  60. }
  61. }