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 /// This is a [weak property][objc2::topics::weak_property].
199 /// Setter for [`mailComposeDelegate`][Self::mailComposeDelegate].
200 #[unsafe(method(setMailComposeDelegate:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn setMailComposeDelegate(
203 &self,
204 mail_compose_delegate: Option<&ProtocolObject<dyn MFMailComposeViewControllerDelegate>>,
205 );
206
207 /// This method sets the Subject header for the email message.
208 ///
209 /// This method will set the Subject header for the email message. This should be called prior to display.
210 /// Newlines are removed from the parameter.
211 /// <p>
212 /// After the view has been presented to the user, this method will no longer change the value.
213 /// </p>
214 ///
215 /// Parameter `subject`: A NSString specifying the message's Subject header.
216 #[unsafe(method(setSubject:))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn setSubject(&self, subject: &NSString);
219
220 /// This method sets the To header for the email message to the specified email addresses.
221 ///
222 /// This method will set the To header for the email message. This should be called prior to display.
223 /// <p>
224 /// Recipient addresses should be specified as per RFC5322.
225 /// </p>
226 /// <p>
227 /// After the view has been presented to the user, this method will no longer change the value.
228 /// </p>
229 ///
230 /// Parameter `toRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
231 #[unsafe(method(setToRecipients:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setToRecipients(&self, to_recipients: Option<&NSArray<NSString>>);
234
235 /// This method sets the CC header for the email message to the specified email addresses.
236 ///
237 /// This method will set the CC header for the email message. This should be called prior to display.
238 /// <p>
239 /// Recipient addresses should be specified as per RFC5322.
240 /// </p>
241 /// <p>
242 /// After the view has been presented to the user, this method will no longer change the value.
243 /// </p>
244 ///
245 /// Parameter `ccRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
246 #[unsafe(method(setCcRecipients:))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn setCcRecipients(&self, cc_recipients: Option<&NSArray<NSString>>);
249
250 /// This method sets the BCC header for the email message to the specified email addresses.
251 ///
252 /// This method will set the BCC header for the email message. This should be called prior to display.
253 /// <p>
254 /// Recipient addresses should be specified as per RFC5322.
255 /// </p>
256 /// <p>
257 /// After the view has been presented to the user, this method will no longer change the value.
258 /// </p>
259 ///
260 /// Parameter `bccRecipients`: A NSArray of NSString instances specifying the email addresses of recipients.
261 #[unsafe(method(setBccRecipients:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn setBccRecipients(&self, bcc_recipients: Option<&NSArray<NSString>>);
264
265 /// This method sets the body of the email message to the specified content.
266 ///
267 /// This method will set the body of the email message. This should be called prior to display.
268 /// The user's signature, if specified, will be added after the body content.
269 ///
270 /// Parameter `body`: A NSString containing the body contents of the email message.
271 ///
272 /// Parameter `isHTML`: A boolean value indicating if the body argument is to be interpreted as HTML content.
273 #[unsafe(method(setMessageBody:isHTML:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn setMessageBody_isHTML(&self, body: &NSString, is_html: bool);
276
277 /// This method adds the specified attachment to the email message.
278 ///
279 /// This method adds the specified attachment to the email message. This should be called prior to display.
280 /// Attachments will be appended to the end of the message.
281 ///
282 /// Parameter `attachment`: NSData containing the contents of the attachment. Must not be
283 /// <tt>
284 /// nil
285 /// </tt>
286 /// .
287 ///
288 /// Parameter `mimeType`: NSString specifying the MIME type for the attachment, as specified by the IANA
289 /// (http://www.iana.org/assignments/media-types/). Must not be
290 /// <tt>
291 /// nil
292 /// </tt>
293 /// .
294 ///
295 /// Parameter `filename`: NSString specifying the intended filename for the attachment. This is displayed below
296 /// the attachment's icon if the attachment is not decoded when displayed. Must not be
297 /// <tt>
298 /// nil
299 /// </tt>
300 /// .
301 #[unsafe(method(addAttachmentData:mimeType:fileName:))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn addAttachmentData_mimeType_fileName(
304 &self,
305 attachment: &NSData,
306 mime_type: &NSString,
307 filename: &NSString,
308 );
309
310 /// This method sets the preferred sending account of the email message.
311 ///
312 /// 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.
313 /// The sending email address should be specified as per RFC5322.
314 /// After the view has been presented to the user, this method will no longer change the value.
315 ///
316 /// Parameter `emailAddress`: A NSString specifying the preferred email address used to send this message.
317 #[unsafe(method(setPreferredSendingEmailAddress:))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn setPreferredSendingEmailAddress(&self, email_address: &NSString);
320
321 #[cfg(feature = "block2")]
322 /// Parameter `itemProvider`: specifying the intended content for collaboration
323 ///
324 /// Returns
325 /// <tt>
326 /// YES
327 /// </tt>
328 /// if the item provider was added to the composition successfully.
329 ///
330 /// If the return value is YES, the itemProvider was added to the composition. The itemProvider must be non-nil.
331 #[unsafe(method(insertCollaborationItemProvider:completionHandler:))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn insertCollaborationItemProvider_completionHandler(
334 &self,
335 item_provider: &NSItemProvider,
336 completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
337 );
338 );
339}
340
341/// Methods declared on superclass `UINavigationController`.
342#[cfg(feature = "objc2-ui-kit")]
343impl MFMailComposeViewController {
344 extern_methods!(
345 #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
346 #[unsafe(method_family = init)]
347 pub unsafe fn initWithNavigationBarClass_toolbarClass(
348 this: Allocated<Self>,
349 navigation_bar_class: Option<&AnyClass>,
350 toolbar_class: Option<&AnyClass>,
351 ) -> Retained<Self>;
352
353 #[unsafe(method(initWithRootViewController:))]
354 #[unsafe(method_family = init)]
355 pub unsafe fn initWithRootViewController(
356 this: Allocated<Self>,
357 root_view_controller: &UIViewController,
358 ) -> Retained<Self>;
359
360 #[unsafe(method(initWithNibName:bundle:))]
361 #[unsafe(method_family = init)]
362 pub unsafe fn initWithNibName_bundle(
363 this: Allocated<Self>,
364 nib_name_or_nil: Option<&NSString>,
365 nib_bundle_or_nil: Option<&NSBundle>,
366 ) -> Retained<Self>;
367
368 #[unsafe(method(initWithCoder:))]
369 #[unsafe(method_family = init)]
370 pub unsafe fn initWithCoder(
371 this: Allocated<Self>,
372 a_decoder: &NSCoder,
373 ) -> Option<Retained<Self>>;
374 );
375}
376
377/// Methods declared on superclass `NSObject`.
378#[cfg(feature = "objc2-ui-kit")]
379impl MFMailComposeViewController {
380 extern_methods!(
381 #[unsafe(method(init))]
382 #[unsafe(method_family = init)]
383 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
384
385 #[unsafe(method(new))]
386 #[unsafe(method_family = new)]
387 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
388 );
389}
390
391extern_protocol!(
392 /// Protocol for delegate callbacks to MFMailComposeViewController instances.
393 ///
394 /// This protocol must be implemented for delegates of MFMailComposeViewController instances. It will
395 /// be called at various times while the user is composing, sending, saving, or canceling email composition.
396 ///
397 /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontrollerdelegate?language=objc)
398 pub unsafe trait MFMailComposeViewControllerDelegate: NSObjectProtocol {
399 #[cfg(feature = "objc2-ui-kit")]
400 /// Delegate callback which is called upon user's completion of email composition.
401 ///
402 /// This delegate callback will be called when the user completes the email composition. How the user chose
403 /// to complete this task will be given as one of the parameters to the callback. Upon this call, the client
404 /// should remove the view associated with the controller, typically by dismissing modally.
405 ///
406 /// Parameter `controller`: The MFMailComposeViewController instance which is returning the result.
407 ///
408 /// Parameter `result`: MFMailComposeResult indicating how the user chose to complete the composition process.
409 ///
410 /// Parameter `error`: NSError indicating the failure reason if failure did occur. This will be
411 /// <tt>
412 /// nil
413 /// </tt>
414 /// if
415 /// result did not indicate failure.
416 #[optional]
417 #[unsafe(method(mailComposeController:didFinishWithResult:error:))]
418 #[unsafe(method_family = none)]
419 unsafe fn mailComposeController_didFinishWithResult_error(
420 &self,
421 controller: &MFMailComposeViewController,
422 result: MFMailComposeResult,
423 error: Option<&NSError>,
424 );
425 }
426);