forked from FMXExpress/ios-object-pascal-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iOSapi.CoreTelephony.pas
332 lines (260 loc) · 8.74 KB
/
iOSapi.CoreTelephony.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework CoreTelephony
//
unit iOSapi.CoreTelephony;
interface
uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Foundation,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
Macapi.QuartzCore,
iOSapi.CocoaTypes,
iOSapi.Foundation;
const
kCTErrorDomainNoError = 0;
kCTErrorDomainPOSIX = 1;
kCTErrorDomainMach = 2;
kCTCellularDataRestrictedStateUnknown = 0;
kCTCellularDataRestricted = 1;
kCTCellularDataNotRestricted = 2;
type
// ===== Forward declarations =====
{$M+}
CTCall = interface;
CTCallCenter = interface;
CTCarrier = interface;
CTCellularData = interface;
CTSubscriber = interface;
CTSubscriberInfo = interface;
CTTelephonyNetworkInfo = interface;
// ===== Framework typedefs =====
{$M+}
CTError = record
domain: Int32;
error: Int32;
end;
PCTError = ^CTError;
TCoreTelephonyCallEventHandler = procedure(param1: CTCall) of object;
NSUInteger = Cardinal;
CTCellularDataRestrictedState = NSUInteger;
CellularDataRestrictionDidUpdateNotifier = procedure
(param1: CTCellularDataRestrictedState) of object;
TCoreTelephonySubscriberCellularProviderDidUpdateNotifier = procedure
(param1: CTCarrier) of object;
// ===== Interface declarations =====
CTCallClass = interface(NSObjectClass)
['{7333E325-C817-4441-9597-11429D0BACCA}']
end;
CTCall = interface(NSObject)
['{94C077D3-2A92-444B-9CB1-54A9C7114131}']
function callState: NSString; cdecl;
function callID: NSString; cdecl;
end;
TCTCall = class(TOCGenericImport<CTCallClass, CTCall>)
end;
PCTCall = Pointer;
CTCallCenterClass = interface(NSObjectClass)
['{8A3FDBD1-343B-403C-AD0C-3812FF0E17F8}']
end;
CTCallCenter = interface(NSObject)
['{A0D57431-40AD-4832-A8B3-FCF236AFDBD6}']
function currentCalls: NSSet; cdecl;
procedure setCallEventHandler(callEventHandler
: TCoreTelephonyCallEventHandler); cdecl;
function callEventHandler: TCoreTelephonyCallEventHandler; cdecl;
end;
TCTCallCenter = class(TOCGenericImport<CTCallCenterClass, CTCallCenter>)
end;
PCTCallCenter = Pointer;
CTCarrierClass = interface(NSObjectClass)
['{C2D9CBAA-D783-488B-8638-E2D02FACC836}']
end;
CTCarrier = interface(NSObject)
['{A5F148CA-6205-44A4-A8EA-D9F3766A4240}']
function carrierName: NSString; cdecl;
function mobileCountryCode: NSString; cdecl;
function mobileNetworkCode: NSString; cdecl;
function isoCountryCode: NSString; cdecl;
function allowsVOIP: Boolean; cdecl;
end;
TCTCarrier = class(TOCGenericImport<CTCarrierClass, CTCarrier>)
end;
PCTCarrier = Pointer;
CTCellularDataClass = interface(NSObjectClass)
['{B140FD4E-8197-4C0A-96B4-E4B4054AF4C0}']
end;
CTCellularData = interface(NSObject)
['{50A49764-F89C-4042-BC23-7FA90ACB13B3}']
procedure setCellularDataRestrictionDidUpdateNotifier
(CellularDataRestrictionDidUpdateNotifier
: CellularDataRestrictionDidUpdateNotifier); cdecl;
function CellularDataRestrictionDidUpdateNotifier
: CellularDataRestrictionDidUpdateNotifier; cdecl;
function restrictedState: CTCellularDataRestrictedState; cdecl;
end;
TCTCellularData = class(TOCGenericImport<CTCellularDataClass, CTCellularData>)
end;
PCTCellularData = Pointer;
CTSubscriberClass = interface(NSObjectClass)
['{CBC3E2BE-DE15-418C-84EF-62E564258E04}']
end;
CTSubscriber = interface(NSObject)
['{16467BE6-040D-4693-BACA-D0C48B50326F}']
function carrierToken: NSData; cdecl;
end;
TCTSubscriber = class(TOCGenericImport<CTSubscriberClass, CTSubscriber>)
end;
PCTSubscriber = Pointer;
CTSubscriberInfoClass = interface(NSObjectClass)
['{5A1B2051-7BFD-4C90-A337-BBEA9666380F}']
{ class } function subscriber: CTSubscriber; cdecl;
end;
CTSubscriberInfo = interface(NSObject)
['{F7FF8555-0158-456A-8147-D179191E7DF7}']
end;
TCTSubscriberInfo = class(TOCGenericImport<CTSubscriberInfoClass,
CTSubscriberInfo>)
end;
PCTSubscriberInfo = Pointer;
CTTelephonyNetworkInfoClass = interface(NSObjectClass)
['{7F830403-94F6-4C9E-8107-293AA4ECDC1B}']
end;
CTTelephonyNetworkInfo = interface(NSObject)
['{7D3F1DB8-199D-4802-B5C0-6C55E8500C80}']
function subscriberCellularProvider: CTCarrier; cdecl;
procedure setSubscriberCellularProviderDidUpdateNotifier
(subscriberCellularProviderDidUpdateNotifier
: TCoreTelephonySubscriberCellularProviderDidUpdateNotifier); cdecl;
function subscriberCellularProviderDidUpdateNotifier
: TCoreTelephonySubscriberCellularProviderDidUpdateNotifier; cdecl;
function currentRadioAccessTechnology: NSString; cdecl;
end;
TCTTelephonyNetworkInfo = class(TOCGenericImport<CTTelephonyNetworkInfoClass,
CTTelephonyNetworkInfo>)
end;
PCTTelephonyNetworkInfo = Pointer;
// ===== Exported string consts =====
function CTCallStateDialing: NSString;
function CTCallStateIncoming: NSString;
function CTCallStateConnected: NSString;
function CTCallStateDisconnected: NSString;
function CTSubscriberTokenRefreshed: NSString;
function CTRadioAccessTechnologyDidChangeNotification: NSString;
function CTRadioAccessTechnologyGPRS: NSString;
function CTRadioAccessTechnologyEdge: NSString;
function CTRadioAccessTechnologyWCDMA: NSString;
function CTRadioAccessTechnologyHSDPA: NSString;
function CTRadioAccessTechnologyHSUPA: NSString;
function CTRadioAccessTechnologyCDMA1x: NSString;
function CTRadioAccessTechnologyCDMAEVDORev0: NSString;
function CTRadioAccessTechnologyCDMAEVDORevA: NSString;
function CTRadioAccessTechnologyCDMAEVDORevB: NSString;
function CTRadioAccessTechnologyeHRPD: NSString;
function CTRadioAccessTechnologyLTE: NSString;
// ===== External functions =====
const
libCoreTelephony =
'/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
CoreTelephonyModule: THandle;
{$ENDIF IOS}
function CTCallStateDialing: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTCallStateDialing');
end;
function CTCallStateIncoming: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTCallStateIncoming');
end;
function CTCallStateConnected: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTCallStateConnected');
end;
function CTCallStateDisconnected: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTCallStateDisconnected');
end;
function CTSubscriberTokenRefreshed: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTSubscriberTokenRefreshed');
end;
function CTRadioAccessTechnologyDidChangeNotification: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyDidChangeNotification');
end;
function CTRadioAccessTechnologyGPRS: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTRadioAccessTechnologyGPRS');
end;
function CTRadioAccessTechnologyEdge: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTRadioAccessTechnologyEdge');
end;
function CTRadioAccessTechnologyWCDMA: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyWCDMA');
end;
function CTRadioAccessTechnologyHSDPA: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyHSDPA');
end;
function CTRadioAccessTechnologyHSUPA: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyHSUPA');
end;
function CTRadioAccessTechnologyCDMA1x: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyCDMA1x');
end;
function CTRadioAccessTechnologyCDMAEVDORev0: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyCDMAEVDORev0');
end;
function CTRadioAccessTechnologyCDMAEVDORevA: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyCDMAEVDORevA');
end;
function CTRadioAccessTechnologyCDMAEVDORevB: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyCDMAEVDORevB');
end;
function CTRadioAccessTechnologyeHRPD: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony,
'CTRadioAccessTechnologyeHRPD');
end;
function CTRadioAccessTechnologyLTE: NSString;
begin
Result := CocoaNSStringConst(libCoreTelephony, 'CTRadioAccessTechnologyLTE');
end;
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
CoreTelephonyModule := dlopen(MarshaledAString(libCoreTelephony), RTLD_LAZY);
finalization
dlclose(CoreTelephonyModule);
{$ENDIF IOS}
end.