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")]
130unsafe impl NSCoding for MFMailComposeViewController {}
131
132#[cfg(feature = "objc2-ui-kit")]
133unsafe impl NSObjectProtocol for MFMailComposeViewController {}
134
135#[cfg(feature = "objc2-ui-kit")]
136unsafe impl UIAppearanceContainer for MFMailComposeViewController {}
137
138#[cfg(feature = "objc2-ui-kit")]
139unsafe impl UIContentContainer for MFMailComposeViewController {}
140
141#[cfg(feature = "objc2-ui-kit")]
142unsafe impl UIFocusEnvironment for MFMailComposeViewController {}
143
144#[cfg(feature = "objc2-ui-kit")]
145unsafe impl UIResponderStandardEditActions for MFMailComposeViewController {}
146
147#[cfg(feature = "objc2-ui-kit")]
148unsafe impl UITraitEnvironment for MFMailComposeViewController {}
149
150#[cfg(feature = "objc2-ui-kit")]
151impl MFMailComposeViewController {
152    extern_methods!(
153        /// Returns
154        /// <tt>
155        /// YES
156        /// </tt>
157        /// if the user has set up the device for sending email.
158        ///
159        /// The client may continue to set the recipients and content if the return value was
160        /// <tt>
161        /// YES
162        /// </tt>
163        /// .  If
164        /// <tt>
165        /// NO
166        /// </tt>
167        /// was the result, the client has a couple options.  It may choose to simply notify the user of the inability to
168        /// send mail, or it may issue a "mailto" URL via
169        /// <tt>
170        /// -[UIApplication openURL:]
171        /// </tt>
172        /// .
173        #[unsafe(method(canSendMail))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn canSendMail(mtm: MainThreadMarker) -> bool;
176
177        /// This property is the delegate for the MFMailComposeViewControllerDelegate method callbacks.
178        #[unsafe(method(mailComposeDelegate))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn mailComposeDelegate(
181            &self,
182        ) -> Option<Retained<ProtocolObject<dyn MFMailComposeViewControllerDelegate>>>;
183
184        /// This is a [weak property][objc2::topics::weak_property].
185        /// Setter for [`mailComposeDelegate`][Self::mailComposeDelegate].
186        #[unsafe(method(setMailComposeDelegate:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn setMailComposeDelegate(
189            &self,
190            mail_compose_delegate: Option<&ProtocolObject<dyn MFMailComposeViewControllerDelegate>>,
191        );
192
193        /// This method sets the Subject header for the email message.
194        ///
195        /// This method will set the Subject header for the email message.  This should be called prior to display.
196        /// Newlines are removed from the parameter.
197        /// <p>
198        /// After the view has been presented to the user, this method will no longer change the value.
199        /// </p>
200        ///
201        /// Parameter `subject`: A NSString specifying the message's Subject header.
202        #[unsafe(method(setSubject:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setSubject(&self, subject: &NSString);
205
206        /// This method sets the To header for the email message to the specified email addresses.
207        ///
208        /// This method will set the To header for the email message.  This should be called prior to display.
209        /// <p>
210        /// Recipient addresses should be specified as per RFC5322.
211        /// </p>
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 `toRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
217        #[unsafe(method(setToRecipients:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn setToRecipients(&self, to_recipients: Option<&NSArray<NSString>>);
220
221        /// This method sets the CC header for the email message to the specified email addresses.
222        ///
223        /// This method will set the CC 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 `ccRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
232        #[unsafe(method(setCcRecipients:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setCcRecipients(&self, cc_recipients: Option<&NSArray<NSString>>);
235
236        /// This method sets the BCC header for the email message to the specified email addresses.
237        ///
238        /// This method will set the BCC 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 `bccRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
247        #[unsafe(method(setBccRecipients:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setBccRecipients(&self, bcc_recipients: Option<&NSArray<NSString>>);
250
251        /// This method sets the body of the email message to the specified content.
252        ///
253        /// This method will set the body of the email message.  This should be called prior to display.
254        /// The user's signature, if specified, will be added after the body content.
255        ///
256        /// Parameter `body`: A NSString containing the body contents of the email message.
257        ///
258        /// Parameter `isHTML`: A boolean value indicating if the body argument is to be interpreted as HTML content.
259        #[unsafe(method(setMessageBody:isHTML:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn setMessageBody_isHTML(&self, body: &NSString, is_html: bool);
262
263        /// This method adds the specified attachment to the email message.
264        ///
265        /// This method adds the specified attachment to the email message.  This should be called prior to display.
266        /// Attachments will be appended to the end of the message.
267        ///
268        /// Parameter `attachment`: NSData containing the contents of the attachment.  Must not be
269        /// <tt>
270        /// nil
271        /// </tt>
272        /// .
273        ///
274        /// Parameter `mimeType`: NSString specifying the MIME type for the attachment, as specified by the IANA
275        /// (http://www.iana.org/assignments/media-types/). Must not be
276        /// <tt>
277        /// nil
278        /// </tt>
279        /// .
280        ///
281        /// Parameter `filename`: NSString specifying the intended filename for the attachment.  This is displayed below
282        /// the attachment's icon if the attachment is not decoded when displayed.  Must not be
283        /// <tt>
284        /// nil
285        /// </tt>
286        /// .
287        #[unsafe(method(addAttachmentData:mimeType:fileName:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn addAttachmentData_mimeType_fileName(
290            &self,
291            attachment: &NSData,
292            mime_type: &NSString,
293            filename: &NSString,
294        );
295
296        /// This method sets the preferred sending account of the email message.
297        ///
298        /// 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.
299        /// The sending email address should be specified as per RFC5322.
300        /// After the view has been presented to the user, this method will no longer change the value.
301        ///
302        /// Parameter `emailAddress`: A NSString specifying the preferred email address used to send this message.
303        #[unsafe(method(setPreferredSendingEmailAddress:))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn setPreferredSendingEmailAddress(&self, email_address: &NSString);
306    );
307}
308
309/// Methods declared on superclass `UINavigationController`.
310#[cfg(feature = "objc2-ui-kit")]
311impl MFMailComposeViewController {
312    extern_methods!(
313        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
314        #[unsafe(method_family = init)]
315        pub unsafe fn initWithNavigationBarClass_toolbarClass(
316            this: Allocated<Self>,
317            navigation_bar_class: Option<&AnyClass>,
318            toolbar_class: Option<&AnyClass>,
319        ) -> Retained<Self>;
320
321        #[unsafe(method(initWithRootViewController:))]
322        #[unsafe(method_family = init)]
323        pub unsafe fn initWithRootViewController(
324            this: Allocated<Self>,
325            root_view_controller: &UIViewController,
326        ) -> Retained<Self>;
327
328        #[unsafe(method(initWithNibName:bundle:))]
329        #[unsafe(method_family = init)]
330        pub unsafe fn initWithNibName_bundle(
331            this: Allocated<Self>,
332            nib_name_or_nil: Option<&NSString>,
333            nib_bundle_or_nil: Option<&NSBundle>,
334        ) -> Retained<Self>;
335
336        #[unsafe(method(initWithCoder:))]
337        #[unsafe(method_family = init)]
338        pub unsafe fn initWithCoder(
339            this: Allocated<Self>,
340            a_decoder: &NSCoder,
341        ) -> Option<Retained<Self>>;
342    );
343}
344
345/// Methods declared on superclass `NSObject`.
346#[cfg(feature = "objc2-ui-kit")]
347impl MFMailComposeViewController {
348    extern_methods!(
349        #[unsafe(method(init))]
350        #[unsafe(method_family = init)]
351        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
352
353        #[unsafe(method(new))]
354        #[unsafe(method_family = new)]
355        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
356    );
357}
358
359extern_protocol!(
360    /// Protocol for delegate callbacks to MFMailComposeViewController instances.
361    ///
362    /// This protocol must be implemented for delegates of MFMailComposeViewController instances.  It will
363    /// be called at various times while the user is composing, sending, saving, or canceling email composition.
364    ///
365    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontrollerdelegate?language=objc)
366    pub unsafe trait MFMailComposeViewControllerDelegate: NSObjectProtocol {
367        #[cfg(feature = "objc2-ui-kit")]
368        /// Delegate callback which is called upon user's completion of email composition.
369        ///
370        /// This delegate callback will be called when the user completes the email composition.  How the user chose
371        /// to complete this task will be given as one of the parameters to the callback.  Upon this call, the client
372        /// should remove the view associated with the controller, typically by dismissing modally.
373        ///
374        /// Parameter `controller`: The MFMailComposeViewController instance which is returning the result.
375        ///
376        /// Parameter `result`: MFMailComposeResult indicating how the user chose to complete the composition process.
377        ///
378        /// Parameter `error`: NSError indicating the failure reason if failure did occur.  This will be
379        /// <tt>
380        /// nil
381        /// </tt>
382        /// if
383        /// result did not indicate failure.
384        #[optional]
385        #[unsafe(method(mailComposeController:didFinishWithResult:error:))]
386        #[unsafe(method_family = none)]
387        unsafe fn mailComposeController_didFinishWithResult_error(
388            &self,
389            controller: &MFMailComposeViewController,
390            result: MFMailComposeResult,
391            error: Option<&NSError>,
392        );
393    }
394);