Mercurial > projects > dstep
annotate dstep/foundation/NSURLConnection.d @ 15:7ff919f595d5
Added the Foundation framework, again
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:31:48 +0200 |
parents | 89f3c3ef1fd2 |
children | 19885b43130e |
rev | line source |
---|---|
14 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSURLConnection; | |
8 | |
9 import dstep.AvailabilityMacros; | |
10 import dstep.foundation.NSCachedURLResponse; | |
11 import dstep.foundation.NSData; | |
12 import dstep.foundation.NSError; | |
13 import dstep.foundation.NSObject; | |
14 import dstep.foundation.NSRunLoop; | |
15 import dstep.foundation.NSURLAuthenticationChallenge; | |
16 import dstep.foundation.NSURLConnectionInternal; | |
17 import dstep.foundation.NSURLRequest; | |
18 import dstep.foundation.NSURLResponse; | |
19 import dstep.objc.bridge.Bridge; | |
20 import dstep.objc.objc : id; | |
21 | |
22 class NSURLConnection : NSObject | |
23 { | |
24 mixin ObjcWrap; | |
25 mixin TNSURLConnectionSynchronousLoading; | |
26 | |
27 static bool canHandleRequest (NSURLRequest request) | |
28 { | |
29 return invokeObjcSelfClass!(bool, "canHandleRequest:", NSURLRequest)(request); | |
30 } | |
31 | |
32 static NSURLConnection connectionWithRequest (NSURLRequest request, Object delegate_) | |
33 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
34 return invokeObjcSelfClass!(NSURLConnection, "connectionWithRequest:delegate:", NSURLRequest, Object)(request, delegate_); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
35 } |
14 | 36 |
37 Object initWithRequest (NSURLRequest request, Object delegate_) | |
38 { | |
39 return invokeObjcSelf!(Object, "initWithRequest:delegate:", NSURLRequest, Object)(request, delegate_); | |
40 } | |
41 | |
42 this (NSURLRequest request, Object delegate_) | |
43 { | |
44 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
45 id result = Bridge.invokeObjcMethod!(id, "initWithRequest:delegate:", NSURLRequest, Object)(objcObject, request, delegate_); | |
46 | |
47 if (result) | |
48 objcObject = ret; | |
49 | |
50 dObject = this; | |
51 } | |
52 | |
53 Object initWithRequest (NSURLRequest request, Object delegate_, bool startImmediately) | |
54 { | |
55 return invokeObjcSelf!(Object, "initWithRequest:delegate:startImmediately:", NSURLRequest, Object, bool)(request, delegate_, startImmediately); | |
56 } | |
57 | |
58 this (NSURLRequest request, Object delegate_, bool startImmediately) | |
59 { | |
60 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
61 id result = Bridge.invokeObjcMethod!(id, "initWithRequest:delegate:startImmediately:", NSURLRequest, Object, bool)(objcObject, request, delegate_, startImmediately); | |
62 | |
63 if (result) | |
64 objcObject = ret; | |
65 | |
66 dObject = this; | |
67 } | |
68 | |
69 void start () | |
70 { | |
71 return invokeObjcSelf!(void, "start"); | |
72 } | |
73 | |
74 void cancel () | |
75 { | |
76 return invokeObjcSelf!(void, "cancel"); | |
77 } | |
78 | |
79 void scheduleInRunLoop (NSRunLoop aRunLoop, NSString mode) | |
80 { | |
81 return invokeObjcSelf!(void, "scheduleInRunLoop:forMode:", NSRunLoop, NSString)(aRunLoop, mode); | |
82 } | |
83 | |
84 void unscheduleFromRunLoop (NSRunLoop aRunLoop, NSString mode) | |
85 { | |
86 return invokeObjcSelf!(void, "unscheduleFromRunLoop:forMode:", NSRunLoop, NSString)(aRunLoop, mode); | |
87 } | |
88 } | |
89 | |
90 template TNSURLConnectionDelegate () | |
91 { | |
92 NSURLRequest connection (NSURLConnection connection, NSURLRequest request, NSURLResponse response); | |
93 void connection (NSURLConnection connection, NSURLAuthenticationChallenge challenge); | |
94 void connection (NSURLConnection connection, NSURLAuthenticationChallenge challenge); | |
95 void connection (NSURLConnection connection, NSURLResponse response); | |
96 void connection (NSURLConnection connection, NSData data); | |
97 void connectionDidFinishLoading (NSURLConnection connection); | |
98 void connection (NSURLConnection connection, NSError error); | |
99 NSCachedURLResponse connection (NSURLConnection connection, NSCachedURLResponse cachedResponse); | |
100 } | |
101 | |
102 template TNSURLConnectionSynchronousLoading () | |
103 { | |
104 static NSData sendSynchronousRequest (NSURLRequest request, NSURLResponse** response, NSError** error) | |
105 { | |
106 return invokeObjcSelfClass!(NSData, "sendSynchronousRequest:returningResponse:error:", NSURLRequest, NSURLResponse**, NSError**)(request, response, error); | |
107 } | |
108 } | |
109 |