use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MFMailComposeResult(pub NSInteger);
impl MFMailComposeResult {
#[doc(alias = "MFMailComposeResultCancelled")]
pub const Cancelled: Self = Self(0);
#[doc(alias = "MFMailComposeResultSaved")]
pub const Saved: Self = Self(1);
#[doc(alias = "MFMailComposeResultSent")]
pub const Sent: Self = Self(2);
#[doc(alias = "MFMailComposeResultFailed")]
pub const Failed: Self = Self(3);
}
unsafe impl Encode for MFMailComposeResult {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for MFMailComposeResult {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static MFMailComposeErrorDomain: &'static NSErrorDomain;
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MFMailComposeErrorCode(pub NSInteger);
impl MFMailComposeErrorCode {
#[doc(alias = "MFMailComposeErrorCodeSaveFailed")]
pub const SaveFailed: Self = Self(0);
#[doc(alias = "MFMailComposeErrorCodeSendFailed")]
pub const SendFailed: Self = Self(1);
}
unsafe impl Encode for MFMailComposeErrorCode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for MFMailComposeErrorCode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "objc2-ui-kit")]
pub struct MFMailComposeViewController;
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl NSCoding for MFMailComposeViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl NSObjectProtocol for MFMailComposeViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIAppearanceContainer for MFMailComposeViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIContentContainer for MFMailComposeViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIFocusEnvironment for MFMailComposeViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UIResponderStandardEditActions for MFMailComposeViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
unsafe impl UITraitEnvironment for MFMailComposeViewController {}
);
#[cfg(feature = "objc2-ui-kit")]
impl MFMailComposeViewController {
extern_methods!(
#[unsafe(method(canSendMail))]
#[unsafe(method_family = none)]
pub unsafe fn canSendMail(mtm: MainThreadMarker) -> bool;
#[unsafe(method(mailComposeDelegate))]
#[unsafe(method_family = none)]
pub unsafe fn mailComposeDelegate(
&self,
) -> Option<Retained<ProtocolObject<dyn MFMailComposeViewControllerDelegate>>>;
#[unsafe(method(setMailComposeDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setMailComposeDelegate(
&self,
mail_compose_delegate: Option<&ProtocolObject<dyn MFMailComposeViewControllerDelegate>>,
);
#[unsafe(method(setSubject:))]
#[unsafe(method_family = none)]
pub unsafe fn setSubject(&self, subject: &NSString);
#[unsafe(method(setToRecipients:))]
#[unsafe(method_family = none)]
pub unsafe fn setToRecipients(&self, to_recipients: Option<&NSArray<NSString>>);
#[unsafe(method(setCcRecipients:))]
#[unsafe(method_family = none)]
pub unsafe fn setCcRecipients(&self, cc_recipients: Option<&NSArray<NSString>>);
#[unsafe(method(setBccRecipients:))]
#[unsafe(method_family = none)]
pub unsafe fn setBccRecipients(&self, bcc_recipients: Option<&NSArray<NSString>>);
#[unsafe(method(setMessageBody:isHTML:))]
#[unsafe(method_family = none)]
pub unsafe fn setMessageBody_isHTML(&self, body: &NSString, is_html: bool);
#[unsafe(method(addAttachmentData:mimeType:fileName:))]
#[unsafe(method_family = none)]
pub unsafe fn addAttachmentData_mimeType_fileName(
&self,
attachment: &NSData,
mime_type: &NSString,
filename: &NSString,
);
#[unsafe(method(setPreferredSendingEmailAddress:))]
#[unsafe(method_family = none)]
pub unsafe fn setPreferredSendingEmailAddress(&self, email_address: &NSString);
#[cfg(feature = "block2")]
#[unsafe(method(insertCollaborationItemProvider:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn insertCollaborationItemProvider_completionHandler(
&self,
item_provider: &NSItemProvider,
completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
);
);
}
#[cfg(feature = "objc2-ui-kit")]
impl MFMailComposeViewController {
extern_methods!(
#[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>;
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
a_decoder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
#[cfg(feature = "objc2-ui-kit")]
impl MFMailComposeViewController {
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!(
pub unsafe trait MFMailComposeViewControllerDelegate: NSObjectProtocol {
#[cfg(feature = "objc2-ui-kit")]
#[optional]
#[unsafe(method(mailComposeController:didFinishWithResult:error:))]
#[unsafe(method_family = none)]
unsafe fn mailComposeController_didFinishWithResult_error(
&self,
controller: &MFMailComposeViewController,
result: MFMailComposeResult,
error: Option<&NSError>,
);
}
);