comparison dwt/internal/cocoa/NSURLProtocol.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D Programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
13 *******************************************************************************/
14 module dwt.internal.cocoa.NSURLProtocol;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSCachedURLResponse;
18 import dwt.internal.cocoa.NSMutableURLRequest;
19 import dwt.internal.cocoa.NSObject;
20 import dwt.internal.cocoa.NSString;
21 import dwt.internal.cocoa.NSURLRequest;
22 import dwt.internal.cocoa.OS;
23 import objc = dwt.internal.objc.runtime;
24
25 public class NSURLProtocol : NSObject
26 {
27
28 public this ()
29 {
30 super();
31 }
32
33 public this (objc.id id)
34 {
35 super(id);
36 }
37
38 public NSCachedURLResponse cachedResponse ()
39 {
40 objc.id result = OS.objc_msgSend(this.id, OS.sel_cachedResponse);
41 return result !is null ? new NSCachedURLResponse(result) : null;
42 }
43
44 public static bool canInitWithRequest (NSURLRequest request)
45 {
46 return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canInitWithRequest_1, request !is null ? request.id : null) !is null;
47 }
48
49 public static NSURLRequest canonicalRequestForRequest (NSURLRequest request)
50 {
51 objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canonicalRequestForRequest_1, request !is null ? request.id : null);
52 return result !is null ? new NSURLRequest(result) : null;
53 }
54
55 public id client ()
56 {
57 objc.id result = OS.objc_msgSend(this.id, OS.sel_client);
58 return result !is null ? new id(result) : null;
59 }
60
61 public id initWithRequest (NSURLRequest request, NSCachedURLResponse cachedResponse, id client)
62 {
63 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRequest_1cachedResponse_1client_1, request !is null ? request.id : null,
64 cachedResponse !is null ? cachedResponse.id : null, client !is null ? client.id : null);
65 return result !is null ? new id(result) : null;
66 }
67
68 public static id propertyForKey (NSString key, NSURLRequest request)
69 {
70 objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_propertyForKey_1inRequest_1, key !is null ? key.id : null,
71 request !is null ? request.id : null);
72 return result !is null ? new id(result) : null;
73 }
74
75 public static bool registerClass (objc.Class protocolClass)
76 {
77 return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_registerClass_1, protocolClass) !is null;
78 }
79
80 public static void removePropertyForKey (NSString key, NSMutableURLRequest request)
81 {
82 OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_removePropertyForKey_1inRequest_1, key !is null ? key.id : null,
83 request !is null ? request.id : null);
84 }
85
86 public NSURLRequest request ()
87 {
88 objc.id result = OS.objc_msgSend(this.id, OS.sel_request);
89 return result !is null ? new NSURLRequest(result) : null;
90 }
91
92 public static bool requestIsCacheEquivalent (NSURLRequest a, NSURLRequest b)
93 {
94 return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_requestIsCacheEquivalent_1toRequest_1, a !is null ? a.id : null,
95 b !is null ? b.id : null) !is null;
96 }
97
98 public static void setProperty (id value, NSString key, NSMutableURLRequest request)
99 {
100 OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_setProperty_1forKey_1inRequest_1, value !is null ? value.id : null,
101 key !is null ? key.id : null, request !is null ? request.id : null);
102 }
103
104 public void startLoading ()
105 {
106 OS.objc_msgSend(this.id, OS.sel_startLoading);
107 }
108
109 public void stopLoading ()
110 {
111 OS.objc_msgSend(this.id, OS.sel_stopLoading);
112 }
113
114 public static void unregisterClass (objc.Class protocolClass)
115 {
116 OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_unregisterClass_1, protocolClass);
117 }
118
119 }