objc2_message_ui/generated/
MFMessageComposeViewController.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#[cfg(feature = "objc2-messages")]
8#[cfg(not(target_os = "visionos"))]
9use objc2_messages::*;
10#[cfg(feature = "objc2-ui-kit")]
11use objc2_ui_kit::*;
12
13use crate::*;
14
15/// Composition result sent to the delegate upon user completion.
16///
17/// This result will inform the client of the user's message composition action.  If the
18/// user cancels the composition,
19/// <tt>
20/// MessageComposeResultCancelled
21/// </tt>
22/// will be sent to the delegate.
23/// Typically
24/// <tt>
25/// MessageComposeResultSent
26/// </tt>
27/// will be sent, but
28/// <tt>
29/// MessageComposeResultFailed
30/// </tt>
31/// will
32/// be sent in the case of failure.
33/// </p>
34/// Send may only be interpreted as a successful queueing of
35/// the message for later sending. The actual send will occur when the device is able to send.
36///
37/// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/messagecomposeresult?language=objc)
38// NS_ENUM
39#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct MessageComposeResult(pub NSInteger);
42impl MessageComposeResult {
43    #[doc(alias = "MessageComposeResultCancelled")]
44    pub const Cancelled: Self = Self(0);
45    #[doc(alias = "MessageComposeResultSent")]
46    pub const Sent: Self = Self(1);
47    #[doc(alias = "MessageComposeResultFailed")]
48    pub const Failed: Self = Self(2);
49}
50
51unsafe impl Encode for MessageComposeResult {
52    const ENCODING: Encoding = NSInteger::ENCODING;
53}
54
55unsafe impl RefEncode for MessageComposeResult {
56    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59extern "C" {
60    /// [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerattachmenturl?language=objc)
61    pub static MFMessageComposeViewControllerAttachmentURL: &'static NSString;
62}
63
64extern "C" {
65    /// [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerattachmentalternatefilename?language=objc)
66    pub static MFMessageComposeViewControllerAttachmentAlternateFilename: &'static NSString;
67}
68
69extern "C" {
70    /// Notification posted when the value of
71    /// <tt>
72    /// +[MFMessageComposeViewController canSendText]
73    /// </tt>
74    /// has changed.
75    ///
76    /// This notification is posted when the value of
77    /// <tt>
78    /// +[MFMessageComposeViewController canSendText]
79    /// </tt>
80    /// has changed. Clients should invalidate any caches and update UI as appropriate.
81    ///
82    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollertextmessageavailabilitydidchangenotification?language=objc)
83    pub static MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification:
84        &'static NSString;
85}
86
87extern "C" {
88    /// UserInfo key for MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification
89    /// containing the value of
90    /// <tt>
91    /// +[MFMessageComposeViewController canSendText]
92    /// </tt>
93    ///
94    /// The value of this key is an NSNumber containing a BOOL value. This value matches
95    /// the result of
96    /// <tt>
97    /// +[MFMessageComposeViewController canSendText]
98    /// </tt>
99    /// .
100    ///
101    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollertextmessageavailabilitykey?language=objc)
102    pub static MFMessageComposeViewControllerTextMessageAvailabilityKey: &'static NSString;
103}
104
105extern_class!(
106    /// The MFMessageComposeViewController class provides an interface for editing and sending a message.
107    ///
108    /// The MFMessageComposeViewController class manages all user interaction.  The client needs to set
109    /// the recipient or recipients.  The client may also set the body of the message. After setup, the
110    /// client needs to only display the view.
111    /// <p>
112    /// The provided delegate will be informed of the user's composition completion and how they chose
113    /// to complete the operation.
114    /// </p>
115    /// <p>
116    /// Prior to use, clients should verify the user has set up the device for sending messages via
117    /// <tt>
118    /// +[MFMessageComposeViewController canSendText]
119    /// </tt>
120    /// .
121    /// </p>
122    ///
123    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontroller?language=objc)
124    #[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
125    #[derive(Debug, PartialEq, Eq, Hash)]
126    #[cfg(feature = "objc2-ui-kit")]
127    pub struct MFMessageComposeViewController;
128);
129
130#[cfg(feature = "objc2-ui-kit")]
131unsafe impl NSCoding for MFMessageComposeViewController {}
132
133#[cfg(feature = "objc2-ui-kit")]
134unsafe impl NSObjectProtocol for MFMessageComposeViewController {}
135
136#[cfg(feature = "objc2-ui-kit")]
137unsafe impl UIAppearanceContainer for MFMessageComposeViewController {}
138
139#[cfg(feature = "objc2-ui-kit")]
140unsafe impl UIContentContainer for MFMessageComposeViewController {}
141
142#[cfg(feature = "objc2-ui-kit")]
143unsafe impl UIFocusEnvironment for MFMessageComposeViewController {}
144
145#[cfg(feature = "objc2-ui-kit")]
146unsafe impl UIResponderStandardEditActions for MFMessageComposeViewController {}
147
148#[cfg(feature = "objc2-ui-kit")]
149unsafe impl UITraitEnvironment for MFMessageComposeViewController {}
150
151#[cfg(feature = "objc2-ui-kit")]
152impl MFMessageComposeViewController {
153    extern_methods!(
154        /// Returns
155        /// <tt>
156        /// YES
157        /// </tt>
158        /// if the user has set up the device for sending text only messages.
159        ///
160        /// If the return value is YES, the client can set the recipients and body of the message.
161        /// If the return value is NO, the client may notify the user of the failure, or the
162        /// client may open an SMS URL via
163        /// <tt>
164        /// -[UIApplication openURL:]
165        /// </tt>
166        /// .
167        #[unsafe(method(canSendText))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn canSendText(mtm: MainThreadMarker) -> bool;
170
171        /// Returns
172        /// <tt>
173        /// YES
174        /// </tt>
175        /// <tt>
176        /// if the user has set up the device for including subjects in messages.
177        /// </tt>
178        /// .
179        #[unsafe(method(canSendSubject))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn canSendSubject(mtm: MainThreadMarker) -> bool;
182
183        /// Returns
184        /// <tt>
185        /// YES
186        /// </tt>
187        /// <tt>
188        /// if the user has set up the device for including attachments in messages.
189        /// </tt>
190        /// .
191        #[unsafe(method(canSendAttachments))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn canSendAttachments(mtm: MainThreadMarker) -> bool;
194
195        /// Returns
196        /// <tt>
197        /// YES
198        /// </tt>
199        /// if the attachment at the specified URL could be accepted by the current composition.
200        ///
201        /// If the return value is YES, the UTI is acceptable for attachment to a message, a return value of NO
202        /// indicates that the given UTI is unsupported.
203        #[unsafe(method(isSupportedAttachmentUTI:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn isSupportedAttachmentUTI(uti: &NSString, mtm: MainThreadMarker) -> bool;
206
207        /// This property is the delegate for the MFMessageComposeViewController method callbacks.
208        #[unsafe(method(messageComposeDelegate))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn messageComposeDelegate(
211            &self,
212        ) -> Option<Retained<ProtocolObject<dyn MFMessageComposeViewControllerDelegate>>>;
213
214        /// This is a [weak property][objc2::topics::weak_property].
215        /// Setter for [`messageComposeDelegate`][Self::messageComposeDelegate].
216        #[unsafe(method(setMessageComposeDelegate:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setMessageComposeDelegate(
219            &self,
220            message_compose_delegate: Option<
221                &ProtocolObject<dyn MFMessageComposeViewControllerDelegate>,
222            >,
223        );
224
225        /// Calling this method will disable the camera/attachment button in the view controller.  After the controller has been presented,
226        /// this call will have no effect.  The camera / attachment button is visible by default.
227        #[unsafe(method(disableUserAttachments))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn disableUserAttachments(&self);
230
231        /// This property sets the initial value of the To field for the message to the specified addresses.
232        ///
233        /// This property will set the initial value of the To field for the message from an NSArray of
234        /// NSString instances specifying the message addresses of recipients. This should be called prior
235        /// to display.
236        /// <p>
237        /// After the view has been presented to the user, this property will no longer change the value.
238        /// </p>
239        #[unsafe(method(recipients))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn recipients(&self) -> Option<Retained<NSArray<NSString>>>;
242
243        /// Setter for [`recipients`][Self::recipients].
244        #[unsafe(method(setRecipients:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<NSString>>);
247
248        /// This property sets the initial value of the body of the message to the specified content.
249        ///
250        /// This property will set the initial value of the body of the message.  This should be called prior
251        /// to display.
252        /// <p>
253        /// After the view has been presented to the user, this property will no longer change the value.
254        /// </p>
255        #[unsafe(method(body))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn body(&self) -> Option<Retained<NSString>>;
258
259        /// Setter for [`body`][Self::body].
260        #[unsafe(method(setBody:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn setBody(&self, body: Option<&NSString>);
263
264        /// This property sets the initial value of the subject of the message to the specified content.
265        ///
266        /// This property will set the initial value of the subject of the message.  This should be called prior
267        /// to display.
268        /// <p>
269        /// After the view has been presented to the user, this property will no longer change the value.
270        /// </p>
271        #[unsafe(method(subject))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn subject(&self) -> Option<Retained<NSString>>;
274
275        /// Setter for [`subject`][Self::subject].
276        #[unsafe(method(setSubject:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn setSubject(&self, subject: Option<&NSString>);
279
280        /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
281        ///
282        /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
283        /// See MFMessageComposeViewControllerAttachmentURL, MFMessageComposeViewControllerAttachmentAlternateFilename.
284        #[unsafe(method(attachments))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn attachments(&self) -> Option<Retained<NSArray<NSDictionary>>>;
287
288        #[cfg(feature = "objc2-messages")]
289        #[cfg(not(target_os = "visionos"))]
290        /// This property sets the initial interactive message.
291        #[unsafe(method(message))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn message(&self) -> Option<Retained<MSMessage>>;
294
295        #[cfg(feature = "objc2-messages")]
296        #[cfg(not(target_os = "visionos"))]
297        /// Setter for [`message`][Self::message].
298        #[unsafe(method(setMessage:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn setMessage(&self, message: Option<&MSMessage>);
301
302        /// Returns
303        /// <tt>
304        /// YES
305        /// </tt>
306        /// if the attachment at the specified URL was added to the composition successfully.
307        ///
308        /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
309        /// the attachment was not added to the composition.  All attachment URLs must be file urls.  The file
310        /// URL must not be NIL.  The alternate filename will be display to the user in leiu of the attachments URL.
311        /// The alternate filename may be NIL.
312        #[unsafe(method(addAttachmentURL:withAlternateFilename:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn addAttachmentURL_withAlternateFilename(
315            &self,
316            attachment_url: &NSURL,
317            alternate_filename: Option<&NSString>,
318        ) -> bool;
319
320        /// Returns
321        /// <tt>
322        /// YES
323        /// </tt>
324        /// if the attachment was added to the composition successfully.
325        ///
326        /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
327        /// the attachment was not added to the composition.  The data and typeIdentifer must be non-nil.  typeIdentifier should be a valid Uniform Type Identifier.
328        #[unsafe(method(addAttachmentData:typeIdentifier:filename:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn addAttachmentData_typeIdentifier_filename(
331            &self,
332            attachment_data: &NSData,
333            uti: &NSString,
334            filename: &NSString,
335        ) -> bool;
336
337        /// Parameter `itemProvider`: created from ShareSheet
338        ///
339        /// Returns
340        /// <tt>
341        /// YES
342        /// </tt>
343        /// if the item provider was added to the composition successfully.
344        ///
345        /// If the return value is YES, the itemProvider was added to the composition. If the return value is NO,
346        /// the itemProvider was not added to the composition.  The itemProvider must be non-nil.
347        #[unsafe(method(insertCollaborationItemProvider:))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn insertCollaborationItemProvider(
350            &self,
351            item_provider: &NSItemProvider,
352        ) -> bool;
353    );
354}
355
356/// Methods declared on superclass `UINavigationController`.
357#[cfg(feature = "objc2-ui-kit")]
358impl MFMessageComposeViewController {
359    extern_methods!(
360        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
361        #[unsafe(method_family = init)]
362        pub unsafe fn initWithNavigationBarClass_toolbarClass(
363            this: Allocated<Self>,
364            navigation_bar_class: Option<&AnyClass>,
365            toolbar_class: Option<&AnyClass>,
366        ) -> Retained<Self>;
367
368        #[unsafe(method(initWithRootViewController:))]
369        #[unsafe(method_family = init)]
370        pub unsafe fn initWithRootViewController(
371            this: Allocated<Self>,
372            root_view_controller: &UIViewController,
373        ) -> Retained<Self>;
374
375        #[unsafe(method(initWithNibName:bundle:))]
376        #[unsafe(method_family = init)]
377        pub unsafe fn initWithNibName_bundle(
378            this: Allocated<Self>,
379            nib_name_or_nil: Option<&NSString>,
380            nib_bundle_or_nil: Option<&NSBundle>,
381        ) -> Retained<Self>;
382
383        #[unsafe(method(initWithCoder:))]
384        #[unsafe(method_family = init)]
385        pub unsafe fn initWithCoder(
386            this: Allocated<Self>,
387            a_decoder: &NSCoder,
388        ) -> Option<Retained<Self>>;
389    );
390}
391
392/// Methods declared on superclass `NSObject`.
393#[cfg(feature = "objc2-ui-kit")]
394impl MFMessageComposeViewController {
395    extern_methods!(
396        #[unsafe(method(init))]
397        #[unsafe(method_family = init)]
398        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
399
400        #[unsafe(method(new))]
401        #[unsafe(method_family = new)]
402        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
403    );
404}
405
406extern_protocol!(
407    /// Protocol for delegate callbacks to MFMessageComposeViewControllerDelegate instances.
408    ///
409    /// This protocol will be implemented by delegates of MFMessageComposeViewController instances.
410    /// It will be called at various times while the user is composing, sending, or canceling
411    /// message composition.
412    ///
413    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerdelegate?language=objc)
414    pub unsafe trait MFMessageComposeViewControllerDelegate: NSObjectProtocol {
415        #[cfg(feature = "objc2-ui-kit")]
416        /// Delegate callback which is called upon user's completion of message composition.
417        ///
418        /// This delegate callback will be called when the user completes the message composition.
419        /// How the user chose to complete this task will be given as one of the parameters to the
420        /// callback.  Upon this call, the client should remove the view associated with the controller,
421        /// typically by dismissing modally.
422        ///
423        /// Parameter `controller`: The MFMessageComposeViewController instance which is returning the result.
424        ///
425        /// Parameter `result`: MessageComposeResult indicating how the user chose to complete the composition process.
426        #[unsafe(method(messageComposeViewController:didFinishWithResult:))]
427        #[unsafe(method_family = none)]
428        unsafe fn messageComposeViewController_didFinishWithResult(
429            &self,
430            controller: &MFMessageComposeViewController,
431            result: MessageComposeResult,
432        );
433    }
434);