objc2_file_provider/generated/NSFileProviderItem.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-uniform-type-identifiers")]
8use objc2_uniform_type_identifiers::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideritemidentifier?language=objc)
13// NS_TYPED_EXTENSIBLE_ENUM
14pub type NSFileProviderItemIdentifier = NSString;
15
16extern "C" {
17 /// The root of the hierarchical enumeration, i.e the container enumerated when the
18 /// user starts browsing your file provider.
19 ///
20 /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderrootcontaineritemidentifier?language=objc)
21 pub static NSFileProviderRootContainerItemIdentifier: &'static NSFileProviderItemIdentifier;
22}
23
24extern "C" {
25 /// The item identifier of the working set, a synthetic container used by the
26 /// extension to communicate changes to the system even when the parent directories
27 /// of these items aren't actively being enumerated. Items in this set should have
28 /// their parentItemIdentifier set to the identifier of their parent directory.
29 ///
30 /// The working set is the set of files and directories that should be made
31 /// available to the system regardless of the local browsing history. Files listed
32 /// in the working set are indexed in the local Spotlight index and appear in
33 /// offline search results. They contribute to the Recents view of the Files app,
34 /// sorted by lastUsedDate, and it is therefore important to provide a consistent
35 /// experience across devices by including in the working set all the documents
36 /// recently used, trashed, favorited, shared or tagged.
37 ///
38 /// The Spotlight index and the Recents view will show outdated information unless
39 /// the file provider extension keeps the working set up to date with local and
40 /// remote changes. When an item in the working set is remotely modified, the
41 /// extension calls -signalEnumeratorForContainerItemIdentifier: on the identifier
42 /// of the working set; the system will then enumerate changes and update its caches.
43 ///
44 /// Starting in iOS 12 and macOS 10.15, the system maintains a cache on the local
45 /// file system of files and directories previously enumerated. The working set
46 /// is the container used to update that set of files. The extension may know
47 /// whether an item is in that set by checking whether its parentItemIdentifier
48 /// is listed in the materialized containers, see the documentation on
49 /// -materializedItemsDidChangeWithCompletionHandler:.
50 ///
51 /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderworkingsetcontaineritemidentifier?language=objc)
52 pub static NSFileProviderWorkingSetContainerItemIdentifier:
53 &'static NSFileProviderItemIdentifier;
54}
55
56extern "C" {
57 /// The container containing all the trashed items.
58 ///
59 /// When an item is trashed, its `parentItemIdentifier` becomes `NSFileProviderTrashContainerItemIdentifier`.
60 ///
61 /// Extension should be able to return all trashed items by supporting the creation of a NSFileProviderEnumerator
62 /// for the trashed items.
63 ///
64 /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertrashcontaineritemidentifier?language=objc)
65 pub static NSFileProviderTrashContainerItemIdentifier: &'static NSFileProviderItemIdentifier;
66}
67
68extern_class!(
69 /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideritemversion?language=objc)
70 #[unsafe(super(NSObject))]
71 #[derive(Debug, PartialEq, Eq, Hash)]
72 pub struct NSFileProviderItemVersion;
73);
74
75unsafe impl NSObjectProtocol for NSFileProviderItemVersion {}
76
77impl NSFileProviderItemVersion {
78 extern_methods!(
79 /// Version component exposed by the system to denote a state that predates a version returned by the provider.
80 ///
81 /// In case an item was created by calling `createItemBasedOnTemplate` and the item returned by the provider in
82 /// the completion handler of that call didn't match the item template passed by the system, the system will try
83 /// to apply the changes asked by the provider to the disk. However, the system may detect conflicts when applying
84 /// those content back to the disk, which will cause the system to send the new disk version to the extension,
85 /// by calling `modifyItem` or `deleteItemWithIdentifier` with a `baseVersion` that represents the item as passed in
86 /// the template of the `createItemBasedOnTemplate` call.
87 ///
88 /// This constant is used by the system to represent that specific version that was communicated by the system to
89 /// the extension but does not have a corresponding version assigned by the extension.
90 #[unsafe(method(beforeFirstSyncComponent))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn beforeFirstSyncComponent() -> Retained<NSData>;
93
94 /// Items versions have two distinct components, one for the file contents and one
95 /// for metadata.
96 ///
97 /// Components are limited to 128 bytes in size.
98 #[unsafe(method(initWithContentVersion:metadataVersion:))]
99 #[unsafe(method_family = init)]
100 pub unsafe fn initWithContentVersion_metadataVersion(
101 this: Allocated<Self>,
102 content_version: &NSData,
103 metadata_version: &NSData,
104 ) -> Retained<Self>;
105
106 /// Version data for the content of the file.
107 ///
108 /// This property is used by the system for two purposes: if the contentVersion changes,
109 /// - the system assumes that the contents have changed and will trigger a redownload if
110 /// necessary. The exception to this is the case where the extension accepts a content
111 /// sent by the system when replying to a createItemBasedOnTemplate or modifyItem call
112 /// with shouldFetchContent set to NO.
113 /// - the thumbnail cache is invalidated
114 ///
115 /// Note that the resource fork of the file is considered content, so this version
116 /// data should change when either the data fork or the resource fork changes.
117 #[unsafe(method(contentVersion))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn contentVersion(&self) -> Retained<NSData>;
120
121 /// Version data for the metadata of the item, i.e everything but the data fork and
122 /// the resource fork.
123 ///
124 /// The system will store this version, but otherwise ignore it:
125 /// - metadata changes on an item will be applied even if the metadataVersion remains unchanged
126 /// - if the metadata version changes without any corresponding observable changes in the metadata returned
127 /// to the system, the system will simply store the updated metadata version (to return it as the base version
128 /// of a possible future change request).
129 #[unsafe(method(metadataVersion))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn metadataVersion(&self) -> Retained<NSData>;
132 );
133}
134
135/// Methods declared on superclass `NSObject`.
136impl NSFileProviderItemVersion {
137 extern_methods!(
138 #[unsafe(method(init))]
139 #[unsafe(method_family = init)]
140 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
141
142 #[unsafe(method(new))]
143 #[unsafe(method_family = new)]
144 pub unsafe fn new() -> Retained<Self>;
145 );
146}
147
148extern "C" {
149 /// A special value for favorite ranks, to use when no rank was set when the item
150 /// was favorited.
151 ///
152 /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderfavoriterankunranked?language=objc)
153 pub static NSFileProviderFavoriteRankUnranked: c_ulonglong;
154}
155
156/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideritemcapabilities?language=objc)
157// NS_OPTIONS
158#[repr(transparent)]
159#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
160pub struct NSFileProviderItemCapabilities(pub NSUInteger);
161bitflags::bitflags! {
162 impl NSFileProviderItemCapabilities: NSUInteger {
163/// Indicates that the file can be opened for reading. If set on a folder
164/// this is equivalent to
165/// `.allowsContentEnumerating.`
166 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsReading")]
167 const AllowsReading = 1<<0;
168/// Indicates that the file can be opened for writing. If set on a folder,
169/// this is equivalent to
170/// `.allowsAddingSubItems.`
171 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsWriting")]
172 const AllowsWriting = 1<<1;
173/// Indicates that the item can be moved to another folder
174 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsReparenting")]
175 const AllowsReparenting = 1<<2;
176/// Indicates that the item can be renamed
177 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsRenaming")]
178 const AllowsRenaming = 1<<3;
179/// Indicates that the item can be moved to the trash
180 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsTrashing")]
181 const AllowsTrashing = 1<<4;
182/// Indicates that the item can be deleted
183 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsDeleting")]
184 const AllowsDeleting = 1<<5;
185/// Indicates that the item can be evicted.
186///
187/// If this capability is set on an item, the item will become evictable when the item is fully uploaded
188/// (-[NSFileProviderItem isUploaded] not implemented or set to YES), is not actively used and contains no
189/// local changes. The eviction can happen either because the user selected the "Remove Download" option
190/// in Finder, because the provider decided to evict the item using `-[NSFileProviderManager evictItemWithIdentifier:completionHandler:]`,
191/// or because the system ran into a low-disk space scenario.
192///
193/// If this capability is not present, the item will never be evicted.
194/// If the provider wishes to only suppress the user's ability to evict the item in the UI (but retain the ability
195/// of the OS or the provider's program to evict items), the provider can set the following key to false in
196/// their Info.plist, in the NSExtension section: NSExtensionFileProviderAllowsUserControlledEviction
197#[deprecated = "use NSFileProviderContentPolicy instead"]
198 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsEvicting")]
199 const AllowsEvicting = 1<<6;
200/// Indicates that the item can be excluded from sync.
201///
202/// The user can choose to exclude the item in the UI (Finder), in which case the system will stop
203/// monitoring changes for the item and its children and will remove the item from the provider.
204///
205/// This capability can be used to allow an item to be excluded from sync.
206 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsExcludingFromSync")]
207 const AllowsExcludingFromSync = 1<<7;
208/// Indicates that items can be imported to the folder. If set on a file,
209/// this is equivalent to
210/// `.allowsWriting.`
211 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsAddingSubItems")]
212 const AllowsAddingSubItems = NSFileProviderItemCapabilities::AllowsWriting.0;
213/// Indicates that the folder can be enumerated. If set on a file, this is
214/// equivalent to
215/// `.allowsReading.`
216 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsContentEnumerating")]
217 const AllowsContentEnumerating = NSFileProviderItemCapabilities::AllowsReading.0;
218/// Indicates that the folder can be enumerated. If set on a file, this is
219/// equivalent to
220/// `.allowsReading.`
221#[deprecated = "This capability is no longer supported, and does not contain all capabilities. Please migrate to directly specifying each of the individual capabilities that should be allowed for the item."]
222 #[doc(alias = "NSFileProviderItemCapabilitiesAllowsAll")]
223 const AllowsAll = NSFileProviderItemCapabilities::AllowsReading.0|NSFileProviderItemCapabilities::AllowsWriting.0|NSFileProviderItemCapabilities::AllowsReparenting.0|NSFileProviderItemCapabilities::AllowsRenaming.0|NSFileProviderItemCapabilities::AllowsTrashing.0|NSFileProviderItemCapabilities::AllowsDeleting.0;
224 }
225}
226
227unsafe impl Encode for NSFileProviderItemCapabilities {
228 const ENCODING: Encoding = NSUInteger::ENCODING;
229}
230
231unsafe impl RefEncode for NSFileProviderItemCapabilities {
232 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
233}
234
235/// NSFileProviderItemContents corresponds to the item's contents.
236///
237/// Each subsequent field corresponds to a property on NSFileProviderItem that can
238/// change.
239///
240/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideritemfields?language=objc)
241// NS_OPTIONS
242#[repr(transparent)]
243#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
244pub struct NSFileProviderItemFields(pub NSUInteger);
245bitflags::bitflags! {
246 impl NSFileProviderItemFields: NSUInteger {
247 #[doc(alias = "NSFileProviderItemContents")]
248 const Contents = 1<<0;
249 #[doc(alias = "NSFileProviderItemFilename")]
250 const Filename = 1<<1;
251 #[doc(alias = "NSFileProviderItemParentItemIdentifier")]
252 const ParentItemIdentifier = 1<<2;
253 #[doc(alias = "NSFileProviderItemLastUsedDate")]
254 const LastUsedDate = 1<<3;
255 #[doc(alias = "NSFileProviderItemTagData")]
256 const TagData = 1<<4;
257 #[doc(alias = "NSFileProviderItemFavoriteRank")]
258 const FavoriteRank = 1<<5;
259 #[doc(alias = "NSFileProviderItemCreationDate")]
260 const CreationDate = 1<<6;
261 #[doc(alias = "NSFileProviderItemContentModificationDate")]
262 const ContentModificationDate = 1<<7;
263 #[doc(alias = "NSFileProviderItemFileSystemFlags")]
264 const FileSystemFlags = 1<<8;
265 #[doc(alias = "NSFileProviderItemExtendedAttributes")]
266 const ExtendedAttributes = 1<<9;
267 #[doc(alias = "NSFileProviderItemTypeAndCreator")]
268 const TypeAndCreator = 1<<10;
269 }
270}
271
272unsafe impl Encode for NSFileProviderItemFields {
273 const ENCODING: Encoding = NSUInteger::ENCODING;
274}
275
276unsafe impl RefEncode for NSFileProviderItemFields {
277 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
278}
279
280/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderfilesystemflags?language=objc)
281// NS_OPTIONS
282#[repr(transparent)]
283#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
284pub struct NSFileProviderFileSystemFlags(pub NSUInteger);
285bitflags::bitflags! {
286 impl NSFileProviderFileSystemFlags: NSUInteger {
287/// Item has the POSIX user-executable (u+x) permission.
288 #[doc(alias = "NSFileProviderFileSystemUserExecutable")]
289 const UserExecutable = 1<<0;
290/// Item has the POSIX user-readable (u+r) permission.
291 #[doc(alias = "NSFileProviderFileSystemUserReadable")]
292 const UserReadable = 1<<1;
293/// Item has the POSIX user-writable (u+w) permission.
294 #[doc(alias = "NSFileProviderFileSystemUserWritable")]
295 const UserWritable = 1<<2;
296/// Item should not be presented in the file viewers.
297///
298/// This includes both the UF_HIDDEN BSD flag and the Invisible bit from the
299/// FinderInfo. When syncing down, the system only sets the UF_HIDDEN
300/// flag.
301 #[doc(alias = "NSFileProviderFileSystemHidden")]
302 const Hidden = 1<<3;
303/// The extension of the item should not be presented in the file viewers.
304 #[doc(alias = "NSFileProviderFileSystemPathExtensionHidden")]
305 const PathExtensionHidden = 1<<4;
306 }
307}
308
309unsafe impl Encode for NSFileProviderFileSystemFlags {
310 const ENCODING: Encoding = NSUInteger::ENCODING;
311}
312
313unsafe impl RefEncode for NSFileProviderFileSystemFlags {
314 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
315}
316
317/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertypeandcreator?language=objc)
318#[repr(C)]
319#[derive(Clone, Copy, Debug, PartialEq)]
320pub struct NSFileProviderTypeAndCreator {
321 /// The first word of the FinderInfo structure. It matches the file type code
322 pub r#type: OSType,
323 /// The second word of the FinderInfo structure. It matches the creator code
324 pub creator: OSType,
325}
326
327unsafe impl Encode for NSFileProviderTypeAndCreator {
328 const ENCODING: Encoding = Encoding::Struct(
329 "NSFileProviderTypeAndCreator",
330 &[<OSType>::ENCODING, <OSType>::ENCODING],
331 );
332}
333
334unsafe impl RefEncode for NSFileProviderTypeAndCreator {
335 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
336}
337
338/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidercontentpolicy?language=objc)
339// NS_ENUM
340#[repr(transparent)]
341#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
342pub struct NSFileProviderContentPolicy(pub NSInteger);
343impl NSFileProviderContentPolicy {
344 /// Inherit the content policy of the parent folder.
345 ///
346 /// This is the default policy on every item other than the root.
347 #[doc(alias = "NSFileProviderContentPolicyInherited")]
348 pub const Inherited: Self = Self(0);
349 /// Download this item lazily (i.e when it is read) if it is dataless.
350 /// Download remote content updates eagerly if this file is not dataless.
351 /// Allow eviction on low disk pressure and other triggers.
352 ///
353 /// This is the default policy on the root on macOS.
354 #[doc(alias = "NSFileProviderContentPolicyDownloadLazily")]
355 pub const DownloadLazily: Self = Self(1);
356 /// Download this item lazily (i.e when it is read.)
357 /// Evict the file upon remote content update.
358 /// Also allow eviction on low disk pressure and other triggers.
359 ///
360 /// This is the default policy on the root on iOS.
361 #[doc(alias = "NSFileProviderContentPolicyDownloadLazilyAndEvictOnRemoteUpdate")]
362 pub const DownloadLazilyAndEvictOnRemoteUpdate: Self = Self(2);
363 /// Download this item eagerly (i.e before it is read.)
364 /// Keep downloading remote updates eagerly.
365 /// Prevent eviction on low disk pressure and other triggers.
366 ///
367 /// When an item with the inherited policy is moved into a folder with
368 /// this policy, the system will automatically schedule a download.
369 #[doc(alias = "NSFileProviderContentPolicyDownloadEagerlyAndKeepDownloaded")]
370 pub const DownloadEagerlyAndKeepDownloaded: Self = Self(3);
371}
372
373unsafe impl Encode for NSFileProviderContentPolicy {
374 const ENCODING: Encoding = NSInteger::ENCODING;
375}
376
377unsafe impl RefEncode for NSFileProviderContentPolicy {
378 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
379}
380
381extern_protocol!(
382 /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideritemprotocol?language=objc)
383 #[name = "NSFileProviderItem"]
384 pub unsafe trait NSFileProviderItemProtocol: NSObjectProtocol {
385 /// The identifier of the item.
386 ///
387 /// The itemIdentifier should not contain sensitive information, as it may be recorded in system logs and
388 /// diagnostic files.
389 #[unsafe(method(itemIdentifier))]
390 #[unsafe(method_family = none)]
391 unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
392
393 /// The parent identifier specifies the parent of the item in the hierarchy.
394 ///
395 /// Set to NSFileProviderRootContainerItemIdentifier for an item at the root of the
396 /// user's storage. Set to the itemIdentifier of the item's parent otherwise.
397 ///
398 /// When enumerating the root container or a generic container, the
399 /// parentItemIdentifier of the enumerated items is expected to match the
400 /// enumerated item's identifier. When enumerating the working set, the
401 /// parentItemIdentifier is expected to match the actual parent of the item in the
402 /// hierarchy (ie. it is not NSFileProviderWorkingSetContainerItemIdentifier).
403 ///
404 /// The parents of trashed items and of the root item are ignored.
405 #[unsafe(method(parentItemIdentifier))]
406 #[unsafe(method_family = none)]
407 unsafe fn parentItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
408
409 /// The file or directory name, complete with its file extension.
410 ///
411 /// The filename property must not be an empty string, including when the item identifier is
412 /// NSFileProviderRootContainerItemIdentifier. The filename for NSFileProviderRootContainerItemIdentifier
413 /// may be displayed in the user interface. Therefore it should be a user-friendly string.
414 #[unsafe(method(filename))]
415 #[unsafe(method_family = none)]
416 unsafe fn filename(&self) -> Retained<NSString>;
417
418 #[cfg(feature = "objc2-uniform-type-identifiers")]
419 /// ContentType (UTType) for the item.
420 ///
421 /// On macOS, items must implement contentType.
422 ///
423 /// On iOS, items must implement either contentType or typeIdentifier. Note
424 /// that contentType is not available on iOS 13 and earlier, so typeIdentifier
425 /// is required in order to target iOS 13 and earlier.
426 ///
427 /// When using NSFileProviderReplicatedExtension, providers must be prepared
428 /// to handle the following contentType in the appropriate manner
429 /// when they are passed in itemTemplates contentType to createItem/modifyItem calls:
430 /// UTType.symbolicLink
431 /// UTType.folder
432 /// UTType.package
433 /// UTType.aliasFile
434 ///
435 /// Changing the contentType for a given item that would result in a transition to/from a folder
436 /// or to/from a symlink is not supported.
437 #[optional]
438 #[unsafe(method(contentType))]
439 #[unsafe(method_family = none)]
440 unsafe fn contentType(&self) -> Retained<UTType>;
441
442 /// Uniform type identifier (UTI) for the item.
443 ///
444 /// This property is deprecated in favor of the "contentType" property.
445 ///
446 /// On macOS, typeIdentifier is not available. Items must implement contentType
447 /// on macOS.
448 ///
449 /// On iOS, items must implement either contentType or typeIdentifier. Note
450 /// that contentType is not available on iOS 13 and earlier, so typeIdentifier
451 /// is required in order to target iOS 13 and earlier.
452 #[deprecated]
453 #[optional]
454 #[unsafe(method(typeIdentifier))]
455 #[unsafe(method_family = none)]
456 unsafe fn typeIdentifier(&self) -> Retained<NSString>;
457
458 /// File type and creator code for the item.
459 ///
460 /// This property contains two variables, one for the file type code and one for the creator code.
461 /// Both will be synchronized at the same time, so you have to define both when changing one.
462 ///
463 /// On change on this structure, the NSFileProviderItemTypeAndCreator field will be set in the
464 /// NSFileProviderItemFields argument to createItem/modifyItem.
465 ///
466 /// These will be written down in the FinderInfo structure if relevant.
467 #[optional]
468 #[unsafe(method(typeAndCreator))]
469 #[unsafe(method_family = none)]
470 unsafe fn typeAndCreator(&self) -> NSFileProviderTypeAndCreator;
471
472 /// The capabilities of the item. This controls the list of actions that the UI
473 /// will allow for the item.
474 ///
475 /// Capabilities on an item only apply to the item itself. They are not inherited by the children of directories.
476 #[optional]
477 #[unsafe(method(capabilities))]
478 #[unsafe(method_family = none)]
479 unsafe fn capabilities(&self) -> NSFileProviderItemCapabilities;
480
481 /// File System level flags.
482 ///
483 /// This includes POSIX permissions and presentation options for the item.
484 ///
485 /// Prior to macOS 11.3, fileSystemFlags are not honored for directories.
486 #[optional]
487 #[unsafe(method(fileSystemFlags))]
488 #[unsafe(method_family = none)]
489 unsafe fn fileSystemFlags(&self) -> NSFileProviderFileSystemFlags;
490
491 #[optional]
492 #[unsafe(method(documentSize))]
493 #[unsafe(method_family = none)]
494 unsafe fn documentSize(&self) -> Option<Retained<NSNumber>>;
495
496 #[optional]
497 #[unsafe(method(childItemCount))]
498 #[unsafe(method_family = none)]
499 unsafe fn childItemCount(&self) -> Option<Retained<NSNumber>>;
500
501 #[optional]
502 #[unsafe(method(creationDate))]
503 #[unsafe(method_family = none)]
504 unsafe fn creationDate(&self) -> Option<Retained<NSDate>>;
505
506 #[optional]
507 #[unsafe(method(contentModificationDate))]
508 #[unsafe(method_family = none)]
509 unsafe fn contentModificationDate(&self) -> Option<Retained<NSDate>>;
510
511 /// Syncable extended attributes on the file.
512 ///
513 /// The system decides which extended attributes should be synced from the device,
514 /// based on a set of rules largely inferred from the name of the extended
515 /// attribute. Extended attributes named with xattr_name_with_flags(XATTR_FLAG_SYNCABLE)
516 /// will be listed in this dictionary; some extended attributes introduced before
517 /// this API are also whitelisted for sync. The provider can declare of list of
518 /// attributes it wants to sync even if the system heuristic won't consider those
519 /// as syncable. For this, it can add a list of xattr names in the Info.plist of the
520 /// extension under the key NSExtensionFileProviderAdditionalSyncableExtendedAttributes.
521 ///
522 /// Syncable xattrs are capped in size to about 32KiB total for a given item.
523 /// When the set of extended attributes on a file is larger than that, the system
524 /// demotes some of the extended attributes to non-syncable.
525 ///
526 /// The system decides which non-syncable extended attributes should be preserved
527 /// locally when the item is updated remotely, based on a set of rules again largely
528 /// inferred from the name of the extended attribute. Extended attributes named
529 /// with xattr_name_with_flags(XATTR_FLAG_CONTENT_DEPENDENT) will be preserved only
530 /// if itemVersion.contentVersion was not modified by the remote update.
531 ///
532 /// Some NSFileProviderItem properties (lastUsedDate, tagData...) happen to be
533 /// stored on disk in extended attributes that won't be listed in this dictionary
534 /// because that would be redundant. The 32 bits of Finder info in the extended
535 /// attribute named XATTR_FINDERINFO_NAME ("com.apple.FinderInfo") is not listed
536 /// here for the same reason: the syncable Finder info bits are deserialized to
537 /// other properties of NSFileProviderItem.
538 ///
539 /// The system will set extended attributes on dataless files, and will preserve
540 /// them when a file is rendered dataless. I.e extended attributes are considered
541 /// metadata, not content. The resource fork however is considered content and
542 /// will not be included in this dictionary. Local changes to the resource fork
543 /// will be communicated under NSFileProviderItemContents. Remote changes to
544 /// the resource fork should bump itemVersion.contentVersion.
545 #[optional]
546 #[unsafe(method(extendedAttributes))]
547 #[unsafe(method_family = none)]
548 unsafe fn extendedAttributes(&self) -> Retained<NSDictionary<NSString, NSData>>;
549
550 /// The date this item was last used. This is neither the modification date nor
551 /// the last access date exposed in traditional file system APIs, and indicates a
552 /// very clear user intent to use the document. For example, this is set when the
553 /// document is open full screen on a device.
554 ///
555 /// This is the system's cue that the document is recent and should appear in the
556 /// recent list of the UIDocumentBrowserViewController.
557 ///
558 /// This property must not be shared between users, even if the item is.
559 #[optional]
560 #[unsafe(method(lastUsedDate))]
561 #[unsafe(method_family = none)]
562 unsafe fn lastUsedDate(&self) -> Option<Retained<NSDate>>;
563
564 /// An abstract data blob representing the tags associated with the item. The same
565 /// tags that are available via -[NSURL getResourceValue:forKey:error:] with key
566 /// NSURLTagNamesKey on macOS, except that this data blob may transport more
567 /// information than just the tag names.
568 ///
569 /// This property must not be shared between users, even if the item is.
570 ///
571 /// Starting in macOS 12 and iOS 15, the system suppports the value of the
572 /// `com.apple.metadata:_kMDItemUserTags` xattr as a valid `tagData` blob input.
573 #[optional]
574 #[unsafe(method(tagData))]
575 #[unsafe(method_family = none)]
576 unsafe fn tagData(&self) -> Option<Retained<NSData>>;
577
578 /// The presence of a favorite rank indicates that a directory is a favorite.
579 /// Favorite ranks are 64-bit unsigned integers. The initial value for the first
580 /// item is the time since the unix epoch in milliseconds, but subsequent items are
581 /// simply placed relative to that. Favorite ranks are modified when the user
582 /// reorders favorites.
583 ///
584 /// When favoriting folders on other platforms, set the rank to the time since the
585 /// unix epoch in milliseconds. Special value
586 /// @
587 /// (NSFileProviderFavoriteRankUnranked)
588 /// may be used if no rank is available: the system will then figure out the best
589 /// rank and set it. Please persist and sync the new value.
590 ///
591 /// This property must not be shared between users, even if the item is.
592 #[optional]
593 #[unsafe(method(favoriteRank))]
594 #[unsafe(method_family = none)]
595 unsafe fn favoriteRank(&self) -> Option<Retained<NSNumber>>;
596
597 /// Set on a directory or a document if it should appear in the trash.
598 ///
599 /// This flag should only be set on the top-level item: trashing a directory sets
600 /// this flag on the directory itself, but not on its children.
601 ///
602 /// Trashed items should remain in the working set; however, children of trashed
603 /// directories should be removed from the working set.
604 #[optional]
605 #[unsafe(method(isTrashed))]
606 #[unsafe(method_family = none)]
607 unsafe fn isTrashed(&self) -> bool;
608
609 /// Uploaded and uploading are used to inform the cloud badge which will be shown on the item.
610 ///
611 /// When using NSFileProviderReplicatedExtension, uploaded is used to inform whether the item may be
612 /// evicted from the local disk. If you choose to finish uploading items after calling the completion handler
613 /// of creteItem/modifyItem, you must set the uploaded flag to false, in order for the item to be excluded from
614 /// eviction.
615 #[optional]
616 #[unsafe(method(isUploaded))]
617 #[unsafe(method_family = none)]
618 unsafe fn isUploaded(&self) -> bool;
619
620 #[optional]
621 #[unsafe(method(isUploading))]
622 #[unsafe(method_family = none)]
623 unsafe fn isUploading(&self) -> bool;
624
625 /// An error that occurred while uploading to your remote server.
626 ///
627 ///
628 /// Note: Typical uploading errors include:
629 /// - NSFileProviderErrorInsufficientQuota
630 /// - NSFileProviderErrorServerUnreachable
631 ///
632 ///
633 /// See also: NSFileProviderErrorInsufficientQuota
634 ///
635 /// See also: NSFileProviderErrorServerUnreachable
636 #[optional]
637 #[unsafe(method(uploadingError))]
638 #[unsafe(method_family = none)]
639 unsafe fn uploadingError(&self) -> Option<Retained<NSError>>;
640
641 /// When using NSFileProviderExtension, downloaded and downloading are used to inform the cloud badge
642 /// which will be shown on the item.
643 ///
644 /// When using NSFileProviderReplicatedExtension, downloaded and downloading are ignored, as they can be
645 /// inferred from the result of calls to fetchContentsForItemWithIdentifier.
646 #[optional]
647 #[unsafe(method(isDownloaded))]
648 #[unsafe(method_family = none)]
649 unsafe fn isDownloaded(&self) -> bool;
650
651 #[optional]
652 #[unsafe(method(isDownloading))]
653 #[unsafe(method_family = none)]
654 unsafe fn isDownloading(&self) -> bool;
655
656 /// An error that occurred while downloading from your remote server.
657 #[optional]
658 #[unsafe(method(downloadingError))]
659 #[unsafe(method_family = none)]
660 unsafe fn downloadingError(&self) -> Option<Retained<NSError>>;
661
662 #[optional]
663 #[unsafe(method(isMostRecentVersionDownloaded))]
664 #[unsafe(method_family = none)]
665 unsafe fn isMostRecentVersionDownloaded(&self) -> bool;
666
667 #[optional]
668 #[unsafe(method(isShared))]
669 #[unsafe(method_family = none)]
670 unsafe fn isShared(&self) -> bool;
671
672 #[optional]
673 #[unsafe(method(isSharedByCurrentUser))]
674 #[unsafe(method_family = none)]
675 unsafe fn isSharedByCurrentUser(&self) -> bool;
676
677 /// ownerNameComponents should be nil when sharedByCurrentUser is equal to YES or
678 /// when the item is not shared.
679 #[optional]
680 #[unsafe(method(ownerNameComponents))]
681 #[unsafe(method_family = none)]
682 unsafe fn ownerNameComponents(&self) -> Option<Retained<NSPersonNameComponents>>;
683
684 #[optional]
685 #[unsafe(method(mostRecentEditorNameComponents))]
686 #[unsafe(method_family = none)]
687 unsafe fn mostRecentEditorNameComponents(&self)
688 -> Option<Retained<NSPersonNameComponents>>;
689
690 /// The versionIdentifier is used to invalidate the thumbnail in the thumbnail cache.
691 /// A content hash would be a reasonable choice.
692 ///
693 /// Version identifiers are limited to 1000 bytes.
694 ///
695 /// This property is deprecated in favor of the "itemVersion" property.
696 #[optional]
697 #[unsafe(method(versionIdentifier))]
698 #[unsafe(method_family = none)]
699 unsafe fn versionIdentifier(&self) -> Option<Retained<NSData>>;
700
701 /// The version is used to track which version of an item has been modified when informing a provider about changes. It is also used to invalidate the thumbnail cache.
702 #[optional]
703 #[unsafe(method(itemVersion))]
704 #[unsafe(method_family = none)]
705 unsafe fn itemVersion(&self) -> Retained<NSFileProviderItemVersion>;
706
707 /// The target of a symlink.
708 ///
709 /// If a replicated extension expose an item with the contentType public.symlink (UTTypeSymbolicLink),
710 /// this field should contain the target of the symlink.
711 #[optional]
712 #[unsafe(method(symlinkTargetPath))]
713 #[unsafe(method_family = none)]
714 unsafe fn symlinkTargetPath(&self) -> Option<Retained<NSString>>;
715
716 /// Use this dictionary to add state information to the item. Entries are accessible to
717 /// FileProviderUI and non-UI action predicates and user interaction predicates [1] via the
718 /// `userInfo` context key.
719 ///
720 /// Additionally, any entry of this dictionary with a key ending in `.inherited`
721 /// will be accessible to predicates for descendants of this item via the context key `inheritedUserInfo`.
722 ///
723 /// Items can redefine inherited values for their descendants by specifying the same key used in an ancestor's `userInfo`.
724 /// Thus, `inheritedUserInfo` for a given item is a dictionary of `*.inherited` keys from all if its ancestors, with each value
725 /// taken from the nearest ancestor that has the entry defined.
726 ///
727 /// In this example directory structure:
728 /// root
729 /// |_ parent
730 /// |_ child
731 /// |_ grandchild
732 ///
733 /// with the following userInfo values set:
734 /// parent.userInfo = { "a.inherited": YES, "b.inherited": YES }
735 /// child.userInfo = { "a.inherited": NO, "c.inherited": NO }
736 /// grandchild.userInfo = { }
737 ///
738 /// the following inheritedUserInfo values will be provided:
739 /// parent.inheritedUserInfo = { }
740 /// child.inheritedUserInfo = { "a.inherited": YES, "b.inherited": YES }
741 /// grandchild.inheritedUserInfo = { "a.inherited": NO, "b.inherited": YES, "c.inherited": NO }
742 ///
743 /// The context key `resolvedUserInfo` is also available. For each item, the resolvedUserInfo is it's
744 /// inheritedUserInfo, combined with the keys suffixed with .inherited from it's userInfo.
745 /// Continuing the previous example:
746 /// parent.resolvedUserInfo = { "a.inherited": YES, "b.inherited": YES }
747 /// child.resolvedUserInfo = { "a.inherited": NO, "b.inherited": YES, "c.inherited": NO }
748 /// grandchild.resolvedUserInfo = { "a.inherited": NO, "b.inherited": YES, "c.inherited": NO }
749 ///
750 /// All values for this dictionary must be of type String, Number, Bool or Date.
751 ///
752 /// [1] UserInteraction can be defined when a user level action occurs with a file.
753 ///
754 /// - `NSFileProviderUserInteractions` *array*
755 /// - `ActivationRule ` *string*, the predicate.
756 /// Parameters predicates
757 /// - `destinationItem`: the destination item for an action. Present for Move/MoveIn/Copy/CopyIn/Create
758 /// - `action` : the action that is being performed
759 /// 'Move' : moving item(s) within the same provider
760 /// 'MoveOut' : moving item(s) out of the provider
761 /// 'MoveIn' : importing item(s) into a folder/root of the provider
762 /// 'Copy' : copying item(s) within the same provider
763 /// 'CopyOut' : copying item(s) out of the provider
764 /// 'CopyIn' : copying item(s) into a folder/root of the provider
765 /// 'Trash' : trashing item(s)
766 /// 'Create' : creating an item (available in macOS 12.0 and later)
767 /// The Create action will be evaluated when the user creates a new file
768 /// or folder in a system Open/Save panel.
769 /// The sourceItem is the file/folder being created. The only field that is
770 /// populated for this item is the filename. The type of file/folder, size, etc,
771 /// are unknown at Create evaluation time.
772 /// The destinationItem is the directory which the file/folder is being created
773 /// within.
774 /// 'Delete' : deleting item(s)
775 /// If the provider wishes to take full responsibility for showing warnings on Delete,
776 /// the provider can set NSExtensionFileProviderAllowsSystemDeleteAlerts=0 in the provider's Info.plist.
777 /// This will ensure that the system does not display it's warnings when the user is deleting a file.
778 /// 'ExcludeFromSync' : deleting items(s) because the user chose to exclude those from sync (available in macOS 12.0 and later)
779 /// 'Rename' : renaming item(s) (available in macOS 11.3 and later)
780 /// The destinationItem has only the `filename` field populated (available in macOS 12.0.1 and later).
781 /// - `sourceItem` : current item that the predicate is evaluating. Present for Move/MoveOut/Copy/CopyOut/Create/Trash/Delete/ExcludeFromSync/Rename
782 /// - `sourceItemsCount` :
783 /// - In userInteraction, represents the count of sourceItems of an action operation
784 /// - In subUserInteraction: represents the count of items that matched the previous predicate
785 /// - `domainUserInfo`: The latest dictionary returned from -[NSFileProviderDomainState userInfo]
786 /// - `Alert` *dictionary*
787 /// - `LocalizedTitle` *string*, title of the alert
788 /// - `LocalizedSubTitle` *string*, sub title of the alert
789 /// -
790 /// Parameters (maximum 10) for LocalizedTitle/LocalizedSubTitle
791 /// - `matchingItemsCount`: count of source items that matched the predicate (only present if matchingItemsCount > 0)
792 /// - `matchingItemsCountMinusOne`: matchingItemsCount minus one (only present if matchingItemsCount > 1)
793 /// - `matchingItemsCountMinusTwo`: matchingItemsCount minus two (only present if matchingItemsCount > 2)
794 /// - `firstMatchingItem`: first sourceItem that matched the predicate (only present if matchingItemsCount > 1)
795 /// - `secondMatchingItem`: second sourceItem that matched the predicate (only present if matchingItemsCount > 2)
796 /// - `LocalizedRecoveryOptions`
797 /// - `Continue` *string*, the string for the continue button - default value if not specified
798 /// - `Cancel` *string*, the string for the cancel button - default value if not specified
799 /// - `RecoveryOptions` (optional)
800 /// - `Continue` *bool*, the boolean for whether to have a continue button - default value is YES if not specified
801 /// - `Destructive` *bool*, the boolean for whether continuing is a destructive action - default value is NO if not specified
802 /// - `HelpURL` *string*: If present, a help button will be displayed on the Alert that is shown. If the user
803 /// clicks the help button, this help URL will be opened. This URL is not restricted to Web URLs. For instance, the extension could configure
804 /// the HelpURL to launch it's application with a custom URL scheme. (available in macOS 12.0 and later)
805 /// - `SubInteractions `: *dictionary* (same as `NSFileProviderUserInteractions`)
806 /// - `SupressionIdentifier` *string*: If present, when this predicate matches, the alert will display an option to
807 /// suppress future alerts from UserInteractions with the same
808 /// SuppressionIdentifier (including the current UserInteraction). This also
809 /// requires implementing the `NSFileProviderUserInteractionSuppressing`
810 /// protocol on the principal class of the FileProvider extension (available in
811 /// macOS 12.0 and later).
812 ///
813 /// For each interaction, either Alert or SubInteractions must be specified. SubInteractions will be evaluated if the main ActivationRule evaluates to
814 /// YES for at least once. This allows you to match a general pattern via the top-level activation rule and then select a specialized error message from a list
815 /// of subpatterns.
816 ///
817 /// At most one UserInteraction alert will be shown for each FileProvider domain involved in the user's Action. For
818 /// instance, if provider A defines a UserInteraction for MoveOut actions, and provider B defines a UserInteraction
819 /// for MoveIn operations. When the user moves a file from A to B, and the predicate for both UserInteraction
820 /// matches, then both of the UserInteraction alerts will be shown to the user. However, as soon as the user
821 /// denies any of the alerts, the remainder will not be shown, and the action will be denied.
822 ///
823 /// If the provider wishes to take full responsibility for showing a custom contextual menu item for Download,
824 /// the provider can set NSExtensionFileProviderAllowsContextualMenuDownloadEntry=0 in the provider's Info.plist.
825 /// This will ensure that the system does not display the "Download Now" button in the contextual menu.
826 ///
827 /// When `sourceItem` or `destinationItem` are present in a UserInteraction, a subset of the fields present on the item will be available for use.
828 /// The subset includes:
829 /// - `userInfo`
830 /// - `itemIdentifier`
831 /// - `parentItemIdentifier`
832 /// - `contentType`
833 /// - `typeIdentifier`
834 /// - `isTrashed`
835 /// - `filename`
836 /// - `capabilities`
837 /// - `documentSize`
838 /// - `childItemCount`
839 /// - `creationDate`
840 /// - `contentModificationDate`
841 /// - `lastUsedDate`
842 /// - `tagData`
843 /// - `favoriteRank`
844 /// - `isUploaded`
845 /// - `isUploading`
846 /// - `uploadingError`
847 /// - `isDownloaded`
848 /// - `isDownloading`
849 /// - `downloadingError`
850 /// - `isMostRecentVersionDownloaded`
851 /// - `isShared`
852 /// - `isSharedByCurrentUser`
853 /// - `ownerNameComponents`
854 /// - `mostRecentEditorNameComponents`
855 /// - `versionIdentifier`
856 /// - `inheritedUserInfo`
857 /// - `resolvedUserInfo`
858 /// - `isRecursivelyDownloaded`
859 ///
860 /// Here is a sample extension Info.plist:
861 ///
862 /// ```text
863 /// <key
864 /// >NSExtension
865 /// </key
866 /// >
867 /// <key
868 /// >NSExtensionFileProviderAllowsContextualMenuDownloadEntry
869 /// </key
870 /// >
871 /// <false
872 /// />
873 /// <key
874 /// >NSFileProviderUserInteractions
875 /// </key
876 /// >
877 /// <array
878 /// >
879 /// <key
880 /// >ActivationRule
881 /// </key
882 /// >
883 /// <string
884 /// >action == "Move"
885 /// </string
886 /// >
887 /// <key
888 /// >SubInteractions
889 /// </key
890 /// >
891 /// <array
892 /// >
893 /// <dict
894 /// >
895 /// <key
896 /// >ActivationRule
897 /// </key
898 /// >
899 /// <string
900 /// >sourceItem.isShared == NO AND
901 /// destinationItem.isShared == YES AND
902 /// destinationItem.isSharedByCurrentUser == YES
903 /// </string
904 /// >
905 /// <key
906 /// >SubInteractions
907 /// </key
908 /// >
909 /// <array
910 /// >
911 /// <dict
912 /// >
913 /// <key
914 /// >ActivationRule
915 /// </key
916 /// >
917 /// <string
918 /// >sourceItemsCount == 1
919 /// </string
920 /// >
921 /// <key
922 /// >Alert
923 /// </key
924 /// >
925 /// <dict
926 /// >
927 /// <key
928 /// >LocalizedTitle
929 /// </key
930 /// >
931 /// <dict
932 /// >
933 /// <key
934 /// >NSStringFormat
935 /// </key
936 /// >
937 /// <string
938 /// >Are you sure you want to move %
939 /// @
940 /// into %
941 /// @
942 /// ?
943 /// </string
944 /// >
945 /// <key
946 /// >NSStringFormatValues
947 /// </key
948 /// >
949 /// <array
950 /// >
951 /// <string
952 /// >firstMatchingItem.filename
953 /// </string
954 /// >
955 /// <string
956 /// >destinationItem.filename
957 /// </string
958 /// >
959 /// </array
960 /// >
961 /// </dict
962 /// >
963 /// <key
964 /// >LocalizedSubTitle
965 /// </key
966 /// >
967 /// <dict
968 /// >
969 /// <key
970 /// >NSStringFormat
971 /// </key
972 /// >
973 /// <string
974 /// >If you move it, people added to the shared folder “%
975 /// @
976 /// ” will be able to access it
977 /// </string
978 /// >
979 /// <key
980 /// >NSStringFormatValues
981 /// </key
982 /// >
983 /// <array
984 /// >
985 /// <string
986 /// >destinationItem.filename
987 /// </string
988 /// >
989 /// </array
990 /// >
991 /// </dict
992 /// >
993 /// <key
994 /// >LocalizedRecoveryOptions
995 /// </key
996 /// >
997 /// <array
998 /// >
999 /// <key
1000 /// >Continue
1001 /// </key
1002 /// >
1003 /// <string
1004 /// >Save to shared folder
1005 /// </string
1006 /// >
1007 /// </array
1008 /// >
1009 /// </dict
1010 /// >
1011 /// </dict
1012 /// >
1013 /// </array
1014 /// >
1015 /// </dict
1016 /// >
1017 /// <dict
1018 /// >
1019 /// <key
1020 /// >ActivationRule
1021 /// </key
1022 /// >
1023 /// <string
1024 /// >sourceItem.isShared == YES AND
1025 /// sourceItem.isSharedByCurrentUser == NO AND
1026 /// destinationItem.isSharedByCurrentUser == YES
1027 /// </string
1028 /// >
1029 /// <key
1030 /// >SubInteractions
1031 /// </key
1032 /// >
1033 /// <array
1034 /// >
1035 /// <dict
1036 /// >
1037 /// <key
1038 /// >ActivationRule
1039 /// </key
1040 /// >
1041 /// <string
1042 /// >sourceItemsCount == 1
1043 /// </string
1044 /// >
1045 /// <key
1046 /// >Alert
1047 /// </key
1048 /// >
1049 /// <dict
1050 /// >
1051 /// <key
1052 /// >LocalizedTitle
1053 /// </key
1054 /// >
1055 /// <dict
1056 /// >
1057 /// <key
1058 /// >NSStringFormat
1059 /// </key
1060 /// >
1061 /// <string
1062 /// >This shared item can't be moved.
1063 /// </string
1064 /// >
1065 /// </dict
1066 /// >
1067 /// <key
1068 /// >LocalizedSubTitle
1069 /// </key
1070 /// >
1071 /// <dict
1072 /// >
1073 /// <key
1074 /// >NSStringFormat
1075 /// </key
1076 /// >
1077 /// <string
1078 /// >Items shared with you can’t be moved to shared folders
1079 /// </string
1080 /// >
1081 /// </dict
1082 /// >
1083 /// </dict
1084 /// >
1085 /// <key
1086 /// >RecoveryOptions
1087 /// </key
1088 /// >
1089 /// <dict
1090 /// >
1091 /// <key
1092 /// >Continue
1093 /// </key
1094 /// >
1095 /// <false
1096 /// />
1097 /// </dict
1098 /// >
1099 /// </dict
1100 /// >
1101 /// </array
1102 /// >
1103 /// </dict
1104 /// >
1105 /// </array
1106 /// >
1107 /// </array
1108 /// >
1109 /// ```
1110 #[optional]
1111 #[unsafe(method(userInfo))]
1112 #[unsafe(method_family = none)]
1113 unsafe fn userInfo(&self) -> Option<Retained<NSDictionary>>;
1114
1115 /// Declarative API to define the item content policy according to the available NSFileProviderContentPolicy
1116 #[optional]
1117 #[unsafe(method(contentPolicy))]
1118 #[unsafe(method_family = none)]
1119 unsafe fn contentPolicy(&self) -> NSFileProviderContentPolicy;
1120 }
1121);
1122
1123/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideritem?language=objc)
1124pub type NSFileProviderItem = ProtocolObject<dyn NSFileProviderItemProtocol>;