objc2-messages 0.3.2

Bindings to the Messages framework
Documentation
//! 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::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/messages/msconversation?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MSConversation;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MSConversation {}
);

impl MSConversation {
    extern_methods!(
        /// A NSUUID that identifies conversation participant on this device.
        ///
        /// This NSUUID  that identifies conversation participant on this device,
        /// this value will be stable while the extension is enabled. If the extension is
        /// disabled and re-enabled or the containing App is removed and re-installed this
        /// value will change.
        #[unsafe(method(localParticipantIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn localParticipantIdentifier(&self) -> Retained<NSUUID>;

        /// A NSArray of NSUUID instances, each uniquely identifies a remote participant in the conversation.
        ///
        /// Each NSUUID identifies the a remote participant in the conversation scoped to
        /// this device. These values will be stable while the extension is enabled. If the extension
        /// is disabled and re-enabled or the containing App is removed and re-installed these
        /// values will change.
        #[unsafe(method(remoteParticipantIdentifiers))]
        #[unsafe(method_family = none)]
        pub unsafe fn remoteParticipantIdentifiers(&self) -> Retained<NSArray<NSUUID>>;

        #[cfg(feature = "MSMessage")]
        /// An MSMessage instance that may be edited and returned to Messages
        ///
        /// If the extension has been invoked in response to the user interacting with
        /// a message in the conversation transcript this property will contain the message.
        /// Otherwise this property will be nil. The message object provided may be saved to the
        /// file system. Later, this saved object may be loaded, modified and staged for sending.
        #[unsafe(method(selectedMessage))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectedMessage(&self) -> Option<Retained<MSMessage>>;

        #[cfg(all(feature = "MSMessage", feature = "block2"))]
        /// Stages the provided MSMessage object for sending.
        ///
        /// This method inserts a MSMessage object into the Messages input field,
        /// Subsequent calls to this method will replace any existing message on the input field.
        /// If the message was successfully inserted on the input field, the completion handler
        /// will be called with a nil error parameter otherwise the error parameter will be
        /// populated with an NSError object describing the failure.
        /// Calling this method when the presentation context is `MSMessagesAppPresentationContextMedia` will result in the completion handler getting called with an error object whose error code is `MSMessageErrorCodeAPIUnavailableInPresentationContext`.
        ///
        /// Parameter `message`: The MSMessage instance describing the message to be sent.
        ///
        /// Parameter `completionHandler`: A completion handler called when the message has been staged or if there was an error.
        #[unsafe(method(insertMessage:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertMessage_completionHandler(
            &self,
            message: &MSMessage,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(all(feature = "MSSticker", feature = "block2"))]
        /// The sticker is inserted into the Messages.app input field.
        ///
        /// Parameter `sticker`: The sticker to be inserted.
        ///
        /// Parameter `completionHandler`: A completion handler called when the insert is complete.
        #[unsafe(method(insertSticker:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertSticker_completionHandler(
            &self,
            sticker: &MSSticker,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        /// The NSString instance provided in the text parameter is inserted into the Messages.app input field.
        ///
        /// Calling this method when the presentation context is `MSMessagesAppPresentationContextMedia` will result in the completion handler getting called with an error object whose error code is `MSMessageErrorCodeAPIUnavailableInPresentationContext`.
        ///
        /// Parameter `text`: The text to be inserted.
        ///
        /// Parameter `completionHandler`: A completion handler called when the insert is complete.
        #[unsafe(method(insertText:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertText_completionHandler(
            &self,
            text: &NSString,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        /// The NSURL instance provided in the URL parameter is inserted into the Messages.app
        /// input field. This must be a file URL.
        ///
        /// Calling this method when the presentation context is `MSMessagesAppPresentationContextMedia` will result in the completion handler getting called with an error object whose error code is `MSMessageErrorCodeAPIUnavailableInPresentationContext` if the attachment type is not an image type supported by `MSSticker`.
        ///
        /// Parameter `URL`: The URL to the media file to be inserted.
        ///
        /// Parameter `filename`: If you supply a string here, the message UI uses it for the attachment. Use an alternate filename to better describe the attachment or to make the name more readable.
        ///
        /// Parameter `completionHandler`: A completion handler called when the insert is complete.
        #[unsafe(method(insertAttachment:withAlternateFilename:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertAttachment_withAlternateFilename_completionHandler(
            &self,
            url: &NSURL,
            filename: Option<&NSString>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(all(feature = "MSMessage", feature = "block2"))]
        /// Start sending a message
        ///
        /// This method begins sending the provided MSMessage. The app must be visible and have had a recent touch interaction since either last launch or last send to succeed. If the message started sending successfully, the completion handler will be called with a nil error parameter. Otherwise the error parameter will be populated with an NSError object describing the failure.
        /// Calling this method when the presentation context is `MSMessagesAppPresentationContextMedia` will result in the completion handler getting called with an error object whose error code is `MSMessageErrorCodeAPIUnavailableInPresentationContext`.
        ///
        /// Parameter `message`: The MSMessage instance describing the message to be sent.
        ///
        /// Parameter `completionHandler`: A completion handler called when the message has been staged or if there was an error.
        #[unsafe(method(sendMessage:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendMessage_completionHandler(
            &self,
            message: &MSMessage,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(all(feature = "MSSticker", feature = "block2"))]
        /// Start sending a sticker
        ///
        /// Calling this method when the presentation context is `MSMessagesAppPresentationContextMedia` will result in the completion handler getting called with an error object whose error code is `MSMessageErrorCodeAPIUnavailableInPresentationContext`.
        ///
        /// Parameter `sticker`: The sticker to be inserted.
        ///
        /// Parameter `completionHandler`: A completion handler called when the insert is complete.
        #[unsafe(method(sendSticker:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendSticker_completionHandler(
            &self,
            sticker: &MSSticker,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        /// Start sending text
        ///
        /// This method begins sending the provided NSString. The app must be visible and have had a recent touch interaction since either last launch or last send to succeed. If the message started sending successfully, the completion handler will be called with a nil error parameter. Otherwise the error parameter will be populated with an NSError object describing the failure.
        /// Calling this method when the presentation context is `MSMessagesAppPresentationContextMedia` will result in the completion handler getting called with an error object whose error code is `MSMessageErrorCodeAPIUnavailableInPresentationContext`.
        ///
        /// Parameter `text`: The text to be inserted.
        ///
        /// Parameter `completionHandler`: A completion handler called when the insert is complete.
        #[unsafe(method(sendText:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendText_completionHandler(
            &self,
            text: &NSString,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        /// Start sending a file located at the provided URL. This must be a file URL.
        ///
        /// This method begins sending the file at the provided file URL. The app must be visible and have had a recent touch interaction since either last launch or last send to succeed. If the message started sending successfully, the completion handler will be called with a nil error parameter. Otherwise the error parameter will be populated with an NSError object describing the failure.
        /// Calling this method when the presentation context is `MSMessagesAppPresentationContextMedia` will result in the completion handler getting called with an error object whose error code is `MSMessageErrorCodeAPIUnavailableInPresentationContext`.
        ///
        /// Parameter `URL`: The URL to the media file to be inserted.
        ///
        /// Parameter `filename`: If you supply a string here, the message UI uses it for the attachment. Use an alternate filename to better describe the attachment or to make the name more readable.
        ///
        /// Parameter `completionHandler`: A completion handler called when the insert is complete.
        #[unsafe(method(sendAttachment:withAlternateFilename:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendAttachment_withAlternateFilename_completionHandler(
            &self,
            url: &NSURL,
            filename: Option<&NSString>,
            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl MSConversation {
    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() -> Retained<Self>;
    );
}