Skip to content

Commit dfb7bfc

Browse files
committed
feat: Nextcloud share permission enum.
- Moved NKShare into dedicated source code file. - Added documentation comments. - Introduced enum for bitmask values in share permissions which previously were implemented in projects using this library. Signed-off-by: Iva Horn <iva.horn@nextcloud.com>
1 parent 71c06c6 commit dfb7bfc

2 files changed

Lines changed: 102 additions & 40 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
import Foundation
5+
6+
///
7+
/// Represents a Nextcloud share with its associated properties and permissions.
8+
///
9+
public final class NKShare: NSObject {
10+
///
11+
/// Bitmask values defining share permissions as used in ``NKShare\permissions``.
12+
///
13+
/// As defined in the [OCS Share API documentation](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html).
14+
///
15+
public enum Permission: Int {
16+
///
17+
/// Access the shared item.
18+
///
19+
/// Default value for public shares.
20+
///
21+
case read = 1
22+
23+
///
24+
/// Edit the shared items.
25+
///
26+
case update = 2
27+
28+
///
29+
/// Create the shared items.
30+
///
31+
case create = 4
32+
33+
///
34+
/// Delete the shared items.
35+
///
36+
case delete = 8
37+
38+
///
39+
/// Reshare the shared items.
40+
///
41+
case share = 16
42+
43+
///
44+
/// Default value except for public shares.
45+
///
46+
case all = 31
47+
48+
///
49+
/// Determine the default permission value based on the given type value.
50+
///
51+
public static func defaultPermission(for type: Int) -> Self {
52+
if type == 3 {
53+
return .read
54+
} else {
55+
return .all
56+
}
57+
}
58+
}
59+
60+
public var account = ""
61+
public var canEdit: Bool = false
62+
public var canDelete: Bool = false
63+
public var date: Date?
64+
public var displaynameFileOwner = ""
65+
public var displaynameOwner = ""
66+
public var expirationDate: NSDate?
67+
public var fileParent: Int = 0
68+
public var fileSource: Int = 0
69+
public var fileTarget = ""
70+
public var hideDownload: Bool = false
71+
public var idShare: Int = 0
72+
public var itemSource: Int = 0
73+
public var itemType = ""
74+
public var label = ""
75+
public var mailSend: Bool = false
76+
public var mimeType = ""
77+
public var note = ""
78+
public var parent = ""
79+
public var password = ""
80+
public var path = ""
81+
82+
///
83+
/// See ``Permission`` for possible bitmask values.
84+
///
85+
public var permissions: Int = 0
86+
87+
public var sendPasswordByTalk: Bool = false
88+
public var shareType: Int = 0
89+
public var shareWith = ""
90+
public var shareWithDisplayname = ""
91+
public var storage: Int = 0
92+
public var storageId = ""
93+
public var token = ""
94+
public var uidFileOwner = ""
95+
public var uidOwner = ""
96+
public var url = ""
97+
public var userClearAt: Date?
98+
public var userIcon = ""
99+
public var userMessage = ""
100+
public var userStatus = ""
101+
public var attributes: String?
102+
}

Sources/NextcloudKit/NextcloudKit+Share.swift

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -690,43 +690,3 @@ public extension NextcloudKit {
690690
return share
691691
}
692692
}
693-
694-
public class NKShare: NSObject {
695-
public var account = ""
696-
public var canEdit: Bool = false
697-
public var canDelete: Bool = false
698-
public var date: Date?
699-
public var displaynameFileOwner = ""
700-
public var displaynameOwner = ""
701-
public var expirationDate: NSDate?
702-
public var fileParent: Int = 0
703-
public var fileSource: Int = 0
704-
public var fileTarget = ""
705-
public var hideDownload: Bool = false
706-
public var idShare: Int = 0
707-
public var itemSource: Int = 0
708-
public var itemType = ""
709-
public var label = ""
710-
public var mailSend: Bool = false
711-
public var mimeType = ""
712-
public var note = ""
713-
public var parent = ""
714-
public var password = ""
715-
public var path = ""
716-
public var permissions: Int = 0
717-
public var sendPasswordByTalk: Bool = false
718-
public var shareType: Int = 0
719-
public var shareWith = ""
720-
public var shareWithDisplayname = ""
721-
public var storage: Int = 0
722-
public var storageId = ""
723-
public var token = ""
724-
public var uidFileOwner = ""
725-
public var uidOwner = ""
726-
public var url = ""
727-
public var userClearAt: Date?
728-
public var userIcon = ""
729-
public var userMessage = ""
730-
public var userStatus = ""
731-
public var attributes: String?
732-
}

0 commit comments

Comments
 (0)