-
Notifications
You must be signed in to change notification settings - Fork 12
/
iOSapi.Social.pas
236 lines (191 loc) · 7 KB
/
iOSapi.Social.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
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework Social
//
unit iOSapi.Social;
interface
uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Foundation,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
Macapi.QuartzCore,
iOSapi.Accounts,
iOSapi.CocoaTypes,
iOSapi.Foundation,
iOSapi.UIKit;
const
SLComposeViewControllerResultCancelled = 0;
SLComposeViewControllerResultDone = 1;
SLRequestMethodGET = 0;
SLRequestMethodPOST = 1;
SLRequestMethodDELETE = 2;
SLRequestMethodPUT = 3;
type
// ===== Forward declarations =====
{$M+}
SLComposeServiceViewController = interface;
SLComposeSheetConfigurationItem = interface;
SLComposeViewController = interface;
SLRequest = interface;
// ===== Framework typedefs =====
{$M+}
SLComposeSheetConfigurationItemTapHandler = procedure() of object;
NSInteger = Integer;
SLComposeViewControllerResult = NSInteger;
SLComposeViewControllerCompletionHandler = procedure
(param1: SLComposeViewControllerResult) of object;
SLRequestMethod = NSInteger;
SLRequestHandler = procedure(param1: NSData; param2: NSHTTPURLResponse;
param3: NSError) of object;
// ===== Interface declarations =====
SLComposeServiceViewControllerClass = interface(UIViewControllerClass)
['{F5A34022-CBE7-426B-B8DB-BE0BA9D7DA87}']
end;
SLComposeServiceViewController = interface(UIViewController)
['{920A2E0F-042F-46AE-AA56-9F4C06227F92}']
procedure presentationAnimationDidFinish; cdecl;
function textView: UITextView; cdecl;
function contentText: NSString; cdecl;
procedure setPlaceholder(placeholder: NSString); cdecl;
function placeholder: NSString; cdecl;
procedure didSelectPost; cdecl;
procedure didSelectCancel; cdecl;
procedure cancel; cdecl;
function isContentValid: Boolean; cdecl;
procedure validateContent; cdecl;
procedure setCharactersRemaining(charactersRemaining: NSNumber); cdecl;
function charactersRemaining: NSNumber; cdecl;
function configurationItems: NSArray; cdecl;
procedure reloadConfigurationItems; cdecl;
procedure pushConfigurationViewController(viewController
: UIViewController); cdecl;
procedure popConfigurationViewController; cdecl;
function loadPreviewView: UIView; cdecl;
procedure setAutoCompletionViewController(autoCompletionViewController
: UIViewController); cdecl;
function autoCompletionViewController: UIViewController; cdecl;
end;
TSLComposeServiceViewController = class
(TOCGenericImport<SLComposeServiceViewControllerClass,
SLComposeServiceViewController>)
end;
PSLComposeServiceViewController = Pointer;
SLComposeSheetConfigurationItemClass = interface(NSObjectClass)
['{6E957D2C-209A-43F5-A6CE-FB63F644BD71}']
end;
SLComposeSheetConfigurationItem = interface(NSObject)
['{9048ABD2-8DBC-4BC6-A180-9B78C80E0869}']
function init: Pointer { instancetype }; cdecl;
procedure setTitle(title: NSString); cdecl;
function title: NSString; cdecl;
procedure setValue(value: NSString); cdecl;
function value: NSString; cdecl;
procedure setValuePending(valuePending: Boolean); cdecl;
function valuePending: Boolean; cdecl;
procedure setTapHandler(tapHandler
: SLComposeSheetConfigurationItemTapHandler); cdecl;
function tapHandler: SLComposeSheetConfigurationItemTapHandler; cdecl;
end;
TSLComposeSheetConfigurationItem = class
(TOCGenericImport<SLComposeSheetConfigurationItemClass,
SLComposeSheetConfigurationItem>)
end;
PSLComposeSheetConfigurationItem = Pointer;
SLComposeViewControllerClass = interface(UIViewControllerClass)
['{BEA6AF8C-4929-4A2E-A2D4-3E2AF1898091}']
{ class } function isAvailableForServiceType(serviceType: NSString)
: Boolean; cdecl;
{ class } function composeViewControllerForServiceType
(serviceType: NSString): SLComposeViewController; cdecl;
end;
SLComposeViewController = interface(UIViewController)
['{134E76EC-B207-4012-AD25-B29BA6FAC107}']
function serviceType: NSString; cdecl;
function setInitialText(text: NSString): Boolean; cdecl;
function addImage(image: UIImage): Boolean; cdecl;
function removeAllImages: Boolean; cdecl;
function addURL(url: NSURL): Boolean; cdecl;
function removeAllURLs: Boolean; cdecl;
procedure setCompletionHandler(completionHandler
: SLComposeViewControllerCompletionHandler); cdecl;
function completionHandler: SLComposeViewControllerCompletionHandler; cdecl;
end;
TSLComposeViewController = class
(TOCGenericImport<SLComposeViewControllerClass, SLComposeViewController>)
end;
PSLComposeViewController = Pointer;
SLRequestClass = interface(NSObjectClass)
['{383E3F40-6250-40A7-965D-6EFA639BF97C}']
{ class } function requestForServiceType(serviceType: NSString;
requestMethod: SLRequestMethod; url: NSURL; parameters: NSDictionary)
: SLRequest; cdecl;
end;
SLRequest = interface(NSObject)
['{40C20D17-36ED-42DB-810F-4251BD3A66BA}']
procedure setAccount(account: ACAccount); cdecl;
function account: ACAccount; cdecl;
function requestMethod: SLRequestMethod; cdecl;
function url: NSURL; cdecl;
function parameters: NSDictionary; cdecl;
procedure addMultipartData(data: NSData; withName: NSString;
&type: NSString; filename: NSString); cdecl;
function preparedURLRequest: NSURLRequest; cdecl;
procedure performRequestWithHandler(handler: SLRequestHandler); cdecl;
end;
TSLRequest = class(TOCGenericImport<SLRequestClass, SLRequest>)
end;
PSLRequest = Pointer;
// ===== Exported string consts =====
function SLServiceTypeTwitter: NSString;
function SLServiceTypeFacebook: NSString;
function SLServiceTypeSinaWeibo: NSString;
function SLServiceTypeTencentWeibo: NSString;
function SLServiceTypeLinkedIn: NSString;
// ===== External functions =====
const
libSocial = '/System/Library/Frameworks/Social.framework/Social';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
SocialModule: THandle;
{$ENDIF IOS}
function SLServiceTypeTwitter: NSString;
begin
Result := CocoaNSStringConst(libSocial, 'SLServiceTypeTwitter');
end;
function SLServiceTypeFacebook: NSString;
begin
Result := CocoaNSStringConst(libSocial, 'SLServiceTypeFacebook');
end;
function SLServiceTypeSinaWeibo: NSString;
begin
Result := CocoaNSStringConst(libSocial, 'SLServiceTypeSinaWeibo');
end;
function SLServiceTypeTencentWeibo: NSString;
begin
Result := CocoaNSStringConst(libSocial, 'SLServiceTypeTencentWeibo');
end;
function SLServiceTypeLinkedIn: NSString;
begin
Result := CocoaNSStringConst(libSocial, 'SLServiceTypeLinkedIn');
end;
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
SocialModule := dlopen(MarshaledAString(libSocial), RTLD_LAZY);
finalization
dlclose(SocialModule);
{$ENDIF IOS}
end.