objc2-message-ui 0.3.2

Bindings to the MessageUI framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-messages")]
#[cfg(not(target_os = "visionos"))]
use objc2_messages::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

/// Composition result sent to the delegate upon user completion.
///
/// This result will inform the client of the user's message composition action.  If the
/// user cancels the composition,
/// <tt>
/// MessageComposeResultCancelled
/// </tt>
/// will be sent to the delegate.
/// Typically
/// <tt>
/// MessageComposeResultSent
/// </tt>
/// will be sent, but
/// <tt>
/// MessageComposeResultFailed
/// </tt>
/// will
/// be sent in the case of failure.
/// </p>
/// Send may only be interpreted as a successful queueing of
/// the message for later sending. The actual send will occur when the device is able to send.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/messagecomposeresult?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MessageComposeResult(pub NSInteger);
impl MessageComposeResult {
    #[doc(alias = "MessageComposeResultCancelled")]
    pub const Cancelled: Self = Self(0);
    #[doc(alias = "MessageComposeResultSent")]
    pub const Sent: Self = Self(1);
    #[doc(alias = "MessageComposeResultFailed")]
    pub const Failed: Self = Self(2);
}

unsafe impl Encode for MessageComposeResult {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for MessageComposeResult {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerattachmenturl?language=objc)
    pub static MFMessageComposeViewControllerAttachmentURL: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerattachmentalternatefilename?language=objc)
    pub static MFMessageComposeViewControllerAttachmentAlternateFilename: &'static NSString;
}

extern "C" {
    /// Notification posted when the value of
    /// <tt>
    /// +[MFMessageComposeViewController canSendText]
    /// </tt>
    /// has changed.
    ///
    /// This notification is posted when the value of
    /// <tt>
    /// +[MFMessageComposeViewController canSendText]
    /// </tt>
    /// has changed. Clients should invalidate any caches and update UI as appropriate.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollertextmessageavailabilitydidchangenotification?language=objc)
    pub static MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification:
        &'static NSString;
}

extern "C" {
    /// UserInfo key for MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification
    /// containing the value of
    /// <tt>
    /// +[MFMessageComposeViewController canSendText]
    /// </tt>
    ///
    /// The value of this key is an NSNumber containing a BOOL value. This value matches
    /// the result of
    /// <tt>
    /// +[MFMessageComposeViewController canSendText]
    /// </tt>
    /// .
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollertextmessageavailabilitykey?language=objc)
    pub static MFMessageComposeViewControllerTextMessageAvailabilityKey: &'static NSString;
}

extern_class!(
    /// The MFMessageComposeViewController class provides an interface for editing and sending a message.
    ///
    /// The MFMessageComposeViewController class manages all user interaction.  The client needs to set
    /// the recipient or recipients.  The client may also set the body of the message. After setup, the
    /// client needs to only display the view.
    /// <p>
    /// The provided delegate will be informed of the user's composition completion and how they chose
    /// to complete the operation.
    /// </p>
    /// <p>
    /// Prior to use, clients should verify the user has set up the device for sending messages via
    /// <tt>
    /// +[MFMessageComposeViewController canSendText]
    /// </tt>
    /// .
    /// </p>
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontroller?language=objc)
    #[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-ui-kit")]
    pub struct MFMessageComposeViewController;
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl NSCoding for MFMessageComposeViewController {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl NSObjectProtocol for MFMessageComposeViewController {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIAppearanceContainer for MFMessageComposeViewController {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIContentContainer for MFMessageComposeViewController {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIFocusEnvironment for MFMessageComposeViewController {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for MFMessageComposeViewController {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UITraitEnvironment for MFMessageComposeViewController {}
);

#[cfg(feature = "objc2-ui-kit")]
impl MFMessageComposeViewController {
    extern_methods!(
        /// Returns
        /// <tt>
        /// YES
        /// </tt>
        /// if the user has set up the device for sending text only messages.
        ///
        /// If the return value is YES, the client can set the recipients and body of the message.
        /// If the return value is NO, the client may notify the user of the failure, or the
        /// client may open an SMS URL via
        /// <tt>
        /// -[UIApplication openURL:]
        /// </tt>
        /// .
        #[unsafe(method(canSendText))]
        #[unsafe(method_family = none)]
        pub unsafe fn canSendText(mtm: MainThreadMarker) -> bool;

        /// Returns
        /// <tt>
        /// YES
        /// </tt>
        /// <tt>
        /// if the user has set up the device for including subjects in messages.
        /// </tt>
        /// .
        #[unsafe(method(canSendSubject))]
        #[unsafe(method_family = none)]
        pub unsafe fn canSendSubject(mtm: MainThreadMarker) -> bool;

        /// Returns
        /// <tt>
        /// YES
        /// </tt>
        /// <tt>
        /// if the user has set up the device for including attachments in messages.
        /// </tt>
        /// .
        #[unsafe(method(canSendAttachments))]
        #[unsafe(method_family = none)]
        pub unsafe fn canSendAttachments(mtm: MainThreadMarker) -> bool;

        /// Returns
        /// <tt>
        /// YES
        /// </tt>
        /// if the attachment at the specified URL could be accepted by the current composition.
        ///
        /// If the return value is YES, the UTI is acceptable for attachment to a message, a return value of NO
        /// indicates that the given UTI is unsupported.
        #[unsafe(method(isSupportedAttachmentUTI:))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSupportedAttachmentUTI(uti: &NSString, mtm: MainThreadMarker) -> bool;

        /// This property is the delegate for the MFMessageComposeViewController method callbacks.
        #[unsafe(method(messageComposeDelegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn messageComposeDelegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn MFMessageComposeViewControllerDelegate>>>;

        /// Setter for [`messageComposeDelegate`][Self::messageComposeDelegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setMessageComposeDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMessageComposeDelegate(
            &self,
            message_compose_delegate: Option<
                &ProtocolObject<dyn MFMessageComposeViewControllerDelegate>,
            >,
        );

        /// Calling this method will disable the camera/attachment button in the view controller.  After the controller has been presented,
        /// this call will have no effect.  The camera / attachment button is visible by default.
        #[unsafe(method(disableUserAttachments))]
        #[unsafe(method_family = none)]
        pub unsafe fn disableUserAttachments(&self);

        /// This property sets the initial value of the To field for the message to the specified addresses.
        ///
        /// This property will set the initial value of the To field for the message from an NSArray of
        /// NSString instances specifying the message addresses of recipients. This should be called prior
        /// to display.
        /// <p>
        /// After the view has been presented to the user, this property will no longer change the value.
        /// </p>
        #[unsafe(method(recipients))]
        #[unsafe(method_family = none)]
        pub unsafe fn recipients(&self) -> Option<Retained<NSArray<NSString>>>;

        /// Setter for [`recipients`][Self::recipients].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setRecipients:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<NSString>>);

        /// This property sets the initial value of the body of the message to the specified content.
        ///
        /// This property will set the initial value of the body of the message.  This should be called prior
        /// to display.
        /// <p>
        /// After the view has been presented to the user, this property will no longer change the value.
        /// </p>
        #[unsafe(method(body))]
        #[unsafe(method_family = none)]
        pub unsafe fn body(&self) -> Option<Retained<NSString>>;

        /// Setter for [`body`][Self::body].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setBody:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBody(&self, body: Option<&NSString>);

        /// This property sets the initial value of the subject of the message to the specified content.
        ///
        /// This property will set the initial value of the subject of the message.  This should be called prior
        /// to display.
        /// <p>
        /// After the view has been presented to the user, this property will no longer change the value.
        /// </p>
        #[unsafe(method(subject))]
        #[unsafe(method_family = none)]
        pub unsafe fn subject(&self) -> Option<Retained<NSString>>;

        /// Setter for [`subject`][Self::subject].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSubject:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSubject(&self, subject: Option<&NSString>);

        /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
        ///
        /// This property returns an NSArray of NSDictionaries describing the properties of the current attachments.
        /// See MFMessageComposeViewControllerAttachmentURL, MFMessageComposeViewControllerAttachmentAlternateFilename.
        #[unsafe(method(attachments))]
        #[unsafe(method_family = none)]
        pub unsafe fn attachments(&self) -> Option<Retained<NSArray<NSDictionary>>>;

        #[cfg(feature = "objc2-messages")]
        #[cfg(not(target_os = "visionos"))]
        /// This property sets the initial interactive message.
        #[unsafe(method(message))]
        #[unsafe(method_family = none)]
        pub unsafe fn message(&self) -> Option<Retained<MSMessage>>;

        #[cfg(feature = "objc2-messages")]
        #[cfg(not(target_os = "visionos"))]
        /// Setter for [`message`][Self::message].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMessage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMessage(&self, message: Option<&MSMessage>);

        /// Returns
        /// <tt>
        /// YES
        /// </tt>
        /// if the attachment at the specified URL was added to the composition successfully.
        ///
        /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
        /// the attachment was not added to the composition.  All attachment URLs must be file urls.  The file
        /// URL must not be NIL.  The alternate filename will be display to the user in leiu of the attachments URL.
        /// The alternate filename may be NIL.
        #[unsafe(method(addAttachmentURL:withAlternateFilename:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addAttachmentURL_withAlternateFilename(
            &self,
            attachment_url: &NSURL,
            alternate_filename: Option<&NSString>,
        ) -> bool;

        /// Returns
        /// <tt>
        /// YES
        /// </tt>
        /// if the attachment was added to the composition successfully.
        ///
        /// If the return value is YES, the attachment was added to the composition. If the return value is NO,
        /// the attachment was not added to the composition.  The data and typeIdentifer must be non-nil.  typeIdentifier should be a valid Uniform Type Identifier.
        #[unsafe(method(addAttachmentData:typeIdentifier:filename:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addAttachmentData_typeIdentifier_filename(
            &self,
            attachment_data: &NSData,
            uti: &NSString,
            filename: &NSString,
        ) -> bool;

        /// Parameter `itemProvider`: created from ShareSheet
        ///
        /// Returns
        /// <tt>
        /// YES
        /// </tt>
        /// if the item provider was added to the composition successfully.
        ///
        /// If the return value is YES, the itemProvider was added to the composition. If the return value is NO,
        /// the itemProvider was not added to the composition.  The itemProvider must be non-nil.
        #[unsafe(method(insertCollaborationItemProvider:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertCollaborationItemProvider(
            &self,
            item_provider: &NSItemProvider,
        ) -> bool;
    );
}

/// Methods declared on superclass `UINavigationController`.
#[cfg(feature = "objc2-ui-kit")]
impl MFMessageComposeViewController {
    extern_methods!(
        /// # Safety
        ///
        /// - `navigation_bar_class` probably has further requirements.
        /// - `toolbar_class` probably has further requirements.
        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithNavigationBarClass_toolbarClass(
            this: Allocated<Self>,
            navigation_bar_class: Option<&AnyClass>,
            toolbar_class: Option<&AnyClass>,
        ) -> Retained<Self>;

        #[unsafe(method(initWithRootViewController:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithRootViewController(
            this: Allocated<Self>,
            root_view_controller: &UIViewController,
        ) -> Retained<Self>;

        #[unsafe(method(initWithNibName:bundle:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithNibName_bundle(
            this: Allocated<Self>,
            nib_name_or_nil: Option<&NSString>,
            nib_bundle_or_nil: Option<&NSBundle>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `a_decoder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            a_decoder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-ui-kit")]
impl MFMessageComposeViewController {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern_protocol!(
    /// Protocol for delegate callbacks to MFMessageComposeViewControllerDelegate instances.
    ///
    /// This protocol will be implemented by delegates of MFMessageComposeViewController instances.
    /// It will be called at various times while the user is composing, sending, or canceling
    /// message composition.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/messageui/mfmessagecomposeviewcontrollerdelegate?language=objc)
    pub unsafe trait MFMessageComposeViewControllerDelegate: NSObjectProtocol {
        #[cfg(feature = "objc2-ui-kit")]
        /// Delegate callback which is called upon user's completion of message composition.
        ///
        /// This delegate callback will be called when the user completes the message composition.
        /// How the user chose to complete this task will be given as one of the parameters to the
        /// callback.  Upon this call, the client should remove the view associated with the controller,
        /// typically by dismissing modally.
        ///
        /// Parameter `controller`: The MFMessageComposeViewController instance which is returning the result.
        ///
        /// Parameter `result`: MessageComposeResult indicating how the user chose to complete the composition process.
        #[unsafe(method(messageComposeViewController:didFinishWithResult:))]
        #[unsafe(method_family = none)]
        unsafe fn messageComposeViewController_didFinishWithResult(
            &self,
            controller: &MFMessageComposeViewController,
            result: MessageComposeResult,
        );
    }
);