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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
use objc2_app_kit::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MEComposeSession;

    unsafe impl ClassType for MEComposeSession {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSCoding for MEComposeSession {}

unsafe impl NSObjectProtocol for MEComposeSession {}

unsafe impl NSSecureCoding for MEComposeSession {}

extern_methods!(
    unsafe impl MEComposeSession {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;

        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics Other sessionID)]
        pub unsafe fn sessionID(&self) -> Retained<NSUUID>;

        #[cfg(feature = "MEMessage")]
        #[method_id(@__retain_semantics Other mailMessage)]
        pub unsafe fn mailMessage(&self) -> Retained<MEMessage>;

        #[cfg(feature = "MEComposeContext")]
        #[method_id(@__retain_semantics Other composeContext)]
        pub unsafe fn composeContext(&self) -> Retained<MEComposeContext>;

        #[method(reloadSession)]
        pub unsafe fn reloadSession(&self);
    }
);

extern "C" {
    pub static MEComposeSessionErrorDomain: &'static NSErrorDomain;
}

// NS_ERROR_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MEComposeSessionErrorCode(pub NSInteger);
impl MEComposeSessionErrorCode {
    #[doc(alias = "MEComposeSessionErrorCodeInvalidRecipients")]
    pub const InvalidRecipients: Self = Self(0);
    #[doc(alias = "MEComposeSessionErrorCodeInvalidHeaders")]
    pub const InvalidHeaders: Self = Self(1);
    #[doc(alias = "MEComposeSessionErrorCodeInvalidBody")]
    pub const InvalidBody: Self = Self(2);
}

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

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

extern_protocol!(
    pub unsafe trait MEComposeSessionHandler: NSObjectProtocol {
        #[method(mailComposeSessionDidBegin:)]
        unsafe fn mailComposeSessionDidBegin(&self, session: &MEComposeSession);

        #[method(mailComposeSessionDidEnd:)]
        unsafe fn mailComposeSessionDidEnd(&self, session: &MEComposeSession);

        #[cfg(all(feature = "MEExtensionViewController", feature = "objc2-app-kit"))]
        #[method_id(@__retain_semantics Other viewControllerForSession:)]
        unsafe fn viewControllerForSession(
            &self,
            session: &MEComposeSession,
            mtm: MainThreadMarker,
        ) -> Retained<MEExtensionViewController>;

        #[cfg(all(
            feature = "MEAddressAnnotation",
            feature = "MEEmailAddress",
            feature = "block2"
        ))]
        #[optional]
        #[method(session:annotateAddressesWithCompletionHandler:)]
        unsafe fn session_annotateAddressesWithCompletionHandler(
            &self,
            session: &MEComposeSession,
            completion_handler: &block2::Block<
                dyn Fn(NonNull<NSDictionary<MEEmailAddress, MEAddressAnnotation>>),
            >,
        );

        #[cfg(feature = "block2")]
        #[optional]
        #[method(session:canSendMessageWithCompletionHandler:)]
        unsafe fn session_canSendMessageWithCompletionHandler(
            &self,
            session: &MEComposeSession,
            completion: &block2::Block<dyn Fn(*mut NSError)>,
        );

        #[optional]
        #[method_id(@__retain_semantics Other additionalHeadersForSession:)]
        unsafe fn additionalHeadersForSession(
            &self,
            session: &MEComposeSession,
        ) -> Retained<NSDictionary<NSString, NSArray<NSString>>>;
    }

    unsafe impl ProtocolType for dyn MEComposeSessionHandler {}
);