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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomainidentifier?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type NSFileProviderDomainIdentifier = NSString;
extern_class!(
/// File provider domain version.
///
/// This object can be used by the `NSFileProviderReplicatedExtension` to describe the
/// current version of the domain. This object is immutable and can safely be used as
/// a key in a dictionary.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomainversion?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSFileProviderDomainVersion;
);
extern_conformance!(
unsafe impl NSCoding for NSFileProviderDomainVersion {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSFileProviderDomainVersion {}
);
extern_conformance!(
unsafe impl NSSecureCoding for NSFileProviderDomainVersion {}
);
impl NSFileProviderDomainVersion {
extern_methods!(
/// Build a version that is strictly greater than the receiver.
#[unsafe(method(next))]
#[unsafe(method_family = none)]
pub unsafe fn next(&self) -> Retained<NSFileProviderDomainVersion>;
/// Compare two domain versions.
///
/// This returns the NSComparisonResult of the comparison of the receiver and the
/// other version:
/// - NSOrderedAscending if the receiver predates the otherVersion
/// - NSOrderedDescending if the otherVersion predates the receiver
/// - NSOrderedSame if both versions are equal
///
/// In Swift, NSFileProviderDomainVersion is comparable.
#[unsafe(method(compare:))]
#[unsafe(method_family = none)]
pub unsafe fn compare(
&self,
other_version: &NSFileProviderDomainVersion,
) -> NSComparisonResult;
);
}
/// Methods declared on superclass `NSObject`.
impl NSFileProviderDomainVersion {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
/// Testing modes.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomaintestingmodes?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFileProviderDomainTestingModes(pub NSUInteger);
bitflags::bitflags! {
impl NSFileProviderDomainTestingModes: NSUInteger {
/// Enable the domain without any user action required.
#[doc(alias = "NSFileProviderDomainTestingModeAlwaysEnabled")]
const AlwaysEnabled = 1<<0;
/// Enable interactive mode.
///
/// Disable the automatic scheduling from the system and allow external tools to
/// control the execution of operations.
///
/// When manual scheduling is enabled, an external tool should use
/// -[NSFileProviderManager listAvailableTestingOperationsWithError:] and
/// -[NSFileProviderManager runTestingOperations:error:] to control the system.
///
/// If that mode is enabled, some crash recovery guarantees are lost. For instance,
/// the system may lose any event that hasn't been ingested. The system does not
/// support removing this mode from a domain on which it has been enabled.
#[doc(alias = "NSFileProviderDomainTestingModeInteractive")]
const Interactive = 1<<1;
}
}
unsafe impl Encode for NSFileProviderDomainTestingModes {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSFileProviderDomainTestingModes {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Specifying a list of known folders.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderknownfolders?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFileProviderKnownFolders(pub NSUInteger);
bitflags::bitflags! {
impl NSFileProviderKnownFolders: NSUInteger {
#[doc(alias = "NSFileProviderDesktop")]
const Desktop = 1<<0;
#[doc(alias = "NSFileProviderDocuments")]
const Documents = 1<<1;
}
}
unsafe impl Encode for NSFileProviderKnownFolders {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSFileProviderKnownFolders {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// 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
/// `-[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
/// `NSFileProviderDomain`registered. In that case, the
/// `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
/// `pathRelativeToDocumentStorage`property.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomain?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSFileProviderDomain;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSFileProviderDomain {}
);
impl NSFileProviderDomain {
extern_methods!(
/// Initialize a new non-replicated NSFileProviderDomain
///
/// The extension will be implementing NSFileProviderExtension.
///
/// The file provider extension implementation can pick any
/// `identifier`as it sees
/// fit to identify the group of items. The identifier must not contain any characters from this set: [/:]
///
///
/// Parameter `displayName`: a user visible string representing the group of items the
/// file provider extension is using.
///
///
/// Parameter `pathRelativeToDocumentStorage`: a path relative to
/// `NSFileProviderExtension.documentStorageURL.`
#[unsafe(method(initWithIdentifier:displayName:pathRelativeToDocumentStorage:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithIdentifier_displayName_pathRelativeToDocumentStorage(
this: Allocated<Self>,
identifier: &NSFileProviderDomainIdentifier,
display_name: &NSString,
path_relative_to_document_storage: &NSString,
) -> Retained<Self>;
/// Initialize a new replicated NSFileProviderDomain
///
/// The extension will be implementing NSFileProviderReplicatedExtension.
///
/// The file provider extension implementation can pick any
/// `identifier`as it sees
/// fit to identify the group of items. The identifier must not contain any characters from this set: [/:]
///
/// In order to migrate a non-replicated domain to a replicated one, implementers have to make sure that they do not
/// use the default domain, and then call +[NSFileProviderManager addDomain:completionHandler:] using
/// the NSFileProviderDomain object returned by that init method.
///
/// A domain with a specific identifier can be added multiple times; subsequent adds will update the properties
/// of the existing domain.
/// If a replicated domain is added "on top" of a non-replicated domain, the domain will be migrated to be replicated;
/// existing bookmarks will remain valid, but the (externally visible) location of items will change to reflect the replicated location.
///
/// It is not possible to migrate the default domain in this manner (since the default domain can not be added).
/// It is recommended to migrate usage of the default domain to a domain with an explicit identifier instead.
///
///
/// Parameter `displayName`: a user visible string representing the group of items the
/// file provider extension is using.
#[unsafe(method(initWithIdentifier:displayName:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithIdentifier_displayName(
this: Allocated<Self>,
identifier: &NSFileProviderDomainIdentifier,
display_name: &NSString,
) -> Retained<Self>;
/// Initialize a new replicated NSFileProviderDomain on a specific volume.
///
/// If a volumeURL is specified, and that volume is eligible, the domain will be located on this volume. The URL is used to designate a volume
/// but doesn't influence where on this volume is the domain going to be stored.
///
/// In order to avoid domainID collisions between volumes, the NSFileProviderDomainIdentifier of external domains are generated randomly by FileProvider.
/// The provider should therefore use the userInfo to associate all necessary information to map the created object to the corresponding account.
/// The userInfo will be persisted on the volume where the domain was created. If that is an external volume, the userInfo can be used on other devices
/// to assist in setting up the domain on those devices. See the`NSFileProviderExternalVolumeHandling` protocol for more details.
///
/// # Safety
///
/// `user_info` generic should be of the correct type.
#[unsafe(method(initWithDisplayName:userInfo:volumeURL:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithDisplayName_userInfo_volumeURL(
this: Allocated<Self>,
display_name: &NSString,
user_info: &NSDictionary,
volume_url: Option<&NSURL>,
) -> Retained<Self>;
/// The identifier - as provided by the file provider extension.
#[unsafe(method(identifier))]
#[unsafe(method_family = none)]
pub unsafe fn identifier(&self) -> Retained<NSFileProviderDomainIdentifier>;
/// The display name shown by the system to represent this domain.
#[unsafe(method(displayName))]
#[unsafe(method_family = none)]
pub unsafe fn displayName(&self) -> Retained<NSString>;
/// The path relative to the document storage of the file provider extension.
/// Files belonging to this domains should be stored under this path.
#[unsafe(method(pathRelativeToDocumentStorage))]
#[unsafe(method_family = none)]
pub unsafe fn pathRelativeToDocumentStorage(&self) -> Retained<NSString>;
/// 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 via the disconnectWithReason method
/// on NSFileProviderManager.
#[unsafe(method(isDisconnected))]
#[unsafe(method_family = none)]
pub unsafe fn isDisconnected(&self) -> bool;
/// If user has disabled this domain from Files.app on iOS or System Settings on macOS, this will be set
/// to NO.
#[unsafe(method(userEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn userEnabled(&self) -> bool;
/// If this domain is not user visible.
///
/// Typically, this can be used for dry-run migration. The files are still on disk though.
#[unsafe(method(isHidden))]
#[unsafe(method_family = none)]
pub unsafe fn isHidden(&self) -> bool;
/// Setter for [`isHidden`][Self::isHidden].
#[unsafe(method(setHidden:))]
#[unsafe(method_family = none)]
pub unsafe fn setHidden(&self, hidden: bool);
/// If the domain is a replicated domain.
///
/// If set to YES, it means the domain is replicated. By default, on macOS, the value will always be YES.
///
/// On iOS, it will depend on the way the NSFileProviderDomain object is contructed. Calling
/// -[NSFileProviderDomain initWithIdentifier:displayName:] will initialize a replicated domain.
/// -[NSFileProviderDomain initWithIdentifier:displayName:pathRelativeToDocumentStorage:] will
/// initialize a non-replicated domain.
///
/// To know whether a domain is replicated or not, users are advised to rely on the output of
/// +[NSFileProviderManager getDomainsForProviderIdentifier:completionHandler:]
#[unsafe(method(isReplicated))]
#[unsafe(method_family = none)]
pub unsafe fn isReplicated(&self) -> bool;
/// Testing modes.
///
/// Testing modes are exposed as a means for the provider to have more control over the system in
/// a testing environment. Enabling a testing mode alters the behavior of the system and enables
/// some APIs for that mode.
///
/// A process must have the com.apple.developer.fileprovider.testing-mode entitlement in order to
/// configure a domain with non-empty testing modes.
#[unsafe(method(testingModes))]
#[unsafe(method_family = none)]
pub unsafe fn testingModes(&self) -> NSFileProviderDomainTestingModes;
/// Setter for [`testingModes`][Self::testingModes].
#[unsafe(method(setTestingModes:))]
#[unsafe(method_family = none)]
pub unsafe fn setTestingModes(&self, testing_modes: NSFileProviderDomainTestingModes);
/// Identity of the backing store of the domain on the system.
///
/// This property only applies for extensions that implement NSFileProviderReplicatedExtension.
///
/// This provides an identifier that uniquely identifies the backing store used by the system for
/// the domain. When this identifier has changed, the system has dropped its backing store and is
/// building a new one.
///
/// The system may decide to rebuild its backing store if it got corrupted. The backing store can also
/// be rebuilt as a response to the provider calling `-[NSFileProviderManager reimportItemsBelowItemWithIdentifier:completionHandler:]`.
/// It is guaranteed that calling reimport on the root item will cause the backing store to be rebuilt,
/// but the system can also decide to do so when reimport is called on other items.
///
/// When rebuilding the backing store, the system will invalidate any extension instance associated
/// to that domain. As a consequence, the identity of the backing store associated with that domain
/// is guaranteed to be stable for the lifetime of the NSFileProviderReplicatedExtension instance.
#[unsafe(method(backingStoreIdentity))]
#[unsafe(method_family = none)]
pub unsafe fn backingStoreIdentity(&self) -> Option<Retained<NSData>>;
/// Whether the domain supports syncing the trash.
///
/// The system supports syncing a trash folder (NSFileProviderTrashContainerItemIdentifier) to the extension.
/// On iOS, this is surfaced to the user as "Recently Deleted" in the Files app. On macOS, this is surfaced
/// to the user as the Trash in Finder.
///
/// If the domain is configured with supportsSyncingTrash=YES, the system will reparent trashed
/// files (which were located in the extension's domain) to NSFileProviderTrashContainerItemIdentifier.
/// If the domain is configured with supportsSyncingTrash=NO, the system will decide how to handle
/// the trashing operation (not guaranteed by API contract).
///
/// This property is only applicable for NSFileProviderReplicatedExtension-based domains.
///
/// This property defaults to YES.
#[unsafe(method(supportsSyncingTrash))]
#[unsafe(method_family = none)]
pub unsafe fn supportsSyncingTrash(&self) -> bool;
/// Setter for [`supportsSyncingTrash`][Self::supportsSyncingTrash].
#[unsafe(method(setSupportsSyncingTrash:))]
#[unsafe(method_family = none)]
pub unsafe fn setSupportsSyncingTrash(&self, supports_syncing_trash: bool);
#[unsafe(method(volumeUUID))]
#[unsafe(method_family = none)]
pub unsafe fn volumeUUID(&self) -> Option<Retained<NSUUID>>;
/// A dictionary set by the client app. Keys must be strings, values must be [String, Number, Date, Data]
#[unsafe(method(userInfo))]
#[unsafe(method_family = none)]
pub unsafe fn userInfo(&self) -> Option<Retained<NSDictionary>>;
/// Setter for [`userInfo`][Self::userInfo].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `user_info` generic should be of the correct type.
#[unsafe(method(setUserInfo:))]
#[unsafe(method_family = none)]
pub unsafe fn setUserInfo(&self, user_info: Option<&NSDictionary>);
/// List of known folders that are currently replicated by this domain.
#[unsafe(method(replicatedKnownFolders))]
#[unsafe(method_family = none)]
pub unsafe fn replicatedKnownFolders(&self) -> NSFileProviderKnownFolders;
/// List known folders that can be replicated by this domain.
#[unsafe(method(supportedKnownFolders))]
#[unsafe(method_family = none)]
pub unsafe fn supportedKnownFolders(&self) -> NSFileProviderKnownFolders;
/// Setter for [`supportedKnownFolders`][Self::supportedKnownFolders].
#[unsafe(method(setSupportedKnownFolders:))]
#[unsafe(method_family = none)]
pub unsafe fn setSupportedKnownFolders(
&self,
supported_known_folders: NSFileProviderKnownFolders,
);
/// Whether the system should use this domain's
/// `NSFileProviderSearching` implementation to support
/// search experiences.
///
/// Defaults to NO.
#[unsafe(method(supportsStringSearchRequest))]
#[unsafe(method_family = none)]
pub unsafe fn supportsStringSearchRequest(&self) -> bool;
/// Setter for [`supportsStringSearchRequest`][Self::supportsStringSearchRequest].
#[unsafe(method(setSupportsStringSearchRequest:))]
#[unsafe(method_family = none)]
pub unsafe fn setSupportsStringSearchRequest(&self, supports_string_search_request: bool);
);
}
/// Methods declared on superclass `NSObject`.
impl NSFileProviderDomain {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
/// NSFileProviderDomain.
#[cfg(feature = "Extension")]
impl NSFileProviderExtension {
extern_methods!(
#[unsafe(method(domain))]
#[unsafe(method_family = none)]
pub unsafe fn domain(&self) -> Option<Retained<NSFileProviderDomain>>;
);
}
extern "C" {
/// Posted when any domain changed.
///
/// Interested client should then call `+[NSFileProviderManager getDomainsWithCompletionHandler:]` and see
/// what changed.
///
/// Note, this notification starts to be posted only after `+[NSFileProviderManager getDomainsWithCompletionHandler:]` is
/// called.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomaindidchange?language=objc)
pub static NSFileProviderDomainDidChange: &'static NSNotificationName;
}
/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideruserinfokey?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type NSFileProviderUserInfoKey = NSString;
extern "C" {
/// System interpreted user info key
/// When setting a value to that user info on a domain, the system will ingest this value.
/// If user has given their consent for telemetry, this value will be used to decorate telemetry messages sent
/// by the FileProvider subsystem.
/// The telemetry messages can be then later on retrieved by developers along with the other metrics through the CloudKit console as detailed here:
/// https://developer.apple.com/documentation/fileprovider/exporting-file-provider-metrics-data?language=objc
/// This will help developers triaging data they receive from testing population compared to regular users
/// The value must either be a NSNumber between [0 - 31]. If it's not in that range, or if it is not a NSNumber, any
/// call to addDomain with that invalid UserInfo dictionary will fail with a EINVAL POSIX NSError.
/// To update this value, the provider must call addDomain with an updated userInfo dictionary
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovideruserinfoexperimentidkey?language=objc)
pub static NSFileProviderUserInfoExperimentIDKey: &'static NSFileProviderUserInfoKey;
}