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        /// This is a [weak property][objc2::topics::weak_property].
229        /// Setter for [`messageComposeDelegate`][Self::messageComposeDelegate].
230        #[unsafe(method(setMessageComposeDelegate:))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn setMessageComposeDelegate(
233            &self,
234            message_compose_delegate: Option<
235                &ProtocolObject<dyn MFMessageComposeViewControllerDelegate>,
236            >,
237        );
238
239        /// Calling this method will disable the camera/attachment button in the view controller.  After the controller has been presented,
240        /// this call will have no effect.  The camera / attachment button is visible by default.
241        #[unsafe(method(disableUserAttachments))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn disableUserAttachments(&self);
244
245        /// This property sets the initial value of the To field for the message to the specified addresses.
246        ///
247        /// This property will set the initial value of the To field for the message from an NSArray of
248        /// NSString instances specifying the message addresses of recipients. This should be called prior
249        /// to display.
250        /// <p>
251        /// After the view has been presented to the user, this property will no longer change the value.
252        /// </p>
253        #[unsafe(method(recipients))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn recipients(&self) -> Option<Retained<NSArray<NSString>>>;
256
257        /// Setter for [`recipients`][Self::recipients].
258        #[unsafe(method(setRecipients:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<NSString>>);
261
262        /// This property sets the initial value of the body of the message to the specified content.
263        ///
264        /// This property will set the initial value of the body of the message.  This should be called prior
265        /// to display.
266        /// <p>
267        /// After the view has been presented to the user, this property will no longer change the value.
268        /// </p>
269        #[unsafe(method(body))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn body(&self) -> Option<Retained<NSString>>;
272
273        /// Setter for [`body`][Self::body].
274        #[unsafe(method(setBody:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setBody(&self, body: Option<&NSString>);
277
278        /// This property sets the initial value of the subject of the message to the specified content.
279        ///
280        /// This property will set the initial value of the subject of the message.  This should be called prior
281        /// to display.
282        /// <p>
283        /// After the view has been presented to the user, this property will no longer change the value.
284        /// </p>
285        #[unsafe(method(subject))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn subject(&self) -> Option<Retained<NSString>>;
288
289        /// Setter for [`subject`][Self::subject].
290        #[unsafe(method(setSubject:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setSubject(&self, subject: Option<&NSString>);
293
294        /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
295        ///
296        /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
297        /// See MFMessageComposeViewControllerAttachmentURL, MFMessageComposeViewControllerAttachmentAlternateFilename.
298        #[unsafe(method(attachments))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn attachments(&self) -> Option<Retained<NSArray<NSDictionary>>>;
301
302        #[cfg(feature = "objc2-messages")]
303        #[cfg(not(target_os = "visionos"))]
304        /// This property sets the initial interactive message.
305        #[unsafe(method(message))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn message(&self) -> Option<Retained<MSMessage>>;
308
309        #[cfg(feature = "objc2-messages")]
310        #[cfg(not(target_os = "visionos"))]
311        /// Setter for [`message`][Self::message].
312        #[unsafe(method(setMessage:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn setMessage(&self, message: Option<&MSMessage>);
315
316        /// Returns
317        /// <tt>
318        /// YES
319        /// </tt>
320        /// if the attachment at the specified URL was added to the composition successfully.
321        ///
322        /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
323        /// the attachment was not added to the composition.  All attachment URLs must be file urls.  The file
324        /// URL must not be NIL.  The alternate filename will be display to the user in leiu of the attachments URL.
325        /// The alternate filename may be NIL.
326        #[unsafe(method(addAttachmentURL:withAlternateFilename:))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn addAttachmentURL_withAlternateFilename(
329            &self,
330            attachment_url: &NSURL,
331            alternate_filename: Option<&NSString>,
332        ) -> bool;
333
334        /// Returns
335        /// <tt>
336        /// YES
337        /// </tt>
338        /// if the attachment was added to the composition successfully.
339        ///
340        /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
341        /// the attachment was not added to the composition.  The data and typeIdentifer must be non-nil.  typeIdentifier should be a valid Uniform Type Identifier.
342        #[unsafe(method(addAttachmentData:typeIdentifier:filename:))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn addAttachmentData_typeIdentifier_filename(
345            &self,
346            attachment_data: &NSData,
347            uti: &NSString,
348            filename: &NSString,
349        ) -> bool;
350
351        /// Parameter `itemProvider`: created from ShareSheet
352        ///
353        /// Returns
354        /// <tt>
355        /// YES
356        /// </tt>
357        /// if the item provider was added to the composition successfully.
358        ///
359        /// If the return value is YES, the itemProvider was added to the composition. If the return value is NO,
360        /// the itemProvider was not added to the composition.  The itemProvider must be non-nil.
361        #[unsafe(method(insertCollaborationItemProvider:))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn insertCollaborationItemProvider(
364            &self,
365            item_provider: &NSItemProvider,
366        ) -> bool;
367    );
368}
369
370/// Methods declared on superclass `UINavigationController`.
371#[cfg(feature = "objc2-ui-kit")]
372impl MFMessageComposeViewController {
373    extern_methods!(
374        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
375        #[unsafe(method_family = init)]
376        pub unsafe fn initWithNavigationBarClass_toolbarClass(
377            this: Allocated<Self>,
378            navigation_bar_class: Option<&AnyClass>,
379            toolbar_class: Option<&AnyClass>,
380        ) -> Retained<Self>;
381
382        #[unsafe(method(initWithRootViewController:))]
383        #[unsafe(method_family = init)]
384        pub unsafe fn initWithRootViewController(
385            this: Allocated<Self>,
386            root_view_controller: &UIViewController,
387        ) -> Retained<Self>;
388
389        #[unsafe(method(initWithNibName:bundle:))]
390        #[unsafe(method_family = init)]
391        pub unsafe fn initWithNibName_bundle(
392            this: Allocated<Self>,
393            nib_name_or_nil: Option<&NSString>,
394            nib_bundle_or_nil: Option<&NSBundle>,
395        ) -> Retained<Self>;
396
397        #[unsafe(method(initWithCoder:))]
398        #[unsafe(method_family = init)]
399        pub unsafe fn initWithCoder(
400            this: Allocated<Self>,
401            a_decoder: &NSCoder,
402        ) -> Option<Retained<Self>>;
403    );
404}
405
406/// Methods declared on superclass `NSObject`.
407#[cfg(feature = "objc2-ui-kit")]
408impl MFMessageComposeViewController {
409    extern_methods!(
410        #[unsafe(method(init))]
411        #[unsafe(method_family = init)]
412        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
413
414        #[unsafe(method(new))]
415        #[unsafe(method_family = new)]
416        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
417    );
418}
419
420extern_protocol!(
421    /// Protocol for delegate callbacks to MFMessageComposeViewControllerDelegate instances.
422    ///
423    /// This protocol will be implemented by delegates of MFMessageComposeViewController instances.
424    /// It will be called at various times while the user is composing, sending, or canceling
425    /// message composition.
426    ///
427    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerdelegate?language=objc)
428    pub unsafe trait MFMessageComposeViewControllerDelegate: NSObjectProtocol {
429        #[cfg(feature = "objc2-ui-kit")]
430        /// Delegate callback which is called upon user's completion of message composition.
431        ///
432        /// This delegate callback will be called when the user completes the message composition.
433        /// How the user chose to complete this task will be given as one of the parameters to the
434        /// callback.  Upon this call, the client should remove the view associated with the controller,
435        /// typically by dismissing modally.
436        ///
437        /// Parameter `controller`: The MFMessageComposeViewController instance which is returning the result.
438        ///
439        /// Parameter `result`: MessageComposeResult indicating how the user chose to complete the composition process.
440        #[unsafe(method(messageComposeViewController:didFinishWithResult:))]
441        #[unsafe(method_family = none)]
442        unsafe fn messageComposeViewController_didFinishWithResult(
443            &self,
444            controller: &MFMessageComposeViewController,
445            result: MessageComposeResult,
446        );
447    }
448);