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