objc2_message_ui/generated/
MFMailComposeViewController.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-ui-kit")]
8use objc2_ui_kit::*;
9
10use crate::*;
11
12/// Composition result sent to the delegate upon user completion.
13///
14/// This result will inform of the user's choice in regards to email composition.  If the user
15/// cancels the composition,
16/// <tt>
17/// MFMailComposeResultCancelled
18/// </tt>
19/// will be sent to the delegate.
20/// Typically
21/// <tt>
22/// MFMailComposeResultSent
23/// </tt>
24/// or
25/// <tt>
26/// MFMailComposeResultSaved
27/// </tt>
28/// will
29/// be sent, but
30/// <tt>
31/// MFMailComposeResultFailed
32/// </tt>
33/// will be sent in the case of failure.
34/// </p>
35/// Send may only be interpreted as a successful queueing of the message for later sending.
36/// The actual send will occur when the device is able to send.
37///
38/// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmailcomposeresult?language=objc)
39// NS_ENUM
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct MFMailComposeResult(pub NSInteger);
43impl MFMailComposeResult {
44    #[doc(alias = "MFMailComposeResultCancelled")]
45    pub const Cancelled: Self = Self(0);
46    #[doc(alias = "MFMailComposeResultSaved")]
47    pub const Saved: Self = Self(1);
48    #[doc(alias = "MFMailComposeResultSent")]
49    pub const Sent: Self = Self(2);
50    #[doc(alias = "MFMailComposeResultFailed")]
51    pub const Failed: Self = Self(3);
52}
53
54unsafe impl Encode for MFMailComposeResult {
55    const ENCODING: Encoding = NSInteger::ENCODING;
56}
57
58unsafe impl RefEncode for MFMailComposeResult {
59    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
60}
61
62extern "C" {
63    /// Error domain for NSError values stemming from the MFMailCompose API.
64    ///
65    /// This error domain is used as the domain for all NSError instances stemmming from the
66    /// MFMailCompose API.  Valid error code values are declared in the
67    /// <tt>
68    /// MFMailComposeErrorCode
69    /// </tt>
70    /// space.
71    ///
72    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmailcomposeerrordomain?language=objc)
73    pub static MFMailComposeErrorDomain: &'static NSErrorDomain;
74}
75
76/// Error codes for NSError values stemming from the MFMailCompose API.
77///
78/// These error codes are used as the codes for all NSError instances stemmming from the
79/// MFMailCompose API.  These are the only valid values for NSError instances with the
80/// <tt>
81/// MFMailComposeErrorDomain
82/// </tt>
83/// domain.
84///
85/// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmailcomposeerrorcode?language=objc)
86// NS_ENUM
87#[repr(transparent)]
88#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
89pub struct MFMailComposeErrorCode(pub NSInteger);
90impl MFMailComposeErrorCode {
91    #[doc(alias = "MFMailComposeErrorCodeSaveFailed")]
92    pub const SaveFailed: Self = Self(0);
93    #[doc(alias = "MFMailComposeErrorCodeSendFailed")]
94    pub const SendFailed: Self = Self(1);
95}
96
97unsafe impl Encode for MFMailComposeErrorCode {
98    const ENCODING: Encoding = NSInteger::ENCODING;
99}
100
101unsafe impl RefEncode for MFMailComposeErrorCode {
102    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
103}
104
105extern_class!(
106    /// The MFMailComposeViewController class provides an interface for editing and sending email.
107    ///
108    /// The MFMailComposeViewController class manages all user interaction.  The client needs to set the recipient or
109    /// recipients.  The client may also set the subject and the body of the message.  Attachments may be added, if
110    /// so desired.  After setup, the client needs to only display the view.
111    /// <p>
112    /// The provided delegate will be informed
113    /// of the user's composition completion and how they chose to complete the operation.
114    /// </p>
115    /// Prior to use, clients
116    /// should verify the user has set up the device for sending email via
117    /// <tt>
118    /// +[MFMailComposeViewController canSendMail]
119    /// </tt>
120    /// .
121    ///
122    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontroller?language=objc)
123    #[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
124    #[derive(Debug, PartialEq, Eq, Hash)]
125    #[cfg(feature = "objc2-ui-kit")]
126    pub struct MFMailComposeViewController;
127);
128
129#[cfg(feature = "objc2-ui-kit")]
130extern_conformance!(
131    unsafe impl NSCoding for MFMailComposeViewController {}
132);
133
134#[cfg(feature = "objc2-ui-kit")]
135extern_conformance!(
136    unsafe impl NSObjectProtocol for MFMailComposeViewController {}
137);
138
139#[cfg(feature = "objc2-ui-kit")]
140extern_conformance!(
141    unsafe impl UIAppearanceContainer for MFMailComposeViewController {}
142);
143
144#[cfg(feature = "objc2-ui-kit")]
145extern_conformance!(
146    unsafe impl UIContentContainer for MFMailComposeViewController {}
147);
148
149#[cfg(feature = "objc2-ui-kit")]
150extern_conformance!(
151    unsafe impl UIFocusEnvironment for MFMailComposeViewController {}
152);
153
154#[cfg(feature = "objc2-ui-kit")]
155extern_conformance!(
156    unsafe impl UIResponderStandardEditActions for MFMailComposeViewController {}
157);
158
159#[cfg(feature = "objc2-ui-kit")]
160extern_conformance!(
161    unsafe impl UITraitEnvironment for MFMailComposeViewController {}
162);
163
164#[cfg(feature = "objc2-ui-kit")]
165impl MFMailComposeViewController {
166    extern_methods!(
167        /// Returns
168        /// <tt>
169        /// YES
170        /// </tt>
171        /// if the user has set up the device for sending email.
172        ///
173        /// The client may continue to set the recipients and content if the return value was
174        /// <tt>
175        /// YES
176        /// </tt>
177        /// .  If
178        /// <tt>
179        /// NO
180        /// </tt>
181        /// was the result, the client has a couple options.  It may choose to simply notify the user of the inability to
182        /// send mail, or it may issue a "mailto" URL via
183        /// <tt>
184        /// -[UIApplication openURL:]
185        /// </tt>
186        /// .
187        #[unsafe(method(canSendMail))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn canSendMail(mtm: MainThreadMarker) -> bool;
190
191        /// This property is the delegate for the MFMailComposeViewControllerDelegate method callbacks.
192        #[unsafe(method(mailComposeDelegate))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn mailComposeDelegate(
195            &self,
196        ) -> Option<Retained<ProtocolObject<dyn MFMailComposeViewControllerDelegate>>>;
197
198        /// Setter for [`mailComposeDelegate`][Self::mailComposeDelegate].
199        ///
200        /// This is a [weak property][objc2::topics::weak_property].
201        #[unsafe(method(setMailComposeDelegate:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn setMailComposeDelegate(
204            &self,
205            mail_compose_delegate: Option<&ProtocolObject<dyn MFMailComposeViewControllerDelegate>>,
206        );
207
208        /// This method sets the Subject header for the email message.
209        ///
210        /// This method will set the Subject header for the email message.  This should be called prior to display.
211        /// Newlines are removed from the parameter.
212        /// <p>
213        /// After the view has been presented to the user, this method will no longer change the value.
214        /// </p>
215        ///
216        /// Parameter `subject`: A NSString specifying the message's Subject header.
217        #[unsafe(method(setSubject:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn setSubject(&self, subject: &NSString);
220
221        /// This method sets the To header for the email message to the specified email addresses.
222        ///
223        /// This method will set the To header for the email message.  This should be called prior to display.
224        /// <p>
225        /// Recipient addresses should be specified as per RFC5322.
226        /// </p>
227        /// <p>
228        /// After the view has been presented to the user, this method will no longer change the value.
229        /// </p>
230        ///
231        /// Parameter `toRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
232        #[unsafe(method(setToRecipients:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setToRecipients(&self, to_recipients: Option<&NSArray<NSString>>);
235
236        /// This method sets the CC header for the email message to the specified email addresses.
237        ///
238        /// This method will set the CC header for the email message.  This should be called prior to display.
239        /// <p>
240        /// Recipient addresses should be specified as per RFC5322.
241        /// </p>
242        /// <p>
243        /// After the view has been presented to the user, this method will no longer change the value.
244        /// </p>
245        ///
246        /// Parameter `ccRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
247        #[unsafe(method(setCcRecipients:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setCcRecipients(&self, cc_recipients: Option<&NSArray<NSString>>);
250
251        /// This method sets the BCC header for the email message to the specified email addresses.
252        ///
253        /// This method will set the BCC header for the email message.  This should be called prior to display.
254        /// <p>
255        /// Recipient addresses should be specified as per RFC5322.
256        /// </p>
257        /// <p>
258        /// After the view has been presented to the user, this method will no longer change the value.
259        /// </p>
260        ///
261        /// Parameter `bccRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
262        #[unsafe(method(setBccRecipients:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn setBccRecipients(&self, bcc_recipients: Option<&NSArray<NSString>>);
265
266        /// This method sets the body of the email message to the specified content.
267        ///
268        /// This method will set the body of the email message.  This should be called prior to display.
269        /// The user's signature, if specified, will be added after the body content.
270        ///
271        /// Parameter `body`: A NSString containing the body contents of the email message.
272        ///
273        /// Parameter `isHTML`: A boolean value indicating if the body argument is to be interpreted as HTML content.
274        #[unsafe(method(setMessageBody:isHTML:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setMessageBody_isHTML(&self, body: &NSString, is_html: bool);
277
278        /// This method adds the specified attachment to the email message.
279        ///
280        /// This method adds the specified attachment to the email message.  This should be called prior to display.
281        /// Attachments will be appended to the end of the message.
282        ///
283        /// Parameter `attachment`: NSData containing the contents of the attachment.  Must not be
284        /// <tt>
285        /// nil
286        /// </tt>
287        /// .
288        ///
289        /// Parameter `mimeType`: NSString specifying the MIME type for the attachment, as specified by the IANA
290        /// (http://www.iana.org/assignments/media-types/). Must not be
291        /// <tt>
292        /// nil
293        /// </tt>
294        /// .
295        ///
296        /// Parameter `filename`: NSString specifying the intended filename for the attachment.  This is displayed below
297        /// the attachment's icon if the attachment is not decoded when displayed.  Must not be
298        /// <tt>
299        /// nil
300        /// </tt>
301        /// .
302        #[unsafe(method(addAttachmentData:mimeType:fileName:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn addAttachmentData_mimeType_fileName(
305            &self,
306            attachment: &NSData,
307            mime_type: &NSString,
308            filename: &NSString,
309        );
310
311        /// This method sets the preferred sending account of the email message.
312        ///
313        /// This method will set the sending account of the message to the specified email address if the user has an account with such an address set up. If there is no account with such an address, the default account will be used instead.
314        /// The sending email address should be specified as per RFC5322.
315        /// After the view has been presented to the user, this method will no longer change the value.
316        ///
317        /// Parameter `emailAddress`: A NSString specifying the preferred email address used to send this message.
318        #[unsafe(method(setPreferredSendingEmailAddress:))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn setPreferredSendingEmailAddress(&self, email_address: &NSString);
321
322        #[cfg(feature = "block2")]
323        /// Parameter `itemProvider`: specifying the intended content for collaboration
324        ///
325        /// Returns
326        /// <tt>
327        /// YES
328        /// </tt>
329        /// if the item provider was added to the composition successfully.
330        ///
331        /// If the return value is YES, the itemProvider was added to the composition.  The itemProvider must be non-nil.
332        #[unsafe(method(insertCollaborationItemProvider:completionHandler:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn insertCollaborationItemProvider_completionHandler(
335            &self,
336            item_provider: &NSItemProvider,
337            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
338        );
339    );
340}
341
342/// Methods declared on superclass `UINavigationController`.
343#[cfg(feature = "objc2-ui-kit")]
344impl MFMailComposeViewController {
345    extern_methods!(
346        /// # Safety
347        ///
348        /// - `navigation_bar_class` probably has further requirements.
349        /// - `toolbar_class` probably has further requirements.
350        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
351        #[unsafe(method_family = init)]
352        pub unsafe fn initWithNavigationBarClass_toolbarClass(
353            this: Allocated<Self>,
354            navigation_bar_class: Option<&AnyClass>,
355            toolbar_class: Option<&AnyClass>,
356        ) -> Retained<Self>;
357
358        #[unsafe(method(initWithRootViewController:))]
359        #[unsafe(method_family = init)]
360        pub unsafe fn initWithRootViewController(
361            this: Allocated<Self>,
362            root_view_controller: &UIViewController,
363        ) -> Retained<Self>;
364
365        #[unsafe(method(initWithNibName:bundle:))]
366        #[unsafe(method_family = init)]
367        pub unsafe fn initWithNibName_bundle(
368            this: Allocated<Self>,
369            nib_name_or_nil: Option<&NSString>,
370            nib_bundle_or_nil: Option<&NSBundle>,
371        ) -> Retained<Self>;
372
373        /// # Safety
374        ///
375        /// `a_decoder` possibly has further requirements.
376        #[unsafe(method(initWithCoder:))]
377        #[unsafe(method_family = init)]
378        pub unsafe fn initWithCoder(
379            this: Allocated<Self>,
380            a_decoder: &NSCoder,
381        ) -> Option<Retained<Self>>;
382    );
383}
384
385/// Methods declared on superclass `NSObject`.
386#[cfg(feature = "objc2-ui-kit")]
387impl MFMailComposeViewController {
388    extern_methods!(
389        #[unsafe(method(init))]
390        #[unsafe(method_family = init)]
391        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
392
393        #[unsafe(method(new))]
394        #[unsafe(method_family = new)]
395        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
396    );
397}
398
399extern_protocol!(
400    /// Protocol for delegate callbacks to MFMailComposeViewController instances.
401    ///
402    /// This protocol must be implemented for delegates of MFMailComposeViewController instances.  It will
403    /// be called at various times while the user is composing, sending, saving, or canceling email composition.
404    ///
405    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontrollerdelegate?language=objc)
406    pub unsafe trait MFMailComposeViewControllerDelegate: NSObjectProtocol {
407        #[cfg(feature = "objc2-ui-kit")]
408        /// Delegate callback which is called upon user's completion of email composition.
409        ///
410        /// This delegate callback will be called when the user completes the email composition.  How the user chose
411        /// to complete this task will be given as one of the parameters to the callback.  Upon this call, the client
412        /// should remove the view associated with the controller, typically by dismissing modally.
413        ///
414        /// Parameter `controller`: The MFMailComposeViewController instance which is returning the result.
415        ///
416        /// Parameter `result`: MFMailComposeResult indicating how the user chose to complete the composition process.
417        ///
418        /// Parameter `error`: NSError indicating the failure reason if failure did occur.  This will be
419        /// <tt>
420        /// nil
421        /// </tt>
422        /// if
423        /// result did not indicate failure.
424        #[optional]
425        #[unsafe(method(mailComposeController:didFinishWithResult:error:))]
426        #[unsafe(method_family = none)]
427        unsafe fn mailComposeController_didFinishWithResult_error(
428            &self,
429            controller: &MFMailComposeViewController,
430            result: MFMailComposeResult,
431            error: Option<&NSError>,
432        );
433    }
434);