From 542518fff686a2a6b15c29d57e7b1b70635ff083 Mon Sep 17 00:00:00 2001 From: Milen Pivchev Date: Wed, 5 Nov 2025 17:28:11 +0100 Subject: [PATCH 1/2] Refactor shares Signed-off-by: Milen Pivchev --- ...nViewCommon+CollectionViewDataSource.swift | 6 +-- iOSClient/Menu/NCShare+Menu.swift | 10 ++--- .../Advanced/NCShareAdvancePermission.swift | 6 +-- iOSClient/Share/Advanced/NCShareCells.swift | 23 ++++++------ .../Share/Advanced/NCShareDateCell.swift | 37 ++++++++++--------- iOSClient/Share/NCShare.swift | 12 +++--- iOSClient/Share/NCShareCommon.swift | 33 ++++------------- iOSClient/Share/NCShareLinkCell.swift | 3 +- .../Share/NCShareNavigationTitleSetting.swift | 4 +- iOSClient/Share/NCShareNetworking.swift | 4 +- iOSClient/Share/NCSharePermissions.swift | 29 ++++++--------- iOSClient/Share/NCShareUserCell.swift | 10 ++--- iOSClient/Share/TransientShare.swift | 4 +- 13 files changed, 81 insertions(+), 100 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift index d26ac99b98..3325b714da 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift @@ -221,10 +221,10 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } else if isShare { cell.filePreviewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NCShareCommon.shareTypeLink) ? + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? (cell.filePreviewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : (cell.filePreviewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) - } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NCShareCommon.shareTypeLink) { + } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { cell.filePreviewImageView?.image = imageCache.getFolderPublic(account: metadata.account) } else if metadata.mountType == "group" { cell.filePreviewImageView?.image = imageCache.getFolderGroup(account: metadata.account) @@ -330,7 +330,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if isShare { cell.fileSharedImage?.image = imageCache.getImageShared() } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NCShareCommon.shareTypeLink) ? + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? (cell.fileSharedImage?.image = imageCache.getImageShareByLink()) : (cell.fileSharedImage?.image = imageCache.getImageShared()) } else { diff --git a/iOSClient/Menu/NCShare+Menu.swift b/iOSClient/Menu/NCShare+Menu.swift index fafba175cc..f4cc7a23fd 100644 --- a/iOSClient/Menu/NCShare+Menu.swift +++ b/iOSClient/Menu/NCShare+Menu.swift @@ -30,7 +30,7 @@ extension NCShare { let capabilities = NCNetworking.shared.capabilities[self.metadata.account] ?? NKCapabilities.Capabilities() var actions = [NCMenuAction]() - if share.shareType == NCShareCommon.shareTypeLink, canReshare { + if share.shareType == NKShare.ShareType.publicLink.rawValue, canReshare { actions.append( NCMenuAction( title: NSLocalizedString("_share_add_sharelink_", comment: ""), @@ -75,7 +75,7 @@ extension NCShare { sender: sender, action: { _ in Task { - if share.shareType != NCShareCommon.shareTypeLink, let metadata = self.metadata, metadata.e2eEncrypted && capabilities.e2EEApiVersion == NCGlobal.shared.e2eeVersionV20 { + if share.shareType != NKShare.ShareType.publicLink.rawValue, let metadata = self.metadata, metadata.e2eEncrypted && capabilities.e2EEApiVersion == NCGlobal.shared.e2eeVersionV20 { if await NCNetworkingE2EE().isInUpload(account: metadata.account, serverUrl: metadata.serverUrlFileName) { let error = NKError(errorCode: NCGlobal.shared.errorE2EEUploadInProgress, errorDescription: NSLocalizedString("_e2e_in_upload_", comment: "")) return NCContentPresenter().showInfo(error: error) @@ -101,7 +101,7 @@ extension NCShare { [NCMenuAction( title: NSLocalizedString("_share_read_only_", comment: ""), icon: utility.loadImage(named: "eye", colors: [NCBrandColor.shared.iconImageColor]), - selected: share.permissions == (NCSharePermissions.permissionReadShare + NCSharePermissions.permissionReshareShare) || share.permissions == NCSharePermissions.permissionReadShare, + selected: share.permissions == (NKShare.Permission.read.rawValue + NKShare.Permission.share.rawValue) || share.permissions == NKShare.Permission.read.rawValue, on: false, sender: sender, action: { _ in @@ -142,11 +142,11 @@ extension NCShare { )] ) - if isDirectory && (share.shareType == NCShareCommon.shareTypeLink /* public link */ || share.shareType == NCShareCommon.shareTypeEmail) { + if isDirectory && (share.shareType == NKShare.ShareType.publicLink.rawValue /* public link */ || share.shareType == NKShare.ShareType.email.rawValue) { actions.insert(NCMenuAction( title: NSLocalizedString("_share_file_drop_", comment: ""), icon: utility.loadImage(named: "arrow.up.document", colors: [NCBrandColor.shared.iconImageColor]), - selected: share.permissions == NCSharePermissions.permissionCreateShare, + selected: share.permissions == NKShare.Permission.create.rawValue, on: false, sender: sender, action: { _ in diff --git a/iOSClient/Share/Advanced/NCShareAdvancePermission.swift b/iOSClient/Share/Advanced/NCShareAdvancePermission.swift index 059ef65886..8f83c79dc5 100644 --- a/iOSClient/Share/Advanced/NCShareAdvancePermission.swift +++ b/iOSClient/Share/Advanced/NCShareAdvancePermission.swift @@ -236,14 +236,14 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg } Task { - if (share.shareType == NCShareCommon.shareTypeLink || share.shareType == NCShareCommon.shareTypeEmail) && NCSharePermissions.hasPermissionToShare(share.permissions) { - share.permissions = share.permissions - NCSharePermissions.permissionReshareShare + if (share.shareType == NKShare.ShareType.publicLink.rawValue || share.shareType == NKShare.ShareType.email.rawValue) && NCSharePermissions.hasPermissionToShare(share.permissions) { + share.permissions = share.permissions - NKShare.Permission.share.rawValue } if isNewShare { let capabilities = await NKCapabilities.shared.getCapabilities(for: metadata.account) - if share.shareType != NCShareCommon.shareTypeLink, metadata.e2eEncrypted, + if share.shareType != NKShare.ShareType.publicLink.rawValue, metadata.e2eEncrypted, capabilities.e2EEApiVersion == NCGlobal.shared.e2eeVersionV20 { if await NCNetworkingE2EE().isInUpload(account: metadata.account, serverUrl: metadata.serverUrlFileName) { diff --git a/iOSClient/Share/Advanced/NCShareCells.swift b/iOSClient/Share/Advanced/NCShareCells.swift index e812b5241c..5fc2337a4c 100644 --- a/iOSClient/Share/Advanced/NCShareCells.swift +++ b/iOSClient/Share/Advanced/NCShareCells.swift @@ -65,11 +65,11 @@ enum NCUserPermission: CaseIterable, NCPermission { var permissionBitFlag: Int { return switch self { - case .read: NCSharePermissions.permissionReadShare - case .reshare: NCSharePermissions.permissionReshareShare - case .edit: NCSharePermissions.permissionEditShare - case .create: NCSharePermissions.permissionCreateShare - case .delete: NCSharePermissions.permissionDeleteShare + case .read: NKShare.Permission.read.rawValue + case .reshare: NKShare.Permission.share.rawValue + case .edit: NKShare.Permission.update.rawValue + case .create: NKShare.Permission.create.rawValue + case .delete: NKShare.Permission.delete.rawValue } } @@ -123,10 +123,10 @@ enum NCLinkEmailPermission: CaseIterable, NCPermission { var permissionBitFlag: Int { return switch self { - case .read: NCSharePermissions.permissionReadShare - case .edit: NCSharePermissions.permissionEditShare - case .create: NCSharePermissions.permissionCreateShare - case .delete: NCSharePermissions.permissionDeleteShare + case .read: NKShare.Permission.read.rawValue + case .edit: NKShare.Permission.update.rawValue + case .create: NKShare.Permission.create.rawValue + case .delete: NKShare.Permission.delete.rawValue } } @@ -223,10 +223,10 @@ struct NCShareConfig { self.shareable = share self.sharePermission = parentMetadata.sharePermissionsCollaborationServices self.isDirectory = parentMetadata.directory - let type: NCPermission.Type = (share.shareType == NCShareCommon.shareTypeLink || share.shareType == NCShareCommon.shareTypeEmail) ? NCLinkEmailPermission.self : NCUserPermission.self + let type: NCPermission.Type = (share.shareType == NKShare.ShareType.publicLink.rawValue || share.shareType == NKShare.ShareType.email.rawValue) ? NCLinkEmailPermission.self : NCUserPermission.self self.permissions = parentMetadata.directory ? (parentMetadata.e2eEncrypted ? type.forDirectoryE2EE(account: parentMetadata.account) : type.forDirectory) : type.forFile - if share.shareType == NCShareCommon.shareTypeLink { + if share.shareType == NKShare.ShareType.publicLink.rawValue { let capabilities = NCNetworking.shared.capabilities[parentMetadata.account] ?? NKCapabilities.Capabilities() let hasDownloadLimitCapability = capabilities.fileSharingDownloadLimit @@ -279,3 +279,4 @@ struct NCShareConfig { } else { return nil } } } + diff --git a/iOSClient/Share/Advanced/NCShareDateCell.swift b/iOSClient/Share/Advanced/NCShareDateCell.swift index 4af43ab227..192b352426 100644 --- a/iOSClient/Share/Advanced/NCShareDateCell.swift +++ b/iOSClient/Share/Advanced/NCShareDateCell.swift @@ -62,17 +62,17 @@ class NCShareDateCell: UITableViewCell { let capabilities = NCNetworking.shared.capabilities[account] ?? NKCapabilities.Capabilities() switch self.shareType { - case NCShareCommon.shareTypeLink, - NCShareCommon.shareTypeEmail, - NCShareCommon.shareTypeGuest: + case NKShare.ShareType.publicLink.rawValue, + NKShare.ShareType.email.rawValue, + NKShare.ShareType.guest.rawValue: return capabilities.fileSharingPubExpireDateEnforced - case NCShareCommon.shareTypeUser, - NCShareCommon.shareTypeGroup, - NCShareCommon.shareTypeTeam, - NCShareCommon.shareTypeRoom: + case NKShare.ShareType.user.rawValue, + NKShare.ShareType.group.rawValue, + NKShare.ShareType.team.rawValue, + NKShare.ShareType.talkConversation.rawValue: return capabilities.fileSharingInternalExpireDateEnforced - case NCShareCommon.shareTypeFederated, - NCShareCommon.shareTypeFederatedGroup: + case NKShare.ShareType.federatedCloud.rawValue, + NKShare.ShareType.federatedGroup.rawValue: return capabilities.fileSharingRemoteExpireDateEnforced default: return false @@ -83,17 +83,18 @@ class NCShareDateCell: UITableViewCell { let capabilities = NCNetworking.shared.capabilities[account] ?? NKCapabilities.Capabilities() switch self.shareType { - case NCShareCommon.shareTypeLink, - NCShareCommon.shareTypeEmail, - NCShareCommon.shareTypeGuest: + case + NKShare.ShareType.publicLink.rawValue, + NKShare.ShareType.email.rawValue, + NKShare.ShareType.guest.rawValue: return capabilities.fileSharingPubExpireDateDays - case NCShareCommon.shareTypeUser, - NCShareCommon.shareTypeGroup, - NCShareCommon.shareTypeTeam, - NCShareCommon.shareTypeRoom: + case NKShare.ShareType.user.rawValue, + NKShare.ShareType.group.rawValue, + NKShare.ShareType.team.rawValue, + NKShare.ShareType.talkConversation.rawValue: return capabilities.fileSharingInternalExpireDateDays - case NCShareCommon.shareTypeFederated, - NCShareCommon.shareTypeFederatedGroup: + case NKShare.ShareType.federatedCloud.rawValue, + NKShare.ShareType.federatedGroup.rawValue: return capabilities.fileSharingRemoteExpireDateDays default: return 0 diff --git a/iOSClient/Share/NCShare.swift b/iOSClient/Share/NCShare.swift index f2f73d42a5..4ed085b192 100644 --- a/iOSClient/Share/NCShare.swift +++ b/iOSClient/Share/NCShare.swift @@ -53,7 +53,7 @@ class NCShare: UIViewController, NCSharePagingContent { var shareLinksCount = 0 var canReshare: Bool { - return ((metadata.sharePermissionsCollaborationServices & NCSharePermissions.permissionReshareShare) != 0) + return ((metadata.sharePermissionsCollaborationServices & NKShare.Permission.share.rawValue) != 0) } var session: NCSession.Session { @@ -120,7 +120,7 @@ class NCShare: UIViewController, NCSharePagingContent { guard let advancePermission = UIStoryboard(name: "NCShare", bundle: nil).instantiateViewController(withIdentifier: "NCShareAdvancePermission") as? NCShareAdvancePermission, let navigationController = self.navigationController else { return } - self.checkEnforcedPassword(shareType: NCShareCommon.shareTypeLink) { password in + self.checkEnforcedPassword(shareType: NKShare.ShareType.publicLink.rawValue) { password in advancePermission.networking = self.networking advancePermission.share = TransientShare.shareLink(metadata: self.metadata, password: password) advancePermission.metadata = self.metadata @@ -215,7 +215,7 @@ class NCShare: UIViewController, NCSharePagingContent { func checkEnforcedPassword(shareType: Int, completion: @escaping (String?) -> Void) { guard capabilities.fileSharingPubPasswdEnforced, - shareType == NCShareCommon.shareTypeLink || shareType == NCShareCommon.shareTypeEmail + shareType == NKShare.ShareType.publicLink.rawValue || shareType == NKShare.ShareType.email.rawValue else { return completion(nil) } self.present(UIAlertController.password(titleKey: "_enforce_password_protection_", completion: completion), animated: true) @@ -284,7 +284,7 @@ extension NCShare: NCShareNetworkingDelegate { if let shares = existingShares.share, shares.contains(where: {$0.shareWith == sharee.shareWith}) { continue } // do not show already existing sharees if metadata.ownerDisplayName == sharee.shareWith { continue } // do not show owner of the share var label = sharee.label - if sharee.shareType == NCShareCommon.shareTypeTeam { + if sharee.shareType == NKShare.ShareType.team.rawValue { label += " (\(sharee.circleInfo), \(sharee.circleOwner))" } @@ -383,14 +383,14 @@ extension NCShare: UITableViewDataSource { guard let tableShare = shares.share?[indexPath.row] else { return UITableViewCell() } // LINK, EMAIL - if tableShare.shareType == NCShareCommon.shareTypeLink || tableShare.shareType == NCShareCommon.shareTypeEmail { + if tableShare.shareType == NKShare.ShareType.publicLink.rawValue || tableShare.shareType == NKShare.ShareType.email.rawValue { if let cell = tableView.dequeueReusableCell(withIdentifier: "cellLink", for: indexPath) as? NCShareLinkCell { cell.indexPath = indexPath cell.tableShare = tableShare cell.isDirectory = metadata.directory cell.delegate = self cell.setupCellUI(titleAppendString: String(shareLinksCount)) - if tableShare.shareType == NCShareCommon.shareTypeLink { shareLinksCount += 1 } + if tableShare.shareType == NKShare.ShareType.publicLink.rawValue { shareLinksCount += 1 } return cell } } else { diff --git a/iOSClient/Share/NCShareCommon.swift b/iOSClient/Share/NCShareCommon.swift index 9d920adf7d..c79dfa9305 100644 --- a/iOSClient/Share/NCShareCommon.swift +++ b/iOSClient/Share/NCShareCommon.swift @@ -22,19 +22,9 @@ import UIKit import DropDown +import NextcloudKit enum NCShareCommon { - static let shareTypeUser = 0 - static let shareTypeGroup = 1 - static let shareTypeLink = 3 - static let shareTypeEmail = 4 - static let shareTypeContact = 5 - static let shareTypeFederated = 6 - static let shareTypeTeam = 7 - static let shareTypeGuest = 8 - static let shareTypeFederatedGroup = 9 - static let shareTypeRoom = 10 - static let itemTypeFile = "file" static let itemTypeFolder = "folder" @@ -69,27 +59,20 @@ enum NCShareCommon { } static func getImageShareType(shareType: Int) -> UIImage? { + typealias type = NKShare.ShareType switch shareType { - case NCShareCommon.shareTypeUser: - return UIImage(named: "shareTypeUser")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeGroup: + case type.group.rawValue: return UIImage(named: "shareTypeGroup")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeLink: + case type.publicLink.rawValue: return UIImage(named: "shareTypeLink")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeEmail: + case type.email.rawValue: return UIImage(named: "shareTypeEmail")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeContact: - return UIImage(named: "shareTypeUser")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeFederated: - return UIImage(named: "shareTypeUser")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeTeam: + case type.team.rawValue: return UIImage(named: "shareTypeTeam")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeGuest: - return UIImage(named: "shareTypeUser")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeFederatedGroup: + case type.federatedGroup.rawValue: return UIImage(named: "shareTypeGroup")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) - case NCShareCommon.shareTypeRoom: + case type.talkConversation.rawValue: return UIImage(named: "shareTypeRoom")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) default: return UIImage(named: "shareTypeUser")?.withTintColor(NCBrandColor.shared.textColor, renderingMode: .alwaysOriginal) diff --git a/iOSClient/Share/NCShareLinkCell.swift b/iOSClient/Share/NCShareLinkCell.swift index 8f42838e6c..406dc31b0a 100644 --- a/iOSClient/Share/NCShareLinkCell.swift +++ b/iOSClient/Share/NCShareLinkCell.swift @@ -21,6 +21,7 @@ // along with this program. If not, see . import UIKit +import NextcloudKit class NCShareLinkCell: UITableViewCell { @IBOutlet private weak var imageItem: UIImageView! @@ -103,7 +104,7 @@ class NCShareLinkCell: UITableViewCell { labelQuickStatus.text = NSLocalizedString("_share_read_only_", comment: "") } - if tableShare.shareType == NCShareCommon.shareTypeEmail { + if tableShare.shareType == NKShare.ShareType.email.rawValue { labelTitle.text = tableShare.shareWithDisplayname imageItem.image = NCUtility().loadImage(named: "envelope.circle.fill", colors: [NCBrandColor.shared.getElement(account: tableShare.account)]) } diff --git a/iOSClient/Share/NCShareNavigationTitleSetting.swift b/iOSClient/Share/NCShareNavigationTitleSetting.swift index 9804dea108..927f21b97f 100644 --- a/iOSClient/Share/NCShareNavigationTitleSetting.swift +++ b/iOSClient/Share/NCShareNavigationTitleSetting.swift @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: 2025 Iva Horn // SPDX-License-Identifier: GPL-3.0-or-later +import NextcloudKit + /// /// View controllers conforming to this gain the convenience method ``setNavigationTitle()`` to set the navigation title in a convenient and consistent way. /// @@ -18,7 +20,7 @@ extension NCShareNavigationTitleSetting where Self: UIViewController { func setNavigationTitle() { title = NSLocalizedString("_share_", comment: "") + " – " - if share.shareType == NCShareCommon.shareTypeLink { + if share.shareType == NKShare.ShareType.publicLink.rawValue { title! += share.label.isEmpty ? NSLocalizedString("_share_link_", comment: "") : share.label } else { title! += share.shareWithDisplayname.isEmpty ? share.shareWith : share.shareWithDisplayname diff --git a/iOSClient/Share/NCShareNetworking.swift b/iOSClient/Share/NCShareNetworking.swift index 42fa956a29..622ae4e5e6 100644 --- a/iOSClient/Share/NCShareNetworking.swift +++ b/iOSClient/Share/NCShareNetworking.swift @@ -149,7 +149,7 @@ class NCShareNetworking: NSObject { } else { if case let .limited(limit, _) = downloadLimit, capabilities.fileSharingDownloadLimit, - shareable.shareType == NCShareCommon.shareTypeLink, + shareable.shareType == NKShare.ShareType.publicLink.rawValue, shareable.itemType == NCShareCommon.itemTypeFile { self.setShareDownloadLimit(limit, token: share.token) } @@ -215,7 +215,7 @@ class NCShareNetworking: NSObject { self.delegate?.readShareCompleted() if capabilities.fileSharingDownloadLimit, - shareable.shareType == NCShareCommon.shareTypeLink, + shareable.shareType == NKShare.ShareType.publicLink.rawValue, shareable.itemType == NCShareCommon.itemTypeFile { if case let .limited(limit, _) = downloadLimit { self.setShareDownloadLimit(limit, token: share.token) diff --git a/iOSClient/Share/NCSharePermissions.swift b/iOSClient/Share/NCSharePermissions.swift index aa44ca07e6..5a4e2cb117 100644 --- a/iOSClient/Share/NCSharePermissions.swift +++ b/iOSClient/Share/NCSharePermissions.swift @@ -23,16 +23,9 @@ import UIKit import Foundation +import NextcloudKit enum NCSharePermissions { - // Share permission - // permissions - (int) 1 = read; 2 = update; 4 = create; 8 = delete; 16 = Reshare; 31 = all - // - static let permissionReadShare: Int = 1 - static let permissionEditShare: Int = 2 - static let permissionCreateShare: Int = 4 - static let permissionDeleteShare: Int = 8 - static let permissionReshareShare: Int = 16 static let permissionMinFileShare: Int = 1 static let permissionMaxFileShare: Int = 19 @@ -46,23 +39,23 @@ enum NCSharePermissions { static let permissionDownloadShare: Int = 0 static func hasPermissionToRead(_ permission: Int) -> Bool { - return ((permission & permissionReadShare) > 0) + return ((permission & NKShare.Permission.read.rawValue) > 0) } static func hasPermissionToDelete(_ permission: Int) -> Bool { - return ((permission & permissionDeleteShare) > 0) + return ((permission & NKShare.Permission.delete.rawValue) > 0) } static func hasPermissionToCreate(_ permission: Int) -> Bool { - return ((permission & permissionCreateShare) > 0) + return ((permission & NKShare.Permission.create.rawValue) > 0) } static func hasPermissionToEdit(_ permission: Int) -> Bool { - return ((permission & permissionEditShare) > 0) + return ((permission & NKShare.Permission.update.rawValue) > 0) } static func hasPermissionToShare(_ permission: Int) -> Bool { - return ((permission & permissionReshareShare) > 0) + return ((permission & NKShare.Permission.share.rawValue) > 0) } static func isAnyPermissionToEdit(_ permission: Int) -> Bool { @@ -86,20 +79,20 @@ enum NCSharePermissions { var permission = 0 if canRead { - permission = permission + permissionReadShare + permission = permission + NKShare.Permission.read.rawValue } if canCreate && isDirectory { - permission = permission + permissionCreateShare + permission = permission + NKShare.Permission.create.rawValue } if canEdit { - permission = permission + permissionEditShare + permission = permission + NKShare.Permission.update.rawValue } if canDelete && isDirectory { - permission = permission + permissionDeleteShare + permission = permission + NKShare.Permission.delete.rawValue } if canShare { - permission = permission + permissionReshareShare + permission = permission + NKShare.Permission.share.rawValue } return permission diff --git a/iOSClient/Share/NCShareUserCell.swift b/iOSClient/Share/NCShareUserCell.swift index 427304106b..c749a99b5f 100644 --- a/iOSClient/Share/NCShareUserCell.swift +++ b/iOSClient/Share/NCShareUserCell.swift @@ -96,7 +96,7 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol { if NCSharePermissions.canEdit(tableShare.permissions, isDirectory: isDirectory) { // Can edit labelQuickStatus.text = NSLocalizedString("_share_editing_", comment: "") - } else if tableShare.permissions == NCSharePermissions.permissionReadShare { // Read only + } else if tableShare.permissions == NKShare.Permission.read.rawValue { // Read only labelQuickStatus.text = NSLocalizedString("_share_read_only_", comment: "") } else { // Custom permissions labelQuickStatus.text = NSLocalizedString("_custom_permissions_", comment: "") @@ -107,7 +107,7 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol { imageItem.contentMode = .scaleAspectFill - if tableShare.shareType == NCShareCommon.shareTypeTeam { + if tableShare.shareType == NKShare.ShareType.team.rawValue { imageItem.image = utility.loadImage(named: "custom.person.3.circle.fill", colors: [NCBrandColor.shared.iconImageColor2]) } else if results.image == nil { imageItem.image = utility.loadUserImage(for: tableShare.shareWith, displayName: tableShare.shareWithDisplayname, urlBase: metadata.urlBase) @@ -123,11 +123,11 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol { private func getTypeString(_ tableShare: tableShareV2) -> String { switch tableShare.shareType { - case NCShareCommon.shareTypeFederated: + case NKShare.ShareType.federatedCloud.rawValue: return NSLocalizedString("_remote_", comment: "") - case NCShareCommon.shareTypeFederatedGroup: + case NKShare.ShareType.federatedGroup.rawValue: return NSLocalizedString("_remote_group_", comment: "") - case NCShareCommon.shareTypeRoom: + case NKShare.ShareType.talkConversation.rawValue: return NSLocalizedString("_conversation_", comment: "") default: return "" diff --git a/iOSClient/Share/TransientShare.swift b/iOSClient/Share/TransientShare.swift index 666b91b66c..5276698339 100644 --- a/iOSClient/Share/TransientShare.swift +++ b/iOSClient/Share/TransientShare.swift @@ -31,7 +31,7 @@ class TransientShare: Shareable { let capabilities = NCNetworking.shared.capabilities[metadata.account] ?? NKCapabilities.Capabilities() if metadata.e2eEncrypted, capabilities.e2EEApiVersion == NCGlobal.shared.e2eeVersionV12 { - self.permissions = NCSharePermissions.permissionCreateShare + self.permissions = NKShare.Permission.create.rawValue } else { self.permissions = capabilities.fileSharingDefaultPermission & metadata.sharePermissionsCollaborationServices } @@ -51,6 +51,6 @@ class TransientShare: Shareable { } static func shareLink(metadata: tableMetadata, password: String?) -> TransientShare { - TransientShare(shareType: NCShareCommon.shareTypeLink, metadata: metadata, password: password) + TransientShare(shareType: NKShare.ShareType.publicLink.rawValue, metadata: metadata, password: password) } } From 6db47a7b22f243cee1da289196c4e6465eca21e2 Mon Sep 17 00:00:00 2001 From: Milen Pivchev Date: Fri, 7 Nov 2025 16:05:44 +0100 Subject: [PATCH 2/2] Update iOSClient/Share/Advanced/NCShareDateCell.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Milen Pivchev --- iOSClient/Share/Advanced/NCShareDateCell.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iOSClient/Share/Advanced/NCShareDateCell.swift b/iOSClient/Share/Advanced/NCShareDateCell.swift index 192b352426..df1c4fe4af 100644 --- a/iOSClient/Share/Advanced/NCShareDateCell.swift +++ b/iOSClient/Share/Advanced/NCShareDateCell.swift @@ -83,8 +83,7 @@ class NCShareDateCell: UITableViewCell { let capabilities = NCNetworking.shared.capabilities[account] ?? NKCapabilities.Capabilities() switch self.shareType { - case - NKShare.ShareType.publicLink.rawValue, + case NKShare.ShareType.publicLink.rawValue, NKShare.ShareType.email.rawValue, NKShare.ShareType.guest.rawValue: return capabilities.fileSharingPubExpireDateDays