objc2_app_kit/generated/
NSSharingService.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::*;
6#[cfg(feature = "objc2-cloud-kit")]
7#[cfg(target_vendor = "apple")]
8use objc2_cloud_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13/// Built-in sharing services
14///
15/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicename?language=objc)
16// NS_TYPED_EXTENSIBLE_ENUM
17pub type NSSharingServiceName = NSString;
18
19extern "C" {
20    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamecomposeemail?language=objc)
21    pub static NSSharingServiceNameComposeEmail: &'static NSSharingServiceName;
22}
23
24extern "C" {
25    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamecomposemessage?language=objc)
26    pub static NSSharingServiceNameComposeMessage: &'static NSSharingServiceName;
27}
28
29extern "C" {
30    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamesendviaairdrop?language=objc)
31    pub static NSSharingServiceNameSendViaAirDrop: &'static NSSharingServiceName;
32}
33
34extern "C" {
35    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenameaddtosafarireadinglist?language=objc)
36    pub static NSSharingServiceNameAddToSafariReadingList: &'static NSSharingServiceName;
37}
38
39extern "C" {
40    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenameaddtoiphoto?language=objc)
41    pub static NSSharingServiceNameAddToIPhoto: &'static NSSharingServiceName;
42}
43
44extern "C" {
45    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenameaddtoaperture?language=objc)
46    pub static NSSharingServiceNameAddToAperture: &'static NSSharingServiceName;
47}
48
49extern "C" {
50    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenameuseasdesktoppicture?language=objc)
51    pub static NSSharingServiceNameUseAsDesktopPicture: &'static NSSharingServiceName;
52}
53
54extern "C" {
55    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostonfacebook?language=objc)
56    pub static NSSharingServiceNamePostOnFacebook: &'static NSSharingServiceName;
57}
58
59extern "C" {
60    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostontwitter?language=objc)
61    pub static NSSharingServiceNamePostOnTwitter: &'static NSSharingServiceName;
62}
63
64extern "C" {
65    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostonsinaweibo?language=objc)
66    pub static NSSharingServiceNamePostOnSinaWeibo: &'static NSSharingServiceName;
67}
68
69extern "C" {
70    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostontencentweibo?language=objc)
71    pub static NSSharingServiceNamePostOnTencentWeibo: &'static NSSharingServiceName;
72}
73
74extern "C" {
75    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostonlinkedin?language=objc)
76    pub static NSSharingServiceNamePostOnLinkedIn: &'static NSSharingServiceName;
77}
78
79extern "C" {
80    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenameuseastwitterprofileimage?language=objc)
81    pub static NSSharingServiceNameUseAsTwitterProfileImage: &'static NSSharingServiceName;
82}
83
84extern "C" {
85    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenameuseasfacebookprofileimage?language=objc)
86    pub static NSSharingServiceNameUseAsFacebookProfileImage: &'static NSSharingServiceName;
87}
88
89extern "C" {
90    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenameuseaslinkedinprofileimage?language=objc)
91    pub static NSSharingServiceNameUseAsLinkedInProfileImage: &'static NSSharingServiceName;
92}
93
94extern "C" {
95    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostimageonflickr?language=objc)
96    pub static NSSharingServiceNamePostImageOnFlickr: &'static NSSharingServiceName;
97}
98
99extern "C" {
100    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostvideoonvimeo?language=objc)
101    pub static NSSharingServiceNamePostVideoOnVimeo: &'static NSSharingServiceName;
102}
103
104extern "C" {
105    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostvideoonyouku?language=objc)
106    pub static NSSharingServiceNamePostVideoOnYouku: &'static NSSharingServiceName;
107}
108
109extern "C" {
110    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamepostvideoontudou?language=objc)
111    pub static NSSharingServiceNamePostVideoOnTudou: &'static NSSharingServiceName;
112}
113
114extern "C" {
115    /// This service differs from other NSSharingServices in that it allows the user to establish a persistent sharing session for the specified items with potentially many participants, instead of sending a copy of the items. You can invoke this service with an NSItemProvider that has registered a CKShare
116    /// &
117    /// CKContainer via either -registerCloudKitShare:container: or -registerCloudKitShareWithPreparationHandler:. (Registering other types on the same provider to enable other sharing services is allowed.)
118    ///
119    /// When performed, this service gives the user the opportunity to invite participants and start sharing. If the content is already shared, the service instead allows the user to view or modify participation or stop sharing. To detect changes the service makes to the CKShare, implement -sharingService:didSaveShare: and -sharingService:didStopSharing:.
120    ///
121    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicenamecloudsharing?language=objc)
122    pub static NSSharingServiceNameCloudSharing: &'static NSSharingServiceName;
123}
124
125extern_class!(
126    /// NSSharingService can be used to share items to different kinds of local and remote services. Items are objects which respond to the NSPasteboardWriting protocol, like NSURL, NSImage or NSString. If an NSURL is a file URL (point to a video for example), then the content of the file will be shared. If the URL is remote, then the URL itself will be shared.
127    ///
128    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservice?language=objc)
129    #[unsafe(super(NSObject))]
130    #[derive(Debug, PartialEq, Eq, Hash)]
131    pub struct NSSharingService;
132);
133
134extern_conformance!(
135    unsafe impl NSObjectProtocol for NSSharingService {}
136);
137
138impl NSSharingService {
139    extern_methods!(
140        #[unsafe(method(delegate))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn delegate(
143            &self,
144            mtm: MainThreadMarker,
145        ) -> Option<Retained<ProtocolObject<dyn NSSharingServiceDelegate>>>;
146
147        /// This is a [weak property][objc2::topics::weak_property].
148        /// Setter for [`delegate`][Self::delegate].
149        #[unsafe(method(setDelegate:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn setDelegate(
152            &self,
153            delegate: Option<&ProtocolObject<dyn NSSharingServiceDelegate>>,
154        );
155
156        #[unsafe(method(title))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn title(&self) -> Retained<NSString>;
159
160        #[cfg(feature = "NSImage")]
161        #[unsafe(method(image))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn image(&self) -> Retained<NSImage>;
164
165        #[cfg(feature = "NSImage")]
166        #[unsafe(method(alternateImage))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn alternateImage(&self) -> Option<Retained<NSImage>>;
169
170        /// Title of the service in the Share menu. Can be modified.
171        #[unsafe(method(menuItemTitle))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn menuItemTitle(&self) -> Retained<NSString>;
174
175        /// Setter for [`menuItemTitle`][Self::menuItemTitle].
176        #[unsafe(method(setMenuItemTitle:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setMenuItemTitle(&self, menu_item_title: &NSString);
179
180        /// NSArray of NSString objects representing handles (example: email adresses)
181        #[unsafe(method(recipients))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn recipients(&self) -> Option<Retained<NSArray<NSString>>>;
184
185        /// Setter for [`recipients`][Self::recipients].
186        #[unsafe(method(setRecipients:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<NSString>>);
189
190        #[unsafe(method(subject))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn subject(&self) -> Option<Retained<NSString>>;
193
194        /// Setter for [`subject`][Self::subject].
195        #[unsafe(method(setSubject:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setSubject(&self, subject: Option<&NSString>);
198
199        /// Message body as string
200        #[unsafe(method(messageBody))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn messageBody(&self) -> Option<Retained<NSString>>;
203
204        /// URL to access the post on Facebook, Twitter, Sina Weibo, etc. (also known as permalink)
205        #[unsafe(method(permanentLink))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn permanentLink(&self) -> Option<Retained<NSURL>>;
208
209        /// Account name used for sending on Twitter or Sina Weibo
210        #[unsafe(method(accountName))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn accountName(&self) -> Option<Retained<NSString>>;
213
214        /// NSArray of NSURL objects representing the files that were shared
215        #[unsafe(method(attachmentFileURLs))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn attachmentFileURLs(&self) -> Option<Retained<NSArray<NSURL>>>;
218
219        /// Returns a list of NSSharingServices which could share all the provided items together. sharingServicesForItems can be used to build a custom UI, or to populate a contextual NSMenu.
220        /// The items represent the objects to be shared and must conform to the
221        /// <NSPasteboardWriting
222        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
223        #[deprecated = "Use -[NSSharingServicePicker standardShareMenuItem] instead."]
224        #[unsafe(method(sharingServicesForItems:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn sharingServicesForItems(
227            items: &NSArray,
228        ) -> Retained<NSArray<NSSharingService>>;
229
230        /// Returns an NSSharingService representing one of the built-in services.
231        #[unsafe(method(sharingServiceNamed:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn sharingServiceNamed(
234            service_name: &NSSharingServiceName,
235        ) -> Option<Retained<NSSharingService>>;
236
237        #[cfg(all(feature = "NSImage", feature = "block2"))]
238        /// Creates a custom NSSharingService object. Custom sharing services can be added to the NSSharingServicePicker with the sharingServicePicker:sharingServicesForItems:proposedSharingServices: delegate method.
239        #[unsafe(method(initWithTitle:image:alternateImage:handler:))]
240        #[unsafe(method_family = init)]
241        pub unsafe fn initWithTitle_image_alternateImage_handler(
242            this: Allocated<Self>,
243            title: &NSString,
244            image: &NSImage,
245            alternate_image: Option<&NSImage>,
246            block: &block2::DynBlock<dyn Fn()>,
247        ) -> Retained<Self>;
248
249        /// Use -initWithTitle:image:alternateImage:handler: instead
250        #[unsafe(method(init))]
251        #[unsafe(method_family = init)]
252        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
253
254        /// Returns whether a service can do something with all the provided items. This can be used to validate a custom UI such as a dedicated Twitter button. If items is nil, the method will return YES when the service is configured. Therefore you could call it once at launch time with nil items to check whether to display the button or not, and then with real items to enable and disable the button depending on the context or selection.
255        ///
256        /// The items represent the objects to be shared and must conform to the
257        /// <NSPasteboardWriting
258        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
259        #[unsafe(method(canPerformWithItems:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn canPerformWithItems(&self, items: Option<&NSArray>) -> bool;
262
263        /// Manually performs the service on the provided items. In most cases this will display a sharing window.
264        ///
265        /// The items represent the objects to be shared and must conform to the
266        /// <NSPasteboardWriting
267        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
268        #[unsafe(method(performWithItems:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn performWithItems(&self, items: &NSArray);
271    );
272}
273
274/// Methods declared on superclass `NSObject`.
275impl NSSharingService {
276    extern_methods!(
277        #[unsafe(method(new))]
278        #[unsafe(method_family = new)]
279        pub unsafe fn new() -> Retained<Self>;
280    );
281}
282
283/// Use the sharing scope to specify the nature of the things you are sharing.
284///
285/// The sharing scope can be modified from the default value of NSSharingContentScopeItem by setting a different value in the out parameter in sharingService:sourceWindowForShareItems:sharingContentScope:.
286///
287/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingcontentscope?language=objc)
288// NS_ENUM
289#[repr(transparent)]
290#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
291pub struct NSSharingContentScope(pub NSInteger);
292impl NSSharingContentScope {
293    /// NSSharingContentScopeItem: use when sharing a clearly identified item, e.g. a file represented by its icon.
294    #[doc(alias = "NSSharingContentScopeItem")]
295    pub const Item: Self = Self(0);
296    /// NSSharingContentScopePartial: use when sharing a portion of a more global content, e.g. part of a webpage
297    #[doc(alias = "NSSharingContentScopePartial")]
298    pub const Partial: Self = Self(1);
299    /// NSSharingContentScopeFull: use when sharing the whole content of the current document, e.g. the url of the webpage
300    #[doc(alias = "NSSharingContentScopeFull")]
301    pub const Full: Self = Self(2);
302}
303
304unsafe impl Encode for NSSharingContentScope {
305    const ENCODING: Encoding = NSInteger::ENCODING;
306}
307
308unsafe impl RefEncode for NSSharingContentScope {
309    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
310}
311
312extern_protocol!(
313    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicedelegate?language=objc)
314    pub unsafe trait NSSharingServiceDelegate: NSObjectProtocol + MainThreadOnly {
315        #[optional]
316        #[unsafe(method(sharingService:willShareItems:))]
317        #[unsafe(method_family = none)]
318        unsafe fn sharingService_willShareItems(
319            &self,
320            sharing_service: &NSSharingService,
321            items: &NSArray,
322        );
323
324        #[optional]
325        #[unsafe(method(sharingService:didFailToShareItems:error:))]
326        #[unsafe(method_family = none)]
327        unsafe fn sharingService_didFailToShareItems_error(
328            &self,
329            sharing_service: &NSSharingService,
330            items: &NSArray,
331            error: &NSError,
332        );
333
334        #[optional]
335        #[unsafe(method(sharingService:didShareItems:))]
336        #[unsafe(method_family = none)]
337        unsafe fn sharingService_didShareItems(
338            &self,
339            sharing_service: &NSSharingService,
340            items: &NSArray,
341        );
342
343        #[optional]
344        #[unsafe(method(sharingService:sourceFrameOnScreenForShareItem:))]
345        #[unsafe(method_family = none)]
346        unsafe fn sharingService_sourceFrameOnScreenForShareItem(
347            &self,
348            sharing_service: &NSSharingService,
349            item: &AnyObject,
350        ) -> NSRect;
351
352        #[cfg(feature = "NSImage")]
353        /// When non-nil, the image returned would be used for the transitioning animation. When nil, the transitioning animation is disabled.
354        #[optional]
355        #[unsafe(method(sharingService:transitionImageForShareItem:contentRect:))]
356        #[unsafe(method_family = none)]
357        unsafe fn sharingService_transitionImageForShareItem_contentRect(
358            &self,
359            sharing_service: &NSSharingService,
360            item: &AnyObject,
361            content_rect: NonNull<NSRect>,
362        ) -> Option<Retained<NSImage>>;
363
364        #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
365        #[optional]
366        #[unsafe(method(sharingService:sourceWindowForShareItems:sharingContentScope:))]
367        #[unsafe(method_family = none)]
368        unsafe fn sharingService_sourceWindowForShareItems_sharingContentScope(
369            &self,
370            sharing_service: &NSSharingService,
371            items: &NSArray,
372            sharing_content_scope: NonNull<NSSharingContentScope>,
373        ) -> Option<Retained<NSWindow>>;
374
375        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
376        /// The following method is invoked when the service is performed and wants to display its contents in a popover. The delegate should return the view that will act as the anchor of the popover, along with the target rectangle within the bounds of that view and preferred edge of that rectangle for the popover to appear. The delegate may also return nil, indicating that there is no anchoring view currently available, in which case the service may attempt to display the service via some other means.
377        ///
378        /// The service named NSSharingServiceNameCloudSharing prefers to display itself using a popover anchored to an "Add People" or "Share" button. If no such button is available or visible, return nil.
379        #[optional]
380        #[unsafe(method(anchoringViewForSharingService:showRelativeToRect:preferredEdge:))]
381        #[unsafe(method_family = none)]
382        unsafe fn anchoringViewForSharingService_showRelativeToRect_preferredEdge(
383            &self,
384            sharing_service: &NSSharingService,
385            positioning_rect: NonNull<NSRect>,
386            preferred_edge: NonNull<NSRectEdge>,
387        ) -> Option<Retained<NSView>>;
388    }
389);
390
391/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscloudkitsharingserviceoptions?language=objc)
392// NS_OPTIONS
393#[repr(transparent)]
394#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
395pub struct NSCloudKitSharingServiceOptions(pub NSUInteger);
396bitflags::bitflags! {
397    impl NSCloudKitSharingServiceOptions: NSUInteger {
398/// Allow the user to configure the share with the standard set of options.
399        #[doc(alias = "NSCloudKitSharingServiceStandard")]
400        const Standard = 0;
401/// The user is allowed to share publicly.
402        #[doc(alias = "NSCloudKitSharingServiceAllowPublic")]
403        const AllowPublic = 1<<0;
404/// The user is allowed to share privately.
405        #[doc(alias = "NSCloudKitSharingServiceAllowPrivate")]
406        const AllowPrivate = 1<<1;
407/// The user is allowed to grant participants read-only permissions.
408        #[doc(alias = "NSCloudKitSharingServiceAllowReadOnly")]
409        const AllowReadOnly = 1<<4;
410/// The user is allowed to grant participants read/write permissions.
411        #[doc(alias = "NSCloudKitSharingServiceAllowReadWrite")]
412        const AllowReadWrite = 1<<5;
413    }
414}
415
416unsafe impl Encode for NSCloudKitSharingServiceOptions {
417    const ENCODING: Encoding = NSUInteger::ENCODING;
418}
419
420unsafe impl RefEncode for NSCloudKitSharingServiceOptions {
421    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
422}
423
424extern_protocol!(
425    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscloudsharingservicedelegate?language=objc)
426    pub unsafe trait NSCloudSharingServiceDelegate: NSSharingServiceDelegate {
427        /// When an NSSharingServiceNameCloudSharing sharing service is dismissed it will invoke this method on the delegate, with an error if there was any. If the delegate implements this method, NSSharingServiceNameCloudSharing will not send -sharingService:didFailToShareItems:error: or -sharingService:didShareItems:.
428        #[optional]
429        #[unsafe(method(sharingService:didCompleteForItems:error:))]
430        #[unsafe(method_family = none)]
431        unsafe fn sharingService_didCompleteForItems_error(
432            &self,
433            sharing_service: &NSSharingService,
434            items: &NSArray,
435            error: Option<&NSError>,
436        );
437
438        /// The options returned by this method describe how the user is allowed to configure the share: whether the share is public or private, and whether participants have read-only or read/write permissions. If this method is not implemented, NSCloudKitSharingServiceStandard is assumed.
439        #[optional]
440        #[unsafe(method(optionsForSharingService:shareProvider:))]
441        #[unsafe(method_family = none)]
442        unsafe fn optionsForSharingService_shareProvider(
443            &self,
444            cloud_kit_sharing_service: &NSSharingService,
445            provider: &NSItemProvider,
446        ) -> NSCloudKitSharingServiceOptions;
447
448        #[cfg(feature = "objc2-cloud-kit")]
449        #[cfg(target_vendor = "apple")]
450        /// When an NSSharingServiceNameCloudSharing sharing service successfully saves modifications to the CKShare, it will invoke this method on the delegate with the last-known state of the CKShare on the server.
451        #[optional]
452        #[unsafe(method(sharingService:didSaveShare:))]
453        #[unsafe(method_family = none)]
454        unsafe fn sharingService_didSaveShare(
455            &self,
456            sharing_service: &NSSharingService,
457            share: &CKShare,
458        );
459
460        #[cfg(feature = "objc2-cloud-kit")]
461        #[cfg(target_vendor = "apple")]
462        /// When an NSSharingServiceNameCloudSharing sharing service stops sharing it will delete the CKShare from the server, then invoke this method on the delegate with the last-known state of the CKShare.
463        #[optional]
464        #[unsafe(method(sharingService:didStopSharing:))]
465        #[unsafe(method_family = none)]
466        unsafe fn sharingService_didStopSharing(
467            &self,
468            sharing_service: &NSSharingService,
469            share: &CKShare,
470        );
471    }
472);
473
474mod private_NSItemProviderNSCloudKitSharing {
475    pub trait Sealed {}
476}
477
478/// Category "NSCloudKitSharing" on [`NSItemProvider`].
479#[doc(alias = "NSCloudKitSharing")]
480pub unsafe trait NSItemProviderNSCloudKitSharing:
481    ClassType + Sized + private_NSItemProviderNSCloudKitSharing::Sealed
482{
483    extern_methods!(
484        #[cfg(all(feature = "block2", feature = "objc2-cloud-kit"))]
485        #[cfg(target_vendor = "apple")]
486        /// Use this method when you want to share a collection of CKRecords but don't currently have a CKShare. When the preparationHandler is called, you should create a new CKShare with the appropriate root CKRecord. After ensuring the share and all records have been saved to the server, invoke the preparationCompletionHandler with either the resulting CKShare and its CKContainer, or an NSError if saving failed. Invoking the service with a CKShare registered with this method will prompt the user to start sharing.
487        #[unsafe(method(registerCloudKitShareWithPreparationHandler:))]
488        #[unsafe(method_family = none)]
489        unsafe fn registerCloudKitShareWithPreparationHandler(
490            &self,
491            preparation_handler: &block2::DynBlock<
492                dyn Fn(
493                    NonNull<block2::DynBlock<dyn Fn(*mut CKShare, *mut CKContainer, *mut NSError)>>,
494                ),
495            >,
496        );
497
498        #[cfg(feature = "objc2-cloud-kit")]
499        #[cfg(target_vendor = "apple")]
500        /// Use this method when you have a CKShare that is already saved to the server. Invoking the service with a CKShare registerd with this method will allow the owner to make modifications to the share settings, or will allow a participant to view the share settings.
501        #[unsafe(method(registerCloudKitShare:container:))]
502        #[unsafe(method_family = none)]
503        unsafe fn registerCloudKitShare_container(&self, share: &CKShare, container: &CKContainer);
504    );
505}
506
507impl private_NSItemProviderNSCloudKitSharing::Sealed for NSItemProvider {}
508unsafe impl NSItemProviderNSCloudKitSharing for NSItemProvider {}
509
510extern_class!(
511    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicepicker?language=objc)
512    #[unsafe(super(NSObject))]
513    #[derive(Debug, PartialEq, Eq, Hash)]
514    pub struct NSSharingServicePicker;
515);
516
517extern_conformance!(
518    unsafe impl NSObjectProtocol for NSSharingServicePicker {}
519);
520
521impl NSSharingServicePicker {
522    extern_methods!(
523        #[unsafe(method(delegate))]
524        #[unsafe(method_family = none)]
525        pub unsafe fn delegate(
526            &self,
527        ) -> Option<Retained<ProtocolObject<dyn NSSharingServicePickerDelegate>>>;
528
529        /// This is a [weak property][objc2::topics::weak_property].
530        /// Setter for [`delegate`][Self::delegate].
531        #[unsafe(method(setDelegate:))]
532        #[unsafe(method_family = none)]
533        pub unsafe fn setDelegate(
534            &self,
535            delegate: Option<&ProtocolObject<dyn NSSharingServicePickerDelegate>>,
536        );
537
538        /// Returns a new picker. The items represent the objects to be shared and must conform to the
539        /// <NSPasteboardWriting
540        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
541        #[unsafe(method(initWithItems:))]
542        #[unsafe(method_family = init)]
543        pub unsafe fn initWithItems(this: Allocated<Self>, items: &NSArray) -> Retained<Self>;
544
545        /// Use initWithItems: instead.
546        #[unsafe(method(init))]
547        #[unsafe(method_family = init)]
548        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
549
550        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
551        /// Shows the picker, populated with sharing services related to the instance items. When the user selects one of the sharing services, the sharing service will be performed. Note that this method must be called on mouseDown.
552        #[unsafe(method(showRelativeToRect:ofView:preferredEdge:))]
553        #[unsafe(method_family = none)]
554        pub unsafe fn showRelativeToRect_ofView_preferredEdge(
555            &self,
556            rect: NSRect,
557            view: &NSView,
558            preferred_edge: NSRectEdge,
559        );
560
561        /// Closes the picker UI. `-[NSSharingServicePickerDelegate sharingServicePicker:didChooseSharingService:]` will be invoked if `delegate` is set, with a `nil` service.
562        #[unsafe(method(close))]
563        #[unsafe(method_family = none)]
564        pub unsafe fn close(&self);
565
566        #[cfg(feature = "NSMenuItem")]
567        /// Returns a menu item suitable to display the picker for the given items.
568        #[unsafe(method(standardShareMenuItem))]
569        #[unsafe(method_family = none)]
570        pub unsafe fn standardShareMenuItem(&self, mtm: MainThreadMarker) -> Retained<NSMenuItem>;
571    );
572}
573
574/// Methods declared on superclass `NSObject`.
575impl NSSharingServicePicker {
576    extern_methods!(
577        #[unsafe(method(new))]
578        #[unsafe(method_family = new)]
579        pub unsafe fn new() -> Retained<Self>;
580    );
581}
582
583extern_protocol!(
584    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicepickerdelegate?language=objc)
585    pub unsafe trait NSSharingServicePickerDelegate: NSObjectProtocol {
586        /// Allows the delegate to customize exactly what appears in the sharing service picker by reordering or removing the services before the picker is presented. It's possible to add custom services by mutating the proposedSharingServices array and adding new NSSharingService instances:
587        ///
588        /// ```objc
589        /// NSMutableArray *sharingServices = [proposedServices mutableCopy];
590        /// NSSharingService * customService = [[NSSharingService alloc] initWithTitle:
591        /// "
592        /// Service Title"
593        /// image:image alternateImage:alternateImage
594        /// handler:^{ [self doCustomServiceWithItems:items]; } ];
595        /// [sharingServices addObject:customService];
596        /// return [sharingServices autorelease];
597        /// ```
598        /// The items represent the objects to be shared and must conform to the
599        /// <NSPasteboardWriting
600        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
601        #[optional]
602        #[unsafe(method(sharingServicePicker:sharingServicesForItems:proposedSharingServices:))]
603        #[unsafe(method_family = none)]
604        unsafe fn sharingServicePicker_sharingServicesForItems_proposedSharingServices(
605            &self,
606            sharing_service_picker: &NSSharingServicePicker,
607            items: &NSArray,
608            proposed_services: &NSArray<NSSharingService>,
609        ) -> Retained<NSArray<NSSharingService>>;
610
611        /// Sent when the user has selected a service and the picker is about to execute it.
612        #[optional]
613        #[unsafe(method(sharingServicePicker:delegateForSharingService:))]
614        #[unsafe(method_family = none)]
615        unsafe fn sharingServicePicker_delegateForSharingService(
616            &self,
617            sharing_service_picker: &NSSharingServicePicker,
618            sharing_service: &NSSharingService,
619            mtm: MainThreadMarker,
620        ) -> Option<Retained<ProtocolObject<dyn NSSharingServiceDelegate>>>;
621
622        /// Sent when the user has selected a service and before it is executed. Service will be nil if the picker was dismissed.
623        #[optional]
624        #[unsafe(method(sharingServicePicker:didChooseSharingService:))]
625        #[unsafe(method_family = none)]
626        unsafe fn sharingServicePicker_didChooseSharingService(
627            &self,
628            sharing_service_picker: &NSSharingServicePicker,
629            service: Option<&NSSharingService>,
630        );
631
632        #[cfg(feature = "NSSharingCollaborationModeRestriction")]
633        /// Used to specify the case where the share picker should not support some modes of sharing even if they are supported by the items being shared.
634        /// Disabling all possible modes at the same time is not supported behavior.
635        #[optional]
636        #[unsafe(method(sharingServicePickerCollaborationModeRestrictions:))]
637        #[unsafe(method_family = none)]
638        unsafe fn sharingServicePickerCollaborationModeRestrictions(
639            &self,
640            sharing_service_picker: &NSSharingServicePicker,
641        ) -> Option<Retained<NSArray<NSSharingCollaborationModeRestriction>>>;
642    }
643);