Class NSFileProviderManager

  • All Implemented Interfaces:
    NSObject

    public class NSFileProviderManager
    extends NSObject
    The file provider manager allows you to communicate with the file provider framework from both the extension and related processes. NSFileProviderManager can be used from the following processes: - the extension - the main app containing the extension - sibling extensions to the extension - executables contained in the main app bundle (on macOS only) Executables contained in the main app bundle need to have a bundle identifier that is prefixed by the bundle identifier of the main app (note that this is generally required for extensions). They must also have access to the document group defined for the provider (via its `NSExtensionFileProviderDocumentGroup` key). The file provider framework will invoke your file provider extension in response to those calls if appropriate. The class also provides methods to manage provider domains. Each domain has a corresponding manager. API-Since: 11.0
    • Constructor Detail

      • NSFileProviderManager

        protected NSFileProviderManager​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • addDomainCompletionHandler

        public static void addDomainCompletionHandler​(@NotNull
                                                      @NotNull NSFileProviderDomain domain,
                                                      @NotNull
                                                      @NotNull NSFileProviderManager.Block_addDomainCompletionHandler completionHandler)
        Register a domain in which items can be stored. If a domain with the same identifier already exists, `addDomain` will update the display name and hidden state of the domain and succeed. When the domain is backed by a NSFileProviderReplicatedExtension, the system will create a disk location where the domain will be replicated. If that location already exists on disk this call will fail with the code NSFileWriteFileExistsError.
      • allocWithZone

        public static NSFileProviderManager allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(@NotNull
                                                                   @NotNull java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(@NotNull
                                                                                 @NotNull java.lang.Object aTarget,
                                                                                 @NotNull
                                                                                 @NotNull org.moe.natj.objc.SEL aSelector,
                                                                                 @Nullable
                                                                                 @Nullable java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        @NotNull
        public static @NotNull NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        @NotNull
        public static @NotNull org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • defaultManager

        @NotNull
        public static @NotNull NSFileProviderManager defaultManager()
        Return the manager responsible for the default domain.
      • description_static

        public static java.lang.String description_static()
      • documentStorageURL

        @NotNull
        public @NotNull NSURL documentStorageURL()
        The root URL for provided documents. This URL is derived by consulting the NSExtensionFileProviderDocumentGroup property on your extension. The document storage URL is the folder "File Provider Storage" in the corresponding container. If the NSExtensionFileProviderDocumentGroup property is not set, calling this method will result in an error. API-Since: 11.0
      • hash_static

        public static long hash_static()
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
      • placeholderURLForURL

        @NotNull
        public static @NotNull NSURL placeholderURLForURL​(@NotNull
                                                          @NotNull NSURL url)
        Returns the designated placeholder URL for a given file URL. Used in conjunction with writePlaceholderAtURL. API-Since: 11.0
      • providerIdentifier

        @NotNull
        public @NotNull java.lang.String providerIdentifier()
        The purpose identifier of your file provider extension. A coordination using a file coordinator with this purpose identifier set will not trigger your file provider extension. You can use this to e.g. perform speculative work on behalf of the file provider from the main app. API-Since: 11.0
      • registerURLSessionTaskForItemWithIdentifierCompletionHandler

        public void registerURLSessionTaskForItemWithIdentifierCompletionHandler​(@NotNull
                                                                                 @NotNull NSURLSessionTask task,
                                                                                 @NotNull
                                                                                 @NotNull java.lang.String identifier,
                                                                                 @NotNull
                                                                                 @NotNull NSFileProviderManager.Block_registerURLSessionTaskForItemWithIdentifierCompletionHandler completion)
        Registers the given NSURLSessionTask to be responsible for the specified item. A given item can only have one task registered at a time. The task must be suspended at the time of calling. The task's progress is displayed on the item when the task is executed.
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • signalEnumeratorForContainerItemIdentifierCompletionHandler

        public void signalEnumeratorForContainerItemIdentifierCompletionHandler​(@NotNull
                                                                                @NotNull java.lang.String containerItemIdentifier,
                                                                                @NotNull
                                                                                @NotNull NSFileProviderManager.Block_signalEnumeratorForContainerItemIdentifierCompletionHandler completion)
        Call this method either in the app or in the extension to trigger an enumeration, typically in response to a push. When using NSFileProviderExtension, the system will enumerate containers while the user is viewing them in the UI. If there are changes to the container while an enumerator is open, call this method with the identifier of that container. This will trigger another call to -[NSFileProviderEnumerator enumerateChangesForObserver:fromSyncAnchor:] on that enumerator, and the UI will be refreshed, giving the user live updates on the presented enumeration. If there are changes in the working set, call this method with containerItemIdentifier set to NSFileProviderWorkingSetContainerItemIdentifier, even if there is no live enumeration for the working set container. When using NSFileProviderReplicatedExtension, only call this method with NSFileProviderWorkingSetContainerItemIdentifier. Other container identifiers are ignored. The system will automatically propagate working set changes to the UI, without explicitly signaling the containers currently being viewed in the UI. In addition to using this method, your application/extension can register for pushes using the PKPushTypeFileProvider push type. Pushes of the form { "container-identifier": "", "domain": "" } with a topic of ".pushkit.fileprovider" will be translated into a call to signalEnumeratorForContainerItemIdentifier:completionHandler:.
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • version_static

        public static long version_static()
      • writePlaceholderAtURLWithMetadataError

        public static boolean writePlaceholderAtURLWithMetadataError​(@NotNull
                                                                     @NotNull NSURL placeholderURL,
                                                                     @NotNull
                                                                     @NotNull NSFileProviderItem metadata,
                                                                     @Nullable
                                                                     @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Writes out a placeholder at the specified URL. The placeholder is used in place of the actual file for operations that do not require the file's actual data to be on disk: - if attributes are requested by an application via the getPromisedItemResourceValue: method on NSURL - or via a coordination with the NSFileCoordinatorReadingImmediatelyAvailableMetadataOnly flag set - to verify whether an application has access to a file Your extension should provide placeholders by implementing the providePlaceholderAtURL: method, but your application may choose to proactively write out placeholders to facilitate access to files. This is especially useful if your application wants to actively hand out a file URL, e.g. using UIActivityViewController, in which case it should ensure that either the file or a placeholder is present on disk first. The path of the placeholder is fixed and must be determined in advance by calling the placeholderURLForURL: method. API-Since: 11.0
      • enumeratorForMaterializedItems

        @NotNull
        public @NotNull NSFileProviderEnumerator enumeratorForMaterializedItems()
        Returns an enumerator for the set of materialized items. When calling -[NSFileProviderEnumerator enumerateItemsForObserver:startingAtPage:] on the returned enumerator, pass the result of [NSData new] as the starting page. The sorting page constants (NSFileProviderInitialPageSortedByName and NSFileProviderInitialPageSortedByDate) will not influence the order of the items enumerated from the materialized set. This enumerator is unlike other enumerators because the roles of the system and the app/extension are reversed: - The system enumerates the working set after the extension calls 'signalEnumeratorForContainerItemIdentifier'; - The app/extension enumerates the materialized set after the system calls 'materializedItemsDidChangeWithCompletionHandler'. API-Since: 16.0
      • enumeratorForPendingItems

        @NotNull
        public @NotNull NSFileProviderPendingSetEnumerator enumeratorForPendingItems()
        Returns an enumerator for the set of pending items. This enumerator behaves like the materialized set enumerator. On later modifications in the set, the system will call 'pendingItemsDidChangeWithCompletionHandler'. API-Since: 16.0
      • evictItemWithIdentifierCompletionHandler

        public void evictItemWithIdentifierCompletionHandler​(@NotNull
                                                             @NotNull java.lang.String itemIdentifier,
                                                             @NotNull
                                                             @NotNull NSFileProviderManager.Block_evictItemWithIdentifierCompletionHandler completionHandler)
        Request that the system remove an item from its cache. When called on a file, the file will be made dataless. When called on a directory, first each of the directory's children will be evicted (child files are made dataless, child directories are recursively evicted). Then the directory itself will be made dataless. If a non-evictable child is encountered, eviction will stop immediately and the completionHandler will be called with the NSFileProviderErrorNonEvictableChildren error. The error will include information on why and which children could not be evicted in -[NSError underlyingErrors]. The materialization state of the remaining items may be either materialized or evicted, depending on the traversal order. The completion handler is called after the items have been evicted from disk or immediately when an error occurs. Eviction might fail with the following errors : - NSFileProviderErrorDomain.NSFileProviderErrorUnsyncedEdits if the item had non-uploaded changes. - NSFileProviderErrorDomain.NSFileProviderErrorNonEvictable if the item has been marked as non-purgeable by the provider. - NSPOSIXErrorDomain.EBUSY : if the item has open file descriptors on it. - NSPOSIXErrorDomain.EMLINK : if the item has several hardlinks. - other NSPOSIXErrorDomain error codes if the system was unable to access or manipulate the corresponding file. API-Since: 16.0
      • getIdentifierForUserVisibleFileAtURLCompletionHandler

        public static void getIdentifierForUserVisibleFileAtURLCompletionHandler​(@NotNull
                                                                                 @NotNull NSURL url,
                                                                                 @NotNull
                                                                                 @NotNull NSFileProviderManager.Block_getIdentifierForUserVisibleFileAtURLCompletionHandler completionHandler)
        Return the identifier and domain for a user visible URL. This method returns the identifier and domain of a user visible URL if applicable. Calling this method on a file which doesn't reside in your provider/domain, or which hasn't yet been assigned an identifier by the provider will return the Cocoa error NSFileNoSuchFileError. API-Since: 16.0
      • getServiceWithNameItemIdentifierCompletionHandler

        public void getServiceWithNameItemIdentifierCompletionHandler​(@NotNull
                                                                      @NotNull java.lang.String serviceName,
                                                                      @NotNull
                                                                      @NotNull java.lang.String itemIdentifier,
                                                                      @NotNull
                                                                      @NotNull NSFileProviderManager.Block_getServiceWithNameItemIdentifierCompletionHandler completionHandler)
        Retrieve the service with the specified named for the specified item.
      • getUserVisibleURLForItemIdentifierCompletionHandler

        public void getUserVisibleURLForItemIdentifierCompletionHandler​(@NotNull
                                                                        @NotNull java.lang.String itemIdentifier,
                                                                        @NotNull
                                                                        @NotNull NSFileProviderManager.Block_getUserVisibleURLForItemIdentifierCompletionHandler completionHandler)
        Return the security scoped URL to the user visible location for an item identifier. The caller must use file coordination (see NSFileCoordinator) if it wishes to read the content or list the children of the URL. The caller should not try to manipulate files in the user visible location. All changes coming from the provider should go through updates in the working set that will be applied to the user visible items by the system. The location may differ from the logical parentURL/filename. If an item on disk cannot be assigned the requested name (e.g. because the local file system has different case collision rules from the provider), one of the items can be assigned a different local name. In that case, the "com.apple.fileprovider.before-bounce#P" extended attribute will contain the filename before collision resolution. This attribute is only set if the item has been assigned a different local name following a collision. Such local names are not synced up to the provider; the purpose of the attribute is to enable consistency checkers to detect this case. Before accessing the content of the returned URL, the caller must call `-[NSURL startAccessingSecurityScopedResource] on the returned URL and call `-[NSURL stopAccessingSecurityScopedResource]` when done accessing the content. The returned URL grants read-write access to the user visible location for the corresponding item. On iOS, for replicated domains, the extension process will never be granted access to the user visible location, this function will always fail with `NSFileReadNoPermissionError`. API-Since: 16.0
      • globalProgressForKind

        @NotNull
        public @NotNull NSProgress globalProgressForKind​(@NotNull
                                                         @NotNull java.lang.String kind)
        Returns the global progress for the specified kind of operations This progress tracks all the ongoing kind of operations (from disk to the provider). Uploading operations are the operations from disk to the provider. Downloading operations are the operations from the provider to the disk. The global progress exposes the two following data: - Number of items with an ongoing matching kind operation along with the grand total; - Number of bytes already transferred along with the total amount of bytes to transfer. `totalUnitCount` will only be reset when there are no operations left. If new operations of the matching kind arrive while the global progress is already ongoing, they will just be summed to the existing global progress. By default, when no matching kind operations are active, the progress has its values set to 1 and its state set to finished. The progress will be updated on the main queue. It is to be retained by the caller and to be observed through KVO. The two only supported values for kind are: - NSProgressFileOperationKindUploading - NSProgressFileOperationKindDownloading The returned progress will have its fileOperationKind property set. API-Since: 16.0
      • importDomainFromDirectoryAtURLCompletionHandler

        public static void importDomainFromDirectoryAtURLCompletionHandler​(@NotNull
                                                                           @NotNull NSFileProviderDomain domain,
                                                                           @NotNull
                                                                           @NotNull NSURL url,
                                                                           @NotNull
                                                                           @NotNull NSFileProviderManager.Block_importDomainFromDirectoryAtURLCompletionHandler completionHandler)
        Request the creation of a new domain that will take ownership of on-disk data that were previously managed without a file provider. You can use this method in order to migrate from a software that managed a file hierarchy on disk to a NSFileProviderExtension without having to redownload the data that was already on disk. The URL is expected to point to a directory. That directory will be moved away, its ownership being taken by the system. From this point, your extension's createItemFromTemplate method will be called for every item found in the directory with the special NSFileProviderCreateItemMayAlreadyExist option. In case a domain with the same name already exists in the file provider manager, the call will fail with the code NSFileWriteFileExistsError. The URL will remain untouched. In case the system does not allow the extension to request a migration, the call will fail with NSFeatureUnsupportedError. In case of success, the URL will become invalid and the domain will be created. The completion handler is called as soon as the domain is created. Your provider will receive calls to createItemBasedOnTemplate afterward. When the import of the file hierarchy is finished, the system calls -[NSFileProviderExtension signalDidFinishImportingItemsFromDiskWithCompletionHandler:]. In case -[NSFileProviderManager reimportItemsBelowItemWithIdentifier:completionHandler:] is called before the end of the import, a single call to importDidFinishWithCompletionHandler will be received for both the import and the scan. API-Since: 16.0
      • listAvailableTestingOperationsWithError

        @Nullable
        public @Nullable NSArray<?> listAvailableTestingOperationsWithError​(@Nullable
                                                                            @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        List the available operations. This lists all of the operations that are ready to be scheduled by the system. The system waits for all the pending disk and working set updates to be known before returning. The operations that are returned may become invalid if the system receives new disk or working set events, or if some operation are scheduled using -runTestingOperations:error:. API-Since: 16.0
      • reimportItemsBelowItemWithIdentifierCompletionHandler

        public void reimportItemsBelowItemWithIdentifierCompletionHandler​(@NotNull
                                                                          @NotNull java.lang.String itemIdentifier,
                                                                          @NotNull
                                                                          @NotNull NSFileProviderManager.Block_reimportItemsBelowItemWithIdentifierCompletionHandler completionHandler)
        Notify the system that the itemIdentifiers known by the system are not valid anymore. This can be called by an extension in case it has lost track of its synchronisation state and as a consequence is not able to guarantee the stability of the itemIdentifiers anymore. In that case, the system will trigger a scan of any data that is cached on disk and call createItemBasedOnTemplate with the special NSFileProviderCreateItemMayAlreadyExist option so that the extension can specify the new itemIdentifier for those items. The provided item identifier is inclusive, meaning the specified item will be re-import as well as any children in case it is a container. In case the extension has lost its synchronisation state but is still able to guarantee the stability of the itemIdentifiers, it should make sure that querying the working set enumerator with an anchor that predates the synchronisation loss will cause a NSFileProviderErrorSyncAnchorExpired error. In case the extension has lost its synchronisation state and is not interested in preserving the data cached on disk, it can remove and re-add the affected domain. The completion handler is called immediately and does not reflect the end of the import. When the import of the file hierarchy is finished, the system calls -[NSFileProviderExtension importDidFinishWithCompletionHandler:]. In some circumstances, in particular in case the requested item is the root item, calling reimport will cause the system to stop the extension process. If the call is initiated from the extension, the system does not guarantee that the completion handler will be called before the extension is stopped. When called on the root item, reimport will cause the system to rebuild its backing store for the domain. See `-[NSFileProviderDomain backingStoreIdentity]`. If this method succeeds, the system will reimport at least the requested sub-tree, but may import more. If the requested item has no on-disk representation, the completion handler will be called with a NSFileProviderErrorNoSuchItem error. The same error will be reported if the reimport request happens quickly after a previous import / reimport and the corresponding item hasn't been reimported yet. API-Since: 16.0
      • requestModificationOfFieldsForItemWithIdentifierOptionsCompletionHandler

        public void requestModificationOfFieldsForItemWithIdentifierOptionsCompletionHandler​(long fields,
                                                                                             @NotNull
                                                                                             @NotNull java.lang.String itemIdentifier,
                                                                                             long options,
                                                                                             @NotNull
                                                                                             @NotNull NSFileProviderManager.Block_requestModificationOfFieldsForItemWithIdentifierOptionsCompletionHandler completionHandler)
        Request that the system schedules a call to -[NSFileProviderReplicatedExtension modifyItem:] for the given item identifier. The fields passed to modifyItem will contain at least the set requested via the `fields` parameter. The completion handler is called when the system has persisted the request. There is no guarantee as to when the modifyItem call will be scheduled. The completion handler may be called with an error. If the provider passes the `.content` field when the item is not downloaded, or when the item is a folder, then the system will return CocoaError(.ubiquitousFileUnavailable). API-Since: 16.0
      • runTestingOperationsError

        @Nullable
        public @Nullable NSDictionary<?,​? extends NSError> runTestingOperationsError​(@NotNull
                                                                                           @NotNull NSArray<?> operations,
                                                                                           @Nullable
                                                                                           @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Run a set of operations. Ask the system to schedule the execution of the listed operations. The system will wait until all those operations have completed and report a per-operation error in case an operation fails. API-Since: 16.0
      • signalErrorResolvedCompletionHandler

        public void signalErrorResolvedCompletionHandler​(@NotNull
                                                         @NotNull NSError error,
                                                         @NotNull
                                                         @NotNull NSFileProviderManager.Block_signalErrorResolvedCompletionHandler completionHandler)
        Calling this method will cause the system to cancel throttling on every item which has been throttled due to the given error. This call supports 4 types of errors: - NSFileProviderErrorNotAuthenticated - NSFileProviderErrorInsufficientQuota - NSFileProviderErrorServerUnreachable - NSFileProviderErrorCannotSynchronize API-Since: 16.0
      • temporaryDirectoryURLWithError

        @Nullable
        public @Nullable NSURL temporaryDirectoryURLWithError​(@Nullable
                                                              @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        A temporary directory suitable to store files that will be exchanged with the system. The returned URL is guaranteed to be on the same volume as the user visible URL, making sure the system can atomatically clone/move files from that location to the user visible URL. The provider can also use that directory as a target for moves and clones of content URL passed to createItemBasedOnTemplate or modifyItem. If the system cannot find a suitable directory, this calls will fail. This could happen e.g. if the domain does not exist. This call will not fail when called from the extension process with an active instance of the extension for that domain. API-Since: 16.0
      • waitForChangesOnItemsBelowItemWithIdentifierCompletionHandler

        public void waitForChangesOnItemsBelowItemWithIdentifierCompletionHandler​(@NotNull
                                                                                  @NotNull java.lang.String itemIdentifier,
                                                                                  @NotNull
                                                                                  @NotNull NSFileProviderManager.Block_waitForChangesOnItemsBelowItemWithIdentifierCompletionHandler completionHandler)
        Wait for all changes on disk in the sub-hierarchy of the item to be acknowledged by the extension. This call can be used to guarantee operation ordering in a sub-hierarchy of the provider. The completion handler is called when all the changes for descendents of the item have been acknowledged by the extension. If any error is met during that process, an error will be raised, in which case the caller should not assume all the changes have been received. This call will only wait for changes affecting items that were already descendents of the requested item in the provider, or items that have been newly created on disk. It will not wait for items that are already known from the provider and are being moved in the directory. As a consequence, that call can be used from within a call to -[NSFileProviderReplicatedExtension modifyItem:baseVersion:changedFields:contents:options:completionHandler:]. Also note that the call will return immediately on items that are not directories. In case a change cannot be applied to the provider, the call will fail with NSFileProviderErrorCannotSynchronize including the NSFileProviderErrorItemKey with the identifier of the item that could not be synced if that item is known by the provider. API-Since: 16.0
      • waitForStabilizationWithCompletionHandler

        public void waitForStabilizationWithCompletionHandler​(@NotNull
                                                              @NotNull NSFileProviderManager.Block_waitForStabilizationWithCompletionHandler completionHandler)
        Wait for stabilization of the domain. The system will wait until it is caught up with the file system's changes up to the time of the call, then wait until it is caught up with the provider's changes up to the time of the call. The completion handler is called when both sets of changes are caught up to at least the time of the call. This is useful to enforce a consistent state for testing. API-Since: 16.0
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.