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")]
131extern_conformance!(
132 unsafe impl NSCoding for MFMessageComposeViewController {}
133);
134
135#[cfg(feature = "objc2-ui-kit")]
136extern_conformance!(
137 unsafe impl NSObjectProtocol for MFMessageComposeViewController {}
138);
139
140#[cfg(feature = "objc2-ui-kit")]
141extern_conformance!(
142 unsafe impl UIAppearanceContainer for MFMessageComposeViewController {}
143);
144
145#[cfg(feature = "objc2-ui-kit")]
146extern_conformance!(
147 unsafe impl UIContentContainer for MFMessageComposeViewController {}
148);
149
150#[cfg(feature = "objc2-ui-kit")]
151extern_conformance!(
152 unsafe impl UIFocusEnvironment for MFMessageComposeViewController {}
153);
154
155#[cfg(feature = "objc2-ui-kit")]
156extern_conformance!(
157 unsafe impl UIResponderStandardEditActions for MFMessageComposeViewController {}
158);
159
160#[cfg(feature = "objc2-ui-kit")]
161extern_conformance!(
162 unsafe impl UITraitEnvironment for MFMessageComposeViewController {}
163);
164
165#[cfg(feature = "objc2-ui-kit")]
166impl MFMessageComposeViewController {
167 extern_methods!(
168 /// Returns
169 /// <tt>
170 /// YES
171 /// </tt>
172 /// if the user has set up the device for sending text only messages.
173 ///
174 /// If the return value is YES, the client can set the recipients and body of the message.
175 /// If the return value is NO, the client may notify the user of the failure, or the
176 /// client may open an SMS URL via
177 /// <tt>
178 /// -[UIApplication openURL:]
179 /// </tt>
180 /// .
181 #[unsafe(method(canSendText))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn canSendText(mtm: MainThreadMarker) -> bool;
184
185 /// Returns
186 /// <tt>
187 /// YES
188 /// </tt>
189 /// <tt>
190 /// if the user has set up the device for including subjects in messages.
191 /// </tt>
192 /// .
193 #[unsafe(method(canSendSubject))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn canSendSubject(mtm: MainThreadMarker) -> bool;
196
197 /// Returns
198 /// <tt>
199 /// YES
200 /// </tt>
201 /// <tt>
202 /// if the user has set up the device for including attachments in messages.
203 /// </tt>
204 /// .
205 #[unsafe(method(canSendAttachments))]
206 #[unsafe(method_family = none)]
207 pub unsafe fn canSendAttachments(mtm: MainThreadMarker) -> bool;
208
209 /// Returns
210 /// <tt>
211 /// YES
212 /// </tt>
213 /// if the attachment at the specified URL could be accepted by the current composition.
214 ///
215 /// If the return value is YES, the UTI is acceptable for attachment to a message, a return value of NO
216 /// indicates that the given UTI is unsupported.
217 #[unsafe(method(isSupportedAttachmentUTI:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn isSupportedAttachmentUTI(uti: &NSString, mtm: MainThreadMarker) -> bool;
220
221 /// This property is the delegate for the MFMessageComposeViewController method callbacks.
222 #[unsafe(method(messageComposeDelegate))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn messageComposeDelegate(
225 &self,
226 ) -> Option<Retained<ProtocolObject<dyn MFMessageComposeViewControllerDelegate>>>;
227
228 /// Setter for [`messageComposeDelegate`][Self::messageComposeDelegate].
229 ///
230 /// This is a [weak property][objc2::topics::weak_property].
231 #[unsafe(method(setMessageComposeDelegate:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setMessageComposeDelegate(
234 &self,
235 message_compose_delegate: Option<
236 &ProtocolObject<dyn MFMessageComposeViewControllerDelegate>,
237 >,
238 );
239
240 /// Calling this method will disable the camera/attachment button in the view controller. After the controller has been presented,
241 /// this call will have no effect. The camera / attachment button is visible by default.
242 #[unsafe(method(disableUserAttachments))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn disableUserAttachments(&self);
245
246 /// This property sets the initial value of the To field for the message to the specified addresses.
247 ///
248 /// This property will set the initial value of the To field for the message from an NSArray of
249 /// NSString instances specifying the message addresses of recipients. This should be called prior
250 /// to display.
251 /// <p>
252 /// After the view has been presented to the user, this property will no longer change the value.
253 /// </p>
254 #[unsafe(method(recipients))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn recipients(&self) -> Option<Retained<NSArray<NSString>>>;
257
258 /// Setter for [`recipients`][Self::recipients].
259 ///
260 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
261 #[unsafe(method(setRecipients:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<NSString>>);
264
265 /// This property sets the initial value of the body of the message to the specified content.
266 ///
267 /// This property will set the initial value of the body of the message. This should be called prior
268 /// to display.
269 /// <p>
270 /// After the view has been presented to the user, this property will no longer change the value.
271 /// </p>
272 #[unsafe(method(body))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn body(&self) -> Option<Retained<NSString>>;
275
276 /// Setter for [`body`][Self::body].
277 ///
278 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
279 #[unsafe(method(setBody:))]
280 #[unsafe(method_family = none)]
281 pub unsafe fn setBody(&self, body: Option<&NSString>);
282
283 /// This property sets the initial value of the subject of the message to the specified content.
284 ///
285 /// This property will set the initial value of the subject of the message. This should be called prior
286 /// to display.
287 /// <p>
288 /// After the view has been presented to the user, this property will no longer change the value.
289 /// </p>
290 #[unsafe(method(subject))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn subject(&self) -> Option<Retained<NSString>>;
293
294 /// Setter for [`subject`][Self::subject].
295 ///
296 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
297 #[unsafe(method(setSubject:))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn setSubject(&self, subject: Option<&NSString>);
300
301 /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
302 ///
303 /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
304 /// See MFMessageComposeViewControllerAttachmentURL, MFMessageComposeViewControllerAttachmentAlternateFilename.
305 #[unsafe(method(attachments))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn attachments(&self) -> Option<Retained<NSArray<NSDictionary>>>;
308
309 #[cfg(feature = "objc2-messages")]
310 #[cfg(not(target_os = "visionos"))]
311 /// This property sets the initial interactive message.
312 #[unsafe(method(message))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn message(&self) -> Option<Retained<MSMessage>>;
315
316 #[cfg(feature = "objc2-messages")]
317 #[cfg(not(target_os = "visionos"))]
318 /// Setter for [`message`][Self::message].
319 ///
320 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
321 #[unsafe(method(setMessage:))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn setMessage(&self, message: Option<&MSMessage>);
324
325 /// Returns
326 /// <tt>
327 /// YES
328 /// </tt>
329 /// if the attachment at the specified URL was added to the composition successfully.
330 ///
331 /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
332 /// the attachment was not added to the composition. All attachment URLs must be file urls. The file
333 /// URL must not be NIL. The alternate filename will be display to the user in leiu of the attachments URL.
334 /// The alternate filename may be NIL.
335 #[unsafe(method(addAttachmentURL:withAlternateFilename:))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn addAttachmentURL_withAlternateFilename(
338 &self,
339 attachment_url: &NSURL,
340 alternate_filename: Option<&NSString>,
341 ) -> bool;
342
343 /// Returns
344 /// <tt>
345 /// YES
346 /// </tt>
347 /// if the attachment was added to the composition successfully.
348 ///
349 /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
350 /// the attachment was not added to the composition. The data and typeIdentifer must be non-nil. typeIdentifier should be a valid Uniform Type Identifier.
351 #[unsafe(method(addAttachmentData:typeIdentifier:filename:))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn addAttachmentData_typeIdentifier_filename(
354 &self,
355 attachment_data: &NSData,
356 uti: &NSString,
357 filename: &NSString,
358 ) -> bool;
359
360 /// Parameter `itemProvider`: created from ShareSheet
361 ///
362 /// Returns
363 /// <tt>
364 /// YES
365 /// </tt>
366 /// if the item provider was added to the composition successfully.
367 ///
368 /// If the return value is YES, the itemProvider was added to the composition. If the return value is NO,
369 /// the itemProvider was not added to the composition. The itemProvider must be non-nil.
370 #[unsafe(method(insertCollaborationItemProvider:))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn insertCollaborationItemProvider(
373 &self,
374 item_provider: &NSItemProvider,
375 ) -> bool;
376 );
377}
378
379/// Methods declared on superclass `UINavigationController`.
380#[cfg(feature = "objc2-ui-kit")]
381impl MFMessageComposeViewController {
382 extern_methods!(
383 /// # Safety
384 ///
385 /// - `navigation_bar_class` probably has further requirements.
386 /// - `toolbar_class` probably has further requirements.
387 #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
388 #[unsafe(method_family = init)]
389 pub unsafe fn initWithNavigationBarClass_toolbarClass(
390 this: Allocated<Self>,
391 navigation_bar_class: Option<&AnyClass>,
392 toolbar_class: Option<&AnyClass>,
393 ) -> Retained<Self>;
394
395 #[unsafe(method(initWithRootViewController:))]
396 #[unsafe(method_family = init)]
397 pub unsafe fn initWithRootViewController(
398 this: Allocated<Self>,
399 root_view_controller: &UIViewController,
400 ) -> Retained<Self>;
401
402 #[unsafe(method(initWithNibName:bundle:))]
403 #[unsafe(method_family = init)]
404 pub unsafe fn initWithNibName_bundle(
405 this: Allocated<Self>,
406 nib_name_or_nil: Option<&NSString>,
407 nib_bundle_or_nil: Option<&NSBundle>,
408 ) -> Retained<Self>;
409
410 /// # Safety
411 ///
412 /// `a_decoder` possibly has further requirements.
413 #[unsafe(method(initWithCoder:))]
414 #[unsafe(method_family = init)]
415 pub unsafe fn initWithCoder(
416 this: Allocated<Self>,
417 a_decoder: &NSCoder,
418 ) -> Option<Retained<Self>>;
419 );
420}
421
422/// Methods declared on superclass `NSObject`.
423#[cfg(feature = "objc2-ui-kit")]
424impl MFMessageComposeViewController {
425 extern_methods!(
426 #[unsafe(method(init))]
427 #[unsafe(method_family = init)]
428 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
429
430 #[unsafe(method(new))]
431 #[unsafe(method_family = new)]
432 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
433 );
434}
435
436extern_protocol!(
437 /// Protocol for delegate callbacks to MFMessageComposeViewControllerDelegate instances.
438 ///
439 /// This protocol will be implemented by delegates of MFMessageComposeViewController instances.
440 /// It will be called at various times while the user is composing, sending, or canceling
441 /// message composition.
442 ///
443 /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerdelegate?language=objc)
444 pub unsafe trait MFMessageComposeViewControllerDelegate: NSObjectProtocol {
445 #[cfg(feature = "objc2-ui-kit")]
446 /// Delegate callback which is called upon user's completion of message composition.
447 ///
448 /// This delegate callback will be called when the user completes the message composition.
449 /// How the user chose to complete this task will be given as one of the parameters to the
450 /// callback. Upon this call, the client should remove the view associated with the controller,
451 /// typically by dismissing modally.
452 ///
453 /// Parameter `controller`: The MFMessageComposeViewController instance which is returning the result.
454 ///
455 /// Parameter `result`: MessageComposeResult indicating how the user chose to complete the composition process.
456 #[unsafe(method(messageComposeViewController:didFinishWithResult:))]
457 #[unsafe(method_family = none)]
458 unsafe fn messageComposeViewController_didFinishWithResult(
459 &self,
460 controller: &MFMessageComposeViewController,
461 result: MessageComposeResult,
462 );
463 }
464);