forked from FMXExpress/ios-object-pascal-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiOSapi.SafariServices.pas
170 lines (130 loc) · 4.58 KB
/
iOSapi.SafariServices.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
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework SafariServices
//
unit iOSapi.SafariServices;
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
SFContentBlockerNoExtensionFound = 1;
SFContentBlockerNoAttachmentFound = 2;
SFContentBlockerLoadingInterrupted = 3;
SSReadingListErrorURLSchemeNotAllowed = 1;
type
// ===== Forward declarations =====
{$M+}
SFContentBlockerManager = interface;
SFSafariViewControllerDelegate = interface;
SFSafariViewController = interface;
SSReadingList = interface;
// ===== Framework typedefs =====
{$M+}
NSInteger = Integer;
SFContentBlockerErrorCode = NSInteger;
TSafariServicesCompletionHandler = procedure(param1: NSError) of object;
SSReadingListErrorCode = NSInteger;
// ===== Interface declarations =====
SFContentBlockerManagerClass = interface(NSObjectClass)
['{94BF17BD-4DA7-4446-B327-57F28622A166}']
{ class } procedure reloadContentBlockerWithIdentifier(identifier: NSString;
completionHandler: TSafariServicesCompletionHandler); cdecl;
end;
SFContentBlockerManager = interface(NSObject)
['{7401F107-850D-4736-A9F5-745E56E93901}']
end;
TSFContentBlockerManager = class
(TOCGenericImport<SFContentBlockerManagerClass, SFContentBlockerManager>)
end;
PSFContentBlockerManager = Pointer;
SFSafariViewControllerClass = interface(UIViewControllerClass)
['{42C51848-7D34-4D7B-A36C-90F69FF006C4}']
end;
SFSafariViewController = interface(UIViewController)
['{127A8D1E-D068-432D-975E-C1246F49EB92}']
procedure setDelegate(delegate: Pointer); cdecl;
function delegate: Pointer; cdecl;
[MethodName('initWithURL:entersReaderIfAvailable:')]
function initWithURLEntersReaderIfAvailable(URL: NSURL;
entersReaderIfAvailable: Boolean): Pointer { instancetype }; cdecl;
[MethodName('initWithURL:')]
function initWithURL(URL: NSURL): Pointer { instancetype }; cdecl;
end;
TSFSafariViewController = class(TOCGenericImport<SFSafariViewControllerClass,
SFSafariViewController>)
end;
PSFSafariViewController = Pointer;
SSReadingListClass = interface(NSObjectClass)
['{BD663A99-430E-4FFE-B55B-B2BA1BF01C90}']
{ class } function defaultReadingList: SSReadingList; cdecl;
{ class } function supportsURL(URL: NSURL): Boolean; cdecl;
end;
SSReadingList = interface(NSObject)
['{995BDDFF-AD60-425F-AF83-D7D7DF36EB2E}']
function addReadingListItemWithURL(URL: NSURL; title: NSString;
previewText: NSString; error: NSError): Boolean; cdecl;
end;
TSSReadingList = class(TOCGenericImport<SSReadingListClass, SSReadingList>)
end;
PSSReadingList = Pointer;
// ===== Protocol declarations =====
SFSafariViewControllerDelegate = interface(IObjectiveC)
['{2192FE6E-19BD-4494-828F-84FC6212C98E}']
[MethodName('safariViewController:activityItemsForURL:title:')]
function safariViewControllerActivityItemsForURLTitle
(controller: SFSafariViewController; activityItemsForURL: NSURL;
title: NSString): NSArray; cdecl;
procedure safariViewControllerDidFinish(controller
: SFSafariViewController); cdecl;
[MethodName('safariViewController:didCompleteInitialLoad:')]
procedure safariViewControllerDidCompleteInitialLoad
(controller: SFSafariViewController;
didCompleteInitialLoad: Boolean); cdecl;
end;
// ===== Exported string consts =====
function SFContentBlockerErrorDomain: NSString;
function SSReadingListErrorDomain: NSString;
// ===== External functions =====
const
libSafariServices =
'/System/Library/Frameworks/SafariServices.framework/SafariServices';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
SafariServicesModule: THandle;
{$ENDIF IOS}
function SFContentBlockerErrorDomain: NSString;
begin
Result := CocoaNSStringConst(libSafariServices,
'SFContentBlockerErrorDomain');
end;
function SSReadingListErrorDomain: NSString;
begin
Result := CocoaNSStringConst(libSafariServices, 'SSReadingListErrorDomain');
end;
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
SafariServicesModule := dlopen(MarshaledAString(libSafariServices), RTLD_LAZY);
finalization
dlclose(SafariServicesModule);
{$ENDIF IOS}
end.