-
Notifications
You must be signed in to change notification settings - Fork 12
/
iOSapi.ExternalAccessory.pas
206 lines (166 loc) · 6.25 KB
/
iOSapi.ExternalAccessory.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
200
201
202
203
204
205
206
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework ExternalAccessory
//
unit iOSapi.ExternalAccessory;
interface
uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Foundation,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
Macapi.QuartzCore,
iOSapi.CocoaTypes,
iOSapi.Foundation;
const
EAConnectionIDNone = 0;
EABluetoothAccessoryPickerAlreadyConnected = 0;
EABluetoothAccessoryPickerResultNotFound = 1;
EABluetoothAccessoryPickerResultCancelled = 2;
EABluetoothAccessoryPickerResultFailed = 3;
EAWiFiUnconfiguredAccessoryPropertySupportsAirPlay = (1 shl 0);
EAWiFiUnconfiguredAccessoryPropertySupportsAirPrint = (1 shl 1);
EAWiFiUnconfiguredAccessoryPropertySupportsHomeKit = (1 shl 2);
EAWiFiUnconfiguredAccessoryBrowserStateWiFiUnavailable = 0;
EAWiFiUnconfiguredAccessoryBrowserStateStopped = 1;
EAWiFiUnconfiguredAccessoryBrowserStateSearching = 2;
EAWiFiUnconfiguredAccessoryBrowserStateConfiguring = 3;
EAWiFiUnconfiguredAccessoryConfigurationStatusSuccess = 0;
EAWiFiUnconfiguredAccessoryConfigurationStatusUserCancelledConfiguration = 1;
EAWiFiUnconfiguredAccessoryConfigurationStatusFailed = 2;
type
// ===== Forward declarations =====
{$M+}
EAAccessoryDelegate = interface;
EAWiFiUnconfiguredAccessory = interface;
EAWiFiUnconfiguredAccessoryBrowserDelegate = interface;
EAWiFiUnconfiguredAccessoryBrowser = interface;
// ===== Framework typedefs =====
{$M+}
NSInteger = Integer;
EABluetoothAccessoryPickerErrorCode = NSInteger;
EABluetoothAccessoryPickerCompletion = procedure(param1: NSError) of object;
NSUInteger = Cardinal;
EAWiFiUnconfiguredAccessoryProperties = NSUInteger;
EAWiFiUnconfiguredAccessoryBrowserState = NSInteger;
EAWiFiUnconfiguredAccessoryConfigurationStatus = NSInteger;
dispatch_queue_t = Pointer;
// ===== Interface declarations =====
EAWiFiUnconfiguredAccessoryClass = interface(NSObjectClass)
['{2FAC18D8-549D-4B25-8AC8-9C3535207230}']
end;
EAWiFiUnconfiguredAccessory = interface(NSObject)
['{1395986B-793F-4F40-8745-30614F04B2FD}']
function name: NSString; cdecl;
function manufacturer: NSString; cdecl;
function model: NSString; cdecl;
function ssid: NSString; cdecl;
function macAddress: NSString; cdecl;
function properties: EAWiFiUnconfiguredAccessoryProperties; cdecl;
end;
TEAWiFiUnconfiguredAccessory = class
(TOCGenericImport<EAWiFiUnconfiguredAccessoryClass,
EAWiFiUnconfiguredAccessory>)
end;
PEAWiFiUnconfiguredAccessory = Pointer;
EAWiFiUnconfiguredAccessoryBrowserClass = interface(NSObjectClass)
['{912FC18C-57E2-4948-84FD-7D3E12A37ED1}']
end;
EAWiFiUnconfiguredAccessoryBrowser = interface(NSObject)
['{9CED06A9-BB97-43E2-8F86-DD1FA0C6EA5A}']
procedure setDelegate(delegate: Pointer); cdecl;
function delegate: Pointer; cdecl;
function unconfiguredAccessories: NSSet; cdecl;
function initWithDelegate(delegate: Pointer; queue: dispatch_queue_t)
: Pointer { instancetype }; cdecl;
procedure startSearchingForUnconfiguredAccessoriesMatchingPredicate
(predicate: NSPredicate); cdecl;
procedure stopSearchingForUnconfiguredAccessories; cdecl;
procedure configureAccessory(accessory: EAWiFiUnconfiguredAccessory;
withConfigurationUIOnViewController: UIViewController); cdecl;
end;
TEAWiFiUnconfiguredAccessoryBrowser = class
(TOCGenericImport<EAWiFiUnconfiguredAccessoryBrowserClass,
EAWiFiUnconfiguredAccessoryBrowser>)
end;
PEAWiFiUnconfiguredAccessoryBrowser = Pointer;
// ===== Protocol declarations =====
EAAccessoryDelegate = interface(IObjectiveC)
['{5A05CE63-6708-4989-8E13-852619C56D3B}']
procedure accessoryDidDisconnect(accessory: Pointer); cdecl;
end;
EAWiFiUnconfiguredAccessoryBrowserDelegate = interface(IObjectiveC)
['{2F6ED635-D17A-4EA3-BEF8-5C2BCDA526CB}']
[MethodName('accessoryBrowser:didUpdateState:')]
procedure accessoryBrowserDidUpdateState
(browser: EAWiFiUnconfiguredAccessoryBrowser;
didUpdateState: EAWiFiUnconfiguredAccessoryBrowserState); cdecl;
[MethodName('accessoryBrowser:didFindUnconfiguredAccessories:')]
procedure accessoryBrowserDidFindUnconfiguredAccessories
(browser: EAWiFiUnconfiguredAccessoryBrowser;
didFindUnconfiguredAccessories: NSSet); cdecl;
[MethodName('accessoryBrowser:didRemoveUnconfiguredAccessories:')]
procedure accessoryBrowserDidRemoveUnconfiguredAccessories
(browser: EAWiFiUnconfiguredAccessoryBrowser;
didRemoveUnconfiguredAccessories: NSSet); cdecl;
[MethodName('accessoryBrowser:didFinishConfiguringAccessory:withStatus:')]
procedure accessoryBrowserDidFinishConfiguringAccessoryWithStatus
(browser: EAWiFiUnconfiguredAccessoryBrowser;
didFinishConfiguringAccessory: EAWiFiUnconfiguredAccessory;
withStatus: EAWiFiUnconfiguredAccessoryConfigurationStatus); cdecl;
end;
// ===== Exported string consts =====
function NSString: Pointer;
function NSString: Pointer;
function NSString: Pointer;
function NSString: Pointer;
function NSString: Pointer;
// ===== External functions =====
const
libExternalAccessory =
'/System/Library/Frameworks/ExternalAccessory.framework/ExternalAccessory';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
ExternalAccessoryModule: THandle;
{$ENDIF IOS}
function NSString: Pointer;
begin
Result := CocoaPointerConst(libExternalAccessory, 'NSString');
end;
function NSString: Pointer;
begin
Result := CocoaPointerConst(libExternalAccessory, 'NSString');
end;
function NSString: Pointer;
begin
Result := CocoaPointerConst(libExternalAccessory, 'NSString');
end;
function NSString: Pointer;
begin
Result := CocoaPointerConst(libExternalAccessory, 'NSString');
end;
function NSString: Pointer;
begin
Result := CocoaPointerConst(libExternalAccessory, 'NSString');
end;
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
ExternalAccessoryModule := dlopen(MarshaledAString(libExternalAccessory),
RTLD_LAZY);
finalization
dlclose(ExternalAccessoryModule);
{$ENDIF IOS}
end.