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
134unsafe impl NSObjectProtocol for NSSharingService {}
135
136impl NSSharingService {
137    extern_methods!(
138        #[unsafe(method(delegate))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn delegate(
141            &self,
142            mtm: MainThreadMarker,
143        ) -> Option<Retained<ProtocolObject<dyn NSSharingServiceDelegate>>>;
144
145        /// This is a [weak property][objc2::topics::weak_property].
146        /// Setter for [`delegate`][Self::delegate].
147        #[unsafe(method(setDelegate:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn setDelegate(
150            &self,
151            delegate: Option<&ProtocolObject<dyn NSSharingServiceDelegate>>,
152        );
153
154        #[unsafe(method(title))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn title(&self) -> Retained<NSString>;
157
158        #[cfg(feature = "NSImage")]
159        #[unsafe(method(image))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn image(&self) -> Retained<NSImage>;
162
163        #[cfg(feature = "NSImage")]
164        #[unsafe(method(alternateImage))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn alternateImage(&self) -> Option<Retained<NSImage>>;
167
168        /// Title of the service in the Share menu. Can be modified.
169        #[unsafe(method(menuItemTitle))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn menuItemTitle(&self) -> Retained<NSString>;
172
173        /// Setter for [`menuItemTitle`][Self::menuItemTitle].
174        #[unsafe(method(setMenuItemTitle:))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn setMenuItemTitle(&self, menu_item_title: &NSString);
177
178        /// NSArray of NSString objects representing handles (example: email adresses)
179        #[unsafe(method(recipients))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn recipients(&self) -> Option<Retained<NSArray<NSString>>>;
182
183        /// Setter for [`recipients`][Self::recipients].
184        #[unsafe(method(setRecipients:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<NSString>>);
187
188        #[unsafe(method(subject))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn subject(&self) -> Option<Retained<NSString>>;
191
192        /// Setter for [`subject`][Self::subject].
193        #[unsafe(method(setSubject:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn setSubject(&self, subject: Option<&NSString>);
196
197        /// Message body as string
198        #[unsafe(method(messageBody))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn messageBody(&self) -> Option<Retained<NSString>>;
201
202        /// URL to access the post on Facebook, Twitter, Sina Weibo, etc. (also known as permalink)
203        #[unsafe(method(permanentLink))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn permanentLink(&self) -> Option<Retained<NSURL>>;
206
207        /// Account name used for sending on Twitter or Sina Weibo
208        #[unsafe(method(accountName))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn accountName(&self) -> Option<Retained<NSString>>;
211
212        /// NSArray of NSURL objects representing the files that were shared
213        #[unsafe(method(attachmentFileURLs))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn attachmentFileURLs(&self) -> Option<Retained<NSArray<NSURL>>>;
216
217        /// 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.
218        /// The items represent the objects to be shared and must conform to the
219        /// <NSPasteboardWriting
220        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
221        #[deprecated = "Use -[NSSharingServicePicker standardShareMenuItem] instead."]
222        #[unsafe(method(sharingServicesForItems:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn sharingServicesForItems(
225            items: &NSArray,
226        ) -> Retained<NSArray<NSSharingService>>;
227
228        /// Returns an NSSharingService representing one of the built-in services.
229        #[unsafe(method(sharingServiceNamed:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn sharingServiceNamed(
232            service_name: &NSSharingServiceName,
233        ) -> Option<Retained<NSSharingService>>;
234
235        #[cfg(all(feature = "NSImage", feature = "block2"))]
236        /// Creates a custom NSSharingService object. Custom sharing services can be added to the NSSharingServicePicker with the sharingServicePicker:sharingServicesForItems:proposedSharingServices: delegate method.
237        #[unsafe(method(initWithTitle:image:alternateImage:handler:))]
238        #[unsafe(method_family = init)]
239        pub unsafe fn initWithTitle_image_alternateImage_handler(
240            this: Allocated<Self>,
241            title: &NSString,
242            image: &NSImage,
243            alternate_image: Option<&NSImage>,
244            block: &block2::Block<dyn Fn()>,
245        ) -> Retained<Self>;
246
247        /// Use -initWithTitle:image:alternateImage:handler: instead
248        #[unsafe(method(init))]
249        #[unsafe(method_family = init)]
250        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
251
252        /// 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.
253        ///
254        /// The items represent the objects to be shared and must conform to the
255        /// <NSPasteboardWriting
256        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
257        #[unsafe(method(canPerformWithItems:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn canPerformWithItems(&self, items: Option<&NSArray>) -> bool;
260
261        /// Manually performs the service on the provided items. In most cases this will display a sharing window.
262        ///
263        /// The items represent the objects to be shared and must conform to the
264        /// <NSPasteboardWriting
265        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
266        #[unsafe(method(performWithItems:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn performWithItems(&self, items: &NSArray);
269    );
270}
271
272/// Methods declared on superclass `NSObject`.
273impl NSSharingService {
274    extern_methods!(
275        #[unsafe(method(new))]
276        #[unsafe(method_family = new)]
277        pub unsafe fn new() -> Retained<Self>;
278    );
279}
280
281/// Use the sharing scope to specify the nature of the things you are sharing.
282///
283/// 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:.
284///
285/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingcontentscope?language=objc)
286// NS_ENUM
287#[repr(transparent)]
288#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
289pub struct NSSharingContentScope(pub NSInteger);
290impl NSSharingContentScope {
291    /// NSSharingContentScopeItem: use when sharing a clearly identified item, e.g. a file represented by its icon.
292    #[doc(alias = "NSSharingContentScopeItem")]
293    pub const Item: Self = Self(0);
294    /// NSSharingContentScopePartial: use when sharing a portion of a more global content, e.g. part of a webpage
295    #[doc(alias = "NSSharingContentScopePartial")]
296    pub const Partial: Self = Self(1);
297    /// NSSharingContentScopeFull: use when sharing the whole content of the current document, e.g. the url of the webpage
298    #[doc(alias = "NSSharingContentScopeFull")]
299    pub const Full: Self = Self(2);
300}
301
302unsafe impl Encode for NSSharingContentScope {
303    const ENCODING: Encoding = NSInteger::ENCODING;
304}
305
306unsafe impl RefEncode for NSSharingContentScope {
307    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
308}
309
310extern_protocol!(
311    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicedelegate?language=objc)
312    pub unsafe trait NSSharingServiceDelegate: NSObjectProtocol + MainThreadOnly {
313        #[optional]
314        #[unsafe(method(sharingService:willShareItems:))]
315        #[unsafe(method_family = none)]
316        unsafe fn sharingService_willShareItems(
317            &self,
318            sharing_service: &NSSharingService,
319            items: &NSArray,
320        );
321
322        #[optional]
323        #[unsafe(method(sharingService:didFailToShareItems:error:))]
324        #[unsafe(method_family = none)]
325        unsafe fn sharingService_didFailToShareItems_error(
326            &self,
327            sharing_service: &NSSharingService,
328            items: &NSArray,
329            error: &NSError,
330        );
331
332        #[optional]
333        #[unsafe(method(sharingService:didShareItems:))]
334        #[unsafe(method_family = none)]
335        unsafe fn sharingService_didShareItems(
336            &self,
337            sharing_service: &NSSharingService,
338            items: &NSArray,
339        );
340
341        #[optional]
342        #[unsafe(method(sharingService:sourceFrameOnScreenForShareItem:))]
343        #[unsafe(method_family = none)]
344        unsafe fn sharingService_sourceFrameOnScreenForShareItem(
345            &self,
346            sharing_service: &NSSharingService,
347            item: &AnyObject,
348        ) -> NSRect;
349
350        #[cfg(feature = "NSImage")]
351        /// When non-nil, the image returned would be used for the transitioning animation. When nil, the transitioning animation is disabled.
352        #[optional]
353        #[unsafe(method(sharingService:transitionImageForShareItem:contentRect:))]
354        #[unsafe(method_family = none)]
355        unsafe fn sharingService_transitionImageForShareItem_contentRect(
356            &self,
357            sharing_service: &NSSharingService,
358            item: &AnyObject,
359            content_rect: NonNull<NSRect>,
360        ) -> Option<Retained<NSImage>>;
361
362        #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
363        #[optional]
364        #[unsafe(method(sharingService:sourceWindowForShareItems:sharingContentScope:))]
365        #[unsafe(method_family = none)]
366        unsafe fn sharingService_sourceWindowForShareItems_sharingContentScope(
367            &self,
368            sharing_service: &NSSharingService,
369            items: &NSArray,
370            sharing_content_scope: NonNull<NSSharingContentScope>,
371        ) -> Option<Retained<NSWindow>>;
372
373        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
374        /// 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.
375        ///
376        /// 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.
377        #[optional]
378        #[unsafe(method(anchoringViewForSharingService:showRelativeToRect:preferredEdge:))]
379        #[unsafe(method_family = none)]
380        unsafe fn anchoringViewForSharingService_showRelativeToRect_preferredEdge(
381            &self,
382            sharing_service: &NSSharingService,
383            positioning_rect: NonNull<NSRect>,
384            preferred_edge: NonNull<NSRectEdge>,
385        ) -> Option<Retained<NSView>>;
386    }
387);
388
389/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscloudkitsharingserviceoptions?language=objc)
390// NS_OPTIONS
391#[repr(transparent)]
392#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
393pub struct NSCloudKitSharingServiceOptions(pub NSUInteger);
394bitflags::bitflags! {
395    impl NSCloudKitSharingServiceOptions: NSUInteger {
396/// Allow the user to configure the share with the standard set of options.
397        #[doc(alias = "NSCloudKitSharingServiceStandard")]
398        const Standard = 0;
399/// The user is allowed to share publicly.
400        #[doc(alias = "NSCloudKitSharingServiceAllowPublic")]
401        const AllowPublic = 1<<0;
402/// The user is allowed to share privately.
403        #[doc(alias = "NSCloudKitSharingServiceAllowPrivate")]
404        const AllowPrivate = 1<<1;
405/// The user is allowed to grant participants read-only permissions.
406        #[doc(alias = "NSCloudKitSharingServiceAllowReadOnly")]
407        const AllowReadOnly = 1<<4;
408/// The user is allowed to grant participants read/write permissions.
409        #[doc(alias = "NSCloudKitSharingServiceAllowReadWrite")]
410        const AllowReadWrite = 1<<5;
411    }
412}
413
414unsafe impl Encode for NSCloudKitSharingServiceOptions {
415    const ENCODING: Encoding = NSUInteger::ENCODING;
416}
417
418unsafe impl RefEncode for NSCloudKitSharingServiceOptions {
419    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
420}
421
422extern_protocol!(
423    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscloudsharingservicedelegate?language=objc)
424    pub unsafe trait NSCloudSharingServiceDelegate: NSSharingServiceDelegate {
425        /// 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:.
426        #[optional]
427        #[unsafe(method(sharingService:didCompleteForItems:error:))]
428        #[unsafe(method_family = none)]
429        unsafe fn sharingService_didCompleteForItems_error(
430            &self,
431            sharing_service: &NSSharingService,
432            items: &NSArray,
433            error: Option<&NSError>,
434        );
435
436        /// 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.
437        #[optional]
438        #[unsafe(method(optionsForSharingService:shareProvider:))]
439        #[unsafe(method_family = none)]
440        unsafe fn optionsForSharingService_shareProvider(
441            &self,
442            cloud_kit_sharing_service: &NSSharingService,
443            provider: &NSItemProvider,
444        ) -> NSCloudKitSharingServiceOptions;
445
446        #[cfg(feature = "objc2-cloud-kit")]
447        #[cfg(target_vendor = "apple")]
448        /// 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.
449        #[optional]
450        #[unsafe(method(sharingService:didSaveShare:))]
451        #[unsafe(method_family = none)]
452        unsafe fn sharingService_didSaveShare(
453            &self,
454            sharing_service: &NSSharingService,
455            share: &CKShare,
456        );
457
458        #[cfg(feature = "objc2-cloud-kit")]
459        #[cfg(target_vendor = "apple")]
460        /// 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.
461        #[optional]
462        #[unsafe(method(sharingService:didStopSharing:))]
463        #[unsafe(method_family = none)]
464        unsafe fn sharingService_didStopSharing(
465            &self,
466            sharing_service: &NSSharingService,
467            share: &CKShare,
468        );
469    }
470);
471
472mod private_NSItemProviderNSCloudKitSharing {
473    pub trait Sealed {}
474}
475
476/// Category "NSCloudKitSharing" on [`NSItemProvider`].
477#[doc(alias = "NSCloudKitSharing")]
478pub unsafe trait NSItemProviderNSCloudKitSharing:
479    ClassType + Sized + private_NSItemProviderNSCloudKitSharing::Sealed
480{
481    extern_methods!(
482        #[cfg(all(feature = "block2", feature = "objc2-cloud-kit"))]
483        #[cfg(target_vendor = "apple")]
484        /// 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.
485        #[unsafe(method(registerCloudKitShareWithPreparationHandler:))]
486        #[unsafe(method_family = none)]
487        unsafe fn registerCloudKitShareWithPreparationHandler(
488            &self,
489            preparation_handler: &block2::Block<
490                dyn Fn(
491                    NonNull<block2::Block<dyn Fn(*mut CKShare, *mut CKContainer, *mut NSError)>>,
492                ),
493            >,
494        );
495
496        #[cfg(feature = "objc2-cloud-kit")]
497        #[cfg(target_vendor = "apple")]
498        /// 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.
499        #[unsafe(method(registerCloudKitShare:container:))]
500        #[unsafe(method_family = none)]
501        unsafe fn registerCloudKitShare_container(&self, share: &CKShare, container: &CKContainer);
502    );
503}
504
505impl private_NSItemProviderNSCloudKitSharing::Sealed for NSItemProvider {}
506unsafe impl NSItemProviderNSCloudKitSharing for NSItemProvider {}
507
508extern_class!(
509    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicepicker?language=objc)
510    #[unsafe(super(NSObject))]
511    #[derive(Debug, PartialEq, Eq, Hash)]
512    pub struct NSSharingServicePicker;
513);
514
515unsafe impl NSObjectProtocol for NSSharingServicePicker {}
516
517impl NSSharingServicePicker {
518    extern_methods!(
519        #[unsafe(method(delegate))]
520        #[unsafe(method_family = none)]
521        pub unsafe fn delegate(
522            &self,
523        ) -> Option<Retained<ProtocolObject<dyn NSSharingServicePickerDelegate>>>;
524
525        /// This is a [weak property][objc2::topics::weak_property].
526        /// Setter for [`delegate`][Self::delegate].
527        #[unsafe(method(setDelegate:))]
528        #[unsafe(method_family = none)]
529        pub unsafe fn setDelegate(
530            &self,
531            delegate: Option<&ProtocolObject<dyn NSSharingServicePickerDelegate>>,
532        );
533
534        /// Returns a new picker. The items represent the objects to be shared and must conform to the
535        /// <NSPasteboardWriting
536        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
537        #[unsafe(method(initWithItems:))]
538        #[unsafe(method_family = init)]
539        pub unsafe fn initWithItems(this: Allocated<Self>, items: &NSArray) -> Retained<Self>;
540
541        /// Use initWithItems: instead.
542        #[unsafe(method(init))]
543        #[unsafe(method_family = init)]
544        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
545
546        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
547        /// 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.
548        #[unsafe(method(showRelativeToRect:ofView:preferredEdge:))]
549        #[unsafe(method_family = none)]
550        pub unsafe fn showRelativeToRect_ofView_preferredEdge(
551            &self,
552            rect: NSRect,
553            view: &NSView,
554            preferred_edge: NSRectEdge,
555        );
556
557        /// Closes the picker UI. `-[NSSharingServicePickerDelegate sharingServicePicker:didChooseSharingService:]` will be invoked if `delegate` is set, with a `nil` service.
558        #[unsafe(method(close))]
559        #[unsafe(method_family = none)]
560        pub unsafe fn close(&self);
561
562        #[cfg(feature = "NSMenuItem")]
563        /// Returns a menu item suitable to display the picker for the given items.
564        #[unsafe(method(standardShareMenuItem))]
565        #[unsafe(method_family = none)]
566        pub unsafe fn standardShareMenuItem(&self, mtm: MainThreadMarker) -> Retained<NSMenuItem>;
567    );
568}
569
570/// Methods declared on superclass `NSObject`.
571impl NSSharingServicePicker {
572    extern_methods!(
573        #[unsafe(method(new))]
574        #[unsafe(method_family = new)]
575        pub unsafe fn new() -> Retained<Self>;
576    );
577}
578
579extern_protocol!(
580    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssharingservicepickerdelegate?language=objc)
581    pub unsafe trait NSSharingServicePickerDelegate: NSObjectProtocol {
582        /// 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:
583        ///
584        /// ```objc
585        /// NSMutableArray *sharingServices = [proposedServices mutableCopy];
586        /// NSSharingService * customService = [[NSSharingService alloc] initWithTitle:
587        /// "
588        /// Service Title"
589        /// image:image alternateImage:alternateImage
590        /// handler:^{ [self doCustomServiceWithItems:items]; } ];
591        /// [sharingServices addObject:customService];
592        /// return [sharingServices autorelease];
593        /// ```
594        /// The items represent the objects to be shared and must conform to the
595        /// <NSPasteboardWriting
596        /// > protocol or be an NSItemProvider or an NSDocument. (e.g. NSString, NSImage, NSURL, etc.)
597        #[optional]
598        #[unsafe(method(sharingServicePicker:sharingServicesForItems:proposedSharingServices:))]
599        #[unsafe(method_family = none)]
600        unsafe fn sharingServicePicker_sharingServicesForItems_proposedSharingServices(
601            &self,
602            sharing_service_picker: &NSSharingServicePicker,
603            items: &NSArray,
604            proposed_services: &NSArray<NSSharingService>,
605        ) -> Retained<NSArray<NSSharingService>>;
606
607        /// Sent when the user has selected a service and the picker is about to execute it.
608        #[optional]
609        #[unsafe(method(sharingServicePicker:delegateForSharingService:))]
610        #[unsafe(method_family = none)]
611        unsafe fn sharingServicePicker_delegateForSharingService(
612            &self,
613            sharing_service_picker: &NSSharingServicePicker,
614            sharing_service: &NSSharingService,
615            mtm: MainThreadMarker,
616        ) -> Option<Retained<ProtocolObject<dyn NSSharingServiceDelegate>>>;
617
618        /// Sent when the user has selected a service and before it is executed. Service will be nil if the picker was dismissed.
619        #[optional]
620        #[unsafe(method(sharingServicePicker:didChooseSharingService:))]
621        #[unsafe(method_family = none)]
622        unsafe fn sharingServicePicker_didChooseSharingService(
623            &self,
624            sharing_service_picker: &NSSharingServicePicker,
625            service: Option<&NSSharingService>,
626        );
627
628        #[cfg(feature = "NSSharingCollaborationModeRestriction")]
629        /// 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.
630        /// Disabling all possible modes at the same time is not supported behavior.
631        #[optional]
632        #[unsafe(method(sharingServicePickerCollaborationModeRestrictions:))]
633        #[unsafe(method_family = none)]
634        unsafe fn sharingServicePickerCollaborationModeRestrictions(
635            &self,
636            sharing_service_picker: &NSSharingServicePicker,
637        ) -> Option<Retained<NSArray<NSSharingCollaborationModeRestriction>>>;
638    }
639);