objc2_file_provider/generated/
NSFileProviderKnownFolders.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// Specify the location of a known folder in the replicated tree.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderknownfolderlocation?language=objc)
14    #[unsafe(super(NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    pub struct NSFileProviderKnownFolderLocation;
17);
18
19extern_conformance!(
20    unsafe impl NSObjectProtocol for NSFileProviderKnownFolderLocation {}
21);
22
23impl NSFileProviderKnownFolderLocation {
24    extern_methods!(
25        #[cfg(feature = "NSFileProviderItem")]
26        /// Initialize a location with the filename of the folder in a specified parent.
27        ///
28        /// When replicating a known folder the system will reuse a folder located at the specified
29        /// filename within the parent if one exists, or create a new item at this location if none
30        /// exists yet.
31        #[unsafe(method(initWithParentItemIdentifier:filename:))]
32        #[unsafe(method_family = init)]
33        pub unsafe fn initWithParentItemIdentifier_filename(
34            this: Allocated<Self>,
35            parent_item_identifier: &NSFileProviderItemIdentifier,
36            filename: &NSString,
37        ) -> Retained<Self>;
38
39        #[cfg(feature = "NSFileProviderItem")]
40        /// Initialize a location with the item identifier of a folder that already exists on the server.
41        ///
42        /// If the known folder already exists on the server, the provider can specify the exact identifier
43        /// of the item that needs to be used to back the known folder.
44        #[unsafe(method(initWithExistingItemIdentifier:))]
45        #[unsafe(method_family = init)]
46        pub unsafe fn initWithExistingItemIdentifier(
47            this: Allocated<Self>,
48            existing_item_identifier: &NSFileProviderItemIdentifier,
49        ) -> Retained<Self>;
50    );
51}
52
53/// Methods declared on superclass `NSObject`.
54impl NSFileProviderKnownFolderLocation {
55    extern_methods!(
56        #[unsafe(method(init))]
57        #[unsafe(method_family = init)]
58        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
59
60        #[unsafe(method(new))]
61        #[unsafe(method_family = new)]
62        pub unsafe fn new() -> Retained<Self>;
63    );
64}
65
66extern_class!(
67    /// Specify the locations at which known folders should be synced in the replicated tree.
68    ///
69    /// Desktop and Documents candidate items need to have the same parent folder.
70    ///
71    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderknownfolderlocations?language=objc)
72    #[unsafe(super(NSObject))]
73    #[derive(Debug, PartialEq, Eq, Hash)]
74    pub struct NSFileProviderKnownFolderLocations;
75);
76
77extern_conformance!(
78    unsafe impl NSObjectProtocol for NSFileProviderKnownFolderLocations {}
79);
80
81impl NSFileProviderKnownFolderLocations {
82    extern_methods!(
83        /// Specify whether the system should create a binary compatibility symlink folders.
84        ///
85        /// If YES, the system creates a symlink from the logical location of the folder in the domain
86        /// sync root to the known folder location. This symlink allows any app that would have hardcoded
87        /// the previous location of the folder to still work after enabling the feature.
88        ///
89        /// Default value is YES.
90        #[unsafe(method(shouldCreateBinaryCompatibilitySymlink))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn shouldCreateBinaryCompatibilitySymlink(&self) -> bool;
93
94        /// Setter for [`shouldCreateBinaryCompatibilitySymlink`][Self::shouldCreateBinaryCompatibilitySymlink].
95        #[unsafe(method(setShouldCreateBinaryCompatibilitySymlink:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn setShouldCreateBinaryCompatibilitySymlink(
98            &self,
99            should_create_binary_compatibility_symlink: bool,
100        );
101
102        /// Candidate item for ~/Desktop
103        ///
104        /// For user experience reasons, it is strongly recommended to name the target folder "Desktop".
105        #[unsafe(method(desktopLocation))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn desktopLocation(&self)
108            -> Option<Retained<NSFileProviderKnownFolderLocation>>;
109
110        /// Setter for [`desktopLocation`][Self::desktopLocation].
111        #[unsafe(method(setDesktopLocation:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setDesktopLocation(
114            &self,
115            desktop_location: Option<&NSFileProviderKnownFolderLocation>,
116        );
117
118        /// Candidate item for ~/Documents
119        ///
120        /// For user experience reasons, it is strongly recommended to name the target folder "Documents".
121        #[unsafe(method(documentsLocation))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn documentsLocation(
124            &self,
125        ) -> Option<Retained<NSFileProviderKnownFolderLocation>>;
126
127        /// Setter for [`documentsLocation`][Self::documentsLocation].
128        #[unsafe(method(setDocumentsLocation:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setDocumentsLocation(
131            &self,
132            documents_location: Option<&NSFileProviderKnownFolderLocation>,
133        );
134
135        #[unsafe(method(init))]
136        #[unsafe(method_family = init)]
137        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
138    );
139}
140
141/// Methods declared on superclass `NSObject`.
142impl NSFileProviderKnownFolderLocations {
143    extern_methods!(
144        #[unsafe(method(new))]
145        #[unsafe(method_family = new)]
146        pub unsafe fn new() -> Retained<Self>;
147    );
148}
149
150/// KnownFolders.
151#[cfg(feature = "Extension")]
152impl NSFileProviderManager {
153    extern_methods!(
154        #[cfg(feature = "block2")]
155        /// Request the specified known folders to be synced by this domain.
156        ///
157        /// This method allows the provider to claim a set of known folders described by the non-null
158        /// properties of the knownFolders parameter. The system will only enable sync for those folders
159        /// in that domain if the set of locations is valid and if the user agrees.
160        ///
161        /// This API should only be called as a result of the user requesting, via UI in the provider's application,
162        /// that they wish to start syncing the Desktop and Document folders.
163        /// If the provider chooses to implement a UI which invokes this API, the provider should also implement a UI
164        /// for the user to request to stop syncing the Desktop and Document folders,
165        /// using the `-[NSFileProviderManager releaseKnownFolders:localizedReason:completionHandler:]` method.
166        ///
167        /// The reason specified in this call is a custom string that the provider can pass and will be
168        /// presented to the user as a way to explain why it is claiming those known folders. One suggested
169        /// phrasing would be:
170        ///
171        /// > Keep your Desktop
172        /// &
173        /// Documents in sync with
174        /// <Provider
175        /// name> and access them from other devices and from
176        /// <Provider
177        /// website>.
178        ///
179        /// If the user denies the transition of the known folders, the call will fail with `NSUserCancelledError`.
180        ///
181        /// The call will fail if:
182        /// - one or more locations are not folders
183        /// - multiple locations are backed by the same folder
184        /// - a known folder doesn't live on the same volume as the root of the domain
185        /// - the known folders don't have the same parent folder
186        /// - ...
187        ///
188        /// Currently, only claiming both ~/Desktop and ~/Documents together is allowed.
189        #[unsafe(method(claimKnownFolders:localizedReason:completionHandler:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn claimKnownFolders_localizedReason_completionHandler(
192            &self,
193            known_folders: &NSFileProviderKnownFolderLocations,
194            localized_reason: &NSString,
195            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
196        );
197
198        #[cfg(all(feature = "NSFileProviderDomain", feature = "block2"))]
199        /// Request that the system stops replicating the specified known folders in the domain.
200        ///
201        /// This call can be used by the provider to immediately disable replication of the specified
202        /// known folders.
203        #[unsafe(method(releaseKnownFolders:localizedReason:completionHandler:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn releaseKnownFolders_localizedReason_completionHandler(
206            &self,
207            known_folders: NSFileProviderKnownFolders,
208            localized_reason: &NSString,
209            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
210        );
211    );
212}
213
214extern_protocol!(
215    /// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderknownfoldersupporting?language=objc)
216    pub unsafe trait NSFileProviderKnownFolderSupporting: NSObjectProtocol {
217        #[cfg(all(feature = "NSFileProviderDomain", feature = "block2"))]
218        /// Request suitable locations for known folders.
219        ///
220        /// This function is called when the user decides to switch some known folders to the current domain, outside of the `claimKnownFolders` call.
221        /// The system provides a list of folders that the user decides to move to this domain, and expect in return non-nil locations for those known
222        /// folders.
223        #[unsafe(method(getKnownFolderLocations:completionHandler:))]
224        #[unsafe(method_family = none)]
225        unsafe fn getKnownFolderLocations_completionHandler(
226            &self,
227            known_folders: NSFileProviderKnownFolders,
228            completion_handler: &block2::DynBlock<
229                dyn Fn(*mut NSFileProviderKnownFolderLocations, *mut NSError),
230            >,
231        );
232    }
233);