forked from FMXExpress/ios-object-pascal-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiOSapi.MessageUI.pas
199 lines (159 loc) · 6 KB
/
iOSapi.MessageUI.pas
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
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework MessageUI
//
unit iOSapi.MessageUI;
interface
uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Foundation,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
Macapi.QuartzCore,
iOSapi.CocoaTypes,
iOSapi.Foundation,
iOSapi.UIKit;
const
MFMailComposeResultCancelled = 0;
MFMailComposeResultSaved = 1;
MFMailComposeResultSent = 2;
MFMailComposeResultFailed = 3;
MFMailComposeErrorCodeSaveFailed = 0;
MFMailComposeErrorCodeSendFailed = 1;
MessageComposeResultCancelled = 0;
MessageComposeResultSent = 1;
MessageComposeResultFailed = 2;
type
// ===== Forward declarations =====
{$M+}
MFMailComposeViewControllerDelegate = interface;
MFMailComposeViewController = interface;
MFMessageComposeViewControllerDelegate = interface;
MFMessageComposeViewController = interface;
// ===== Framework typedefs =====
{$M+}
MFMailComposeResult = Cardinal;
MFMailComposeErrorCode = Cardinal;
MessageComposeResult = Cardinal;
// ===== Interface declarations =====
MFMailComposeViewControllerClass = interface(UINavigationControllerClass)
['{23041F7D-6F10-4351-BE7C-C606BF9A8165}']
{ class } function canSendMail: Boolean; cdecl;
end;
MFMailComposeViewController = interface(UINavigationController)
['{F4D14FF1-B13C-4BCE-A5BA-84F05CE11E94}']
procedure setMailComposeDelegate(mailComposeDelegate: Pointer); cdecl;
function mailComposeDelegate: Pointer; cdecl;
procedure setSubject(subject: NSString); cdecl;
procedure setToRecipients(toRecipients: NSArray); cdecl;
procedure setCcRecipients(ccRecipients: NSArray); cdecl;
procedure setBccRecipients(bccRecipients: NSArray); cdecl;
procedure setMessageBody(body: NSString; isHTML: Boolean); cdecl;
procedure addAttachmentData(attachment: NSData; mimeType: NSString;
fileName: NSString); cdecl;
end;
TMFMailComposeViewController = class
(TOCGenericImport<MFMailComposeViewControllerClass,
MFMailComposeViewController>)
end;
PMFMailComposeViewController = Pointer;
MFMessageComposeViewControllerClass = interface(UINavigationControllerClass)
['{EDF3ABDC-3B86-4274-804F-2E7B38B9D3BF}']
{ class } function canSendText: Boolean; cdecl;
{ class } function canSendSubject: Boolean; cdecl;
{ class } function canSendAttachments: Boolean; cdecl;
{ class } function isSupportedAttachmentUTI(uti: NSString): Boolean; cdecl;
end;
MFMessageComposeViewController = interface(UINavigationController)
['{658B22D4-708A-4A95-B5F3-DB8B5C4943CF}']
procedure setMessageComposeDelegate(messageComposeDelegate: Pointer); cdecl;
function messageComposeDelegate: Pointer; cdecl;
procedure disableUserAttachments; cdecl;
procedure setRecipients(recipients: NSArray); cdecl;
function recipients: NSArray; cdecl;
procedure setBody(body: NSString); cdecl;
function body: NSString; cdecl;
procedure setSubject(subject: NSString); cdecl;
function subject: NSString; cdecl;
function attachments: NSArray; cdecl;
function addAttachmentURL(attachmentURL: NSURL;
withAlternateFilename: NSString): Boolean; cdecl;
function addAttachmentData(attachmentData: NSData; typeIdentifier: NSString;
fileName: NSString): Boolean; cdecl;
end;
TMFMessageComposeViewController = class
(TOCGenericImport<MFMessageComposeViewControllerClass,
MFMessageComposeViewController>)
end;
PMFMessageComposeViewController = Pointer;
// ===== Protocol declarations =====
MFMailComposeViewControllerDelegate = interface(IObjectiveC)
['{27703958-2E37-4491-8D21-CF7BD14DB724}']
procedure mailComposeController(controller: MFMailComposeViewController;
didFinishWithResult: MFMailComposeResult; error: NSError); cdecl;
end;
MFMessageComposeViewControllerDelegate = interface(IObjectiveC)
['{5B8114E8-DA1B-40FD-9D01-E81BC4B31978}']
procedure messageComposeViewController(controller
: MFMessageComposeViewController;
didFinishWithResult: MessageComposeResult); cdecl;
end;
// ===== Exported string consts =====
function MFMailComposeErrorDomain: NSString;
function MFMessageComposeViewControllerAttachmentURL: NSString;
function MFMessageComposeViewControllerAttachmentAlternateFilename: NSString;
function MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification
: NSString;
function MFMessageComposeViewControllerTextMessageAvailabilityKey: NSString;
// ===== External functions =====
const
libMessageUI = '/System/Library/Frameworks/MessageUI.framework/MessageUI';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
MessageUIModule: THandle;
{$ENDIF IOS}
function MFMailComposeErrorDomain: NSString;
begin
Result := CocoaNSStringConst(libMessageUI, 'MFMailComposeErrorDomain');
end;
function MFMessageComposeViewControllerAttachmentURL: NSString;
begin
Result := CocoaNSStringConst(libMessageUI,
'MFMessageComposeViewControllerAttachmentURL');
end;
function MFMessageComposeViewControllerAttachmentAlternateFilename: NSString;
begin
Result := CocoaNSStringConst(libMessageUI,
'MFMessageComposeViewControllerAttachmentAlternateFilename');
end;
function MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification
: NSString;
begin
Result := CocoaNSStringConst(libMessageUI,
'MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification');
end;
function MFMessageComposeViewControllerTextMessageAvailabilityKey: NSString;
begin
Result := CocoaNSStringConst(libMessageUI,
'MFMessageComposeViewControllerTextMessageAvailabilityKey');
end;
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
MessageUIModule := dlopen(MarshaledAString(libMessageUI), RTLD_LAZY);
finalization
dlclose(MessageUIModule);
{$ENDIF IOS}
end.