forked from FMXExpress/ios-object-pascal-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iOSapi.Twitter.pas
140 lines (112 loc) · 3.81 KB
/
iOSapi.Twitter.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
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework Twitter
//
unit iOSapi.Twitter;
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.Social,
iOSapi.UIKit;
const
TWRequestMethodGET = SLRequestMethodGET;
TWRequestMethodPOST = SLRequestMethodPOST;
TWRequestMethodDELETE = SLRequestMethodDELETE;
TWTweetComposeViewControllerResultCancelled =
SLComposeViewControllerResultCancelled;
TWTweetComposeViewControllerResultDone = SLComposeViewControllerResultDone;
type
// ===== Forward declarations =====
{$M+}
TWRequest = interface;
TWTweetComposeViewController = interface;
// ===== Framework typedefs =====
{$M+}
NSInteger = Integer;
SLRequestMethod = NSInteger;
TWRequestMethod = SLRequestMethod;
SLRequestHandler = procedure(param1: NSData; param2: NSHTTPURLResponse;
param3: NSError) of object;
TWRequestHandler = SLRequestHandler;
SLComposeViewControllerResult = NSInteger;
TWTweetComposeViewControllerResult = SLComposeViewControllerResult;
SLComposeViewControllerCompletionHandler = procedure
(param1: SLComposeViewControllerResult) of object;
TWTweetComposeViewControllerCompletionHandler =
SLComposeViewControllerCompletionHandler;
// ===== Interface declarations =====
TWRequestClass = interface(NSObjectClass)
['{5BC53F4A-66E0-4178-A352-DF3B7FF01416}']
end;
TWRequest = interface(NSObject)
['{1C968E2E-0CA2-44CC-97B0-7C19EF5C6BD4}']
function initWithURL(url: NSURL; parameters: NSDictionary;
requestMethod: TWRequestMethod): Pointer; cdecl;
procedure setAccount(account: ACAccount); cdecl;
function account: ACAccount; cdecl;
function requestMethod: TWRequestMethod; cdecl;
function url: NSURL; cdecl;
function parameters: NSDictionary; cdecl;
procedure addMultiPartData(data: NSData; withName: NSString;
&type: NSString); cdecl;
function signedURLRequest: NSURLRequest; cdecl;
procedure performRequestWithHandler(handler: TWRequestHandler); cdecl;
end;
TTWRequest = class(TOCGenericImport<TWRequestClass, TWRequest>)
end;
PTWRequest = Pointer;
TWTweetComposeViewControllerClass = interface(UIViewControllerClass)
['{CAEDF7B8-3434-4025-968C-D74C97207A07}']
{ class } function canSendTweet: Boolean; cdecl;
end;
TWTweetComposeViewController = interface(UIViewController)
['{3CAD83D4-171D-446E-AF39-DABF79C46B35}']
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
: TWTweetComposeViewControllerCompletionHandler); cdecl;
function completionHandler
: TWTweetComposeViewControllerCompletionHandler; cdecl;
end;
TTWTweetComposeViewController = class
(TOCGenericImport<TWTweetComposeViewControllerClass,
TWTweetComposeViewController>)
end;
PTWTweetComposeViewController = Pointer;
// ===== External functions =====
const
libTwitter = '/System/Library/Frameworks/Twitter.framework/Twitter';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
TwitterModule: THandle;
{$ENDIF IOS}
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
TwitterModule := dlopen(MarshaledAString(libTwitter), RTLD_LAZY);
finalization
dlclose(TwitterModule);
{$ENDIF IOS}
end.