Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSURLHandle.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.NSURLHandle; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSData; | |
18 import dwt.internal.cocoa.NSInteger; | |
19 import dwt.internal.cocoa.NSObject; | |
20 import dwt.internal.cocoa.NSString; | |
21 import dwt.internal.cocoa.NSURL; | |
22 import dwt.internal.cocoa.OS; | |
23 import objc = dwt.internal.objc.runtime; | |
24 | |
25 enum NSURLHandleStatus : NSUInteger | |
26 { | |
27 NSURLHandleNotLoaded = 0, | |
28 NSURLHandleLoadSucceeded, | |
29 NSURLHandleLoadInProgress, | |
30 NSURLHandleLoadFailed | |
31 } | |
32 | |
33 alias NSURLHandleStatus.NSURLHandleNotLoaded NSURLHandleNotLoaded; | |
34 alias NSURLHandleStatus.NSURLHandleLoadSucceeded NSURLHandleLoadSucceeded; | |
35 alias NSURLHandleStatus.NSURLHandleLoadInProgress NSURLHandleLoadInProgress; | |
36 alias NSURLHandleStatus.NSURLHandleLoadFailed NSURLHandleLoadFailed; | |
37 | |
38 public class NSURLHandle : NSObject | |
39 { | |
40 | |
41 public this () | |
42 { | |
43 super(); | |
44 } | |
45 | |
46 public this (objc.id id) | |
47 { | |
48 super(id); | |
49 } | |
50 | |
51 public static objc.Class URLHandleClassForURL (NSURL anURL) | |
52 { | |
53 return cast(objc.Class) OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_URLHandleClassForURL_1, anURL !is null ? anURL.id : null); | |
54 } | |
55 | |
56 public void addClient (id client) | |
57 { | |
58 OS.objc_msgSend(this.id, OS.sel_addClient_1, client !is null ? client.id : null); | |
59 } | |
60 | |
61 public NSData availableResourceData () | |
62 { | |
63 objc.id result = OS.objc_msgSend(this.id, OS.sel_availableResourceData); | |
64 return result !is null ? new NSData(result) : null; | |
65 } | |
66 | |
67 public void backgroundLoadDidFailWithReason (NSString reason) | |
68 { | |
69 OS.objc_msgSend(this.id, OS.sel_backgroundLoadDidFailWithReason_1, reason !is null ? reason.id : null); | |
70 } | |
71 | |
72 public void beginLoadInBackground () | |
73 { | |
74 OS.objc_msgSend(this.id, OS.sel_beginLoadInBackground); | |
75 } | |
76 | |
77 public static NSURLHandle cachedHandleForURL (NSURL anURL) | |
78 { | |
79 objc.id result = OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_cachedHandleForURL_1, anURL !is null ? anURL.id : null); | |
80 return result !is null ? new NSURLHandle(result) : null; | |
81 } | |
82 | |
83 public static bool canInitWithURL (NSURL anURL) | |
84 { | |
85 return OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_canInitWithURL_1, anURL !is null ? anURL.id : null) !is null; | |
86 } | |
87 | |
88 public void cancelLoadInBackground () | |
89 { | |
90 OS.objc_msgSend(this.id, OS.sel_cancelLoadInBackground); | |
91 } | |
92 | |
93 public void didLoadBytes (NSData newBytes, bool yorn) | |
94 { | |
95 OS.objc_msgSend(this.id, OS.sel_didLoadBytes_1loadComplete_1, newBytes !is null ? newBytes.id : null, yorn); | |
96 } | |
97 | |
98 public void endLoadInBackground () | |
99 { | |
100 OS.objc_msgSend(this.id, OS.sel_endLoadInBackground); | |
101 } | |
102 | |
103 public long expectedResourceDataSize () | |
104 { | |
105 return cast(long) OS.objc_msgSend(this.id, OS.sel_expectedResourceDataSize); | |
106 } | |
107 | |
108 public NSString failureReason () | |
109 { | |
110 objc.id result = OS.objc_msgSend(this.id, OS.sel_failureReason); | |
111 return result !is null ? new NSString(result) : null; | |
112 } | |
113 | |
114 public void flushCachedData () | |
115 { | |
116 OS.objc_msgSend(this.id, OS.sel_flushCachedData); | |
117 } | |
118 | |
119 public id initWithURL (NSURL anURL, bool willCache) | |
120 { | |
121 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithURL_1cached_1, anURL !is null ? anURL.id : null, willCache); | |
122 return result !is null ? new id(result) : null; | |
123 } | |
124 | |
125 public void loadInBackground () | |
126 { | |
127 OS.objc_msgSend(this.id, OS.sel_loadInBackground); | |
128 } | |
129 | |
130 public NSData loadInForeground () | |
131 { | |
132 objc.id result = OS.objc_msgSend(this.id, OS.sel_loadInForeground); | |
133 return result !is null ? new NSData(result) : null; | |
134 } | |
135 | |
136 public id propertyForKey (NSString propertyKey) | |
137 { | |
138 objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyForKey_1, propertyKey !is null ? propertyKey.id : null); | |
139 return result !is null ? new id(result) : null; | |
140 } | |
141 | |
142 public id propertyForKeyIfAvailable (NSString propertyKey) | |
143 { | |
144 objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyForKeyIfAvailable_1, propertyKey !is null ? propertyKey.id : null); | |
145 return result !is null ? new id(result) : null; | |
146 } | |
147 | |
148 public static void registerURLHandleClass (objc.Class anURLHandleSubclass) | |
149 { | |
150 OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_registerURLHandleClass_1, anURLHandleSubclass); | |
151 } | |
152 | |
153 public void removeClient (id client) | |
154 { | |
155 OS.objc_msgSend(this.id, OS.sel_removeClient_1, client !is null ? client.id : null); | |
156 } | |
157 | |
158 public NSData resourceData () | |
159 { | |
160 objc.id result = OS.objc_msgSend(this.id, OS.sel_resourceData); | |
161 return result !is null ? new NSData(result) : null; | |
162 } | |
163 | |
164 public NSURLHandleStatus status () | |
165 { | |
166 return cast(NSURLHandleStatus) OS.objc_msgSend(this.id, OS.sel_status); | |
167 } | |
168 | |
169 public bool writeData (NSData data) | |
170 { | |
171 return OS.objc_msgSend(this.id, OS.sel_writeData_1, data !is null ? data.id : null) !is null; | |
172 } | |
173 | |
174 public bool writeProperty (id propertyValue, NSString propertyKey) | |
175 { | |
176 return OS.objc_msgSend(this.id, OS.sel_writeProperty_1forKey_1, propertyValue !is null ? propertyValue.id : null, | |
177 propertyKey !is null ? propertyKey.id : null) !is null; | |
178 } | |
179 | |
180 } |