objc2_image_capture_core/generated/
ICDeviceBrowser.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
10/// [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icauthorizationstatus?language=objc)
11// NS_TYPED_ENUM
12pub type ICAuthorizationStatus = NSString;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icauthorizationstatusnotdetermined?language=objc)
16    pub static ICAuthorizationStatusNotDetermined: &'static ICAuthorizationStatus;
17}
18
19extern "C" {
20    /// [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icauthorizationstatusrestricted?language=objc)
21    pub static ICAuthorizationStatusRestricted: &'static ICAuthorizationStatus;
22}
23
24extern "C" {
25    /// [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icauthorizationstatusdenied?language=objc)
26    pub static ICAuthorizationStatusDenied: &'static ICAuthorizationStatus;
27}
28
29extern "C" {
30    /// [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icauthorizationstatusauthorized?language=objc)
31    pub static ICAuthorizationStatusAuthorized: &'static ICAuthorizationStatus;
32}
33
34extern_protocol!(
35    /// A delegate of ICDeviceBrowser must conform to ICDeviceBrowserDelegate protocol.
36    ///
37    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icdevicebrowserdelegate?language=objc)
38    pub unsafe trait ICDeviceBrowserDelegate: NSObjectProtocol {
39        #[cfg(feature = "ICDevice")]
40        /// This message is sent to the delegate to inform that a device has been added.
41        ///
42        /// If several devices are found during the initial search, then this message is sent once for each device with the value of 'moreComing' set to YES in each message except the last one.
43        #[unsafe(method(deviceBrowser:didAddDevice:moreComing:))]
44        #[unsafe(method_family = none)]
45        unsafe fn deviceBrowser_didAddDevice_moreComing(
46            &self,
47            browser: &ICDeviceBrowser,
48            device: &ICDevice,
49            more_coming: bool,
50        );
51
52        #[cfg(feature = "ICDevice")]
53        /// This message is sent to the delegate to inform that a device has been removed.
54        ///
55        /// If several devices are removed at the same time, then this message is sent once for each device with the value of 'moreGoing' set to YES in each message except the last one.
56        #[unsafe(method(deviceBrowser:didRemoveDevice:moreGoing:))]
57        #[unsafe(method_family = none)]
58        unsafe fn deviceBrowser_didRemoveDevice_moreGoing(
59            &self,
60            browser: &ICDeviceBrowser,
61            device: &ICDevice,
62            more_going: bool,
63        );
64
65        #[cfg(feature = "ICDevice")]
66        /// This message is sent if the name of a device changes.
67        ///
68        /// This happens if the device module overrides the default name of the device reported by the device's transport layer, or if the name of the filesystem volume mounted by the device is changed by the user.
69        #[optional]
70        #[unsafe(method(deviceBrowser:deviceDidChangeName:))]
71        #[unsafe(method_family = none)]
72        unsafe fn deviceBrowser_deviceDidChangeName(
73            &self,
74            browser: &ICDeviceBrowser,
75            device: &ICDevice,
76        );
77
78        #[cfg(feature = "ICDevice")]
79        /// This message is sent when the sharing state of a device has changes.
80        ///
81        /// Any Image Capture client application can choose to share the device over the network using the sharing or webSharing facility in Image Capture.
82        #[deprecated = "deviceDidChangeSharingState will no longer be called"]
83        #[optional]
84        #[unsafe(method(deviceBrowser:deviceDidChangeSharingState:))]
85        #[unsafe(method_family = none)]
86        unsafe fn deviceBrowser_deviceDidChangeSharingState(
87            &self,
88            browser: &ICDeviceBrowser,
89            device: &ICDevice,
90        );
91
92        #[cfg(feature = "ICDevice")]
93        /// This message is sent when an event that occurred on the device may be of interest to the client application.
94        ///
95        /// In Mac OS X 10.6, this message is sent when a button is pressed on a device and the current application is the target for that button press. In the case of the button-press event, if a session is open on the device, this message will not be sent to the browser delegate, instead the message 'device:didReceiveButtonPress:' is sent to the device delegate.
96        #[optional]
97        #[unsafe(method(deviceBrowser:requestsSelectDevice:))]
98        #[unsafe(method_family = none)]
99        unsafe fn deviceBrowser_requestsSelectDevice(
100            &self,
101            browser: &ICDeviceBrowser,
102            device: &ICDevice,
103        );
104
105        /// This message is sent after the device browser completes sending 'deviceBrowser:didAddDevice:moreComing:' message for all local devices.
106        ///
107        /// Detecting locally connected devices (USB and FireWire devices) is faster than detecting devices connected using a network protocol. An Image Capture client application may use this message to update its user interface to let the user know that it has completed looking for locally connected devices and then start looking for network devices.
108        #[optional]
109        #[unsafe(method(deviceBrowserDidEnumerateLocalDevices:))]
110        #[unsafe(method_family = none)]
111        unsafe fn deviceBrowserDidEnumerateLocalDevices(&self, browser: &ICDeviceBrowser);
112
113        /// This message is sent to the delegate to inform that operations on devices in the browser will be suspended shortly.
114        ///
115        /// Attached devices may require time to prepare the device for suspended communication.  This delegate method is called
116        /// when the application is switched into the background.
117        #[optional]
118        #[unsafe(method(deviceBrowserWillSuspendOperations:))]
119        #[unsafe(method_family = none)]
120        unsafe fn deviceBrowserWillSuspendOperations(&self, browser: &ICDeviceBrowser);
121
122        /// This message is sent to the delegate to inform that operations on devices in the browser have been suspended.
123        ///
124        /// All communcation with the attached device will remain suspended until the application has entered the foreground.
125        /// In no way does this suspension modify the state of the connected device, nor does it issue a close session of any kind.  State should always be
126        /// managed by the application.
127        #[optional]
128        #[unsafe(method(deviceBrowserDidSuspendOperations:))]
129        #[unsafe(method_family = none)]
130        unsafe fn deviceBrowserDidSuspendOperations(&self, browser: &ICDeviceBrowser);
131
132        /// This message is sent to the delegate to inform that operations on devices in the browser have resumed before the suspension timeout.
133        ///
134        /// All communcation with the attached device will remain available as the application was switched back to the foreground before the
135        /// suspension timeout.
136        #[optional]
137        #[unsafe(method(deviceBrowserDidCancelSuspendOperations:))]
138        #[unsafe(method_family = none)]
139        unsafe fn deviceBrowserDidCancelSuspendOperations(&self, browser: &ICDeviceBrowser);
140
141        /// This message is sent to the delegate to inform that operations on devices in the browser have resumed.
142        ///
143        /// All communcation with the attached device has been resumed as the application has now entered the foreground.
144        #[optional]
145        #[unsafe(method(deviceBrowserDidResumeOperations:))]
146        #[unsafe(method_family = none)]
147        unsafe fn deviceBrowserDidResumeOperations(&self, browser: &ICDeviceBrowser);
148    }
149);
150
151extern_class!(
152    /// The ICDeviceBrowser object is used to find devices such as digital cameras and scanners that are supported by Image Capture. These device may be directly attached to the USB or FireWire bus on the host computer, or available over a TCP/IP network. This object communicates with an Image Capture agent process asynchronously to accomplish this.
153    ///
154    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icdevicebrowser?language=objc)
155    #[unsafe(super(NSObject))]
156    #[derive(Debug, PartialEq, Eq, Hash)]
157    pub struct ICDeviceBrowser;
158);
159
160extern_conformance!(
161    unsafe impl NSObjectProtocol for ICDeviceBrowser {}
162);
163
164impl ICDeviceBrowser {
165    extern_methods!(
166        /// The delegate. It must conform to ICDeviceBrowserDelegate protocol. The messages this delegate can expect to receive are described by ICDeviceBrowserDelegate protocol.
167        ///
168        /// # Safety
169        ///
170        /// This is not retained internally, you must ensure the object is still alive.
171        #[unsafe(method(delegate))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn delegate(
174            &self,
175        ) -> Option<Retained<ProtocolObject<dyn ICDeviceBrowserDelegate>>>;
176
177        /// Setter for [`delegate`][Self::delegate].
178        ///
179        /// # Safety
180        ///
181        /// This is unretained, you must ensure the object is kept alive while in use.
182        #[unsafe(method(setDelegate:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn setDelegate(
185            &self,
186            delegate: Option<&ProtocolObject<dyn ICDeviceBrowserDelegate>>,
187        );
188
189        /// Indicates whether the device browser is browsing for devices.
190        #[unsafe(method(isBrowsing))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn isBrowsing(&self) -> bool;
193
194        /// Indicates whether the  devices in the browser have suspended communication.
195        #[unsafe(method(isSuspended))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn isSuspended(&self) -> bool;
198
199        #[cfg(feature = "ICDevice")]
200        /// A mask whose set bits indicate the type of device(s) being browsed after the receiver receives the start message. This property can be changed while the browser is browsing for devices. This property can be constructed by OR'd values of ICDeviceTypeMask with values of ICDeviceLocationTypeMask.
201        #[unsafe(method(browsedDeviceTypeMask))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn browsedDeviceTypeMask(&self) -> ICDeviceTypeMask;
204
205        #[cfg(feature = "ICDevice")]
206        /// Setter for [`browsedDeviceTypeMask`][Self::browsedDeviceTypeMask].
207        #[unsafe(method(setBrowsedDeviceTypeMask:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn setBrowsedDeviceTypeMask(&self, browsed_device_type_mask: ICDeviceTypeMask);
210
211        #[cfg(feature = "ICDevice")]
212        /// All devices found by the browser. This property will change as devices appear and disappear. This array is empty before the first invocation of the delegate method 'deviceBrowser:didAddDevice:moreComing:'.
213        #[unsafe(method(devices))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn devices(&self) -> Option<Retained<NSArray<ICDevice>>>;
216
217        #[cfg(feature = "ICDevice")]
218        /// This property returns a device object that should be selected by the client application when it is launched.
219        ///
220        /// If the client application that calls this method is the auto-launch application associated with a device and that device is the last device attached (through USB, FireWire or network), then that device will be the preferred device. The best place to call this method is in the implmentation of the ICDeviceBrowser delegate method "deviceBrowser:didAddDevice:moreComing:", if the "moreComing" parameter passed to the delegate is "NO"; or in the delegate method "deviceBrowserDidEnumerateLocalDevices:".
221        #[unsafe(method(preferredDevice))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn preferredDevice(&self) -> Option<Retained<ICDevice>>;
224
225        /// This is the designated initializer.
226        #[unsafe(method(init))]
227        #[unsafe(method_family = init)]
228        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
229
230        /// This message tells the receiver to start looking for devices.
231        ///
232        /// Make sure that the receiver's delegate is set prior to sending this message; otherwise this message will be ignored. The messages the delegate can expect to receive are described by ICDeviceBrowserDelegate protocol.
233        #[unsafe(method(start))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn start(&self);
236
237        /// This method tells the receiver to stop looking for devices.
238        ///
239        /// This will free all device instances that are not in use.
240        #[unsafe(method(stop))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn stop(&self);
243
244        /// This property returns a constant indicating whether the app has permission to acces the contents of an attached media device.
245        ///
246        /// A constant indicating authorization status.
247        #[unsafe(method(contentsAuthorizationStatus))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn contentsAuthorizationStatus(&self) -> Retained<ICAuthorizationStatus>;
250
251        #[cfg(feature = "block2")]
252        /// This method requests the user’s permission, if needed, for accessing the conents of an external media device.
253        #[unsafe(method(requestContentsAuthorizationWithCompletion:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn requestContentsAuthorizationWithCompletion(
256            &self,
257            completion: &block2::DynBlock<dyn Fn(NonNull<ICAuthorizationStatus>)>,
258        );
259
260        /// This property returns a constant indicating whether the app has permission to control the attached camera device.
261        #[unsafe(method(controlAuthorizationStatus))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn controlAuthorizationStatus(&self) -> Retained<ICAuthorizationStatus>;
264
265        #[cfg(feature = "block2")]
266        /// This method requests the user’s permission, if needed, for controlling the attached camera device.
267        #[unsafe(method(requestControlAuthorizationWithCompletion:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn requestControlAuthorizationWithCompletion(
270            &self,
271            completion: &block2::DynBlock<dyn Fn(NonNull<ICAuthorizationStatus>)>,
272        );
273
274        #[cfg(feature = "block2")]
275        /// This method resets the authorization status for the application accessing the conents of an external media device.
276        #[unsafe(method(resetContentsAuthorizationWithCompletion:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn resetContentsAuthorizationWithCompletion(
279            &self,
280            completion: &block2::DynBlock<dyn Fn(NonNull<ICAuthorizationStatus>)>,
281        );
282
283        #[cfg(feature = "block2")]
284        /// This method resets the authorization status for the application controlling the attached camera device.
285        ///
286        /// If the application already has been granted camera access, this will reset only the presentation dialog letting the user know the app has permission, not the camera access itself.
287        #[unsafe(method(resetControlAuthorizationWithCompletion:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn resetControlAuthorizationWithCompletion(
290            &self,
291            completion: &block2::DynBlock<dyn Fn(NonNull<ICAuthorizationStatus>)>,
292        );
293    );
294}
295
296/// Methods declared on superclass `NSObject`.
297impl ICDeviceBrowser {
298    extern_methods!(
299        #[unsafe(method(new))]
300        #[unsafe(method_family = new)]
301        pub unsafe fn new() -> Retained<Self>;
302    );
303}