-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileProvider.framework.h
2205 lines (1750 loc) · 96.8 KB
/
FileProvider.framework.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========== FileProvider.framework/Headers/NSFileProviderEnumerating.h
//
// NSFileProviderEnumerating.h
// FileProvider
//
// Copyright (c) 2014-2017 Apple Inc. All rights reserved.
//
#import <FileProvider/NSFileProviderExtension.h>
#import <FileProvider/NSFileProviderItem.h>
#import <FileProvider/NSFileProviderSearchQuery.h>
#if TARGET_OS_OSX
#import <CoreGraphics/CoreGraphics.h>
#endif
NS_ASSUME_NONNULL_BEGIN
/**
A user-defined chunk of data that defines a starting point to enumerate changes
from.
The size of a sync anchor should not exceed a combined 500 bytes.
*/
typedef NSData *NSFileProviderSyncAnchor NS_TYPED_EXTENSIBLE_ENUM;
/**
A user- or system-defined chunk of data that defines a page to continue the
enumeration from. Initial enumeration is started from one of the below
system-defined pages.
The size of a page should not exceed 500 bytes.
*/
typedef NSData *NSFileProviderPage NS_TYPED_EXTENSIBLE_ENUM;
FOUNDATION_EXPORT API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos)
NSFileProviderPage const NSFileProviderInitialPageSortedByDate;
FOUNDATION_EXPORT API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos)
NSFileProviderPage const NSFileProviderInitialPageSortedByName;
@protocol NSFileProviderEnumerationObserver <NSObject>
- (void)didEnumerateItems:(NSArray <id<NSFileProviderItem>> *)updatedItems;
/**
Call this method after enumerating a full page of items. If you set a non-nil
nextPage, -[NSFileProviderEnumerator enumerateItemsToObserver:startingAtPage:]
might be called with nextPage to enumerate more items. This is typically
driven by the user scrolling a UIDocumentBrowserViewController presenting a
directory containing more child items that would fit in the view.
Page data is limited to 500 bytes. Setting a larger nextPage interrupts the
enumeration.
*/
- (void)finishEnumeratingUpToPage:(nullable NSFileProviderPage)nextPage NS_SWIFT_NAME(finishEnumerating(upTo:));
- (void)finishEnumeratingWithError:(NSError *)error;
@end
@protocol NSFileProviderChangeObserver <NSObject>
/**
Send updates to existing items, or insert new items.
*/
- (void)didUpdateItems:(NSArray <id<NSFileProviderItem>> *)updatedItems;
/**
Delete existing items. No-op if the item was unknown.
*/
- (void)didDeleteItemsWithIdentifiers:(NSArray <NSFileProviderItemIdentifier> *)deletedItemIdentifiers;
/**
Call the following method every so often while sending changes, particularly
while enumerating changes to NSFileProviderWorkingSetContainerItemIdentifier.
If the device reboots during an enumeration, it would later resume starting
at the latest known sync anchor.
It is expected that the sync anchor passed here be different than the sync
anchor that the enumeration started at, unless the client was already up to
date on all the changes on the server, and didn't have any pending updates or
deletions.
Additionally, if the client is up to date on all the changes on the server it
should set moreComing to NO.
Sync anchor data is limited to 500 bytes. Setting a larger anchor has the
same effect as calling finishEnumeratingWithError with an expired sync anchor
error.
*/
- (void)finishEnumeratingChangesUpToSyncAnchor:(NSFileProviderSyncAnchor)anchor
moreComing:(BOOL)moreComing NS_SWIFT_NAME(finishEnumeratingChanges(upTo:moreComing:));
/**
If the enumeration fails with NSFileProviderErrorSyncAnchorExpired, we will
drop all cached data and start the enumeration over starting with sync anchor
nil.
*/
- (void)finishEnumeratingWithError:(NSError *)error;
@end
@protocol NSFileProviderEnumerator <NSObject>
- (void)invalidate;
/**
Enumerate items starting from the specified page, typically
NSFileProviderInitialPageSortedByDate or NSFileProviderInitialPageSortedByName.
Pagination allows large collections to be enumerated in multiple batches. The
sort order specified in the initial page is important even if the enumeration
results will actually be sorted again before display. If results are sorted
correctly across pages, then the new results will be appended at the bottom of
the list, probably not on screen, which is the best user experience. Otherwise
results from the second page might be inserted in the results from the first
page, causing bizarre animations.
The page data should contain whatever information is needed to resume the
enumeration after the previous page. If a file provider sends batches of 200
items to -[NSFileProviderEnumerationObserver didEnumerateItems:] for example,
then successive pages might contain offsets in increments of 200.
*/
- (void)enumerateItemsForObserver:(id<NSFileProviderEnumerationObserver>)observer
startingAtPage:(NSFileProviderPage)page NS_SWIFT_NAME(enumerateItems(for:startingAt:));
@optional
/**
Enumerate changes starting from a sync anchor. This should enumerate /all/
changes (not restricted to a specific page) since the given sync anchor.
Until the enumeration update is invalidated, a call to -[NSFileProviderManager
signalEnumeratorForContainerItemIdentifier:completionHandler:] will trigger a
call to enumerateFromSyncAnchor with the latest known sync anchor, giving the
file provider (app or extension) a chance to notify about changes.
The anchor data should contain whatever information is needed to resume
enumerating changes from the previous synchronization point. A naive sync
anchor might for example be the date of the last change that was sent from the
server to the client, meaning that at that date, the client was in sync with
all the server changes. A request to enumerate changes from that sync anchor
would only return the changes that happened after that date, which are
therefore changes that the client doesn't yet know about.
NOTE that the change-based observation methods are marked optional for historical
reasons, but are really required. System performance will be severely degraded if
they are not implemented.
*/
- (void)enumerateChangesForObserver:(id<NSFileProviderChangeObserver>)observer
fromSyncAnchor:(NSFileProviderSyncAnchor)syncAnchor NS_SWIFT_NAME(enumerateChanges(for:from:));
/**
Request the current sync anchor.
To keep an enumeration updated, the system will typically
- request the current sync anchor (1)
- enumerate items starting with an initial page
- continue enumerating pages, each time from the page returned in the previous
enumeration, until finishEnumeratingUpToPage: is called with nextPage set to
nil
- enumerate changes starting from the sync anchor returned in (1)
- continue enumerating changes, each time from the sync anchor returned in the
previous enumeration, until finishEnumeratingChangesUpToSyncAnchor: is called
with moreComing:NO
This method will be called again if you signal that there are more changes with
-[NSFileProviderManager signalEnumeratorForContainerItemIdentifier:
completionHandler:] and again, the system will enumerate changes until
finishEnumeratingChangesUpToSyncAnchor: is called with moreComing:NO.
NOTE that the change-based observation methods are marked optional for historical
reasons, but are really required. System performance will be severely degraded if
they are not implemented.
*/
- (void)currentSyncAnchorWithCompletionHandler:(void(^)(_Nullable NSFileProviderSyncAnchor currentAnchor))completionHandler;
#if TARGET_OS_OSX
/**
Notify that the window that is presenting this enumerator has become frontmost.
This method will only be called if the enumerator was instantiated to subscribe to
live updates for a single document, as described under enumeratorForContainerItemIdentifier:error:
below. The extension must have been granted access to presence information; see
NSFileProviderExtension -requestPresenceAuthorization.
*/
- (void)didPresentEnumeratorInWindow:(CGWindowID)window frontmost:(BOOL)frontmost API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios, watchos, tvos) NS_SWIFT_NAME(didPresent(in:frontmost:));
#endif
@end
@interface NSFileProviderExtension (NSFileProviderEnumeration)
/**
Create an enumerator for an item.
When the user opens the browse tab of the UIDocumentsBrowserViewController and
selects a file provider, this is called with
NSFileProviderRootContainerItemIdentifier, and -[NSFileProviderEnumerator
enumerateItemsForObserver:startingAtPage:] is immediately called to list the
first items available under at the root level of the file provider.
As the user navigates down into directories, new enumerators are created with
this method, passing in the itemIdentifier of those directories. Past
enumerators are then invalidated.
This method is also called with
NSFileProviderWorkingSetContainerItemIdentifier, which is enumerated with
-[NSFileProviderEnumerator enumerateChangesForObserver:fromSyncAnchor:]. That
enumeration is special in that it isn't driven by the
UIDocumentsBrowserViewController. It happens in the background to sync the
working set down to the device.
This is also used to subscribe to live updates for a single document. In that
case, -[NSFileProviderEnumerator enumerateChangesToObserver:fromSyncAnchor:]
will be called and the enumeration results shouldn't include items other than
the very item that the enumeration was started on.
If returning nil, you must set the error out parameter.
*/
- (nullable id<NSFileProviderEnumerator>)enumeratorForContainerItemIdentifier:(NSFileProviderItemIdentifier)containerItemIdentifier
error:(NSError **)error NS_SWIFT_NAME(enumerator(for:));
/**
Create an enumerator for all items matching a given search query.
In order to be invoked to perform a remote search a provider needs to specify
in its plist an array of supported search filters under the property name
NSExtensionFileProviderSupportedSearchCapabilities. The allowed values are:
- NSExtensionFileProviderSearchByFilename
- NSExtensionFileProviderSearchByContentType
- NSExtensionFileProviderSearchScopedToDirectory
NSExtensionFileProviderSearchByFilename is always assumed to be available.
The enumerator returned will be invalidated when the search results are
discarded.
If returning nil, you must set the error out parameter.
*/
- (nullable id<NSFileProviderEnumerator>)enumeratorForSearchQuery:(NSFileProviderSearchQuery *)searchQuery
error:(NSError **)error API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== FileProvider.framework/Headers/NSFileProviderDomain.h
//
// NSFileProviderDomain.h
// FileProvider
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <FileProvider/NSFileProviderExtension.h>
NS_ASSUME_NONNULL_BEGIN
typedef NSString *NSFileProviderDomainIdentifier NS_EXTENSIBLE_STRING_ENUM;
/**
File provider domain.
A file provider domain can be used to represent accounts or different locations
exposed within a given file provider.
Domains can be registered to the system using
@c -[NSFileProviderMananger addDomain:completionHandler:]
By default, a file provider extension does not have any domain.
On the extension side, a separate instance of NSFileProviderExtension will be
created for each @c NSFileProviderDomain registered. In that case, the
@c NSFileProviderExtension.domain properties will indicate which domain the
NSFileProviderExtension belongs to (or nil if none).
All the files on disk belonging to the same domain must be grouped inside a
common directory. That directory path is indicated by the
@p pathRelativeToDocumentStorage property.
*/
API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos)
@interface NSFileProviderDomain : NSObject
/**
Initialize a new NSFileProviderDomain
The file provider extension implementation can pick any @c identifier as it sees
fit to identify the group of items.
@param displayName a user visible string representing the group of items the
file provider extension is using.
@param pathRelativeToDocumentStorage a path relative to
@c NSFileProviderExtension.documentStorageURL.
*/
- (instancetype)initWithIdentifier:(NSFileProviderDomainIdentifier)identifier displayName:(NSString *)displayName pathRelativeToDocumentStorage:(NSString *)pathRelativeToDocumentStorage;
/**
The identifier - as provided by the file provider extension.
*/
@property (readonly, copy) NSFileProviderDomainIdentifier identifier;
/**
The display name shown by the system to represent this domain.
*/
@property (readonly, copy) NSString *displayName;
/**
The path relative to the document storage of the file provider extension.
Files belonging to this domains should be stored under this path.
*/
@property (readonly, copy) NSString *pathRelativeToDocumentStorage;
/* If set, the domain is present, but disconnected from its extension.
In this state, the user continues to be able to browse the domain's contents,
but the extension doesn't receive updates on modifications to the files, nor is
it consulted to update folder's contents.
The disconnected state can be modified on an existing domain by recreating a domain
with the same identifier, then passing it to addDomain.
*/
@property (readwrite, getter=isDisconnected) BOOL disconnected API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@end
API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos)
@interface NSFileProviderExtension (NSFileProviderDomain)
@property(nonatomic, readonly, nullable) NSFileProviderDomain *domain;
@end
NS_ASSUME_NONNULL_END
// ========== FileProvider.framework/Headers/NSFileProviderRequest.h
//
// NSFileProviderRequest.h
// FileProvider
//
// Copyright © 2018 Apple Inc. All rights reserved.
//
#import <FileProvider/NSFileProviderExtension.h>
#import <FileProvider/NSFileProviderManager.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos)
@interface NSFileProviderRequest : NSObject
/**
An identifier for the application. The identifier is system-specific and may
change between different installations of the application.
*/
@property (nonatomic, readonly, strong) NSUUID *requestingApplicationIdentifier;
/**
The following properties are available only after user opt-in, via the
-requestPresenceAuthorization method on NSFileProviderManager.
*/
@property (nonatomic, readonly, copy, nullable) NSURL *requestingExecutable API_UNAVAILABLE(ios);
@end
@interface NSFileProviderExtension (Request)
- (nullable NSFileProviderRequest *)currentRequest API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@end
typedef NS_ENUM(NSUInteger, NSFileProviderPresenceAuthorizationStatus) {
NSFileProviderPresenceAuthorizationNotDetermined,
NSFileProviderPresenceAuthorizationRestricted,
NSFileProviderPresenceAuthorizationDenied,
NSFileProviderPresenceAuthorizationAllowed
};
@interface NSFileProviderManager (Presence)
@property (nonatomic, assign, readonly) NSFileProviderPresenceAuthorizationStatus presenceAuthorizationStatus API_UNAVAILABLE(ios);
/**
If (presenceAuthorizationStatus == NSFileProviderPresenceAuthorizationNotDetermined),
presents a dialog requesting authorization to share additional information
about requests with the provider.
The authorization dialog will display the contents of the
NSFileProviderPresenceUsageDescription key. The key must be present in the
app's Info.plist.
*/
- (void)requestPresenceAuthorization API_UNAVAILABLE(ios);
@end
NS_ASSUME_NONNULL_END
// ========== FileProvider.framework/Headers/NSFileProviderError.h
//
// NSFileProviderError.h
// FileProvider
//
// Copyright (c) 2014-2017 Apple Inc. All rights reserved.
//
#import <FileProvider/NSFileProviderDefines.h>
#import <FileProvider/NSFileProviderItem.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXPORT NSErrorDomain const NSFileProviderErrorDomain API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
FOUNDATION_EXPORT NSString * const NSFileProviderErrorCollidingItemKey API_DEPRECATED("NSFileProviderErrorItemKey", ios(8.0, 13.0)) API_UNAVAILABLE(macos, tvos, watchos);
FOUNDATION_EXPORT NSString * const NSFileProviderErrorItemKey API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
FOUNDATION_EXPORT NSString * const NSFileProviderErrorNonExistentItemIdentifierKey API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
typedef NS_ERROR_ENUM(NSFileProviderErrorDomain, NSFileProviderErrorCode) {
/** The user credentials cannot be verified */
NSFileProviderErrorNotAuthenticated = -1000,
/** An item already exists with the same parentItemIdentifier and filename (or with a filename differing only in case.)
\note Please use -[NSError (NSFileProviderError) fileProviderErrorForCollisionWithItem:] to build an error with this code.
\see -[NSError (NSFileProviderError) fileProviderErrorForCollisionWithItem:]
*/
NSFileProviderErrorFilenameCollision = -1001,
/** The value of the sync anchor is too old, and the system must re-sync from scratch */
NSFileProviderErrorSyncAnchorExpired = -1002,
/** The value of the page token is too old, and the system must re-sync from scratch */
NSFileProviderErrorPageExpired = NSFileProviderErrorSyncAnchorExpired,
/** The item has not been uploaded because it would push the account over quota */
NSFileProviderErrorInsufficientQuota = -1003,
/** Connecting to the servers failed */
NSFileProviderErrorServerUnreachable = -1004,
/** The requested item doesn't exist
\note Please use -[NSError (NSFileProviderError) fileProviderErrorForNonExistentItemWithIdentifier:] to build an error with this code.
\see -[NSError (NSFileProviderError) fileProviderErrorForNonExistentItemWithIdentifier:]
*/
NSFileProviderErrorNoSuchItem = -1005,
/** The requested version is not the latest version of the file.
\note Please use -[NSError (NSFileProviderError) fileProviderErrorForOutOfDateItem:] to build an error with this code.
\see -[NSError (NSFileProviderError) fileProviderErrorForOutOfDateItem:]
*/
NSFileProviderErrorVersionOutOfDate API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos) = -1006,
/** We're trying to non-recursively delete a non-empty directory
*/
NSFileProviderErrorDirectoryNotEmpty API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos) = -1007,
} API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
@interface NSError (NSFileProviderError)
+ (instancetype)fileProviderErrorForCollisionWithItem:(NSFileProviderItem)existingItem API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
+ (instancetype)fileProviderErrorForNonExistentItemWithIdentifier:(NSFileProviderItemIdentifier)itemIdentifier API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
+ (instancetype)fileProviderErrorForOutOfDateItem:(NSFileProviderItem)updatedVersion NS_SWIFT_NAME(fileProviderErrorForOutOfDateItem(_:)) API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== FileProvider.framework/Headers/NSFileProviderManager.h
//
// NSFileProviderManager.h
// FileProvider
//
// Copyright (c) 2016-2017 Apple Inc. All rights reserved.
//
#import <FileProvider/NSFileProviderDefines.h>
#import <FileProvider/NSFileProviderItem.h>
#import <FileProvider/NSFileProviderDomain.h>
NS_ASSUME_NONNULL_BEGIN
@class NSURLSessionTask;
@class NSFileProviderDomain;
/**
The file provider manager allows you to communicate with the file provider
framework for purposes that may be relevant from both the extension and
the containing application (or sibling extensions).
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_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos)
@interface NSFileProviderManager : NSObject
- (instancetype)init NS_UNAVAILABLE;
/**
Return the manager responsible for the default domain.
*/
@property (class, readonly, strong) NSFileProviderManager *defaultManager API_UNAVAILABLE(macos);
/**
Return the manager for the specified domain.
*/
+ (nullable instancetype)managerForDomain:(NSFileProviderDomain *)domain;
/**
Call this method either in the app or in the extension to trigger an
enumeration, typically in response to a push.
Set the containerItemIdentifier to the identifier of the enumerated container
that was specified in
-[NSFileProviderExtension enumeratorForContainerItemIdentifier:error:]
This will trigger another call to
-[NSFileProviderEnumerator enumerateChangesForObserver:fromSyncAnchor:]
and the UI will be refreshed, giving the user live updates on the presented
enumeration.
If you have a change in the working set, call this method with
containerItemIdentifier set to NSFileProviderWorkingSetContainerItemIdentifier,
even if there is no live enumeration for this item. The working set is cached
on the device and it's important to keep the cache in sync.
In addition to using this method, your application/extension can register for
pushes using the PKPushTypeFileProvider push type. Pushes of the form
{
container-identifier = "<identifier>"
domain = "<domain identifier>"
}
with a topic of "<your application identifier>.pushkit.fileprovider" will be
translated into a call to signalEnumeratorForContainerItemIdentifier:completionHandler:.
*/
- (void)signalEnumeratorForContainerItemIdentifier:(NSFileProviderItemIdentifier)containerItemIdentifier completionHandler:(void (^)(NSError * __nullable error))completion NS_SWIFT_NAME(signalEnumerator(for:completionHandler:));
/**
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.
*/
- (void)registerURLSessionTask:(NSURLSessionTask *)task forItemWithIdentifier:(NSFileProviderItemIdentifier)identifier completionHandler:(void (^)(NSError * __nullable error))completion;
/**
Return the user visible URL for an item identifier.
Calling this method marks the calling process in such a way that accessing
files will not trigger materialization; instead, accesses to unmd
files will fail with EDEADLK.
*/
- (void)getUserVisibleURLForItemIdentifier:(NSFileProviderItemIdentifier)itemIdentifier completionHandler:(void (^)(NSURL * __nullable userVisibleFile, NSError * __nullable error))completionHandler API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos) NS_SWIFT_NAME(getUserVisibleURL(for: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 will return the Cocoa error NSFileNoSuchFileError.
*/
+ (void)getIdentifierForUserVisibleFileAtURL:(NSURL *)url completionHandler:(void (^)(NSFileProviderItemIdentifier __nullable itemIdentifier, NSFileProviderDomainIdentifier __nullable domainIdentifier, NSError * __nullable error))completionHandler API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
/**
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.
*/
@property(nonatomic, readonly) NSString *providerIdentifier;
/**
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.
*/
@property(nonatomic, readonly) NSURL *documentStorageURL;
/**
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.
*/
+ (BOOL)writePlaceholderAtURL:(NSURL *)placeholderURL
withMetadata:(NSFileProviderItem)metadata
error:(NSError **)error;
/**
Returns the designated placeholder URL for a given file URL. Used in
conjunction with writePlaceholderAtURL.
*/
+ (NSURL *)placeholderURLForURL:(NSURL *)url;
/**
Register a domain in which items can be stored.
*/
+ (void)addDomain:(NSFileProviderDomain *)domain completionHandler:(void(^)(NSError *_Nullable error))completionHandler;
/**
Remove a domain.
*/
+ (void)removeDomain:(NSFileProviderDomain *)domain completionHandler:(void(^)(NSError *_Nullable error))completionHandler;
/**
Get all registered domains.
*/
+ (void)getDomainsWithCompletionHandler:(void (^)(NSArray<NSFileProviderDomain *> *domains, NSError * _Nullable error))completionHandler;
/**
Remove all registered domains.
*/
+ (void)removeAllDomainsWithCompletionHandler:(void(^)(NSError *_Nullable error))completionHandler;
@end
@interface NSFileProviderManager (Import)
/** 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 NSFileProviderCreateItemOptionsItemMayAlreadyExist 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.
*/
+ (void)importDomain:(NSFileProviderDomain *)domain fromDirectoryAtURL:(NSURL *)url completionHandler:(void(^)(NSError * _Nullable error))completionHandler
API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
/** 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 NSFileProviderCreateItemOptionsItemMayAlreadyExist
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:].
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.
*/
- (void)reimportItemsBelowItemWithIdentifier:(NSFileProviderItemIdentifier)itemIdentifier
completionHandler:(void (^)(NSError * _Nullable error))completionHandler
NS_SWIFT_NAME(reimportItems(below:completionHandler:))
API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@end
/**
Policy regarding download and caching of an item by the system.
*/
typedef NS_ENUM(NSUInteger, NSFileProviderDownloadPolicy) {
/**
By default, files are downloaded on demand (e.g. when explicitely open by
the user) and may be evicted when needed (e.g. on low disk pressure.)
*/
NSFileProviderDownloadPolicyDefault = 0,
/**
Download this item when appropriate, minding shared resources like
available disk space.
Set this policy on files that are likely to be needed by the user in the
near future.
*/
NSFileProviderDownloadPolicySpeculative = 1,
/**
Download this item and keep it downloaded forever.
This policy applies recursively to all the items in a directory.
Set this policy only on files that the user must keep locally available for
offline use; abusing this policy causes shared resources like availabe disk
space to run out.
*/
NSFileProviderDownloadPolicyKeepDownloaded = 2,
} API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@interface NSFileProviderManager (DownloadAndEviction)
/**
Trigger a download or change the download policy.
See the documentation on the download policies for details.
The completion handler is called to acknowledge the change of policy: the
actual downloads are scheduled asynchronously when appropriate.
*/
- (void)downloadItemWithIdentifier:(NSFileProviderItemIdentifier)itemIdentifier
downloadPolicy:(NSFileProviderDownloadPolicy)downloadPolicy
completionHandler:(void (^)(NSError * _Nullable))completionHandler
API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
/**
Request that the system removes an item from its cache.
This removes the contents of a file, or the metadata and contents of all the
files in a directory. It resets the download policies of all the evicted
items back to the default policy.
The completion handler is called when the item has been evicted from disk.
*/
- (void)evictItemWithIdentifier:(NSFileProviderItemIdentifier)itemIdentifier
completionHandler:(void (^)(NSError * _Nullable))completionHandler
API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@end
NS_ASSUME_NONNULL_END
// ========== FileProvider.framework/Headers/NSFileProviderDefines.h
//
// NSFileProviderDefines.h
// FileProvider
//
// Copyright © 2017 Apple Inc. All rights reserved.
//
// This file intentionally left blank.
// ========== FileProvider.framework/Headers/FileProvider.h
//
// FileProvider.h
// FileProvider
//
// Copyright (c) 2014-2017 Apple Inc. All rights reserved.
//
/**
@framework FileProvider
@abstract A framework for providing files on demand.
@discussion The FileProvider framework allows content providers
and storage services to provide files to file browsers and applications.
*/
#import <FileProvider/NSFileProviderDomain.h>
#import <FileProvider/NSFileProviderExtension.h>
#import <FileProvider/NSFileProviderEnumerating.h>
#import <FileProvider/NSFileProviderError.h>
#import <FileProvider/NSFileProviderItem.h>
#import <FileProvider/NSFileProviderManager.h>
#import <FileProvider/NSFileProviderActions.h>
#import <FileProvider/NSFileProviderService.h>
#import <FileProvider/NSFileProviderThumbnailing.h>
#import <FileProvider/NSFileProviderMaterializedSet.h>
#import <FileProvider/NSFileProviderRequest.h>
#import <FileProvider/NSFileProviderItemDecoration.h>
// ========== FileProvider.framework/Headers/NSFileProviderItem.h
//
// NSFileProviderItem.h
// FileProvider
//
// Copyright (c) 2016-2017 Apple Inc. All rights reserved.
//
#import <FileProvider/NSFileProviderDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NSString *NSFileProviderItemIdentifier NS_EXTENSIBLE_STRING_ENUM;
/**
The root of the hierarchical enumeration, i.e the container enumerated when the
user starts browsing your file provider.
*/
FOUNDATION_EXPORT NSFileProviderItemIdentifier const NSFileProviderRootContainerItemIdentifier NS_SWIFT_NAME(NSFileProviderItemIdentifier.rootContainer) API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
/**
The item identifier of the working set, a synthetic container used by the
extension to communicate changes to the system even when the parent directories
of these items aren't actively being enumerated. Items in this set should have
their parentItemIdentifier set to the identifier of their parent directory.
The working set is the set of files and directories that should be made
available to the system regardless of the local browsing history. Files listed
in the working set are indexed in the local Spotlight index and appear in
offline search results. They contribute to the Recents view of the Files app,
sorted by lastUsedDate, and it is therefore important to provide a consistent
experience across devices by including in the working set all the documents
recently used, trashed, favorited, shared or tagged.
The Spotlight index and the Recents view will show outdated information unless
the file provider extension keeps the working set up to date with local and
remote changes. When an item in the working set is remotely modified, the
extension calls -signalEnumeratorForContainerItemIdentifier: on the identifier
of the working set; the system will then enumerate changes and update its caches.
Starting in iOS 12 and macOS 10.15, the system maintains a cache on the local
file system of files and directories previously enumerated. The working set
is the container used to update that set of files. The extension may know
whether an item is in that set by checking whether its parentItemIdentifier
is listed in the materialized containers, see the documentation on
-materializedItemsDidChangeWithCompletionHandler:.
*/
FOUNDATION_EXPORT NSFileProviderItemIdentifier const NSFileProviderWorkingSetContainerItemIdentifier NS_SWIFT_NAME(NSFileProviderItemIdentifier.workingSet) API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
/**
A version blob, used for either structure or content.
Version blobs are limited to 128 bytes in size.
*/
typedef NSData *NSFileProviderVersionData NS_TYPED_EXTENSIBLE_ENUM;
API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos)
@interface NSFileProviderItemVersion : NSObject
/**
Items versions have two distinct components, one for the file contents and one
for metadata. Bumping the right component on a change allows for important
optimizations.
*/
- (instancetype)initWithContentVersion:(NSFileProviderVersionData)contentVersion
metadataVersion:(NSFileProviderVersionData)metadataVersion;
/**
Version data for the content of the file. The system will typically ask for a
new download of the file if this field changes and the file was already
downloaded.
This property is used to invalidate the thumbnail cache maintained by the system.
Note that the resource fork of the file is considered content, so this version
data should change when either the data fork or the resource fork changes.
*/
@property (nonatomic, readonly) NSFileProviderVersionData contentVersion;
/**
Version data for the metadata of the item, i.e everything but the data fork and
the resource fork. The system will typically update a dataless representation
of the file if this changes; but it will not ask for a new download.
*/
@property (nonatomic, readonly) NSFileProviderVersionData metadataVersion;
@end
/**
A special value for favorite ranks, to use when no rank was set when the item
was favorited.
*/
FOUNDATION_EXPORT unsigned long long const NSFileProviderFavoriteRankUnranked API_AVAILABLE(ios(11.0), macos(10.14)) API_UNAVAILABLE(watchos, tvos);
typedef NS_OPTIONS(NSUInteger, NSFileProviderItemCapabilities) {
/**
Indicates that the file can be opened for reading. If set on a folder
this is equivalent to @c .allowsContentEnumerating.
*/
NSFileProviderItemCapabilitiesAllowsReading = 1 << 0,
/**
Indicates that the file can be opened for writing. If set on a folder,
this is equivalent to @c .allowsAddingSubItems.
*/
NSFileProviderItemCapabilitiesAllowsWriting = 1 << 1,
/** Indicates that the item can be moved to another folder */
NSFileProviderItemCapabilitiesAllowsReparenting = 1 << 2,
/** Indicates that the item can be renamed */
NSFileProviderItemCapabilitiesAllowsRenaming = 1 << 3,
/** Indicates that the item can be moved to the trash */
NSFileProviderItemCapabilitiesAllowsTrashing = 1 << 4,
/** Indicates that the item can be deleted */
NSFileProviderItemCapabilitiesAllowsDeleting = 1 << 5,
/**
Indicates that items can be imported to the folder. If set on a file,
this is equivalent to @c .allowsWriting.
*/
NSFileProviderItemCapabilitiesAllowsAddingSubItems = NSFileProviderItemCapabilitiesAllowsWriting,
/**
Indicates that the folder can be enumerated. If set on a file, this is
equivalent to @c .allowsReading.
*/
NSFileProviderItemCapabilitiesAllowsContentEnumerating = NSFileProviderItemCapabilitiesAllowsReading,
NSFileProviderItemCapabilitiesAllowsAll =
NSFileProviderItemCapabilitiesAllowsReading
| NSFileProviderItemCapabilitiesAllowsWriting
| NSFileProviderItemCapabilitiesAllowsReparenting
| NSFileProviderItemCapabilitiesAllowsRenaming
| NSFileProviderItemCapabilitiesAllowsTrashing
| NSFileProviderItemCapabilitiesAllowsDeleting
};
@protocol NSFileProviderItemFlags <NSObject>
@property (nonatomic, readonly, getter=isUserExecutable) BOOL userExecutable;
@property (nonatomic, readonly, getter=isUserReadable) BOOL userReadable;
@property (nonatomic, readonly, getter=isUserWritable) BOOL userWritable;
@property (nonatomic, readonly, getter=isHidden) BOOL hidden;
@property (nonatomic, readonly, getter=isPathExtensionHidden) BOOL pathExtensionHidden;
@end
@protocol NSFileProviderItem <NSObject>
@property (nonatomic, readonly, copy) NSFileProviderItemIdentifier itemIdentifier;
/**
The parent identifier specifies the parent of the item in the hierarchy.
Set to NSFileProviderRootContainerItemIdentifier for an item at the root of the
user's storage. Set to the itemIdentifier of the item's parent otherwise.
When enumerating the root container or a generic container, the
parentItemIdentifier of the enumerated items is expected to match the
enumerated item's identifier. When enumerating the working set, the
parentItemIdentifier is expected to match the actual parent of the item in the
hierarchy (ie. it is not NSFileProviderWorkingSetContainerItemIdentifier).
The parents of trashed items and of the root item are ignored.
*/
@property (nonatomic, readonly, copy) NSFileProviderItemIdentifier parentItemIdentifier;
/**
The file or directory name, complete with its file extension.
*/
@property (nonatomic, readonly, copy) NSString *filename;
/**
Uniform type identifier (UTI) for the item
*/
@property (nonatomic, readonly, copy) NSString *typeIdentifier;
@optional
/**
The capabilities of the item. This controls the list of actions that the UI
will allow for the item.
*/
@property (nonatomic, readonly) NSFileProviderItemCapabilities capabilities;
/**
The flags of the item. Flags define on-disk properties of the item but are
also taken into account by the UI to determine item actions.
*/
@property (nonatomic, readonly, strong, nullable) id <NSFileProviderItemFlags> flags API_AVAILABLE(ios(13.0), macos(10.15)) API_UNAVAILABLE(watchos, tvos);
@property (nonatomic, readonly, copy, nullable) NSNumber *documentSize;
@property (nonatomic, readonly, copy, nullable) NSNumber *childItemCount;
@property (nonatomic, readonly, copy, nullable) NSDate *creationDate;
@property (nonatomic, readonly, copy, nullable) NSDate *contentModificationDate;