Mercurial > projects > dstep
annotate dstep/foundation/NSURLProtocol.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
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.NSURLProtocol; | |
8 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
9 import dstep.foundation.NSData; |
14 | 10 import dstep.foundation.NSError; |
11 import dstep.foundation.NSObject; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
12 import dstep.foundation.NSString; |
14 | 13 import dstep.foundation.NSURLAuthenticationChallenge; |
14 import dstep.foundation.NSURLCache; | |
15 import dstep.foundation.NSURLConnection; | |
16 import dstep.foundation.NSURLRequest; | |
17 import dstep.foundation.NSURLResponse; | |
18 import dstep.objc.bridge.Bridge; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
19 import dstep.objc.objc; |
14 | 20 |
21 class NSURLProtocol : NSObject | |
22 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
23 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
24 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
25 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
26 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
27 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
28 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
29 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
30 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
31 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
32 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
33 } |
14 | 34 |
35 Object initWithRequest (NSURLRequest request, NSCachedURLResponse cachedResponse, INSURLProtocolClient client) | |
36 { | |
37 return invokeObjcSelf!(Object, "initWithRequest:cachedResponse:client:", NSURLRequest, NSCachedURLResponse, INSURLProtocolClient)(request, cachedResponse, client); | |
38 } | |
39 | |
40 this (NSURLRequest request, NSCachedURLResponse cachedResponse, INSURLProtocolClient client) | |
41 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
42 typeof(this).alloc.initWithRequest(request, cachedResponse, client); |
14 | 43 } |
44 | |
45 INSURLProtocolClient client () | |
46 { | |
47 return invokeObjcSelf!(INSURLProtocolClient, "client"); | |
48 } | |
49 | |
50 NSURLRequest request () | |
51 { | |
52 return invokeObjcSelf!(NSURLRequest, "request"); | |
53 } | |
54 | |
55 NSCachedURLResponse cachedResponse () | |
56 { | |
57 return invokeObjcSelf!(NSCachedURLResponse, "cachedResponse"); | |
58 } | |
59 | |
60 static bool canInitWithRequest (NSURLRequest request) | |
61 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
62 return invokeObjcSuperClass!(bool, "canInitWithRequest:", NSURLRequest)(request); |
14 | 63 } |
64 | |
65 static NSURLRequest canonicalRequestForRequest (NSURLRequest request) | |
66 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
67 return invokeObjcSuperClass!(NSURLRequest, "canonicalRequestForRequest:", NSURLRequest)(request); |
14 | 68 } |
69 | |
70 static bool requestIsCacheEquivalent (NSURLRequest a, NSURLRequest b) | |
71 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
72 return invokeObjcSuperClass!(bool, "requestIsCacheEquivalent:toRequest:", NSURLRequest, NSURLRequest)(a, b); |
14 | 73 } |
74 | |
75 void startLoading () | |
76 { | |
77 return invokeObjcSelf!(void, "startLoading"); | |
78 } | |
79 | |
80 void stopLoading () | |
81 { | |
82 return invokeObjcSelf!(void, "stopLoading"); | |
83 } | |
84 | |
85 static Object propertyForKey (NSString key, NSURLRequest request) | |
86 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
87 return invokeObjcSuperClass!(Object, "propertyForKey:inRequest:", NSString, NSURLRequest)(key, request); |
14 | 88 } |
89 | |
90 static void setProperty (Object value, NSString key, NSMutableURLRequest request) | |
91 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
92 return invokeObjcSuperClass!(void, "setProperty:forKey:inRequest:", Object, NSString, NSMutableURLRequest)(value, key, request); |
14 | 93 } |
94 | |
95 static void removePropertyForKey (NSString key, NSMutableURLRequest request) | |
96 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
97 return invokeObjcSuperClass!(void, "removePropertyForKey:inRequest:", NSString, NSMutableURLRequest)(key, request); |
14 | 98 } |
99 | |
100 static bool registerClass (Class protocolClass) | |
101 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
102 return invokeObjcSuperClass!(bool, "registerClass:", Class)(protocolClass); |
14 | 103 } |
104 | |
105 static void unregisterClass (Class protocolClass) | |
106 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
107 return invokeObjcSuperClass!(void, "unregisterClass:", Class)(protocolClass); |
14 | 108 } |
109 } | |
110 | |
111 interface INSURLProtocolClient : INSObject | |
112 { | |
113 void URLProtocol (NSURLProtocol protocol, NSURLRequest request, NSURLResponse redirectResponse); | |
114 void URLProtocol (NSURLProtocol protocol, NSCachedURLResponse cachedResponse); | |
115 void URLProtocol (NSURLProtocol protocol, NSURLResponse response, uint policy); | |
116 void URLProtocol (NSURLProtocol protocol, NSData data); | |
117 void URLProtocolDidFinishLoading (NSURLProtocol protocol); | |
118 void URLProtocol (NSURLProtocol protocol, NSError error); | |
119 void URLProtocol (NSURLProtocol protocol, NSURLAuthenticationChallenge challenge); | |
120 void URLProtocol (NSURLProtocol protocol, NSURLAuthenticationChallenge challenge); | |
121 } | |
122 |