Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions iOSClient/Menu/NCShare+Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""),
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions iOSClient/Share/Advanced/NCShareAdvancePermission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
23 changes: 12 additions & 11 deletions iOSClient/Share/Advanced/NCShareCells.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@

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
}
}

Expand Down Expand Up @@ -123,10 +123,10 @@

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
}
}

Expand Down Expand Up @@ -223,10 +223,10 @@
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

Expand Down Expand Up @@ -279,3 +279,4 @@
} else { return nil }
}
}

Check warning on line 282 in iOSClient/Share/Advanced/NCShareCells.swift

View workflow job for this annotation

GitHub Actions / Lint

Trailing Newline Violation: Files should have a single trailing newline (trailing_newline)
36 changes: 18 additions & 18 deletions iOSClient/Share/Advanced/NCShareDateCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -83,17 +83,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.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
Expand Down
12 changes: 6 additions & 6 deletions iOSClient/Share/NCShare.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))"
}

Expand Down Expand Up @@ -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 {
Expand Down
33 changes: 8 additions & 25 deletions iOSClient/Share/NCShareCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion iOSClient/Share/NCShareLinkCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import UIKit
import NextcloudKit

class NCShareLinkCell: UITableViewCell {
@IBOutlet private weak var imageItem: UIImageView!
Expand Down Expand Up @@ -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)])
}
Expand Down
4 changes: 3 additions & 1 deletion iOSClient/Share/NCShareNavigationTitleSetting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/Share/NCShareNetworking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading